https://devtalk.nvidia.com/default/topic/962948/optix/type-mismatch-of-light-buffer-in-context-validation/post/4985633/#4985633
I want to pass the structure according to the above link.
Struct camera_variable {
Double3 eye;
Double3 U;
Double3 V;
Double3 W;
Double eye_r;
};
Go to the device side and do the calculations.
This is create user buffer in create context:
Buffer bufferDoubles = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_USER);
bufferDoubles->setElementSize(sizeof(camera_variable));
bufferDoubles->setSize(1);
context["doublebuffer"]->set(bufferDoubles);
and update camera function, this value can be updated:
Buffer b_c = context["doublebuffer"]->getBuffer();
camera_variable* data=static_cast<camera_variable*>(b_c->map());
data[0].eye = camera_eye;
data[0].eye_r = 0.05;
data[0].U = camera_u;
data[0].V = camera_v;
data[0].W = camera_w;
b_c->unmap();
In cu file these values been used in this way:
rtBuffer<camera_variable,1> camera_variables;
double3 eye = camera_variables[0].eye;
double eye_r = camera_variables[0].eye_r;
double3 U = camera_variables[0].U;
double3 V = camera_variables[0].V;
double3 W = camera_variables[0].W;
but there is some error in my code that:
OptiX Error: ‘Variable not found (Details: Function “_rtContextValidate” caught exception: Variable “Unresolved reference to variable camera_variables from _Z14display_camerav” not found in scope)’