0
\$\begingroup\$

I'm making a game in Direct3D10. For several of my rendering passes, I need to change the behavior of the pass depending on what is already rendered on the back buffer. (For example, I'd like to do some custom blending- when the destination color is dark, do one thing; when it is light, do another).

It looks like I'll need to create multiple render targets and render back and forth between them. What's the best way to do this?

  • Create my own render textures, use them, and then copy the final result into the back buffer.
  • Create multiple back buffers, render between them, and then present the last one that was rendered to.
  • Create one render texture, and one back buffer, render between them, and just ensure that the back buffer is the final target rendered to

I'm not sure which of these is possible, and if there are any performance issues that aren't obvious. Clearly my preference would be to have 2 rather than 3 default render targets, if possible.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Something like #2 is probably your best bet. Create two ID3D10Texture2D surfaces, and ensure that the D3D10_TEXTURE2D_DESC.BindFlags field includes both D3D10_BIND_SHADER_RESOURCE and D3D10_BIND_RENDER_TARGET. That will let you use each surface as a shader resource and as a render target -- not as both in the same draw call, though! Then just ping-pong between the two of them -- use surface A as in input to target B in pass 2*N, and then use surface B as an input to target A for pass 2*N+1.

\$\endgroup\$
1
  • \$\begingroup\$ Yup; this is what I do and it works very well; performance-wise it's no worse than e.g. blending a fullscreen quad over the main backbuffer, which is about as good as you're going to get. A solid +1. \$\endgroup\$ Commented Sep 10, 2012 at 22:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .