Jump to content
  • Advertisement
Sign in to follow this  
remigius

[MDX] Checking multisample capabilities (Revisited - .NET question)

This topic is 4732 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 just added multisampling to my MDX app and it works fine, but I'm a bit confused on how to check what level of multisampling is actually supported on the device. The documentation contains a code snippet for Manager.CheckDeviceMultiSampleType I could use, but iirc I'll have to check all possible multisample types with the current device settings to find out if it'll work. And changing the device settings will require new checks, right? Isn't there something like device.Caps.MaxMultiSampleType to check this more easily, or perhaps something similar in the DXUT framework I've missed? [Edited by - remigius on October 7, 2005 5:14:16 AM]

Share this post


Link to post
Share on other sites
Advertisement
Well, I haven't worked too much with MDX, but with my unmanaged DirectX program I am only checking to see if the multisampling levels that I want are supported (2x, 4x, and 6x). I really don't know how often any other ones are used. You might be able to try something similar...

Share this post


Link to post
Share on other sites
Well, I went with the documented Managed code and especially in combination with the sample framework it turns out to be surprisingly easy to use. You can paste the following code to the end of the sample framework's ModifyDeviceSettings method and voila, scaling multisampling is yours :)

[source lang=c#]
// define types you want to support here
MultiSampleType[] types = new MultiSampleType[] { MultiSampleType.EightSamples, MultiSampleType.SixSamples, MultiSampleType.FourSamples, MultiSampleType.TwoSamples, MultiSampleType.None };

for (int i = 0; i < types.Length; i++)
{
if (Manager.CheckDeviceMultiSampleType( 0, settings.DeviceType, settings.AdapterFormat, settings.presentParams.Windowed, types))
{
System.Diagnostics.Debug.WriteLine( String.Format("Using {0} multisampling", types ));
settings.presentParams.MultiSample = types;
break;
}
}

Share this post


Link to post
Share on other sites
I was tinkering to make the above code use reflection to check the available multisample types. This way I won't have to add the types manually and any future types will be automatically used. The code for this is quite straightforward and working correctly:

[source lang=c#]
System.Reflection.FieldInfo[] fields = typeof(MultiSampleType).GetFields();

foreach(System.Reflection.FieldInfo field in fields)
{
if (field.IsSpecialName) continue; // ignore special fields
MultiSampleType type = (MultiSampleType)field.GetValue(0);

if (Manager.CheckDeviceMultiSampleType( 0, settings.DeviceType, settings.AdapterFormat, settings.presentParams.Windowed, type))
{
settings.presentParams.MultiSample = type;
break;
}
}




First I was thinking I'd need to implement a comparator to sort the types ordered by descending quality, but the retrieved fields array already seems in perfect order for this code. My question is, how reliable is the order in which these fields are returned by the .NET reflection?

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!