[D3D 17] Re: bug (regression) in ddraw/d3d

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Might be, but since i know next to nothing about win32 programming i can't 
> test it on real windows or give a good comment on that :-)
> Maybe it's a bug in FF8Config which just happen to work, but afaics using only 
> 1 guid and do the cast can't hurt. 

Could you try the attached patch ? It should work and introduce no
regression so I also send it directly to wine-patches.

If it does not work, yell before Alexandre commits it :-)

Changelog:
 Have only one GIUD for Wine's OpenGL D3D device

                                  Lionel

-- 
		 Lionel Ulmer - http://www.bbrox.org/
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3ddevice/mesa.c	2002-12-05 06:43:02.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3ddevice/mesa.c	2002-12-05 06:45:18.000000000 +0100
@@ -45,27 +45,6 @@
   { 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfa }
 };
 
-const GUID IID_D3DDEVICE2_OpenGL = {
-  0x31416d44,
-  0x86ae,
-  0x11d2,
-  { 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfb }
-};
-
-const GUID IID_D3DDEVICE3_OpenGL = {
-  0x31416d44,
-  0x86ae,
-  0x11d2,
-  { 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfc }
-};
-
-const GUID IID_D3DDEVICE7_OpenGL = {
-  0x31416d44,
-  0x86ae,
-  0x11d2,
-  { 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfd }
-};
-
 /* Define this variable if you have an unpatched Mesa 3.0 (patches are available
    on Mesa's home page) or version 3.1b.
 
@@ -275,26 +254,15 @@
 
 
 
-HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD interface_version)
+HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context)
 {
     D3DDEVICEDESC d1, d2;
-    char buf[256];
-    const void *iid = NULL;
-
-    switch (interface_version) {
-        case 1: iid = &IID_D3DDEVICE_OpenGL; break;
-	case 2: iid = &IID_D3DDEVICE2_OpenGL; break;
-	case 3: iid = &IID_D3DDEVICE3_OpenGL; break;
-	case 7: iid = &IID_D3DDEVICE7_OpenGL; break;
-    }
-    strcpy(buf, "WINE Direct3DX using OpenGL");
-    buf[13] = '0' + interface_version;
 
     fill_opengl_caps(&d1);
     d2 = d1;
 
-    TRACE(" enumerating OpenGL D3DDevice%ld interface (IID %s).\n", interface_version, debugstr_guid(iid));
-    return cb((LPGUID) iid, buf, "direct3d", &d1, &d2, context);
+    TRACE(" enumerating OpenGL D3DDevice interface (IID %s).\n", debugstr_guid(&IID_D3DDEVICE_OpenGL));
+    return cb((LPIID) &IID_D3DDEVICE_OpenGL, "WINE Direct3DX using OpenGL", "direct3d", &d1, &d2, context);
 }
 
 HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context)
@@ -462,8 +430,7 @@
 HRESULT
 d3ddevice_find(IDirect3DImpl *d3d,
 	       LPD3DFINDDEVICESEARCH lpD3DDFS,
-	       LPD3DFINDDEVICERESULT lplpD3DDevice,
-	       DWORD interface_version)
+	       LPD3DFINDDEVICERESULT lplpD3DDevice)
 {
     DWORD dwSize;
     D3DDEVICEDESC desc;
@@ -476,23 +443,14 @@
     if (lpD3DDFS->dwFlags & D3DFDS_GUID) {
         TRACE(" trying to match guid %s.\n", debugstr_guid(&(lpD3DDFS->guid)));
 	if ((IsEqualGUID( &IID_D3DDEVICE_OpenGL, &(lpD3DDFS->guid)) == 0) &&
-	    (IsEqualGUID( &IID_D3DDEVICE2_OpenGL, &(lpD3DDFS->guid)) == 0) &&
-	    (IsEqualGUID( &IID_D3DDEVICE3_OpenGL, &(lpD3DDFS->guid)) == 0) &&
-	    (IsEqualGUID( &IID_D3DDEVICE7_OpenGL, &(lpD3DDFS->guid)) == 0) &&
 	    (IsEqualGUID(&IID_IDirect3DHALDevice, &(lpD3DDFS->guid)) == 0)) {
 	    TRACE(" no match for this GUID.\n");
 	    return DDERR_INVALIDPARAMS;
 	}
     }
 
-    /* Now return our own GUIDs according to Direct3D version */
-    if (interface_version == 1) {
-        lplpD3DDevice->guid = IID_D3DDEVICE_OpenGL;
-    } else if (interface_version == 2) {
-        lplpD3DDevice->guid = IID_D3DDEVICE2_OpenGL;
-    } else if (interface_version == 3) {
-        lplpD3DDevice->guid = IID_D3DDEVICE3_OpenGL;
-    }
+    /* Now return our own GUID */
+    lplpD3DDevice->guid = IID_D3DDEVICE_OpenGL;
     fill_opengl_caps(&desc);
     dwSize = lplpD3DDevice->ddHwDesc.dwSize;
     memset(&(lplpD3DDevice->ddHwDesc), 0, dwSize);
