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

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.

Sorry for having overlooked your last post of yesterday, but it crossed with my post.
Thanks for your attention.
The point is exactly this: GetMaxMultiSampleCount(GraphicsDevice device) is called byPlatformInitializeAfterResources(GraphicsDevice device) which is called by InitializeAfterResources(GraphicsDevice device) within GraphicsCapabilities.cs which is called by Initialize() within GraphicsDevice.cs. However within Initialize() the call to InitializeAfterResources is preceded by a call to PlatformInitialize(). Within PlatformInitialize there is the creation of _swapChain basing on PresentationParameters.MultiSampleCount which does not yet have the correct value. Therefore the exception.
In fact I did some code chunk switching (modifying the order of operations) and got a working version (only for Windows).
Probably the exception does not occur often because usually platforms accept PresentationParameters.MultiSampleCount = 32, which is the default value. I however have a Notebook that has some year, and it accepts as a maximum only PresentationParameters.MultiSampleCount = 8.
You probably can get the exception too if you replace 32 with a higher value that your platform can’t support within
private const int MultiSampleCountLimit = 32;
in GraphicsCapabilities.cs
and within
presentationParameters.MultiSampleCount = GraphicsDevice != null
? GraphicsDevice.GraphicsCapabilities.MaxMultiSampleCount
: 32;
in GraphicsDeviceManager.cs.
So I think the code should be revisited.

Make sure you’re using a recent build. This was fixed in https://github.com/MonoGame/MonoGame/pull/5477
Develop no longer has the code you’re referring to.

I’m getting a unit test failure with max multisample count with latest develop branch since I upgraded my graphics card. May be related to this as well. Haven’t diagnosed the issue yet.

In effect I believed I was using the development branch, but it wasn’t so. I’m quite new in the git world.
Now that I’m using the real development branch I don’t get any more that exception.
Jjagg, thank you very much for your support and sorry for the time you spent on this non-issue.

I get another exception later during game loading, but if necessary I’ll open a new topic for that.

1 Like

Trying to use Monogame (ver 3.7.1) in Visual Studio 2019.
Using Windows 10, Intel G45/43 chipset (it’s an old chip, I know, but it’s updated to newest version).

Everything works out okay (found templates, can build game), UNTIL I go to actually Start the game on my PC (and have the game window appear); then I’m getting the error that it ‘failed to create graphics device.’ I can successfully build the project but can’t launch the game window.

I am unable to find any line that mentions ‘multisampling’ or anything like that in my Game.cs file (or elsewhere within the project), otherwise I’d just comment it out.


EDIT: 1/17/20

Hmm, this is how I fixed this problem.

Running: Windows 10, with integrated graphics card (Intel G45/G43), Visual Studio 19, Monogame 3.7.1

Project Structure: Solution(from blank solution) > Game.Shared, Game.Android, Game.OpenGL (followed this guide on creating a Cross-Platform project, method number 3, where before I only had 1 Cross Platform Desktop project, Shared project is the main project ).

I simply commented out the 'using Microsoft.Xna.Framework.Storage;" line and the app will build and deploy to an Android device.**

I have been unable to get the game to launch to android device AND load content. I can launch it WITHOUT content (by commenting out the line), or I can build it with content BUT can’t deploy to a device. I don’t have any references to XNA libraries on any of my projects.
No nuGet’s installed. I will gladly send a .zip of my project if anyone wants the whole code.