[PATCH] DDraw: Beware of the surface type when checing for =
Stefan Doesinger
stefan at codeweavers.com
Wed Aug 27 10:42:40 CDT 2008
format support=0A=
=0A=
---=0A=
dlls/d3d8/directx.c | 2 +-=0A=
dlls/d3d9/directx.c | 2 +-=0A=
dlls/ddraw/ddraw.c | 6 +++-=0A=
dlls/ddraw/device.c | 9 ++++--=0A=
dlls/ddraw/direct3d.c | 3 +-=0A=
dlls/wined3d/directx.c | 57 =
++++++++++++++++++++++++++++++++++----=0A=
include/wine/wined3d_interface.h | 4 +-=0A=
7 files changed, 68 insertions(+), 15 deletions(-)=0A=
=0A=
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c=0A=
index 6bffcb1..afcb0fe 100644=0A=
--- a/dlls/d3d8/directx.c=0A=
+++ b/dlls/d3d8/directx.c=0A=
@@ -184,7 +184,7 @@ static HRESULT WINAPI =
IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 i=0A=
=0A=
EnterCriticalSection(&d3d8_cs);=0A=
hr =3D IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, =
DeviceType, AdapterFormat,=0A=
- Usage, RType, CheckFormat);=0A=
+ Usage, RType, CheckFormat, =
SURFACE_OPENGL);=0A=
LeaveCriticalSection(&d3d8_cs);=0A=
return hr;=0A=
}=0A=
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c=0A=
index 78244ec..b605f44 100644=0A=
--- a/dlls/d3d9/directx.c=0A=
+++ b/dlls/d3d9/directx.c=0A=
@@ -186,7 +186,7 @@ static HRESULT WINAPI =
IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9EX iface,=0A=
=0A=
EnterCriticalSection(&d3d9_cs);=0A=
hr =3D IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, =
DeviceType, AdapterFormat,=0A=
- Usage, RType, CheckFormat);=0A=
+ Usage, RType, CheckFormat, =
SURFACE_OPENGL);=0A=
LeaveCriticalSection(&d3d9_cs);=0A=
return hr;=0A=
}=0A=
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c=0A=
index 436846c..1728c96 100644=0A=
--- a/dlls/ddraw/ddraw.c=0A=
+++ b/dlls/ddraw/ddraw.c=0A=
@@ -887,6 +887,7 @@ IDirectDrawImpl_GetFourCCCodes(IDirectDraw7 *iface,=0A=
DWORD count =3D 0, i, outsize;=0A=
HRESULT hr;=0A=
WINED3DDISPLAYMODE d3ddm;=0A=
+ WINED3DSURFTYPE type =3D This->ImplType;=0A=
TRACE("(%p)->(%p, %p)\n", This, NumCodes, Codes);=0A=
=0A=
IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,=0A=
@@ -895,6 +896,8 @@ IDirectDrawImpl_GetFourCCCodes(IDirectDraw7 *iface,=0A=
=0A=
outsize =3D NumCodes && Codes ? *NumCodes : 0;=0A=
=0A=
+ if(type =3D=3D SURFACE_UNKNOWN) type =3D SURFACE_GDI;=0A=
+=0A=
for(i =3D 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {=0A=
hr =3D IWineD3D_CheckDeviceFormat(This->wineD3D,=0A=
WINED3DADAPTER_DEFAULT,=0A=
@@ -902,7 +905,8 @@ IDirectDrawImpl_GetFourCCCodes(IDirectDraw7 *iface,=0A=
d3ddm.Format /* AdapterFormat =
*/,=0A=
0 /* usage */,=0A=
WINED3DRTYPE_SURFACE,=0A=
- formats[i]);=0A=
+ formats[i],=0A=
+ type);=0A=
if(SUCCEEDED(hr)) {=0A=
if(count < outsize) {=0A=
Codes[count] =3D formats[i];=0A=
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c=0A=
index edcb88f..94f3949 100644=0A=
--- a/dlls/ddraw/device.c=0A=
+++ b/dlls/ddraw/device.c=0A=
@@ -1210,7 +1210,8 @@ =
IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,=0A=
0 /* AdapterFormat */,=0A=
0 /* Usage */,=0A=
0 /* ResourceType */,=0A=
- FormatList[i]);=0A=
+ FormatList[i],=0A=
+ SURFACE_OPENGL);=0A=
if(hr =3D=3D D3D_OK)=0A=
{=0A=
DDPIXELFORMAT pformat;=0A=
@@ -1238,7 +1239,8 @@ =
IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,=0A=
0 /* AdapterFormat */,=0A=
=
WINED3DUSAGE_QUERY_LEGACYBUMPMAP,=0A=
0 /* ResourceType */,=0A=
- BumpFormatList[i]);=0A=
+ BumpFormatList[i],=0A=
+ SURFACE_OPENGL);=0A=
if(hr =3D=3D D3D_OK)=0A=
{=0A=
DDPIXELFORMAT pformat;=0A=
@@ -1347,7 +1349,8 @@ =
IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,=0A=
0 /* AdapterFormat */,=0A=
0 /* Usage */,=0A=
0 /* ResourceType */,=0A=
- FormatList[i]);=0A=
+ FormatList[i],=0A=
+ SURFACE_OPENGL);=0A=
if(hr =3D=3D D3D_OK)=0A=
{=0A=
DDSURFACEDESC sdesc;=0A=
diff --git a/dlls/ddraw/direct3d.c b/dlls/ddraw/direct3d.c=0A=
index 6c47e69..d3ce886 100644=0A=
--- a/dlls/ddraw/direct3d.c=0A=
+++ b/dlls/ddraw/direct3d.c=0A=
@@ -1205,7 +1205,8 @@ IDirect3DImpl_7_EnumZBufferFormats(IDirect3D7 =
*iface,=0A=
d3ddm.Format /* AdapterFormat =
*/,=0A=
WINED3DUSAGE_DEPTHSTENCIL /* =
Usage */,=0A=
WINED3DRTYPE_SURFACE,=0A=
- FormatList[i]);=0A=
+ FormatList[i],=0A=
+ SURFACE_OPENGL);=0A=
if(hr =3D=3D D3D_OK)=0A=
{=0A=
DDPIXELFORMAT pformat;=0A=
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c=0A=
index d269406..67a6fa6 100644=0A=
--- a/dlls/wined3d/directx.c=0A=
+++ b/dlls/wined3d/directx.c=0A=
@@ -148,7 +148,7 @@ static const struct {=0A=
static int numAdapters =3D 0;=0A=
static struct WineD3DAdapter Adapters[1];=0A=
=0A=
-static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, =
UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, =
DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat);=0A=
+static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, =
UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, =
DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat, =
WINED3DSURFTYPE SurfaceType);=0A=
static const struct fragment_pipeline =
*select_fragment_implementation(UINT Adapter, WINED3DDEVTYPE DeviceType);=0A=
static const shader_backend_t *select_shader_backend(UINT Adapter, =
WINED3DDEVTYPE DeviceType);=0A=
static const struct blit_shader *select_blit_implementation(UINT =
Adapter, WINED3DDEVTYPE DeviceType);=0A=
@@ -1954,7 +1954,7 @@ static HRESULT WINAPI =
IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter=0A=
}=0A=
=0A=
/* Use CheckDeviceFormat to see if the BackBufferFormat is usable =
with the given DisplayFormat */=0A=
- hr =3D IWineD3DImpl_CheckDeviceFormat(iface, Adapter, DeviceType, =
DisplayFormat, WINED3DUSAGE_RENDERTARGET, WINED3DRTYPE_SURFACE, =
BackBufferFormat);=0A=
+ hr =3D IWineD3DImpl_CheckDeviceFormat(iface, Adapter, DeviceType, =
DisplayFormat, WINED3DUSAGE_RENDERTARGET, WINED3DRTYPE_SURFACE, =
BackBufferFormat, SURFACE_OPENGL);=0A=
if(FAILED(hr))=0A=
TRACE_(d3d_caps)("Unsupported display/backbuffer format =
combination %s/%s\n", debug_d3dformat(DisplayFormat), =
debug_d3dformat(BackBufferFormat));=0A=
=0A=
@@ -2421,9 +2421,37 @@ static BOOL CheckTextureCapability(UINT Adapter, =
WINED3DDEVTYPE DeviceType, WINE=0A=
return FALSE;=0A=
}=0A=
=0A=
-static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT =
AdapterFormat, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat) {=0A=
+static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT =
AdapterFormat, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat, =
WINED3DSURFTYPE SurfaceType) {=0A=
const struct blit_shader *blitter;=0A=
=0A=
+ if(SurfaceType =3D=3D SURFACE_GDI) {=0A=
+ switch(CheckFormat) {=0A=
+ case WINED3DFMT_R8G8B8:=0A=
+ case WINED3DFMT_A8R8G8B8:=0A=
+ case WINED3DFMT_X8R8G8B8:=0A=
+ case WINED3DFMT_R5G6B5:=0A=
+ case WINED3DFMT_X1R5G5B5:=0A=
+ case WINED3DFMT_A1R5G5B5:=0A=
+ case WINED3DFMT_A4R4G4B4:=0A=
+ case WINED3DFMT_R3G3B2:=0A=
+ case WINED3DFMT_A8:=0A=
+ case WINED3DFMT_A8R3G3B2:=0A=
+ case WINED3DFMT_X4R4G4B4:=0A=
+ case WINED3DFMT_A2B10G10R10:=0A=
+ case WINED3DFMT_A8B8G8R8:=0A=
+ case WINED3DFMT_X8B8G8R8:=0A=
+ case WINED3DFMT_G16R16:=0A=
+ case WINED3DFMT_A2R10G10B10:=0A=
+ case WINED3DFMT_A16B16G16R16:=0A=
+ case WINED3DFMT_P8:=0A=
+ TRACE_(d3d_caps)("[OK]\n");=0A=
+ return TRUE;=0A=
+ default:=0A=
+ TRACE_(d3d_caps)("[FAILED] - not available on GDI =
surfaces\n");=0A=
+ return FALSE;=0A=
+ }=0A=
+ }=0A=
+=0A=
/* All format that are supported for textures are supported for =
surfaces as well */=0A=
if(CheckTextureCapability(Adapter, DeviceType, CheckFormat)) return =
TRUE;=0A=
/* All depth stencil formats are supported on surfaces */=0A=
@@ -2465,7 +2493,8 @@ static BOOL CheckVertexTextureCapability(UINT =
Adapter, WINED3DFORMAT CheckFormat=0A=
}=0A=
=0A=
static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, =
UINT Adapter, WINED3DDEVTYPE DeviceType, =0A=
- WINED3DFORMAT =
AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT =
CheckFormat) {=0A=
+ WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE =
RType, WINED3DFORMAT CheckFormat,=0A=
+ WINED3DSURFTYPE SurfaceType) {=0A=
IWineD3DImpl *This =3D (IWineD3DImpl *)iface;=0A=
DWORD UsageCaps =3D 0;=0A=
=0A=
@@ -2483,6 +2512,12 @@ static HRESULT WINAPI =
IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt=0A=
}=0A=
=0A=
if(RType =3D=3D WINED3DRTYPE_CUBETEXTURE) {=0A=
+=0A=
+ if(SurfaceType !=3D SURFACE_OPENGL) {=0A=
+ TRACE("[FAILED]\n");=0A=
+ return WINED3DERR_NOTAVAILABLE;=0A=
+ }=0A=
+=0A=
/* Cubetexture allows:=0A=
* - D3DUSAGE_AUTOGENMIPMAP=0A=
* - D3DUSAGE_DEPTHSTENCIL=0A=
@@ -2596,7 +2631,7 @@ static HRESULT WINAPI =
IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt=0A=
* - D3DUSAGE_RENDERTARGET=0A=
*/=0A=
=0A=
- if(CheckSurfaceCapability(Adapter, AdapterFormat, DeviceType, =
CheckFormat)) {=0A=
+ if(CheckSurfaceCapability(Adapter, AdapterFormat, DeviceType, =
CheckFormat, SurfaceType)) {=0A=
if(Usage & WINED3DUSAGE_DEPTHSTENCIL) {=0A=
if(CheckDepthStencilCapability(Adapter, AdapterFormat, =
CheckFormat)) {=0A=
UsageCaps |=3D WINED3DUSAGE_DEPTHSTENCIL;=0A=
@@ -2642,6 +2677,11 @@ static HRESULT WINAPI =
IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt=0A=
* - D3DUSAGE_QUERY_WRAPANDMIP=0A=
*/=0A=
=0A=
+ if(SurfaceType !=3D SURFACE_OPENGL) {=0A=
+ TRACE("[FAILED]\n");=0A=
+ return WINED3DERR_NOTAVAILABLE;=0A=
+ }=0A=
+=0A=
/* Check if the texture format is around */=0A=
if(CheckTextureCapability(Adapter, DeviceType, CheckFormat)) {=0A=
if(Usage & WINED3DUSAGE_AUTOGENMIPMAP) {=0A=
@@ -2764,6 +2804,11 @@ static HRESULT WINAPI =
IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt=0A=
* - D3DUSAGE_QUERY_WRAPANDMIP=0A=
*/=0A=
=0A=
+ if(SurfaceType !=3D SURFACE_OPENGL) {=0A=
+ TRACE("[FAILED]\n");=0A=
+ return WINED3DERR_NOTAVAILABLE;=0A=
+ }=0A=
+=0A=
/* Check volume texture and volume usage caps */=0A=
if(GL_SUPPORT(EXT_TEXTURE3D)) {=0A=
if(CheckTextureCapability(Adapter, DeviceType, CheckFormat) =
=3D=3D FALSE) {=0A=
@@ -2896,7 +2941,7 @@ static HRESULT WINAPI =
IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt=0A=
/* For instance vertexbuffer/indexbuffer aren't supported yet =
because no Windows drivers seem to offer it */=0A=
TRACE_(d3d_caps)("Unhandled resource type D3DRTYPE_INDEXBUFFER =
/ D3DRTYPE_VERTEXBUFFER\n");=0A=
return WINED3DERR_NOTAVAILABLE;=0A=
- }=0A=
+ }=0A=
=0A=
/* This format is nothing special and it is supported perfectly.=0A=
* However, ati and nvidia driver on windows do not mark this =
format as=0A=
diff --git a/include/wine/wined3d_interface.h =
b/include/wine/wined3d_interface.h=0A=
index 4b960d5..6ecab39 100644=0A=
--- a/include/wine/wined3d_interface.h=0A=
+++ b/include/wine/wined3d_interface.h=0A=
@@ -310,7 +310,7 @@ DECLARE_INTERFACE_(IWineD3D, IWineD3DBase)=0A=
STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter, =
WINED3DDEVTYPE DeviceType, WINED3DFORMAT SurfaceFormat, BOOL =
Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQuality) =
PURE;=0A=
STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter, =
WINED3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, WINED3DFORMAT =
RenderTargetFormat, WINED3DFORMAT DepthStencilFormat) PURE;=0A=
STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter, WINED3DDEVTYPE =
CheckType, WINED3DFORMAT DisplayFormat, WINED3DFORMAT =
BackBufferFormat, BOOL Windowed) PURE;=0A=
- STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, WINED3DDEVTYPE =
DeviceType, WINED3DFORMAT AdapterFormat, DWORD Usage, =
WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) PURE;=0A=
+ STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, WINED3DDEVTYPE =
DeviceType, WINED3DFORMAT AdapterFormat, DWORD Usage, =
WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat, WINED3DSURFTYPE =
SurfaceType) PURE;=0A=
STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, =
WINED3DDEVTYPE DeviceType, WINED3DFORMAT SourceFormat, WINED3DFORMAT =
TargetFormat) PURE;=0A=
STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, WINED3DDEVTYPE =
DeviceType, WINED3DCAPS *pCaps) PURE;=0A=
STDMETHOD(CreateDevice)(THIS_ UINT Adapter, WINED3DDEVTYPE =
DeviceType,HWND hFocusWindow, DWORD BehaviorFlags, struct =
IWineD3DDevice **ppReturnedDeviceInterface, IUnknown *parent) PURE;=0A=
@@ -336,7 +336,7 @@ DECLARE_INTERFACE_(IWineD3D, IWineD3DBase)=0A=
#define IWineD3D_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) =
(p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e,f)=0A=
#define IWineD3D_CheckDepthStencilMatch(p,a,b,c,d,e) =
(p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e)=0A=
#define IWineD3D_CheckDeviceType(p,a,b,c,d,e) =
(p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e)=0A=
-#define IWineD3D_CheckDeviceFormat(p,a,b,c,d,e,f) =
(p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f)=0A=
+#define IWineD3D_CheckDeviceFormat(p,a,b,c,d,e,f,g) =
(p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f,g)=0A=
#define IWineD3D_CheckDeviceFormatConversion(p,a,b,c,d) =
(p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d)=0A=
#define IWineD3D_GetDeviceCaps(p,a,b,c) =
(p)->lpVtbl->GetDeviceCaps(p,a,b,c)=0A=
#define IWineD3D_CreateDevice(p,a,b,c,d,e,f) =
(p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f)=0A=
-- =0A=
1.5.6.4=0A=
=0A=
------=_NextPart_000_0039_01C909E1.87FFCE30--
More information about the wine-patches
mailing list