• Advertisement
Sign in to follow this  

Swapchain fails to create when SampleDesc.Quality is greater than 0

This topic is 865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I am having a problem with trying to enable MSAA for my game. When I set the Swapchain description's SampleDesc.Quality to 0 the game runs fine and everything renders, but once I set it to a value greater than 0, for example 1, it fails to create the Swapchain.

 

Here is my swapchain description:

			DXGI_SWAP_CHAIN_DESC scdesc;
			ZeroMemory(&scdesc, sizeof(DXGI_SWAP_CHAIN_DESC));
			scdesc.BufferDesc = { width, height, { 1, 60 }, DXGI_FORMAT_R8G8B8A8_UNORM };
			scdesc.SampleDesc = aasettings;
			scdesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
			scdesc.BufferCount = 1;
			scdesc.OutputWindow = window;
			scdesc.Windowed = !(isFullScreen());
			scdesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
			scdesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

			D3D_FEATURE_LEVEL level = D3D_FEATURE_LEVEL_11_0;

			D3D11CreateDeviceAndSwapChain(0, D3D_DRIVER_TYPE_HARDWARE, 0, 0,
				&level, 1, D3D11_SDK_VERSION, &scdesc, &swapchain, &device, 0, &context));

The variable aasettings basically looks like:

DXGI_SAMPLE_DESC aasettings{ 8, 1 };

Where 8 is the SampleDesc.Count, and 1 is SampleDesc.Quality.

 

Would anyone happen to know why its failing when I increase the Quality value?

Edited by MushroomFire

Share this post


Link to post
Share on other sites
Advertisement
Did you enumerate the valid samplecount and quality values which you can use by the ID3D11Device::CheckMultisampleQualityLevels() function?

Different cards support different values and what you set shouldn't be hard coded.

You also need to set exactly the same values for your depth buffer as you set for the swap chain.

See: http://www.gamedev.net/topic/637614-how-to-enable-msaa-in-directx-11/
And
https://msdn.microsoft.com/en-us/library/windows/desktop/ff476499(v=vs.85).aspx

Share this post


Link to post
Share on other sites
Do you have any logs or errors from the debug layer? D3D makes it pretty easy to tell when something's wrong if you turn on D3D11_CREATE_DEVICE_DEBUG.

That said, multisample quality varies per card and the number of samples requested. You should use CheckMultisampleQualityLevels to query the available quality levels. See also the D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS enumeration for the stand stipple patterns.

https://msdn.microsoft.com/en-us/library/windows/desktop/ff476499(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218(v=vs.85).aspx

Share this post


Link to post
Share on other sites
You have to ask the driver which quality levels it supports, which is done using ID3D11Device::CheckMultisampleQualityLevels. In your case the device probably only supports a quality level of 0.

Quality levels are typically used to expose vendor-specific MSAA extensions like CSAA and EQAA, so it's generally not something you want to use blindly.

Share this post


Link to post
Share on other sites

Alright, so I tried using CheckMultisampleQualityLevels(), it looks like this:

			D3D11CreateDevice(0, D3D_DRIVER_TYPE_HARDWARE, 0, 0, &level, 1, D3D11_SDK_VERSION, &device, 0, &context);
			UINT samplecount = 8;
			UINT samplequality;

			device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, samplecount, &samplequality);

And when I run the debugger, it says that samplequality has a value of 1, which should mean it is supported right?

 

Would anyone also know why this effect happens when the Quality is 0?

557c3475ebc32f801d8873a6c1b6b278.png

This effect only happens in window mode, when I run the game in fullscreen it looks antialiased properly. The green part is just the background so that you can see the effect, but as you can see, there is still some jaggy-ness to the lines in window mode.

Edited by MushroomFire

Share this post


Link to post
Share on other sites
The levels start at 0, so if it returns "1" then "0" is the only valid quality level.

Regarding your artifact, are you sure that the client rectangle of your window is the same size if your backbuffer? Try calling GetClientRect and making sure that it's the size that you expect it to be.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement