I set it up like this:
optix::Program calculate_NGEN = context->createProgramFromPTXString(source.data(), "calculate_NGEN");
p_space["calculate_NGEN"] = calculate_NGEN;
optix::Buffer buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_PROGRAM_ID, 1);
int* buffer_map = (int*) buffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD);
buffer_map = p_space["calculate_NGEN"]->getId();
I do have --keep-device-functions in my arguements, otherwise createProgramFromPTXString fails to find calculate_NGEN and the function is nowhere to be seen in the generated PTX file.
Does this mean that I have to interpret a buffer as it is ? I pass a buffer to my closest hit program like this:
I cast this buffer like this:
NGEN_CALLABLE_PROGRAMS(&color_graph, n_.x, n_.y, n_.z);
Is there a way to ensure the alignment of that buffer ? I have around 12 different type of structs that reside in a hierarchy in that char buffer. Each struct have their own function and they need to execute depending on the the hierarchy, which may or may not change.I can’t pass the hierarchy in at the compile time. Can I pass a rtBuffer to a function ?
But isn’t it rather odd that I get an unresolved reference if that is the case ?
I did go through the intro tutorials and I saw the definition in rt_function.h . I use device tag on all of my other functions. But could the unresolved reference be caused because the functions are not inlined ?
Also, thank you so much Detlef. Through your other recommendations I got my program working. I am trying to make it even better though, trying to utilize all of the processing power in my card. For reference this is what I’m building:
Its a procedurally generated planet with an adjustable generation graph. The detail increases as you get closer. With my code above I’m trying to generate the textures on the GPU and set them in a buffer so I can increase the vertex complexity and get better shadows. (I’m not passing a normal buffer as of yet, thats why the shadows look like triangles)