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

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

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.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 on other sites
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 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 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 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?

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 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.

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
17
5. 5

• 9
• 12
• 9
• 33
• 13
• Forum Statistics

• Total Topics
632594
• Total Posts
3007260

×