Jump to content

  • Log In with Google      Sign In   
  • Create Account

DirectX detecting highest MSAA supported


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 spyter   Members   -  Reputation: 102

Like
0Likes
Like

Posted 19 February 2014 - 07:58 AM

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

 



Sponsor:

#2 spyter   Members   -  Reputation: 102

Like
0Likes
Like

Posted 19 February 2014 - 08:48 AM

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;
}
}
}





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS