[PATCH 2/2] wined3d: Allow setting the renderer using the WINE_D3D_RENDERER environment variable.

Zebediah Figura zfigura at codeweavers.com
Fri Mar 4 17:39:23 CST 2022


This is significantly more convenient, and scriptable, than modifying the
registry.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/wined3d/wined3d_main.c | 41 +++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index 5bddc2587f4..67066dcab42 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -206,6 +206,7 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
     HKEY appkey = 0;
     DWORD tmpvalue;
     WNDCLASSA wc;
+    char *string;
 
     wined3d_context_tls_idx = TlsAlloc();
     if (wined3d_context_tls_idx == TLS_OUT_OF_INDEXES)
@@ -373,24 +374,7 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
             TRACE("Limiting PS shader model to %u.\n", wined3d_settings.max_sm_ps);
         if (!get_config_key_dword(hkey, appkey, "MaxShaderModelCS", &wined3d_settings.max_sm_cs))
             TRACE("Limiting CS shader model to %u.\n", wined3d_settings.max_sm_cs);
-        if (!get_config_key(hkey, appkey, "renderer", buffer, size))
-        {
-            if (!strcmp(buffer, "vulkan"))
-            {
-                ERR_(winediag)("Using the Vulkan renderer.\n");
-                wined3d_settings.renderer = WINED3D_RENDERER_VULKAN;
-            }
-            else if (!strcmp(buffer, "gl"))
-            {
-                ERR_(winediag)("Using the OpenGL renderer.\n");
-                wined3d_settings.renderer = WINED3D_RENDERER_OPENGL;
-            }
-            else if (!strcmp(buffer, "gdi") || !strcmp(buffer, "no3d"))
-            {
-                ERR_(winediag)("Disabling 3D support.\n");
-                wined3d_settings.renderer = WINED3D_RENDERER_NO3D;
-            }
-        }
+
         if (!get_config_key_dword(hkey, appkey, "cb_access_map_w", &tmpvalue) && tmpvalue)
         {
             TRACE("Forcing all constant buffers to be write-mappable.\n");
@@ -398,6 +382,27 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
         }
     }
 
+    if (!(string = getenv("WINE_D3D_RENDERER")) && !get_config_key(hkey, appkey, "renderer", buffer, size))
+        string = buffer;
+    if (string)
+    {
+        if (!strcmp(string, "vulkan"))
+        {
+            ERR_(winediag)("Using the Vulkan renderer.\n");
+            wined3d_settings.renderer = WINED3D_RENDERER_VULKAN;
+        }
+        else if (!strcmp(string, "gl"))
+        {
+            ERR_(winediag)("Using the OpenGL renderer.\n");
+            wined3d_settings.renderer = WINED3D_RENDERER_OPENGL;
+        }
+        else if (!strcmp(string, "gdi") || !strcmp(string, "no3d"))
+        {
+            ERR_(winediag)("Disabling 3D support.\n");
+            wined3d_settings.renderer = WINED3D_RENDERER_NO3D;
+        }
+    }
+
     if (appkey) RegCloseKey( appkey );
     if (hkey) RegCloseKey( hkey );
 
-- 
2.35.1




More information about the wine-devel mailing list