Hi Detlef,
I’m sorry but it is still not working.
- No just to test it out I made the following:
1.1. In order to have values different as the standard zeros I added the following line
in the ‘pinhole_camera.cu’
prd.test_output_var_float_4 = make_float4( 0.0f, 2.0f, 2.0f, 0.0f );
1.2. Afterwards BEFORE the rtTrace([…]); Call I added a rtPrintf-call => cmd.exe shows the right values
rtPrintf("Function RT_PROGRAM void pinhole_camera() before rtTrace has been called: \n %f \n %f \n %f \n %f : \n ", prd.test_output_var_float_4.x, prd.test_output_var_float_4.y, prd.test_output_var_float_4.z, prd.test_output_var_float_4.w);
1.3 The same as in 1.2 I added AFTER the rtTrace call.
What is happening in the meanwhile is that OptiX calls the
‘RT_PROGRAM void closest_hit_radiance()’ in phong.cu.
In that file I added the line in order to see, if the value is taken over by the pinhole_camera.cu
correctly and, like described in 1.3., the value 1,2,3,4 is printed correctly in the cmd.exe.
prd.test_output_var_float_4 = make_float4(1.0f, 2.0f, 3.0f, 4.0f);
1.4 Then I added the following line to write those values in the RT_OUTPUT_BUFFER
and tested if the correct values have been written IN-to the Buffer by calling
the rtPrintf function again → and they were (1,2,3,4).
output_buffer_Hit_Points_float4_dim2[launch_index] = prd.test_output_var_float_4;
So far so good, but now I’m becoming exasperated with copying those float4 into my *.cpp file.
I even tried it with the CUDA interop functionality today, but it showed the same behaviour.
- Global definitions in the header of the *.cpp file
Variable st_OUTPUT_rtBuffer_Variable;
Buffer st_OUTPUT_rtBuffer_Buffer;
float4 *pt_DATA_OUTPUT_rtBuffer_float4;
2.1 According to the SDK Sample I created the Buffer-Linkage just after the context
has been created createContext()
st_OUTPUT_rtBuffer_Variable = context["output_buffer_Hit_Points_float4_dim2"];
// Here I tried several things -- nothing lead to a solution
// Now with | RT_BUFFER_GPU_LOCAL
st_OUTPUT_rtBuffer_Buffer = context->createBuffer(RT_BUFFER_INPUT_OUTPUT, RT_FORMAT_FLOAT4, width, height);
pt_DATA_OUTPUT_rtBuffer_float4 = reinterpret_cast<float4*>(st_OUTPUT_rtBuffer_Buffer->map());
context["output_buffer_Hit_Points_float4_dim2"]->set(st_OUTPUT_rtBuffer_Buffer);
st_OUTPUT_rtBuffer_Variable->set(st_OUTPUT_rtBuffer_Buffer);
st_OUTPUT_rtBuffer_Buffer->unmap();
2.2. Latestly AFTER the context->launch([…]); call I added the following debug code
in order to see if I can read my (1,2,3,4) at any place but I can’t.
int tryout(0);
float4 laufvariable_float4;
double float_sizeof_d;
float_sizeof_d = sizeof(float);
for ( tryout = 0;
tryout <= width + height;
tryout++
)
{
laufvariable_float4 = *pt_DATA_OUTPUT_rtBuffer_float4;
pt_DATA_OUTPUT_rtBuffer_float4 = pt_DATA_OUTPUT_rtBuffer_float4 + 1;
}
Actually, according to everthing I read in this forum (Old Posts) and in the internet,
this code should work, actually.
Have you any idea what’s happening here or if there is a structural error?
Kind Regards
Robert