Some additions to D3D

Lionel Ulmer lionel.ulmer at free.fr
Sat Nov 23 14:16:13 CST 2002


Hi all,

This patch is layered upon Christian latest's D3D patch.

Note (for Alexandre): how would you prefer for us to track dependencies
     between patches ? Submit each time a patch agains fresh CVS with all
     previous patches sent (with an ever growing changelog) or do you prefer
     (like here) a lot of patches dependant one on the others ?

     If it's the latter, do we need to do 'letter tracking' as Dimi did ?

                     Lionel

Changelog:
 - add implementation for FindDevice function
 - some miscellaneous clean-ups / additions

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
--- ../wine_work_base/dlls/ddraw/d3dtexture.c	Sat Nov 23 20:45:28 2002
+++ dlls/ddraw/d3dtexture.c	Sat Nov 23 18:27:41 2002
@@ -203,19 +203,19 @@
     *obp = NULL;
 
     if ( IsEqualGUID( &IID_IUnknown,  riid ) ) {
-        IDirect3DTexture_AddRef(ICOM_INTERFACE(This, IDirect3DTexture));
+        IDirect3DTexture2_AddRef(ICOM_INTERFACE(This, IDirect3DTexture2));
 	*obp = iface;
 	TRACE("  Creating IUnknown interface at %p.\n", *obp);
 	return S_OK;
     }
     if ( IsEqualGUID( &IID_IDirect3DTexture, riid ) ) {
-        IDirect3DTexture_AddRef(ICOM_INTERFACE(This, IDirect3DTexture));
+        IDirect3DTexture2_AddRef(ICOM_INTERFACE(This, IDirect3DTexture2));
         *obp = ICOM_INTERFACE(This, IDirect3DTexture);
 	TRACE("  Creating IDirect3DTexture interface %p\n", *obp);
 	return S_OK;
     }
     if ( IsEqualGUID( &IID_IDirect3DTexture2, riid ) ) {
-        IDirect3DTexture_AddRef(ICOM_INTERFACE(This, IDirect3DTexture));
+        IDirect3DTexture2_AddRef(ICOM_INTERFACE(This, IDirect3DTexture2));
         *obp = ICOM_INTERFACE(This, IDirect3DTexture2);
 	TRACE("  Creating IDirect3DTexture2 interface %p\n", *obp);
 	return S_OK;
@@ -350,8 +350,8 @@
     /* Associate the texture with the device and perform the appropriate AddRef/Release */
     /* FIXME: Is there only one or several textures associated with the device ? */
     if (lpDeviceImpl->current_texture != NULL)
-        IDirect3DTexture_Release(ICOM_INTERFACE(lpDeviceImpl->current_texture, IDirect3DTexture));           
-    IDirect3DTexture_AddRef(ICOM_INTERFACE(This, IDirect3DTexture));
+        IDirect3DTexture2_Release(ICOM_INTERFACE(lpDeviceImpl->current_texture, IDirect3DTexture2));           
+    IDirect3DTexture2_AddRef(ICOM_INTERFACE(This, IDirect3DTexture2));
     lpDeviceImpl->current_texture = This;
 
     TRACE("OpenGL texture handle is : %d\n", glThis->tex_name);
@@ -375,7 +375,7 @@
     static BOOL color_table_queried = FALSE;
 #endif
     
-    TRACE("(%p/%p)->(%p): stub!\n", This, iface, lpD3DTexture2);
+    TRACE("(%p/%p)->(%p)\n", This, iface, lpD3DTexture2);
     TRACE("Copied surface %p to surface %p\n", lpD3DTextureImpl->surface, This->surface);
 
     if ( This->surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_ALLOCONLOAD )
--- ../wine_work_base/dlls/ddraw/mesa_private.h	Sat Nov 23 20:45:28 2002
+++ dlls/ddraw/mesa_private.h	Sat Nov 23 08:14:20 2002
@@ -60,7 +60,6 @@
 extern const GUID IID_D3DDEVICE2_OpenGL;
 extern const GUID IID_D3DDEVICE3_OpenGL;
 extern const GUID IID_D3DDEVICE7_OpenGL;
-extern const GUID IID_D3DDEVICE_Default;
 
 typedef struct render_state {
     /* This is used for the device mode */
@@ -123,7 +122,8 @@
 extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surface);
 
 /* Used for Direct3D to request the device to enumerate itself */
-extern HRESULT d3device_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD interface_version) ;
+extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD interface_version) ;
+extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice, DWORD interface_version);
 
 /* Matrix copy WITH transposition */
 #define conv_mat2(mat,gl_mat)			\
--- ../wine_work_base/dlls/ddraw/d3ddevice/mesa.c	Sat Nov 23 20:46:31 2002
+++ dlls/ddraw/d3ddevice/mesa.c	Sat Nov 23 19:24:48 2002
@@ -66,13 +66,6 @@
   { 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfd }
 };
 