--- /home/ulmer/Wine/wine_base//dlls/ddraw/mesa_private.h	2002-11-30 23:45:05.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/mesa_private.h	2002-12-05 06:21:00.000000000 +0100
@@ -57,9 +57,6 @@
 #define LEAVE_GL() wine_tsx11_unlock_ptr()
 
 extern const GUID IID_D3DDEVICE_OpenGL;
-extern const GUID IID_D3DDEVICE2_OpenGL;
-extern const GUID IID_D3DDEVICE3_OpenGL;
-extern const GUID IID_D3DDEVICE7_OpenGL;
 
 typedef struct render_state {
     /* This is used for the device mode */
@@ -123,9 +120,9 @@
 extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surface);
 
 /* Used for Direct3D to request the device to enumerate itself */
-extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD interface_version) ;
+extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) ;
 extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
-extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice, DWORD interface_version);
+extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
 
 /* Some helper functions.. Would need to put them in a better place */
 extern void dump_flexible_vertex(DWORD d3dvtVertexType);
--- /home/ulmer/Wine/wine_base//dlls/ddraw/direct3d/main.c	2002-11-28 23:04:38.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/direct3d/main.c	2002-12-05 06:37:28.000000000 +0100
@@ -170,29 +170,9 @@
 }
 
 HRESULT WINAPI
-Main_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface,
-                                LPD3DFINDDEVICESEARCH lpD3DDFS,
-                                LPD3DFINDDEVICERESULT lplpD3DDevice)
-{
-    ICOM_THIS_FROM(IDirect3DImpl, IDirect3D, iface);
-    FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lplpD3DDevice);
-    return D3D_OK;
-}
-
-HRESULT WINAPI
-Main_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
-				LPD3DFINDDEVICESEARCH lpD3DDFS,
-				LPD3DFINDDEVICERESULT lpD3DFDR)
-{
-    ICOM_THIS_FROM(IDirect3DImpl, IDirect3D2, iface);
-    FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lpD3DFDR);
-    return D3D_OK;
-}
-
-HRESULT WINAPI
-Main_IDirect3DImpl_3_FindDevice(LPDIRECT3D3 iface,
-				LPD3DFINDDEVICESEARCH lpD3DDFS,
-				LPD3DFINDDEVICERESULT lpD3DFDR)
+Main_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface,
+				      LPD3DFINDDEVICESEARCH lpD3DDFS,
+				      LPD3DFINDDEVICERESULT lpD3DFDR)
 {
     ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
     FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lpD3DFDR);
@@ -497,3 +477,25 @@
     
     return ret;
 }
