PDA

View Full Version : Render to texture and using it



V-man
05-16-2007, 08:46 PM
Let's say I want to render my entire scene to a RTT, then use the texture an render a fullscreen quad.
This is the case for many post processing effects.
Would this be like a glFinish?

I'm thinking of coding something like this:
- make 2 RTT
- OVERHERE
- render to RTT 1
- use RTT 2 to render a fullscreen quad
- SwapBuffers
-
- render to RTT 2
- use RTT 1 to render a fullscreen quad
- SwapBuffers
-
- goto OVERHERE

game_cy
05-17-2007, 02:11 AM
I'm not sure if the question is clear. would what be like a glFinish?
SwapBuffers doesnt require a glFinish i think.

alternatively :
int current=0, previous=1;
while(true)
{
render to RTT[current]
render RTT[previous] to fullscreen quad

if (current==0) { current=1; previous=0;}
else { current=0; previous=1;}

swapbuffers();
}

Zengar
05-17-2007, 02:36 AM
Basically, SwapBuffers calls Finish internally, also, using a texture will require that all rendering operations are finished. Still I am not sure if you will get a performance win. Let us assume that the card can work on one render target at time, then your first SwapBuffers will finish the rendering to RTT1 and from RTT2 to the screen. So no win here. Still, you could try this out and tell us if there is a difference :)

V-man
05-17-2007, 03:40 AM
Not sure if I was clear so I will restate it.

Basically, I want to do a post processing effect, like glow or whatever.
I need to render the scene to a RTT. Then I render a fullscreen quad and use the RTT.

Let's say in my naive implementation, I do this.

- make 1 RTT when program starts
-
- OVERHERE
- render to RTT
- use RTT to render a fullscreen quad
- SwapBuffers
-
- goto OVERHERE

As you can see, the GPU is force to complete all rendering to the RTT before I can use it to render the fullscreen quad.

But if I use the code from my first post, perhaps magically I will gain some FPS.

game_cy, I don't see the difference between your pseudo code and mine.

SwapBuffers doesn't call glFinish. It is glFlush.

However, I'm wondering if rendering to a RTT and suddenly using it will cause a glFinish.

There is a win if I put some CPU related work in the right places.

game_cy
05-17-2007, 07:21 AM
Theres no difference except that you only have the same code (rendering) in one place instead of two, so you wont forget to edit both parts and create bugs :)