-const GUID IID_D3DDEVICE_Default = {
-  0x00000000,
-  0x0000,
-  0x0000,
-  { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }
-};
-
 /* Define this variable if you have an unpatched Mesa 3.0 (patches are available
    on Mesa's home page) or version 3.1b.
 
@@ -226,7 +219,7 @@
 
 
 
-HRESULT d3device_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD interface_version)
+HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD interface_version)
 {
     D3DDEVICEDESC d1, d2;
     char buf[256];
@@ -290,7 +283,7 @@
     memset(lpD3DHELDevDesc, 0, dwSize);
     memcpy(lpD3DHELDevDesc, &desc, (dwSize <= desc.dwSize ? dwSize : desc.dwSize));
 
-    TRACE(" returning caps : TODO\n");
+    TRACE(" returning caps : (no dump function yet)\n");
 
     return DD_OK;
 }
@@ -396,6 +389,52 @@
 
     TRACE("End of enumeration\n");
     return DD_OK;
+}
+
+
+HRESULT
+d3ddevice_find(IDirect3DImpl *d3d,
+	       LPD3DFINDDEVICESEARCH lpD3DDFS,
+	       LPD3DFINDDEVICERESULT lplpD3DDevice,
+	       DWORD interface_version)
+{
+    DWORD dwSize;
+    D3DDEVICEDESC desc;
+  
+    if ((lpD3DDFS->dwFlags & D3DFDS_COLORMODEL) &&
+	(lpD3DDFS->dcmColorModel != D3DCOLOR_RGB)) {
+        TRACE(" trying to request a non-RGB D3D color model. Not supported.\n");
+	return DDERR_INVALIDPARAMS; /* No real idea what to return here :-) */
+    }
+    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;
+    }
+    fill_opengl_caps(&desc);
+    dwSize = lplpD3DDevice->ddHwDesc.dwSize;
+    memset(&(lplpD3DDevice->ddHwDesc), 0, dwSize);
+    memcpy(&(lplpD3DDevice->ddHwDesc), &desc, (dwSize <= desc.dwSize ? dwSize : desc.dwSize));
+    dwSize = lplpD3DDevice->ddSwDesc.dwSize;
+    memset(&(lplpD3DDevice->ddSwDesc), 0, dwSize);
+    memcpy(&(lplpD3DDevice->ddSwDesc), &desc, (dwSize <= desc.dwSize ? dwSize : desc.dwSize));
+    
+    return D3D_OK;
 }
 
 HRESULT WINAPI
--- ../wine_work_base/dlls/ddraw/direct3d/main.c	Sat Nov 23 20:46:31 2002
+++ dlls/ddraw/direct3d/main.c	Sat Nov 23 19:24:48 2002
@@ -180,9 +180,19 @@
 }
 
 HRESULT WINAPI
-Main_IDirect3DImpl_3_2T_FindDevice(LPDIRECT3D3 iface,
-                                   LPD3DFINDDEVICESEARCH lpD3DDFS,
-                                   LPD3DFINDDEVICERESULT lpD3DFDR)
+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)
 {
     ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
     FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lpD3DFDR);
@@ -400,17 +410,6 @@
     return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface),
                                   lplpDirect3DLight,
                                   pUnkOuter);
-}
-
-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, IDirect3D2, IDirect3D3, iface),
-                                 lpD3DDFS,
-                                 lpD3DFDR);
 }
 
 HRESULT WINAPI
--- ../wine_work_base/dlls/ddraw/direct3d/main.h	Thu Nov 21 22:04:16 2002
+++ dlls/ddraw/direct3d/main.h	Sat Nov 23 07:41:54 2002
@@ -78,9 +78,14 @@
 					  IUnknown* pUnkOuter);
 
 HRESULT WINAPI
-Main_IDirect3DImpl_3_2T_FindDevice(LPDIRECT3D3 iface,
-                                   LPD3DFINDDEVICESEARCH lpD3DDFS,
-                                   LPD3DFINDDEVICERESULT lpD3DFDR);
+Main_IDirect3DImpl_3_FindDevice(LPDIRECT3D3 iface,
+				LPD3DFINDDEVICESEARCH lpD3DDFS,
+				LPD3DFINDDEVICERESULT lpD3DFDR);
+
+HRESULT WINAPI
+Main_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
+				LPD3DFINDDEVICESEARCH lpD3DDFS,
+				LPD3DFINDDEVICERESULT lpD3DFDR);
 
 HRESULT WINAPI
 Main_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface,
@@ -193,7 +198,3 @@
                                   LPDIRECT3DLIGHT* lplpDirect3DLight,
                                   IUnknown* pUnkOuter);
 
