Hi there, I’m implementing lights as bindless callable programs in my renderer and I’m now trying to use buffers (in this case the buffers hold cdfs for doing importance sampling of the environment map for an IBL).
Everything compiles fine, and I can create the buffers and set them to the appropriate variables on my program without error (in my implementation every optix call is checked and throws if not RT_SUCCESS). However, when I validate the context immediately before launching I get the following error:
Context::validate(): Invalid value (Details: Function "RTresult _rtContextValidate(RTcontext)" caught exception: Non-initialized variable buf_marginal: Buffer(1d, 8 byte element))
After stripping down, the code for the light is essentially the following:
rtDeclareVariable(Matrix4x4, light_to_world, , );
rtDeclareVariable(Matrix4x4, world_to_light, , );
rtDeclareVariable(float3, L_e, , );
rtDeclareVariable(int, tex_id, , );
rtBuffer<float2, 2> buf_conditional;
rtBuffer<float2, 1> buf_marginal;
RT_CALLABLE_PROGRAM LightSample light_sample(ShadingFrame frame, const float u1,
const float u2) {
#if 1
LightSample ls;
float i = buf_marginal[32].x;
ls.L_i = make_float3(i, i, i);
ls.pdf = 1.0f;
ls.omega_i = make_float3(0.0f, 1.0f, 0.0f);
return ls;
#else
// old code just doing cosine sampling, looking up the texture and transforming the result into world space from the shading frame using the matrices declared at the top
#endif
}
I’ve checked that the buffer is being set correctly by validating the buffer and then checking the RTobject held by the buf_marginal variable on the program is the same as the RTbuffer both immediately after setting it and just before validating the context.
If I switch out the #if, the old code which does texture accesses and uses matrices set by the host works perfectly. It’s just as soon as I try to use either buffer it fails.
I’m not really sure what to try next to debug this.
Cheers,
Anders