[PATCH 2/5] ddraw: Handle the "DirectDrawRenderer" registry key in wined3d.
Henri Verbeet
hverbeet at codeweavers.com
Thu May 30 03:05:33 CDT 2013
---
dlls/ddraw/ddraw.c | 35 ++++++++++++------------
dlls/ddraw/ddraw_private.h | 8 +-----
dlls/ddraw/device.c | 2 +-
dlls/ddraw/main.c | 61 +++---------------------------------------
dlls/wined3d/wined3d_main.c | 10 +++++++
dlls/wined3d/wined3d_private.h | 1 +
6 files changed, 35 insertions(+), 82 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 7eda266..6836d12 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -366,7 +366,7 @@ void ddraw_destroy_swapchain(struct ddraw *ddraw)
wined3d_swapchain_decref(ddraw->wined3d_swapchain);
ddraw->wined3d_swapchain = NULL;
- if (DefaultSurfaceType == DDRAW_SURFACE_TYPE_OPENGL)
+ if (!(ddraw->flags & DDRAW_NO3D))
{
UINT i;
@@ -629,7 +629,7 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win
swapchain_desc.device_window = window;
swapchain_desc.windowed = windowed;
- if (DefaultSurfaceType == DDRAW_SURFACE_TYPE_OPENGL)
+ if (!(ddraw->flags & DDRAW_NO3D))
hr = ddraw_attach_d3d_device(ddraw, &swapchain_desc);
else
hr = wined3d_device_init_gdi(ddraw->wined3d_device, &swapchain_desc);
@@ -850,7 +850,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND windo
if (This->wined3d_swapchain)
{
- if (DefaultSurfaceType != DDRAW_SURFACE_TYPE_GDI)
+ if (!(This->flags & DDRAW_NO3D))
{
restore_state = TRUE;
@@ -1206,13 +1206,6 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD
caps.dwSSBCKeyCaps = winecaps.ddraw_caps.ssb_color_key_caps;
caps.dwSSBFXCaps = winecaps.ddraw_caps.ssb_fx_caps;
- /* Even if wined3d supports 3D rendering, remove the cap if ddraw is
- * configured not to use it. */
- if (DefaultSurfaceType == DDRAW_SURFACE_TYPE_GDI)
- {
- caps.dwCaps &= ~DDCAPS_3D;
- caps.ddsCaps.dwCaps &= ~(DDSCAPS_3DDEVICE | DDSCAPS_MIPMAP | DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER);
- }
if (winecaps.ddraw_caps.stride_align)
{
caps.dwCaps |= DDCAPS_ALIGNSTRIDE;
@@ -2469,9 +2462,9 @@ static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *pDDSD,
DDRAW_dump_surface_desc(pDDSD);
}
- if ((pDDSD->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && DefaultSurfaceType != DDRAW_SURFACE_TYPE_OPENGL)
+ if ((pDDSD->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && (ddraw->flags & DDRAW_NO3D))
{
- WARN("The application requests a 3D capable surface, but a non-OpenGL surface type was set in the registry.\n");
+ WARN("The application requests a 3D capable surface, but the ddraw object was created without 3D support.\n");
/* Do not fail surface creation, only fail 3D device creation. */
}
@@ -5219,6 +5212,7 @@ static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops =
HRESULT ddraw_init(struct ddraw *ddraw, enum wined3d_device_type device_type)
{
+ WINED3DCAPS caps;
DWORD flags;
HRESULT hr;
@@ -5235,19 +5229,26 @@ HRESULT ddraw_init(struct ddraw *ddraw, enum wined3d_device_type device_type)
ddraw->ref7 = 1;
flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING;
- if (DefaultSurfaceType != DDRAW_SURFACE_TYPE_OPENGL)
- flags |= WINED3D_NO3D;
-
if (!(ddraw->wined3d = wined3d_create(7, flags)))
{
- if ((flags & WINED3D_NO3D) || !(ddraw->wined3d = wined3d_create(7, flags | WINED3D_NO3D)))
+ if (!(ddraw->wined3d = wined3d_create(7, flags | WINED3D_NO3D)))
{
WARN("Failed to create a wined3d object.\n");
return E_FAIL;
}
+ }
+
+ if (FAILED(hr = wined3d_get_device_caps(ddraw->wined3d, WINED3DADAPTER_DEFAULT, device_type, &caps)))
+ {
+ ERR("Failed to get device caps, hr %#x.\n", hr);
+ wined3d_decref(ddraw->wined3d);
+ return E_FAIL;
+ }
+ if (!(caps.ddraw_caps.caps & WINEDDCAPS_3D))
+ {
WARN("Created a wined3d object without 3D support.\n");
- DefaultSurfaceType = DDRAW_SURFACE_TYPE_GDI;
+ ddraw->flags |= DDRAW_NO3D;
}
hr = wined3d_device_create(ddraw->wined3d, WINED3DADAPTER_DEFAULT, device_type,
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 6b4fedc..8377732 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -37,14 +37,7 @@
#include "wine/list.h"
#include "wine/wined3d.h"
-enum ddraw_surface_type
-{
- DDRAW_SURFACE_TYPE_OPENGL,
- DDRAW_SURFACE_TYPE_GDI,
-};
-
extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN;
-extern enum ddraw_surface_type DefaultSurfaceType DECLSPEC_HIDDEN;
extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
/*****************************************************************************
@@ -59,6 +52,7 @@ struct FvfToDecl
#define DDRAW_INITIALIZED 0x00000001
#define DDRAW_D3D_INITIALIZED 0x00000002
#define DDRAW_RESTORE_MODE 0x00000004
+#define DDRAW_NO3D 0x00000008
struct ddraw
{
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 6659735..64f5537 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -6741,7 +6741,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target,
TRACE("ddraw %p, target %p, version %u, device %p, outer_unknown %p.\n",
ddraw, target, version, device, outer_unknown);
- if (DefaultSurfaceType != DDRAW_SURFACE_TYPE_OPENGL)
+ if (ddraw->flags & DDRAW_NO3D)
{
ERR_(winediag)("The application wants to create a Direct3D device, "
"but the current DirectDrawRenderer does not support this.\n");
diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c
index aaa4032..8e7b098 100644
--- a/dlls/ddraw/main.c
+++ b/dlls/ddraw/main.c
@@ -36,9 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
-/* The configured default surface */
-enum ddraw_surface_type DefaultSurfaceType = DDRAW_SURFACE_TYPE_OPENGL;
-
static struct list global_ddraw_list = LIST_INIT(global_ddraw_list);
static HINSTANCE instance;
@@ -371,7 +368,6 @@ HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA callback, void *context)
HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA callback, void *context, DWORD flags)
{
struct wined3d *wined3d;
- DWORD wined3d_flags;
TRACE("callback %p, context %p, flags %#x.\n", callback, context, flags);
@@ -383,21 +379,16 @@ HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA callback, void *contex
if (flags)
FIXME("flags 0x%08x not handled\n", flags);
- wined3d_flags = WINED3D_LEGACY_DEPTH_BIAS;
- if (DefaultSurfaceType != DDRAW_SURFACE_TYPE_OPENGL)
- wined3d_flags |= WINED3D_NO3D;
-
TRACE("Enumerating ddraw interfaces\n");
- if (!(wined3d = wined3d_create(7, wined3d_flags)))
+ if (!(wined3d = wined3d_create(7, WINED3D_LEGACY_DEPTH_BIAS)))
{
- if ((wined3d_flags & WINED3D_NO3D) || !(wined3d = wined3d_create(7, wined3d_flags | WINED3D_NO3D)))
+ if (!(wined3d = wined3d_create(7, WINED3D_LEGACY_DEPTH_BIAS | WINED3D_NO3D)))
{
WARN("Failed to create a wined3d object.\n");
return E_FAIL;
}
WARN("Created a wined3d object without 3D support.\n");
- DefaultSurfaceType = DDRAW_SURFACE_TYPE_GDI;
}
__TRY
@@ -856,12 +847,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID reserved)
case DLL_PROCESS_ATTACH:
{
static HMODULE ddraw_self;
- char buffer[MAX_PATH+10];
- DWORD size = sizeof(buffer);
HKEY hkey = 0;
- HKEY appkey = 0;
WNDCLASSA wc;
- DWORD len;
/* Register the window class. This is used to create a hidden window
* for D3D rendering, if the application didn't pass one. It can also
@@ -882,47 +869,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID reserved)
return FALSE;
}
- /* @@ Wine registry key: HKCU\Software\Wine\Direct3D */
- if ( RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey ) ) hkey = 0;
-
- len = GetModuleFileNameA( 0, buffer, MAX_PATH );
- if (len && len < MAX_PATH)
- {
- HKEY tmpkey;
- /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Direct3D */
- if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
- {
- char *p, *appname = buffer;
- if ((p = strrchr( appname, '/' ))) appname = p + 1;
- if ((p = strrchr( appname, '\\' ))) appname = p + 1;
- strcat( appname, "\\Direct3D" );
- TRACE("appname = [%s]\n", appname);
- if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
- RegCloseKey( tmpkey );
- }
- }
-
- if ( 0 != hkey || 0 != appkey )
- {
- if ( !get_config_key( hkey, appkey, "DirectDrawRenderer", buffer, size) )
- {
- if (!strcmp(buffer,"gdi"))
- {
- TRACE("Defaulting to GDI surfaces\n");
- DefaultSurfaceType = DDRAW_SURFACE_TYPE_GDI;
- }
- else if (!strcmp(buffer,"opengl"))
- {
- TRACE("Defaulting to opengl surfaces\n");
- DefaultSurfaceType = DDRAW_SURFACE_TYPE_OPENGL;
- }
- else
- {
- ERR("Unknown default surface type. Supported are:\n gdi, opengl\n");
- }
- }
- }
-
/* On Windows one can force the refresh rate that DirectDraw uses by
* setting an override value in dxdiag. This is documented in KB315614
* (main article), KB230002, and KB217348. By comparing registry dumps
@@ -945,7 +891,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID reserved)
*/
if ( !RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectDraw", &hkey ) )
{
- DWORD type, data;
+ DWORD type, data, size;
+
size = sizeof(data);
if (!RegQueryValueExA( hkey, "ForceRefreshRate", NULL, &type, (LPBYTE)&data, &size ) && type == REG_DWORD)
{
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index 50bee78..62dc462 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -85,6 +85,7 @@ struct wined3d_settings wined3d_settings =
~0U, /* No VS shader model limit by default. */
~0U, /* No GS shader model limit by default. */
~0U, /* No PS shader model limit by default. */
+ FALSE, /* 3D support enabled by default. */
};
/* Do not call while under the GL lock. */
@@ -100,6 +101,9 @@ struct wined3d * CDECL wined3d_create(UINT version, DWORD flags)
return NULL;
}
+ if (version == 7 && wined3d_settings.no_3d)
+ flags |= WINED3D_NO3D;
+
hr = wined3d_init(object, version, flags);
if (FAILED(hr))
{
@@ -309,6 +313,12 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
TRACE("Limiting GS shader model to %u.\n", wined3d_settings.max_sm_gs);
if (!get_config_key_dword(hkey, appkey, "MaxShaderModelPS", &wined3d_settings.max_sm_ps))
TRACE("Limiting PS shader model to %u.\n", wined3d_settings.max_sm_ps);
+ if (!get_config_key(hkey, appkey, "DirectDrawRenderer", buffer, size)
+ && !strcmp(buffer, "gdi"))
+ {
+ TRACE("Disabling 3D support.\n");
+ wined3d_settings.no_3d = TRUE;
+ }
}
if (appkey) RegCloseKey( appkey );
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9e63f2c..cbaa12d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -268,6 +268,7 @@ struct wined3d_settings
unsigned int max_sm_vs;
unsigned int max_sm_gs;
unsigned int max_sm_ps;
+ BOOL no_3d;
};
extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
--
1.8.1.5
More information about the wine-patches
mailing list