Why doesn't the second RTPmodel initialize

0

I parse a txt file for a scene description and try to add an Optix Prime RTPmodel for every triangle in the file. This works for the first triangle, but the second model is somehow still a NULL reference after initialization. The program throws the following error: Exception thrown at 0x00007FFB608640D0 (optix_prime.6.0.0.dll) in CustomEngine.exe: 0xC0000005: Access violation reading location 0x0000000000000020 while pushing the model into a vector.

I'm using VC++ in Visual Studio and Optix 6.0

I've tried to do the whole RTPmodel creation in one function, to no avail. Since it only affects the second model it parses it could be some closing function call I forgot, but I do call rtpModelUpdate() and also tried with rtpModelFinish(), but then the error occurs there instead of during push_back. Buffer locking an unrelated buffer (the hits buffer) appears to resolve it, but throws the same exception when creating the RTPquery.

    // Parses a triangle definition
    void SceneParser::parseTriangle(const char* line)
    {
        //
        // [...] This is where I parse the vertices
        //
        std::vector<float> vertices({ v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z });
        std::vector<uint> indices({ 0, 1, 2 });

        RTPmodel triangle;
        rtpModelCreate(m_scene->getContext(), &triangle); // after this call, the second parsed triangle is still NULL, whereas the first had an adress
        m_scene->addObject(triangle, vertices, indices, TransformMatrix(vec3(0.0f), 0.0f)); // Dummy transform, since the vertices are already in place
    }
// Adds the object to the object queue as a triangle model and as a transformation matrix to the transform queue
void Scene::addObject(RTPmodel model, std::vector<float> vertices, std::vector<uint> indices, TransformMatrix transform)
{
    RTPbufferdesc indBuffer, verBuffer;
    rtpBufferDescCreate(m_context, RTP_BUFFER_FORMAT_INDICES_INT3, RTP_BUFFER_TYPE_CUDA_LINEAR, indices.data(), &indBuffer);
    rtpBufferDescCreate(m_context, RTP_BUFFER_FORMAT_VERTEX_FLOAT3, RTP_BUFFER_TYPE_CUDA_LINEAR, indices.data(), &verBuffer);
    rtpBufferDescSetRange(indBuffer, 0, indices.size());
    rtpBufferDescSetRange(verBuffer, 0, vertices.size());

    rtpModelSetTriangles(model, indBuffer, verBuffer);
    rtpModelUpdate(model, RTP_MODEL_HINT_NONE);

    m_objects.push_back(model); // This is where the exception happens
    m_transforms.push_back(transform);
}
c++
optix
asked on Stack Overflow May 9, 2019 by Jornam • edited May 16, 2019 by Jornam

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0