[RESOLVED] Run() causes: No Suitable Graphics Device Exception - Failed to create graphics device (3.6.0.1625)

Yeah, there’s a bug with multisampling going on :confused: Sucks that it made it into the release.

Related issue https://github.com/MonoGame/MonoGame/issues/5449
Pull request that fixes it: https://github.com/MonoGame/MonoGame/pull/5477

1 Like

I amended the title to include your MG version and as this is not yet solved I have marked it as resolved as it is identified but not fixed.

@Jjagg Good to know, even though it’s not good to have

Thank you!

Hi

I’ve just installed VS2017 and Monogame 3.6 onto a new laptop I’ve just got (first one, always use desktops) and I was getting the same sort of error message (never had the problem on my desktop pc).

I found this line in my code:

_graphics.PreferMultiSampling = true;

and removing it also made my app work as it should. Thanks for the heads up - though I can’t remember what this will do and why I put it to true in the first place :slight_smile:

It shoudl enable MSAA and set the multisample count to the highest level supported by your GPU. You can still enable multisampling by setting the multisample count directly. For details see this post: Quick Overview: How to work with MSAA (DirectX too!)

Hi

Thanks for the refresher, been a while since I’ve done any MG stuff but like to keep the binaries on the machine just in case. Thanks for the link too!

Also ran into this bug. Just commented out the line

graphics.PreferMultiSampling = true;

in the Game1 constructor and it works.

This came up in some other topics. A fix for this bug was recently merged and will be included in the 3.6.1 release.

I’ve just built MonoGame starting from the code as October 5th, 2017, and I still get the exception if I don’t comment out
GraphicsDeviceManager.PreferMultiSampling = true;

Have you tried setting it to false?

Setting it to false works, but setting it to false is not what I want.

What project type are you using?

1 Like

I’m using a Windows C# project type.

Debugging a bit I see that the exception is generated by
_swapChain = new SwapChain(dxgiFactory, dxgiDevice, desc);
of GraphicsDevice.DirectX.cs
The same line passes well up to commits dated mid January 2017.

Digging further I found out that with commits before January 2017 in above SwapChain call desc.SampleDescription.Count is 8 and desc.SampleDescription.Quality is 16, while with later commits such values are 32 and -1. By replacing a 32 with an 8 in line
presentationParameters.MultiSampleCount = GraphicsDevice != null
? GraphicsDevice.GraphicsCapabilities.MaxMultiSampleCount
: 32;
of GraphicsDevice.DirectX.cs and in line
private const int MultiSampleCountLimit = 32;
of GraphicsCapabilities.cs I get desc.SampleDescription.Count = 8 and desc.SampleDescription.Quality = 16 and no crash.
Note that the line of GraphicsDevice.DirectX.cs is executed twice before the call to SwapChain(), and both times GraphicsDevice is null, so that the fixed limit is selected without checking the capabilities of the platform.
I hope this helps to define how to proceed. By the moment I proceed with above lines changed.

What version of MG are you using? I can’t reproduce this on latest develop.

I’ve used the 5 ott 2017, 22:10 version.

Can you check that GraphicsCapabilities.MaxMultiSampleCount is properly initialized and that the ms count is clamped to that value when the GraphicsDevice is being created here?

The first execution of

presentationParameters.MultiSampleCount = GraphicsDevice != null
? GraphicsDevice.GraphicsCapabilities.MaxMultiSampleCount
: 32;

within GraphicsDevice.DirectX.cs occurs in Initialize() within CreateDevice(). GraphicsDevice is null there.
The second execution of such lines occurs in

         var gdi = DoPreparingDeviceSettings();

and therefore again before

        CreateDevice(gdi);

that is before the creation of GraphicsDevice.

Instead PresentationParameters.MultiSampleCount should be set after the creation of GraphicsDevice and after PlatformInitializeAfterResources(GraphicsDevice device) , that computes MaxMultiSampleCount, I believe.