Skip to content

Commit

Permalink
Changed the prototype of osl_get_attribute callback in liboslexec (#1404
Browse files Browse the repository at this point in the history
)

Changed the prototype of osl_get_attribute callback in liboslexec in
order it takes a copy of the attribute TypeDesc casted into a long long
instead of taking a pointer to it. This allows to make it work properly
on GPU else we have an invalid pointer.

Signed-off-by: nicolas <[email protected]>
  • Loading branch information
ix-nico authored Sep 14, 2021
1 parent 879545c commit 22105d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/liboslexec/builtindecl.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ DECL (osl_range_check, "iiiXXXiXiXX")
DECL (osl_range_check_err, "iiiXXXiXiXX")
DECL (osl_naninf_check, "xiXiXXiXiiX")
DECL (osl_uninit_check, "xLXXXiXiXXiXiXii")
DECL (osl_get_attribute, "iXiXXiiXX")
DECL (osl_get_attribute, "iXiXXiiLX")
DECL (osl_bind_interpolated_param, "iXXLiXiXiXi")
DECL (osl_get_texture_options, "XX");
DECL (osl_get_noise_options, "XX");
Expand Down
4 changes: 2 additions & 2 deletions src/liboslexec/llvm_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2976,7 +2976,7 @@ LLVMGEN (llvm_gen_getattribute)
// We'll pass the destination's attribute type directly to the
// RenderServices callback so that the renderer can perform any
// necessary conversions from its internal format to OSL's.
const TypeDesc* dest_type = &Destination.typespec().simpletype();
TypeDesc dest_type = Destination.typespec().simpletype();

llvm::Value * args[] = {
rop.sg_void_ptr(),
Expand All @@ -2985,7 +2985,7 @@ LLVMGEN (llvm_gen_getattribute)
rop.llvm_load_value (Attribute),
rop.ll.constant ((int)array_lookup),
rop.llvm_load_value (Index),
rop.ll.constant_ptr ((void *) dest_type),
rop.ll.constant (dest_type),
rop.llvm_void_ptr (Destination),
};
llvm::Value *r = rop.ll.call_function ("osl_get_attribute", args);
Expand Down
4 changes: 2 additions & 2 deletions src/liboslexec/shadingsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4189,7 +4189,7 @@ OSL_SHADEOP int osl_get_attribute(void *sg_,
void *attr_name_,
int array_lookup,
int index,
const void *attr_type,
long long attr_type,
void *attr_dest)
{
ShaderGlobals *sg = (ShaderGlobals *)sg_;
Expand All @@ -4199,7 +4199,7 @@ OSL_SHADEOP int osl_get_attribute(void *sg_,
return sg->context->osl_get_attribute (sg, sg->objdata,
dest_derivs, obj_name, attr_name,
array_lookup, index,
*(const TypeDesc *)attr_type,
TYPEDESC(attr_type),
attr_dest);
}

Expand Down

0 comments on commit 22105d2

Please sign in to comment.