TheDanman
TheDanman

Reputation: 98

How can I get the Multisampling capabilities of a graphics card with SlimDX in C#?

I want to give the user choices for MSAA options in a game. I want to be able to check which Multisampling options that their machine can provide and display only these ones. The application I am working in is built in WinForms; it's not actually the game itself, but a launcher for that game.

I found SlimDX.Direct3D11.Device.CheckMultisampleQualityLevels() but I am not sure how I can get a reference to the Direct3D11 Device in WinForms. https://msdn.microsoft.com/en-us/library/windows/desktop/ff476499%28v=vs.85%29.aspx

Upvotes: 0

Views: 302

Answers (1)

mrvux
mrvux

Reputation: 8963

You need to iterate trough all possible sample counts, and check that at least one quality level is supported (you need to do it per format):

SlimDX.Direct3D11.Device device; //your created device
SlimDX.DXGI.Format format = SlimDX.DXGI.Format.R8G8B8A8_Unorm; //Replace by the format you want to test, this one is very common still
for (int samplecount = 1; samplecount  < SlimDX.Device.MultisampleCountMaximum ; samplecount *= 2)
{
     int levels = device.CheckMultisampleQualityLevels(format, samplecount );
     if (levels > 0)
     {
         //you can use a sampledescription of
         new SampleDescription(samplecount, /* value between 0 and levels -1 */
     }
     else
     {
         // samplecount is not supported for this format
     }
}

Upvotes: 1

Related Questions