Instance pointer build input

Hi Nol,

I just tried switching a sample that uses instances to use instance pointers. It ran okay. That might be something you can do to compare against your own code, try converting an OptiX SDK sample like optixCutouts or optixHair to use instance pointers.

One thing I did differently is I constructed the instance pointers on the host using pointer arithmetic rather than making a CUDA kernel, like so:

    CUdeviceptr  d_instance_pointers;
    std::vector<CUdeviceptr> optix_instance_pointers;
    for( int i = 0; i < numInstances; i++ )
        optix_instance_pointers.push_back( d_instances + i * sizeof( OptixInstance ) );
    createOnDevice(optix_instance_pointers, &d_instance_pointers);

This lazy approach makes it a tiny bit easier to double-check the alignment of each pointer, on the host.

A few other things you can try:

  • Make sure to also call cudaDeviceSyncronize before optixAccelBuild in case there was a pending error before the launch.
  • Try turning on OptiX validation mode. (see OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_ALL)
  • Check to make sure all relevant device buffers are copied to the GPU before optixAccelBuild runs; it’s easy sometimes to forget or to have the copy code running at a different time than you think.


David.