Hello all,
First time poster and occasional reader of this forum. I have been using optiX for a couple of months.
I am writing because I am having some issues with acceleration structures that I don’t understand and would like some help.
Namely, different behavior depending on the acceleration structure used, the refit property, and exceptions enabled.
By way of summary, see this image
The scene set-up:
//list of points Npt each [x,y,z]
vert_ = context_->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, mesh->numVert());
//connectivity Ntri each [ind0, ind1, ind2, ID]
ind_ = context_->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_INT4, mesh->numTri());
//the mesh is already on device
//with correct types, list of 3 floats (packed), list of 4 int (packed)
vert_->setDevicePointer(0, mesh->get_pts().ptr_);
ind_->setDevicePointer(0, mesh->get_tri().ptr_);
//create geometry (all primitives in one)
geo_ = context_->createGeometry();
geo_["vertex_buffer"]->setBuffer(vert_);
geo_["index_buffer"]->setBuffer(ind_);
geo_->setPrimitiveCount(mesh->numTri());
/*these are the bounding box and intersection programs that come with SUTIL SDK
(with slight modification to allow for indices being int4 instead of int3
and keep intersecting primitive index) */
geo_->setBoundingBoxProgram(boundProg_);
geo_->setIntersectionProgram(interProg_);
geoInst_ = context_->createGeometryInstance();
geoInst_->setMaterialCount(1);
geoInst_->setGeometry(geo_);
/* material doesn't have anything special, it associates ray type and uses the primitive index
variable to look-up the triangle color in the closest_hit program */
geoInst_->setMaterial(0, mat_);
geoGroup_ = context_->createGeometryGroup();
geoGroup_->addChild(geoInst_);
accel_ = context_->createAcceleration("Trbvh");
//index buffer stride to account for the <ID>
accel_->setProperty("index_buffer_stride", "4");
accel_->setProperty("refit", "1");
//accel_ = context_->createAcceleration("NoAccel");
geoGroup_->setAcceleration(accel_);
context_["top_object"]->set(geoGroup_);
context_["top_shadower"]->set(geoGroup_);
All entry points are associated with an exception program in the form of:
RT_PROGRAM void exception()
{
const unsigned int code = rtGetExceptionCode();
rtPrintf("Caught exception 0x%X at launch index (%d,%d)\n", code, launch_index.x, launch_index.y);
rtPrintExceptionDetails();
output_buffer[launch_index] = make_color(OPTIX_BAD_COLOR); //BAD_COLOR = RED
}
The test:
I have been using this code for a couple of months now, using TRBVH acceleration with refit and with exceptions turned off (mostly ‘release’ builds). The code seems to be stable, with no undefined behavior or crashes. [top left image in summary image] I recently switched to a ‘debug’ build (which enabled ALL exceptions and printing) when I noticed that I had no output from the raytracer [bottom left image in the summary]. There were no crashes and the exception program produce no visible BAD_COLOR pixels or print outs).
I tried a couple of other configurations to figure out what was causing the issue. But have not been able to troubleshoot the problem very well.
The fact that No-Acceleration produces the correct results make me think that somehow the issue is with the acceleration builds. I do have a stride in the index buffer, but I think its being handled correctly.
I find it odd that exceptions enabled/disable change the behavior. While using TRBVH with refit one, I tried turning on each exception type individually, all but RT_EXCEPTION_BUFFER_INDEX_OUT_OF_BOUNDS produced the expected renders. I have not been able to figure out if (or where) I am indexing out of bound but it’s odd that there are no outputs (pixels or print outs) from the exception program.
Any ideas what could be causing this problem? Or how to go about troubleshooting it?
The configuration: Windows 7 x64, VS2015, CUDA 8, OptiX 4.1.1, GTX 1080 Ti