In looking through the OptiX API reference documentation, I found that there is a function to set the value of a program variable to be an array of variables (e.g., for an array of floats - rtVariableSet1fv). So I am successfully able to set the variable on the host side using the following:
RTvariable dummy_RTvariable;
float dummy[5] = {0, 1, 2, 3, 4};
rtGeometryInstanceDeclareVariable( instance, "dummy", &dummy_RTvariable );
rtVariableSet1fv( dummy_RTvariable, dummy );
All of this compiles just fine. However, I am not able to find any documentation on how to use the variable on the device side. If I try to declare the variable as ‘float’ and then try to index it as an array, it obviously doesn’t compile:
rtDeclareVariable(float, dummy,,);
RT_PROGRAM void closest_hit(){
rtPrintf("rho = %f\n",dummy[0]);
}
If I try to declare the variable as a float*, I get a runtime error when OptiX tries to compile the context:
rtDeclareVariable(float*, dummy,,);
RT_PROGRAM void closest_hit(){
rtPrintf("rho = %f\n",dummy[0]);
}
OptiX Error: Invalid context (Details: Function “RTresult _rtContextCompile(RTcontext)” caught exception: Validation error: Variable “dummy” assigned type float. Should be user data.
Can somebody please point me to any documentation or examples for the corresponding code for rtVariableSet1fv on the device side?