D3D11 - RenderTargetView at slot 0 is not compatable with the DepthStencilView

Started by
1 comment, last by Migi0027 11 years, 1 month ago

Hi guys,

right now I'm trying to follow a tutorial from raster tek, tutorial 22 about Render To Texture: http://www.rastertek.com/dx11tut22.html , but stuff isn't going as well as i thought because this pops up:


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:800,h:600,as:1), while the Resource is a Texture2D with (mc:1,mq:0). The DepthStencilView has (w:800,h:600,as:1), while the Resource is a Texture2D with (mc:4,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 ]

So as I understand, theres something wrong with my Texture2D, now some code:

For the render to texture class: (textureWidth debugged 800, textureHeight debugged 600)


// Setup the render target texture description.
textureDesc.Width = textureWidth;
textureDesc.Height = textureHeight;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
textureDesc.SampleDesc.Count = 1;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;

In the system class (the default texture) (sw debugged 800, sh debugged 600)


texd.Width = sw;
texd.Height = sh;
texd.ArraySize = 1;
texd.MipLevels = 1;
texd.SampleDesc.Count = 4;
texd.Format = DXGI_FORMAT_D32_FLOAT;
texd.BindFlags = D3D11_BIND_DEPTH_STENCIL;

Now I've never touched Render To Texture before this, so if you wan't more information, please tell me.

Thank You

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

Advertisement

Hi!


Your render target view (that views the texture to render into) and your depth stencil view (the corresponding depth buffer) have different multi-sampling settings.
When using multi-sampling, every pixel needs to store extra data for the sub-samples (their depth and the coverage bits). Each texture resource is prepared for one certain multi-sampling setting and to make them work together, both the color texture and the depth buffer (after all, it’s just another texture) need the same setting. You can have resources with different settings, but you can only bind them together, if their settings coincide.


If you disable multi-sampling, it would be:


sampleDesc.Count = 1;
sampleDesc.Quality = 0;


High-quality 4x MSAA (for instance) is achieved by setting:


sampleDesc.Count = 4;
sampleDesc.Quality = 16.


Keep in mind that MSAA comes at a cost. If you don’t need it, try to avoid it. Also, combining multi-sampled with single-sampled textures requires you to convert one into the other. (I'd advise you to first familarize yourself with the rendering to textures, before working with multi-sampling)

Okay, so try to set in your default texture (system class):


texd.SampleDesc.Count = 1; 

and make sure that your view dimensions are set to the single-sampled types, e.g.,

for the depth stencil view: D3D11_DSV_DIMENSION_TEXTURE2D (not: D3D11_DSV_DIMENSION_TEXTURE2DMS).

Cheers!

Thank!

My render to texture works perfectly, MVUHAHAHAH!

..sorry, but awesome feeling.

Cheers!

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

This topic is closed to new replies.

Advertisement