Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API for building attribute getter free functions. #1704

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d318962
Add API for building attribute getter free functions.
curtisblack Jun 23, 2023
1176fd4
Support all standard C++ types and ustring/ustringhash.
curtisblack Jul 21, 2023
c312d24
Fix different sign comparison.
curtisblack Jul 21, 2023
07bf09a
Fix memcpy error.
curtisblack Jul 21, 2023
6e352b6
Merge branch 'main' into getattribute_builder
curtisblack Jul 24, 2023
d3ec4fe
Disambiguate function call.
curtisblack Jul 24, 2023
637275d
Fix formatting.
curtisblack Jul 24, 2023
e4efe31
Fix formatting.
curtisblack Jul 24, 2023
4ad7c1d
Add helper functions and comments.
curtisblack Aug 17, 2023
9c929bd
Merge branch 'main' into getattribute_builder
curtisblack Aug 17, 2023
587fe5e
Use string params to ensure optimisation.
curtisblack Aug 18, 2023
46cc9e2
Merge branch 'main' into getattribute_builder
curtisblack Aug 18, 2023
9f05e03
Fix rebase conflict.
curtisblack Aug 18, 2023
02c4237
Convert return type to match virtual function signature.
curtisblack Aug 20, 2023
028aa6c
clang format
curtisblack Aug 20, 2023
e90f4e9
Fix incorrect indexing.
curtisblack Aug 21, 2023
0a1498d
Support userdata in attribute builder.
curtisblack Aug 21, 2023
0db9c26
Add missing derivatives argument.
curtisblack Aug 21, 2023
6c03cda
Fix typo.
curtisblack Aug 21, 2023
f914eeb
Use find_pv correctly.
curtisblack Aug 21, 2023
1577a8d
Merge branch 'main' into getattribute_builder
curtisblack Aug 21, 2023
630530f
Remove unused variable.
curtisblack Aug 21, 2023
a0dd0ed
clang format
curtisblack Aug 21, 2023
6f68b60
Fix some attribute types.
curtisblack Aug 21, 2023
651c7f9
Fix incorrect size.
curtisblack Aug 21, 2023
3edffb9
Cast to avoid ambiguity.
curtisblack Aug 25, 2023
697d1d3
Refactor for future reusability.
curtisblack Aug 25, 2023
217a238
Formatting.
curtisblack Aug 25, 2023
3006684
Fix template specialisations.
curtisblack Aug 25, 2023
3a0d66c
Formatting.
curtisblack Aug 25, 2023
74048bc
Remove templates.
curtisblack Aug 25, 2023
f8e449b
Fix asserts.
curtisblack Aug 25, 2023
c9cebdf
Fix type.
curtisblack Aug 25, 2023
8c5e57c
Merge branch 'main' into getattribute_builder
curtisblack Aug 28, 2023
e21087a
Use POD type with known size.
curtisblack Aug 28, 2023
7c62b2f
Update src/include/OSL/rendererservices.h
curtisblack Aug 31, 2023
c260dac
Make optional args const pointers.
curtisblack Sep 1, 2023
e72ddfb
clang format.
curtisblack Sep 1, 2023
2798354
clang format.
curtisblack Sep 1, 2023
c7971ef
constify ShaderGroup.
curtisblack Sep 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 29 additions & 35 deletions src/include/OSL/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,99 +132,93 @@ template<typename TBuiltinArg> class ArgVariant {
return false;
}

template<typename T> T get() const
{
OSL_DASSERT(false);
return T();
}

template<> inline TBuiltinArg get() const
TBuiltinArg get_builtin() const
{
OSL_DASSERT(is_holding<TBuiltinArg>());
return m_builtin;
}

template<> inline bool get() const
bool get_bool() const
AlexMWells marked this conversation as resolved.
Show resolved Hide resolved
{
OSL_DASSERT(is_holding<bool>());
return OSL_DASSERT(is_holding<bool>());
return m_bool;
}

template<> inline int8_t get() const
int8_t get_int8() const
{
OSL_DASSERT(is_holding<int8_t>());
return OSL_DASSERT(is_holding<int8_t>());
return m_int8;
}

template<> inline int16_t get() const
int16_t get_int16() const
{
OSL_DASSERT(is_holding<int16_t>());
return OSL_DASSERT(is_holding<int16_t>());
return m_int16;
}

template<> inline int32_t get() const
int32_t get_int32() const
{
OSL_DASSERT(is_holding<int32_t>());
return OSL_DASSERT(is_holding<int32_t>());
return m_int32;
}

template<> inline int64_t get() const
int64_t get_int64() const
{
OSL_DASSERT(is_holding<int64_t>());
return OSL_DASSERT(is_holding<int64_t>());
return m_int64;
}

template<> inline uint8_t get() const
uint8_t get_uint8() const
{
OSL_DASSERT(is_holding<uint8_t>());
return OSL_DASSERT(is_holding<uint8_t>());
return m_uint8;
}

template<> inline uint16_t get() const
uint16_t get_uint16() const
{
OSL_DASSERT(is_holding<uint16_t>());
return OSL_DASSERT(is_holding<uint16_t>());
return m_uint16;
}

template<> inline uint32_t get() const
uint32_t get_uint32() const
{
OSL_DASSERT(is_holding<uint32_t>());
return OSL_DASSERT(is_holding<uint32_t>());
return m_uint32;
}

template<> inline uint64_t get() const
uint64_t get_uint64() const
{
OSL_DASSERT(is_holding<uint64_t>());
return OSL_DASSERT(is_holding<uint64_t>());
return m_uint64;
}

template<> inline float get() const
float get_float() const
{
OSL_DASSERT(is_holding<float>());
return OSL_DASSERT(is_holding<float>());
return m_float;
}

template<> inline double get() const
double get_double() const
{
OSL_DASSERT(is_holding<double>());
return OSL_DASSERT(is_holding<double>());
return m_double;
}

template<> inline void* get() const
void* get_ptr() const
{
OSL_DASSERT(is_holding<void*>());
return OSL_DASSERT(is_holding<void*>());
return m_ptr;
}

template<> inline ustring get() const
ustring get_ustring() const
{
OSL_DASSERT(is_holding<ustring>());
return OSL_DASSERT(is_holding<ustring>());
return m_ustring;
}

template<> inline ustringhash get() const
ustringhash get_ustringhash() const
{
OSL_DASSERT(is_holding<ustringhash>());
return OSL_DASSERT(is_holding<ustringhash>());
return m_ustringhash;
}
};
Expand Down
30 changes: 15 additions & 15 deletions src/liboslexec/llvm_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3310,46 +3310,46 @@ append_constant_arg(BackendLLVM& rop, const TArgVariant& arg,
case TArgVariant::Type::Unspecified:
case TArgVariant::Type::Builtin: OSL_DASSERT(false); break;
case TArgVariant::Type::Bool:
args.push_back(rop.ll.constant_bool(arg.get<bool>()));
args.push_back(rop.ll.constant_bool(arg.get_bool()));
break;
case TArgVariant::Type::Int8:
args.push_back(rop.ll.constant8(arg.get<int8_t>()));
args.push_back(rop.ll.constant8(arg.get_int8()));
break;
case TArgVariant::Type::Int16:
args.push_back(rop.ll.constant16(arg.get<int16_t>()));
args.push_back(rop.ll.constant16(arg.get_int16()));
break;
case TArgVariant::Type::Int32:
args.push_back(rop.ll.constant(arg.get<int32_t>()));
args.push_back(rop.ll.constant(arg.get_int32()));
break;
case TArgVariant::Type::Int64:
args.push_back(rop.ll.constanti64(arg.get<int64_t>()));
args.push_back(rop.ll.constanti64(arg.get_int64()));
break;
case TArgVariant::Type::UInt8:
args.push_back(rop.ll.constant8(arg.get<uint8_t>()));
args.push_back(rop.ll.constant8(arg.get_uint8()));
break;
case TArgVariant::Type::UInt16:
args.push_back(rop.ll.constant16(arg.get<uint16_t>()));
args.push_back(rop.ll.constant16(arg.get_uint16()));
break;
case TArgVariant::Type::UInt32:
args.push_back(rop.ll.constant(arg.get<uint32_t>()));
args.push_back(rop.ll.constant(arg.get_uint32()));
break;
case TArgVariant::Type::UInt64:
args.push_back(rop.ll.constant64(arg.get<uint64_t>()));
args.push_back(rop.ll.constant64(arg.get_uint64()));
break;
case TArgVariant::Type::Float:
args.push_back(rop.ll.constant(arg.get<float>()));
args.push_back(rop.ll.constant(arg.get_float()));
break;
case TArgVariant::Type::Double:
args.push_back(rop.ll.constant64(arg.get<double>()));
args.push_back(rop.ll.constant64(arg.get_double()));
break;
case TArgVariant::Type::Pointer:
args.push_back(rop.ll.constant_ptr(arg.get<void*>()));
args.push_back(rop.ll.constant_ptr(arg.get_ptr()));
break;
case TArgVariant::Type::UString:
args.push_back(rop.ll.constant(arg.get<ustring>()));
args.push_back(rop.ll.constant(arg.get_ustring()));
break;
case TArgVariant::Type::UStringHash:
args.push_back(rop.ll.constant(ustring(arg.get<ustringhash>())));
args.push_back(rop.ll.constant(ustring(arg.get_ustringhash())));
break;
}
}
Expand Down Expand Up @@ -3428,7 +3428,7 @@ LLVMGEN(llvm_gen_getattribute)
for (size_t index = 0; index < spec.arg_count(); ++index) {
const auto& arg = spec.arg(index);
if (arg.is_holding<AttributeSpecArg::Type::Builtin>()) {
switch (arg.get<AttributeSpecBuiltinArg>()) {
switch (arg.get_builtin()) {
default: OSL_DASSERT(false); break;
case AttributeSpecBuiltinArg::ShaderGlobalsPointer:
args.push_back(rop.sg_void_ptr());
Expand Down
Loading