how to copy depthstencil rendertarget

Started by
2 comments, last by JohnnyCode 10 years, 7 months ago

... without using copyresource/copysubresource?

i need to copy depth/stencil from one depth target to another using blitting screen aligned rectangle (via shader). i'm able to copy depth info, but somehow stencil info is lost. (i'm guessing it's prolly source shader resource view is R24_X8 type ... )

any idea?

Advertisement

You can't directly write to the stencil buffer using a pixel shader like you can with depth using SV_Depth. The only way to write to the stencil buffer is to do it indirectly using a depth/stencil state. You can read the stencil data if you want, but that's not very helpful in your case. Note that to read stencil you have to create a separate shader resource view using DXGI_FORMAT_X24_TYPELESS_G8_UINT, and bind it as a separate texture. The stencil data will then be in the green channel of the texture when you sample it in the shader.

Do you actually use multiple stencil buffer values? It would be possible to "copy" the stencil value by doing 1 extra pass per stencil bit. So if you were only using 1 bit, you could fill the stencil using 1 extra pass after the depth fill pass. If you were using all possible values, then you would need 8 extra passes.

Jep, eight passes for 8 bits. But now I'm wondering if one could write all bits with just four passes...

You want to use Z-S of target A but output to target B, not discading target A data?

Hmmm, there is MRT, and in case of MRT (multiple render targets), you output the value to more targets, but pixel treatment logic behaves on Z-S of target 0. Try speculating on this.

This topic is closed to new replies.

Advertisement