@Please always use the online documentation to get the up to date version:
Thanks, I will read the online documentation from now on :)
@The recommended CUDA toolkit version for OptiX 5 is CUDA 9.0.
You are right, I would like to avoid this by all means. I decided to port all to RTX now and not in the summer, so we will be using OptiX 6 and CUDA 10, which match.
@Is that in the exact same system configuration from the first post in this thread?
Yes, mo change in hardware, I’m adjusting the source code though.
@The OptiX 6.0.0 optixPathTracer or other SDK examples using a PBO for display work?
optixPathTracer works fine, we do not use PBO though.
Creating a buffer:
Buffer OptiXInterface::createOutputBuffer(optix::Context context, RTformat format, size_t element_size,
unsigned int width, unsigned int height)
{
if (element_size == 0 || width == 0 || height == 0)
{
m_ig->notify(vig::ImageGenerator::VIGNFL_FATAL,
"OptiXInterface::createOutputBuffer has a 0 element size or width/height is 0.\n");
}
Buffer buffer;
GLuint vbo = 0;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, element_size * width * height, 0, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
buffer = context->createBufferFromGLBO(RT_BUFFER_OUTPUT, vbo);
buffer->setFormat(format);
if (format == RT_FORMAT_USER)
{
buffer->setElementSize(element_size);
}
buffer->setSize(width, height);
return buffer;
}
Element Size:
size_t element_size;
context->checkError(rtuGetSizeForRTformat(format, &element_size));
Buffer Parameters:
m_context[OUTPUT_BUFFER_PARAM_NAME]->set(createOutputBuffer(m_context, RT_FORMAT_FLOAT3, m_width, m_height));
Drawing resulting image:
void
OptiXDrawable::drawBuffer(osg::RenderInfo& renderInfo) const
{
// Draw the resulting image
Buffer buffer = m_optiXInterface->getBuffer(OptiXInterface::OUTPUT_BUFFER_PARAM_NAME);
RTsize buffer_width_rts, buffer_height_rts;
buffer->getSize( buffer_width_rts, buffer_height_rts );
int buffer_width = static_cast<int>(buffer_width_rts);
int buffer_height = static_cast<int>(buffer_height_rts);
RTformat buffer_format = buffer->getFormat();
unsigned int vboId = 0;
vboId = buffer->getGLBOId();
if (vboId)
{
glBindTexture( GL_TEXTURE_RECTANGLE , m_osgTex->getTextureObject(renderInfo.getContextID())->_id );
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, vboId);
RTsize elementSize = buffer->getElementSize();
if ((elementSize % 8) == 0) glPixelStorei(GL_UNPACK_ALIGNMENT, 8);
else if ((elementSize % 4) == 0) glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
else if ((elementSize % 2) == 0) glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
else glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if(buffer_format == RT_FORMAT_UNSIGNED_BYTE4) {
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA8, buffer_width, buffer_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
} else if(buffer_format == RT_FORMAT_FLOAT4) {
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA32F_ARB, buffer_width, buffer_height, 0, GL_RGBA, GL_FLOAT, 0);
} else if(buffer_format == RT_FORMAT_FLOAT3) {
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGB32F_ARB, buffer_width, buffer_height, 0, GL_RGB, GL_FLOAT, 0);
} else if(buffer_format == RT_FORMAT_FLOAT) {
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_LUMINANCE32F_ARB, buffer_width, buffer_height, 0, GL_LUMINANCE, GL_FLOAT, 0);
} else {
m_ig->notify( vig::ImageGenerator::VIGNFL_FATAL, "OptiXDrawable::drawImplementation() unknown buffer format\n");
}
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 );
}
}
The code is the same as in OptiX 5 + CUDA 9. Since I also tried OptiX 5 and CUDA 10, this has to be caused by the OptiX 6 changes. I enabled all exceptions and usageReportLevel is on 3, no problems detected. I get a OpenGL warning, but hard to say where it’s comming from - I might disable the drawBuffer and watch if it remains.
Warning: detected OpenGL error ‘invalid operation’ at after RenderBin::draw(…)