+
+HRESULT WINAPI
+Thunk_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface,
+				 LPD3DFINDDEVICESEARCH lpD3DDFS,
+				 LPD3DFINDDEVICERESULT lplpD3DDevice)
+{
+    TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lplpD3DDevice);
+    return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface),
+				 lpD3DDFS,
+				 lplpD3DDevice);
+}
+
+HRESULT WINAPI
+Thunk_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
+				 LPD3DFINDDEVICESEARCH lpD3DDFS,
+				 LPD3DFINDDEVICERESULT lpD3DFDR)
+{
+    TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lpD3DFDR);
+    return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface),
+				 lpD3DDFS,
+				 lpD3DFDR);
+}
--- /home/ulmer/Wine/wine_base//dlls/ddraw/direct3d/mesa.c	2002-12-02 01:00:29.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/direct3d/mesa.c	2002-12-05 06:33:30.000000000 +0100
@@ -43,45 +43,15 @@
 #define MAX_LIGHTS 8
 
 HRESULT WINAPI
-GL_IDirect3DImpl_1_EnumDevices(LPDIRECT3D iface,
-			       LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
-			       LPVOID lpUserArg)
-{
-    ICOM_THIS_FROM(IDirect3DImpl, IDirect3D, iface);
-    TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
-
-    /* Call functions defined in d3ddevices.c */
-    if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 1) != D3DENUMRET_OK)
-	return D3D_OK;
-
-    return D3D_OK;
-}
-
-HRESULT WINAPI
-GL_IDirect3DImpl_2_EnumDevices(LPDIRECT3D2 iface,
-			       LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
-			       LPVOID lpUserArg)
-{
-    ICOM_THIS_FROM(IDirect3DImpl, IDirect3D2, iface);
-    TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
-
-    /* Call functions defined in d3ddevices.c */
-    if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 2) != D3DENUMRET_OK)
-	return D3D_OK;
-
-    return D3D_OK;
-}
-
-HRESULT WINAPI
-GL_IDirect3DImpl_3_EnumDevices(LPDIRECT3D3 iface,
-			       LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
-			       LPVOID lpUserArg)
+GL_IDirect3DImpl_3_2T_1T_EnumDevices(LPDIRECT3D3 iface,
+				     LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
+				     LPVOID lpUserArg)
 {
     ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
     TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
 
     /* Call functions defined in d3ddevices.c */
-    if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 3) != D3DENUMRET_OK)
+    if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg) != D3DENUMRET_OK)
 	return D3D_OK;
 
     return D3D_OK;
@@ -160,48 +130,29 @@
     ret_value = d3ddevice_create(&lpd3ddev, This, lpDDS);
     if (FAILED(ret_value)) return ret_value;
     
-    if (IsEqualGUID( &IID_D3DDEVICE_OpenGL, iid )) {
-	*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice);
-        TRACE(" returning OpenGL D3DDevice %p\n", *obj);
-	return D3D_OK;
-    }
-    if (IsEqualGUID( &IID_D3DDEVICE2_OpenGL, iid )) {
-	*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice2);
-        TRACE(" returning OpenGL D3DDevice2 %p\n", *obj);
-	return D3D_OK;
-    }
-    if (IsEqualGUID( &IID_D3DDEVICE3_OpenGL, iid )) {
-	*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice3);
-        TRACE(" returning OpenGL D3DDevice3 %p\n", *obj);
-	return D3D_OK;
-    }
-    if (IsEqualGUID( &IID_D3DDEVICE7_OpenGL, iid )) {
-	*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice7);
-        TRACE(" returning OpenGL D3DDevice7 %p\n", *obj);
-	return D3D_OK;
-    }
     if ((iid == NULL) ||
+	(IsEqualGUID(&IID_D3DDEVICE_OpenGL, iid)) ||
 	(IsEqualGUID(&IID_IDirect3DHALDevice, iid)) ||
 	(IsEqualGUID(&IID_IDirect3DTnLHalDevice, iid))) {
         switch (interface) {
 	    case 1:
 		*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice);
-	        TRACE(" returning OpenGL D3DDevice %p via default / HAL interface\n", *obj);
+	        TRACE(" returning OpenGL D3DDevice %p.\n", *obj);
 		return D3D_OK;
 
 	    case 2:
 		*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice2);
