Can I read from a framebuffer while drawing to it?

Started by CodeBunny, March 17, 2012, 16:53:53

Previous topic - Next topic

CodeBunny

Yes, I know I cannot read and write to a target from within a shader. This is slightly different. Can I have a single framebuffer, render different passes to different sections of it, and then render the final version to
another section?

A simple graphic illustrating what I'm trying to do:

spasi

Two options:

- NV_texture_barrier: Widely supported on NV/AMD, has limitations.
- ARB_shader_image_load_store: More advanced, but supported on DX11+ GPUs only.

CodeBunny


spasi

Why do you want to render this way anyway? Why not have a texture that holds the 3 render passes (like [1][2][3]) and then perform the combined render pass on the backbuffer directly?

CodeBunny

Efficiency experiments. That's actually what I'm doing currently, and I'm trying to improve my render process.

For one thing, I'm using pixel scaling, so the actual scene I'm rendering is 2-4x smaller than the view. The shader I use to combine the render passes is expensive, so it occurred to me that rendering to a smaller texture first, and then just using a straight replace blend function would probably be the fastest method.

Additionally, it seemed like I could be most efficient memory-wise if I combined my framebuffers onto a single texture. I try to minimize PoT overflow as much as I can.