Commit e4816996 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Handle the "DirectDrawRenderer" registry key in wined3d.

parent b886d067
......@@ -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,
......
......@@ -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
{
......
......@@ -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");
......
......@@ -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)
{
......
......@@ -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 );
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment