Skip to content

Commit

Permalink
call_support: allow override of the Domain
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinND committed Oct 28, 2024
1 parent 14950da commit 2836965
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions include/drjit/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,32 @@

NAMESPACE_BEGIN(drjit)

NAMESPACE_BEGIN(detail)

template <typename T>
using has_domain_override = decltype(T::domain_());

template <typename CallSupport>
constexpr const char *get_domain(const char *fallback) {
if constexpr (is_detected_v<has_domain_override, CallSupport>) {
return CallSupport::domain_();
} else {
return fallback;
}
}

NAMESPACE_END(detail)

#define DRJIT_CALL_BEGIN(Name) \
namespace drjit { \
template <typename Self> \
struct call_support<Name, Self> { \
using Base_ = void; \
using Class_ = Name; \
using Mask_ = mask_t<Self>; \
static constexpr const char *Domain = #Name; \
using CallSupport_ = call_support<Name, Self>; \
static constexpr const char *Domain = \
detail::get_domain<CallSupport_>(#Name); \
call_support(const Self &self) : self(self) { } \
const call_support *operator->() const { \
return this; \
Expand All @@ -38,7 +56,9 @@ NAMESPACE_BEGIN(drjit)
using Base_ = void; \
using Class_ = Name<Ts...>; \
using Mask_ = mask_t<Self>; \
static constexpr const char *Domain = #Name; \
using CallSupport_ = call_support<Name<Ts...>, Self>; \
static constexpr const char *Domain = \
detail::get_domain<CallSupport_>(#Name); \
call_support(const Self &self) : self(self) { } \
const call_support *operator->() const { \
return this; \
Expand Down Expand Up @@ -125,8 +145,8 @@ public: \
state->collect_rv(rv_i); \
}; \
\
return detail::call<Self, Ret, Ret, Mask_>(self, Domain, #Name "()", \
true, callback, mask); \
return detail::call<Self, Ret, Ret, Mask_>( \
self, Domain, #Name "()", true, callback, mask); \
}
template <typename Guide, typename T>
using vectorize_rv_t =
Expand Down

0 comments on commit 2836965

Please sign in to comment.