-	        TRACE(" returning OpenGL D3DDevice2 %p via default / HAL interface\n", *obj);
+	        TRACE(" returning OpenGL D3DDevice2 %p.\n", *obj);
 		return D3D_OK;
 
 	    case 3:
 		*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice3);
-	        TRACE(" returning OpenGL D3DDevice3 %p via default / HAL interface\n", *obj);
+	        TRACE(" returning OpenGL D3DDevice3 %p.\n", *obj);
 		return D3D_OK;
 
 	    case 7:
 		*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice7);
-	        TRACE(" returning OpenGL D3DDevice7 %p via default / HAL interface\n", *obj);
+	        TRACE(" returning OpenGL D3DDevice7 %p.\n", *obj);
 		return D3D_OK;
         }
     }
@@ -239,33 +190,13 @@
 }
 
 HRESULT WINAPI
-GL_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface,
-			      LPD3DFINDDEVICESEARCH lpD3DDFS,
-			      LPD3DFINDDEVICERESULT lplpD3DDevice)
-{
-    ICOM_THIS_FROM(IDirect3DImpl, IDirect3D, iface);
-    TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DDFS, lplpD3DDevice);
-    return d3ddevice_find(This, lpD3DDFS, lplpD3DDevice, 1);
-}
-
-HRESULT WINAPI
-GL_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
-			      LPD3DFINDDEVICESEARCH lpD3DDFS,
-			      LPD3DFINDDEVICERESULT lpD3DFDR)
-{
-    ICOM_THIS_FROM(IDirect3DImpl, IDirect3D2, iface);
-    TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DDFS, lpD3DFDR);
-    return d3ddevice_find(This, lpD3DDFS, lpD3DFDR, 2);
-}
-
-HRESULT WINAPI
-GL_IDirect3DImpl_3_FindDevice(LPDIRECT3D3 iface,
-			      LPD3DFINDDEVICESEARCH lpD3DDFS,
-			      LPD3DFINDDEVICERESULT lpD3DFDR)
+GL_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface,
+				    LPD3DFINDDEVICESEARCH lpD3DDFS,
+				    LPD3DFINDDEVICERESULT lpD3DFDR)
 {
     ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
     TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DDFS, lpD3DFDR);
-    return d3ddevice_find(This, lpD3DDFS, lpD3DFDR, 3);
+    return d3ddevice_find(This, lpD3DDFS, lpD3DFDR);
 }
 
 HRESULT WINAPI
@@ -381,11 +312,11 @@
     XCAST(QueryInterface) Thunk_IDirect3DImpl_3_QueryInterface,
     XCAST(AddRef) Thunk_IDirect3DImpl_3_AddRef,
     XCAST(Release) Thunk_IDirect3DImpl_3_Release,
-    XCAST(EnumDevices) GL_IDirect3DImpl_3_EnumDevices,
+    XCAST(EnumDevices) GL_IDirect3DImpl_3_2T_1T_EnumDevices,
     XCAST(CreateLight) GL_IDirect3DImpl_3_2T_1T_CreateLight,
     XCAST(CreateMaterial) GL_IDirect3DImpl_3_2T_1T_CreateMaterial,
     XCAST(CreateViewport) GL_IDirect3DImpl_3_2T_1T_CreateViewport,
-    XCAST(FindDevice) GL_IDirect3DImpl_3_FindDevice,
+    XCAST(FindDevice) GL_IDirect3DImpl_3_2T_1T_FindDevice,
     XCAST(CreateDevice) GL_IDirect3DImpl_3_CreateDevice,
     XCAST(CreateVertexBuffer) Thunk_IDirect3DImpl_3_CreateVertexBuffer,
     XCAST(EnumZBufferFormats) Thunk_IDirect3DImpl_3_EnumZBufferFormats,
