From b859317915261a39e835e1d5497198de12028142 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sat, 4 May 2024 21:58:44 -0700 Subject: [PATCH] cleanup: Switch some deprecated TypeDesc names to modern ones (#1806) Signed-off-by: Larry Gritz --- src/include/OSL/batched_texture.h | 8 +-- src/include/OSL/genclosure.h | 20 +++--- src/include/OSL/oslexec.h | 2 +- src/include/osl_pvt.h | 48 +++---------- src/liboslcomp/ast.h | 6 +- src/liboslcomp/codegen.cpp | 4 +- src/liboslcomp/oslcomp.cpp | 25 +++---- src/liboslcomp/oslgram.y | 16 ++--- src/liboslcomp/symtab.h | 11 ++- src/liboslcomp/typecheck.cpp | 74 ++++++++++---------- src/liboslexec/backendllvm.cpp | 14 ++-- src/liboslexec/batched_backendllvm.cpp | 86 ++++++++++++------------ src/liboslexec/batched_llvm_gen.cpp | 62 +++++++---------- src/liboslexec/batched_llvm_instance.cpp | 21 +++--- src/liboslexec/closure.cpp | 10 +-- src/liboslexec/constfold.cpp | 68 ++++++++----------- src/liboslexec/llvm_gen.cpp | 21 +++--- src/liboslexec/loadshader.cpp | 10 +-- src/liboslexec/osogram.y | 16 ++--- src/liboslexec/pointcloud.h | 6 +- src/liboslexec/runtimeoptimize.cpp | 2 +- src/liboslexec/runtimeoptimize.h | 21 ++---- src/liboslexec/shadingsys.cpp | 71 ++++++++++--------- src/osl.imageio/oslinput.cpp | 8 +-- src/osltoy/osltoyapp.cpp | 4 +- src/osltoy/osltoyrenderer.cpp | 22 +++--- src/testrender/background.h | 4 +- src/testrender/simpleraytracer.cpp | 37 +++++----- src/testshade/simplerend.cpp | 49 ++++++-------- src/testshade/testshade.cpp | 14 ++-- 30 files changed, 336 insertions(+), 424 deletions(-) diff --git a/src/include/OSL/batched_texture.h b/src/include/OSL/batched_texture.h index a2cd78285..c720e9bed 100644 --- a/src/include/OSL/batched_texture.h +++ b/src/include/OSL/batched_texture.h @@ -219,7 +219,7 @@ template class BatchedTextureOutputs { void* errormessage, Mask mask) : m_result(result) , m_resultHasDerivs(resultHasDerivs) - , m_resultType((chans == 1) ? TypeDesc::TypeFloat : TypeDesc::TypeColor) + , m_resultType((chans == 1) ? TypeFloat : TypeColor) , m_alpha(alpha) , m_alphaHasDerivs(alphaHasDerivs) , m_errormessage(errormessage) @@ -240,15 +240,13 @@ template class BatchedTextureOutputs { // The return value maybe invalid or be Masked OSL_FORCEINLINE MaskedData alpha() { - return MaskedData(TypeDesc::TypeFloat, m_alphaHasDerivs, m_mask, - m_alpha); + return MaskedData(TypeFloat, m_alphaHasDerivs, m_mask, m_alpha); } // The return value maybe invalid or be Masked OSL_FORCEINLINE MaskedData errormessage() { - return MaskedData(TypeDesc::TypeString, false, m_mask, - m_errormessage); + return MaskedData(TypeString, false, m_mask, m_errormessage); } private: diff --git a/src/include/OSL/genclosure.h b/src/include/OSL/genclosure.h index f03038537..559707c4c 100644 --- a/src/include/OSL/genclosure.h +++ b/src/include/OSL/genclosure.h @@ -24,15 +24,15 @@ struct ClosureParam { #define fieldsize(st, fld) sizeof(((st *)0)->fld) #define CLOSURE_INT_PARAM(st, fld) \ - { TypeDesc::TypeInt, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } + { TypeInt, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } #define CLOSURE_FLOAT_PARAM(st, fld) \ - { TypeDesc::TypeFloat, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } + { TypeFloat, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } #define CLOSURE_COLOR_PARAM(st, fld) \ - { TypeDesc::TypeColor, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } + { TypeColor, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } #define CLOSURE_VECTOR_PARAM(st, fld) \ - { TypeDesc::TypeVector, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } + { TypeVector, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } #define CLOSURE_STRING_PARAM(st, fld) \ - { TypeDesc::TypeString, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } + { TypeString, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } #define CLOSURE_CLOSURE_PARAM(st, fld) \ { TypeDesc::PTR, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) } @@ -49,15 +49,15 @@ struct ClosureParam { // NOTE: this keyword args have to be always at the end of the list #define CLOSURE_INT_KEYPARAM(st, fld, key) \ - { TypeDesc::TypeInt, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } + { TypeInt, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } #define CLOSURE_FLOAT_KEYPARAM(st, fld, key) \ - { TypeDesc::TypeFloat, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } + { TypeFloat, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } #define CLOSURE_COLOR_KEYPARAM(st, fld, key) \ - { TypeDesc::TypeColor, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } + { TypeColor, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } #define CLOSURE_VECTOR_KEYPARAM(st, fld, key) \ - { TypeDesc::TypeVector, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } + { TypeVector, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } #define CLOSURE_STRING_KEYPARAM(st, fld, key) \ - { TypeDesc::TypeString, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } + { TypeString, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) } #define CLOSURE_FINISH_PARAM(st) { TypeDesc(), sizeof(st), nullptr, alignof(st) } diff --git a/src/include/OSL/oslexec.h b/src/include/OSL/oslexec.h index 0ae628aff..ced35df2e 100644 --- a/src/include/OSL/oslexec.h +++ b/src/include/OSL/oslexec.h @@ -570,7 +570,7 @@ class OSLEXECPUBLIC ShadingSystem { // float blur = 0.001; // ss->Parameter (*group, "blur", blur); // Vec3 colorfilter (0.5f, 0.5f, 1.0f); - // ss->Parameter (*group, "colorfilter", TypeDesc::TypeColor, + // ss->Parameter (*group, "colorfilter", TypeColor, // &colorfilter); // ss->Shader ("surface", "texmap", "texturelayer"); // /* Second layer - generate the BSDF closure: */ diff --git a/src/include/osl_pvt.h b/src/include/osl_pvt.h index dc3528397..8b723374c 100644 --- a/src/include/osl_pvt.h +++ b/src/include/osl_pvt.h @@ -244,46 +244,25 @@ class TypeSpec { // m_simple is always UNKNOWN for structures. /// Is it a simple scalar int? - bool is_int() const - { - return m_simple == TypeDesc::TypeInt && !is_closure(); - } + bool is_int() const { return m_simple == TypeInt && !is_closure(); } /// Is it a simple scalar float? - bool is_float() const - { - return m_simple == TypeDesc::TypeFloat && !is_closure(); - } + bool is_float() const { return m_simple == TypeFloat && !is_closure(); } /// Is it a color? - bool is_color() const - { - return m_simple == TypeDesc::TypeColor && !is_closure(); - } + bool is_color() const { return m_simple == TypeColor && !is_closure(); } /// Is it a point? - bool is_point() const - { - return m_simple == TypeDesc::TypePoint && !is_closure(); - } + bool is_point() const { return m_simple == TypePoint && !is_closure(); } /// Is it a vector? - bool is_vector() const - { - return m_simple == TypeDesc::TypeVector && !is_closure(); - } + bool is_vector() const { return m_simple == TypeVector && !is_closure(); } /// Is it a normal? - bool is_normal() const - { - return m_simple == TypeDesc::TypeNormal && !is_closure(); - } + bool is_normal() const { return m_simple == TypeNormal && !is_closure(); } /// Is it a simple string? - bool is_string() const - { - return m_simple == TypeDesc::TypeString && !is_closure(); - } + bool is_string() const { return m_simple == TypeString && !is_closure(); } /// Is it a string or an array of strings? /// @@ -357,9 +336,8 @@ class TypeSpec { bool is_vectriple() const { return !is_closure() - && (m_simple == TypeDesc::TypePoint - || m_simple == TypeDesc::TypeVector - || m_simple == TypeDesc::TypeNormal); + && (m_simple == TypePoint || m_simple == TypeVector + || m_simple == TypeNormal); } /// Is it based on a vector-like triple (point, vector, or normal)? @@ -367,16 +345,12 @@ class TypeSpec { bool is_vectriple_based() const { auto elem = m_simple.elementtype(); - return (elem == TypeDesc::TypePoint || elem == TypeDesc::TypeVector - || elem == TypeDesc::TypeNormal); + return (elem == TypePoint || elem == TypeVector || elem == TypeNormal); } /// Is it a simple matrix (but not an array or closure)? /// - bool is_matrix() const - { - return m_simple == TypeDesc::TypeMatrix && !is_closure(); - } + bool is_matrix() const { return m_simple == TypeMatrix && !is_closure(); } /// Is it a color closure? /// diff --git a/src/liboslcomp/ast.h b/src/liboslcomp/ast.h index f4bd2eeec..7696753af 100644 --- a/src/liboslcomp/ast.h +++ b/src/liboslcomp/ast.h @@ -1032,19 +1032,19 @@ class ASTliteral final : public ASTNode { ASTliteral(OSLCompilerImpl* comp, int i) : ASTNode(literal_node, comp), m_i(i) { - m_typespec = TypeDesc::TypeInt; + m_typespec = TypeInt; } ASTliteral(OSLCompilerImpl* comp, float f) : ASTNode(literal_node, comp), m_f(f) { - m_typespec = TypeDesc::TypeFloat; + m_typespec = TypeFloat; } ASTliteral(OSLCompilerImpl* comp, ustring s) : ASTNode(literal_node, comp), m_s(s) { - m_typespec = TypeDesc::TypeString; + m_typespec = TypeString; } const char* nodetypename() const { return "literal"; } diff --git a/src/liboslcomp/codegen.cpp b/src/liboslcomp/codegen.cpp index 6cb81bf0d..8afba9deb 100644 --- a/src/liboslcomp/codegen.cpp +++ b/src/liboslcomp/codegen.cpp @@ -354,7 +354,7 @@ ASTNode::codegen_int(Symbol*, bool boolify, bool invert) if (!type.is_int() || boolify || invert) { // If they're not using an int as the condition, then it's an // implied comparison to zero. - Symbol* tempvar = m_compiler->make_temporary(TypeDesc::TypeInt); + Symbol* tempvar = m_compiler->make_temporary(TypeInt); Symbol* zerovar = NULL; if (type.is_closure()) zerovar = m_compiler->make_constant((int)0); @@ -1543,7 +1543,7 @@ ASTbinary_expression::codegen(Symbol* dest) if (m_op == Mul || m_op == Div) { // Need to coerce the weight into a color. // N.B. The typecheck always reorders c=k*c into c=c*k. - rsym = coerce(rsym, TypeDesc::TypeColor, true); + rsym = coerce(rsym, TypeColor, true); } emitcode(opword(), dest, lsym, rsym); return dest; diff --git a/src/liboslcomp/oslcomp.cpp b/src/liboslcomp/oslcomp.cpp index c71eebc84..1c29aee50 100644 --- a/src/liboslcomp/oslcomp.cpp +++ b/src/liboslcomp/oslcomp.cpp @@ -632,20 +632,15 @@ struct GlobalTable { void OSLCompilerImpl::initialize_globals() { - static GlobalTable globals[] - = { { "P", TypeDesc::TypePoint, false }, - { "I", TypeDesc::TypeVector, false }, - { "N", TypeDesc::TypeNormal, false }, - { "Ng", TypeDesc::TypeNormal }, - { "u", TypeDesc::TypeFloat }, - { "v", TypeDesc::TypeFloat }, - { "dPdu", TypeDesc::TypeVector }, - { "dPdv", TypeDesc::TypeVector }, - { "Ps", TypeDesc::TypePoint }, - { "Ci", TypeSpec(TypeDesc::TypeColor, true), false }, - { "time", TypeDesc::TypeFloat }, - { "dtime", TypeDesc::TypeFloat }, - { "dPdtime", TypeDesc::TypeVector } }; + static GlobalTable globals[] = { + { "P", TypePoint, false }, { "I", TypeVector, false }, + { "N", TypeNormal, false }, { "Ng", TypeNormal }, + { "u", TypeFloat }, { "v", TypeFloat }, + { "dPdu", TypeVector }, { "dPdv", TypeVector }, + { "Ps", TypePoint }, { "Ci", TypeSpec(TypeColor, true), false }, + { "time", TypeFloat }, { "dtime", TypeFloat }, + { "dPdtime", TypeVector } + }; for (auto& g : globals) { Symbol* s = new Symbol(ustring(g.name), g.type, SymTypeGlobal); @@ -706,7 +701,7 @@ OSLCompilerImpl::write_oso_const_value(const ConstantSymbol* sym) const else if (elemtype == TypeDesc::FLOAT) for (int i = 0; i < nelements; ++i) osofmt("{:.9g}{}", sym->floatval(i), nelements > 1 ? " " : ""); - else if (equivalent(elemtype, TypeDesc::TypeVector)) + else if (equivalent(elemtype, TypeVector)) for (int i = 0; i < nelements; ++i) { Vec3 v = sym->get_vec3(i); osofmt("{:.9g} {:.9g} {:.9g}{}", v.x, v.y, v.z, diff --git a/src/liboslcomp/oslgram.y b/src/liboslcomp/oslgram.y index e46bbd822..052c09821 100644 --- a/src/liboslcomp/oslgram.y +++ b/src/liboslcomp/oslgram.y @@ -1110,14 +1110,14 @@ inline TypeDesc OSL::pvt::osllextype (int lex) { switch (lex) { - case COLORTYPE : return TypeDesc::TypeColor; - case FLOATTYPE : return TypeDesc::TypeFloat; - case INTTYPE : return TypeDesc::TypeInt; - case MATRIXTYPE : return TypeDesc::TypeMatrix; - case NORMALTYPE : return TypeDesc::TypeNormal; - case POINTTYPE : return TypeDesc::TypePoint; - case STRINGTYPE : return TypeDesc::TypeString; - case VECTORTYPE : return TypeDesc::TypeVector; + case COLORTYPE : return TypeColor; + case FLOATTYPE : return TypeFloat; + case INTTYPE : return TypeInt; + case MATRIXTYPE : return TypeMatrix; + case NORMALTYPE : return TypeNormal; + case POINTTYPE : return TypePoint; + case STRINGTYPE : return TypeString; + case VECTORTYPE : return TypeVector; case VOIDTYPE : return TypeDesc::NONE; default: return TypeDesc::UNKNOWN; } diff --git a/src/liboslcomp/symtab.h b/src/liboslcomp/symtab.h index 173af726e..3e58eebe5 100644 --- a/src/liboslcomp/symtab.h +++ b/src/liboslcomp/symtab.h @@ -114,20 +114,17 @@ class FunctionSymbol final : public Symbol { /// the parent class to properly free it upon destruction. class ConstantSymbol final : public Symbol { public: - ConstantSymbol(ustring n, ustring val) - : Symbol(n, TypeDesc::TypeString, SymTypeConst) + ConstantSymbol(ustring n, ustring val) : Symbol(n, TypeString, SymTypeConst) { m_val.s = val.c_str(); set_dataptr(SymArena::Absolute, &m_val.s); } - ConstantSymbol(ustring n, int val) - : Symbol(n, TypeDesc::TypeInt, SymTypeConst) + ConstantSymbol(ustring n, int val) : Symbol(n, TypeInt, SymTypeConst) { m_val.i = val; set_dataptr(SymArena::Absolute, &m_val.i); } - ConstantSymbol(ustring n, float val) - : Symbol(n, TypeDesc::TypeFloat, SymTypeConst) + ConstantSymbol(ustring n, float val) : Symbol(n, TypeFloat, SymTypeConst) { m_val.f = val; set_dataptr(SymArena::Absolute, &m_val.f); @@ -148,7 +145,7 @@ class ConstantSymbol final : public Symbol { set_dataptr(SymArena::Absolute, &m_val.i); else if (type == TypeDesc::STRING) set_dataptr(SymArena::Absolute, &m_val.s); - else if (equivalent(type, TypeDesc::TypeVector)) + else if (equivalent(type, TypeVector)) set_dataptr(SymArena::Absolute, &m_val.v); else { OSL_DASSERT(arena() == SymArena::Unknown); diff --git a/src/liboslcomp/typecheck.cpp b/src/liboslcomp/typecheck.cpp index 83dc4d9f6..be66fe057 100644 --- a/src/liboslcomp/typecheck.cpp +++ b/src/liboslcomp/typecheck.cpp @@ -426,7 +426,7 @@ ASTunary_expression::typecheck(TypeSpec expected) m_typespec = t; break; case Not: - m_typespec = TypeDesc::TypeInt; // ! is always an int + m_typespec = TypeInt; // ! is always an int break; case Compl: if (!t.is_int()) { @@ -515,7 +515,7 @@ ASTbinary_expression::typecheck(TypeSpec expected) if (m_op == And || m_op == Or) { // Logical ops work can work on closures (since they test // for nonemptiness, but always return int. - return m_typespec = TypeDesc::TypeInt; + return m_typespec = TypeInt; } // If we got this far, it's an op that's not allowed errorfmt("Not allowed: '{} {} {}'", l, opname(), r); @@ -538,10 +538,10 @@ ASTbinary_expression::typecheck(TypeSpec expected) if (equivalent(l, r)) { // handle a few couple special cases if (m_op == Sub && l.is_point() && r.is_point()) // p-p == v - return m_typespec = TypeDesc::TypeVector; + return m_typespec = TypeVector; if ((m_op == Add || m_op == Sub) && (l.is_point() || r.is_point())) // p +/- v, v +/- p == p - return m_typespec = TypeDesc::TypePoint; + return m_typespec = TypePoint; // everything else: the first operand is also the return type return m_typespec = l; } @@ -553,7 +553,7 @@ ASTbinary_expression::typecheck(TypeSpec expected) case Mod: // Mod only works with ints, and return ints. if (l.is_int() && r.is_int()) - return m_typespec = TypeDesc::TypeInt; + return m_typespec = TypeInt; break; case Equal: @@ -563,7 +563,7 @@ ASTbinary_expression::typecheck(TypeSpec expected) // Result is always an int. if (equivalent(l, r) || (l.is_numeric() && r.is_int_or_float()) || (l.is_int_or_float() && r.is_numeric())) - return m_typespec = TypeDesc::TypeInt; + return m_typespec = TypeInt; break; case Greater: @@ -573,7 +573,7 @@ ASTbinary_expression::typecheck(TypeSpec expected) // G/L comparisons only work with floats or ints, and always // return int. if (l.is_int_or_float() && r.is_int_or_float()) - return m_typespec = TypeDesc::TypeInt; + return m_typespec = TypeInt; break; case BitAnd: @@ -583,14 +583,14 @@ ASTbinary_expression::typecheck(TypeSpec expected) case ShiftRight: // Bitwise ops only work with ints, and return ints. if (l.is_int() && r.is_int()) - return m_typespec = TypeDesc::TypeInt; + return m_typespec = TypeInt; break; case And: case Or: // Logical ops work on any simple type (since they test for // nonzeroness), but always return int. - return m_typespec = TypeDesc::TypeInt; + return m_typespec = TypeInt; default: errorfmt("unknown binary operator"); } @@ -606,7 +606,7 @@ TypeSpec ASTternary_expression::typecheck(TypeSpec expected) { // FIXME - closures - TypeSpec c = typecheck_list(cond(), TypeDesc::TypeInt); + TypeSpec c = typecheck_list(cond(), TypeInt); TypeSpec t = typecheck_list(trueexpr(), expected); TypeSpec f = typecheck_list(falseexpr(), expected); @@ -1268,9 +1268,9 @@ ASTfunction_call::typecheck_builtin_specialcase() if (m_name == "transform") { // Special case for transform: under the covers, it selects // vector or normal special versions depending on its use. - if (typespec().simpletype() == TypeDesc::TypeVector) + if (typespec().simpletype() == TypeVector) m_name = ustring("transformv"); - else if (typespec().simpletype() == TypeDesc::TypeNormal) + else if (typespec().simpletype() == TypeNormal) m_name = ustring("transformn"); } @@ -1760,21 +1760,21 @@ class CandidateFunctions { OSL_DASSERT(!s.is_closure() || s.is_color_closure()); const TypeDesc& td = s.simpletype(); - if (td == TypeDesc::TypeFloat) + if (td == TypeFloat) return 0; - if (td == TypeDesc::TypeInt) + if (td == TypeInt) return 1; - if (td == TypeDesc::TypeColor) + if (td == TypeColor) return 2; - if (td == TypeDesc::TypeVector) + if (td == TypeVector) return 3; - if (td == TypeDesc::TypePoint) + if (td == TypePoint) return 4; - if (td == TypeDesc::TypeNormal) + if (td == TypeNormal) return 5; - if (td == TypeDesc::TypeMatrix) + if (td == TypeMatrix) return 6; - if (td == TypeDesc::TypeString) + if (td == TypeString) return 7; if (s.is_color_closure()) @@ -2238,20 +2238,20 @@ OSLCompilerImpl::type_from_code(const char* code, int* advance) TypeSpec t; int i = 0; switch (code[i]) { - case 'i': t = TypeDesc::TypeInt; break; - case 'f': t = TypeDesc::TypeFloat; break; - case 'c': t = TypeDesc::TypeColor; break; - case 'p': t = TypeDesc::TypePoint; break; - case 'v': t = TypeDesc::TypeVector; break; - case 'n': t = TypeDesc::TypeNormal; break; - case 'm': t = TypeDesc::TypeMatrix; break; - case 's': t = TypeDesc::TypeString; break; + case 'i': t = TypeInt; break; + case 'f': t = TypeFloat; break; + case 'c': t = TypeColor; break; + case 'p': t = TypePoint; break; + case 'v': t = TypeVector; break; + case 'n': t = TypeNormal; break; + case 'm': t = TypeMatrix; break; + case 's': t = TypeString; break; case 'h': t = OSL::TypeUInt64; break; // ustringhash_pod case 'x': t = TypeDesc(TypeDesc::NONE); break; case 'X': t = TypeDesc(TypeDesc::PTR); break; case 'L': t = TypeDesc(TypeDesc::LONGLONG); break; case 'C': // color closure - t = TypeSpec(TypeDesc::TypeColor, true); + t = TypeSpec(TypeColor, true); break; case 'S': // structure // Following the 'S' is the numeric structure ID @@ -2337,21 +2337,21 @@ OSLCompilerImpl::code_from_type(TypeSpec type) const } else if (type.is_closure() || type.is_closure_array()) { out = 'C'; } else { - if (elem == TypeDesc::TypeInt) + if (elem == TypeInt) out = 'i'; - else if (elem == TypeDesc::TypeFloat) + else if (elem == TypeFloat) out = 'f'; - else if (elem == TypeDesc::TypeColor) + else if (elem == TypeColor) out = 'c'; - else if (elem == TypeDesc::TypePoint) + else if (elem == TypePoint) out = 'p'; - else if (elem == TypeDesc::TypeVector) + else if (elem == TypeVector) out = 'v'; - else if (elem == TypeDesc::TypeNormal) + else if (elem == TypeNormal) out = 'n'; - else if (elem == TypeDesc::TypeMatrix) + else if (elem == TypeMatrix) out = 'm'; - else if (elem == TypeDesc::TypeString) + else if (elem == TypeString) out = 's'; else if (elem == TypeDesc::NONE) out = 'x'; diff --git a/src/liboslexec/backendllvm.cpp b/src/liboslexec/backendllvm.cpp index 62855dfa1..a72854152 100644 --- a/src/liboslexec/backendllvm.cpp +++ b/src/liboslexec/backendllvm.cpp @@ -378,13 +378,13 @@ BackendLLVM::llvm_load_value(const Symbol& sym, int deriv, if (sym.is_constant() && !sym.typespec().is_array() && !arrayindex) { // Shortcut for simple constants if (sym.typespec().is_float()) { - if (cast == TypeDesc::TypeInt) + if (cast == TypeInt) return ll.constant((int)sym.get_float()); else return ll.constant(sym.get_float()); } if (sym.typespec().is_int()) { - if (cast == TypeDesc::TypeFloat) + if (cast == TypeFloat) return ll.constant((float)sym.get_int()); else return ll.constant(sym.get_int()); @@ -438,9 +438,9 @@ BackendLLVM::llvm_load_value(llvm::Value* ptr, const TypeSpec& type, int deriv, return result; // Handle int<->float type casting - if (type.is_float_based() && !type.is_array() && cast == TypeDesc::TypeInt) + if (type.is_float_based() && !type.is_array() && cast == TypeInt) result = ll.op_float_to_int(result); - else if (type.is_int() && cast == TypeDesc::TypeFloat) + else if (type.is_int() && cast == TypeFloat) result = ll.op_int_to_float(result); return result; @@ -473,13 +473,13 @@ BackendLLVM::llvm_load_constant_value(const Symbol& sym, int arrayindex, return ll.constant(sym.get_float(linear_index)); } if (sym.typespec().is_float_based()) { - if (cast == TypeDesc::TypeInt) + if (cast == TypeInt) return ll.constant((int)sym.get_float(linear_index)); else return ll.constant(sym.get_float(linear_index)); } if (sym.typespec().is_int_based()) { - if (cast == TypeDesc::TypeFloat) + if (cast == TypeFloat) return ll.constant((float)sym.get_int(linear_index)); else return ll.constant(sym.get_int(linear_index)); @@ -719,7 +719,7 @@ BackendLLVM::llvm_test_nonzero(Symbol& val, bool test_derivs) TypeDesc t = ts.simpletype(); // Handle int case -- guaranteed no derivs, no multi-component - if (t == TypeDesc::TypeInt) + if (t == TypeInt) return ll.op_ne(llvm_load_value(val), ll.constant(0)); // float-based diff --git a/src/liboslexec/batched_backendllvm.cpp b/src/liboslexec/batched_backendllvm.cpp index d7beb8772..e94122ef4 100644 --- a/src/liboslexec/batched_backendllvm.cpp +++ b/src/liboslexec/batched_backendllvm.cpp @@ -702,7 +702,7 @@ BatchedBackendLLVM::llvm_widen_value_into_temp(const Symbol& sym, int deriv) auto disable_masked_stores = ll.create_masking_scope(false); for (int c = 0; c < t.aggregate(); ++c) { // NOTE: we use the passed deriv to load, but store to value (deriv==0) - llvm::Value* v = llvm_load_value(sym, deriv, c, TypeDesc::UNKNOWN, + llvm::Value* v = llvm_load_value(sym, deriv, c, TypeUnknown, /*is_uniform*/ false); llvm_store_value(v, widePtr, t, 0, NULL, c, /*is_uniform*/ false); } @@ -739,7 +739,7 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv, // Shortcut for simple constants if (sym.typespec().is_float()) { float float_val = sym.get_float(); - if (cast == TypeDesc::TypeInt) { + if (cast == TypeInt) { int int_val = static_cast(float_val); if (op_is_uniform) { return ll.constant(int_val); @@ -754,7 +754,7 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv, } if (sym.typespec().is_int()) { int int_val = sym.get_int(); - if (cast == TypeDesc::TypeFloat) { + if (cast == TypeFloat) { float float_val = static_cast(int_val); if (op_is_uniform) { return ll.constant(float_val); @@ -806,9 +806,9 @@ BatchedBackendLLVM::llvm_load_mask(const Symbol& cond) llvm::Value* llvm_mask = nullptr; llvm::Value* llvm_mask_or_wide_int = llvm_load_value(cond, /*deriv*/ 0, /*component*/ 0, - /*cast*/ TypeDesc::UNKNOWN, /*op_is_uniform*/ false); + /*cast*/ TypeUnknown, /*op_is_uniform*/ false); if (cond.forced_llvm_bool()) { - // The llvm_load_value + TypeDesc::UNKNOWN will check and convert to llvm mask already + // The llvm_load_value + TypeUnknown will check and convert to llvm mask already llvm_mask = llvm_mask_or_wide_int; } else { OSL_ASSERT(ll.llvm_typeof(llvm_mask_or_wide_int) == ll.type_wide_int()); @@ -890,19 +890,19 @@ BatchedBackendLLVM::llvm_load_value(llvm::Value* src_ptr, const TypeSpec& type, result = ll.native_to_llvm_mask(result); } - if (cast != TypeDesc::UNKNOWN) { - if (cast == TypeDesc::TypeInt) { + if (cast != TypeUnknown) { + if (cast == TypeInt) { result = ll.op_bool_to_int(result); - } else if (cast == TypeDesc::TypeFloat) { + } else if (cast == TypeFloat) { result = ll.op_bool_to_float(result); } } } // Handle int<->float type casting - if (type.is_float_based() && cast == TypeDesc::TypeInt) + if (type.is_float_based() && cast == TypeInt) result = ll.op_float_to_int(result); - else if (type.is_int() && cast == TypeDesc::TypeFloat) + else if (type.is_int() && cast == TypeFloat) result = ll.op_int_to_float(result); else if (type.is_string() && cast == TypeDesc::LONGLONG) result = ll.ptr_to_cast(result, ll.type_longlong()); @@ -911,12 +911,11 @@ BatchedBackendLLVM::llvm_load_value(llvm::Value* src_ptr, const TypeSpec& type, // TODO: remove this assert once we have confirmed correct handling off all the // different data types. Using OSL_ASSERT as a checklist to verify what we have // handled so far during development - OSL_ASSERT( - cast == TypeDesc::UNKNOWN || cast == TypeDesc::TypeColor - || cast == TypeDesc::TypeVector || cast == TypeDesc::TypePoint - || cast == TypeDesc::TypeNormal || cast == TypeDesc::TypeFloat - || cast == TypeDesc::TypeInt || cast == TypeDesc::TypeString - || cast == TypeDesc::TypeMatrix || cast == TypeDesc::LONGLONG); + OSL_ASSERT(cast == TypeUnknown || cast == TypeColor + || cast == TypeVector || cast == TypePoint + || cast == TypeNormal || cast == TypeFloat + || cast == TypeInt || cast == TypeString + || cast == TypeMatrix || cast == TypeDesc::LONGLONG); if ((ll.llvm_typeof(result) == ll.type_bool()) || (ll.llvm_typeof(result) == ll.type_float()) @@ -991,9 +990,9 @@ BatchedBackendLLVM::llvm_load_value(llvm::Value* src_ptr, const TypeSpec& type, OSL_ASSERT(ll.llvm_typeof(result) != ll.type_wide_bool()); // Handle int<->float type casting - if (type.is_float_based() && cast == TypeDesc::TypeInt) + if (type.is_float_based() && cast == TypeInt) result = ll.op_float_to_int(result); - else if (type.is_int() && cast == TypeDesc::TypeFloat) + else if (type.is_int() && cast == TypeFloat) result = ll.op_int_to_float(result); else if (type.is_string() && cast == TypeDesc::LONGLONG) result = ll.ptr_to_cast(result, ll.type_longlong()); @@ -1027,7 +1026,7 @@ BatchedBackendLLVM::llvm_load_constant_value(const Symbol& sym, int arrayindex, if (elementType.is_float()) { float float_elem = sym.get_float(arrayindex); - if (cast == TypeDesc::TypeInt) { + if (cast == TypeInt) { int int_elem = static_cast(float_elem); if (op_is_uniform) { return ll.constant(int_elem); @@ -1042,7 +1041,7 @@ BatchedBackendLLVM::llvm_load_constant_value(const Symbol& sym, int arrayindex, } if (elementType.is_int()) { int int_elem = sym.get_int(arrayindex); - if (cast == TypeDesc::TypeFloat) { + if (cast == TypeFloat) { float float_elem = static_cast(int_elem); if (op_is_uniform) { return ll.constant(float_elem); @@ -1164,14 +1163,14 @@ BatchedBackendLLVM::llvm_load_arg(const Symbol& sym, bool derivs, // get passed as a pointer instead of by value // So let this case fall through if (op_is_uniform) { - return llvm_load_value(sym, 0, 0, TypeDesc::UNKNOWN, op_is_uniform); + return llvm_load_value(sym, 0, 0, TypeUnknown, op_is_uniform); } else if (sym.symtype() == SymTypeConst) { // As the case to deliver a pointer to a symbol data // doesn't provide an opportunity to promote a uniform constant // to a wide value that the non-uniform function is expecting // we will handle it here. llvm::Value* wide_constant_value - = llvm_load_constant_value(sym, 0, 0, TypeDesc::UNKNOWN, + = llvm_load_constant_value(sym, 0, 0, TypeUnknown, op_is_uniform); // Have to have a place on the stack for the pointer to the wide constant to point to @@ -1208,7 +1207,7 @@ BatchedBackendLLVM::llvm_load_arg(const Symbol& sym, bool derivs, for (int c = 0; c < t.aggregate(); ++c) { // Will automatically widen value if needed llvm::Value* v = llvm_load_value(sym, d, arrayIndex, c, - TypeDesc::UNKNOWN, + TypeUnknown, op_is_uniform); llvm_store_value(v, tmpptr, t, d, arrayIndex, c, op_is_uniform); @@ -1460,10 +1459,11 @@ BatchedBackendLLVM::llvm_broadcast_uniform_value_from_mem( // Load the uniform component from the temporary // base passing false for op_is_uniform, the llvm_load_value will // automatically broadcast the uniform value to a vector type - llvm::Value* wide_component_value = llvm_load_value( - pointerTotempUniform, dest_type, derivIndex, - llvm_array_index, componentIndex, true /*src_is_uniform*/, - TypeDesc::UNKNOWN, false /*op_is_uniform*/); + llvm::Value* wide_component_value + = llvm_load_value(pointerTotempUniform, dest_type, + derivIndex, llvm_array_index, + componentIndex, true /*src_is_uniform*/, + TypeUnknown, false /*op_is_uniform*/); bool success = llvm_store_value(wide_component_value, Destination, derivIndex, llvm_array_index, @@ -1556,7 +1556,7 @@ BatchedBackendLLVM::groupdata_field_ptr(int fieldnum, TypeDesc type, bool is_uniform, bool forceBool) { llvm::Value* result = ll.void_ptr(groupdata_field_ref(fieldnum)); - if (type != TypeDesc::UNKNOWN) { + if (type != TypeUnknown) { if (is_uniform) { result = ll.ptr_to_cast(result, forceBool ? ll.type_bool() : llvm_type(type)); @@ -1713,9 +1713,10 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name, int numDeriv = s.has_derivs() ? 3 : 1; for (int d = 0; d < numDeriv; ++d) { for (int c = 0; c < t.simpletype().aggregate; ++c) { - llvm::Value* wide_value = llvm_load_value( - s, /*deriv=*/d, /*component*/ c, - TypeDesc::UNKNOWN, function_is_uniform); + llvm::Value* wide_value + = 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); @@ -1748,7 +1749,7 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name, auto disable_masked_stores = ll.create_masking_scope(false); for (int a = 0; a < t.simpletype().aggregate; ++a) { llvm::Value* wide_constant_value - = llvm_load_constant_value(s, 0, a, TypeDesc::UNKNOWN, + = llvm_load_constant_value(s, 0, a, TypeUnknown, function_is_uniform); // Store our wide pointer on the stack llvm_store_value(wide_constant_value, tmpptr, t, 0, NULL, a, @@ -1765,8 +1766,7 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name, OSL_DEV_ONLY(std::cout << "....pushing " << s.name().c_str() << " as value" << std::endl); valargs[i] = llvm_load_value(s, /*deriv*/ 0, /*component*/ 0, - TypeDesc::UNKNOWN, - function_is_uniform); + TypeUnknown, function_is_uniform); if (function_is_uniform && t.simpletype() == TypeDesc::STRING) { // We are going to be calling a function from the scalar version // of the OSL library. The scalar version has @@ -1860,7 +1860,7 @@ BatchedBackendLLVM::llvm_test_nonzero(const Symbol& val, bool test_derivs) TypeDesc t = ts.simpletype(); // Handle int case -- guaranteed no derivs, no multi-component - if (t == TypeDesc::TypeInt) { + if (t == TypeInt) { // Because we allow temporaries and local results of comparison operations // to use the native bool type of i1, we will need to build an matching constant 0 // for comparisons. @@ -1919,8 +1919,7 @@ BatchedBackendLLVM::llvm_assign_impl(const Symbol& Result, const Symbol& Src, if (Result.typespec().is_closure() || Src.typespec().is_closure()) { if (Src.typespec().is_closure()) { llvm::Value* srcval = llvm_load_value(Src, 0, arrind, 0, - TypeDesc::UNKNOWN, - op_is_uniform); + TypeUnknown, op_is_uniform); llvm_store_value(srcval, Result, 0, arrind, 0); } else { llvm::Value* null_value = ll.constant_ptr(NULL, ll.type_void_ptr()); @@ -2038,8 +2037,7 @@ BatchedBackendLLVM::llvm_assign_impl(const Symbol& Result, const Symbol& Src, // src and result both have derivs -- copy them // allow a uniform Src to store to a varying Result, val = llvm_load_value(Src, d, arrind, i, - TypeDesc::UNKNOWN, - op_is_uniform); + TypeUnknown, op_is_uniform); } llvm_store_value(val, Result, d, arrind, i); } @@ -2049,7 +2047,7 @@ BatchedBackendLLVM::llvm_assign_impl(const Symbol& Result, const Symbol& Src, // src and result both have derivs -- copy them // allow a uniform Src to store to a varying Result, val = llvm_load_value(Src, d, arrind, srccomp, - TypeDesc::UNKNOWN, op_is_uniform); + TypeUnknown, op_is_uniform); } if (dstcomp == -1) { @@ -2093,13 +2091,13 @@ BatchedBackendLLVM::append_arg_to(llvm::raw_svector_ostream& OS, const TypeDesc& td = arg.type(); const char* name = nullptr; - if (td == TypeDesc::TypeInt) + if (td == TypeInt) name = "i"; - else if (td == TypeDesc::TypeMatrix) + else if (td == TypeMatrix) name = "m"; - else if (td == TypeDesc::TypeString) + else if (td == TypeString) name = "s"; - else if (td == TypeDesc::TypeFloat) + else if (td == TypeFloat) name = arg.has_derivs() ? "df" : "f"; else if (td.aggregate == 3 && td.basetype == TypeDesc::FLOAT && td.arraylen == 0) diff --git a/src/liboslexec/batched_llvm_gen.cpp b/src/liboslexec/batched_llvm_gen.cpp index 5e61785ed..dacf4f0ba 100644 --- a/src/liboslexec/batched_llvm_gen.cpp +++ b/src/liboslexec/batched_llvm_gen.cpp @@ -598,7 +598,7 @@ LLVMGEN(llvm_gen_aref) bool index_is_uniform = Index.is_uniform(); // Get array index we're interested in - llvm::Value* index = rop.loadLLVMValue(Index, 0, 0, TypeDesc::TypeInt, + llvm::Value* index = rop.loadLLVMValue(Index, 0, 0, TypeInt, index_is_uniform); if (!index) return false; @@ -681,7 +681,7 @@ LLVMGEN(llvm_gen_aassign) OSL_ASSERT(index_is_uniform || !resultIsUniform); // Get array index we're interested in - llvm::Value* index = rop.loadLLVMValue(Index, 0, 0, TypeDesc::TypeInt, + llvm::Value* index = rop.loadLLVMValue(Index, 0, 0, TypeInt, index_is_uniform); if (!index) @@ -1017,11 +1017,9 @@ LLVMGEN(llvm_gen_andor) bool result_is_uniform = result.is_uniform(); - llvm::Value* i1_res = NULL; - llvm::Value* a_val = rop.llvm_load_value(a, 0, 0, TypeDesc::TypeInt, - op_is_uniform); - llvm::Value* b_val = rop.llvm_load_value(b, 0, 0, TypeDesc::TypeInt, - op_is_uniform); + llvm::Value* i1_res = NULL; + llvm::Value* a_val = rop.llvm_load_value(a, 0, 0, TypeInt, op_is_uniform); + llvm::Value* b_val = rop.llvm_load_value(b, 0, 0, TypeInt, op_is_uniform); llvm::Value* zero_set = op_is_uniform ? rop.ll.constant(0) : rop.ll.wide_constant(0); @@ -2115,7 +2113,7 @@ LLVMGEN(llvm_gen_bitwise_binary_op) bool op_is_uniform = A.is_uniform() && B.is_uniform(); bool result_is_uniform = Result.is_uniform(); - TypeDesc type = TypeDesc::TypeInt; + TypeDesc type = TypeInt; bool is_logical_op = op.opname() == op_bitand || op.opname() == op_bitor || op.opname() == op_xor; if (is_logical_op) { @@ -2437,8 +2435,7 @@ LLVMGEN(llvm_gen_compassign) } for (int d = 0; d < 3; ++d) { // deriv - llvm::Value* val = rop.llvm_load_value(Val, d, 0, - TypeDesc::TypeFloat, + llvm::Value* val = rop.llvm_load_value(Val, d, 0, TypeFloat, op_is_uniform); if (Index.is_constant()) { int i = Index.get_int(); @@ -2497,8 +2494,7 @@ LLVMGEN(llvm_gen_compassign) for (int d = 0; d < 3; ++d) { // deriv - llvm::Value* val = rop.llvm_load_value(Val, d, 0, - TypeDesc::TypeFloat, + llvm::Value* val = rop.llvm_load_value(Val, d, 0, TypeFloat, op_is_uniform); llvm::Value* valc0 = rop.llvm_load_value(Result, d, 0, @@ -2613,8 +2609,7 @@ LLVMGEN(llvm_gen_mxcompref) int r = Imath::clamp(Row.get_int(), 0, 3); int c = Imath::clamp(Col.get_int(), 0, 3); int comp = 4 * r + c; - val = rop.llvm_load_value(M, 0, comp, TypeDesc::TypeFloat, - op_is_uniform); + val = rop.llvm_load_value(M, 0, comp, TypeFloat, op_is_uniform); } else { llvm::Value* comp = rop.ll.op_mul(row, components_are_uniform ? rop.ll.constant(4) @@ -2712,8 +2707,7 @@ LLVMGEN(llvm_gen_mxcompassign) } } - llvm::Value* val = rop.llvm_load_value(Val, 0, 0, TypeDesc::TypeFloat, - op_is_uniform); + llvm::Value* val = rop.llvm_load_value(Val, 0, 0, TypeFloat, op_is_uniform); if (Row.is_constant() && Col.is_constant()) { int r = Imath::clamp(Row.get_int(), 0, 3); @@ -2770,9 +2764,8 @@ LLVMGEN(llvm_gen_construct_color) for (int d = 0; d < dmax; ++d) { // loop over derivs for (int c = 0; c < 3; ++c) { // loop over components const Symbol& comp = *rop.opargsym(op, c + 1 + using_space); - llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, - TypeDesc::TypeFloat, - result_is_uniform); + llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, TypeFloat, + result_is_uniform); rop.llvm_store_value(val, Result, d, NULL, c); } } @@ -3248,9 +3241,8 @@ LLVMGEN(llvm_gen_construct_triple) for (int d = 0; d < dmax; ++d) { // loop over derivs for (int c = 0; c < 3; ++c) { // loop over components const Symbol& comp = *rop.opargsym(op, c + 1 + using_space); - llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, - TypeDesc::TypeFloat, - op_is_uniform); + llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, TypeFloat, + op_is_uniform); if (op_is_uniform && !resultIsUniform) { rop.llvm_broadcast_uniform_value(val, Result, d, c); @@ -3313,9 +3305,9 @@ LLVMGEN(llvm_gen_construct_triple) // Dynamically build function name FuncSpec func_spec("build_transform_matrix"); - func_spec.arg_varying(TypeDesc::TypeMatrix); + func_spec.arg_varying(TypeMatrix); func_spec.arg(Space, false /*derivs*/, space_is_uniform); - func_spec.arg_uniform(TypeDesc::TypeString); + func_spec.arg_uniform(TypeString); func_spec.mask(); succeeded_as_int = rop.ll.call_function(rop.build_name(func_spec), @@ -3337,7 +3329,7 @@ LLVMGEN(llvm_gen_construct_triple) FuncSpec func_spec(transform_name); func_spec.arg(Result, Result.has_derivs(), resultIsUniform); func_spec.arg(Result, Result.has_derivs(), resultIsUniform); - func_spec.arg_varying(TypeDesc::TypeMatrix44); + func_spec.arg_varying(TypeMatrix); func_spec.mask(); rop.ll.call_function(rop.build_name(func_spec), args); @@ -3594,7 +3586,7 @@ LLVMGEN(llvm_gen_transform) rop.ll.mask_as_int(rop.ll.current_mask()) }; FuncSpec func_spec("build_transform_matrix"); - func_spec.arg_varying(TypeDesc::TypeMatrix44); + func_spec.arg_varying(TypeMatrix); // Ignore derivatives if unneeded or unsupplied func_spec.arg(*From, from_is_uniform); func_spec.arg(*To, to_is_uniform); @@ -3624,7 +3616,7 @@ LLVMGEN(llvm_gen_transform) // The matrix is always varying if we looked it up, // if it was passed directly in "To", then we respect to's uniformity // otherwise it will be the varying result of the callback to the renderer - func_spec.arg(TypeDesc::TypeMatrix44, + func_spec.arg(TypeMatrix, To->typespec().is_matrix() ? to_is_uniform : false); func_spec.arg(*Result, has_derivs, result_is_uniform); @@ -3649,7 +3641,7 @@ LLVMGEN(llvm_gen_transform) // The matrix is always varying if we looked it up, // if it was passed directly in "To", then we respect to's uniformity // otherwise it will be the varying result of the callback to the renderer - func_spec.arg(TypeDesc::TypeMatrix44, + func_spec.arg(TypeMatrix, To->typespec().is_matrix() ? to_is_uniform : false); func_spec.mask(); @@ -4511,8 +4503,7 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum, continue; } - if (name == Strings::missingcolor - && equivalent(valtype, TypeDesc::TypeColor)) { + if (name == Strings::missingcolor && equivalent(valtype, TypeColor)) { if (!missingcolor_buffer) { // If not already done, allocate enough storage for the // missingcolor value (4 floats), and call the special @@ -4851,8 +4842,7 @@ llvm_batched_texture_varying_options(BatchedBackendLLVM& rop, int opnum, PARAM_VARYING_STRING_CODE(interp, osl_texture_decode_interpmode, interpmode) - if (name == Strings::missingcolor - && equivalent(valtype, TypeDesc::TypeColor)) { + if (name == Strings::missingcolor && equivalent(valtype, TypeColor)) { OSL_ASSERT(missingcolor_buffer != nullptr); int num_components = valtype.aggregate; @@ -5852,7 +5842,7 @@ llvm_batched_noise_options(BatchedBackendLLVM& rop, int opnum, } rop.ll.call_function("osl_noiseparams_set_bandwidth", opt, rop.llvm_load_value(Val, 0, NULL, 0, - TypeDesc::TypeFloat)); + TypeFloat)); } else if (name == Strings::impulses && (Val.typespec().is_float() || Val.typespec().is_int())) { if (!Val.is_uniform()) { @@ -5861,7 +5851,7 @@ llvm_batched_noise_options(BatchedBackendLLVM& rop, int opnum, } rop.ll.call_function("osl_noiseparams_set_impulses", opt, rop.llvm_load_value(Val, 0, NULL, 0, - TypeDesc::TypeFloat)); + TypeFloat)); } else { rop.shadingcontext()->errorfmt( "Unknown {} optional argument: \"{}\", <{}> ({}:{})", @@ -5941,7 +5931,7 @@ llvm_batched_noise_varying_options(BatchedBackendLLVM& rop, int opnum, llvm::Value* wide_bandwidth = rop.llvm_load_value(Val, /*deriv=*/0, /*component=*/0, - /*cast=*/TypeDesc::TypeFloat, + /*cast=*/TypeFloat, /*op_is_uniform=*/false); llvm::Value* scalar_bandwidth = rop.ll.op_extract(wide_bandwidth, leadLane); @@ -5956,7 +5946,7 @@ llvm_batched_noise_varying_options(BatchedBackendLLVM& rop, int opnum, llvm::Value* wide_impulses = rop.llvm_load_value(Val, /*deriv=*/0, /*component=*/0, - /*cast=*/TypeDesc::TypeFloat, + /*cast=*/TypeFloat, /*op_is_uniform=*/false); llvm::Value* scalar_impulses = rop.ll.op_extract(wide_impulses, leadLane); diff --git a/src/liboslexec/batched_llvm_instance.cpp b/src/liboslexec/batched_llvm_instance.cpp index 7cc5e2f0d..8e6ff0a76 100644 --- a/src/liboslexec/batched_llvm_instance.cpp +++ b/src/liboslexec/batched_llvm_instance.cpp @@ -1193,7 +1193,7 @@ BatchedBackendLLVM::llvm_assign_initial_value( ll.constant(ncomps), ll.constant("") }; ll.call_function(build_name(FuncSpec("naninf_check_offset") - .arg_uniform(TypeDesc::TypeInt) + .arg_uniform(TypeInt) .mask()), args); } @@ -1455,7 +1455,7 @@ BatchedBackendLLVM::llvm_generate_debugnan(const Opcode& op) ncheck, ll.constant(op.opname()) }; ll.call_function(build_name(FuncSpec("naninf_check_offset") - .arg_varying(TypeDesc::TypeInt) + .arg_varying(TypeInt) .mask()), args); @@ -1485,7 +1485,7 @@ BatchedBackendLLVM::llvm_generate_debugnan(const Opcode& op) ncheck, ll.constant(op.opname()) }; ll.call_function(build_name(FuncSpec("naninf_check_offset") - .arg_uniform(TypeDesc::TypeInt) + .arg_uniform(TypeInt) .mask()), args); } @@ -1629,14 +1629,14 @@ BatchedBackendLLVM::llvm_generate_debug_uninit(const Opcode& op) ll.call_function(build_name( FuncSpec("uninit_check_values_offset") .arg_uniform(TypeDesc::PTR) - .arg_varying(TypeDesc::TypeInt) + .arg_varying(TypeInt) .mask()), args); } else { ll.call_function(build_name( FuncSpec("uninit_check_values_offset") .arg_varying(TypeDesc::PTR) - .arg_varying(TypeDesc::TypeInt) + .arg_varying(TypeInt) .mask()), args); } @@ -1661,7 +1661,7 @@ BatchedBackendLLVM::llvm_generate_debug_uninit(const Opcode& op) ll.call_function(build_name( FuncSpec("uninit_check_values_offset") .arg_uniform(TypeDesc::PTR) - .arg_uniform(TypeDesc::TypeInt)), + .arg_uniform(TypeInt)), args); } else { llvm::Value* args[] @@ -1684,7 +1684,7 @@ BatchedBackendLLVM::llvm_generate_debug_uninit(const Opcode& op) ll.call_function(build_name( FuncSpec("uninit_check_values_offset") .arg_varying(TypeDesc::PTR) - .arg_uniform(TypeDesc::TypeInt) + .arg_uniform(TypeInt) .mask()), args); } @@ -2099,10 +2099,9 @@ BatchedBackendLLVM::build_llvm_instance(bool groupentry) ll.constant(0), ll.constant(ncomps), ll.constant("") }; - ll.call_function(build_name( - FuncSpec("naninf_check_offset") - .arg_uniform(TypeDesc::TypeInt) - .mask()), + ll.call_function(build_name(FuncSpec("naninf_check_offset") + .arg_uniform(TypeInt) + .mask()), args); } } diff --git a/src/liboslexec/closure.cpp b/src/liboslexec/closure.cpp index e511ae218..8f27d4333 100644 --- a/src/liboslexec/closure.cpp +++ b/src/liboslexec/closure.cpp @@ -43,17 +43,17 @@ print_component_value(std::ostream& out, ShadingSystemImpl* ss, TypeDesc type, const void* data, bool treat_ustrings_as_hash) { - if (type == TypeDesc::TypeInt) + if (type == TypeInt) out << *(int*)data; - else if (type == TypeDesc::TypeFloat) + else if (type == TypeFloat) out << *(float*)data; - else if (type == TypeDesc::TypeColor) + else if (type == TypeColor) out << "(" << ((Color3*)data)->x << ", " << ((Color3*)data)->y << ", " << ((Color3*)data)->z << ")"; - else if (type == TypeDesc::TypeVector) + else if (type == TypeVector) out << "(" << ((Vec3*)data)->x << ", " << ((Vec3*)data)->y << ", " << ((Vec3*)data)->z << ")"; - else if (type == TypeDesc::TypeString) { + else if (type == TypeString) { if (treat_ustrings_as_hash == true) { out << "\"" << *((ustringhash*)data) << "\""; } else { diff --git a/src/liboslexec/constfold.cpp b/src/liboslexec/constfold.cpp index d8e218c09..03742ef65 100644 --- a/src/liboslexec/constfold.cpp +++ b/src/liboslexec/constfold.cpp @@ -291,7 +291,7 @@ DECLFOLDER(constfold_dot) if (A.is_constant() && B.is_constant()) { OSL_DASSERT(A.typespec().is_triple() && B.typespec().is_triple()); float result = A.get_vec3().dot(B.get_vec3()); - int cind = rop.add_constant(TypeDesc::TypeFloat, &result); + int cind = rop.add_constant(TypeFloat, &result); rop.turn_into_assign(op, cind, "dot(const,const)"); return 1; } @@ -376,8 +376,7 @@ DECLFOLDER(constfold_eq) } // Turn the 'eq R A B' into 'assign R X' where X is 0 or 1. static const int int_zero = 0, int_one = 1; - int cind = rop.add_constant(TypeDesc::TypeInt, - val ? &int_one : &int_zero); + int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero); rop.turn_into_assign(op, cind, "const == const"); return 1; } @@ -404,8 +403,7 @@ DECLFOLDER(constfold_neq) } // Turn the 'neq R A B' into 'assign R X' where X is 0 or 1. static const int int_zero = 0, int_one = 1; - int cind = rop.add_constant(TypeDesc::TypeInt, - val ? &int_one : &int_zero); + int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero); rop.turn_into_assign(op, cind, "const != const"); return 1; } @@ -436,8 +434,7 @@ DECLFOLDER(constfold_lt) } else { return 0; // unhandled case } - int cind = rop.add_constant(TypeDesc::TypeInt, - val ? &int_one : &int_zero); + int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero); rop.turn_into_assign(op, cind, "const < const"); return 1; } @@ -468,8 +465,7 @@ DECLFOLDER(constfold_le) } else { return 0; // unhandled case } - int cind = rop.add_constant(TypeDesc::TypeInt, - val ? &int_one : &int_zero); + int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero); rop.turn_into_assign(op, cind, "const <= const"); return 1; } @@ -500,8 +496,7 @@ DECLFOLDER(constfold_gt) } else { return 0; // unhandled case } - int cind = rop.add_constant(TypeDesc::TypeInt, - val ? &int_one : &int_zero); + int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero); rop.turn_into_assign(op, cind, "const > const"); return 1; } @@ -532,8 +527,7 @@ DECLFOLDER(constfold_ge) } else { return 0; // unhandled case } - int cind = rop.add_constant(TypeDesc::TypeInt, - val ? &int_one : &int_zero); + int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero); rop.turn_into_assign(op, cind, "const >= const"); return 1; } @@ -552,8 +546,7 @@ DECLFOLDER(constfold_or) bool val = A.get_int() || B.get_int(); // Turn the 'or R A B' into 'assign R X' where X is 0 or 1. static const int int_zero = 0, int_one = 1; - int cind = rop.add_constant(TypeDesc::TypeInt, - val ? &int_one : &int_zero); + int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero); rop.turn_into_assign(op, cind, "const || const"); return 1; } @@ -572,8 +565,7 @@ DECLFOLDER(constfold_and) OSL_DASSERT(A.typespec().is_int() && B.typespec().is_int()); bool val = A.get_int() && B.get_int(); static const int int_zero = 0, int_one = 1; - int cind = rop.add_constant(TypeDesc::TypeInt, - val ? &int_one : &int_zero); + int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero); rop.turn_into_assign(op, cind, "const && const"); return 1; } @@ -1300,7 +1292,7 @@ DECLFOLDER(constfold_concat) } // If we made it this far, all args were constants, and the // concatenation is in result. - int cind = rop.add_constant(TypeDesc::TypeString, &result); + int cind = rop.add_constant(TypeString, &result); rop.turn_into_assign(op, cind, "const fold concat"); return 1; } @@ -1604,7 +1596,7 @@ DECLFOLDER(constfold_mix) if (B.connected()) { // Add the test and conditional for X==0, in which case we can // just R=A and not have to access B - int cond = rop.add_temp(TypeDesc::TypeInt); + int cond = rop.add_temp(TypeInt); int fzero = rop.add_constant(0.0f); rop.insert_code(opnum++, u_eq, RuntimeOptimizer::GroupWithNext, cond, Xind, fzero); @@ -1621,7 +1613,7 @@ DECLFOLDER(constfold_mix) if (A.connected()) { // Add the test and conditional for X==1, in which case we can // just R=B and not have to access A - int cond = rop.add_temp(TypeDesc::TypeInt); + int cond = rop.add_temp(TypeInt); int fone = rop.add_constant(1.0f); rop.insert_code(opnum++, u_eq, RuntimeOptimizer::GroupWithNext, cond, Xind, fone); @@ -2043,7 +2035,7 @@ DECLFOLDER(constfold_matrix) // turn it into a constant rather than calling getmatrix at // execution time. Matrix44 Mresult = Mfrom * Mto; - int cind = rop.add_constant(TypeDesc::TypeMatrix, &Mresult); + int cind = rop.add_constant(TypeMatrix, &Mresult); rop.turn_into_assign(op, cind, "const fold matrix"); return 1; } @@ -2079,7 +2071,7 @@ DECLFOLDER(constfold_matrix) } } if (all_const) { - rop.turn_into_assign(op, rop.add_constant(TypeDesc::TypeMatrix, M), + rop.turn_into_assign(op, rop.add_constant(TypeMatrix, M), "const fold matrix"); return 1; } @@ -2142,14 +2134,14 @@ DECLFOLDER(constfold_getmatrix) rop.inst()->args()[op.firstarg() + 0] = dataarg; // Now turn it into an assignment Matrix44 Mresult = Mfrom * Mto; - int cind = rop.add_constant(TypeDesc::TypeMatrix, &Mresult); + int cind = rop.add_constant(TypeMatrix, &Mresult); rop.turn_into_assign(op, cind, "getmatrix of known matrix"); // Now insert a new instruction that assigns 1 to the // original return result of getmatrix. const int one = 1; const int args_to_add[] = { resultarg, - rop.add_constant(TypeDesc::TypeInt, &one) }; + rop.add_constant(TypeInt, &one) }; rop.insert_code(opnum, u_assign, args_to_add, RuntimeOptimizer::RecomputeRWRanges, RuntimeOptimizer::GroupWithNext); @@ -2316,22 +2308,19 @@ DECLFOLDER(constfold_getattribute) bool found = false; // Check global things first - if (attr_name == "osl:version" && attr_type == TypeDesc::TypeInt) { + if (attr_name == "osl:version" && attr_type == TypeInt) { int* val = (int*)(char*)buf; *val = OSL_VERSION; found = true; - } else if (attr_name == "shader:shadername" - && attr_type == TypeDesc::TypeString) { + } else if (attr_name == "shader:shadername" && attr_type == TypeString) { ustring* up = (ustring*)(char*)buf; *up = ustring(rop.inst()->shadername()); found = true; - } else if (attr_name == "shader:layername" - && attr_type == TypeDesc::TypeString) { + } else if (attr_name == "shader:layername" && attr_type == TypeString) { ustring* up = (ustring*)(char*)buf; *up = rop.inst()->layername(); found = true; - } else if (attr_name == "shader:groupname" - && attr_type == TypeDesc::TypeString) { + } else if (attr_name == "shader:groupname" && attr_type == TypeString) { ustring* up = (ustring*)(char*)buf; *up = rop.group().name(); found = true; @@ -2374,7 +2363,7 @@ DECLFOLDER(constfold_getattribute) // original return result of getattribute. const int one = 1; const int args_to_add[] = { oldresultarg, - rop.add_constant(TypeDesc::TypeInt, &one) }; + rop.add_constant(TypeInt, &one) }; rop.insert_code(opnum, u_assign, args_to_add, RuntimeOptimizer::RecomputeRWRanges, RuntimeOptimizer::GroupWithNext); @@ -2445,9 +2434,9 @@ DECLFOLDER(constfold_gettextureinfo) // Now insert a new instruction that assigns 1 to the // original return result of gettextureinfo. - int one = 1; - const int args_to_add[] - = { oldresultarg, rop.add_constant(TypeDesc::TypeInt, &one) }; + int one = 1; + const int args_to_add[] = { oldresultarg, + rop.add_constant(TypeInt, &one) }; rop.insert_code(opnum, u_assign, args_to_add, RuntimeOptimizer::RecomputeRWRanges, RuntimeOptimizer::GroupWithNext); @@ -2594,7 +2583,7 @@ DECLFOLDER(constfold_texture) // Just turn the param name into empty string and it will // be skipped. ustring empty; - int cind = rop.add_constant(TypeDesc::TypeString, &empty); + int cind = rop.add_constant(TypeString, &empty); rop.inst()->args()[op.firstarg() + i] = cind; rop.inst()->args()[op.firstarg() + i + 1] = cind; any_elided = true; @@ -2746,8 +2735,7 @@ DECLFOLDER(constfold_pointcloud_search) // Query results all copied. The only thing left to do is to assign // status (query result count) to the original "result". - const int args_to_add[] = { result_sym, - rop.add_constant(TypeDesc::TypeInt, &count) }; + const int args_to_add[] = { result_sym, rop.add_constant(TypeInt, &count) }; rop.insert_code(opnum, u_assign, args_to_add, RuntimeOptimizer::RecomputeRWRanges, RuntimeOptimizer::GroupWithNext); @@ -2796,7 +2784,7 @@ DECLFOLDER(constfold_pointcloud_get) &data[0]); rop.shadingsys().pointcloud_stats(0, 1, 0); - rop.turn_into_assign(op, rop.add_constant(TypeDesc::TypeInt, &ok), + rop.turn_into_assign(op, rop.add_constant(TypeInt, &ok), "Folded constant pointcloud_get"); // Now make a constant array for those results we just retrieved... @@ -2921,7 +2909,7 @@ DECLFOLDER(constfold_noise) cell(n, Vec3(input[0], input[1], input[2])); else cell(n, Vec3(input[0], input[1], input[2]), input[3]); - int cind = rop.add_constant(TypeDesc::TypePoint, &n); + int cind = rop.add_constant(TypePoint, &n); rop.turn_into_assign(op, cind, "const fold cellnoise"); return 1; } diff --git a/src/liboslexec/llvm_gen.cpp b/src/liboslexec/llvm_gen.cpp index ba7e60aa3..d3a258fd7 100644 --- a/src/liboslexec/llvm_gen.cpp +++ b/src/liboslexec/llvm_gen.cpp @@ -1558,7 +1558,7 @@ LLVMGEN(llvm_gen_compassign) } for (int d = 0; d < 3; ++d) { // deriv - llvm::Value* val = rop.llvm_load_value(Val, d, 0, TypeDesc::TypeFloat); + llvm::Value* val = rop.llvm_load_value(Val, d, 0, TypeFloat); if (Index.is_constant()) { int i = Index.get_int(); i = Imath::clamp(i, 0, 2); @@ -1669,7 +1669,7 @@ LLVMGEN(llvm_gen_mxcompassign) } } - llvm::Value* val = rop.llvm_load_value(Val, 0, 0, TypeDesc::TypeFloat); + llvm::Value* val = rop.llvm_load_value(Val, 0, 0, TypeFloat); if (Row.is_constant() && Col.is_constant()) { int r = Imath::clamp(Row.get_int(), 0, 3); @@ -1829,8 +1829,7 @@ LLVMGEN(llvm_gen_construct_color) for (int d = 0; d < dmax; ++d) { // loop over derivs for (int c = 0; c < 3; ++c) { // loop over components const Symbol& comp = *rop.opargsym(op, c + 1 + using_space); - llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, - TypeDesc::TypeFloat); + llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, TypeFloat); rop.llvm_store_value(val, Result, d, NULL, c); } } @@ -1875,8 +1874,7 @@ LLVMGEN(llvm_gen_construct_triple) for (int d = 0; d < dmax; ++d) { // loop over derivs for (int c = 0; c < 3; ++c) { // loop over components const Symbol& comp = *rop.opargsym(op, c + 1 + using_space); - llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, - TypeDesc::TypeFloat); + llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, TypeFloat); rop.llvm_store_value(val, Result, d, NULL, c); } } @@ -2438,8 +2436,8 @@ LLVMGEN(llvm_gen_andor) Symbol& b = *rop.opargsym(op, 2); llvm::Value* i1_res = NULL; - llvm::Value* a_val = rop.llvm_load_value(a, 0, 0, TypeDesc::TypeInt); - llvm::Value* b_val = rop.llvm_load_value(b, 0, 0, TypeDesc::TypeInt); + llvm::Value* a_val = rop.llvm_load_value(a, 0, 0, TypeInt); + llvm::Value* b_val = rop.llvm_load_value(b, 0, 0, TypeInt); if (op.opname() == op_and) { // From the old bitcode generated // define i32 @osl_and_iii(i32 %a, i32 %b) nounwind readnone ssp { @@ -2719,8 +2717,7 @@ llvm_gen_texture_options(BackendLLVM& rop, int opnum, int first_optional_arg, errormessage = rop.llvm_get_pointer(Val); continue; } - if (name == Strings::missingcolor - && equivalent(valtype, TypeDesc::TypeColor)) { + if (name == Strings::missingcolor && equivalent(valtype, TypeColor)) { if (!missingcolor) { // If not already done, allocate enough storage for the // missingcolor value (4 floats), and call the special @@ -3089,12 +3086,12 @@ llvm_gen_noise_options(BackendLLVM& rop, int opnum, int first_optional_arg) && (Val.typespec().is_float() || Val.typespec().is_int())) { rop.ll.call_function("osl_noiseparams_set_bandwidth", opt, rop.llvm_load_value(Val, 0, NULL, 0, - TypeDesc::TypeFloat)); + TypeFloat)); } else if (name == Strings::impulses && (Val.typespec().is_float() || Val.typespec().is_int())) { rop.ll.call_function("osl_noiseparams_set_impulses", opt, rop.llvm_load_value(Val, 0, NULL, 0, - TypeDesc::TypeFloat)); + TypeFloat)); } else { rop.shadingcontext()->errorfmt( "Unknown {} optional argument: \"{}\", <{}> ({}:{})", diff --git a/src/liboslexec/loadshader.cpp b/src/liboslexec/loadshader.cpp index 0698826a0..4c274735f 100644 --- a/src/liboslexec/loadshader.cpp +++ b/src/liboslexec/loadshader.cpp @@ -417,21 +417,21 @@ OSOReaderToMaster::hint(string_view hintstring) if (m_master->m_symbols.size()) { // metadata is attached to a particular symbol Symbol& sym(m_master->m_symbols.back()); - if (type == TypeDesc::TypeInt && ident == "lockgeom" + if (type == TypeInt && ident == "lockgeom" && Strutil::parse_int(h, ival) && ival >= 0) sym.interpolated(!ival); // soft deprecated - else if (type == TypeDesc::TypeInt && ident == "interpolated" + else if (type == TypeInt && ident == "interpolated" && Strutil::parse_int(h, ival) && ival >= 0) sym.interpolated(ival); - else if (type == TypeDesc::TypeInt && ident == "interactive" + else if (type == TypeInt && ident == "interactive" && Strutil::parse_int(h, ival) && ival >= 0) sym.interactive(ival); - else if (type == TypeDesc::TypeInt && ident == "allowconnect" + else if (type == TypeInt && ident == "allowconnect" && Strutil::parse_int(h, ival) && ival >= 0) sym.allowconnect(ival); } else { // metadata is attached at the shader level - if (type == TypeDesc::TypeInt && ident == "range_checking" + if (type == TypeInt && ident == "range_checking" && Strutil::parse_int(h, ival) && ival >= 0) m_master->range_checking(ival != 0); } diff --git a/src/liboslexec/osogram.y b/src/liboslexec/osogram.y index b640238aa..d474ccd7b 100644 --- a/src/liboslexec/osogram.y +++ b/src/liboslexec/osogram.y @@ -330,14 +330,14 @@ inline TypeDesc OSL::pvt::osolextype (int lex) { switch (lex) { - case COLORTYPE : return TypeDesc::TypeColor; - case FLOATTYPE : return TypeDesc::TypeFloat; - case INTTYPE : return TypeDesc::TypeInt; - case MATRIXTYPE : return TypeDesc::TypeMatrix; - case NORMALTYPE : return TypeDesc::TypeNormal; - case POINTTYPE : return TypeDesc::TypePoint; - case STRINGTYPE : return TypeDesc::TypeString; - case VECTORTYPE : return TypeDesc::TypeVector; + case COLORTYPE : return TypeColor; + case FLOATTYPE : return TypeFloat; + case INTTYPE : return TypeInt; + case MATRIXTYPE : return TypeMatrix; + case NORMALTYPE : return TypeNormal; + case POINTTYPE : return TypePoint; + case STRINGTYPE : return TypeString; + case VECTORTYPE : return TypeVector; case VOIDTYPE : return TypeDesc::NONE; default: return TypeDesc::UNKNOWN; } diff --git a/src/liboslexec/pointcloud.h b/src/liboslexec/pointcloud.h index 474e92c69..7dcfcfe04 100644 --- a/src/liboslexec/pointcloud.h +++ b/src/liboslexec/pointcloud.h @@ -72,13 +72,13 @@ struct SortedPointCompare { inline Partio::ParticleAttributeType PartioType(TypeDesc t) { - if (t == TypeDesc::TypeFloat) + if (t == TypeFloat) return Partio::FLOAT; if (t.basetype == TypeDesc::FLOAT && t.aggregate == TypeDesc::VEC3) return Partio::VECTOR; - if (t == TypeDesc::TypeInt) + if (t == TypeInt) return Partio::INT; - if (t == TypeDesc::TypeString) + if (t == TypeString) return Partio::INDEXEDSTR; return Partio::NONE; } diff --git a/src/liboslexec/runtimeoptimize.cpp b/src/liboslexec/runtimeoptimize.cpp index d5032f131..7baf6ba34 100644 --- a/src/liboslexec/runtimeoptimize.cpp +++ b/src/liboslexec/runtimeoptimize.cpp @@ -2498,7 +2498,7 @@ RuntimeOptimizer::resolve_isconnected() upconnected = true; bool downconnected = s->connected_down() || s->renderer_output(); int val = (upconnected ? 1 : 0) + (downconnected ? 2 : 0); - turn_into_assign(op, add_constant(TypeDesc::TypeInt, &val), + turn_into_assign(op, add_constant(TypeInt, &val), "resolve isconnected()"); } } diff --git a/src/liboslexec/runtimeoptimize.h b/src/liboslexec/runtimeoptimize.h index 5442dea58..355b8a482 100644 --- a/src/liboslexec/runtimeoptimize.h +++ b/src/liboslexec/runtimeoptimize.h @@ -86,20 +86,11 @@ class RuntimeOptimizer final : public OSOProcessorBase { /// the datatype is expected to be ustring, not ustringhash int add_constant(const TypeSpec& type, const void* data, TypeDesc datatype = TypeDesc::UNKNOWN); - int add_constant(float c) { return add_constant(TypeDesc::TypeFloat, &c); } - int add_constant(int c) { return add_constant(TypeDesc::TypeInt, &c); } - int add_constant(ustring s) - { - return add_constant(TypeDesc::TypeString, &s); - } - int add_constant(const Matrix44& c) - { - return add_constant(TypeDesc::TypeMatrix, &c); - } - int add_constantc(const Color3& c) - { - return add_constant(TypeDesc::TypeColor, &c); - } + int add_constant(float c) { return add_constant(TypeFloat, &c); } + int add_constant(int c) { return add_constant(TypeInt, &c); } + int add_constant(ustring s) { return add_constant(TypeString, &s); } + int add_constant(const Matrix44& c) { return add_constant(TypeMatrix, &c); } + int add_constantc(const Color3& c) { return add_constant(TypeColor, &c); } int add_constantv(const Vec3& c, const TypeSpec& vectype) { return add_constant(vectype, &c); @@ -107,7 +98,7 @@ class RuntimeOptimizer final : public OSOProcessorBase { int add_constant(string_view s) { ustring u(s); - return add_constant(TypeDesc::TypeString, &s); + return add_constant(TypeString, &s); } /// Create a new temporary variable of the given type, return its index. diff --git a/src/liboslexec/shadingsys.cpp b/src/liboslexec/shadingsys.cpp index ee22895e9..a935a2ab6 100644 --- a/src/liboslexec/shadingsys.cpp +++ b/src/liboslexec/shadingsys.cpp @@ -905,17 +905,17 @@ ShadingSystem::convert_value(void* dst, TypeDesc dsttype, const void* src, tmp_int = *(const unsigned char*)src; src = &tmp_int; } - srctype = TypeDesc::TypeInt; + srctype = TypeInt; } float tmp_float; - if (srctype == TypeDesc::TypeInt && dsttype.basetype == TypeDesc::FLOAT) { + if (srctype == TypeInt && dsttype.basetype == TypeDesc::FLOAT) { // int -> float-based : up-convert the source to float if (src) { tmp_float = (float)(*(const int*)src); src = &tmp_float; } - srctype = TypeDesc::TypeFloat; + srctype = TypeFloat; } // Just copy equivalent types @@ -925,9 +925,9 @@ ShadingSystem::convert_value(void* dst, TypeDesc dsttype, const void* src, return true; } - if (srctype == TypeDesc::TypeFloat) { + if (srctype == TypeFloat) { // float->triple conversion - if (equivalent(dsttype, TypeDesc::TypePoint)) { + if (equivalent(dsttype, TypePoint)) { if (dst && src) { float f = *(const float*)src; ((OSL::Vec3*)dst)->setValue(f, f, f); @@ -935,7 +935,7 @@ ShadingSystem::convert_value(void* dst, TypeDesc dsttype, const void* src, return true; } // float->int - if (dsttype == TypeDesc::TypeInt) { + if (dsttype == TypeInt) { if (dst && src) *(int*)dst = (int)*(const float*)src; return true; @@ -964,26 +964,23 @@ ShadingSystem::convert_value(void* dst, TypeDesc dsttype, const void* src, } // float[3] -> triple - if ((srctype == TypeFloatArray3 && equivalent(dsttype, TypeDesc::TypePoint)) - || (dsttype == TypeFloatArray3 - && equivalent(srctype, TypeDesc::TypePoint))) { + if ((srctype == TypeFloatArray3 && equivalent(dsttype, TypePoint)) + || (dsttype == TypeFloatArray3 && equivalent(srctype, TypePoint))) { if (dst && src) memmove(dst, src, dsttype.size()); return true; } // float[4] -> vec4 - if ((srctype == TypeFloatArray4 && equivalent(dsttype, TypeDesc::TypeFloat4)) - || (dsttype == TypeFloatArray4 - && equivalent(srctype, TypeDesc::TypeFloat4))) { + if ((srctype == TypeFloatArray4 && equivalent(dsttype, TypeFloat4)) + || (dsttype == TypeFloatArray4 && equivalent(srctype, TypeFloat4))) { if (dst && src) memmove(dst, src, dsttype.size()); return true; } // float[2] -> triple - if (srctype == TypeFloatArray2 - && equivalent(dsttype, TypeDesc::TypePoint)) { + if (srctype == TypeFloatArray2 && equivalent(dsttype, TypePoint)) { if (dst && src) { float f0 = ((const float*)src)[0]; float f1 = ((const float*)src)[1]; @@ -2043,11 +2040,11 @@ ShadingSystemImpl::attribute(ShaderGroup* group, string_view name, group->mark_entry_layer(ustring(((const char**)val)[i])); return true; } - if (name == "exec_repeat" && type == TypeDesc::TypeInt) { + if (name == "exec_repeat" && type == TypeInt) { group->m_exec_repeat = *(const int*)val; return true; } - if (name == "groupname" && type == TypeDesc::TypeString) { + if (name == "groupname" && type == TypeString) { group->name(ustring(((const char**)val)[0])); return true; } @@ -2063,11 +2060,11 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, if (!group) return false; - if (name == "groupname" && type == TypeDesc::TypeString) { + if (name == "groupname" && type == TypeString) { *(ustring*)val = group->name(); return true; } - if (name == "num_layers" && type == TypeDesc::TypeInt) { + if (name == "num_layers" && type == TypeInt) { *(int*)val = group->nlayers(); return true; } @@ -2135,7 +2132,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, *(ustring*)val = ustring(group->serialize()); return true; } - if (name == "exec_repeat" && type == TypeDesc::TypeInt) { + if (name == "exec_repeat" && type == TypeInt) { *(int*)val = group->m_exec_repeat; return true; } @@ -2163,7 +2160,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, destroy_thread_info(threadinfo); } - if (name == "num_textures_needed" && type == TypeDesc::TypeInt) { + if (name == "num_textures_needed" && type == TypeInt) { *(int*)val = (int)group->m_textures_needed.size(); return true; } @@ -2172,12 +2169,12 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, *(ustring**)val = n ? &group->m_textures_needed[0] : NULL; return true; } - if (name == "unknown_textures_needed" && type == TypeDesc::TypeInt) { + if (name == "unknown_textures_needed" && type == TypeInt) { *(int*)val = (int)group->m_unknown_textures_needed; return true; } - if (name == "num_closures_needed" && type == TypeDesc::TypeInt) { + if (name == "num_closures_needed" && type == TypeInt) { *(int*)val = (int)group->m_closures_needed.size(); return true; } @@ -2186,12 +2183,12 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, *(ustring**)val = n ? &group->m_closures_needed[0] : NULL; return true; } - if (name == "unknown_closures_needed" && type == TypeDesc::TypeInt) { + if (name == "unknown_closures_needed" && type == TypeInt) { *(int*)val = (int)group->m_unknown_closures_needed; return true; } - if (name == "num_globals_needed" && type == TypeDesc::TypeInt) { + if (name == "num_globals_needed" && type == TypeInt) { *(int*)val = (int)group->m_globals_needed.size(); return true; } @@ -2209,7 +2206,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, return true; } - if (name == "num_userdata" && type == TypeDesc::TypeInt) { + if (name == "num_userdata" && type == TypeInt) { *(int*)val = (int)group->m_userdata_names.size(); return true; } @@ -2233,7 +2230,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, *(char**)val = n ? &group->m_userdata_derivs[0] : NULL; return true; } - if (name == "num_attributes_needed" && type == TypeDesc::TypeInt) { + if (name == "num_attributes_needed" && type == TypeInt) { *(int*)val = (int)group->m_attributes_needed.size(); return true; } @@ -2252,11 +2249,11 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, *(TypeDesc**)val = n ? &group->m_attribute_types[0] : NULL; return true; } - if (name == "unknown_attributes_needed" && type == TypeDesc::TypeInt) { + if (name == "unknown_attributes_needed" && type == TypeInt) { *(int*)val = (int)group->m_unknown_attributes_needed; return true; } - if (name == "group_id" && type == TypeDesc::TypeInt) { + if (name == "group_id" && type == TypeInt) { *(int*)val = (int)group->id(); return true; } @@ -2272,7 +2269,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name, *(void**)val = n ? &group->m_userdata_init_vals[0] : NULL; return true; } - if (name == "llvm_groupdata_size" && type == TypeDesc::TypeInt) { + if (name == "llvm_groupdata_size" && type == TypeInt) { *(int*)val = (int)group->llvm_groupdata_size(); return true; } @@ -3101,21 +3098,21 @@ ShadingSystemImpl::ShaderGroupBegin(string_view groupname, string_view usage, } TypeDesc type; if (typestring == "int") - type = TypeDesc::TypeInt; + type = TypeInt; else if (typestring == "float") - type = TypeDesc::TypeFloat; + type = TypeFloat; else if (typestring == "color") - type = TypeDesc::TypeColor; + type = TypeColor; else if (typestring == "point") - type = TypeDesc::TypePoint; + type = TypePoint; else if (typestring == "vector") - type = TypeDesc::TypeVector; + type = TypeVector; else if (typestring == "normal") - type = TypeDesc::TypeNormal; + type = TypeNormal; else if (typestring == "matrix") - type = TypeDesc::TypeMatrix; + type = TypeMatrix; else if (typestring == "string") - type = TypeDesc::TypeString; + type = TypeString; else { err = true; errdesc = fmtformat("Unknown type: {}", typestring); diff --git a/src/osl.imageio/oslinput.cpp b/src/osl.imageio/oslinput.cpp index b535d45fd..0ca136eb0 100644 --- a/src/osl.imageio/oslinput.cpp +++ b/src/osl.imageio/oslinput.cpp @@ -381,16 +381,16 @@ parse_param(string_view paramname, string_view val, ImageSpec& spec) // Surrounded by quotes? it's a string (strip off the quotes) val.remove_prefix(1); val.remove_suffix(1); - type = TypeDesc::TypeString; + type = TypeString; } else if (Strutil::string_is(val)) { // Looks like an int, is an int - type = TypeDesc::TypeInt; + type = TypeInt; } else if (Strutil::string_is(val)) { // Looks like a float, is a float - type = TypeDesc::TypeFloat; + type = TypeFloat; } else { // Everything else is assumed a string - type = TypeDesc::TypeString; + type = TypeString; } } diff --git a/src/osltoy/osltoyapp.cpp b/src/osltoy/osltoyapp.cpp index 7c4042714..aa47d639f 100644 --- a/src/osltoy/osltoyapp.cpp +++ b/src/osltoy/osltoyapp.cpp @@ -1052,14 +1052,14 @@ OSLToyMainWindow::make_param_adjustment_row(ParamRec* param, auto label_and_adjust_layout = new QHBoxLayout; label_and_adjust->setLayout(label_and_adjust_layout); std::string labeltext; - if (param->type == TypeDesc::TypeColor) + if (param->type == TypeColor) labeltext = string_view(&("RGB"[c]), 1); else labeltext = string_view(&("xyz"[c]), 1); auto channellabel = QtUtils::make_qlabelfmt("{}", labeltext); label_and_adjust_layout->addWidget(channellabel); auto adjustWidget = new QtUtils::DoubleSpinBox(param->fdefault[c]); - if (param->type == TypeDesc::TypeColor) { + if (param->type == TypeColor) { adjustWidget->setRange(0.0, 1.0); } label_and_adjust_layout->addWidget(adjustWidget); diff --git a/src/osltoy/osltoyrenderer.cpp b/src/osltoy/osltoyrenderer.cpp index 26c6ad120..f4584810c 100644 --- a/src/osltoy/osltoyrenderer.cpp +++ b/src/osltoy/osltoyrenderer.cpp @@ -320,7 +320,7 @@ OSLToyRenderer::get_array_attribute(ShaderGlobals* sg, bool derivatives, // In order to test getattribute(), respond positively to // "options"/"blahblah" if (object == RS::Hashes::options && name == RS::Hashes::blahblah - && type == TypeDesc::TypeFloat) { + && type == TypeFloat) { *(float*)val = 3.14159; return true; } @@ -354,7 +354,7 @@ OSLToyRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, // look up something specific to the primitive, rather than have hard- // coded names. - if (name == RS::Hashes::s && type == TypeDesc::TypeFloat) { + if (name == RS::Hashes::s && type == TypeFloat) { ((float*)val)[0] = sg->u; if (derivatives) { ((float*)val)[1] = sg->dudx; @@ -362,7 +362,7 @@ OSLToyRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, } return true; } - if (name == RS::Hashes::t && type == TypeDesc::TypeFloat) { + if (name == RS::Hashes::t && type == TypeFloat) { ((float*)val)[0] = sg->v; if (derivatives) { ((float*)val)[1] = sg->dvdx; @@ -380,7 +380,7 @@ OSLToyRenderer::get_osl_version(ShaderGlobals* /*sg*/, bool /*derivs*/, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeInt) { + if (type == TypeInt) { ((int*)val)[0] = OSL_VERSION; return true; } @@ -407,7 +407,7 @@ OSLToyRenderer::get_camera_projection(ShaderGlobals* /*sg*/, bool /*derivs*/, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeString) { + if (type == TypeString) { ((ustringhash*)val)[0] = m_projection; return true; } @@ -421,7 +421,7 @@ OSLToyRenderer::get_camera_fov(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*name*/, void* val) { // N.B. in a real renderer, this may be time-dependent - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_fov; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -436,7 +436,7 @@ OSLToyRenderer::get_camera_pixelaspect(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_pixelaspect; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -467,7 +467,7 @@ OSLToyRenderer::get_camera_clip_near(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_hither; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -482,7 +482,7 @@ OSLToyRenderer::get_camera_clip_far(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_yon; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -514,7 +514,7 @@ OSLToyRenderer::get_camera_shutter_open(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_shutter[0]; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -529,7 +529,7 @@ OSLToyRenderer::get_camera_shutter_close(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_shutter[1]; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); diff --git a/src/testrender/background.h b/src/testrender/background.h index db4ee61fa..ac196cf27 100644 --- a/src/testrender/background.h +++ b/src/testrender/background.h @@ -58,9 +58,9 @@ struct Background { #if 0 // DEBUG: visualize importance table using namespace OIIO; ImageOutput* out = ImageOutput::create("bg.exr"); - ImageSpec spec(res, res, 3, TypeDesc::TypeFloat); + ImageSpec spec(res, res, 3, TypeFloat); if (out && out->open("bg.exr", spec)) - out->write_image(TypeDesc::TypeFloat, &values[0]); + out->write_image(TypeFloat, &values[0]); delete out; #endif } diff --git a/src/testrender/simpleraytracer.cpp b/src/testrender/simpleraytracer.cpp index 6b3666109..d9ae68063 100644 --- a/src/testrender/simpleraytracer.cpp +++ b/src/testrender/simpleraytracer.cpp @@ -383,28 +383,23 @@ SimpleRaytracer::parse_scene_xml(const std::string& scenefile) float f[3]; string_view val(attr.value()); if (parse_prefix_and_ints(val, "int ", 1, &i)) - shadingsys->Parameter(*group, attr.name(), - TypeDesc::TypeInt, + shadingsys->Parameter(*group, attr.name(), TypeInt, store.Int(i)); else if (parse_prefix_and_floats(val, "float ", 1, f)) shadingsys->Parameter(*group, attr.name(), - TypeDesc::TypeFloat, - store.Float(f[0])); + TypeFloat, store.Float(f[0])); else if (parse_prefix_and_floats(val, "vector ", 3, f)) shadingsys->Parameter(*group, attr.name(), - TypeDesc::TypeVector, - store.Vec(f)); + TypeVector, store.Vec(f)); else if (parse_prefix_and_floats(val, "point ", 3, f)) shadingsys->Parameter(*group, attr.name(), - TypeDesc::TypePoint, - store.Vec(f)); + TypePoint, store.Vec(f)); else if (parse_prefix_and_floats(val, "color ", 3, f)) shadingsys->Parameter(*group, attr.name(), - TypeDesc::TypeColor, - store.Vec(f)); + TypeColor, store.Vec(f)); else shadingsys->Parameter(*group, attr.name(), - TypeDesc::TypeString, + TypeString, store.Str(attr.value())); } } else if (strcmp(gnode.name(), "Shader") == 0) { @@ -609,7 +604,7 @@ SimpleRaytracer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, // look up something specific to the primitive, rather than have hard- // coded names. - if (name == RS::Hashes::s && type == TypeDesc::TypeFloat) { + if (name == RS::Hashes::s && type == TypeFloat) { ((float*)val)[0] = sg->u; if (derivatives) { ((float*)val)[1] = sg->dudx; @@ -617,7 +612,7 @@ SimpleRaytracer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, } return true; } - if (name == RS::Hashes::t && type == TypeDesc::TypeFloat) { + if (name == RS::Hashes::t && type == TypeFloat) { ((float*)val)[0] = sg->v; if (derivatives) { ((float*)val)[1] = sg->dvdx; @@ -635,7 +630,7 @@ SimpleRaytracer::get_osl_version(ShaderGlobals* /*sg*/, bool /*derivs*/, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeInt) { + if (type == TypeInt) { ((int*)val)[0] = OSL_VERSION; return true; } @@ -662,7 +657,7 @@ SimpleRaytracer::get_camera_projection(ShaderGlobals* /*sg*/, bool /*derivs*/, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeString) { + if (type == TypeString) { ((ustringhash*)val)[0] = m_projection; return true; } @@ -676,7 +671,7 @@ SimpleRaytracer::get_camera_fov(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*name*/, void* val) { // N.B. in a real renderer, this may be time-dependent - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_fov; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -691,7 +686,7 @@ SimpleRaytracer::get_camera_pixelaspect(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_pixelaspect; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -722,7 +717,7 @@ SimpleRaytracer::get_camera_clip_near(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_hither; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -737,7 +732,7 @@ SimpleRaytracer::get_camera_clip_far(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_yon; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -769,7 +764,7 @@ SimpleRaytracer::get_camera_shutter_open(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_shutter[0]; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -784,7 +779,7 @@ SimpleRaytracer::get_camera_shutter_close(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_shutter[1]; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); diff --git a/src/testshade/simplerend.cpp b/src/testshade/simplerend.cpp index 1c3d11fa3..65862c2db 100644 --- a/src/testshade/simplerend.cpp +++ b/src/testshade/simplerend.cpp @@ -466,13 +466,13 @@ SimpleRenderer::get_array_attribute(ShaderGlobals* sg, bool derivatives, // In order to test getattribute(), respond positively to // "options"/"blahblah" if (object == RS::Hashes::options && name == RS::Hashes::blahblah - && type == TypeDesc::TypeFloat) { + && type == TypeFloat) { *(float*)val = 3.14159; return true; } if (object.empty() && name == RS::Hashes::shading_index - && type == TypeDesc::TypeInt) { + && type == TypeInt) { *(int*)val = OSL::get_shade_index(sg); return true; } @@ -506,7 +506,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, // look up something specific to the primitive, rather than have hard- // coded names. - if (name == RS::Hashes::s && type == TypeDesc::TypeFloat) { + if (name == RS::Hashes::s && type == TypeFloat) { ((float*)val)[0] = sg->u; if (derivatives) { ((float*)val)[1] = sg->dudx; @@ -514,7 +514,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, } return true; } - if (name == RS::Hashes::t && type == TypeDesc::TypeFloat) { + if (name == RS::Hashes::t && type == TypeFloat) { ((float*)val)[0] = sg->v; if (derivatives) { ((float*)val)[1] = sg->dvdx; @@ -522,8 +522,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, } return true; } - if (name == RS::Hashes::red && type == TypeDesc::TypeFloat - && sg->P.x > 0.5f) { + if (name == RS::Hashes::red && type == TypeFloat && sg->P.x > 0.5f) { ((float*)val)[0] = sg->u; if (derivatives) { ((float*)val)[1] = sg->dudx; @@ -531,8 +530,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, } return true; } - if (name == RS::Hashes::green && type == TypeDesc::TypeFloat - && sg->P.x < 0.5f) { + if (name == RS::Hashes::green && type == TypeFloat && sg->P.x < 0.5f) { ((float*)val)[0] = sg->v; if (derivatives) { ((float*)val)[1] = sg->dvdx; @@ -540,7 +538,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type, } return true; } - if (name == RS::Hashes::blue && type == TypeDesc::TypeFloat + if (name == RS::Hashes::blue && type == TypeFloat && ((static_cast(sg->P.y * 12) % 2) == 0)) { ((float*)val)[0] = 1.0f - sg->u; if (derivatives) { @@ -711,32 +709,27 @@ SimpleRenderer::build_interpolated_getter(const ShaderGroup& group, static const OIIO::ustring rs_get_attribute_constant_float4( "rs_get_attribute_constant_float4"); - if (param_name == RS::Hashes::s && type == OIIO::TypeDesc::TypeFloat) { + if (param_name == RS::Hashes::s && type == OIIO::TypeFloat) { spec.set(rs_get_interpolated_s, InterpolatedSpecBuiltinArg::OpaqueExecutionContext, InterpolatedSpecBuiltinArg::Derivatives); - } else if (param_name == RS::Hashes::t - && type == OIIO::TypeDesc::TypeFloat) { + } else if (param_name == RS::Hashes::t && type == OIIO::TypeFloat) { spec.set(rs_get_interpolated_t, InterpolatedSpecBuiltinArg::OpaqueExecutionContext, InterpolatedSpecBuiltinArg::Derivatives); - } else if (param_name == RS::Hashes::red - && type == OIIO::TypeDesc::TypeFloat) { + } else if (param_name == RS::Hashes::red && type == OIIO::TypeFloat) { spec.set(rs_get_interpolated_red, InterpolatedSpecBuiltinArg::OpaqueExecutionContext, InterpolatedSpecBuiltinArg::Derivatives); - } else if (param_name == RS::Hashes::green - && type == OIIO::TypeDesc::TypeFloat) { + } else if (param_name == RS::Hashes::green && type == OIIO::TypeFloat) { spec.set(rs_get_interpolated_green, InterpolatedSpecBuiltinArg::OpaqueExecutionContext, InterpolatedSpecBuiltinArg::Derivatives); - } else if (param_name == RS::Hashes::blue - && type == OIIO::TypeDesc::TypeFloat) { + } else if (param_name == RS::Hashes::blue && type == OIIO::TypeFloat) { spec.set(rs_get_interpolated_blue, InterpolatedSpecBuiltinArg::OpaqueExecutionContext, InterpolatedSpecBuiltinArg::Derivatives); - } else if (param_name == RS::Hashes::test - && type == OIIO::TypeDesc::TypeFloat) { + } else if (param_name == RS::Hashes::test && type == OIIO::TypeFloat) { spec.set(rs_get_interpolated_test); } else if (const OIIO::ParamValue* p = userdata.find_pv(param_name, type)) { if (p->type().basetype == OIIO::TypeDesc::INT) { @@ -859,7 +852,7 @@ SimpleRenderer::get_osl_version(ShaderGlobals* /*sg*/, bool /*derivs*/, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeInt) { + if (type == TypeInt) { ((int*)val)[0] = OSL_VERSION; return true; } @@ -886,7 +879,7 @@ SimpleRenderer::get_camera_projection(ShaderGlobals* /*sg*/, bool /*derivs*/, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeString) { + if (type == TypeString) { ((ustringhash*)val)[0] = m_projection; return true; } @@ -900,7 +893,7 @@ SimpleRenderer::get_camera_fov(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*name*/, void* val) { // N.B. in a real renderer, this may be time-dependent - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_fov; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -915,7 +908,7 @@ SimpleRenderer::get_camera_pixelaspect(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_pixelaspect; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -946,7 +939,7 @@ SimpleRenderer::get_camera_clip_near(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_hither; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -961,7 +954,7 @@ SimpleRenderer::get_camera_clip_far(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_yon; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -993,7 +986,7 @@ SimpleRenderer::get_camera_shutter_open(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_shutter[0]; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); @@ -1008,7 +1001,7 @@ SimpleRenderer::get_camera_shutter_close(ShaderGlobals* /*sg*/, bool derivs, ustringhash /*object*/, TypeDesc type, ustringhash /*name*/, void* val) { - if (type == TypeDesc::TypeFloat) { + if (type == TypeFloat) { ((float*)val)[0] = m_shutter[1]; if (derivs) memset((char*)val + type.size(), 0, 2 * type.size()); diff --git a/src/testshade/testshade.cpp b/src/testshade/testshade.cpp index 52f1614b9..39834f638 100644 --- a/src/testshade/testshade.cpp +++ b/src/testshade/testshade.cpp @@ -522,24 +522,24 @@ add_param(ParamValueList& params, string_view command, string_view paramname, } // If it is or might be a matrix, look for 16 comma-separated floats - if ((type == TypeDesc::UNKNOWN || type == TypeDesc::TypeMatrix) + if ((type == TypeDesc::UNKNOWN || type == TypeMatrix) && parse_float_list(stringval, f, 16)) { - params.emplace_back(paramname, TypeDesc::TypeMatrix, 1, f); + params.emplace_back(paramname, TypeMatrix, 1, f); param_hints.push_back(hint); return; } // If it is or might be a vector type, look for 3 comma-separated floats - if ((type == TypeDesc::UNKNOWN || equivalent(type, TypeDesc::TypeVector)) + if ((type == TypeDesc::UNKNOWN || equivalent(type, TypeVector)) && parse_float_list(stringval, f, 3)) { if (type == TypeDesc::UNKNOWN) - type = TypeDesc::TypeVector; + type = TypeVector; params.emplace_back(paramname, type, 1, f); param_hints.push_back(hint); return; } // If it is or might be an int, look for an int that takes up the whole // string. - if ((type == TypeDesc::UNKNOWN || type == TypeDesc::TypeInt) + if ((type == TypeDesc::UNKNOWN || type == TypeInt) && OIIO::Strutil::string_is(stringval)) { params.emplace_back(paramname, OIIO::Strutil::stoi(stringval)); param_hints.push_back(hint); @@ -547,7 +547,7 @@ add_param(ParamValueList& params, string_view command, string_view paramname, } // If it is or might be an float, look for a float that takes up the // whole string. - if ((type == TypeDesc::UNKNOWN || type == TypeDesc::TypeFloat) + if ((type == TypeDesc::UNKNOWN || type == TypeFloat) && OIIO::Strutil::string_is(stringval)) { params.emplace_back(paramname, OIIO::Strutil::stof(stringval)); param_hints.push_back(hint); @@ -595,7 +595,7 @@ add_param(ParamValueList& params, string_view command, string_view paramname, // All remaining cases -- it's a string const char* s = ustring(stringval).c_str(); - params.emplace_back(paramname, TypeDesc::TypeString, 1, &s); + params.emplace_back(paramname, TypeString, 1, &s); param_hints.push_back(hint); }