Jump to content
  • Advertisement
Sign in to follow this  
spek

OpenGL CPU & GPU, reading/writing textures

This topic is 3628 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to combine the CPU and GPU: 1.- GPU renders geometry with shadowMaps to a flat texture (FBO) 2.- CPU reads this texture and uses it for a raytracer kinda-like thing and produces an ambient lightmap. 3.- When the CPU is done, an updated map must be send back to the GPU as a texture. Step 3 can be done by rendering a grid of quads with color values, so that shouldn't be too much of a problem (unless, there are also faster ways???). I'm worried more about step 1. The maps are probably small (32x32, 64x64), but glReadPixels is still a slow instruction. If possible, I'd like to do this ~20 times per second. I got this idea from the author from LightsMark, a benchmark program that does realtime GI (and works with OpenGL as well). I asked him if reading out that map wouldn't be slow, but he told we underestamated this, and was actually surprised that almost nobody uses the CPU in combination. Either that means glReadPixels is faster than I thought, or he uses a different OpenGL technique... What can you guru's say about this? Are there optimizations, or specific moments where I should (NOT) read pixels to prevent interrupting the rendering process? Then I have a second related question. I plan the raytracing part to happens on a second CPU (I have a dual core system). So we have the main loop that does all the normal rendering stuff, and another thread that runs on the other core does the lightmap updating. Can this core also read/write/render via OpenGL? I guess not, but I'd like to ask anyway. Greetings, Rick

Share this post


Link to post
Share on other sites
Advertisement
readpixels isnt as slow as it once was you should be able to achieve 60fps at decent resolution

also look into PBO's

Share this post


Link to post
Share on other sites
Ah, that was the answer Í was hoping for :) But does the timing of this instruction matter? Long time ago someone explained that glReadPixels is slow because it interrupts the OpenGL 'flow'. Can't remember the details anymore, but if that is correct, it might be better to do this at the end of the rendering each cycle for example...?

Never worked with PBO's so far. What exactly is the difference when rendering to a texture (FBO) or using a PBO?

Thanks!
Rick

Share this post


Link to post
Share on other sites
The two are really completely unrelated. You can think of FBO functionality as a way of rendering onto another destination than the usual framebuffer (backbuffer). PBO functionality can be used to transfer data asynchronously back and forth between the CPU and the GPU - if have a need to transfer a significant amount of data, you can use PBO to avoid blocking the application.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!