Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: D3D11 fails with NoSuitableGraphicsDeviceException in Wine #199

Open
madewokherd opened this issue Feb 22, 2024 · 9 comments
Open
Labels

Comments

@madewokherd
Copy link

Tested for merging into Wine Mono, but this most likely affects Wine generally. I used One Finger Death Punch to test.

Excerpt of terminal output:

01ac:fixme:d3d11:d3d11_device_CheckFormatSupport iface 02BBD018, format 28, format_support 0060E404 partial-stub!

Unhandled Exception:
Microsoft.Xna.Framework.Graphics.NoSuitableGraphicsDeviceException: Unsupported backbuffer DXGI format
  at Microsoft.Xna.Framework.Graphics.GraphicsDevice..ctor (Microsoft.Xna.Framework.Graphics.GraphicsAdapter adapter, Microsoft.Xna.Framework.Graphics.GraphicsProfile graphicsProfile, Microsoft.Xna.Framework
.Graphics.PresentationParameters presentationParameters) [0x000e8] in <4f068e9dcd4d43d0a8fa447441bae910>:0 
  at Microsoft.Xna.Framework.GraphicsDeviceManager.Microsoft.Xna.Framework.IGraphicsDeviceManager.CreateDevice () [0x000db] in <4f068e9dcd4d43d0a8fa447441bae910>:0 
  at Microsoft.Xna.Framework.Game.DoInitialize () [0x00031] in <4f068e9dcd4d43d0a8fa447441bae910>:0 
  at Microsoft.Xna.Framework.Game.Run () [0x00011] in <4f068e9dcd4d43d0a8fa447441bae910>:0 
  at One_Finger_Death_Punch.Program.Main (System.String[] args) [0x00008] in <3ace895f2277420d87519d83d7f08e21>:0 

So it's probably something with Wine's CheckFormatSupport stub.

@madewokherd
Copy link
Author

Forgot to mention: the first bad commit is 508d572

@madewokherd

This comment was marked as outdated.

@madewokherd
Copy link
Author

Let me know if reporting this to Winehq would be appropriate. I'm kinda in over my head here.

@flibitijibibo
Copy link
Member

Looks like WineD3D is missing the SUPPORT_DISPLAY flags, which are required for some formats depending on the feature level: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/bb173064(v=vs.85)

This will likely come up more often as HDR adoption in particular increases.

@flibitijibibo
Copy link
Member

flibitijibibo commented Feb 26, 2024

Not sure if the WineHQ Bugzilla has a ticket yet, but I wrote a quick patch that would fix this for WineD3D:

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 061fd57fe09..bfe0a92f805 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -3960,6 +3960,32 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device2 *
                 | D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD;
     }
 
+    if (feature_level >= D3D_FEATURE_LEVEL_9_1)
+    {
+        if (format == DXGI_FORMAT_R8G8B8A8_UNORM ||
+                format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB ||
+                format == DXGI_FORMAT_B8G8R8A8_UNORM ||
+                format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB)
+        {
+            *format_support |= D3D11_FORMAT_SUPPORT_DISPLAY;
+        }
+    }
+    if (feature_level >= D3D_FEATURE_LEVEL_10_0)
+    {
+        if (format == DXGI_FORMAT_R16G16B16A16_FLOAT ||
+                format == DXGI_FORMAT_R10G10B10A2_UNORM)
+        {
+            *format_support |= D3D11_FORMAT_SUPPORT_DISPLAY;
+        }
+    }
+    if (feature_level >= D3D_FEATURE_LEVEL_11_0)
+    {
+        if (format == DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM)
+        {
+            *format_support |= D3D11_FORMAT_SUPPORT_DISPLAY;
+        }
+    }
+
     return *format_support ? S_OK : E_FAIL;
 }
 

I'm sure the WineD3D team would want something more thorough/accurate-to-hardware but this at least covers the surface formats mandated by the D3D feature levels!

@madewokherd
Copy link
Author

They might be OK with a partial solution like this.

@flibitijibibo
Copy link
Member

Since we didn't have any other commits this month I went ahead and added a quick workaround that should make XNA games happy:

085e573

We'll undo this when WineD3D is caught up! Will keep this issue open to track on our end.

@madewokherd
Copy link
Author

Thanks, it works so I just merged the update. At some point I'll file a Winehq bug and link it here.

@madewokherd
Copy link
Author

Filed a Winehq bug: https://bugs.winehq.org/show_bug.cgi?id=56383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants