diff --git a/include/drjit/call.h b/include/drjit/call.h index 87a24baf..20cbb6fc 100644 --- a/include/drjit/call.h +++ b/include/drjit/call.h @@ -18,6 +18,22 @@ NAMESPACE_BEGIN(drjit) +NAMESPACE_BEGIN(detail) + +template +using has_domain_override = decltype(T::domain_()); + +template +constexpr const char *get_domain(const char *fallback) { + if constexpr (is_detected_v) { + return CallSupport::domain_(); + } else { + return fallback; + } +} + +NAMESPACE_END(detail) + #define DRJIT_CALL_BEGIN(Name) \ namespace drjit { \ template \ @@ -25,7 +41,9 @@ NAMESPACE_BEGIN(drjit) using Base_ = void; \ using Class_ = Name; \ using Mask_ = mask_t; \ - static constexpr const char *Domain = #Name; \ + using CallSupport_ = call_support; \ + static constexpr const char *Domain = \ + detail::get_domain(#Name); \ call_support(const Self &self) : self(self) { } \ const call_support *operator->() const { \ return this; \ @@ -38,7 +56,9 @@ NAMESPACE_BEGIN(drjit) using Base_ = void; \ using Class_ = Name; \ using Mask_ = mask_t; \ - static constexpr const char *Domain = #Name; \ + using CallSupport_ = call_support, Self>; \ + static constexpr const char *Domain = \ + detail::get_domain(#Name); \ call_support(const Self &self) : self(self) { } \ const call_support *operator->() const { \ return this; \ @@ -125,8 +145,8 @@ public: \ state->collect_rv(rv_i); \ }; \ \ - return detail::call(self, Domain, #Name "()", \ - true, callback, mask); \ + return detail::call( \ + self, Domain, #Name "()", true, callback, mask); \ } template using vectorize_rv_t =