Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Categories
- All Discussions1,524
- General534
- Graphics109
- GPU Computing419
- Mobile141
- Pro Graphics163
- Tools158
In this Discussion
- DefiniteIntegral January 10
- szerbst January 10
Optix tutorial / OpenGL question
-
Sorry I am sure this has been asked but these new forums are pretty horrible to find anything compared to the old one....
I am just getting started with Optix. This means I am using OpenGL directly for the first time in many years, as for a long time I have been using Ogre3D to do all the work for me. So now getting back into OpenGL I feel like a dinosaur, not sure what I am doing. Anyway to get to the point...
I am looking at the Optix tutorials, specifically GLUTDisplay::displayFrame()
I can see there are 2 rendering methods, one using VBO and one using glDrawPixels. I don't even know how/why a vertex buffer object is being used to render pixels, but whatever. I have tried running the demo using both VBO and glDrawPixels versions and have noticed no difference whatsoever either in quality or speed.
So, is there a particular reason to use VBO instead of drawpixels? Since the drawpixels version maps the optix buffer to GL image data, I guess both versions are rendering the data directly from video memory without transferring the buffer contents to CPU. So is there a reason one would be preferable to the other? Is one faster?
Also, it's always preferable to enable GL_FRAMEBUFFER_SRGB_CAPABLE_EXT when supported, for better color precision right?
Thanks
-
3 Comments sorted by
-
OK never mind I'm an idiot. The VBO version does get about 5FPS better on my computer.
-
The difference is where the data is stored and how it gets to the back buffer.
In case of the VBO you allow OptiX direct access to OpenGL resources. So Optix can directly render into graphics memory (the VBO's memory). From there you can pretty fast copy the VBO content (the raytraced image) into a texture which you then render on a screen filling rectangle.
If you do not use a VBO then Optix renders into its own buffer on the graphics card. From there you have no direct access to OpenGL resources and cannot display the image directly. If you look at the correponding code path you will notice the call to optix::Buffer::map. That copies the buffer content (the raytraced image) from the graphics card (Optix space) to your system RAM. This is comparably slow. Then you call glDrawPixels to move the pixels from your system RAM to the graphics card but into an OpenGL resource so that you can display it on screen. That, again, is comparably slow.DefiniteIntegral said:Since the drawpixels version maps the optix buffer to GL image data, I guess both versions are rendering the data directly from video memory without transferring the buffer contents to CPU.
This is a wrong guess. glDrawPixels reads from host memory (system RAM). That is why optix::Buffer::map has to be called before that to copy the OptiX buffer from device (graphcis card) to host (CPU) memory before calling glDrawPixels.
It might not be a measurable time delay in your case but staying inside OpenGL and bypassing the system RAM is the fastest way to do it. If your rendered image gets bigger or uses more data (4 component floating point pixels for example) then you start feeling the difference.
regards,
Stefan -
OK thanks for that