Optix Prime 3.7 bug report

in include/optix_prime/optix_primepp.h:

function should be inline on line 485
function should be inline on line 633

I’m updating my code now to work with 3.7. Will report back if I find anything else.

Ok well it took me a few hours to track down the other bug breaking my unit tests, but here it is: if you assign a nonzero minimum distance to a ray in OptiX Prime++, the hit can fail when it shouldn’t.


$ nvcc -std=c++11 -I/home/jeremy/optix/NVIDIA-OptiX-SDK-3.6.3-linux64/include -L/home/jeremy/optix/NVIDIA-OptiX-SDK-3.6.3-linux64/lib64 -loptix_prime min_test.cu -o min_test-3.6
$ nvcc -std=c++11 -I/home/jeremy/optix/NVIDIA-OptiX-SDK-3.7.0-linux64/include -L/home/jeremy/optix/NVIDIA-OptiX-SDK-3.7.0-linux64/lib64 -loptix_prime min_test.cu -o min_test-3.7
$ ./min_test-3.7
hit triangle -1 at distance -1
hit triangle 0 at distance 3
(these should be the same)
$ LD_LIBRARY_PATH=/home/jeremy/optix/NVIDIA-OptiX-SDK-3.6.3-linux64/lib64 ./min_test-3.6
hit triangle 0 at distance 3
hit triangle 0 at distance 3
(these should be the same)

test source code:

#include <optix_prime/optix_primepp.h>
#include <vector_types.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>

using Hit_t = struct HitStruct_t
	float t;
	int triId;

using Ray_t = struct RayStruct_t
    float3 origin;
    float  tmin;
    float3 dir;
    float  tmax;

int main() {
    using namespace optix::prime;

    Context context = Context::create(RTP_CONTEXT_TYPE_CUDA);
    Model model = context->createModel();
    std::vector<float3> vertices = {{0,3,1}, {-1,3,-0.5}, {1,3,-0.5}};
    std::vector<int3> triangles = {{0, 1, 2}};

    thrust::device_vector<float3> device_vertices(vertices.begin(), vertices.end());
    thrust::device_vector<int3> device_triangles(triangles.begin(), triangles.end());

    model->setTriangles(device_triangles.size(), RTP_BUFFER_TYPE_CUDA_LINEAR, device_triangles.data().get(), device_vertices.size(), RTP_BUFFER_TYPE_CUDA_LINEAR, device_vertices.data().get());
    model->update( 0 );

    float3 origin {0, 0, 0};
    float3 direction {0, 1, 0};

    std::vector<Ray_t> rays(2);
    rays[0].origin = origin; rays[1].origin = origin;
    rays[0].dir = direction; rays[1].dir = direction;
    rays[0].tmax = 1e20; rays[1].tmax = 1e20;

    rays[0].tmin = 0.00000001; rays[1].tmin = 0; // HERE IS THE PROBLEM

    thrust::device_vector<Ray_t> device_rays(rays.begin(), rays.end());
    thrust::device_vector<Hit_t> device_hits(device_rays.size());

    Query query = model->createQuery(RTP_QUERY_TYPE_CLOSEST);
    query->setRays(device_rays.size(), RTP_BUFFER_FORMAT_RAY_ORIGIN_TMIN_DIRECTION_TMAX, RTP_BUFFER_TYPE_CUDA_LINEAR, device_rays.data().get());
    query->setHits(device_hits.size(), RTP_BUFFER_FORMAT_HIT_T_TRIID, RTP_BUFFER_TYPE_CUDA_LINEAR, device_hits.data().get());

    for (int i=0; i<2; i++) {
        Hit_t h = device_hits[i];
        std::cout << "hit triangle " << h.triId << " at distance " << h.t << std::endl;
    std::cout << "(these should be the same)" << std::endl;

I’m using CUDA6.5 on Ubuntu 14.04 x64. I should also mention that since the problem in the post above was in the header files, I was able to fix them myself to continue testing. But I think this one is in the binary. If only Optix was open source, I would patch it myself ;)

I can confirm that without the inline statements in front of these functions, functions are doubly exported and the linkers I’ve tried will complain and fail to link.

We have fixed the tmin bug. It will appear in our next drop of 3.7.

We fixed “inline” for those two calls. Thanks for catching that.

Beta 3 will probably be out this week.