The programming guide says it’s possible to use buffer IDs in arbitrary structs, data members of ray payload, so I thought that using bindless callable programs could work as well.
Is it possible?
I tried a small test with storing ID or pointer to ID in the ray payload during closest hit program and then calling it afterwards in ray generation program, but was getting this:
“Assertion failed: “var != vlm->m_variables.end””
Here how it was used:
typedef rtCallableProgramId<int()> BsdfEvalProgramID;
struct SubpathPRD
{
BsdfEvalProgramID bsdfEvalProgID; // also tried storing a pointer
};
// --- some_material.cu
RT_CALLABLE_PROGRAM int bsdfEvalProg() {
rtPrintf("Print from callable program\n");
}
rtDeclareVariable(BsdfEvalProgramID, bsdfEval, ,);
RT_PROGRAM void closestHit() {
subpathPrd.bsdfEvalProgID = bsdfEval; // call bsdfEval() works here
return;
}
// --- entry_point.cu - tried to use callable program as
BsdfEvalProgID callable = BsdfEvalProgID(lightPrd.bsdfEvalProgID);
//or
BsdfEvalProgID(lightPrd.bsdfEvalProgID) callable;
callable();
I’m working on implementation of Vertex Connection and Merging (extension of bidir PT and PPM). I need to store some per hit vertex data on first pass from light source, they are later used together with camera pass data to construct full paths/pdfs.
I can register callable programs for each material in context scope and later call the proper one based on stored material ID in per hit vertex data. But if I could store callable programs IDs in that data, I wouldn’t need to bother with material IDs at all.