About a month ago, I was studied geometry import and run the program. Fortunately, it was successful.
However, I found an issue with an unknown problem.
The problem is:
The first code above also works sometimes.
But of course nothing is displayed on the screen.
OptiX Error: ‘Unknown error (Details: Function “_rtContextLaunch2D” caught exception: Encountered a CUDA error: cudaDriver().CuMemcpy2D( pCopy ) returned (700): Illegal address)’
unsigned int total_faces = 5804;
float2 *tex = new float2[total_faces * 3];
float3 *VTX = new float3[total_faces * 3];
float3 *NVP = new float3[total_faces * 3];
unsigned int *index = new unsigned int[total_faces * 3];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// after input data....................
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const unsigned int num_vertices = total_faces*3;
const unsigned int num_faces = total_faces;
Buffer vertex_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, num_vertices);
Buffer normal_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, num_vertices);
Buffer texcoord_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT2, num_vertices);
Buffer index_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_UNSIGNED_INT3, num_faces);
memcpy(vertex_buffer ->map(), VTX, sizeof(VTX));
memcpy(normal_buffer ->map(), NVP, sizeof(NVP));
memcpy(texcoord_buffer ->map(), tex, sizeof(tex));
memcpy(index_buffer ->map(), index, sizeof(index));
vertex_buffer->unmap();
normal_buffer->unmap();
texcoord_buffer->unmap();
index_buffer ->unmap();
whatever good working code (static array)
unsigned int total_faces = 5804;
float2 tex[5804 * 3];
float3 VTX[5804 * 3];
float3 NVP[5804 * 3];
unsigned int index[5804 * 3];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// after input data....................
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const unsigned int num_vertices = total_faces*3;
const unsigned int num_faces = total_faces;
Buffer vertex_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, num_vertices);
Buffer normal_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, num_vertices);
Buffer texcoord_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT2, num_vertices);
Buffer index_buffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_UNSIGNED_INT3, num_faces);
memcpy(vertex_buffer ->map(), VTX, sizeof(VTX));
memcpy(normal_buffer ->map(), NVP, sizeof(NVP));
memcpy(texcoord_buffer ->map(), tex, sizeof(tex));
memcpy(index_buffer ->map(), index, sizeof(index));
vertex_buffer->unmap();
normal_buffer->unmap();
texcoord_buffer->unmap();
index_buffer ->unmap();
I want to do dynamic allocation and I need it.
How should dynamic allocation be done?