-HRESULT WINAPI
-Thunk_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
-                                 LPD3DFINDDEVICESEARCH lpD3DDFS,
-                                 LPD3DFINDDEVICERESULT lpD3DFDR);
--- ../wine_work_base/dlls/ddraw/direct3d/mesa.c	Sat Nov 23 20:46:31 2002
+++ dlls/ddraw/direct3d/mesa.c	Sat Nov 23 19:24:48 2002
@@ -51,7 +51,7 @@
     TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
 
     /* Call functions defined in d3ddevices.c */
-    if (d3device_enumerate(lpEnumDevicesCallback, lpUserArg, 1) != D3DENUMRET_OK)
+    if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 1) != D3DENUMRET_OK)
 	return D3D_OK;
 
     return D3D_OK;
@@ -66,7 +66,7 @@
     TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
 
     /* Call functions defined in d3ddevices.c */
-    if (d3device_enumerate(lpEnumDevicesCallback, lpUserArg, 2) != D3DENUMRET_OK)
+    if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 2) != D3DENUMRET_OK)
 	return D3D_OK;
 
     return D3D_OK;
@@ -81,7 +81,7 @@
     TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
 
     /* Call functions defined in d3ddevices.c */
-    if (d3device_enumerate(lpEnumDevicesCallback, lpUserArg, 3) != D3DENUMRET_OK)
+    if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 3) != D3DENUMRET_OK)
 	return D3D_OK;
 
     return D3D_OK;
@@ -166,23 +166,22 @@
 	return D3D_OK;
     }
     if (IsEqualGUID( &IID_D3DDEVICE2_OpenGL, iid )) {
-        TRACE(" returning OpenGL D3DDevice2 %p\n", *obj);
 	*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice2);
+        TRACE(" returning OpenGL D3DDevice2 %p\n", *obj);
 	return D3D_OK;
     }
     if (IsEqualGUID( &IID_D3DDEVICE3_OpenGL, iid )) {
-        TRACE(" returning OpenGL D3DDevice3 %p\n", *obj);
 	*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice3);
+        TRACE(" returning OpenGL D3DDevice3 %p\n", *obj);
 	return D3D_OK;
     }
     if (IsEqualGUID( &IID_D3DDEVICE7_OpenGL, iid )) {
-        TRACE(" returning OpenGL D3DDevice7 %p\n", *obj);
 	*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice7);
+        TRACE(" returning OpenGL D3DDevice7 %p\n", *obj);
 	return D3D_OK;
     }
     if ((iid == NULL) ||
-	(IsEqualGUID(&IID_IDirect3DHALDevice, iid)) ||
-	(IsEqualGUID(&IID_D3DDEVICE_Default, iid))) {
+	(IsEqualGUID(&IID_IDirect3DHALDevice, iid))) {
         switch (interface) {
 	    case 1:
 		*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice);
@@ -238,6 +237,36 @@
     return create_device_helper(This, rclsid, ddsurfaceimpl, (void **) lplpD3DDevice3, 3);
 }
 
+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)
+{
+    ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
+    TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DDFS, lpD3DFDR);
+    return d3ddevice_find(This, lpD3DDFS, lpD3DFDR, 3);
+}
+
 static void light_released(IDirect3DImpl *This, GLenum light_num)
 {
     IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This;
@@ -284,7 +313,7 @@
     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) Main_IDirect3DImpl_3_2T_FindDevice,
+    XCAST(FindDevice) GL_IDirect3DImpl_3_FindDevice,
     XCAST(CreateDevice) GL_IDirect3DImpl_3_CreateDevice,
     XCAST(CreateVertexBuffer) Thunk_IDirect3DImpl_3_CreateVertexBuffer,
     XCAST(EnumZBufferFormats) Thunk_IDirect3DImpl_3_EnumZBufferFormats,
@@ -312,7 +341,7 @@
     XCAST(CreateLight) Thunk_IDirect3DImpl_2_CreateLight,
     XCAST(CreateMaterial) Thunk_IDirect3DImpl_2_CreateMaterial,
     XCAST(CreateViewport) Thunk_IDirect3DImpl_2_CreateViewport,
-    XCAST(FindDevice) Thunk_IDirect3DImpl_2_FindDevice,
+    XCAST(FindDevice) GL_IDirect3DImpl_2_FindDevice,
     XCAST(CreateDevice) GL_IDirect3DImpl_2_CreateDevice,
 };
 
@@ -338,7 +367,7 @@
     XCAST(CreateLight) Thunk_IDirect3DImpl_1_CreateLight,
     XCAST(CreateMaterial) Thunk_IDirect3DImpl_1_CreateMaterial,
     XCAST(CreateViewport) Thunk_IDirect3DImpl_1_CreateViewport,
-    XCAST(FindDevice) Main_IDirect3DImpl_1_FindDevice,
+    XCAST(FindDevice) GL_IDirect3DImpl_1_FindDevice,
 };
 
 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)


More information about the wine-patches mailing list