DS / RT dimensions

Started by
2 comments, last by Hodgman 6 years, 9 months ago

I was using DX9 long time. Before i could use depth/stencil buffer with render target that has smaller size without a problem. 

Now i get this error:


D3D11 ERROR: ID3D11DeviceContext::OMSetRenderTargets: The RenderTargetView at slot 0 is not compatable with the DepthStencilView. DepthStencilViews may only be used with RenderTargetViews if the effective dimensions of the Views are equal, as well as the Resource types, multisample count, and multisample quality. The RenderTargetView at slot 0 has (w:640,h:360,as:1), while the Resource is a Texture2D with (mc:1,mq:0). The DepthStencilView has (w:1280,h:720,as:1), while the Resource is a Texture2D with (mc:1,mq:0). D3D11_RESOURCE_MISC_TEXTURECUBE factors into the Resource type, unless GetFeatureLevel() returns D3D_FEATURE_LEVEL_10_1 or greater. [ STATE_SETTING ERROR #388: OMSETRENDERTARGETS_INVALIDVIEW]

 

I thought i could reuse same DS.

Such a waste if i have to create DS for every RT that doesnt match in size.

 

Advertisement

That error message is correct: the dimensions and MSAA counts need to match between your render targets and your depth-stencil buffers. You can't use a larger depth-stencil buffer with a smaller render target. Depth buffers tend to be complicated in modern GPU's: they have all kinds of compression features, and they will often use tiled memory layouts to improve bandwidth. Allowing  a larger depth buffer to work with a smaller render target would probably get in the way with these things.

In D3D12 you can alias two different depth buffer resources onto the same heap range to avoid wasting memory, but in D3D11 you don't have control over resource memory placement.

I forgot about that D3D9 feature. It must be doing a lot of hidden work under the hood. The memory layouts of different resolution depth buffers will be different, so the fact that the data is preserved in the resource afterwards means that it's doing much more than D3D12 style aliasing. I'd be wary of a hidden perf penalty or memory overhead. 

You can achieve the same thing by reusing large-sized color targets too and setting a small viewport ;)

This topic is closed to new replies.

Advertisement