@@ -409,11 +340,11 @@
     XCAST(QueryInterface) Thunk_IDirect3DImpl_2_QueryInterface,
     XCAST(AddRef) Thunk_IDirect3DImpl_2_AddRef,
     XCAST(Release) Thunk_IDirect3DImpl_2_Release,
-    XCAST(EnumDevices) GL_IDirect3DImpl_2_EnumDevices,
+    XCAST(EnumDevices) Thunk_IDirect3DImpl_2_EnumDevices,
     XCAST(CreateLight) Thunk_IDirect3DImpl_2_CreateLight,
     XCAST(CreateMaterial) Thunk_IDirect3DImpl_2_CreateMaterial,
     XCAST(CreateViewport) Thunk_IDirect3DImpl_2_CreateViewport,
-    XCAST(FindDevice) GL_IDirect3DImpl_2_FindDevice,
+    XCAST(FindDevice) Thunk_IDirect3DImpl_2_FindDevice,
     XCAST(CreateDevice) GL_IDirect3DImpl_2_CreateDevice,
 };
 
@@ -435,11 +366,11 @@
     XCAST(AddRef) Thunk_IDirect3DImpl_1_AddRef,
     XCAST(Release) Thunk_IDirect3DImpl_1_Release,
     XCAST(Initialize) Main_IDirect3DImpl_1_Initialize,
-    XCAST(EnumDevices) GL_IDirect3DImpl_1_EnumDevices,
+    XCAST(EnumDevices) Thunk_IDirect3DImpl_1_EnumDevices,
     XCAST(CreateLight) Thunk_IDirect3DImpl_1_CreateLight,
     XCAST(CreateMaterial) Thunk_IDirect3DImpl_1_CreateMaterial,
     XCAST(CreateViewport) Thunk_IDirect3DImpl_1_CreateViewport,
-    XCAST(FindDevice) GL_IDirect3DImpl_1_FindDevice,
+    XCAST(FindDevice) Thunk_IDirect3DImpl_1_FindDevice,
 };
 
 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
--- /home/ulmer/Wine/wine_base//dlls/ddraw/direct3d/main.h	2002-11-28 23:04:38.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/direct3d/main.h	2002-12-05 06:36:54.000000000 +0100
@@ -78,14 +78,9 @@
 					  IUnknown* pUnkOuter);
 
 HRESULT WINAPI
-Main_IDirect3DImpl_3_FindDevice(LPDIRECT3D3 iface,
-				LPD3DFINDDEVICESEARCH lpD3DDFS,
-				LPD3DFINDDEVICERESULT lpD3DFDR);
-
-HRESULT WINAPI
-Main_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
-				LPD3DFINDDEVICESEARCH lpD3DDFS,
-				LPD3DFINDDEVICERESULT lpD3DFDR);
+Main_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface,
+				      LPD3DFINDDEVICESEARCH lpD3DDFS,
+				      LPD3DFINDDEVICERESULT lpD3DFDR);
 
 HRESULT WINAPI
 Main_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface,
@@ -197,3 +192,13 @@
 Thunk_IDirect3DImpl_1_CreateLight(LPDIRECT3D iface,
                                   LPDIRECT3DLIGHT* lplpDirect3DLight,
                                   IUnknown* pUnkOuter);
+
+HRESULT WINAPI
+Thunk_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface,
+				 LPD3DFINDDEVICESEARCH lpD3DDFS,
+				 LPD3DFINDDEVICERESULT lplpD3DDevice);
+
+HRESULT WINAPI
+Thunk_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
+				 LPD3DFINDDEVICESEARCH lpD3DDFS,
+				 LPD3DFINDDEVICERESULT lpD3DFDR);

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux