DirectX detecting highest MSAA supported

Started by
0 comments, last by spyter 10 years, 2 months ago

I am relatively new to game programming and I have been following some tutorials online for setting up a game window, game loop and initializing the required directx components in order to start drawing some meshes and textures to the screen. I have all of it working, except I am having issues with detecting MSAA levels. At some point I would like to offer different settings but for now I am just trying to detect the highest MSAA supported and set that on the swap chain.

I'm sure this is a simple feat but below is what I am having trouble with. Any advice would be greatly appreciated!!

...other initialization code here....

....create a device...

...declare a swap chain....


swapChainDescription.SampleDesc.Quality = 0;


if (m_configuration->EnableMSAA)
{
UINT sampleCount = GetMaxMSAASupport();


swapChainDescription.SampleDesc.Count = sampleCount;
}
else
{
swapChainDescription.SampleDesc.Count = 1;
}

Basically if msaa bool is not enabled, it defaults to 0 quality/1 sample count. Otherwise it will use 0 quality and attempt to detect the max sample count.

Below is the code for the GetMaxMSAASupport() function:


UINT Direct3d::GetMaxMSAASupport()
{
UINT maxQualityLevel = 0;


for (UINT sampleCount = D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; sampleCount > 0; sampleCount /= 2)
{
if (SUCCEEDED(m_device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, sampleCount, &maxQualityLevel) && 
maxQualityLevel <= 0))
{
return sampleCount;
}
}
}

When I run the above, it is returning 32 MSAA (max), which my card does not support. My card only goes up to x16. Something is off in my GetMaxMSAASupport function but I am not sure what.

Also, is quality always supposed to be 0? Does it have a ratio to sample count? I have been all over the internet but I havent found any "good" explanations on this or examples.

Thanks in advance!!!!

Advertisement

I seem to have resolved this w/the following fix. I am still unsure on what the sample count is vs the quality level but the below code works for detecting the max supported sample count (xMSAA level). To get the max available quality level it would simple be --&maxQualityLevel.


UINT Direct3d::GetMaxMSAASupport()
{
UINT maxQualityLevel = 0;


for (UINT sampleCount = D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; sampleCount > 0; sampleCount /= 2)
{
if (sampleCount == 1) return sampleCount; 


if (SUCCEEDED(m_device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, sampleCount, &maxQualityLevel)) && 
maxQualityLevel > 0)
{
return sampleCount;
}
}
}

This topic is closed to new replies.

Advertisement