rtCallableProgramId as a member of struct/class

Hi,

Can’t I declare a bindless callable program as a member of a struct/class?
The following code fails to compile:

class MyClass {
    typedef rtCallableProgramId<void()> ProgSig;
    ProgSig m_callableProgram;
public:
    __device__ MyClass(int32_t cpId) : m_callableProgram((ProgSig)cpId) {}

    __device__ void func() const {
        m_callableProgram();
    }
};

Error Message:
no instance of overloaded function “optix::callableProgramId<ReturnT ()>::operator() [with ReturnT=void]” matches the argument list and object (the object has type qualifiers that prevent a match)

It seems possible to avoid the error by casting the ID in each function:

class MyClass {
    typedef rtCallableProgramId<void()> ProgSig;
    int32_t m_cpId;
public:
    __device__ MyClass(int32_t cpId) : m_cpId(cpId) {}

    __device__ void func() const {
        ProgSig callableProgram = (ProgSig)m_cpId;
        callableProgram();
    }
};

The error “the object has type qualifiers that prevent a match” is about the const after func(). It compiles without that.

I would also recommend to always use forceinline device for OptiX functions.
Only RT_PROGRAM and RT_CALLABLE_PROGRAM are the exceptions.
I defined an RT_FUNCTION for that to have a similar look.
Find it in the rt_function.h of the OptiX Introduction examples. Links here:
[url]https://devtalk.nvidia.com/default/topic/998546/optix/optix-advanced-samples-on-github/[/url]

Thanks for your reply.

Why doesn’t it work with the const qualifier?