Graphic Profile / Feature Level fallback?

I have found that with some computers, DXDIAG states DX 11, where they really are DX 10.1. In XNA and SharpDX we could do one of two things about this.

1- Check the feature level of the device before setting the level
2- Have a nested fallback right back to DX9

I am new to Paradox (just playing for now) and first thing I came across (ForwardLighting Demo) was this piece of code:

 case PlatformType.Windows:
      allowShadows = true;
      graphicsProfile = GraphicsProfile.Level_11_0;
      break;

This is matched in the .pdxpkg file. However, this failed (and crashed to debugger) with a “No Screen Modes Found” error. Looking that up, it refers to the wrong feature level of DX for the installed card. So, if I change it to 10_1 (only in the code - I left the .pdxpkg file as is) it then works.

So, once a game is written, I prefer not going to the lowest common denominator (probably 10.1 these days), but would prefer to either see if the running machine is capable of higher, or fall back from 11.2 until it find one that suits.

I looked through the sparse docs (I know its still an alpha - not complaining) and GitHub logs and here too, but have found no mention of handling this (other than at dev time by matching installed card on dev box).

Is there a way to go about this? If not, any plans to?

Cheers :slight_smile:

In your Game ctor, GraphicsDeviceManager.PreferredGraphicsProfile is actually an array (which default to the pattern you described 11, 10_1, … up until 9.1).

As an example:

GraphicsDeviceManager.PreferredGraphicsProfile = new[] { GraphicsProfile.Level_11_0, GraphicsProfile.Level_10_1 };

Documentation is available here:
http://doc.paradox3d.net/html/index.htm?page=P_SiliconStudio_Paradox_Games_GraphicsDeviceManager_PreferredGraphicsProfile

Hope that helps!

1 Like

Yes, this was the answer - do not know how to mark as such though. For anyone finding this, here is how I fixed it…

Change to ForwardLighting.ForwardLightingGame constructor as follows:

public ForwardLightingGame()
        {
            _allowShadows = false;
            var graphicsProfiles = new List<GraphicsProfile>();
            // GraphicsProfile graphicsProfile = GraphicsProfile.Level_9_1; //-- old code
            
            // change profile based on platform
            switch (Platform.Type)
            {
                case PlatformType.Windows:
                    _allowShadows = true;
                    // graphicsProfile = GraphicsProfile.Level_11_0; //-- old code
                    graphicsProfiles.Add( GraphicsProfile.Level_11_2 );
                    graphicsProfiles.Add( GraphicsProfile.Level_11_1 );
                    graphicsProfiles.Add( GraphicsProfile.Level_11_0 );
                    graphicsProfiles.Add(GraphicsProfile.Level_10_1);
                    graphicsProfiles.Add( GraphicsProfile.Level_10_0 );
                    graphicsProfiles.Add( GraphicsProfile.Level_9_3 );
                    graphicsProfiles.Add( GraphicsProfile.Level_9_2 );
                    graphicsProfiles.Add( GraphicsProfile.Level_9_1 );
                   
                   //graphicsProfile = GraphicsProfile.Level_10_1;
                    break;
                case PlatformType.Shared:
                case PlatformType.WindowsPhone:
                case PlatformType.WindowsStore:
                case PlatformType.Android:
                case PlatformType.iOS:
                    _allowShadows = false;
                    graphicsProfiles.Add(GraphicsProfile.Level_9_1);
                    // graphicsProfile = GraphicsProfile.Level_9_1; //-- old code

                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            GraphicsDeviceManager.PreferredDepthStencilFormat = PixelFormat.D24_UNorm_S8_UInt;
            GraphicsDeviceManager.DeviceCreationFlags = DeviceCreationFlags.None;
            GraphicsDeviceManager.PreferredGraphicsProfile = graphicsProfiles.ToArray(); // new[] { graphicsProfile }; --old code // should be the same as the one in the pdxpkg...
        }