[PATCH] wined3d: Raise the default max_gl_version for specific cases.

Henri Verbeet hverbeet at codeweavers.com
Thu Dec 7 09:38:27 CST 2017


Effectively, this will enable Direct3D 11 by default on AMD and Intel
hardware.

Yes, this patch is awful.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/directx.c         | 22 ++++++++++++++++++++--
 dlls/wined3d/wined3d_main.c    | 11 +++++------
 dlls/wined3d/wined3d_private.h |  1 +
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index cc8a78c..c145944 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -6527,6 +6527,22 @@ static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc
     }
 }
 
+static DWORD get_max_gl_version(const struct wined3d_gl_info *gl_info, DWORD flags)
+{
+    const char *gl_vendor, *gl_renderer;
+
+    if (wined3d_settings.explicit_gl_version || (flags & WINED3D_PIXEL_CENTER_INTEGER))
+        return wined3d_settings.max_gl_version;
+
+    gl_vendor = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
+    gl_renderer = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
+    if (!gl_vendor || !gl_renderer
+            || wined3d_guess_card_vendor(gl_vendor, gl_renderer) == HW_VENDOR_NVIDIA)
+        return wined3d_settings.max_gl_version;
+
+    return MAKEDWORD_VERSION(4, 4);
+}
+
 static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, DWORD wined3d_creation_flags)
 {
     static const DWORD supported_gl_versions[] =
@@ -6539,6 +6555,7 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal,
     struct wined3d_caps_gl_ctx caps_gl_ctx = {0};
     unsigned int i;
     DISPLAY_DEVICEW display_device;
+    DWORD max_gl_version;
 
     TRACE("adapter %p, ordinal %u.\n", adapter, ordinal);
 
@@ -6583,15 +6600,16 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal,
         return FALSE;
     }
 
+    max_gl_version = get_max_gl_version(gl_info, wined3d_creation_flags);
     for (i = 0; i < ARRAY_SIZE(supported_gl_versions); ++i)
     {
-        if (supported_gl_versions[i] <= wined3d_settings.max_gl_version)
+        if (supported_gl_versions[i] <= max_gl_version)
             break;
     }
     if (i == ARRAY_SIZE(supported_gl_versions))
     {
         ERR_(winediag)("Requested invalid GL version %u.%u.\n",
-                wined3d_settings.max_gl_version >> 16, wined3d_settings.max_gl_version & 0xffff);
+                max_gl_version >> 16, max_gl_version & 0xffff);
         i = ARRAY_SIZE(supported_gl_versions) - 1;
     }
 
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index 54ddc23..28a34a7 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -73,6 +73,7 @@ static CRITICAL_SECTION wined3d_wndproc_cs = {&wined3d_wndproc_cs_debug, -1, 0,
 struct wined3d_settings wined3d_settings =
 {
     FALSE,          /* No multithreaded CS by default. */
+    FALSE,          /* explicit_gl_version */
     MAKEDWORD_VERSION(1, 0), /* Default to legacy OpenGL */
     TRUE,           /* Use of GLSL enabled by default */
     ORM_FBO,        /* Use FBOs to do offscreen rendering */
@@ -215,12 +216,10 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
             ERR_(winediag)("Setting multithreaded command stream to %#x.\n", wined3d_settings.cs_multithreaded);
         if (!get_config_key_dword(hkey, appkey, "MaxVersionGL", &tmpvalue))
         {
-            if (tmpvalue != wined3d_settings.max_gl_version)
-            {
-                ERR_(winediag)("Setting maximum allowed wined3d GL version to %u.%u.\n",
-                        tmpvalue >> 16, tmpvalue & 0xffff);
-                wined3d_settings.max_gl_version = tmpvalue;
-            }
+            ERR_(winediag)("Setting maximum allowed wined3d GL version to %u.%u.\n",
+                    tmpvalue >> 16, tmpvalue & 0xffff);
+            wined3d_settings.explicit_gl_version = TRUE;
+            wined3d_settings.max_gl_version = tmpvalue;
         }
         if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) )
         {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a79a68f..f03733d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -382,6 +382,7 @@ static inline void wined3d_pause(void)
 struct wined3d_settings
 {
     unsigned int cs_multithreaded;
+    BOOL explicit_gl_version;
     DWORD max_gl_version;
     BOOL glslRequested;
     int offscreen_rendering_mode;
-- 
2.1.4




More information about the wine-devel mailing list