Skip to content

Commit

Permalink
Attempt MSVC fix
Browse files Browse the repository at this point in the history
+ static_assert that our domain name override is detected to avoid bad surprises.
  • Loading branch information
merlinND committed Oct 29, 2024
1 parent e1b1fce commit d4063dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ext/drjit
Submodule drjit updated 1 files
+5 −4 include/drjit/call.h
36 changes: 14 additions & 22 deletions include/mitsuba/core/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,29 +261,15 @@ constexpr auto constexpr_array_concatenation(const std::array<char, Len> &...arr

NAMESPACE_END(detail)

template <typename Float, typename Spectrum, size_t N>
constexpr auto domain_name_for_class(const std::array<char, N> &class_name) {
constexpr std::array variant = ::mitsuba::detail::get_variant_padded<Float, Spectrum>();
return detail::constexpr_array_concatenation(
std::array<char, 10>{"mitsuba::"},
variant,
std::array<char, 3>{"__"},
class_name
);
}

/**
* Adds the given class instance to a DrJit registry domain that is specific
* to this backend and Mitsuba variant.
*
* Example usage:
* MI_REGISTRY_PUT("BSDF", this);
*/
#define MI_REGISTRY_PUT(name, ptr) \
if constexpr (dr::is_jit_v<Float>) { \
static constexpr std::array<char, sizeof(name) / sizeof(char)> class_name_arr{name}; \
static constexpr auto domain_name \
= domain_name_for_class<Float, Spectrum>(class_name_arr); \
= detail::constexpr_array_concatenation( \
std::array<char, 10>{"mitsuba::"}, \
detail::get_variant_padded<Float, Spectrum>(), \
std::array<char, 3>{"__"}, \
std::array<char, sizeof(name) / sizeof(char)>{name} \
); \
jit_registry_put(dr::backend_v<Float>, domain_name.data(), ptr); \
}

Expand All @@ -292,12 +278,18 @@ constexpr auto domain_name_for_class(const std::array<char, N> &class_name) {

#define MI_CALL_TEMPLATE_END(Name) \
private: \
static constexpr std::array<char, sizeof(#Name) / sizeof(char)> MIClass_{#Name}; \
static constexpr auto MIDomain_ = mitsuba::domain_name_for_class<Ts...>(MIClass_); \
static constexpr auto MIDomain_ \
= ::mitsuba::detail::constexpr_array_concatenation( \
std::array<char, 10>{"mitsuba::"}, \
::mitsuba::detail::get_variant_padded<Ts...>(), \
std::array<char, 3>{"__"}, \
std::array<char, sizeof(#Name) / sizeof(char)>{#Name} \
); \
public: \
static constexpr const char *domain_() { \
return MIDomain_.data(); \
} \
static_assert(is_detected_v<detail::has_domain_override, CallSupport_>); \
DRJIT_CALL_END(mitsuba::Name)


Expand Down

0 comments on commit d4063dc

Please sign in to comment.