From 2836965519f984fb6c52a5c1b9022efa60a3b97f Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Fri, 25 Oct 2024 19:55:49 +0200 Subject: [PATCH] call_support: allow override of the Domain --- include/drjit/call.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) 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 =