8x FSAA not working on render targets

Started by
6 comments, last by DividedByZero 8 years, 4 months ago

Hi guys,

I have render targets working nicely in my game, but I cant figure out how to make the render target render at 8x FSAA like the back buffer is doing.

Here is a screenshot of my scene. The left is a render target rendered at full screen to the back buffer and the right side is the same sphere model rendered direct to the back buffer right after the render target draw.

XbdASTT.png

As you can see, the render target is getting no FSAA softening. Where the model on the right is.

I tried matching the render target texture desc to the back buffer like this

textureDesc.SampleDesc.Count = 8;

But this results in a crash, which for some reason is being caused by a NULL pointer in the vertex shader for the render target, which only happens when the 'Count' is not equal to 1.

Any advice on how to make the render target receive FSAA / MSAA would be awesome.

Thanks in advance :)

Advertisement
enable the d3d debug runtime and also check whether the rendertarget creation was successful.
Certainly is. The image above is the draw of the render target being dawn to the back buffer and then another drawing of the model on top (the right hand side is the second draw).

He means when the sample count is set to 8, obviously.

He means when the sample count is set to 8, obviously.


Sorry, wasn't so obvious to me.

The render target creation actually does fail if I set textureDesc.SampleDesc.Count = 8


D3D11_TEXTURE2D_DESC textureDesc;
 
ZeroMemory(&textureDesc, sizeof(textureDesc));
textureDesc.Width = nWidth;
textureDesc.Height = nHeight;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;//DXGI_FORMAT_R32G32B32A32_FLOAT;// DXGI_FORMAT_R8G8B8A8_UNORM;
textureDesc.SampleDesc.Count = 8;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
Does anything look wrong with how I am setting up the texture description?

The texture creation call succeeds but the CreateRenderTargetView() fails.

Thanks again.
Oooh. I just worked it out.

I needed to specify D3D11_RTV_DIMENSION_TEXTURE2DMS instead of D3D11_RTV_DIMENSION_TEXTURE2D.

Thanks for guiding me in the right direction smile.png

You will probably find that what you also want to do is use ResolveSubResource() to copy the MSAA texture to a normal one to read it back with. If you don't do that you may get some weird looking results as you will be reading back individual samples.

If you're doing that I'd also drop the D3D11_BIND_SHADER_RESOURCE flag from the MSAA version to make sure you don't try and use it directly. Making an MSAA render target a shader resource is also not supported on a D3DFEATURE_LEVEL_9_* device.

Thanks for the advice Adam.

I'm not getting any weird graphical results as such, but I am getting some pretty nasty warnings and errors in the debug pane that I am working through. ResolveSubResource() looks like it might be the answer to those though.

Thanks for the heads up smile.png

This topic is closed to new replies.

Advertisement