diff --git a/CMakeLists.txt b/CMakeLists.txt index b0e96253f..7e45d5204 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,10 +113,14 @@ set (OSL_SHADER_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/shade set (OSL_PTX_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/ptx" CACHE STRING "Directory where OptiX PTX files will be installed") set (CMAKE_DEBUG_POSTFIX "" CACHE STRING "Library naming postfix for Debug builds (e.g., '_debug')") -option (OSL_USTRINGREP_IS_HASH "Always use ustringhash for strings" OFF) +option (OSL_USTRINGREP_IS_HASH "Always use ustringhash for strings" ON) set (OSL_NO_DEFAULT_TEXTURESYSTEM OFF CACHE BOOL "Do not use create a raw OIIO::TextureSystem") + +if (OSL_USTRINGREP_IS_HASH) + add_definitions ("-DOSL_USTRINGREP_IS_HASH=1") +endif () if (OSL_NO_DEFAULT_TEXTURESYSTEM) add_definitions ("-DOSL_NO_DEFAULT_TEXTURESYSTEM=1") endif () diff --git a/src/include/OSL/export.h b/src/include/OSL/export.h index f601557c1..44ea766c6 100644 --- a/src/include/OSL/export.h +++ b/src/include/OSL/export.h @@ -48,7 +48,11 @@ # define OSL_DLL_EXPORT # define OSL_DLL_LOCAL # else -# define OSL_DLL_IMPORT __declspec(dllimport) +# ifndef OSL_NO_DLL_IMPORTS +# define OSL_DLL_IMPORT __declspec(dllimport) +# else +# define OSL_DLL_IMPORT +# endif # define OSL_DLL_EXPORT __declspec(dllexport) # define OSL_DLL_LOCAL # endif diff --git a/src/include/OSL/llvm_util.h b/src/include/OSL/llvm_util.h index 7f112ccf5..9e428950f 100644 --- a/src/include/OSL/llvm_util.h +++ b/src/include/OSL/llvm_util.h @@ -718,6 +718,7 @@ class OSLEXECPUBLIC LLVM_Util { /// Return an llvm::Value holding the given string constant (as /// determined by the ustring_rep). llvm::Value* constant(ustring s); + llvm::Value* constant_real_ustring(ustring s); llvm::Value* constant(string_view s) { return constant(ustring(s)); } llvm::Constant* constant_array(cspan constants); @@ -750,6 +751,7 @@ class OSLEXECPUBLIC LLVM_Util { llvm::Constant* wide_constant(size_t i); llvm::Constant* wide_constant_bool(bool b); llvm::Value* wide_constant(ustring s); + llvm::Value* wide_constant_real_ustring(ustring s); llvm::Value* wide_constant(string_view s) { return wide_constant(ustring(s)); @@ -1058,10 +1060,14 @@ class OSLEXECPUBLIC LLVM_Util { IRBuilder& builder(); int m_debug; - bool m_dumpasm = false; - bool m_jit_fma = false; - bool m_jit_aggressive = false; + bool m_dumpasm = false; + bool m_jit_fma = false; + bool m_jit_aggressive = false; +#ifndef OSL_USTRINGREP_IS_HASH UstringRep m_ustring_rep = UstringRep::charptr; +#else + UstringRep m_ustring_rep = UstringRep::hash; +#endif PerThreadInfo::Impl* m_thread; llvm::LLVMContext* m_llvm_context; llvm::Module* m_llvm_module; diff --git a/src/include/OSL/oslexec.h b/src/include/OSL/oslexec.h index 7583c7765..033c10374 100644 --- a/src/include/OSL/oslexec.h +++ b/src/include/OSL/oslexec.h @@ -55,9 +55,7 @@ namespace Strings { #ifdef __CUDA_ARCH__ # define STRDECL(str, var_name) #else -// Any strings referenced inside of a libsoslexec/wide/*.cpp -// or liboslnoise/wide/*.cpp will need OSLEXECPUBLIC -# define STRDECL(str, var_name) OSLEXECPUBLIC extern const ustring var_name; +# define STRDECL(str, var_name) extern const ustring var_name; #endif #include #undef STRDECL diff --git a/src/include/OSL/oslnoise.h b/src/include/OSL/oslnoise.h index 7183d1c5f..6c5b21f6c 100644 --- a/src/include/OSL/oslnoise.h +++ b/src/include/OSL/oslnoise.h @@ -90,7 +90,6 @@ template OSL_HOSTDEVICE Vec3 vhashnoise (S x, T y); } // namespace oslnoise - /////////////////////////////////////////////////////////////////////// // Implementation follows... // @@ -110,7 +109,7 @@ typedef void (*NoiseGenericFunc)(int outdim, float *out, bool derivs, const float *period, NoiseParams *params); typedef void (*NoiseImplFunc)(float *out, const float *in, const float *period, NoiseParams *params); - +#ifndef INCLUDED_FROM_WIDE OSLNOISEPUBLIC OSL_HOSTDEVICE float simplexnoise1 (float x, int seed=0, float *dnoise_dx=NULL); @@ -127,7 +126,7 @@ OSLNOISEPUBLIC OSL_HOSTDEVICE float simplexnoise4 (float x, float y, float z, float w, int seed=0, float *dnoise_dx=NULL, float *dnoise_dy=NULL, float *dnoise_dz=NULL, float *dnoise_dw=NULL); - +#endif namespace { @@ -2797,6 +2796,7 @@ struct PeriodicSNoise : PeriodicSNoiseImpl {}; struct PeriodicSNoiseScalar : PeriodicSNoiseImpl {}; +#ifndef INCLUDED_FROM_WIDE struct SimplexNoise { OSL_HOSTDEVICE SimplexNoise () { } @@ -2908,7 +2908,7 @@ struct SimplexNoise { result = make_Vec3 (r0, r1, r2); } }; - +#endif // Scalar version of SimplexNoise that is SIMD friendly suitable to be // inlined inside of a SIMD loops @@ -3024,6 +3024,7 @@ struct SimplexNoiseScalar { } }; +#ifndef INCLUDED_FROM_WIDE // Unsigned simplex noise struct USimplexNoise { OSL_HOSTDEVICE USimplexNoise () { } @@ -3151,6 +3152,7 @@ struct USimplexNoise { } }; +#endif // Scalar version of USimplexNoise that is SIMD friendly suitable to be // inlined inside of a SIMD loops diff --git a/src/liboslexec/CMakeLists.txt b/src/liboslexec/CMakeLists.txt index 328565af6..c205f40cd 100644 --- a/src/liboslexec/CMakeLists.txt +++ b/src/liboslexec/CMakeLists.txt @@ -528,6 +528,12 @@ foreach(batched_target ${BATCHED_TARGET_LIST}) target_link_libraries(${batched_target_lib} PRIVATE partio::partio ZLIB::ZLIB) target_compile_definitions (${batched_target_lib} PRIVATE USE_PARTIO=1) endif () + + target_compile_definitions (${batched_target_lib} + PRIVATE + OSL_NO_DLL_IMPORTS + INCLUDED_FROM_WIDE + ) endforeach(batched_target) diff --git a/src/liboslexec/batched_backendllvm.cpp b/src/liboslexec/batched_backendllvm.cpp index e94122ef4..13c97edb1 100644 --- a/src/liboslexec/batched_backendllvm.cpp +++ b/src/liboslexec/batched_backendllvm.cpp @@ -19,19 +19,6 @@ using namespace OSL::pvt; OSL_NAMESPACE_ENTER -namespace Strings { - -// TODO: What qualifies these to move to strdecls.h? -// Being used in more than one .cpp? - -// Shader global strings -static ustring backfacing("backfacing"); -static ustring surfacearea("surfacearea"); -static ustring object2common("object2common"); -static ustring shader2common("shader2common"); -static ustring flipHandedness("flipHandedness"); -} // namespace Strings - namespace pvt { namespace // Unnamed @@ -40,39 +27,39 @@ namespace // Unnamed // BatchedShaderGlobals struct in batched_shaderglobals.h, // as well as the llvm 'sg' type // defined in BatchedBackendLLVM::llvm_type_sg(). -static ustring fields[] = { +static ustringhash fields[] = { // Uniform - ustring("renderstate"), // - ustring("tracedata"), // - ustring("objdata"), // - ustring("shadingcontext"), // - ustring("renderer"), // - Strings::raytype, // - ustring("pad0"), // - ustring("pad1"), // - ustring("pad2"), // - ustring("pad3"), // - ustring("pad4"), // + ustringhash("renderstate"), // + ustringhash("tracedata"), // + ustringhash("objdata"), // + ustringhash("shadingcontext"), // + ustringhash("renderer"), // + Hashes::raytype, // + ustringhash("pad0"), // + ustringhash("pad1"), // + ustringhash("pad2"), // + ustringhash("pad3"), // + ustringhash("pad4"), // // Varying - Strings::P, // - ustring("dPdz"), // - Strings::I, // - Strings::N, // - Strings::Ng, // - Strings::u, // - Strings::v, // - Strings::dPdu, // - Strings::dPdv, // - Strings::time, // - Strings::dtime, // - Strings::dPdtime, // - Strings::Ps, // - Strings::object2common, // - Strings::shader2common, // - Strings::Ci, // - Strings::surfacearea, // - Strings::flipHandedness, // - Strings::backfacing + Hashes::P, // + ustringhash("dPdz"), // + Hashes::I, // + Hashes::N, // + Hashes::Ng, // + Hashes::u, // + Hashes::v, // + Hashes::dPdu, // + Hashes::dPdv, // + Hashes::time, // + Hashes::dtime, // + Hashes::dPdtime, // + Hashes::Ps, // + ustringhash("object2common"), // + ustringhash("shader2common"), // + Hashes::Ci, // + ustringhash("surfacearea"), // + ustringhash("flipHandedness"), // + ustringhash("backfacing") }; static bool field_is_uniform[] = { @@ -143,6 +130,10 @@ BatchedBackendLLVM::BatchedBackendLLVM(ShadingSystemImpl& shadingsys, case 8: m_true_mask_value = Mask<8>(true).value(); break; default: OSL_ASSERT(0 && "unsupported vector width"); } + + // Select the appropriate ustring representation + ll.ustring_rep(LLVM_Util::UstringRep::hash); + ll.dumpasm(shadingsys.m_llvm_dumpasm); ll.jit_fma(shadingsys.m_llvm_jit_fma); ll.jit_aggressive(shadingsys.m_llvm_jit_aggressive); @@ -191,7 +182,7 @@ BatchedBackendLLVM::llvm_pass_type(const TypeSpec& typespec) else if (t == TypeDesc::INT) lt = ll.type_int(); else if (t == TypeDesc::STRING) - lt = (llvm::Type*)ll.type_ustring(); + lt = (llvm::Type*)ll.type_real_ustring(); else if (t.aggregate == TypeDesc::VEC3) lt = (llvm::Type*)ll.type_void_ptr(); //llvm_type_triple_ptr(); else if (t.aggregate == TypeDesc::MATRIX44) @@ -271,9 +262,9 @@ BatchedBackendLLVM::llvm_assign_zero(const Symbol& sym) zero = ll.wide_constant(0); } else if (elemtype.is_string_based()) { if (sym.is_uniform()) - zero = ll.constant(ustring()); + zero = ll.constant(uint64_t(0)); else - zero = ll.wide_constant(ustring()); + zero = ll.wide_constant(uint64_t(0)); } else if (elemtype.is_closure_based()) { if (sym.is_uniform()) zero = ll.void_ptr_null(); @@ -715,7 +706,8 @@ llvm::Value* BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv, llvm::Value* arrayindex, int component, TypeDesc cast, bool op_is_uniform, - bool index_is_uniform) + bool index_is_uniform, + bool always_real_ustring) { // A uniform symbol can be broadcast into a varying value. // But a varying symbol can NOT be loaded into a uniform value. @@ -780,9 +772,15 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv, if (sym.typespec().is_string()) { ustring string_val = sym.get_string(); if (op_is_uniform) { - return ll.constant(string_val); + if (!always_real_ustring) + return ll.constant(string_val); + else + return ll.constant_real_ustring(string_val); } else { - return ll.wide_constant(string_val); + if (!always_real_ustring) + return ll.wide_constant(string_val); + else + return ll.wide_constant_real_ustring(string_val); } } OSL_ASSERT(0 && "unhandled constant type"); @@ -796,7 +794,17 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv, sym.forced_llvm_bool()); } +llvm::Value* +BatchedBackendLLVM::llvm_const_hash(string_view str) +{ + return llvm_const_hash(ustring(str)); +} +llvm::Value* +BatchedBackendLLVM::llvm_const_hash(ustring str) +{ + return ll.constant64((uint64_t)str.hash()); +} llvm::Value* BatchedBackendLLVM::llvm_load_mask(const Symbol& cond) @@ -1717,6 +1725,7 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name, = llvm_load_value(s, /*deriv=*/d, /*component*/ c, TypeUnknown, function_is_uniform); + // Store our wide pointer on the stack llvm_store_value(wide_value, tmpptr, t, d, NULL, c, /*dst_is_uniform*/ false); diff --git a/src/liboslexec/batched_backendllvm.h b/src/liboslexec/batched_backendllvm.h index 9bafa7767..e8da8a678 100644 --- a/src/liboslexec/batched_backendllvm.h +++ b/src/liboslexec/batched_backendllvm.h @@ -98,10 +98,14 @@ class BatchedBackendLLVM : public OSOProcessorBase { /// performed if cast is the default of UNKNOWN). llvm::Value* llvm_load_value(const Symbol& sym, int deriv, llvm::Value* arrayindex, int component, - TypeDesc cast = TypeDesc::UNKNOWN, - bool op_is_uniform = true, - bool index_is_uniform = true); + TypeDesc cast = TypeDesc::UNKNOWN, + bool op_is_uniform = true, + bool index_is_uniform = true, + bool always_real_ustring = false); + llvm::Value* llvm_const_hash(string_view str); + + llvm::Value* llvm_const_hash(ustring str); /// Given an llvm::Value* of a pointer (and the type of the data /// that it points to), Return the llvm::Value* corresponding to the diff --git a/src/liboslexec/batched_llvm_gen.cpp b/src/liboslexec/batched_llvm_gen.cpp index dacf4f0ba..411689859 100644 --- a/src/liboslexec/batched_llvm_gen.cpp +++ b/src/liboslexec/batched_llvm_gen.cpp @@ -15,7 +15,7 @@ #endif #include "batched_backendllvm.h" - +#include using namespace OSL; @@ -79,8 +79,9 @@ BatchedBackendLLVM::llvm_gen_debug_printf(string_view message) { ustring s = ustring::fmtformat("({} {}) {}", inst()->shadername(), inst()->layername(), message); - ll.call_function(build_name("printf"), sg_void_ptr(), ll.constant("%s\n"), - ll.constant(s)); + ll.call_function(build_name("printf"), sg_void_ptr(), + ll.constant((unsigned int)(1)), ll.constant("%s\n"), + ll.constant_real_ustring(s)); } @@ -375,6 +376,7 @@ LLVMGEN(llvm_gen_printf) std::string ourformat(oldfmt, format); // straddle the format // Doctor it to fix mismatches between format and data Symbol& sym(*rop.opargsym(op, arg)); + OSL_ASSERT(!sym.typespec().is_structure_based()); bool arg_is_uniform = sym.is_uniform(); @@ -416,11 +418,13 @@ LLVMGEN(llvm_gen_printf) // widened, so our typical op_is_uniform doesn't do what we // want for this when loading. So just pass arg_is_uniform // which will avoid widening any uniform arguments. - llvm::Value* loaded - = rop.llvm_load_value(sym, 0, arrind, c, - TypeDesc::UNKNOWN, - /*op_is_uniform*/ arg_is_uniform, - /*index_is_uniform*/ true); + // Always use real ustring here because wide/opstring printf va_args expects + // strings and not hashes + bool always_real_ustring = true; + llvm::Value* loaded = rop.llvm_load_value( + sym, 0, arrind, c, TypeDesc::UNKNOWN, + /*op_is_uniform*/ arg_is_uniform, + /*index_is_uniform*/ true, always_real_ustring); // Always expand llvm booleans to integers if (sym.forced_llvm_bool()) { @@ -482,6 +486,7 @@ LLVMGEN(llvm_gen_printf) llvm::Value* ret = rop.ll.call_function(rop.build_name(func_spec), call_args); + // The format op returns a string value, put in in the right spot if (op.opname() == op_format) rop.llvm_store_value(ret, *rop.opargsym(op, 0)); @@ -861,6 +866,7 @@ LLVMGEN(llvm_gen_generic) && (uniformFormOfFunction || functionIsLlvmInlined)) { OSL_DEV_ONLY(std::cout << ">>stores return value " << rop.build_name(func_spec) << std::endl); + llvm::Value* r = rop.llvm_call_function( func_spec, &(args[1]), op.nargs() - 1, /*deriv_ptrs*/ false, uniformFormOfFunction, @@ -3300,7 +3306,7 @@ LLVMGEN(llvm_gen_construct_triple) = { rop.sg_void_ptr(), rop.ll.void_ptr(transform), space_is_uniform ? rop.llvm_load_value(Space) : rop.llvm_void_ptr(Space), - rop.ll.constant(Strings::common), + rop.llvm_const_hash(Strings::common), rop.ll.mask_as_int(rop.ll.current_mask()) }; // Dynamically build function name diff --git a/src/liboslexec/batched_llvm_instance.cpp b/src/liboslexec/batched_llvm_instance.cpp index 8e6ff0a76..904cbf301 100644 --- a/src/liboslexec/batched_llvm_instance.cpp +++ b/src/liboslexec/batched_llvm_instance.cpp @@ -1038,9 +1038,8 @@ BatchedBackendLLVM::llvm_assign_initial_value( : ll.wide_constant(std::numeric_limits::min()); } } else if (sym.typespec().is_string_based()) { - u = sym.is_uniform() - ? ll.constant(Strings::uninitialized_string) - : ll.wide_constant(Strings::uninitialized_string); + u = sym.is_uniform() ? ll.constant(uint64_t(0)) + : ll.wide_constant(uint64_t(0)); } if (u) { //std::cout << "Assigning uninit value to symbol=" << sym.name().c_str() << std::endl; diff --git a/src/liboslexec/builtindecl.h b/src/liboslexec/builtindecl.h index 5db1d902c..39d877189 100644 --- a/src/liboslexec/builtindecl.h +++ b/src/liboslexec/builtindecl.h @@ -133,7 +133,7 @@ DECL(osl_closure_to_string, "sXX") DECL(osl_closure_to_ustringhash, "hXX") #endif DECL(osl_format, "hh*") -DECL(osl_gen_ustringhash_pod, "hs") +DECL(osl_gen_ustringhash_pod, "hh") DECL(osl_gen_ustring, "sh") DECL(osl_gen_printfmt, "xXhiXiX") DECL(osl_gen_filefmt, "xXhhiXiX") diff --git a/src/liboslexec/builtindecl_wide_xmacro.h b/src/liboslexec/builtindecl_wide_xmacro.h index 37171c0b1..2ff97fd63 100644 --- a/src/liboslexec/builtindecl_wide_xmacro.h +++ b/src/liboslexec/builtindecl_wide_xmacro.h @@ -45,14 +45,14 @@ #define WIDE_GENERIC_NOISE_DERIV_IMPL_INDIRECT(name) \ - DECL(__OSL_MASKED_OP2(name, Wdf, Wdf), "xsXXXXXi") \ - DECL(__OSL_MASKED_OP3(name, Wdf, Wdf, Wdf), "xsXXXXXXi") \ - DECL(__OSL_MASKED_OP2(name, Wdf, Wdv), "xsXXXXXi") \ - DECL(__OSL_MASKED_OP3(name, Wdf, Wdv, Wdf), "xsXXXXXXi") \ - DECL(__OSL_MASKED_OP2(name, Wdv, Wdf), "xsXXXXXi") \ - DECL(__OSL_MASKED_OP3(name, Wdv, Wdf, Wdf), "xsXXXXXXi") \ - DECL(__OSL_MASKED_OP2(name, Wdv, Wdv), "xsXXXXXi") \ - DECL(__OSL_MASKED_OP3(name, Wdv, Wdv, Wdf), "xsXXXXXXi") + DECL(__OSL_MASKED_OP2(name, Wdf, Wdf), "xhXXXXXi") \ + DECL(__OSL_MASKED_OP3(name, Wdf, Wdf, Wdf), "xhXXXXXXi") \ + DECL(__OSL_MASKED_OP2(name, Wdf, Wdv), "xhXXXXXi") \ + DECL(__OSL_MASKED_OP3(name, Wdf, Wdv, Wdf), "xhXXXXXXi") \ + DECL(__OSL_MASKED_OP2(name, Wdv, Wdf), "xhXXXXXi") \ + DECL(__OSL_MASKED_OP3(name, Wdv, Wdf, Wdf), "xhXXXXXXi") \ + DECL(__OSL_MASKED_OP2(name, Wdv, Wdv), "xhXXXXXi") \ + DECL(__OSL_MASKED_OP3(name, Wdv, Wdv, Wdf), "xhXXXXXXi") #define WIDE_GENERIC_NOISE_DERIV_IMPL(name) \ WIDE_GENERIC_NOISE_DERIV_IMPL_INDIRECT(name) @@ -90,14 +90,14 @@ #define WIDE_GENERIC_PNOISE_DERIV_IMPL_INDIRECT(name) \ - DECL(__OSL_MASKED_OP3(name, Wdf, Wdf, Wf), "xsXXXXXXi") \ - DECL(__OSL_MASKED_OP5(name, Wdf, Wdf, Wdf, Wf, Wf), "xsXXXXXXXXi") \ - DECL(__OSL_MASKED_OP3(name, Wdf, Wdv, Wv), "xsXXXXXXi") \ - DECL(__OSL_MASKED_OP5(name, Wdf, Wdv, Wdf, Wv, Wf), "xsXXXXXXXXi") \ - DECL(__OSL_MASKED_OP3(name, Wdv, Wdf, Wf), "xsXXXXXXi") \ - DECL(__OSL_MASKED_OP5(name, Wdv, Wdf, Wdf, Wf, Wf), "xsXXXXXXXXi") \ - DECL(__OSL_MASKED_OP3(name, Wdv, Wdv, Wv), "xsXXXXXXi") \ - DECL(__OSL_MASKED_OP5(name, Wdv, Wdv, Wdf, Wv, Wf), "xsXXXXXXXXi") + DECL(__OSL_MASKED_OP3(name, Wdf, Wdf, Wf), "xhXXXXXXi") \ + DECL(__OSL_MASKED_OP5(name, Wdf, Wdf, Wdf, Wf, Wf), "xhXXXXXXXXi") \ + DECL(__OSL_MASKED_OP3(name, Wdf, Wdv, Wv), "xhXXXXXXi") \ + DECL(__OSL_MASKED_OP5(name, Wdf, Wdv, Wdf, Wv, Wf), "xhXXXXXXXXi") \ + DECL(__OSL_MASKED_OP3(name, Wdv, Wdf, Wf), "xhXXXXXXi") \ + DECL(__OSL_MASKED_OP5(name, Wdv, Wdf, Wdf, Wf, Wf), "xhXXXXXXXXi") \ + DECL(__OSL_MASKED_OP3(name, Wdv, Wdv, Wv), "xhXXXXXXi") \ + DECL(__OSL_MASKED_OP5(name, Wdv, Wdv, Wdf, Wv, Wf), "xhXXXXXXXXi") #define WIDE_GENERIC_PNOISE_DERIV_IMPL(name) \ WIDE_GENERIC_PNOISE_DERIV_IMPL_INDIRECT(name) @@ -175,12 +175,12 @@ DECL(__OSL_MASKED_OP(mul_closure_float), "xXXXXi") DECL(__OSL_MASKED_OP(mul_closure_color), "xXXXXi") DECL(__OSL_OP(closure_to_string), "sXX") -DECL(__OSL_OP(format), "xXis*") -DECL(__OSL_OP(format_uniform), "ss*") -DECL(__OSL_OP(printf), "xXis*") -DECL(__OSL_OP(error), "xXis*") -DECL(__OSL_OP(warning), "xXis*") -DECL(__OSL_OP(fprintf), "xXiss*") +DECL(__OSL_OP(format), "xXih*") +DECL(__OSL_OP(format_uniform), "hh*") +DECL(__OSL_OP(printf), "xXih*") +DECL(__OSL_OP(error), "xXih*") +DECL(__OSL_OP(warning), "xXih*") +DECL(__OSL_OP(fprintf), "xXihh*") DECL(__OSL_MASKED_OP(split), "xXXXXXii") @@ -263,61 +263,61 @@ DECL(__OSL_MASKED_OP3(hash, Wi, Wv, Wf), "xXXXi") // first vs. directly passing the shader global. We don't expect this // to be encountered, but is possible -DECL(__OSL_MASKED_OP3(spline, Wf, Wf, Wf), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wf, Wf, f), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wf, f, Wf), "xXXXXiii") +DECL(__OSL_MASKED_OP3(spline, Wf, Wf, Wf), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wf, Wf, f), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wf, f, Wf), "xXhXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdf, Wdf, Wdf), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdf, Wdf, df), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdf, Wf, df), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdf, df, Wdf), "xXXXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdf, Wdf, Wdf), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdf, Wdf, df), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdf, Wf, df), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdf, df, Wdf), "xXhXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdf, Wdf, f), "xXXXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdf, Wdf, f), "xXhXXiii") -DECL(__OSL_MASKED_OP3(spline, Wv, Wf, Wv), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wv, Wf, v), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wv, f, Wv), "xXXXXiii") +DECL(__OSL_MASKED_OP3(spline, Wv, Wf, Wv), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wv, Wf, v), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wv, f, Wv), "xXhXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, Wdf, Wdv), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, Wdf, dv), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, df, Wdv), "xXXXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, Wdf, Wdv), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, Wdf, dv), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, df, Wdv), "xXhXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, Wdf, v), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, Wdf, Wv), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, df, Wv), "xXXXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, Wdf, v), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, Wdf, Wv), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, df, Wv), "xXhXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdf, f, Wdf), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdf, Wf, Wdf), "xXXXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdf, f, Wdf), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdf, Wf, Wdf), "xXhXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, f, Wdv), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, Wf, Wdv), "xXXXXiii") -DECL(__OSL_MASKED_OP3(spline, Wdv, Wf, dv), "xXXXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, f, Wdv), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, Wf, Wdv), "xXhXXiii") +DECL(__OSL_MASKED_OP3(spline, Wdv, Wf, dv), "xXhXXiii") //--------------------------------------------------------------- -DECL(__OSL_MASKED_OP3(splineinverse, Wf, Wf, Wf), "xXXXXiii") -DECL(__OSL_MASKED_OP3(splineinverse, Wf, Wf, f), "xXXXXiii") -DECL(__OSL_MASKED_OP3(splineinverse, Wf, f, Wf), "xXXXXiii") +DECL(__OSL_MASKED_OP3(splineinverse, Wf, Wf, Wf), "xXhXXiii") +DECL(__OSL_MASKED_OP3(splineinverse, Wf, Wf, f), "xXhXXiii") +DECL(__OSL_MASKED_OP3(splineinverse, Wf, f, Wf), "xXhXXiii") //dfdfdf is treated as dfdff -DECL(__OSL_MASKED_OP3(splineinverse, Wdf, Wdf, Wdf), "xXXXXiii") //redone -DECL(__OSL_MASKED_OP3(splineinverse, Wdf, Wdf, df), "xXXXXiii") -DECL(__OSL_MASKED_OP3(splineinverse, Wdf, df, Wdf), "xXXXXiii") +DECL(__OSL_MASKED_OP3(splineinverse, Wdf, Wdf, Wdf), "xXhXXiii") //redone +DECL(__OSL_MASKED_OP3(splineinverse, Wdf, Wdf, df), "xXhXXiii") +DECL(__OSL_MASKED_OP3(splineinverse, Wdf, df, Wdf), "xXhXXiii") //====== -DECL(__OSL_MASKED_OP3(splineinverse, Wdf, Wdf, f), "xXXXXiii") +DECL(__OSL_MASKED_OP3(splineinverse, Wdf, Wdf, f), "xXhXXiii") //dffdf is treated as fff -DECL(__OSL_MASKED_OP3(splineinverse, Wdf, f, Wdf), "xXXXXiii") +DECL(__OSL_MASKED_OP3(splineinverse, Wdf, f, Wdf), "xXhXXiii") // // unreachable, can't find .osl to produce this combination //DECL(__OSL_MASKED_OP3(splineinverse, Wdf, Wf, Wdf), "xXXXXiii") -DECL(__OSL_MASKED_OP(pointcloud_search), "xXXsXXiiXiXiiii*") -DECL(__OSL_MASKED_OP(pointcloud_get), "iXsXiXsLXi") -DECL(__OSL_MASKED_OP(pointcloud_write), "iXsXiXXXi") +DECL(__OSL_MASKED_OP(pointcloud_search), "xXXhXXiiXiXiiii*") +DECL(__OSL_MASKED_OP(pointcloud_get), "iXhXiXhLXi") +DECL(__OSL_MASKED_OP(pointcloud_write), "iXhXiXXXi") -DECL(__OSL_MASKED_OP(getmessage), "xXXssLXiisii") -DECL(__OSL_MASKED_OP2(setmessage, s, WX), "xXsLXisii") -DECL(__OSL_MASKED_OP2(setmessage, Ws, WX), "xXXLXisii") +DECL(__OSL_MASKED_OP(getmessage), "xXXhhLXiihii") +DECL(__OSL_MASKED_OP2(setmessage, s, WX), "xXhLXihii") +DECL(__OSL_MASKED_OP2(setmessage, Ws, WX), "xXXLXihii") DECL(__OSL_OP(blackbody_vf), "xXXf") DECL(__OSL_MASKED_OP2(blackbody, Wv, Wf), "xXXXi") @@ -329,13 +329,13 @@ DECL(__OSL_MASKED_OP2(wavelength_color, Wv, Wf), "xXXXi") //DECL (osl_luminance_fv, "xXXX") //DECL (osl_luminance_dfdv, "xXXX") -DECL(__OSL_OP(prepend_color_from_vs), "xXXs") -DECL(__OSL_MASKED_OP2(prepend_color_from, Wv, s), "xXXsi") +DECL(__OSL_OP(prepend_color_from_vs), "xXXh") +DECL(__OSL_MASKED_OP2(prepend_color_from, Wv, s), "xXXhi") DECL(__OSL_MASKED_OP2(prepend_color_from, Wv, Ws), "xXXXi") // forced masked version only -DECL(__OSL_MASKED_OP2(prepend_matrix_from, Wm, s), "xXXsi") +DECL(__OSL_MASKED_OP2(prepend_matrix_from, Wm, s), "xXXhi") DECL(__OSL_MASKED_OP2(prepend_matrix_from, Wm, Ws), "xXXXi") // Batched code gen uses a combination of osl_build_transform_matrix @@ -345,42 +345,42 @@ DECL(__OSL_MASKED_OP2(prepend_matrix_from, Wm, Ws), "xXXXi") // DECL (osl_transform_triple, "iXXiXiXXi") // unneeded // DECL (osl_transform_triple_nonlinear, "iXXiXiXXi") // unneeded -DECL(__OSL_MASKED_OP3(build_transform_matrix, Wm, s, s), "iXXXXi") -DECL(__OSL_MASKED_OP3(build_transform_matrix, Wm, Ws, s), "iXXXXi") -DECL(__OSL_MASKED_OP3(build_transform_matrix, Wm, s, Ws), "iXXXXi") +DECL(__OSL_MASKED_OP3(build_transform_matrix, Wm, s, s), "iXXhhi") +DECL(__OSL_MASKED_OP3(build_transform_matrix, Wm, Ws, s), "iXXXhi") +DECL(__OSL_MASKED_OP3(build_transform_matrix, Wm, s, Ws), "iXXhXi") DECL(__OSL_MASKED_OP3(build_transform_matrix, Wm, Ws, Ws), "iXXXXi") -DECL(__OSL_OP(dict_find_iis), "iXis") +DECL(__OSL_OP(dict_find_iis), "iXih") DECL(__OSL_MASKED_OP3(dict_find, Wi, Wi, Ws), "xXXXXi") -DECL(__OSL_OP(dict_find_iss), "iXss") +DECL(__OSL_OP(dict_find_iss), "iXhh") DECL(__OSL_MASKED_OP3(dict_find, Wi, Ws, Ws), "xXXXXi") DECL(__OSL_OP(dict_next), "iXi") DECL(__OSL_MASKED_OP(dict_next), "xXXXi") -DECL(__OSL_OP(dict_value), "iXisLX") +DECL(__OSL_OP(dict_value), "iXihLX") DECL(__OSL_MASKED_OP(dict_value), "xXXXXLXi") -DECL(__OSL_OP(raytype_name), "iXs") +DECL(__OSL_OP(raytype_name), "iXh") DECL(__OSL_MASKED_OP(raytype_name), "xXXXi") -DECL(__OSL_OP(naninf_check), "xiXiXsisiis") -DECL(__OSL_MASKED_OP1(naninf_check_offset, i), "xiiXiXsisiis") -DECL(__OSL_MASKED_OP1(naninf_check_offset, Wi), "xiiXiXsisXis") -DECL(__OSL_OP(range_check), "iiisXsisiss") -DECL(__OSL_MASKED_OP(range_check), "xXiisXsisiss") -DECL(__OSL_OP2(uninit_check_values_offset, X, i), "xLXXsisissisisii") -DECL(__OSL_MASKED_OP2(uninit_check_values_offset, X, Wi), "xiLXXsisissisisXi") -DECL(__OSL_MASKED_OP2(uninit_check_values_offset, WX, i), "xiLXXsisissisisii") -DECL(__OSL_MASKED_OP2(uninit_check_values_offset, WX, Wi), "xiLXXsisissisisXi") - -DECL(__OSL_OP1(get_attribute, s), "iXissiiXXi") -DECL(__OSL_MASKED_OP1(get_attribute, Ws), "iXisXiiXXi") -DECL(__OSL_OP(get_attribute_uniform), "iXissiiXX") +DECL(__OSL_OP(naninf_check), "xiXiXhihiih") +DECL(__OSL_MASKED_OP1(naninf_check_offset, i), "xiiXiXhihiih") +DECL(__OSL_MASKED_OP1(naninf_check_offset, Wi), "xiiXiXhihXih") +DECL(__OSL_OP(range_check), "iiihXhihihh") +DECL(__OSL_MASKED_OP(range_check), "xXiihXhihihh") +DECL(__OSL_OP2(uninit_check_values_offset, X, i), "xLXXhihihhihihii") +DECL(__OSL_MASKED_OP2(uninit_check_values_offset, X, Wi), "xiLXXhihihhihihXi") +DECL(__OSL_MASKED_OP2(uninit_check_values_offset, WX, i), "xiLXXhihihhihihii") +DECL(__OSL_MASKED_OP2(uninit_check_values_offset, WX, Wi), "xiLXXhihihhihihXi") + +DECL(__OSL_OP1(get_attribute, s), "iXihhiiXXi") +DECL(__OSL_MASKED_OP1(get_attribute, Ws), "iXihXiiXXi") +DECL(__OSL_OP(get_attribute_uniform), "iXihhiiXX") // TODO: shouldn't bind_interpolated_param be MASKED? change name to reflect -DECL(__OSL_OP(bind_interpolated_param), "iXsLiXiXiXii") +DECL(__OSL_OP(bind_interpolated_param), "iXhLiXiXiXii") //DECL (osl_get_texture_options, "XX") // unneeded DECL(__OSL_OP(get_noise_options), "XX") @@ -520,8 +520,8 @@ DECL(__OSL_MASKED_OP3(transform_normal, Wdv, Wdv, Wm), "xXXXii") DECL(__OSL_MASKED_OP3(transform_normal, Wv, Wv, m), "xXXXii") DECL(__OSL_MASKED_OP3(transform_normal, Wdv, Wdv, m), "xXXXii") -DECL(__OSL_MASKED_OP3(transform_color, Wv, s, s), "xXXiXissi") -DECL(__OSL_OP3(transform_color, v, s, s), "xXXiXiss") +DECL(__OSL_MASKED_OP3(transform_color, Wv, s, s), "xXXiXihhi") +DECL(__OSL_OP3(transform_color, v, s, s), "xXXiXihh") DECL(__OSL_OP3(dot, Wf, Wv, Wv), "xXXX") DECL(__OSL_MASKED_OP3(dot, Wf, Wv, Wv), "xXXXi") @@ -588,9 +588,9 @@ DECL(__OSL_MASKED_OP3(div, Wm, Wm, Wf), "xXXXi") DECL(__OSL_MASKED_OP3(div, Wm, Wf, Wm), "xXXXi") // forced masked version only -DECL(__OSL_MASKED_OP3(get_from_to_matrix, Wm, s, s), "iXXssi") -DECL(__OSL_MASKED_OP3(get_from_to_matrix, Wm, s, Ws), "iXXsXi") -DECL(__OSL_MASKED_OP3(get_from_to_matrix, Wm, Ws, s), "iXXXsi") +DECL(__OSL_MASKED_OP3(get_from_to_matrix, Wm, s, s), "iXXhhi") +DECL(__OSL_MASKED_OP3(get_from_to_matrix, Wm, s, Ws), "iXXhXi") +DECL(__OSL_MASKED_OP3(get_from_to_matrix, Wm, Ws, s), "iXXXhi") DECL(__OSL_MASKED_OP3(get_from_to_matrix, Wm, Ws, Ws), "iXXXXi") //varying vs non varying @@ -612,17 +612,17 @@ DECL(__OSL_MASKED_OP2(stof, Wf, Ws), "xXXi") DECL(__OSL_MASKED_OP4(substr, Ws, Ws, Wi, Wi), "xXXXXi") DECL(__OSL_MASKED_OP(regex_impl), "xXXXXiXii") -DECL(__OSL_OP(regex_impl), "iXsXisi") +DECL(__OSL_OP(regex_impl), "iXhXihi") // BATCH texturing manages the BatchedTextureOptions // directly in LLVM ir, and has no need for wide versions // of osl_texture_set_XXX functions -DECL(__OSL_MASKED_OP(texture), "iXsXXXXXXXXiXiXiXi") -DECL(__OSL_MASKED_OP(texture3d), "iXsXXXXXXiXiXiXi") -DECL(__OSL_MASKED_OP(environment), "iXsXXXXXiXiXiXi") -DECL(__OSL_OP(resolve_udim_uniform), "XXXXff") -DECL(__OSL_MASKED_OP(resolve_udim), "xXXXXXXi") -DECL(__OSL_OP(get_textureinfo_uniform), "iXsXsXX") +DECL(__OSL_MASKED_OP(texture), "iXhXXXXXXXXiXiXiXi") +DECL(__OSL_MASKED_OP(texture3d), "iXhXXXXXXiXiXiXi") +DECL(__OSL_MASKED_OP(environment), "iXhXXXXXiXiXiXi") +DECL(__OSL_OP(resolve_udim_uniform), "XXhXff") +DECL(__OSL_MASKED_OP(resolve_udim), "xXhXXXXi") +DECL(__OSL_OP(get_textureinfo_uniform), "iXhXhXX") // Wide Code generator will set trace options directly in LLVM IR // without calling helper functions diff --git a/src/liboslexec/llvm_util.cpp b/src/liboslexec/llvm_util.cpp index 3dd888cab..3b3db3942 100644 --- a/src/liboslexec/llvm_util.cpp +++ b/src/liboslexec/llvm_util.cpp @@ -564,10 +564,15 @@ LLVM_Util::ustring_rep(UstringRep rep) } m_llvm_type_ustring_ptr = llvm::PointerType::get(m_llvm_type_ustring, 0); - // Batched versions haven't been updated to handle hash yet. - // For now leave them using the real ustring regardless of UstringRep - m_llvm_type_wide_ustring = llvm_vector_type(m_llvm_type_real_ustring, - m_vector_width); + if (m_ustring_rep == UstringRep::charptr) { + m_llvm_type_wide_ustring = llvm_vector_type(m_llvm_type_real_ustring, + m_vector_width); + } else { + OSL_ASSERT(m_ustring_rep == UstringRep::hash); + m_llvm_type_wide_ustring + = llvm_vector_type(llvm::Type::getInt64Ty(*m_llvm_context), + m_vector_width); + } m_llvm_type_wide_ustring_ptr = llvm::PointerType::get(m_llvm_type_wide_ustring, 0); } @@ -3533,6 +3538,11 @@ LLVM_Util::constant(ustring s) } } +llvm::Value* +LLVM_Util::constant_real_ustring(ustring s) +{ + return constant_ptr((void*)s.c_str(), type_char_ptr()); +} llvm::Value* @@ -3541,7 +3551,12 @@ LLVM_Util::wide_constant(ustring s) return builder().CreateVectorSplat(m_vector_width, constant(s)); } - +llvm::Value* +LLVM_Util::wide_constant_real_ustring(ustring s) +{ + return builder().CreateVectorSplat(m_vector_width, + constant_real_ustring(s)); +} llvm::Value* LLVM_Util::llvm_mask_to_native(llvm::Value* llvm_mask) diff --git a/src/liboslexec/opcolor_impl.h b/src/liboslexec/opcolor_impl.h index d6d65d019..d0c9a3fbb 100644 --- a/src/liboslexec/opcolor_impl.h +++ b/src/liboslexec/opcolor_impl.h @@ -54,7 +54,7 @@ namespace { // anon namespace to avoid duplicate OptiX symbols #ifdef __CUDACC__ OSL_CONSTANT_DATA const float cie_colour_match[81*3] = #else -OSL_CONSTANT_DATA const float cie_colour_match[81 * 3] OSL_ALIGNAS(64) = +OSL_CONSTANT_DATA OSL_ALIGNAS(64) const float cie_colour_match[81 * 3] = #endif { 0.0014,0.0000,0.0065, 0.0022,0.0001,0.0105, 0.0042,0.0001,0.0201, diff --git a/src/liboslexec/opfmt.cpp b/src/liboslexec/opfmt.cpp index c0caa21fd..d66326e85 100644 --- a/src/liboslexec/opfmt.cpp +++ b/src/liboslexec/opfmt.cpp @@ -31,10 +31,12 @@ namespace pvt { // Shims to convert llvm gen to rs free function C++ parameter types // and forward on calls to re free functions. +// TODO this can be removed now that batched supports ustringhash_pod OSL_RSOP OSL::ustringhash_pod -osl_gen_ustringhash_pod(ustring_pod s) +osl_gen_ustringhash_pod(OSL::ustringhash_pod hash) { - return USTR(s).hash(); + return hash; + //return USTR(s).hash(); } OSL_RSOP const char* @@ -114,4 +116,4 @@ get_max_warnings_per_thread(OpaqueExecContextPtr oec) } //namespace pvt -OSL_NAMESPACE_EXIT \ No newline at end of file +OSL_NAMESPACE_EXIT diff --git a/src/liboslexec/oslexec_pvt.h b/src/liboslexec/oslexec_pvt.h index 5921c4ba6..59bdc166d 100644 --- a/src/liboslexec/oslexec_pvt.h +++ b/src/liboslexec/oslexec_pvt.h @@ -245,14 +245,14 @@ struct AttributeNeeded { // "C" linkage (no C++ name mangling). #define OSL_SHADEOP extern "C" OSL_DLL_LOCAL - +/* // Handy re-casting macros inline ustring USTR(ustring_pod s) noexcept { return OSL::bitcast(s); } - +*/ #define MAT(m) (*(Matrix44*)m) #define VEC(v) (*(Vec3*)v) @@ -674,6 +674,10 @@ class ShadingSystemImpl { { return ustring_from(m_shading_state_uniform.m_commonspace_synonym); } + ustringhash commonspace_synonym_hash() const + { + return ustringhash_from(m_shading_state_uniform.m_commonspace_synonym); + } bool llvm_jit_fma() const { return m_llvm_jit_fma; } ustring llvm_jit_target() const { return m_llvm_jit_target; } @@ -2154,40 +2158,52 @@ class OSLEXECPUBLIC ShadingContext { inline void errorfmt(Mask mask, const Str& fmt, Args&&... args) const { + // TODO FIXME + /* m_sc.record_error(ErrorHandler::EH_ERROR, fmtformat(fmt, std::forward(args)...), static_cast>( mask)); +*/ } template inline void warningfmt(Mask mask, const Str& fmt, Args&&... args) const { + // TODO FIXME + /* m_sc.record_error(ErrorHandler::EH_WARNING, fmtformat(fmt, std::forward(args)...), static_cast>( mask)); +*/ } template inline void infofmt(Mask mask, const Str& fmt, Args&&... args) const { + // TODO FIXME + /* m_sc.record_error(ErrorHandler::EH_INFO, fmtformat(fmt, std::forward(args)...), static_cast>( mask)); +*/ } template inline void messagefmt(Mask mask, const Str& fmt, Args&&... args) const { + // TODO FIXME + /* m_sc.record_error(ErrorHandler::EH_MESSAGE, fmtformat(fmt, std::forward(args)...), static_cast>( mask)); +*/ } }; @@ -2378,25 +2394,29 @@ class OSLEXECPUBLIC ShadingContext { template inline void errorfmt(const char* fmt, const Args&... args) const { - record_error(ErrorHandler::EH_ERROR, fmtformat(fmt, args...)); + //TODO FIXME + //record_error(ErrorHandler::EH_ERROR, fmtformat(fmt, args...)); } template inline void warningfmt(const char* fmt, const Args&... args) const { - record_error(ErrorHandler::EH_WARNING, fmtformat(fmt, args...)); + //TODO FIXME + //record_error(ErrorHandler::EH_WARNING, fmtformat(fmt, args...)); } template inline void infofmt(const char* fmt, const Args&... args) const { - record_error(ErrorHandler::EH_INFO, fmtformat(fmt, args...)); + //TODO FIXME + //record_error(ErrorHandler::EH_INFO, fmtformat(fmt, args...)); } template inline void messagefmt(const char* fmt, const Args&... args) const { - record_error(ErrorHandler::EH_MESSAGE, fmtformat(fmt, args...)); + //TODO FIXME + //record_error(ErrorHandler::EH_MESSAGE, fmtformat(fmt, args...)); } void reserve_heap(size_t size) diff --git a/src/liboslexec/wide/wide_opclosure.cpp b/src/liboslexec/wide/wide_opclosure.cpp index 872abe7fe..ee8815f79 100644 --- a/src/liboslexec/wide/wide_opclosure.cpp +++ b/src/liboslexec/wide/wide_opclosure.cpp @@ -210,8 +210,10 @@ __OSL_OP(closure_to_string)(void* bsg_, ClosureColor* c) // Special case for printing closures std::ostringstream stream; stream.imbue(std::locale::classic()); // force C locale - print_closure(stream, c, &bsg->uniform.context->shadingsys(), false); - return ustring(stream.str()).c_str(); + // TODO FIXME + //print_closure(stream, c, &bsg->uniform.context->shadingsys(), false); + //return ustring(stream.str()).c_str(); + return NULL; } diff --git a/src/liboslexec/wide/wide_opcolor.cpp b/src/liboslexec/wide/wide_opcolor.cpp index d1e96320f..57b6126a7 100644 --- a/src/liboslexec/wide/wide_opcolor.cpp +++ b/src/liboslexec/wide/wide_opcolor.cpp @@ -161,14 +161,14 @@ __OSL_MASKED_OP2(wavelength_color, Wv, Wf)(void* bsg_, void* wout_, } - OSL_BATCHOP void -__OSL_OP(prepend_color_from_vs)(void* bsg_, void* c_, const char* from) +__OSL_OP(prepend_color_from_vs)(void* bsg_, void* c_, ustringhash_pod from) { const ColorSystem& cs = cs_from_bsg(bsg_); Color3& c(*(Color3*)c_); - c = cs.to_rgb(USTR(from), c, context_from_bsg(bsg_)); + // TODO FIXME + //c = cs.to_rgb(ustringhash_from(from), c, context_from_bsg(bsg_)); } namespace { @@ -176,12 +176,12 @@ namespace { // NOTE: keep implementation as mirror of ColorSystem::to_rgb void wide_prepend_color_from(ShadingContext* ctx, const ColorSystem& cs, - Masked wR, ustring fromspace) + Masked wR, ustringhash fromspace) { // Rather than attempt outer loop vectorization of ColorSystem::to_rgb // we will pull it's implementation up and insert SIMD loops inside // the uniform branches - if (fromspace == Strings::RGB || fromspace == Strings::rgb + if (fromspace == Hashes::RGB || fromspace == Hashes::rgb || fromspace == cs.colorspace()) { OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { @@ -190,7 +190,7 @@ wide_prepend_color_from(ShadingContext* ctx, const ColorSystem& cs, } return; } - if (fromspace == Strings::hsv) { + if (fromspace == Hashes::hsv) { OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { Color3 C = wR[lane]; @@ -201,7 +201,7 @@ wide_prepend_color_from(ShadingContext* ctx, const ColorSystem& cs, } return; } - if (fromspace == Strings::hsl) { + if (fromspace == Hashes::hsl) { OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { Color3 C = wR[lane]; @@ -212,7 +212,7 @@ wide_prepend_color_from(ShadingContext* ctx, const ColorSystem& cs, } return; } - if (fromspace == Strings::YIQ) { + if (fromspace == Hashes::YIQ) { OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { Color3 C = wR[lane]; @@ -223,7 +223,7 @@ wide_prepend_color_from(ShadingContext* ctx, const ColorSystem& cs, } return; } - if (fromspace == Strings::XYZ) { + if (fromspace == Hashes::XYZ) { OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { Color3 C = wR[lane]; @@ -234,7 +234,7 @@ wide_prepend_color_from(ShadingContext* ctx, const ColorSystem& cs, } return; } - if (fromspace == Strings::xyY) { + if (fromspace == Hashes::xyY) { OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { Color3 C = wR[lane]; @@ -249,8 +249,9 @@ wide_prepend_color_from(ShadingContext* ctx, const ColorSystem& cs, // Serialize calls to ocio wR.mask().foreach ([=, &cs](ActiveLane lane) -> void { Color3 C = wR[lane]; - Color3 R = cs.ocio_transform(fromspace, Strings::RGB, C, ctx); - wR[lane] = R; + // TODO FIXME + //Color3 R = cs.ocio_transform(fromspace, Hashes::RGB, C, ctx); + //wR[lane] = R; }); } @@ -260,14 +261,14 @@ wide_prepend_color_from(ShadingContext* ctx, const ColorSystem& cs, OSL_BATCHOP void __OSL_MASKED_OP2(prepend_color_from, Wv, s)(void* bsg_, void* c_, - const char* from, + ustringhash_pod from, unsigned int mask_value) { const ColorSystem& cs = cs_from_bsg(bsg_); ShadingContext* ctx = context_from_bsg(bsg_); Masked wR(c_, Mask(mask_value)); - ustring fromspace = USTR(from); + ustringhash fromspace = ustringhash_from(from); wide_prepend_color_from(ctx, cs, wR, fromspace); } @@ -281,9 +282,9 @@ __OSL_MASKED_OP2(prepend_color_from, Wv, Ws)(void* bsg_, void* c_, void* from_, const ColorSystem& cs = cs_from_bsg(bsg_); ShadingContext* ctx = context_from_bsg(bsg_); - Wide wFrom(from_); + Wide wFrom(from_); foreach_unique(wFrom, Mask(mask_value), - [=, &cs](const ustring& from, Mask from_mask) { + [=, &cs](const ustringhash& from, Mask from_mask) { // Reuse the uniform from implementation by restricting results to // just the lanes with the same value of "from". Masked wsub_result(c_, from_mask); @@ -305,16 +306,16 @@ namespace { template OSL_NOINLINE void -wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, - Masked wOutput, Wide wInput, - ShadingContext* context); +wide_transformc(const ColorSystem cs, ustringhash fromspace, + ustringhash tospace, Masked wOutput, + Wide wInput, ShadingContext* context); // NOTE: keep implementation as mirror of ColorSystem::transformc template void -wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, - Masked wOutput, Wide wInput, - ShadingContext* context) +wide_transformc(const ColorSystem cs, ustringhash fromspace, + ustringhash tospace, Masked wOutput, + Wide wInput, ShadingContext* context) { // Rather than attempt outer loop vectorization of ColorSystem::transformc // we will pull it's implementation up and insert SIMD loops inside @@ -322,14 +323,14 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, bool use_colorconfig = false; Block bCrgb; Wide wCrgb(bCrgb); - if (fromspace == Strings::RGB || fromspace == Strings::rgb - || fromspace == Strings::linear || fromspace == cs.colorspace()) { + if (fromspace == Hashes::RGB || fromspace == Hashes::rgb + || fromspace == Hashes::linear || fromspace == cs.colorspace()) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR C = wInput[lane]; wCrgb[lane] = C; } - } else if (fromspace == Strings::hsv) { + } else if (fromspace == Hashes::hsv) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR C = wInput[lane]; @@ -338,7 +339,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wCrgb[ActiveLane(lane)] = R; } } - } else if (fromspace == Strings::hsl) { + } else if (fromspace == Hashes::hsl) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR C = wInput[lane]; @@ -347,7 +348,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wCrgb[ActiveLane(lane)] = R; } } - } else if (fromspace == Strings::YIQ) { + } else if (fromspace == Hashes::YIQ) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR C = wInput[lane]; @@ -356,7 +357,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wCrgb[ActiveLane(lane)] = R; } } - } else if (fromspace == Strings::XYZ) { + } else if (fromspace == Hashes::XYZ) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR C = wInput[lane]; @@ -365,7 +366,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wCrgb[ActiveLane(lane)] = R; } } - } else if (fromspace == Strings::xyY) { + } else if (fromspace == Hashes::xyY) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR C = wInput[lane]; @@ -374,7 +375,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wCrgb[ActiveLane(lane)] = R; } } - } else if (fromspace == Strings::sRGB) { + } else if (fromspace == Hashes::sRGB) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR C = wInput[lane]; @@ -389,14 +390,14 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, if (use_colorconfig) { // do things the ColorConfig way, so skip all these other clauses... - } else if (tospace == Strings::RGB || tospace == Strings::rgb - || tospace == Strings::linear || tospace == cs.colorspace()) { + } else if (tospace == Hashes::RGB || tospace == Hashes::rgb + || tospace == Hashes::linear || tospace == cs.colorspace()) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR C = wCrgb[lane]; wOutput[lane] = C; } - } else if (tospace == Strings::hsv) { + } else if (tospace == Hashes::hsv) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR Crgb = wCrgb[lane]; @@ -405,7 +406,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wOutput[ActiveLane(lane)] = Cto; } } - } else if (tospace == Strings::hsl) { + } else if (tospace == Hashes::hsl) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR Crgb = wCrgb[lane]; @@ -414,7 +415,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wOutput[ActiveLane(lane)] = Cto; } } - } else if (tospace == Strings::YIQ) { + } else if (tospace == Hashes::YIQ) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR Crgb = wCrgb[lane]; @@ -423,7 +424,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wOutput[ActiveLane(lane)] = Cto; } } - } else if (tospace == Strings::XYZ) { + } else if (tospace == Hashes::XYZ) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR Crgb = wCrgb[lane]; @@ -432,7 +433,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wOutput[ActiveLane(lane)] = Cto; } } - } else if (tospace == Strings::xyY) { + } else if (tospace == Hashes::xyY) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR Crgb = wCrgb[lane]; @@ -441,7 +442,7 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, wOutput[ActiveLane(lane)] = Cto; } } - } else if (tospace == Strings::sRGB) { + } else if (tospace == Hashes::sRGB) { WIDE_TRANSFORMC_OMP_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { COLOR Crgb = wCrgb[lane]; @@ -457,9 +458,10 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, if (use_colorconfig) { // Serialize calls to ocio wOutput.mask().foreach ([=, &cs](ActiveLane lane) -> void { - COLOR C = wInput[lane]; - COLOR Cto = cs.ocio_transform(fromspace, tospace, C, context); - wOutput[lane] = Cto; + COLOR C = wInput[lane]; + // TODO FIXME + //COLOR Cto = cs.ocio_transform(fromspace, tospace, C, context); + //wOutput[lane] = Cto; }); } } @@ -473,14 +475,14 @@ wide_transformc(const ColorSystem cs, ustring fromspace, ustring tospace, OSL_BATCHOP void __OSL_MASKED_OP3(transform_color, Wv, s, s)(void* bsg_, void* Cin, int Cin_derivs, void* Cout, - int Cout_derivs, ustring_pod from_, ustring_pod to_, + int Cout_derivs, ustringhash_pod from_, ustringhash_pod to_, unsigned int mask_value) { const ColorSystem& cs = cs_from_bsg(bsg_); ShadingContext* ctx = context_from_bsg(bsg_); - const ustring& from = USTR(from_); - const ustring& to = USTR(to_); + ustringhash from = ustringhash_from(from_); + ustringhash to = ustringhash_from(to_); if (Cout_derivs) { if (Cin_derivs) { @@ -512,17 +514,18 @@ __OSL_MASKED_OP3(transform_color, Wv, s, OSL_BATCHOP void __OSL_OP3(transform_color, v, s, s)(void* bsg_, void* Cin, int Cin_derivs, void* Cout, int Cout_derivs, - ustring_pod from_, ustring_pod to_) + ustringhash_pod from_, ustringhash_pod to_) { const ColorSystem& cs = cs_from_bsg(bsg_); ShadingContext* ctx = context_from_bsg(bsg_); - const ustring& from = USTR(from_); - const ustring& to = USTR(to_); + ustringhash from = ustringhash_from(from_); + ustringhash to = ustringhash_from(to_); if (Cout_derivs) { if (Cin_derivs) { - DCOL(Cout) = cs.transformc(from, to, DCOL(Cin), ctx); + // TODO FIXME + //DCOL(Cout) = cs.transformc(from, to, DCOL(Cin), ctx); return; } else { // We had output derivs, but not input. Zero the output @@ -533,7 +536,8 @@ __OSL_OP3(transform_color, v, s, s)(void* bsg_, void* Cin, int Cin_derivs, } // No-derivs case - COL(Cout) = cs.transformc(from, to, COL(Cin), ctx); + // TODO FIXME + //COL(Cout) = cs.transformc(from, to, COL(Cin), ctx); return; } diff --git a/src/liboslexec/wide/wide_opdictionary.cpp b/src/liboslexec/wide/wide_opdictionary.cpp index b209d9bf8..0228949f9 100644 --- a/src/liboslexec/wide/wide_opdictionary.cpp +++ b/src/liboslexec/wide/wide_opdictionary.cpp @@ -48,12 +48,14 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH) #include "define_opname_macros.h" OSL_BATCHOP int -__OSL_OP(dict_find_iis)(void* bsg_, int nodeID, ustring_pod query) +__OSL_OP(dict_find_iis)(void* bsg_, int nodeID, ustringhash_pod query) { auto* bsg = reinterpret_cast(bsg_); - return bsg->uniform.context->dict_find( - nullptr /*causes errors be reported through ShadingContext*/, nodeID, - USTR(query)); + // TODO FIXME + //return bsg->uniform.context->dict_find( + // nullptr causes errors be reported through ShadingContext, nodeID, + // ustring_from(query)) + return 0; } @@ -73,21 +75,25 @@ __OSL_MASKED_OP3(dict_find, Wi, Wi, Ws)(void* bsg_, void* wout, void* wnodeID, mask.foreach ([=](ActiveLane lane) -> void { int nodeID = wNID[lane]; ustring query = wQ[lane]; - wOut[lane] = bsg->uniform.context->dict_find( - nullptr /*causes errors be reported through ShadingContext*/, - nodeID, query); + // TODO FIXME + //wOut[lane] = bsg->uniform.context->dict_find( + // nullptr causes errors be reported through ShadingContext, + // nodeID, query); }); } OSL_BATCHOP int -__OSL_OP(dict_find_iss)(void* bsg_, ustring_pod dictionary, ustring_pod query) +__OSL_OP(dict_find_iss)(void* bsg_, ustringhash_pod dictionary, + ustringhash_pod query) { auto* bsg = reinterpret_cast(bsg_); - return bsg->uniform.context->dict_find( - nullptr /*causes errors be reported through ShadingContext*/, - USTR(dictionary), USTR(query)); + // TOOD FIXME + //return bsg->uniform.context->dict_find( + // nullptr causes errors be reported through ShadingContext, + // ustring_from(dictionary), ustring_from(query)); + return 0; } @@ -108,9 +114,10 @@ __OSL_MASKED_OP3(dict_find, Wi, Ws, Ws)(void* bsg_, void* wout, mask.foreach ([=](ActiveLane lane) -> void { ustring dictionary = wD[lane]; ustring query = wQ[lane]; - wOut[lane] = bsg->uniform.context->dict_find( - nullptr /*causes errors be reported through ShadingContext*/, - dictionary, query); + //TODO FIXME + //wOut[lane] = bsg->uniform.context->dict_find( + // nullptr causes errors be reported through ShadingContext, + // dictionary, query); }); } @@ -119,7 +126,9 @@ OSL_BATCHOP int __OSL_OP(dict_next)(void* bsg_, int nodeID) { auto* bsg = reinterpret_cast(bsg_); - return bsg->uniform.context->dict_next(nodeID); + // TODO FIXME + //return bsg->uniform.context->dict_next(nodeID); + return 0; } @@ -138,20 +147,23 @@ __OSL_MASKED_OP(dict_next)(void* bsg_, void* wout, void* wNodeID, mask.foreach ([=](ActiveLane lane) -> void { int nodeID = wNID[lane]; - wR[lane] = bsg->uniform.context->dict_next(nodeID); + // TODO FIXME + //wR[lane] = bsg->uniform.context->dict_next(nodeID); }); } OSL_BATCHOP int -__OSL_OP(dict_value)(void* bsg_, int nodeID, ustring_pod attribname, +__OSL_OP(dict_value)(void* bsg_, int nodeID, ustringhash_pod attribname, long long type, void* data) { auto* bsg = reinterpret_cast(bsg_); - return bsg->uniform.context->dict_value(nodeID, USTR(attribname), - TYPEDESC(type), data, - /*treat_ustrings_as_hash*/ false); + // TODO FIXME + //return bsg->uniform.context->dict_value(nodeID, ustring_from(attribname), + // TYPEDESC(type), data, + // treat_ustrings_as_hash false); + return 0; } namespace { // anonymous @@ -169,9 +181,11 @@ template struct DictValueGetter { ustring attribname = wAttribName[lane]; ValueT value; - int result = context->dict_value(nodeID, attribname, wdest.type(), - &value, - /*treat_ustrings_as_hash*/ false); + // TODO FIXME + //int result = context->dict_value(nodeID, attribname, wdest.type(), + // &value, + // treat_ustrings_as_hash false); + int result = 0; wout[lane] = result; if (result) { dest[lane] = value; @@ -192,9 +206,11 @@ template struct DictValueGetter { int nodeID = wNID[lane]; ustring attribname = wAttribName[lane]; ElementType value[dest_array.length()]; - int result = context->dict_value(nodeID, attribname, wdest.type(), - &value[0], - /*treat_ustrings_as_hash*/ false); + // TODO FIXME + //int result = context->dict_value(nodeID, attribname, wdest.type(), + // &value[0], + // treat_ustrings_as_hash false); + int result = 0; auto dest = dest_array[lane]; for (int element = 0; element < dest.length(); ++element) { dest[element] = value[element]; diff --git a/src/liboslexec/wide/wide_opmatrix.cpp b/src/liboslexec/wide/wide_opmatrix.cpp index 33b3ef2aa..3502035f2 100644 --- a/src/liboslexec/wide/wide_opmatrix.cpp +++ b/src/liboslexec/wide/wide_opmatrix.cpp @@ -51,7 +51,7 @@ inline void block_ustringhash_from_ptr(Block& b, const void* w_ptr) { for (int i = 0; i < __OSL_WIDTH; ++i) - b.set(i, reinterpret_cast(w_ptr)[i]); + b.set(i, reinterpret_cast(w_ptr)[i]); } @@ -532,39 +532,42 @@ makeIdentity(Masked wrm) OSL_FORCEINLINE Mask impl_get_uniform_from_matrix_masked(void* bsg_, Masked wrm, - const char* from) + ustringhash_pod from_) { + ustringhash from = ustringhash_from(from_); auto* bsg = reinterpret_cast(bsg_); ShadingContext* ctx = bsg->uniform.context; - if (USTR(from) == Strings::common - || USTR(from) == ctx->shadingsys().commonspace_synonym()) { + if (from == Hashes::common + || from == ctx->shadingsys().commonspace_synonym_hash()) { makeIdentity(wrm); return wrm.mask(); } - if (USTR(from) == Strings::shader) { + if (from == Hashes::shader) { ctx->batched<__OSL_WIDTH>().renderer()->get_matrix( bsg, wrm, bsg->varying.shader2common, bsg->varying.time); // NOTE: matching scalar version of code which ignores the renderservices return value return wrm.mask(); } - if (USTR(from) == Strings::object) { + if (from == Hashes::object) { ctx->batched<__OSL_WIDTH>().renderer()->get_matrix( bsg, wrm, bsg->varying.object2common, bsg->varying.time); // NOTE: matching scalar version of code which ignores the renderservices return value return wrm.mask(); } - Mask succeeded = ctx->batched<__OSL_WIDTH>().renderer()->get_matrix( - bsg, wrm, USTR(from), bsg->varying.time); + Mask succeeded + = ctx->batched<__OSL_WIDTH>().renderer()->get_matrix(bsg, wrm, from, + bsg->varying.time); auto failedResults = wrm & succeeded.invert(); if (failedResults.mask().any_on()) { makeIdentity(failedResults); ShadingContext* ctx = bsg->uniform.context; if (ctx->shadingsys().unknown_coordsys_error()) { - ctx->errorfmt("Unknown transformation \"{}\"", from); + // TODO FIXME + //ctx->errorfmt("Unknown transformation \"{}\"", from); } } return succeeded; @@ -572,24 +575,25 @@ impl_get_uniform_from_matrix_masked(void* bsg_, Masked wrm, OSL_FORCEINLINE Mask impl_get_uniform_to_inverse_matrix_masked(void* bsg_, Masked wrm, - const char* to) + ustringhash_pod to_) { + ustringhash to = ustringhash_from(to_); auto* bsg = reinterpret_cast(bsg_); ShadingContext* ctx = bsg->uniform.context; - if (USTR(to) == Strings::common - || USTR(to) == ctx->shadingsys().commonspace_synonym()) { + if (to == Hashes::common + || to == ctx->shadingsys().commonspace_synonym_hash()) { makeIdentity(wrm); return wrm.mask(); } - if (USTR(to) == Strings::shader) { + if (to == Hashes::shader) { dispatch_get_inverse_matrix(ctx->batched<__OSL_WIDTH>().renderer(), bsg, wrm, bsg->varying.shader2common, bsg->varying.time); // NOTE: matching scalar version of code which ignores the renderservices return value return wrm.mask(); } - if (USTR(to) == Strings::object) { + if (to == Hashes::object) { dispatch_get_inverse_matrix(ctx->batched<__OSL_WIDTH>().renderer(), bsg, wrm, bsg->varying.object2common, bsg->varying.time); @@ -602,13 +606,14 @@ impl_get_uniform_to_inverse_matrix_masked(void* bsg_, Masked wrm, // so no need to make sure that the values are valid (assuming FP exceptions are disabled) Mask succeeded = dispatch_get_inverse_matrix(ctx->batched<__OSL_WIDTH>().renderer(), - bsg, wrm, USTR(to), bsg->varying.time); + bsg, wrm, to, bsg->varying.time); auto failedResults = wrm & succeeded.invert(); if (failedResults.mask().any_on()) { makeIdentity(failedResults); if (ctx->shadingsys().unknown_coordsys_error()) { - ctx->errorfmt("Unknown transformation \"{}\"", to); + // TODO FIXME + //ctx->errorfmt("Unknown transformation \"{}\"", to); } } return succeeded; @@ -641,7 +646,8 @@ impl_get_varying_from_matrix_batched(BatchedShaderGlobals* bsg, Masked wMfrom) { // Deal with a varying 'from' space - ustring commonspace_synonym = ctx->shadingsys().commonspace_synonym(); + ustringhash commonspace_synonym + = ctx->shadingsys().commonspace_synonym_hash(); // Use int instead of Mask<> to allow reduction clause in openmp simd declaration int common_space_bits { 0 }; @@ -651,20 +657,23 @@ impl_get_varying_from_matrix_batched(BatchedShaderGlobals* bsg, OSL_FORCEINLINE_BLOCK { + // TODO re-enable failing for unknown reason after change from Strings:: to Hashes:: + /* OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH) reduction(| : common_space_bits, shader_space_bits, object_space_bits, named_space_bits)) + */ for (int lane = 0; lane < __OSL_WIDTH; ++lane) { - ustringhash from = wFrom[lane]; + ustringhash from = unproxy(wFrom[lane]); if (wMfrom.mask()[lane]) { - if (from == Strings::common || from == commonspace_synonym) { + if (from == Hashes::common || from == commonspace_synonym) { // inline of Mask::set_on(lane) common_space_bits |= 1 << lane; - } else if (from == Strings::shader) { + } else if (from == Hashes::shader) { // inline of Mask::set_on(lane) shader_space_bits |= 1 << lane; - } else if (from == Strings::object) { + } else if (from == Hashes::object) { // inline of Mask::set_on(lane) object_space_bits |= 1 << lane; } else { @@ -714,9 +723,10 @@ impl_get_varying_from_matrix_batched(BatchedShaderGlobals* bsg, for (int lane = 0; lane < __OSL_WIDTH; ++lane) { if (failedLanes[lane]) { ustringhash from = wFrom[lane]; - ctx->batched<__OSL_WIDTH>().errorfmt( - Mask(Lane(lane)), "Unknown transformation \"{}\"", - ustring(from)); + // TODO FIXME + //ctx->batched<__OSL_WIDTH>().errorfmt( + // Mask(Lane(lane)), "Unknown transformation \"{}\"", + // ustring(from)); } } } @@ -731,7 +741,7 @@ impl_get_varying_from_matrix_batched(BatchedShaderGlobals* bsg, OSL_BATCHOP void __OSL_MASKED_OP2(prepend_matrix_from, Wm, s)(void* bsg_, void* wr, - const char* from, + ustringhash_pod from_, unsigned int mask_value) { auto* bsg = reinterpret_cast(bsg_); @@ -739,7 +749,7 @@ __OSL_MASKED_OP2(prepend_matrix_from, Wm, s)(void* bsg_, void* wr, Block wMfrom; Masked from_matrix(wMfrom, Mask(mask_value)); /*Mask succeeded =*/ - impl_get_uniform_from_matrix_masked(bsg, from_matrix, from); + impl_get_uniform_from_matrix_masked(bsg, from_matrix, from_); Masked wrm(wr, Mask(mask_value)); @@ -779,7 +789,8 @@ impl_get_varying_to_matrix_masked(BatchedShaderGlobals* bsg, Masked wMto) { // Deal with a varying 'to' space - ustring commonspace_synonym = ctx->shadingsys().commonspace_synonym(); + ustringhash commonspace_synonym + = ctx->shadingsys().commonspace_synonym_hash(); // Use int instead of Mask<> to allow reduction clause in openmp simd declaration int common_space_bits { 0 }; @@ -789,20 +800,22 @@ impl_get_varying_to_matrix_masked(BatchedShaderGlobals* bsg, OSL_FORCEINLINE_BLOCK { + // TODO re-enable failing for unknown reason after change from Strings:: to Hashes:: + /* OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH) reduction(| : common_space_bits, shader_space_bits, - object_space_bits, named_space_bits)) + object_space_bits, named_space_bits))*/ for (int lane = 0; lane < __OSL_WIDTH; ++lane) { ustringhash to = wTo[lane]; if (wMto.mask()[lane]) { - if (to == Strings::common || to == commonspace_synonym) { + if (to == Hashes::common || to == commonspace_synonym) { // inline of Mask::set_on(lane) common_space_bits |= 1 << lane; - } else if (to == Strings::shader) { + } else if (to == Hashes::shader) { // inline of Mask::set_on(lane) shader_space_bits |= 1 << lane; - } else if (to == Strings::object) { + } else if (to == Hashes::object) { // inline of Mask::set_on(lane) object_space_bits |= 1 << lane; } else { @@ -850,9 +863,10 @@ impl_get_varying_to_matrix_masked(BatchedShaderGlobals* bsg, for (int lane = 0; lane < __OSL_WIDTH; ++lane) { if (failedLanes[lane]) { ustringhash to = wTo[lane]; - ctx->batched<__OSL_WIDTH>().errorfmt( - Mask(Lane(lane)), "Unknown transformation \"{}\"", - ustring(to)); + // TODO FIXME + //ctx->batched<__OSL_WIDTH>().errorfmt( + // Mask(Lane(lane)), "Unknown transformation \"{}\"", + // ustring(to)); } } } @@ -867,18 +881,19 @@ impl_get_varying_to_matrix_masked(BatchedShaderGlobals* bsg, OSL_FORCEINLINE Mask impl_get_uniform_from_to_matrix_masked(BatchedShaderGlobals* bsg, - Masked wrm, const char* from, - const char* to) + Masked wrm, + ustringhash_pod from_, + ustringhash_pod to_) { Block wMfrom, wMto; Masked from_matrix(wMfrom, wrm.mask()); Mask succeeded = impl_get_uniform_from_matrix_masked(bsg, from_matrix, - from); + from_); // NOTE: even if we failed to get a from matrix, it should have been set to // identity, so we still need to try to get the to matrix for the original mask Masked to_matrix(wMto, wrm.mask()); - succeeded &= impl_get_uniform_to_inverse_matrix_masked(bsg, to_matrix, to); + succeeded &= impl_get_uniform_to_inverse_matrix_masked(bsg, to_matrix, to_); impl_wide_mat_multiply(wrm, from_matrix, to_matrix); return succeeded; @@ -886,27 +901,27 @@ impl_get_uniform_from_to_matrix_masked(BatchedShaderGlobals* bsg, } // namespace OSL_BATCHOP int -__OSL_MASKED_OP3(get_from_to_matrix, Wm, s, s)(void* bsg_, void* wr, - const char* from, const char* to, - unsigned int mask_value) +__OSL_MASKED_OP3(get_from_to_matrix, Wm, s, + s)(void* bsg_, void* wr, ustringhash_pod from_, + ustringhash_pod to_, unsigned int mask_value) { auto* bsg = reinterpret_cast(bsg_); Masked wrm(wr, Mask(mask_value)); - return impl_get_uniform_from_to_matrix_masked(bsg, wrm, from, to).value(); + return impl_get_uniform_from_to_matrix_masked(bsg, wrm, from_, to_).value(); } OSL_BATCHOP int __OSL_MASKED_OP3(get_from_to_matrix, Wm, s, - Ws)(void* bsg_, void* wr, const char* from, void* w_to_ptr, - unsigned int mask_value) + Ws)(void* bsg_, void* wr, ustringhash_pod from_, + void* w_to_ptr, unsigned int mask_value) { auto* bsg = reinterpret_cast(bsg_); ShadingContext* ctx = bsg->uniform.context; Block wMfrom; Masked from_matrix(wMfrom, Mask(mask_value)); Mask succeeded = impl_get_uniform_from_matrix_masked(bsg, from_matrix, - from); + from_); Block bwToSpace; block_ustringhash_from_ptr(bwToSpace, w_to_ptr); @@ -927,7 +942,7 @@ __OSL_MASKED_OP3(get_from_to_matrix, Wm, s, OSL_BATCHOP int __OSL_MASKED_OP3(get_from_to_matrix, Wm, Ws, - s)(void* bsg_, void* wr, void* w_from_ptr, const char* to, + s)(void* bsg_, void* wr, void* w_from_ptr, ustringhash_pod to_, unsigned int mask_value) { auto* bsg = reinterpret_cast(bsg_); @@ -940,7 +955,7 @@ __OSL_MASKED_OP3(get_from_to_matrix, Wm, Ws, Block wMto; Masked to_matrix(wMto, Mask(mask_value)); Mask succeeded = impl_get_uniform_to_inverse_matrix_masked(bsg, to_matrix, - to); + to_); Block wMfrom; // NOTE: even if we failed to get a to matrix, it should have been set to @@ -1001,34 +1016,30 @@ __OSL_MASKED_OP3(get_from_to_matrix, Wm, Ws, OSL_BATCHOP int __OSL_MASKED_OP3(build_transform_matrix, Wm, s, - s)(void* bsg_, void* WM_, ustring_pod from_, ustring_pod to_, - unsigned int mask_value) + s)(void* bsg_, void* WM_, ustringhash_pod from_, + ustringhash_pod to_, unsigned int mask_value) { - auto* bsg = reinterpret_cast(bsg_); + ustringhash from = ustringhash_from(from_); + ustringhash to = ustringhash_from(to_); + auto* bsg = reinterpret_cast(bsg_); Mask mask(mask_value); Masked mm(WM_, mask); ShadingContext* ctx = bsg->uniform.context; - ustring from = USTR(from_); - ustring to = USTR(to_); - Mask succeeded; // Avoid matrix concatenation if possible by detecting when the // adjacent matrix would be identity // We don't expect both from and to == common, so we are not // optimizing for it - if (from == Strings::common - || from == ctx->shadingsys().commonspace_synonym()) { - succeeded = impl_get_uniform_to_inverse_matrix_masked(bsg, mm, - to.c_str()); - } else if (to == Strings::common - || to == ctx->shadingsys().commonspace_synonym()) { - succeeded = impl_get_uniform_from_matrix_masked(bsg, mm, from.c_str()); + if (from == Hashes::common + || from == ctx->shadingsys().commonspace_synonym_hash()) { + succeeded = impl_get_uniform_to_inverse_matrix_masked(bsg, mm, to_); + } else if (to == Hashes::common + || to == ctx->shadingsys().commonspace_synonym_hash()) { + succeeded = impl_get_uniform_from_matrix_masked(bsg, mm, from_); } else { - succeeded = impl_get_uniform_from_to_matrix_masked(bsg, mm, - from.c_str(), - to.c_str()); + succeeded = impl_get_uniform_from_to_matrix_masked(bsg, mm, from_, to_); } return succeeded.value(); } @@ -1037,7 +1048,7 @@ __OSL_MASKED_OP3(build_transform_matrix, Wm, s, OSL_BATCHOP int __OSL_MASKED_OP3(build_transform_matrix, Wm, Ws, - s)(void* bsg_, void* WM_, void* wfrom_, ustring_pod to_, + s)(void* bsg_, void* WM_, void* wfrom_, ustringhash_pod to_, unsigned int mask_value) { auto* bsg = reinterpret_cast(bsg_); @@ -1049,8 +1060,6 @@ __OSL_MASKED_OP3(build_transform_matrix, Wm, Ws, block_ustringhash_from_ptr(bwfrom_space, wfrom_); Wide wfrom_space(bwfrom_space); - ustring to_space = USTR(to_); - Block wMfrom, wMto; Masked from_matrix(wMfrom, wrm.mask()); ShadingContext* ctx = bsg->uniform.context; @@ -1058,8 +1067,7 @@ __OSL_MASKED_OP3(build_transform_matrix, Wm, Ws, Mask succeeded = impl_get_varying_from_matrix_batched(bsg, ctx, wfrom_space, from_matrix); Masked to_matrix(wMto, wrm.mask() & succeeded); - succeeded &= impl_get_uniform_to_inverse_matrix_masked(bsg, to_matrix, - to_space.c_str()); + succeeded &= impl_get_uniform_to_inverse_matrix_masked(bsg, to_matrix, to_); impl_wide_mat_multiply(wrm, from_matrix, to_matrix); return succeeded.value(); @@ -1069,7 +1077,7 @@ __OSL_MASKED_OP3(build_transform_matrix, Wm, Ws, OSL_BATCHOP int __OSL_MASKED_OP3(build_transform_matrix, Wm, s, - Ws)(void* bsg_, void* WM_, ustring_pod from_, void* wto_, + Ws)(void* bsg_, void* WM_, ustringhash_pod from_, void* wto_, unsigned int mask_value) { auto* bsg = reinterpret_cast(bsg_); @@ -1077,7 +1085,6 @@ __OSL_MASKED_OP3(build_transform_matrix, Wm, s, Mask mask(mask_value); Masked wrm(WM_, mask); - ustring from = USTR(from_); Block bwto_space; block_ustringhash_from_ptr(bwto_space, wto_); Wide wto_space(bwto_space); @@ -1087,7 +1094,7 @@ __OSL_MASKED_OP3(build_transform_matrix, Wm, s, ShadingContext* ctx = bsg->uniform.context; Mask succeeded = impl_get_uniform_from_matrix_masked(bsg, from_matrix, - from.c_str()); + from_); Masked to_matrix(wMto, wrm.mask() & succeeded); succeeded &= impl_get_varying_to_matrix_masked(bsg, ctx, wto_space, to_matrix); diff --git a/src/liboslexec/wide/wide_opmessage.cpp b/src/liboslexec/wide/wide_opmessage.cpp index de426f9c7..0d0fd074e 100644 --- a/src/liboslexec/wide/wide_opmessage.cpp +++ b/src/liboslexec/wide/wide_opmessage.cpp @@ -163,7 +163,6 @@ impl_setmessage(BatchedShaderGlobals* bsg, ustring sourcefile, int sourceline, lanes_with_data.foreach ([=](ActiveLane lane) -> void { ustring msg_sourcefile = msg_wsourcefile[lane]; int msg_sourceline = msg_wsourceline[lane]; - bsg->uniform.context->batched<__OSL_WIDTH>().errorfmt( lanes_with_data, "message \"{}\" already exists (created here: {}:{})" @@ -183,6 +182,7 @@ impl_setmessage(BatchedShaderGlobals* bsg, ustring sourcefile, int sourceline, lanes_that_getmessage_called_on.foreach ([=](ActiveLane lane) -> void { ustring msg_sourcefile = msg_wsourcefile[lane]; int msg_sourceline = msg_wsourceline[lane]; + bsg->uniform.context->batched<__OSL_WIDTH>().errorfmt( Mask(Lane(lane)), "message \"{}\" was queried before being set (queried here: {}:{})" @@ -201,18 +201,19 @@ impl_setmessage(BatchedShaderGlobals* bsg, ustring sourcefile, int sourceline, OSL_BATCHOP void __OSL_MASKED_OP2(setmessage, s, WX)(BatchedShaderGlobals* bsg_, - ustring_pod name_, long long type, + ustringhash_pod name_, long long type, void* wvalue, int layeridx, - ustring_pod sourcefile_, int sourceline, + ustringhash_pod sourcefile_, int sourceline, unsigned int mask_value) { Mask mask(mask_value); OSL_ASSERT(mask.any_on()); - ustring name = USTR(name_); + ustring name = ustring_from(name_); + MaskedData wsrcval(TYPEDESC(type), false /*has_derivs*/, mask, wvalue); - ustring sourcefile = USTR(sourcefile_); + ustring sourcefile = ustring_from(sourcefile_); auto* bsg = reinterpret_cast(bsg_); @@ -238,8 +239,8 @@ __OSL_MASKED_OP2(setmessage, s, WX)(BatchedShaderGlobals* bsg_, OSL_BATCHOP void __OSL_MASKED_OP2(setmessage, Ws, WX)(BatchedShaderGlobals* bsg_, void* wname, long long type, void* wvalue, int layeridx, - ustring_pod sourcefile_, int sourceline, - unsigned int mask_value) + ustringhash_pod sourcefile_, + int sourceline, unsigned int mask_value) { Mask mask(mask_value); OSL_ASSERT(mask.any_on()); @@ -247,7 +248,7 @@ __OSL_MASKED_OP2(setmessage, Ws, WX)(BatchedShaderGlobals* bsg_, void* wname, Wide wName(wname); MaskedData wsrcval(TYPEDESC(type), false /*has_derivs*/, mask, wvalue); - ustring sourcefile = USTR(sourcefile_); + ustring sourcefile = ustring_from(sourcefile_); auto* bsg = reinterpret_cast(bsg_); @@ -275,14 +276,15 @@ __OSL_MASKED_OP2(setmessage, Ws, WX)(BatchedShaderGlobals* bsg_, void* wname, OSL_BATCHOP void -__OSL_MASKED_OP(getmessage)(void* bsg_, void* result, ustring_pod source_, - ustring_pod name_, long long type_, void* val, - int derivs, int layeridx, ustring_pod sourcefile_, - int sourceline, unsigned int mask_value) +__OSL_MASKED_OP(getmessage)(void* bsg_, void* result, ustringhash_pod source_, + ustringhash_pod name_, long long type_, void* val, + int derivs, int layeridx, + ustringhash_pod sourcefile_, int sourceline, + unsigned int mask_value) { - ustring source = USTR(source_); - ustring name = USTR(name_); - ustring sourcefile = USTR(sourcefile_); + ustring source = ustring_from(source_); + ustring name = ustring_from(name_); + ustring sourcefile = ustring_from(sourcefile_); Mask mask(mask_value); @@ -301,7 +303,7 @@ __OSL_MASKED_OP(getmessage)(void* bsg_, void* result, ustring_pod source_, static ustring ktrace("trace"); OSL_ASSERT(val != nullptr); MaskedData valRef(type, derivs, mask, val); - if (USTR(source_) == ktrace) { + if (source == ktrace) { // Source types where we need to ask the renderer return bsg->uniform.renderer->batched(WidthTag()) ->getmessage(bsg, wR, source, name, valRef); diff --git a/src/liboslexec/wide/wide_opnoise_gabor_impl.cpp b/src/liboslexec/wide/wide_opnoise_gabor_impl.cpp index 7dd2b66b5..8008c18f3 100644 --- a/src/liboslexec/wide/wide_opnoise_gabor_impl.cpp +++ b/src/liboslexec/wide/wide_opnoise_gabor_impl.cpp @@ -79,8 +79,8 @@ dispatch_Vec3_result(const NoiseParams* opt, Block* opt_varying_direction, } // namespace OSL_BATCHOP void -__OSL_NOISE_OP2(Wdf, Wdf)(char* name, char* r_ptr, char* x_ptr, char* bsg, - char* opt, char* varying_direction_ptr, +__OSL_NOISE_OP2(Wdf, Wdf)(ustringhash_pod name, char* r_ptr, char* x_ptr, + char* bsg, char* opt, char* varying_direction_ptr, unsigned int mask_value) { dispatch_float_result(reinterpret_cast(opt), @@ -92,7 +92,7 @@ __OSL_NOISE_OP2(Wdf, Wdf)(char* name, char* r_ptr, char* x_ptr, char* bsg, OSL_BATCHOP void -__OSL_NOISE_OP3(Wdf, Wdf, Wdf)(char* name, char* r_ptr, char* x_ptr, +__OSL_NOISE_OP3(Wdf, Wdf, Wdf)(ustringhash_pod name, char* r_ptr, char* x_ptr, char* y_ptr, char* bsg, char* opt, char* varying_direction_ptr, unsigned int mask_value) @@ -107,8 +107,8 @@ __OSL_NOISE_OP3(Wdf, Wdf, Wdf)(char* name, char* r_ptr, char* x_ptr, OSL_BATCHOP void -__OSL_NOISE_OP2(Wdf, Wdv)(char* name, char* r_ptr, char* p_ptr, char* bsg, - char* opt, char* varying_direction_ptr, +__OSL_NOISE_OP2(Wdf, Wdv)(ustringhash_pod name, char* r_ptr, char* p_ptr, + char* bsg, char* opt, char* varying_direction_ptr, unsigned int mask_value) { dispatch_float_result(reinterpret_cast(opt), @@ -120,7 +120,7 @@ __OSL_NOISE_OP2(Wdf, Wdv)(char* name, char* r_ptr, char* p_ptr, char* bsg, OSL_BATCHOP void -__OSL_NOISE_OP3(Wdf, Wdv, Wdf)(char* name, char* r_ptr, char* p_ptr, +__OSL_NOISE_OP3(Wdf, Wdv, Wdf)(ustringhash_pod name, char* r_ptr, char* p_ptr, char* t_ptr, char* bsg, char* opt, char* varying_direction_ptr, unsigned int mask_value) @@ -135,7 +135,7 @@ __OSL_NOISE_OP3(Wdf, Wdv, Wdf)(char* name, char* r_ptr, char* p_ptr, OSL_BATCHOP void -__OSL_NOISE_OP3(Wdv, Wdv, Wdf)(char* name, char* r_ptr, char* p_ptr, +__OSL_NOISE_OP3(Wdv, Wdv, Wdf)(ustringhash_pod name, char* r_ptr, char* p_ptr, char* t_ptr, char* bsg, char* opt, char* varying_direction_ptr, unsigned int mask_value) @@ -150,8 +150,8 @@ __OSL_NOISE_OP3(Wdv, Wdv, Wdf)(char* name, char* r_ptr, char* p_ptr, OSL_BATCHOP void -__OSL_NOISE_OP2(Wdv, Wdf)(char* name, char* r_ptr, char* x_ptr, char* bsg, - char* opt, char* varying_direction_ptr, +__OSL_NOISE_OP2(Wdv, Wdf)(ustringhash_pod name, char* r_ptr, char* x_ptr, + char* bsg, char* opt, char* varying_direction_ptr, unsigned int mask_value) { dispatch_Vec3_result(reinterpret_cast(opt), @@ -163,7 +163,7 @@ __OSL_NOISE_OP2(Wdv, Wdf)(char* name, char* r_ptr, char* x_ptr, char* bsg, OSL_BATCHOP void -__OSL_NOISE_OP3(Wdv, Wdf, Wdf)(char* name, char* r_ptr, char* x_ptr, +__OSL_NOISE_OP3(Wdv, Wdf, Wdf)(ustringhash_pod name, char* r_ptr, char* x_ptr, char* y_ptr, char* bsg, char* opt, char* varying_direction_ptr, unsigned int mask_value) @@ -178,8 +178,8 @@ __OSL_NOISE_OP3(Wdv, Wdf, Wdf)(char* name, char* r_ptr, char* x_ptr, OSL_BATCHOP void -__OSL_NOISE_OP2(Wdv, Wdv)(char* name, char* r_ptr, char* p_ptr, char* bsg, - char* opt, char* varying_direction_ptr, +__OSL_NOISE_OP2(Wdv, Wdv)(ustringhash_pod name, char* r_ptr, char* p_ptr, + char* bsg, char* opt, char* varying_direction_ptr, unsigned int mask_value) { dispatch_Vec3_result(reinterpret_cast(opt), diff --git a/src/liboslexec/wide/wide_opnoise_generic_impl.cpp b/src/liboslexec/wide/wide_opnoise_generic_impl.cpp index 2f5679ada..8f6ff99dd 100644 --- a/src/liboslexec/wide/wide_opnoise_generic_impl.cpp +++ b/src/liboslexec/wide/wide_opnoise_generic_impl.cpp @@ -78,11 +78,9 @@ zero_derivs(Masked> wr) #define __OSL_GENERIC_DISPATCH2(A, B, NONDERIV_A, NONDERIV_B, DUALTYPE) \ - OSL_BATCHOP void __OSL_MASKED_OP2(gabornoise, A, \ - B)(char* name_ptr, char* r_ptr, \ - char* x_ptr, char* bsg, char* opt, \ - char* varying_direction_ptr, \ - unsigned int mask_value); \ + OSL_BATCHOP void __OSL_MASKED_OP2(gabornoise, A, B)( \ + ustringhash_pod name_ptr, char* r_ptr, char* x_ptr, char* bsg, \ + char* opt, char* varying_direction_ptr, unsigned int mask_value); \ OSL_BATCHOP void __OSL_MASKED_OP2(noise, A, B)(char* r_ptr, char* x_ptr, \ unsigned int mask_value); \ OSL_BATCHOP void __OSL_MASKED_OP2(simplexnoise, A, \ @@ -105,38 +103,35 @@ zero_derivs(Masked> wr) OSL_BATCHOP void __OSL_MASKED_OP2(hashnoise, NONDERIV_A, \ NONDERIV_B)(char* r_ptr, char* x_ptr, \ unsigned int mask_value); \ - OSL_BATCHOP void __OSL_MASKED_OP2(genericnoise, A, \ - B)(char* name_ptr, char* r_ptr, \ - char* x_ptr, char* bsg, char* opt, \ - char* varying_direction_ptr, \ - unsigned int mask_value) \ + OSL_BATCHOP void __OSL_MASKED_OP2(genericnoise, A, B)( \ + ustringhash_pod name_ptr, char* r_ptr, char* x_ptr, char* bsg, \ + char* opt, char* varying_direction_ptr, unsigned int mask_value) \ { \ - ustring name = USTR(name_ptr); \ - if (name == Strings::uperlin || name == Strings::noise) { \ + ustringhash name = ustringhash_from(name_ptr); \ + if (name == Hashes::uperlin || name == Hashes::noise) { \ __OSL_MASKED_OP2(noise, A, B)(r_ptr, x_ptr, mask_value); \ - } else if (name == Strings::perlin || name == Strings::snoise) { \ + } else if (name == Hashes::perlin || name == Hashes::snoise) { \ __OSL_MASKED_OP2(snoise, A, B)(r_ptr, x_ptr, mask_value); \ - } else if (name == Strings::simplexnoise \ - || name == Strings::simplex) { \ + } else if (name == Hashes::simplexnoise || name == Hashes::simplex) { \ __OSL_MASKED_OP2(simplexnoise, A, B)(r_ptr, x_ptr, mask_value); \ - } else if (name == Strings::usimplexnoise \ - || name == Strings::usimplex) { \ + } else if (name == Hashes::usimplexnoise \ + || name == Hashes::usimplex) { \ __OSL_MASKED_OP2(usimplexnoise, A, B)(r_ptr, x_ptr, mask_value); \ - } else if (name == Strings::cell) { \ + } else if (name == Hashes::cell) { \ /* NOTE: calling non derivative version */ \ __OSL_MASKED_OP2(cellnoise, NONDERIV_A, NONDERIV_B) \ (r_ptr, x_ptr, mask_value); \ Masked wr(r_ptr, Mask(mask_value)); \ zero_derivs(wr); \ - } else if (name == Strings::gabor) { \ + } else if (name == Hashes::gabor) { \ __OSL_MASKED_OP2(gabornoise, A, B) \ (name_ptr, r_ptr, x_ptr, bsg, opt, varying_direction_ptr, \ mask_value); \ - } else if (name == Strings::null) { \ + } else if (name == Hashes::null) { \ __OSL_MASKED_OP2(nullnoise, A, B)(r_ptr, x_ptr, mask_value); \ - } else if (name == Strings::unull) { \ + } else if (name == Hashes::unull) { \ __OSL_MASKED_OP2(unullnoise, A, B)(r_ptr, x_ptr, mask_value); \ - } else if (name == Strings::hash) { \ + } else if (name == Hashes::hash) { \ /* NOTE: calling non derivative version */ \ __OSL_MASKED_OP2(hashnoise, NONDERIV_A, NONDERIV_B) \ (r_ptr, x_ptr, mask_value); \ @@ -155,9 +150,12 @@ __OSL_GENERIC_DISPATCH2(Wdf, Wdf, Wf, Wf, Dual2) #define __OSL_GENERIC_DISPATCH3(A, B, C, NONDERIV_A, NONDERIV_B, NONDERIV_C, \ DUALTYPE) \ - OSL_BATCHOP void __OSL_MASKED_OP3(gabornoise, A, B, C)( \ - char* name_ptr, char* r_ptr, char* x_ptr, char* y_ptr, char* bsg, \ - char* opt, char* varying_direction_ptr, unsigned int mask_value); \ + OSL_BATCHOP void __OSL_MASKED_OP3(gabornoise, A, B, \ + C)(ustringhash_pod name_ptr, \ + char* r_ptr, char* x_ptr, \ + char* y_ptr, char* bsg, char* opt, \ + char* varying_direction_ptr, \ + unsigned int mask_value); \ OSL_BATCHOP void __OSL_MASKED_OP3(noise, A, B, \ C)(char* r_ptr, char* x_ptr, \ char* y_ptr, \ @@ -190,41 +188,43 @@ __OSL_GENERIC_DISPATCH2(Wdf, Wdf, Wf, Wf, Dual2) NONDERIV_C)(char* r_ptr, char* x_ptr, \ char* y_ptr, \ unsigned int mask_value); \ - OSL_BATCHOP void __OSL_MASKED_OP3(genericnoise, A, B, C)( \ - char* name_ptr, char* r_ptr, char* x_ptr, char* y_ptr, char* bsg, \ - char* opt, char* varying_direction_ptr, unsigned int mask_value) \ + OSL_BATCHOP void __OSL_MASKED_OP3(genericnoise, A, B, \ + C)(ustringhash_pod name_ptr, \ + char* r_ptr, char* x_ptr, \ + char* y_ptr, char* bsg, char* opt, \ + char* varying_direction_ptr, \ + unsigned int mask_value) \ { \ - ustring name = USTR(name_ptr); \ - if (name == Strings::uperlin || name == Strings::noise) { \ + ustringhash name = ustringhash_from(name_ptr); \ + if (name == Hashes::uperlin || name == Hashes::noise) { \ __OSL_MASKED_OP3(noise, A, B, C)(r_ptr, x_ptr, y_ptr, mask_value); \ - } else if (name == Strings::perlin || name == Strings::snoise) { \ + } else if (name == Hashes::perlin || name == Hashes::snoise) { \ __OSL_MASKED_OP3(snoise, A, B, C) \ (r_ptr, x_ptr, y_ptr, mask_value); \ - } else if (name == Strings::simplexnoise \ - || name == Strings::simplex) { \ + } else if (name == Hashes::simplexnoise || name == Hashes::simplex) { \ __OSL_MASKED_OP3(simplexnoise, A, B, C) \ (r_ptr, x_ptr, y_ptr, mask_value); \ - } else if (name == Strings::usimplexnoise \ - || name == Strings::usimplex) { \ + } else if (name == Hashes::usimplexnoise \ + || name == Hashes::usimplex) { \ __OSL_MASKED_OP3(usimplexnoise, A, B, C) \ (r_ptr, x_ptr, y_ptr, mask_value); \ - } else if (name == Strings::cell) { \ + } else if (name == Hashes::cell) { \ /* NOTE: calling non derivative version */ \ __OSL_MASKED_OP3(cellnoise, NONDERIV_A, NONDERIV_B, NONDERIV_C) \ (r_ptr, x_ptr, y_ptr, mask_value); \ Masked wr(r_ptr, Mask(mask_value)); \ zero_derivs(wr); \ - } else if (name == Strings::gabor) { \ + } else if (name == Hashes::gabor) { \ __OSL_MASKED_OP3(gabornoise, A, B, C) \ (name_ptr, r_ptr, x_ptr, y_ptr, bsg, opt, varying_direction_ptr, \ mask_value); \ - } else if (name == Strings::null) { \ + } else if (name == Hashes::null) { \ __OSL_MASKED_OP3(nullnoise, A, B, C) \ (r_ptr, x_ptr, y_ptr, mask_value); \ - } else if (name == Strings::unull) { \ + } else if (name == Hashes::unull) { \ __OSL_MASKED_OP3(unullnoise, A, B, C) \ (r_ptr, x_ptr, y_ptr, mask_value); \ - } else if (name == Strings::hash) { \ + } else if (name == Hashes::hash) { \ /* NOTE: calling non derivative version */ \ __OSL_MASKED_OP3(hashnoise, NONDERIV_A, NONDERIV_B, NONDERIV_C) \ (r_ptr, x_ptr, y_ptr, mask_value); \ diff --git a/src/liboslexec/wide/wide_opnoise_impl_deriv_xmacro.h b/src/liboslexec/wide/wide_opnoise_impl_deriv_xmacro.h index b3beb5990..284e6253f 100644 --- a/src/liboslexec/wide/wide_opnoise_impl_deriv_xmacro.h +++ b/src/liboslexec/wide/wide_opnoise_impl_deriv_xmacro.h @@ -62,6 +62,8 @@ __OSL_NOISE_OP2(Wdf, Wdf)(char* r_ptr, char* x_ptr, unsigned int mask_value) { Masked> wresult(r_ptr, Mask(mask_value)); Wide> wx(x_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -76,6 +78,7 @@ __OSL_NOISE_OP2(Wdf, Wdf)(char* r_ptr, char* x_ptr, unsigned int mask_value) }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -100,6 +103,8 @@ __OSL_NOISE_OP3(Wdf, Wdf, Wdf)(char* r_ptr, char* x_ptr, char* y_ptr, Masked> wresult(r_ptr, Mask(mask_value)); Wide> wx(x_ptr); Wide> wy(y_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -115,6 +120,7 @@ __OSL_NOISE_OP3(Wdf, Wdf, Wdf)(char* r_ptr, char* x_ptr, char* y_ptr, }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -138,6 +144,8 @@ __OSL_NOISE_OP2(Wdf, Wdv)(char* r_ptr, char* p_ptr, unsigned int mask_value) { Masked> wresult(r_ptr, Mask(mask_value)); Wide> wp(p_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -152,6 +160,7 @@ __OSL_NOISE_OP2(Wdf, Wdv)(char* r_ptr, char* p_ptr, unsigned int mask_value) }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -176,6 +185,8 @@ __OSL_NOISE_OP3(Wdf, Wdv, Wdf)(char* r_ptr, char* p_ptr, char* t_ptr, Masked> wresult(r_ptr, Mask(mask_value)); Wide> wp(p_ptr); Wide> wt(t_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -191,6 +202,7 @@ __OSL_NOISE_OP3(Wdf, Wdv, Wdf)(char* r_ptr, char* p_ptr, char* t_ptr, }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -216,6 +228,8 @@ __OSL_NOISE_OP2(Wdv, Wdf)(char* r_ptr, char* x_ptr, unsigned int mask_value) { Masked> wresult(r_ptr, Mask(mask_value)); Wide> wx(x_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -230,6 +244,7 @@ __OSL_NOISE_OP2(Wdv, Wdf)(char* r_ptr, char* x_ptr, unsigned int mask_value) }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -254,6 +269,8 @@ __OSL_NOISE_OP3(Wdv, Wdf, Wdf)(char* r_ptr, char* x_ptr, char* y_ptr, Masked> wresult(r_ptr, Mask(mask_value)); Wide> wx(x_ptr); Wide> wy(y_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -269,6 +286,7 @@ __OSL_NOISE_OP3(Wdv, Wdf, Wdf)(char* r_ptr, char* x_ptr, char* y_ptr, }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -292,6 +310,8 @@ __OSL_NOISE_OP2(Wdv, Wdv)(char* r_ptr, char* p_ptr, unsigned int mask_value) { Masked> wresult(r_ptr, Mask(mask_value)); Wide> wp(p_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -306,6 +326,7 @@ __OSL_NOISE_OP2(Wdv, Wdv)(char* r_ptr, char* p_ptr, unsigned int mask_value) }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -329,6 +350,8 @@ __OSL_NOISE_OP3(Wdv, Wdv, Wdf)(char* r_ptr, char* p_ptr, char* t_ptr, Masked> wresult(r_ptr, Mask(mask_value)); Wide> wp(p_ptr); Wide> wt(t_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -344,6 +367,7 @@ __OSL_NOISE_OP3(Wdv, Wdv, Wdf)(char* r_ptr, char* p_ptr, char* t_ptr, }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { diff --git a/src/liboslexec/wide/wide_opnoise_impl_xmacro.h b/src/liboslexec/wide/wide_opnoise_impl_xmacro.h index b7c99ebe2..f88490e6e 100644 --- a/src/liboslexec/wide/wide_opnoise_impl_xmacro.h +++ b/src/liboslexec/wide/wide_opnoise_impl_xmacro.h @@ -59,7 +59,8 @@ __OSL_NOISE_OP2(Wf, Wf)(char* r_ptr, char* x_ptr, unsigned int mask_value) { Masked wresult(r_ptr, Mask(mask_value)); Wide wx(x_ptr); - + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -74,7 +75,7 @@ __OSL_NOISE_OP2(Wf, Wf)(char* r_ptr, char* x_ptr, unsigned int mask_value) }); return; } - +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -99,7 +100,8 @@ __OSL_NOISE_OP3(Wf, Wf, Wf)(char* r_ptr, char* x_ptr, char* y_ptr, Masked wresult(r_ptr, Mask(mask_value)); Wide wx(x_ptr); Wide wy(y_ptr); - + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -115,7 +117,7 @@ __OSL_NOISE_OP3(Wf, Wf, Wf)(char* r_ptr, char* x_ptr, char* y_ptr, }); return; } - +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -139,7 +141,8 @@ __OSL_NOISE_OP2(Wf, Wv)(char* r_ptr, char* p_ptr, unsigned int mask_value) { Masked wresult(r_ptr, Mask(mask_value)); Wide wp(p_ptr); - + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -154,6 +157,7 @@ __OSL_NOISE_OP2(Wf, Wv)(char* r_ptr, char* p_ptr, unsigned int mask_value) }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -178,6 +182,8 @@ __OSL_NOISE_OP3(Wf, Wv, Wf)(char* r_ptr, char* p_ptr, char* t_ptr, Masked wresult(r_ptr, Mask(mask_value)); Wide wp(p_ptr); Wide wt(t_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -193,6 +199,7 @@ __OSL_NOISE_OP3(Wf, Wv, Wf)(char* r_ptr, char* p_ptr, char* t_ptr, }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -219,6 +226,8 @@ __OSL_NOISE_OP2(Wv, Wv)(char* r_ptr, char* p_ptr, unsigned int mask_value) Masked wresult(r_ptr, Mask(mask_value)); Wide wp(p_ptr); typedef BatchedCGPolicy Policy; + // TODO FIXME + /* if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 && wresult.mask().count() < Policy::simd_threshold)) { @@ -232,6 +241,7 @@ __OSL_NOISE_OP2(Wv, Wv)(char* r_ptr, char* p_ptr, unsigned int mask_value) }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -255,6 +265,8 @@ __OSL_NOISE_OP2(Wv, Wf)(char* r_ptr, char* x_ptr, unsigned int mask_value) Masked wresult(r_ptr, Mask(mask_value)); Wide wx(x_ptr); typedef BatchedCGPolicy Policy; + // TODO FIXME + /* if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 && wresult.mask().count() < Policy::simd_threshold)) { @@ -268,6 +280,7 @@ __OSL_NOISE_OP2(Wv, Wf)(char* r_ptr, char* x_ptr, unsigned int mask_value) }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -292,6 +305,8 @@ __OSL_NOISE_OP3(Wv, Wv, Wf)(char* r_ptr, char* p_ptr, char* t_ptr, Masked wresult(r_ptr, Mask(mask_value)); Wide wp(p_ptr); Wide wt(t_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -307,6 +322,7 @@ __OSL_NOISE_OP3(Wv, Wv, Wf)(char* r_ptr, char* p_ptr, char* t_ptr, }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { @@ -332,6 +348,8 @@ __OSL_NOISE_OP3(Wv, Wf, Wf)(char* r_ptr, char* x_ptr, char* y_ptr, Masked wresult(r_ptr, Mask(mask_value)); Wide wx(x_ptr); Wide wy(y_ptr); + // TODO FIXME + /* typedef BatchedCGPolicy Policy; if (Policy::simd_threshold > __OSL_WIDTH || (Policy::simd_threshold > 1 @@ -347,6 +365,7 @@ __OSL_NOISE_OP3(Wv, Wf, Wf)(char* r_ptr, char* x_ptr, char* y_ptr, }); return; } +*/ __OSL_XMACRO_SFM_IMPLNAME impl; OSL_FORCEINLINE_BLOCK { diff --git a/src/liboslexec/wide/wide_opnoise_periodic_generic_impl.cpp b/src/liboslexec/wide/wide_opnoise_periodic_generic_impl.cpp index 8d0357640..09af37e98 100644 --- a/src/liboslexec/wide/wide_opnoise_periodic_generic_impl.cpp +++ b/src/liboslexec/wide/wide_opnoise_periodic_generic_impl.cpp @@ -24,9 +24,12 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH) #define __OSL_GENERIC_DISPATCH3(A, B, C, NONDERIV_A, NONDERIV_B, DUALTYPE) \ - OSL_BATCHOP void __OSL_MASKED_OP3(gaborpnoise, A, B, C)( \ - char* name_ptr, char* r_ptr, char* x_ptr, char* px_ptr, char* bsg, \ - char* opt, char* varying_direction_ptr, unsigned int mask_value); \ + OSL_BATCHOP void __OSL_MASKED_OP3(gaborpnoise, A, B, \ + C)(ustringhash_pod name_ptr, \ + char* r_ptr, char* x_ptr, \ + char* px_ptr, char* bsg, char* opt, \ + char* varying_direction_ptr, \ + unsigned int mask_value); \ OSL_BATCHOP void __OSL_MASKED_OP3(pnoise, A, B, \ C)(char* r_ptr, char* x_ptr, \ char* px_ptr, \ @@ -43,18 +46,21 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH) C)(char* r_ptr, char* x_ptr, \ char* px_ptr, \ unsigned int mask_value); \ - OSL_BATCHOP void __OSL_MASKED_OP3(genericpnoise, A, B, C)( \ - char* name_ptr, char* r_ptr, char* x_ptr, char* px_ptr, char* bsg, \ - char* opt, char* varying_direction_ptr, unsigned int mask_value) \ + OSL_BATCHOP void __OSL_MASKED_OP3(genericpnoise, A, B, \ + C)(ustringhash_pod name_ptr, \ + char* r_ptr, char* x_ptr, \ + char* px_ptr, char* bsg, char* opt, \ + char* varying_direction_ptr, \ + unsigned int mask_value) \ { \ - ustring name = USTR(name_ptr); \ - if (name == Strings::uperlin || name == Strings::noise) { \ + ustringhash name = ustringhash_from(name_ptr); \ + if (name == Hashes::uperlin || name == Hashes::noise) { \ __OSL_MASKED_OP3(pnoise, A, B, C) \ (r_ptr, x_ptr, px_ptr, mask_value); \ - } else if (name == Strings::perlin || name == Strings::snoise) { \ + } else if (name == Hashes::perlin || name == Hashes::snoise) { \ __OSL_MASKED_OP3(psnoise, A, B, C) \ (r_ptr, x_ptr, px_ptr, mask_value); \ - } else if (name == Strings::cell) { \ + } else if (name == Hashes::cell) { \ /* NOTE: calling non derivative version */ \ __OSL_MASKED_OP3(pcellnoise, NONDERIV_A, NONDERIV_B, C) \ (r_ptr, x_ptr, px_ptr, mask_value); \ @@ -67,11 +73,11 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH) /* TODO: add helper that operates on Block> SOA directly */ \ wr[lane] = result; \ } \ - } else if (name == Strings::gabor) { \ + } else if (name == Hashes::gabor) { \ __OSL_MASKED_OP3(gaborpnoise, A, B, C) \ (name_ptr, r_ptr, x_ptr, px_ptr, bsg, opt, varying_direction_ptr, \ mask_value); \ - } else if (name == Strings::hash) { \ + } else if (name == Hashes::hash) { \ /* NOTE: calling non derivative version */ \ __OSL_MASKED_OP3(phashnoise, NONDERIV_A, NONDERIV_B, C) \ (r_ptr, x_ptr, px_ptr, mask_value); \ @@ -95,9 +101,9 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH) #define __OSL_GENERIC_DISPATCH5(A, B, C, D, E, NONDERIV_A, NONDERIV_B, \ NONDERIV_C, DUALTYPE) \ OSL_BATCHOP void __OSL_MASKED_OP5(gaborpnoise, A, B, C, D, E)( \ - char* name_ptr, char* r_ptr, char* x_ptr, char* y_ptr, char* px_ptr, \ - char* py_ptr, char* bsg, char* opt, char* varying_direction_ptr, \ - unsigned int mask_value); \ + ustringhash_pod name_ptr, char* r_ptr, char* x_ptr, char* y_ptr, \ + char* px_ptr, char* py_ptr, char* bsg, char* opt, \ + char* varying_direction_ptr, unsigned int mask_value); \ OSL_BATCHOP void __OSL_MASKED_OP5(pnoise, A, B, C, D, \ E)(char* r_ptr, char* x_ptr, \ char* y_ptr, char* px_ptr, \ @@ -121,18 +127,18 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH) char* py_ptr, \ unsigned int mask_value); \ OSL_BATCHOP void __OSL_MASKED_OP5(genericpnoise, A, B, C, D, E)( \ - char* name_ptr, char* r_ptr, char* x_ptr, char* y_ptr, char* px_ptr, \ - char* py_ptr, char* bsg, char* opt, char* varying_direction_ptr, \ - unsigned int mask_value) \ + ustringhash_pod name_ptr, char* r_ptr, char* x_ptr, char* y_ptr, \ + char* px_ptr, char* py_ptr, char* bsg, char* opt, \ + char* varying_direction_ptr, unsigned int mask_value) \ { \ - ustring name = USTR(name_ptr); \ - if (name == Strings::uperlin || name == Strings::noise) { \ + ustringhash name = ustringhash_from(name_ptr); \ + if (name == Hashes::uperlin || name == Hashes::noise) { \ __OSL_MASKED_OP5(pnoise, A, B, C, D, E) \ (r_ptr, x_ptr, y_ptr, px_ptr, py_ptr, mask_value); \ - } else if (name == Strings::perlin || name == Strings::snoise) { \ + } else if (name == Hashes::perlin || name == Hashes::snoise) { \ __OSL_MASKED_OP5(psnoise, A, B, C, D, E) \ (r_ptr, x_ptr, y_ptr, px_ptr, py_ptr, mask_value); \ - } else if (name == Strings::cell) { \ + } else if (name == Hashes::cell) { \ /* NOTE: calling non derivative version */ \ __OSL_MASKED_OP5(pcellnoise, NONDERIV_A, NONDERIV_B, NONDERIV_C, \ D, E) \ @@ -146,11 +152,11 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH) /* TODO: add helper that operates on Block> SOA directly */ \ wr[lane] = result; \ } \ - } else if (name == Strings::gabor) { \ + } else if (name == Hashes::gabor) { \ __OSL_MASKED_OP5(gaborpnoise, A, B, C, D, E) \ (name_ptr, r_ptr, x_ptr, y_ptr, px_ptr, py_ptr, bsg, opt, \ varying_direction_ptr, mask_value); \ - } else if (name == Strings::hash) { \ + } else if (name == Hashes::hash) { \ /* NOTE: calling non derivative version */ \ __OSL_MASKED_OP5(phashnoise, NONDERIV_A, NONDERIV_B, NONDERIV_C, \ D, E) \ diff --git a/src/liboslexec/wide/wide_oppointcloud.cpp b/src/liboslexec/wide/wide_oppointcloud.cpp index 1ed34138b..091921e2c 100644 --- a/src/liboslexec/wide/wide_oppointcloud.cpp +++ b/src/liboslexec/wide/wide_oppointcloud.cpp @@ -494,7 +494,7 @@ dispatch_pointcloud_write(BatchedShaderGlobals* bsg, ustringhash filename, OSL_BATCHOP void __OSL_MASKED_OP(pointcloud_search)( - BatchedShaderGlobals* bsg, void* wout_num_points_, ustring_pod filename, + BatchedShaderGlobals* bsg, void* wout_num_points_, ustringhash_pod filename, const void* wcenter_, void* wradius_, int max_points, int sort, void* wout_indices_, int indices_array_length, void* wout_distances_, int distances_array_length, int distances_has_derivs, int mask_value, @@ -521,8 +521,8 @@ __OSL_MASKED_OP(pointcloud_search)( Wide wradius(wradius_); - dispatch_pointcloud_search(bsg, USTR(filename).uhash(), wcenter_, wradius, - max_points, sort, pcsr); + dispatch_pointcloud_search(bsg, ustringhash_from(filename), wcenter_, + wradius, max_points, sort, pcsr); if (nattrs > 0) { Wide windices { wout_indices_, indices_array_length }; @@ -531,12 +531,15 @@ __OSL_MASKED_OP(pointcloud_search)( va_list args; va_start(args, nattrs); for (int i = 0; i < nattrs; i++) { - ustring attr_name = USTR(va_arg(args, ustring_pod)); + ustringhash attr_name = ustringhash_from( + va_arg(args, ustringhash_pod)); TypeDesc attr_type = TYPEDESC(va_arg(args, long long)); void* out_data = va_arg(args, void*); - dispatch_pointcloud_get( - bsg, USTR(filename), windices, wnum_points, attr_name, - MaskedData { attr_type, false, Mask { mask_value }, out_data }); + dispatch_pointcloud_get(bsg, ustringhash_from(filename), windices, + wnum_points, attr_name, + MaskedData { attr_type, false, + Mask { mask_value }, + out_data }); } va_end(args); } @@ -548,11 +551,11 @@ __OSL_MASKED_OP(pointcloud_search)( OSL_BATCHOP int -__OSL_MASKED_OP(pointcloud_get)(BatchedShaderGlobals* bsg, ustring_pod filename, - void* windices_, int indices_array_length, - void* wnum_points_, ustring_pod attr_name, - long long attr_type_, void* wout_data_, - int mask_value) +__OSL_MASKED_OP(pointcloud_get)(BatchedShaderGlobals* bsg, + ustringhash_pod filename, void* windices_, + int indices_array_length, void* wnum_points_, + ustringhash_pod attr_name, long long attr_type_, + void* wout_data_, int mask_value) { ShadingContext* ctx = bsg->uniform.context; if (ctx->shadingsys() @@ -565,8 +568,8 @@ __OSL_MASKED_OP(pointcloud_get)(BatchedShaderGlobals* bsg, ustring_pod filename, TypeDesc attr_type = TYPEDESC(attr_type_); Mask success = dispatch_pointcloud_get( - bsg, USTR(filename).uhash(), windices, wnum_points, - USTR(attr_name).uhash(), + bsg, ustringhash_from(filename), windices, wnum_points, + ustringhash_from(attr_name), MaskedData { attr_type, false, Mask { mask_value }, wout_data_ }); return success.value(); } @@ -575,7 +578,7 @@ __OSL_MASKED_OP(pointcloud_get)(BatchedShaderGlobals* bsg, ustring_pod filename, OSL_BATCHOP int __OSL_MASKED_OP(pointcloud_write)(BatchedShaderGlobals* bsg, - ustring_pod filename, const void* wpos_, + ustringhash_pod filename, const void* wpos_, int nattribs, const ustring* attr_names, const TypeDesc* attr_types, const void** ptrs_to_wide_attr_value, @@ -589,10 +592,10 @@ __OSL_MASKED_OP(pointcloud_write)(BatchedShaderGlobals* bsg, Wide wpos(wpos_); - Mask success = dispatch_pointcloud_write(bsg, USTR(filename).uhash(), wpos, - nattribs, attr_names, attr_types, - ptrs_to_wide_attr_value, - Mask(mask_value)); + Mask success + = dispatch_pointcloud_write(bsg, ustringhash_from(filename), wpos, + nattribs, attr_names, attr_types, + ptrs_to_wide_attr_value, Mask(mask_value)); return success.value(); } diff --git a/src/liboslexec/wide/wide_opspline.cpp b/src/liboslexec/wide/wide_opspline.cpp index 0b77b9cb2..6e48e2bd3 100644 --- a/src/liboslexec/wide/wide_opspline.cpp +++ b/src/liboslexec/wide/wide_opspline.cpp @@ -431,7 +431,7 @@ spline_evaluate_wide_with_static_matrix(RAccessorT wR, XAccessorT wX, template OSL_FORCEINLINE void -spline_evaluate_wide(RAccessorT wR, ustring spline_basis, XAccessorT wX, +spline_evaluate_wide(RAccessorT wR, ustringhash spline_basis, XAccessorT wX, KAccessor_T wK, int knot_count) { typedef void (*FuncPtr)(RAccessorT, XAccessorT, KAccessor_T, @@ -514,8 +514,8 @@ splineinverse_evaluate_wide_with_static_matrix(RAccessorT wR, XAccessorT wX, template OSL_FORCEINLINE void -splineinverse_evaluate_wide(RAccessorT wR, ustring spline_basis, XAccessorT wX, - KAccessor_T wK, int knot_count) +splineinverse_evaluate_wide(RAccessorT wR, ustringhash spline_basis, + XAccessorT wX, KAccessor_T wK, int knot_count) { typedef void (*FuncPtr)(RAccessorT, XAccessorT, KAccessor_T, int /*knot_count*/); @@ -554,12 +554,12 @@ splineinverse_evaluate_wide(RAccessorT wR, ustring spline_basis, XAccessorT wX, // spline (hermite, bezier, etc.) vs. making us doing a bunch of comparisons OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wf, Wf, f)(void* wout_, const char* spline_, void* wx_, - float* knots, int knot_count, +__OSL_MASKED_OP3(spline, Wf, Wf, f)(void* wout_, ustringhash_pod spline_, + void* wx_, float* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { - spline_evaluate_wide(Masked(wout_, Mask(mask_value)), USTR(spline_), - Wide(wx_), + spline_evaluate_wide(Masked(wout_, Mask(mask_value)), + ustringhash_from(spline_), Wide(wx_), UniformAsWide(knots, knot_arraylen), knot_count); } @@ -567,11 +567,12 @@ __OSL_MASKED_OP3(spline, Wf, Wf, f)(void* wout_, const char* spline_, void* wx_, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wf, f, Wf)(void* wout_, const char* spline_, void* wx_, - float* knots, int knot_count, +__OSL_MASKED_OP3(spline, Wf, f, Wf)(void* wout_, ustringhash_pod spline_, + void* wx_, float* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { - spline_evaluate_wide(Masked(wout_, Mask(mask_value)), USTR(spline_), + spline_evaluate_wide(Masked(wout_, Mask(mask_value)), + ustringhash_from(spline_), UniformAsWide(wx_), Wide(knots, knot_arraylen), knot_count); } @@ -579,13 +580,14 @@ __OSL_MASKED_OP3(spline, Wf, f, Wf)(void* wout_, const char* spline_, void* wx_, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdf, Wdf, Wdf)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wdf, Wdf, Wdf)(void* wout_, ustringhash_pod spline_, void* wx_, float* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide>(wx_), + ustringhash_from(spline_), + Wide>(wx_), Wide[]>(knots, knot_arraylen), knot_count); } @@ -593,26 +595,27 @@ __OSL_MASKED_OP3(spline, Wdf, Wdf, Wdf)(void* wout_, const char* spline_, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdf, Wdf, - df)(void* wout_, const char* spline_, void* wx_, float* knots, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(spline, Wdf, Wdf, df)(void* wout_, ustringhash_pod spline_, + void* wx_, float* knots, int knot_count, + int knot_arraylen, + unsigned int mask_value) { - spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide>(wx_), - UniformAsWide[]>(knots, - knot_arraylen), - knot_count); + spline_evaluate_wide( + Masked>(wout_, Mask(mask_value)), + ustringhash_from(spline_), Wide>(wx_), + UniformAsWide[]>(knots, knot_arraylen), knot_count); } OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdf, Wf, - df)(void* wout_, const char* spline_, void* wx_, float* knots, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(spline, Wdf, Wf, df)(void* wout_, ustringhash_pod spline_, + void* wx_, float* knots, int knot_count, + int knot_arraylen, + unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide(wx_), + ustringhash_from(spline_), Wide(wx_), UniformAsWide[]>(knots, knot_arraylen), knot_count); @@ -621,13 +624,14 @@ __OSL_MASKED_OP3(spline, Wdf, Wf, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdf, df, Wdf)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wdf, df, Wdf)(void* wout_, ustringhash_pod spline_, void* wx_, float* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), UniformAsWide>(wx_), + ustringhash_from(spline_), + UniformAsWide>(wx_), Wide[]>(knots, knot_arraylen), knot_count); } @@ -637,26 +641,27 @@ __OSL_MASKED_OP3(spline, Wdf, df, Wdf)(void* wout_, const char* spline_, //=========================================================================== OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdf, f, Wdf)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wdf, f, Wdf)(void* wout_, ustringhash_pod spline_, void* wx_, float* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), UniformAsWide(wx_), + ustringhash_from(spline_), + UniformAsWide(wx_), Wide[]>(knots, knot_arraylen), knot_count); } OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdf, Wf, Wdf)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wdf, Wf, Wdf)(void* wout_, ustringhash_pod spline_, void* wx_, float* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide(wx_), + ustringhash_from(spline_), Wide(wx_), Wide[]>(knots, knot_arraylen), knot_count); } @@ -665,12 +670,14 @@ __OSL_MASKED_OP3(spline, Wdf, Wf, Wdf)(void* wout_, const char* spline_, //=========================================================================== OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdf, Wdf, - f)(void* wout_, const char* spline_, void* wx_, float* knots, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(spline, Wdf, Wdf, f)(void* wout_, ustringhash_pod spline_, + void* wx_, float* knots, int knot_count, + int knot_arraylen, + unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide>(wx_), + ustringhash_from(spline_), + Wide>(wx_), UniformAsWide(knots, knot_arraylen), knot_count); } @@ -678,12 +685,12 @@ __OSL_MASKED_OP3(spline, Wdf, Wdf, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wf, Wf, Wf)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wf, Wf, Wf)(void* wout_, ustringhash_pod spline_, void* wx_, void* wknots_, int knot_count, int knot_arraylen, unsigned int mask_value) { - spline_evaluate_wide(Masked(wout_, Mask(mask_value)), USTR(spline_), - Wide(wx_), + spline_evaluate_wide(Masked(wout_, Mask(mask_value)), + ustringhash_from(spline_), Wide(wx_), Wide(wknots_, knot_arraylen), knot_count); } @@ -692,12 +699,12 @@ __OSL_MASKED_OP3(spline, Wf, Wf, Wf)(void* wout_, const char* spline_, //======================================================================= OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wv, Wf, v)(void* wout_, const char* spline_, void* wx_, - Vec3* knots, int knot_count, +__OSL_MASKED_OP3(spline, Wv, Wf, v)(void* wout_, ustringhash_pod spline_, + void* wx_, Vec3* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { - spline_evaluate_wide(Masked(wout_, Mask(mask_value)), USTR(spline_), - Wide(wx_), + spline_evaluate_wide(Masked(wout_, Mask(mask_value)), + ustringhash_from(spline_), Wide(wx_), UniformAsWide(knots, knot_arraylen), knot_count); } @@ -705,23 +712,24 @@ __OSL_MASKED_OP3(spline, Wv, Wf, v)(void* wout_, const char* spline_, void* wx_, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wv, Wf, Wv)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wv, Wf, Wv)(void* wout_, ustringhash_pod spline_, void* wx_, Vec3* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { - spline_evaluate_wide(Masked(wout_, Mask(mask_value)), USTR(spline_), - Wide(wx_), + spline_evaluate_wide(Masked(wout_, Mask(mask_value)), + ustringhash_from(spline_), Wide(wx_), Wide(knots, knot_arraylen), knot_count); } OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wv, f, Wv)(void* wout_, const char* spline_, void* wx_, - Vec3* knots, int knot_count, +__OSL_MASKED_OP3(spline, Wv, f, Wv)(void* wout_, ustringhash_pod spline_, + void* wx_, Vec3* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { - spline_evaluate_wide(Masked(wout_, Mask(mask_value)), USTR(spline_), + spline_evaluate_wide(Masked(wout_, Mask(mask_value)), + ustringhash_from(spline_), UniformAsWide(wx_), Wide(knots, knot_arraylen), knot_count); } @@ -729,12 +737,14 @@ __OSL_MASKED_OP3(spline, Wv, f, Wv)(void* wout_, const char* spline_, void* wx_, //======================================================================= OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, Wdf, - v)(void* wout_, const char* spline_, void* wx_, Vec3* knots, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(spline, Wdv, Wdf, v)(void* wout_, ustringhash_pod spline_, + void* wx_, Vec3* knots, int knot_count, + int knot_arraylen, + unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide>(wx_), + ustringhash_from(spline_), + Wide>(wx_), UniformAsWide(knots, knot_arraylen), knot_count); } @@ -742,24 +752,28 @@ __OSL_MASKED_OP3(spline, Wdv, Wdf, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, Wdf, - Wv)(void* wout_, const char* spline_, void* wx_, Vec3* knots, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(spline, Wdv, Wdf, Wv)(void* wout_, ustringhash_pod spline_, + void* wx_, Vec3* knots, int knot_count, + int knot_arraylen, + unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide>(wx_), + ustringhash_from(spline_), + Wide>(wx_), Wide(knots, knot_arraylen), knot_count); } OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, df, - Wv)(void* wout_, const char* spline_, void* wx_, Vec3* knots, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(spline, Wdv, df, Wv)(void* wout_, ustringhash_pod spline_, + void* wx_, Vec3* knots, int knot_count, + int knot_arraylen, + unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), UniformAsWide>(wx_), + ustringhash_from(spline_), + UniformAsWide>(wx_), Wide(knots, knot_arraylen), knot_count); } @@ -767,13 +781,14 @@ __OSL_MASKED_OP3(spline, Wdv, df, //======================================================================= OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, f, Wdv)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wdv, f, Wdv)(void* wout_, ustringhash_pod spline_, void* wx_, Vec3* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), UniformAsWide(wx_), + ustringhash_from(spline_), + UniformAsWide(wx_), Wide[]>(knots, knot_arraylen), knot_count); } @@ -781,13 +796,13 @@ __OSL_MASKED_OP3(spline, Wdv, f, Wdv)(void* wout_, const char* spline_, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, Wf, Wdv)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wdv, Wf, Wdv)(void* wout_, ustringhash_pod spline_, void* wx_, Vec3* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide(wx_), + ustringhash_from(spline_), Wide(wx_), Wide[]>(knots, knot_arraylen), knot_count); } @@ -795,12 +810,13 @@ __OSL_MASKED_OP3(spline, Wdv, Wf, Wdv)(void* wout_, const char* spline_, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, Wf, - dv)(void* wout_, const char* spline_, void* wx_, Vec3* knots, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(spline, Wdv, Wf, dv)(void* wout_, ustringhash_pod spline_, + void* wx_, Vec3* knots, int knot_count, + int knot_arraylen, + unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide(wx_), + ustringhash_from(spline_), Wide(wx_), UniformAsWide[]>(knots, knot_arraylen), knot_count); @@ -810,13 +826,14 @@ __OSL_MASKED_OP3(spline, Wdv, Wf, //======================================================================= OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, Wdf, Wdv)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wdv, Wdf, Wdv)(void* wout_, ustringhash_pod spline_, void* wx_, Vec3* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide>(wx_), + ustringhash_from(spline_), + Wide>(wx_), Wide[]>(knots, knot_arraylen), knot_count); } @@ -824,27 +841,28 @@ __OSL_MASKED_OP3(spline, Wdv, Wdf, Wdv)(void* wout_, const char* spline_, OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, Wdf, - dv)(void* wout_, const char* spline_, void* wx_, Vec3* knots, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(spline, Wdv, Wdf, dv)(void* wout_, ustringhash_pod spline_, + void* wx_, Vec3* knots, int knot_count, + int knot_arraylen, + unsigned int mask_value) { - spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide>(wx_), - UniformAsWide[]>(knots, - knot_arraylen), - knot_count); + spline_evaluate_wide( + Masked>(wout_, Mask(mask_value)), ustringhash_from(spline_), + Wide>(wx_), + UniformAsWide[]>(knots, knot_arraylen), knot_count); } OSL_BATCHOP void -__OSL_MASKED_OP3(spline, Wdv, df, Wdv)(void* wout_, const char* spline_, +__OSL_MASKED_OP3(spline, Wdv, df, Wdv)(void* wout_, ustringhash_pod spline_, void* wx_, Vec3* knots, int knot_count, int knot_arraylen, unsigned int mask_value) { spline_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), UniformAsWide>(wx_), + ustringhash_from(spline_), + UniformAsWide>(wx_), Wide[]>(knots, knot_arraylen), knot_count); } @@ -861,12 +879,14 @@ __OSL_MASKED_OP3(spline, Wdv, df, Wdv)(void* wout_, const char* spline_, OSL_BATCHOP void __OSL_MASKED_OP3(splineinverse, Wf, Wf, - Wf)(void* wout_, const char* spline_, void* wx_, void* wknots_, - int knot_count, int knot_arraylen, unsigned int mask_value) + Wf)(void* wout_, ustringhash_pod spline_, void* wx_, + void* wknots_, int knot_count, int knot_arraylen, + unsigned int mask_value) { // Version with no derivs splineinverse_evaluate_wide(Masked(wout_, Mask(mask_value)), - USTR(spline_), Wide(wx_), + ustringhash_from(spline_), + Wide(wx_), Wide(wknots_, knot_arraylen), knot_count); } @@ -874,28 +894,30 @@ __OSL_MASKED_OP3(splineinverse, Wf, Wf, OSL_BATCHOP void -__OSL_MASKED_OP3(splineinverse, Wf, Wf, - f)(void* wout_, const char* spline_, void* wx_, void* wknots_, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(splineinverse, Wf, Wf, f)(void* wout_, ustringhash_pod spline_, + void* wx_, void* wknots_, + int knot_count, int knot_arraylen, + unsigned int mask_value) { // Version with no derivs - splineinverse_evaluate_wide(Masked(wout_, Mask(mask_value)), - USTR(spline_), Wide(wx_), - UniformAsWide(wknots_, - knot_arraylen), - knot_count); + splineinverse_evaluate_wide( + Masked(wout_, Mask(mask_value)), ustringhash_from(spline_), + Wide(wx_), + UniformAsWide(wknots_, knot_arraylen), knot_count); } OSL_BATCHOP void -__OSL_MASKED_OP3(splineinverse, Wf, f, - Wf)(void* wout_, const char* spline_, void* wx_, void* wknots_, - int knot_count, int knot_arraylen, unsigned int mask_value) +__OSL_MASKED_OP3(splineinverse, Wf, f, Wf)(void* wout_, ustringhash_pod spline_, + void* wx_, void* wknots_, + int knot_count, int knot_arraylen, + unsigned int mask_value) { // Version with no derivs splineinverse_evaluate_wide(Masked(wout_, Mask(mask_value)), - USTR(spline_), UniformAsWide(wx_), + ustringhash_from(spline_), + UniformAsWide(wx_), Wide(wknots_, knot_arraylen), knot_count); } @@ -904,22 +926,22 @@ __OSL_MASKED_OP3(splineinverse, Wf, f, OSL_BATCHOP void __OSL_MASKED_OP3(splineinverse, Wdf, Wdf, - f)(void* wout_, const char* spline_, void* wx_, void* wknots_, - int knot_count, int knot_arraylen, unsigned int mask_value) + f)(void* wout_, ustringhash_pod spline_, void* wx_, + void* wknots_, int knot_count, int knot_arraylen, + unsigned int mask_value) { // x has derivs, so return derivs as well - splineinverse_evaluate_wide(Masked>(wout_, Mask(mask_value)), - USTR(spline_), Wide>(wx_), - UniformAsWide(wknots_, - knot_arraylen), - knot_count); + splineinverse_evaluate_wide( + Masked>(wout_, Mask(mask_value)), + ustringhash_from(spline_), Wide>(wx_), + UniformAsWide(wknots_, knot_arraylen), knot_count); } OSL_BATCHOP void __OSL_MASKED_OP3(splineinverse, Wdf, Wdf, - Wdf)(void* wout_, const char* spline_, void* wx_, + Wdf)(void* wout_, ustringhash_pod spline_, void* wx_, void* wknots_, int knot_count, int knot_arraylen, unsigned int mask_value) { @@ -927,8 +949,8 @@ __OSL_MASKED_OP3(splineinverse, Wdf, Wdf, // // x has derivs, so return derivs as well splineinverse_evaluate_wide( - Masked>(wout_, Mask(mask_value)), USTR(spline_), - Wide>(wx_), + Masked>(wout_, Mask(mask_value)), + ustringhash_from(spline_), Wide>(wx_), // wknots_ is really a Wide[]>, // but we are ignoring knot derivatives, // so just treat it as Wide which is binary compatible. @@ -938,8 +960,9 @@ __OSL_MASKED_OP3(splineinverse, Wdf, Wdf, OSL_BATCHOP void __OSL_MASKED_OP3(splineinverse, Wdf, Wdf, - df)(void* wout_, const char* spline_, void* wx_, void* wknots_, - int knot_count, int knot_arraylen, unsigned int mask_value) + df)(void* wout_, ustringhash_pod spline_, void* wx_, + void* wknots_, int knot_count, int knot_arraylen, + unsigned int mask_value) { // Ignore knot derivatives __OSL_MASKED_OP3(splineinverse, Wdf, Wdf, f) @@ -949,15 +972,15 @@ __OSL_MASKED_OP3(splineinverse, Wdf, Wdf, OSL_BATCHOP void -__OSL_MASKED_OP3(splineinverse, Wdf, df, Wdf)(void* wout_, const char* spline_, - void* wx_, void* wknots_, - int knot_count, int knot_arraylen, - unsigned int mask_value) +__OSL_MASKED_OP3(splineinverse, Wdf, df, + Wdf)(void* wout_, ustringhash_pod spline_, void* wx_, + void* wknots_, int knot_count, int knot_arraylen, + unsigned int mask_value) { // Ignore knot derivatives splineinverse_evaluate_wide( - Masked>(wout_, Mask(mask_value)), USTR(spline_), - UniformAsWide>(wx_), + Masked>(wout_, Mask(mask_value)), + ustringhash_from(spline_), UniformAsWide>(wx_), // wknots_ is really a Wide[]>, // but we are ignoring knot derivatives, // so just treat it as Wide which is binary compatible. @@ -967,10 +990,10 @@ __OSL_MASKED_OP3(splineinverse, Wdf, df, Wdf)(void* wout_, const char* spline_, OSL_BATCHOP void -__OSL_MASKED_OP3(splineinverse, Wdf, f, Wdf)(void* wout_, const char* spline_, - void* wx_, void* wknots_, - int knot_count, int knot_arraylen, - unsigned int mask_value) +__OSL_MASKED_OP3(splineinverse, Wdf, f, + Wdf)(void* wout_, ustringhash_pod spline_, void* wx_, + void* wknots_, int knot_count, int knot_arraylen, + unsigned int mask_value) { // Ignore knot derivs // treated as fff diff --git a/src/liboslexec/wide/wide_opstring.cpp b/src/liboslexec/wide/wide_opstring.cpp index b08474e5e..a14bbb507 100644 --- a/src/liboslexec/wide/wide_opstring.cpp +++ b/src/liboslexec/wide/wide_opstring.cpp @@ -10,6 +10,7 @@ /// ///////////////////////////////////////////////////////////////////////// + #include #include @@ -29,13 +30,12 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH) #include "define_opname_macros.h" - OSL_BATCHOP void __OSL_MASKED_OP3(concat, Ws, Ws, Ws)(void* wr_, void* ws_, void* wt_, unsigned int mask_value) { - Wide wS(ws_); - Wide wT(wt_); + Wide wS(ws_); + Wide wT(wt_); Masked wR(wr_, Mask(mask_value)); char local_buf[256]; @@ -46,8 +46,8 @@ __OSL_MASKED_OP3(concat, Ws, Ws, Ws)(void* wr_, void* ws_, void* wt_, // as they are undefined when masked off wR.mask().foreach ( [=, &local_buf, &heap_buf, &heap_buf_len](ActiveLane lane) -> void { - ustring s = wS[lane]; - ustring t = wT[lane]; + ustring s = ustring_from(wS[lane]); + ustring t = ustring_from(wT[lane]); size_t sl = s.length(); size_t tl = t.length(); size_t len = sl + tl; @@ -70,7 +70,7 @@ __OSL_MASKED_OP3(concat, Ws, Ws, Ws)(void* wr_, void* ws_, void* wt_, OSL_BATCHOP void __OSL_MASKED_OP2(strlen, Wi, Ws)(void* wr_, void* ws_, unsigned int mask_value) { - Wide wS(ws_); + Wide wS(ws_); Masked wR(wr_, Mask(mask_value)); OSL_FORCEINLINE_BLOCK @@ -81,7 +81,7 @@ __OSL_MASKED_OP2(strlen, Wi, Ws)(void* wr_, void* ws_, unsigned int mask_value) OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) #endif for (int lane = 0; lane < __OSL_WIDTH; ++lane) { - ustring s = wS[lane]; + ustring s = ustring_from(wS[lane]); if (wR.mask()[lane]) { wR[ActiveLane(lane)] = (int)s.length(); } @@ -93,16 +93,16 @@ __OSL_MASKED_OP2(strlen, Wi, Ws)(void* wr_, void* ws_, unsigned int mask_value) OSL_BATCHOP void __OSL_MASKED_OP2(hash, Wi, Ws)(void* wr_, void* ws_, unsigned int mask_value) { - Wide wS(ws_); + Wide wS(ws_); Masked wR(wr_, Mask(mask_value)); OSL_FORCEINLINE_BLOCK { OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { - ustring s = wS[lane]; + ustringhash h = wS[lane]; if (wR.mask()[lane]) { - wR[ActiveLane(lane)] = (int)s.hash(); + wR[ActiveLane(lane)] = (int)h.hash(); } } } @@ -114,13 +114,13 @@ OSL_BATCHOP void __OSL_MASKED_OP3(getchar, Wi, Ws, Wi)(void* wr_, void* ws_, void* wi_, unsigned int mask_value) { - Wide wS(ws_); + Wide wS(ws_); Wide wI(wi_); Masked wR(wr_, Mask(mask_value)); #if 1 // SIMD version may not be profitable, need to benchmark to confirm wR.mask().foreach ([=](ActiveLane lane) -> void { - ustring str = wS[lane]; + ustring str = ustring_from(wS[lane]); int index = wI[lane]; wR[lane] = ((!str.empty()) && unsigned(index) < str.length()) ? str[index] @@ -168,13 +168,13 @@ OSL_BATCHOP void __OSL_MASKED_OP3(startswith, Wi, Ws, Ws)(void* wr_, void* ws_, void* wsubs_, unsigned int mask_value) { - Wide wS(ws_); + Wide wS(ws_); Wide wSubs(wsubs_); Masked wR(wr_, Mask(mask_value)); wR.mask().foreach ([=](ActiveLane lane) -> void { - ustring substr = wSubs[lane]; - ustring s = wS[lane]; + ustring substr = ustring_from(wSubs[lane]); + ustring s = ustring_from(wS[lane]); wR[lane] = startswith_iss_impl(s, substr); }); } @@ -200,13 +200,13 @@ OSL_BATCHOP void __OSL_MASKED_OP3(endswith, Wi, Ws, Ws)(void* wr_, void* ws_, void* wsubs_, unsigned int mask_value) { - Wide wS(ws_); - Wide wSubs(wsubs_); + Wide wS(ws_); + Wide wSubs(wsubs_); Masked wR(wr_, Mask(mask_value)); wR.mask().foreach ([=](ActiveLane lane) -> void { - ustring substr = wSubs[lane]; - ustring s = wS[lane]; + ustring substr = ustring_from(wSubs[lane]); + ustring s = ustring_from(wS[lane]); wR[lane] = endswith_iss_impl(s, substr); }); } @@ -217,14 +217,14 @@ OSL_BATCHOP void __OSL_MASKED_OP2(stoi, Wi, Ws)(void* wint_ptr, void* wstr_ptr, unsigned int mask_value) { - Wide wstr(wstr_ptr); + Wide wstr(wstr_ptr); Masked wR(wint_ptr, Mask(mask_value)); // Avoid cost of strtol if lane is masked off // Also the value of str for a masked off lane could be // invalid/undefined and not safe to call strtol on. wR.mask().foreach ([=](ActiveLane lane) -> void { - const char* str = unproxy(wstr[lane]).c_str(); + const char* str = ustring_from(unproxy(wstr[lane])).c_str(); // TODO: Suspect we could implement SIMD friendly version // that is more efficient than the library call wR[lane] = str ? OIIO::Strutil::from_string(str) : 0; @@ -236,14 +236,14 @@ __OSL_MASKED_OP2(stoi, Wi, Ws)(void* wint_ptr, void* wstr_ptr, OSL_BATCHOP void __OSL_MASKED_OP2(stof, Wf, Ws)(void* wr_, void* ws_, unsigned int mask_value) { - Wide wS(ws_); + Wide wS(ws_); Masked wR(wr_, Mask(mask_value)); // Avoid cost of strtof if lane is masked off // Also the value of str for a masked off lane could be // invalid/undefined and not safe to call strtod on. wR.mask().foreach ([=](ActiveLane lane) -> void { - const char* str = unproxy(wS[lane]).c_str(); + const char* str = ustring_from(unproxy(wS[lane])).c_str(); // TODO: Suspect we could implement SIMD friendly version // that is more efficient than the library call wR[lane] = str ? OIIO::Strutil::from_string(str) : 0.0f; @@ -274,13 +274,13 @@ __OSL_MASKED_OP4(substr, Ws, Ws, Wi, Wi)(void* wr_, void* ws_, void* wstart_, void* wlength_, unsigned int mask_value) { - Wide wS(ws_); + Wide wS(ws_); Wide wL(wlength_); Wide wSt(wstart_); Masked wR(wr_, Mask(mask_value)); wR.mask().foreach ([=](ActiveLane lane) -> void { - ustring s = wS[lane]; + ustring s = ustring_from(wS[lane]); int start = wSt[lane]; int length = wL[lane]; wR[lane] = substr_ssii_impl(s, start, length); @@ -290,19 +290,23 @@ __OSL_MASKED_OP4(substr, Ws, Ws, Wi, Wi)(void* wr_, void* ws_, void* wstart_, OSL_BATCHOP int -__OSL_OP(regex_impl)(void* bsg_, const char* subject_, void* results, - int nresults, const char* pattern, int fullmatch) +__OSL_OP(regex_impl)(void* bsg_, ustringhash_pod subject_, void* results, + int nresults, ustringhash_pod pattern, int fullmatch) { auto* bsg = reinterpret_cast(bsg_); ShadingContext* ctx = bsg->uniform.context; // TODO: probably could share implementation from here with osl_regex_impl from opstring.cpp - OSL_ASSERT(ustring::is_unique(subject_)); - OSL_ASSERT(ustring::is_unique(pattern)); + OSL_ASSERT(ustring::is_unique(ustring_from(subject_).c_str())); + OSL_ASSERT(ustring::is_unique(ustring_from(pattern).c_str())); - const std::string& subject(ustring::from_unique(subject_).string()); + const std::string& subject( + ustring::from_unique(ustring_from(subject_).c_str()).string()); std::match_results mresults; - const std::regex& regex(ctx->find_regex(USTR(pattern))); + // TODO FIXME + //const std::regex& regex(ctx->find_regex(ustring_from(pattern))); + return 0; + /* if (nresults > 0) { std::string::const_iterator start = subject.begin(); int res = fullmatch ? std::regex_match(subject, mresults, regex) @@ -315,7 +319,7 @@ __OSL_OP(regex_impl)(void* bsg_, const char* subject_, void* results, else m[r] = mresults[r / 2].second - start; } else { - m[r] = USTR(pattern).length(); + m[r] = ustring_from(pattern).length(); } } return res; @@ -323,6 +327,7 @@ __OSL_OP(regex_impl)(void* bsg_, const char* subject_, void* results, return fullmatch ? regex_match(subject, regex) : regex_search(subject, regex); } +*/ } @@ -341,12 +346,12 @@ __OSL_MASKED_OP(regex_impl)(void* bsg_, void* wsuccess_ptr, void* wsubject_ptr, Masked wsuccess(wsuccess_ptr, mask); Masked wresults(wresults_ptr, nresults, mask); - Wide wsubject(wsubject_ptr); - Wide wpattern(wpattern_ptr); + Wide wsubject(wsubject_ptr); + Wide wpattern(wpattern_ptr); mask.foreach ([=](ActiveLane lane) -> void { - ustring usubject = wsubject[lane]; - ustring pattern = wpattern[lane]; + ustring usubject = ustring_from(wsubject[lane]); + ustring pattern = ustring_from(wpattern[lane]); OSL_ASSERT(ustring::is_unique(usubject.c_str())); OSL_ASSERT(ustring::is_unique(pattern.c_str())); @@ -354,6 +359,8 @@ __OSL_MASKED_OP(regex_impl)(void* bsg_, void* wsuccess_ptr, void* wsubject_ptr, const std::string& subject = usubject.string(); std::match_results mresults; + // TODO FIXME + /* const std::regex& regex(ctx->find_regex(pattern)); if (nresults > 0) { std::string::const_iterator start = subject.begin(); @@ -374,6 +381,7 @@ __OSL_MASKED_OP(regex_impl)(void* bsg_, void* wsuccess_ptr, void* wsubject_ptr, wsuccess[lane] = fullmatch ? regex_match(subject, regex) : regex_search(subject, regex); } +*/ }); } @@ -381,11 +389,11 @@ __OSL_MASKED_OP(regex_impl)(void* bsg_, void* wsuccess_ptr, void* wsubject_ptr, OSL_BATCHOP void __OSL_OP(format)(void* wide_output, unsigned int mask_value, - const char* format_str, ...) + ustringhash_pod format_str, ...) { va_list args; va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); + std::string s = Strutil::vsprintf(ustring_from(format_str).c_str(), args); va_end(args); ustring result = ustring(s); @@ -395,11 +403,11 @@ __OSL_OP(format)(void* wide_output, unsigned int mask_value, } OSL_BATCHOP const char* -__OSL_OP(format_uniform)(const char* format_str, ...) +__OSL_OP(format_uniform)(ustringhash_pod format_str, ...) { va_list args; va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); + std::string s = Strutil::vsprintf(ustring_from(format_str).c_str(), args); va_end(args); return ustring(s).c_str(); } @@ -407,7 +415,7 @@ __OSL_OP(format_uniform)(const char* format_str, ...) OSL_BATCHOP void __OSL_OP(printf)(BatchedShaderGlobals* bsg, unsigned int mask_value, - const char* format_str, ...) + ustringhash_pod format_str, ...) { Mask mask(mask_value); // Not strictly necessary, but using to ensure "current" logic that conditionals should skip @@ -416,19 +424,20 @@ __OSL_OP(printf)(BatchedShaderGlobals* bsg, unsigned int mask_value, va_list args; va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); + std::string s = Strutil::vsprintf(ustring_from(format_str).c_str(), args); va_end(args); - bsg->uniform.context->record_error( - ErrorHandler::EH_MESSAGE, s, - static_cast>(mask)); + //TODO FIXME + //bsg->uniform.context->record_error( + // ErrorHandler::EH_MESSAGE, s, + // static_cast>(mask)); } OSL_BATCHOP void __OSL_OP(error)(BatchedShaderGlobals* bsg, unsigned int mask_value, - const char* format_str, ...) + ustringhash_pod format_str, ...) { Mask mask(mask_value); // Not strictly necessary, but using to ensure "current" logic that conditionals should skip @@ -437,19 +446,20 @@ __OSL_OP(error)(BatchedShaderGlobals* bsg, unsigned int mask_value, va_list args; va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); + std::string s = Strutil::vsprintf(ustring_from(format_str).c_str(), args); va_end(args); - bsg->uniform.context->record_error( - ErrorHandler::EH_ERROR, s, - static_cast>(mask)); + //TODO FIXME + //bsg->uniform.context->record_error( + // ErrorHandler::EH_ERROR, s, + // static_cast>(mask)); } OSL_BATCHOP void __OSL_OP(warning)(BatchedShaderGlobals* bsg, unsigned int mask_value, - const char* format_str, ...) + ustringhash_pod format_str, ...) { if (bsg->uniform.context->allow_warnings()) { Mask mask(mask_value); @@ -459,12 +469,14 @@ __OSL_OP(warning)(BatchedShaderGlobals* bsg, unsigned int mask_value, va_list args; va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); + std::string s = Strutil::vsprintf(ustring_from(format_str).c_str(), + args); va_end(args); - bsg->uniform.context->record_error( - ErrorHandler::EH_WARNING, s, - static_cast>(mask)); + //TODO FIXME + //bsg->uniform.context->record_error( + // ErrorHandler::EH_WARNING, s, + // static_cast>(mask)); } } @@ -472,11 +484,10 @@ __OSL_OP(warning)(BatchedShaderGlobals* bsg, unsigned int mask_value, OSL_BATCHOP void __OSL_OP(fprintf)(BatchedShaderGlobals* bsg, unsigned int mask_value, - const char* filename, const char* format_str, ...) + ustringhash_pod filename, ustringhash_pod format_str, ...) { OSL_ASSERT(bsg != nullptr); - OSL_ASSERT(filename != nullptr); - OSL_ASSERT(format_str != nullptr); + //OSL_ASSERT(format_str != nullptr); Mask mask(mask_value); // Not strictly necessary, but using to ensure "current" logic that conditionals should skip // any code block with no active lanes, this could be changed in future @@ -484,12 +495,13 @@ __OSL_OP(fprintf)(BatchedShaderGlobals* bsg, unsigned int mask_value, va_list args; va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); + std::string s = Strutil::vsprintf(ustring_from(format_str).c_str(), args); va_end(args); - bsg->uniform.context->record_to_file( - USTR(filename), s, - static_cast>(mask)); + //TODO FIXME + //bsg->uniform.context->record_to_file( + // ustring_from(filename), s, + // static_cast>(mask)); } @@ -502,19 +514,19 @@ __OSL_MASKED_OP(split)(void* wresults, void* wmaxsplit, /*void *wrlen,*/ int resultslen, unsigned int mask_value) { - Wide wS(wstr); + Wide wS(wstr); Masked wR(wresults, Mask(mask_value)); //length of split array Masked wRString(wresult_string, resultslen, Mask(mask_value)); //Split string - Wide wSep(wsep); + Wide wSep(wsep); Wide wMaxSplit(wmaxsplit); wR.mask().foreach ([=](ActiveLane lane) -> void { int maxsplit = wMaxSplit[lane]; - ustring str = wS[lane]; - ustring sep = wSep[lane]; + ustring str = ustring_from(wS[lane]); + ustring sep = ustring_from(wSep[lane]); auto resultStrings = wRString[lane]; maxsplit = OIIO::clamp(maxsplit, 0, resultslen); diff --git a/src/liboslexec/wide/wide_optexture.cpp b/src/liboslexec/wide/wide_optexture.cpp index 63353be22..0696d8e26 100644 --- a/src/liboslexec/wide/wide_optexture.cpp +++ b/src/liboslexec/wide/wide_optexture.cpp @@ -33,7 +33,7 @@ namespace { Mask -default_texture(BatchedRendererServices* bsr, ustring filename, +default_texture(BatchedRendererServices* bsr, ustringhash_pod filename, TextureSystem::TextureHandle* texture_handle, TextureSystem::Perthread* texture_thread_info, const BatchedTextureOptions& options, BatchedShaderGlobals* bsg, @@ -49,7 +49,7 @@ default_texture(BatchedRendererServices* bsr, ustring filename, texture_thread_info = context->texture_thread_info(); if (!texture_handle) texture_handle - = bsr->texturesys()->get_texture_handle(filename, + = bsr->texturesys()->get_texture_handle(ustring_from(filename), texture_thread_info); Mask mask = outputs.mask(); @@ -180,7 +180,8 @@ default_texture(BatchedRendererServices* bsr, ustring filename, if (errMsgSize) { errormessage[lane] = ustring(err); } else { - errormessage[lane] = Strings::unknown; + // TODO FIXME + //errormessage[lane] = Strings::unknown; } } else if (errMsgSize) { context->batched<__OSL_WIDTH>().errorfmt( @@ -194,7 +195,7 @@ default_texture(BatchedRendererServices* bsr, ustring filename, OSL_FORCEINLINE Mask -dispatch_texture(BatchedRendererServices* bsr, ustring filename, +dispatch_texture(BatchedRendererServices* bsr, ustringhash_pod filename, TextureSystem::TextureHandle* texture_handle, TextureSystem::Perthread* texture_thread_info, const BatchedTextureOptions& options, @@ -204,9 +205,9 @@ dispatch_texture(BatchedRendererServices* bsr, ustring filename, Wide dtdy, BatchedTextureOutputs& outputs) { if (bsr->is_overridden_texture()) { - return bsr->texture(filename, texture_handle, texture_thread_info, - options, bsg, s, t, dsdx, dtdx, dsdy, dtdy, - outputs); + return bsr->texture(ustringhash_from(filename), texture_handle, + texture_thread_info, options, bsg, s, t, dsdx, dtdx, + dsdy, dtdy, outputs); } else { return default_texture(bsr, filename, texture_handle, texture_thread_info, options, bsg, s, t, dsdx, @@ -217,7 +218,7 @@ dispatch_texture(BatchedRendererServices* bsr, ustring filename, Mask -default_texture3d(BatchedRendererServices* bsr, ustring filename, +default_texture3d(BatchedRendererServices* bsr, ustringhash_pod filename, TextureSystem::TextureHandle* texture_handle, TextureSystem::Perthread* texture_thread_info, const BatchedTextureOptions& options, @@ -232,7 +233,7 @@ default_texture3d(BatchedRendererServices* bsr, ustring filename, texture_thread_info = context->texture_thread_info(); if (!texture_handle) texture_handle - = bsr->texturesys()->get_texture_handle(filename, + = bsr->texturesys()->get_texture_handle(ustring_from(filename), texture_thread_info); Mask mask = outputs.mask(); @@ -377,7 +378,8 @@ default_texture3d(BatchedRendererServices* bsr, ustring filename, if (errMsgSize) { errormessage[lane] = ustring(err); } else { - errormessage[lane] = Strings::unknown; + // TODO FIXME + //errormessage[lane] = Strings::unknown; } } else if (errMsgSize) { context->batched<__OSL_WIDTH>().errorfmt( @@ -391,7 +393,7 @@ default_texture3d(BatchedRendererServices* bsr, ustring filename, OSL_FORCEINLINE Mask -dispatch_texture3d(BatchedRendererServices* bsr, ustring filename, +dispatch_texture3d(BatchedRendererServices* bsr, ustringhash_pod filename, TextureSystem::TextureHandle* texture_handle, TextureSystem::Perthread* texture_thread_info, const BatchedTextureOptions& options, @@ -400,8 +402,9 @@ dispatch_texture3d(BatchedRendererServices* bsr, ustring filename, Wide dPdz, BatchedTextureOutputs& outputs) { if (bsr->is_overridden_texture3d()) { - return bsr->texture3d(filename, texture_handle, texture_thread_info, - options, bsg, P, dPdx, dPdy, dPdz, outputs); + return bsr->texture3d(ustringhash_from(filename), texture_handle, + texture_thread_info, options, bsg, P, dPdx, dPdy, + dPdz, outputs); } else { return default_texture3d(bsr, filename, texture_handle, texture_thread_info, options, bsg, P, dPdx, @@ -412,7 +415,7 @@ dispatch_texture3d(BatchedRendererServices* bsr, ustring filename, Mask -default_environment(BatchedRendererServices* bsr, ustring filename, +default_environment(BatchedRendererServices* bsr, ustringhash_pod filename, TextureSystem::TextureHandle* texture_handle, TextureSystem::Perthread* texture_thread_info, const BatchedTextureOptions& options, @@ -427,7 +430,7 @@ default_environment(BatchedRendererServices* bsr, ustring filename, texture_thread_info = context->texture_thread_info(); if (!texture_handle) texture_handle - = bsr->texturesys()->get_texture_handle(filename, + = bsr->texturesys()->get_texture_handle(ustring_from(filename), texture_thread_info); Mask mask = outputs.mask(); @@ -524,7 +527,8 @@ default_environment(BatchedRendererServices* bsr, ustring filename, if (errMsgSize) { errormessage[lane] = ustring(err); } else { - errormessage[lane] = Strings::unknown; + // TODO FIXME + //errormessage[lane] = Strings::unknown; } } else if (errMsgSize) { context->batched<__OSL_WIDTH>().errorfmt( @@ -539,7 +543,7 @@ default_environment(BatchedRendererServices* bsr, ustring filename, OSL_FORCEINLINE Mask -dispatch_environment(BatchedRendererServices* bsr, ustring filename, +dispatch_environment(BatchedRendererServices* bsr, ustringhash_pod filename, TextureSystem::TextureHandle* texture_handle, TextureSystem::Perthread* texture_thread_info, const BatchedTextureOptions& options, @@ -548,8 +552,9 @@ dispatch_environment(BatchedRendererServices* bsr, ustring filename, BatchedTextureOutputs& outputs) { if (bsr->is_overridden_texture3d()) { - return bsr->environment(filename, texture_handle, texture_thread_info, - options, bsg, R, dRdx, dRdy, outputs); + return bsr->environment(ustringhash_from(filename), texture_handle, + texture_thread_info, options, bsg, R, dRdx, + dRdy, outputs); } else { return default_environment(bsr, filename, texture_handle, texture_thread_info, options, bsg, R, dRdx, @@ -563,7 +568,7 @@ dispatch_environment(BatchedRendererServices* bsr, ustring filename, OSL_BATCHOP int -__OSL_MASKED_OP(texture)(void* bsg_, ustring_pod name_, void* handle, +__OSL_MASKED_OP(texture)(void* bsg_, ustringhash_pod name_, void* handle, const void* opt_, const void* s, const void* t, const void* dsdx, const void* dtdx, const void* dsdy, const void* dtdy, int chans, void* result, @@ -582,8 +587,8 @@ __OSL_MASKED_OP(texture)(void* bsg_, ustring_pod name_, void* handle, (bool)alphaHasDerivs, errormessage, mask); Mask retVal - = dispatch_texture(bsg->uniform.renderer->batched(WidthTag()), - USTR(name_), (TextureSystem::TextureHandle*)handle, + = dispatch_texture(bsg->uniform.renderer->batched(WidthTag()), name_, + (TextureSystem::TextureHandle*)handle, bsg->uniform.context->texture_thread_info(), opt, bsg, Wide(s), Wide(t), Wide(dsdx), Wide(dtdx), @@ -596,7 +601,8 @@ __OSL_MASKED_OP(texture)(void* bsg_, ustring_pod name_, void* handle, OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int i = 0; i < __OSL_WIDTH; ++i) { if (retVal[i]) { - err[i] = Strings::_emptystring_; + // TODO FIXME + //err[i] = Strings::_emptystring_; } } } @@ -607,7 +613,7 @@ __OSL_MASKED_OP(texture)(void* bsg_, ustring_pod name_, void* handle, OSL_BATCHOP int -__OSL_MASKED_OP(texture3d)(void* bsg_, ustring_pod name_, void* handle, +__OSL_MASKED_OP(texture3d)(void* bsg_, ustringhash_pod name_, void* handle, const void* opt_, const void* wP, const void* wPdx, const void* wPdy, const void* wPdz, int chans, void* result, int resultHasDerivs, void* alpha, @@ -630,8 +636,8 @@ __OSL_MASKED_OP(texture3d)(void* bsg_, ustring_pod name_, void* handle, // NOTE: If overridden, BatchedRendererServiced::texture is responsible // for correcting our str texture space gradients into xyz-space gradients Mask retVal - = dispatch_texture3d(bsg->uniform.renderer->batched(WidthTag()), - USTR(name_), (TextureSystem::TextureHandle*)handle, + = dispatch_texture3d(bsg->uniform.renderer->batched(WidthTag()), name_, + (TextureSystem::TextureHandle*)handle, bsg->uniform.context->texture_thread_info(), opt, bsg, Wide(wP), Wide(wPdx), Wide(wPdy), Wide(wPdz), @@ -643,7 +649,8 @@ __OSL_MASKED_OP(texture3d)(void* bsg_, ustring_pod name_, void* handle, OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int i = 0; i < __OSL_WIDTH; ++i) { if (retVal[i]) { - err[i] = Strings::_emptystring_; + // TODO FIXME + //err[i] = Strings::_emptystring_; } } } @@ -653,7 +660,7 @@ __OSL_MASKED_OP(texture3d)(void* bsg_, ustring_pod name_, void* handle, OSL_BATCHOP int -__OSL_MASKED_OP(environment)(void* bsg_, ustring_pod name_, void* handle, +__OSL_MASKED_OP(environment)(void* bsg_, ustringhash_pod name_, void* handle, const void* opt_, const void* wR, const void* wRdx, const void* wRdy, int chans, void* result, int resultHasDerivs, void* alpha, @@ -670,12 +677,13 @@ __OSL_MASKED_OP(environment)(void* bsg_, ustring_pod name_, void* handle, // NOTE: If overridden, BatchedRendererServiced::texture is responsible // for correcting our str texture space gradients into xyz-space gradients - Mask retVal = dispatch_environment( - bsg->uniform.renderer->batched(WidthTag()), USTR(name_), - (TextureSystem::TextureHandle*)handle, - bsg->uniform.context->texture_thread_info(), opt, bsg, - Wide(wR), Wide(wRdx), Wide(wRdy), - outputs); + Mask retVal + = dispatch_environment(bsg->uniform.renderer->batched(WidthTag()), + name_, (TextureSystem::TextureHandle*)handle, + bsg->uniform.context->texture_thread_info(), opt, + bsg, Wide(wR), + Wide(wRdx), Wide(wRdy), + outputs); // For now, just zero out the result derivatives. If somebody needs // derivatives of environment lookups, we'll fix it. The reason @@ -712,7 +720,8 @@ __OSL_MASKED_OP(environment)(void* bsg_, ustring_pod name_, void* handle, OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) for (int i = 0; i < __OSL_WIDTH; ++i) { if (retVal[i]) { - err[i] = Strings::_emptystring_; + // TODO FIXME + //err[i] = Strings::_emptystring_; } } } @@ -723,7 +732,7 @@ __OSL_MASKED_OP(environment)(void* bsg_, ustring_pod name_, void* handle, OSL_BATCHOP TextureSystem::TextureHandle* -__OSL_OP(resolve_udim_uniform)(void* bsg_, const char* name, void* handle, +__OSL_OP(resolve_udim_uniform)(void* bsg_, ustringhash_pod name, void* handle, float S, float T) { // recreate TypeDesc @@ -731,14 +740,14 @@ __OSL_OP(resolve_udim_uniform)(void* bsg_, const char* name, void* handle, return bsg->uniform.renderer->batched(WidthTag()) ->resolve_udim_uniform(bsg, bsg->uniform.context->texture_thread_info(), - USTR(name), + ustringhash_from(name), (RendererServices::TextureHandle*)handle, S, T); } OSL_BATCHOP void -__OSL_MASKED_OP(resolve_udim)(void* bsg_, const char* name, void* handle, +__OSL_MASKED_OP(resolve_udim)(void* bsg_, ustringhash_pod name, void* handle, void* wS_, void* wT_, void* wResult_, int mask_value) { @@ -747,7 +756,8 @@ __OSL_MASKED_OP(resolve_udim)(void* bsg_, const char* name, void* handle, bsg->uniform.renderer->batched(WidthTag()) ->resolve_udim(bsg, bsg->uniform.context->texture_thread_info(), - USTR(name), (RendererServices::TextureHandle*)handle, + ustringhash_from(name), + (RendererServices::TextureHandle*)handle, Wide(wS_), Wide(wT_), Masked( wResult_, Mask(mask_value))); @@ -756,9 +766,9 @@ __OSL_MASKED_OP(resolve_udim)(void* bsg_, const char* name, void* handle, OSL_BATCHOP int -__OSL_OP(get_textureinfo_uniform)(void* bsg_, ustring_pod name_, void* handle, - ustring_pod dataname_, const void* attr_type, - void* attr_dest) +__OSL_OP(get_textureinfo_uniform)(void* bsg_, ustringhash_pod name_, + void* handle, ustringhash_pod dataname_, + const void* attr_type, void* attr_dest) { // recreate TypeDesc auto* bsg = reinterpret_cast(bsg_); @@ -768,8 +778,9 @@ __OSL_OP(get_textureinfo_uniform)(void* bsg_, ustring_pod name_, void* handle, bool retVal = bsg->uniform.renderer->batched(WidthTag()) ->get_texture_info_uniform( bsg, bsg->uniform.context->texture_thread_info(), - USTR(name_), (RendererServices::TextureHandle*)handle, - 0 /*FIXME-ptex*/, USTR(dataname_), dest); + ustringhash_from(name_), + (RendererServices::TextureHandle*)handle, + 0 /*FIXME-ptex*/, ustringhash_from(dataname_), dest); return retVal; } diff --git a/src/liboslexec/wide/wide_shadingsys.cpp b/src/liboslexec/wide/wide_shadingsys.cpp index 5a9006f03..666c9c588 100644 --- a/src/liboslexec/wide/wide_shadingsys.cpp +++ b/src/liboslexec/wide/wide_shadingsys.cpp @@ -29,9 +29,9 @@ using WidthTag = OSL::WidthOf<__OSL_WIDTH>; // firstcheck,nchecks are used to check just one element of an array. OSL_BATCHOP void __OSL_OP(naninf_check)(int ncomps, const void* vals_, int has_derivs, - void* bsg_, ustring_pod sourcefile, int sourceline, - ustring_pod symbolname, int firstcheck, int nchecks, - ustring_pod opname) + void* bsg_, ustringhash_pod sourcefile, int sourceline, + ustringhash_pod symbolname, int firstcheck, int nchecks, + ustringhash_pod opname) { auto* bsg = reinterpret_cast(bsg_); ShadingContext* ctx = bsg->uniform.context; @@ -42,8 +42,9 @@ __OSL_OP(naninf_check)(int ncomps, const void* vals_, int has_derivs, if (!std::isfinite(vals[i])) { ctx->errorfmt("Detected {} value in {}{} at {}:{} (op {})", vals[i], d > 0 ? "the derivatives of " : "", - USTR(symbolname), USTR(sourcefile), sourceline, - USTR(opname)); + ustring_from(symbolname), + ustring_from(sourcefile), sourceline, + ustring_from(opname)); return; } } @@ -56,9 +57,9 @@ __OSL_OP(naninf_check)(int ncomps, const void* vals_, int has_derivs, OSL_BATCHOP void __OSL_MASKED_OP1(naninf_check_offset, i)(int mask_value, int ncomps, const void* vals_, - int has_derivs, void* bsg_, ustring_pod sourcefile, - int sourceline, ustring_pod symbolname, int firstcheck, - int nchecks, ustring_pod opname) + int has_derivs, void* bsg_, ustringhash_pod sourcefile, + int sourceline, ustringhash_pod symbolname, int firstcheck, + int nchecks, ustringhash_pod opname) { auto* bsg = reinterpret_cast(bsg_); ShadingContext* ctx = bsg->uniform.context; @@ -72,9 +73,9 @@ __OSL_MASKED_OP1(naninf_check_offset, ctx->errorfmt( "Detected {} value in {}{} at {}:{} (op {}) batch lane:{}", vals[i * __OSL_WIDTH + lane], - d > 0 ? "the derivatives of " : "", USTR(symbolname), - USTR(sourcefile), sourceline, USTR(opname), - lane.value()); + d > 0 ? "the derivatives of " : "", + ustring_from(symbolname), ustring_from(sourcefile), + sourceline, ustring_from(opname), lane.value()); // continue checking all data lanes, and all components // for that matter, we want to find all issues, not just // the 1st, right? @@ -91,10 +92,10 @@ __OSL_MASKED_OP1(naninf_check_offset, OSL_BATCHOP void __OSL_MASKED_OP1(naninf_check_offset, Wi)(int mask_value, int ncomps, const void* vals_, - int has_derivs, void* bsg_, ustring_pod sourcefile, - int sourceline, ustring_pod symbolname, + int has_derivs, void* bsg_, ustringhash_pod sourcefile, + int sourceline, ustringhash_pod symbolname, const void* wide_offsets_ptr, int nchecks, - ustring_pod opname) + ustringhash_pod opname) { auto* bsg = reinterpret_cast(bsg_); ShadingContext* ctx = bsg->uniform.context; @@ -111,9 +112,9 @@ __OSL_MASKED_OP1(naninf_check_offset, ctx->errorfmt( "Detected {} value in {}{} at {}:{} (op {}) batch lane:{}", vals[i * __OSL_WIDTH + lane], - d > 0 ? "the derivatives of " : "", USTR(symbolname), - USTR(sourcefile), sourceline, USTR(opname), - lane.value()); + d > 0 ? "the derivatives of " : "", + ustring_from(symbolname), ustring_from(sourcefile), + sourceline, ustring_from(opname), lane.value()); // continue checking all data lanes, and all components // for that matter, we want to find all issues, not just // the 1st, right? @@ -131,10 +132,11 @@ __OSL_MASKED_OP1(naninf_check_offset, OSL_BATCHOP void __OSL_OP2(uninit_check_values_offset, X, i)(long long typedesc_, void* vals_, void* bsg_, - ustring_pod sourcefile, int sourceline, ustring_pod groupname_, - int layer, ustring_pod layername_, ustring_pod shadername, - int opnum, ustring_pod opname, int argnum, ustring_pod symbolname, - int firstcheck, int nchecks) + ustringhash_pod sourcefile, int sourceline, + ustringhash_pod groupname_, int layer, ustringhash_pod layername_, + ustringhash_pod shadername, int opnum, ustringhash_pod opname, + int argnum, ustringhash_pod symbolname, int firstcheck, + int nchecks) { TypeDesc typedesc = TYPEDESC(typedesc_); auto* bsg = reinterpret_cast(bsg_); @@ -157,16 +159,16 @@ __OSL_OP2(uninit_check_values_offset, X, } } if (typedesc.basetype == TypeDesc::STRING) { - ustring* vals = (ustring*)vals_; + ustringhash* vals = (ustringhash*)vals_; for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c) - if (vals[c] == Strings::uninitialized_string) { + if (vals[c] == Hashes::uninitialized_string) { uninit = true; vals[c] = ustring(); } } if (uninit) { - ustring groupname = USTR(groupname_); - ustring layername = USTR(layername_); + ustring groupname = ustring_from(groupname_); + ustring layername = ustring_from(layername_); ctx->errorfmt( "Detected possible use of uninitialized value in {} {} at {}:{} (group {}, layer {} {}, shader {}, op {} '{}', arg {})", typedesc, symbolname, sourcefile, sourceline, @@ -183,11 +185,11 @@ __OSL_OP2(uninit_check_values_offset, X, OSL_BATCHOP void __OSL_MASKED_OP2(uninit_check_values_offset, WX, i)(int mask_value, long long typedesc_, void* vals_, - void* bsg_, ustring_pod sourcefile, int sourceline, - ustring_pod groupname_, int layer, ustring_pod layername_, - ustring_pod shadername, int opnum, ustring_pod opname, - int argnum, ustring_pod symbolname, int firstcheck, - int nchecks) + void* bsg_, ustringhash_pod sourcefile, int sourceline, + ustringhash_pod groupname_, int layer, + ustringhash_pod layername_, ustringhash_pod shadername, + int opnum, ustringhash_pod opname, int argnum, + ustringhash_pod symbolname, int firstcheck, int nchecks) { TypeDesc typedesc = TYPEDESC(typedesc_); auto* bsg = reinterpret_cast(bsg_); @@ -218,19 +220,19 @@ __OSL_MASKED_OP2(uninit_check_values_offset, WX, }); } if (typedesc.basetype == TypeDesc::STRING) { - ustring* vals = (ustring*)vals_; + ustringhash* vals = (ustringhash*)vals_; for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c) mask.foreach ([=, &lanes_uninit](ActiveLane lane) -> void { if (vals[c * __OSL_WIDTH + lane] - == Strings::uninitialized_string) { + == Hashes::uninitialized_string) { lanes_uninit.set_on(lane); vals[c * __OSL_WIDTH + lane] = ustring(); } }); } if (lanes_uninit.any_on()) { - ustring groupname = USTR(groupname_); - ustring layername = USTR(layername_); + ustring groupname = ustring_from(groupname_); + ustring layername = ustring_from(layername_); ctx->errorfmt( "Detected possible use of uninitialized value in {} {} at {}:{} (group {}, layer {} {}, shader {}, op {} '{}', arg {}) for lanes({:x}) of batch", typedesc, symbolname, sourcefile, sourceline, @@ -247,11 +249,12 @@ __OSL_MASKED_OP2(uninit_check_values_offset, WX, OSL_BATCHOP void __OSL_MASKED_OP2(uninit_check_values_offset, X, Wi)(int mask_value, long long typedesc_, void* vals_, - void* bsg_, ustring_pod sourcefile, int sourceline, - ustring_pod groupname_, int layer, ustring_pod layername_, - ustring_pod shadername, int opnum, ustring_pod opname, - int argnum, ustring_pod symbolname, - const void* wide_offsets_ptr, int nchecks) + void* bsg_, ustringhash_pod sourcefile, int sourceline, + ustringhash_pod groupname_, int layer, + ustringhash_pod layername_, ustringhash_pod shadername, + int opnum, ustringhash_pod opname, int argnum, + ustringhash_pod symbolname, const void* wide_offsets_ptr, + int nchecks) { TypeDesc typedesc = TYPEDESC(typedesc_); auto* bsg = reinterpret_cast(bsg_); @@ -283,11 +286,11 @@ __OSL_MASKED_OP2(uninit_check_values_offset, X, }); } if (typedesc.basetype == TypeDesc::STRING) { - ustring* vals = (ustring*)vals_; + ustringhash* vals = (ustringhash*)vals_; mask.foreach ([=, &lanes_uninit](ActiveLane lane) -> void { int firstcheck = wOffsets[lane]; for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c) - if (vals[c] == Strings::uninitialized_string) { + if (vals[c] == Hashes::uninitialized_string) { lanes_uninit.set_on(lane); vals[c] = ustring(); } @@ -295,8 +298,8 @@ __OSL_MASKED_OP2(uninit_check_values_offset, X, } if (lanes_uninit.any_on()) { - ustring groupname = USTR(groupname_); - ustring layername = USTR(layername_); + ustring groupname = ustring_from(groupname_); + ustring layername = ustring_from(layername_); ctx->errorfmt( "Detected possible use of uninitialized value in {} {} at {}:{} (group {}, layer {} {}, shader {}, op {} '{}', arg {}) for lanes({:x}) of batch", typedesc, symbolname, sourcefile, sourceline, @@ -313,11 +316,12 @@ __OSL_MASKED_OP2(uninit_check_values_offset, X, OSL_BATCHOP void __OSL_MASKED_OP2(uninit_check_values_offset, WX, Wi)(int mask_value, long long typedesc_, void* vals_, - void* bsg_, ustring_pod sourcefile, int sourceline, - ustring_pod groupname_, int layer, ustring_pod layername_, - ustring_pod shadername, int opnum, ustring_pod opname, - int argnum, ustring_pod symbolname, - const void* wide_offsets_ptr, int nchecks) + void* bsg_, ustringhash_pod sourcefile, int sourceline, + ustringhash_pod groupname_, int layer, + ustringhash_pod layername_, ustringhash_pod shadername, + int opnum, ustringhash_pod opname, int argnum, + ustringhash_pod symbolname, const void* wide_offsets_ptr, + int nchecks) { TypeDesc typedesc = TYPEDESC(typedesc_); auto* bsg = reinterpret_cast(bsg_); @@ -350,12 +354,12 @@ __OSL_MASKED_OP2(uninit_check_values_offset, WX, }); } if (typedesc.basetype == TypeDesc::STRING) { - ustring* vals = (ustring*)vals_; + ustringhash* vals = (ustringhash*)vals_; mask.foreach ([=, &lanes_uninit](ActiveLane lane) -> void { int firstcheck = wOffsets[lane]; for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c) if (vals[c * __OSL_WIDTH + lane] - == Strings::uninitialized_string) { + == Hashes::uninitialized_string) { lanes_uninit.set_on(lane); vals[c * __OSL_WIDTH + lane] = ustring(); } @@ -363,8 +367,8 @@ __OSL_MASKED_OP2(uninit_check_values_offset, WX, } if (lanes_uninit.any_on()) { - ustring groupname = USTR(groupname_); - ustring layername = USTR(layername_); + ustring groupname = ustring_from(groupname_); + ustring layername = ustring_from(layername_); ctx->errorfmt( "Detected possible use of uninitialized value in {} {} at {}:{} (group {}, layer {} {}, shader {}, op {} '{}', arg {}) for lanes({:x}) of batch", typedesc, symbolname, sourcefile, sourceline, @@ -377,24 +381,24 @@ __OSL_MASKED_OP2(uninit_check_values_offset, WX, OSL_BATCHOP int -__OSL_OP(range_check)(int indexvalue, int length, ustring_pod symname, - void* bsg_, ustring_pod sourcefile, int sourceline, - ustring_pod groupname_, int layer, ustring_pod layername_, - ustring_pod shadername) +__OSL_OP(range_check)(int indexvalue, int length, ustringhash_pod symname, + void* bsg_, ustringhash_pod sourcefile, int sourceline, + ustringhash_pod groupname_, int layer, + ustringhash_pod layername_, ustringhash_pod shadername) { if (indexvalue < 0 || indexvalue >= length) { - ustring groupname = USTR(groupname_); - ustring layername = USTR(layername_); + ustring groupname = ustring_from(groupname_); + ustring layername = ustring_from(layername_); auto* bsg = reinterpret_cast(bsg_); ShadingContext* ctx = bsg->uniform.context; ctx->errorfmt("Index [{}] out of range {}[0..{}]: {}:{}" " (group {}, layer {} {}, shader {})", - indexvalue, USTR(symname), length - 1, USTR(sourcefile), - sourceline, + indexvalue, ustring_from(symname), length - 1, + ustring_from(sourcefile), sourceline, groupname.empty() ? "" : groupname.c_str(), layer, layername.empty() ? "" : layername.c_str(), - USTR(shadername)); + ustring_from(shadername)); if (indexvalue >= length) indexvalue = length - 1; else @@ -407,13 +411,14 @@ __OSL_OP(range_check)(int indexvalue, int length, ustring_pod symname, OSL_BATCHOP void __OSL_MASKED_OP(range_check)(void* wide_indexvalue, unsigned int mask_value, - int length, ustring_pod symname, void* bsg_, - ustring_pod sourcefile, int sourceline, - ustring_pod groupname_, int layer, - ustring_pod layername_, ustring_pod shadername) + int length, ustringhash_pod symname, void* bsg_, + ustringhash_pod sourcefile, int sourceline, + ustringhash_pod groupname_, int layer, + ustringhash_pod layername_, + ustringhash_pod shadername) { - ustring groupname = USTR(groupname_); - ustring layername = USTR(layername_); + ustring groupname = ustring_from(groupname_); + ustring layername = ustring_from(layername_); auto* bsg = reinterpret_cast(bsg_); Masked wIndexValue(wide_indexvalue, Mask(mask_value)); wIndexValue.mask().foreach ([=](ActiveLane lane) -> void { @@ -422,12 +427,12 @@ __OSL_MASKED_OP(range_check)(void* wide_indexvalue, unsigned int mask_value, ShadingContext* ctx = bsg->uniform.context; ctx->errorfmt( "Index [{}] out of range {}[0..{}]: {}:{} (group {}, layer {} {}, shader {})", - indexvalue, USTR(symname), length - 1, USTR(sourcefile), - sourceline, + indexvalue, ustring_from(symname), length - 1, + ustring_from(sourcefile), sourceline, groupname.empty() ? "" : groupname.c_str(), layer, layername.empty() ? "" : layername.c_str(), - USTR(shadername)); + ustring_from(shadername)); if (indexvalue >= length) indexvalue = length - 1; else @@ -441,17 +446,17 @@ __OSL_MASKED_OP(range_check)(void* wide_indexvalue, unsigned int mask_value, OSL_BATCHOP int -__OSL_OP1(get_attribute, s)(void* bsg_, int dest_derivs, ustring_pod obj_name_, - ustring_pod attr_name_, int array_lookup, int index, - const void* attr_type, void* wide_attr_dest, - int mask_) +__OSL_OP1(get_attribute, + s)(void* bsg_, int dest_derivs, ustringhash_pod obj_name_, + ustringhash_pod attr_name_, int array_lookup, int index, + const void* attr_type, void* wide_attr_dest, int mask_) { Mask mask(mask_); ASSERT(mask.any_on()); - auto* bsg = reinterpret_cast(bsg_); - ustring obj_name = USTR(obj_name_); - ustring attr_name = USTR(attr_name_); + auto* bsg = reinterpret_cast(bsg_); + ustringhash obj_name = ustringhash_from(obj_name_); + ustringhash attr_name = ustringhash_from(attr_name_); // Ignoring m_next_failed_attrib cache for now, // might be faster @@ -473,15 +478,15 @@ __OSL_OP1(get_attribute, s)(void* bsg_, int dest_derivs, ustring_pod obj_name_, OSL_BATCHOP int __OSL_MASKED_OP1(get_attribute, - Ws)(void* bsg_, int dest_derivs, ustring_pod obj_name_, - ustring_pod* wattr_name_, int array_lookup, int index, + Ws)(void* bsg_, int dest_derivs, ustringhash_pod obj_name_, + ustringhash_pod* wattr_name_, int array_lookup, int index, const void* attr_type, void* wide_attr_dest, int mask_) { Mask mask(mask_); ASSERT(mask.any_on()); - auto* bsg = reinterpret_cast(bsg_); - ustring obj_name = USTR(obj_name_); + auto* bsg = reinterpret_cast(bsg_); + ustringhash obj_name = ustringhash_from(obj_name_); Wide wAttrName(wattr_name_); auto* renderer = bsg->uniform.context->batched<__OSL_WIDTH>().renderer(); @@ -521,13 +526,14 @@ __OSL_MASKED_OP1(get_attribute, OSL_BATCHOP bool __OSL_OP(get_attribute_uniform)(void* bsg_, int dest_derivs, - ustring_pod obj_name_, ustring_pod attr_name_, - int array_lookup, int index, - const void* attr_type, void* attr_dest) + ustringhash_pod obj_name_, + ustringhash_pod attr_name_, int array_lookup, + int index, const void* attr_type, + void* attr_dest) { - auto* bsg = reinterpret_cast(bsg_); - ustring obj_name = USTR(obj_name_); - ustring attr_name = USTR(attr_name_); + auto* bsg = reinterpret_cast(bsg_); + ustringhash obj_name = ustringhash_from(obj_name_); + ustringhash attr_name = ustringhash_from(attr_name_); auto* renderer = bsg->uniform.context->batched<__OSL_WIDTH>().renderer(); @@ -547,10 +553,10 @@ __OSL_OP(get_attribute_uniform)(void* bsg_, int dest_derivs, OSL_BATCHOP int -__OSL_OP(bind_interpolated_param)(void* bsg_, ustring_pod name, long long type, - int userdata_has_derivs, void* userdata_data, - int symbol_has_derivs, void* symbol_data, - int symbol_data_size, +__OSL_OP(bind_interpolated_param)(void* bsg_, ustringhash_pod name, + long long type, int userdata_has_derivs, + void* userdata_data, int symbol_has_derivs, + void* symbol_data, int symbol_data_size, unsigned int* userdata_initialized, int userdata_index, unsigned int mask_value) { @@ -564,7 +570,8 @@ __OSL_OP(bind_interpolated_param)(void* bsg_, ustring_pod name, long long type, MaskedData userDest(TYPEDESC(type), userdata_has_derivs, Mask(mask_value), userdata_data); Mask foundUserData = bsg->uniform.renderer->batched(WidthTag()) - ->get_userdata(USTR(name), bsg, userDest); + ->get_userdata(ustringhash_from(name), bsg, + userDest); // print("Binding {} {} : index {}, ok = {}\n", name, // TYPEDESC(type).c_str(),userdata_index, foundUserData.value()); @@ -589,19 +596,25 @@ __OSL_OP(bind_interpolated_param)(void* bsg_, ustring_pod name, long long type, OSL_BATCHOP int __OSL_OP(raytype_bit)(void* bsg_, int bit) { - auto* bsg = reinterpret_cast(bsg_); - return (bsg->uniform.raytype & bit) != 0; + //TODO FIXME + //auto* bsg = reinterpret_cast(bsg_); + //return (bsg->uniform.raytype & bit) != 0; + return 0; } // Asked if the raytype is a name we can't know until mid-shader. OSL_BATCHOP int -__OSL_OP(raytype_name)(void* bsg_, ustring_pod name) +__OSL_OP(raytype_name)(void* bsg_, ustringhash_pod name) { auto* bsg = reinterpret_cast(bsg_); - int bit = bsg->uniform.context->shadingsys().raytype_bit(USTR(name)); - return (bsg->uniform.raytype & bit) != 0; + //TODO FIXME + //int bit = bsg->uniform.context->shadingsys().raytype_bit( + // // TODO change to ustringhash + // ustring_from(name)); + //return (bsg->uniform.raytype & bit) != 0; + return 0; } @@ -615,7 +628,9 @@ __OSL_MASKED_OP(raytype_name)(void* bsg_, void* r_, ustring* name_, Mask mask(mask_value); foreach_unique(wname, mask, [=](ustring name, Mask matching_lanes) -> void { - int bit = bsg->uniform.context->shadingsys().raytype_bit(name); + // TODO FIXME + //int bit = bsg->uniform.context->shadingsys().raytype_bit(name); + int bit = 0; int ray_is_named_type = ((bsg->uniform.raytype & bit) != 0); Masked wr(r_, matching_lanes); assign_all(wr, ray_is_named_type);