I have a variable declared per RTgeometryinstance as follows:
// Device attribute program rtDeclareVariable(int, sole_material, , ) = -1; /* sole material index to use for all triangles, or -1 to use per-triangles material index */ // Host if (node->sole_material != -1) applyGeometryInstanceVariable1i(context, node->instance, "sole_material", node->sole_material);
This produces the following warning from OptiX:
PERF WARNING: Variable "sole_material" used in program "_Z14mesh_attributev" (ATTRIBUTE) is declared at different scopes (Unknown, GeometryInstance). PERF WARNING: For best runtime performance, a variable should be declared at one scope only, and in the same order with other variables on that scope.
I have only declared the variable once in the host code and once in the device code, but I do have multiple geometry instances. Is there anything I can do the resolve the performance issue?
Furthermore, if I have a more complicated scene structure (RTgeometryinstances within RTgeometrygroups within RTgroups within a top-level RTgroup), then OptiX will not assign the correct sole_material value to each RTgeometryinstance. Instead, all of the instances will have whatever value I assigned to the first instance. I realize complex scene hierarchies are not recommended for performance reasons, but is there a reason that this fails?