PATCH: Reenable some D3D parts + some fixes

Christian Costa titan.costa at wanadoo.fr
Sat Nov 23 04:39:36 CST 2002


Let's send the first patch based on Lionel's work.
The TWIST.EXE demo works again now.

Modified files :
dlls/ddraw/d3dexecutebuffer.c
dlls/ddraw/d3ddevice/mesa.c
dlls/ddraw/direct3d/main.c
dlls/ddraw/direct3d/mesa.c
 
Changelog :
Reenable OpenGL surface's flip method.
Reenable execute buffers.
Some bug fixes.

Christian Costa   titan.costa at wanadoo.fr

-------------- next part --------------
Index: d3dexecutebuffer.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3dexecutebuffer.c,v
retrieving revision 1.12
diff -u -r1.12 d3dexecutebuffer.c
--- d3dexecutebuffer.c	21 Nov 2002 21:04:16 -0000	1.12
+++ d3dexecutebuffer.c	23 Nov 2002 10:12:55 -0000
@@ -183,28 +183,26 @@
 
 static void execute(IDirect3DExecuteBufferImpl *This,
 		    IDirect3DDeviceImpl *lpDevice,
-		    IDirect3DViewportImpl *lpViewport) {
-#if 0
-    IDirect3DExecuteBufferImpl* ilpBuff=(IDirect3DExecuteBufferImpl*)lpBuff;
-    IDirect3DViewport2Impl* ivp=(IDirect3DViewport2Impl*)vp;
-    /* DWORD bs = ilpBuff->desc.dwBufferSize; */
-    DWORD vs = ilpBuff->data.dwVertexOffset;
-    /* DWORD vc = ilpBuff->data.dwVertexCount; */
-    DWORD is = ilpBuff->data.dwInstructionOffset;
-    /* DWORD il = ilpBuff->data.dwInstructionLength; */
+		    IDirect3DViewportImpl *lpViewport)
+{
+    IDirect3DDeviceGLImpl* lpDeviceGL = (IDirect3DDeviceGLImpl*) lpDevice;
+    /* DWORD bs = This->desc.dwBufferSize; */
+    DWORD vs = This->data.dwVertexOffset;
+    /* DWORD vc = This->data.dwVertexCount; */
+    DWORD is = This->data.dwInstructionOffset;
+    /* DWORD il = This->data.dwInstructionLength; */
     
-    void *instr = ilpBuff->desc.lpData + is;
-    D3DDPRIVATE((IDirect3DDeviceImpl*)dev);
+    void *instr = This->desc.lpData + is;
 
     /* Should check if the viewport was added or not to the device */
 
     /* Activate the viewport */
-    ivp->device.active_device1 = (IDirect3DDeviceImpl*)dev;
-    ivp->activate(ivp);
+    lpViewport->active_device = lpDevice;
+    lpViewport->activate(lpViewport);
 
     TRACE("ExecuteData : \n");
     if (TRACE_ON(ddraw))
-      _dump_executedata(&(ilpBuff->data));
+      _dump_executedata(&(This->data));
 
     ENTER_GL();
 
@@ -230,12 +228,12 @@
 
 	    case D3DOP_TRIANGLE: {
 	        int i;
-		OGL_Vertex  *vx    = (OGL_Vertex  *) ilpBuff->vertex_data;
-		OGL_LVertex *l_vx  = (OGL_LVertex *) ilpBuff->vertex_data;
-		D3DTLVERTEX *tl_vx = (D3DTLVERTEX *) ilpBuff->vertex_data;
+		OGL_Vertex  *vx    = (OGL_Vertex  *) This->vertex_data;
+		OGL_LVertex *l_vx  = (OGL_LVertex *) This->vertex_data;
+		D3DTLVERTEX *tl_vx = (D3DTLVERTEX *) This->vertex_data;
 		TRACE("TRIANGLE         (%d)\n", count);
 		
-		switch (ilpBuff->vertex_type) {
+		switch (This->vertex_type) {
 		    case D3DVT_VERTEX:
 		        /* This time, there is lighting */
 		        glEnable(GL_LIGHTING);
@@ -245,16 +243,16 @@
 			glLoadIdentity(); /* The model transformation was done during the
 					     transformation phase */
 			glMatrixMode(GL_PROJECTION);
-			TRACE("  Projection Matrix : (%p)\n", odev->proj_mat);
-			dump_mat(odev->proj_mat);
-			TRACE("  View       Matrix : (%p)\n", odev->view_mat);
-			dump_mat(odev->view_mat);
+			TRACE("  Projection Matrix : (%p)\n", lpDeviceGL->proj_mat);
+			dump_mat(lpDeviceGL->proj_mat);
+			TRACE("  View       Matrix : (%p)\n", lpDeviceGL->view_mat);
+			dump_mat(lpDeviceGL->view_mat);
 
 			/* Although z axis is inverted between OpenGL and Direct3D, the z projected coordinates
 			   are always 0.0 at the front viewing volume and 1.0 at the back with Direct 3D and with
 			   the default behaviour of OpenGL. So, no additional transformation is required. */
-			glLoadMatrixf((float *) odev->proj_mat);
-			glMultMatrixf((float *) odev->view_mat);
+			glLoadMatrixf((float *) lpDeviceGL->proj_mat);
+			glMultMatrixf((float *) lpDeviceGL->view_mat);
 			break;
 
 		    case D3DVT_LVERTEX:
@@ -267,16 +265,16 @@
 					     transformation phase */
 			glMatrixMode(GL_PROJECTION);
 			
-			TRACE("  Projection Matrix : (%p)\n", odev->proj_mat);
-			dump_mat(odev->proj_mat);
-			TRACE("  View       Matrix : (%p)\n", odev->view_mat);
-			dump_mat(odev->view_mat);
+			TRACE("  Projection Matrix : (%p)\n", lpDeviceGL->proj_mat);
+			dump_mat(lpDeviceGL->proj_mat);
+			TRACE("  View       Matrix : (%p)\n", lpDeviceGL->view_mat);
+			dump_mat(lpDeviceGL->view_mat);
 			
 			/* Although z axis is inverted between OpenGL and Direct3D, the z projected coordinates
 			   are always 0 at the front viewing volume and 1 at the back with Direct 3D and with
 			   the default behaviour of OpenGL. So, no additional transformation is required. */
-			glLoadMatrixf((float *) odev->proj_mat);
-			glMultMatrixf((float *) odev->view_mat);
+			glLoadMatrixf((float *) lpDeviceGL->proj_mat);
+			glMultMatrixf((float *) lpDeviceGL->view_mat);
 			break;
 
 		    case D3DVT_TLVERTEX: {
@@ -291,7 +289,7 @@
 			glMatrixMode(GL_PROJECTION);
 			glLoadIdentity();
 			
-			if (ivp == NULL) {
+			if (lpViewport == NULL) {
 			    ERR("No current viewport !\n");
 			    /* Using standard values */
 			    height = 640.0;
@@ -299,10 +297,10 @@
 			    minZ = -10.0;
 			    maxZ = 10.0;
 			} else {
-			    height = (GLdouble) ivp->viewport.vp1.dwHeight;
-			    width  = (GLdouble) ivp->viewport.vp1.dwWidth;
-			    minZ   = (GLdouble) ivp->viewport.vp1.dvMinZ;
-			    maxZ   = (GLdouble) ivp->viewport.vp1.dvMaxZ;
+			    height = (GLdouble) lpViewport->viewports.vp1.dwHeight;
+			    width  = (GLdouble) lpViewport->viewports.vp1.dwWidth;
+			    minZ   = (GLdouble) lpViewport->viewports.vp1.dvMinZ;
+			    maxZ   = (GLdouble) lpViewport->viewports.vp1.dvMaxZ;
 			    
 			    if (minZ == maxZ) {
 			        /* I do not know why, but many Dx 3.0 games have minZ = maxZ = 0.0 */
@@ -318,7 +316,7 @@
 			break;
 		}
 
-		switch (ilpBuff->vertex_type) {
+		switch (This->vertex_type) {
 		    case D3DVT_VERTEX:
 		        TRIANGLE_LOOP(DO_VERTEX);
 			break;
@@ -381,17 +379,17 @@
 		    switch (ci->u1.dtstTransformStateType) {
 		        case D3DTRANSFORMSTATE_WORLD: {
 			    TRACE("  WORLD (%p)\n", (D3DMATRIX*) ci->u2.dwArg[0]);
-			    odev->world_mat = (D3DMATRIX*) ci->u2.dwArg[0];
+			    lpDeviceGL->world_mat = (D3DMATRIX*) ci->u2.dwArg[0];
 			} break;
 
 			case D3DTRANSFORMSTATE_VIEW: {
 			    TRACE("  VIEW (%p)\n", (D3DMATRIX*) ci->u2.dwArg[0]);
-			    odev->view_mat = (D3DMATRIX*) ci->u2.dwArg[0];
+			    lpDeviceGL->view_mat = (D3DMATRIX*) ci->u2.dwArg[0];
 			} break;
 
 			case D3DTRANSFORMSTATE_PROJECTION: {
 			    TRACE("  PROJECTION (%p)\n", (D3DMATRIX*) ci->u2.dwArg[0]);
-			    odev->proj_mat = (D3DMATRIX*) ci->u2.dwArg[0];
+			    lpDeviceGL->proj_mat = (D3DMATRIX*) ci->u2.dwArg[0];
 			} break;
 			  
 			default:
@@ -413,7 +411,7 @@
 		    /* Handle the state transform */
 		    switch (ci->u1.dlstLightStateType) {
 		        case D3DLIGHTSTATE_MATERIAL: {
-			    IDirect3DMaterial2Impl* mat = (IDirect3DMaterial2Impl*) ci->u2.dwArg[0];
+			    IDirect3DMaterialImpl* mat = (IDirect3DMaterialImpl*) ci->u2.dwArg[0];
 			    TRACE("  MATERIAL\n");
 			    
 			    if (mat != NULL) {
@@ -477,7 +475,7 @@
 		    LPD3DSTATE ci = (LPD3DSTATE) instr;
 		    
 		    /* Handle the state transform */
-		    set_render_state(ci->u1.drstRenderStateType, ci->u2.dwArg[0], &(odev->rs));
+		    set_render_state(ci->u1.drstRenderStateType, ci->u2.dwArg[0], &(lpDeviceGL->render_state));
 
 		    instr += size;
 		}
@@ -538,14 +536,14 @@
 		    /* Enough for the moment */
 		    if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) {
 		        int nb;
-			D3DVERTEX  *src = ((LPD3DVERTEX)  (ilpBuff->desc.lpData + vs)) + ci->wStart;
-			OGL_Vertex *dst = ((OGL_Vertex *) (ilpBuff->vertex_data)) + ci->wDest;
-			D3DMATRIX *mat = odev->world_mat;
+			D3DVERTEX  *src = ((LPD3DVERTEX)  (This->desc.lpData + vs)) + ci->wStart;
+			OGL_Vertex *dst = ((OGL_Vertex *) (This->vertex_data)) + ci->wDest;
+			D3DMATRIX *mat = lpDeviceGL->world_mat;
 			
 			TRACE("  World Matrix : (%p)\n", mat);
 			dump_mat(mat);
 
-			ilpBuff->vertex_type = D3DVT_VERTEX;
+			This->vertex_type = D3DVT_VERTEX;
 			
 			for (nb = 0; nb < ci->dwCount; nb++) {
 			    /* For the moment, no normal transformation... */
@@ -567,14 +565,14 @@
 			}
 		    } else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) {
 		        int nb;
-			D3DLVERTEX *src  = ((LPD3DLVERTEX) (ilpBuff->desc.lpData + vs)) + ci->wStart;
-			OGL_LVertex *dst = ((OGL_LVertex *) (ilpBuff->vertex_data)) + ci->wDest;
-			D3DMATRIX *mat = odev->world_mat;
+			D3DLVERTEX *src  = ((LPD3DLVERTEX) (This->desc.lpData + vs)) + ci->wStart;
+			OGL_LVertex *dst = ((OGL_LVertex *) (This->vertex_data)) + ci->wDest;
+			D3DMATRIX *mat = lpDeviceGL->world_mat;
 			
 			TRACE("  World Matrix : (%p)\n", mat);
 			dump_mat(mat);
 			
-			ilpBuff->vertex_type = D3DVT_LVERTEX;
+			This->vertex_type = D3DVT_LVERTEX;
 			
 			for (nb = 0; nb < ci->dwCount; nb++) {
 			    dst->c  = src->u4.color;
@@ -592,10 +590,10 @@
 			    dst++;
 			}
 		    } else if (ci->dwFlags == D3DPROCESSVERTICES_COPY) {
-		        D3DTLVERTEX *src = ((LPD3DTLVERTEX) (ilpBuff->desc.lpData + vs)) + ci->wStart;
-			D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (ilpBuff->vertex_data)) + ci->wDest;
+		        D3DTLVERTEX *src = ((LPD3DTLVERTEX) (This->desc.lpData + vs)) + ci->wStart;
+			D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (This->vertex_data)) + ci->wDest;
 			
-			ilpBuff->vertex_type = D3DVT_TLVERTEX;
+			This->vertex_type = D3DVT_TLVERTEX;
 			
 			memcpy(dst, src, ci->dwCount * sizeof(D3DTLVERTEX));
 		    } else {
@@ -627,7 +625,7 @@
 		for (i = 0; i < count; i++) {
 		    LPD3DBRANCH ci = (LPD3DBRANCH) instr;
 
-		    if ((ilpBuff->data.dsStatus.dwStatus & ci->dwMask) == ci->dwValue) {
+		    if ((This->data.dsStatus.dwStatus & ci->dwMask) == ci->dwValue) {
 		        if (!ci->bNegate) {
 			    TRACE(" Should branch to %ld\n", ci->dwOffset);
 			}
@@ -654,7 +652,7 @@
 		for (i = 0; i < count; i++) {
 		    LPD3DSTATUS ci = (LPD3DSTATUS) instr;
 		    
-		    ilpBuff->data.dsStatus = *ci;
+		    This->data.dsStatus = *ci;
 
 		    instr += size;
 		}
@@ -668,11 +666,8 @@
 	}
     }
 
-  end_of_buffer:
+end_of_buffer:
     LEAVE_GL();
-#else
-    FIXME("Need to make this function compile again !!!\n");
-#endif
 }
 
 HRESULT WINAPI
@@ -868,7 +863,7 @@
     object->d3ddev = d3ddev;
 
     /* Initializes memory */
-    memcpy(&object->desc, &lpDesc, lpDesc->dwSize);
+    memcpy(&object->desc, lpDesc, lpDesc->dwSize);
 
     /* No buffer given */
     if ((object->desc.dwFlags & D3DDEB_LPDATA) == 0)
Index: d3ddevice/mesa.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3ddevice/mesa.c,v
retrieving revision 1.23
diff -u -r1.23 mesa.c
--- d3ddevice/mesa.c	21 Nov 2002 21:04:16 -0000	1.23
+++ d3ddevice/mesa.c	23 Nov 2002 10:12:58 -0000
@@ -132,20 +132,17 @@
 /*******************************************************************************
  *				OpenGL static functions
  */
-static void set_context(IDirect3DDeviceImpl* This) {
-#if 0
-    D3DDPRIVATE(This);
-
+static void set_context(IDirect3DDeviceImpl* This)
+{
+    IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This;
+   
     ENTER_GL();
-    TRACE("glxMakeCurrent %p, %ld, %p\n",odev->gdi_display,odev->drawable, odev->ctx);
-    if (glXMakeCurrent(odev->gdi_display,odev->drawable, odev->ctx) == False) {
+    TRACE("glxMakeCurrent %p, %ld, %p\n",glThis->display,glThis->drawable, glThis->gl_context);
+    if (glXMakeCurrent(glThis->display, glThis->drawable, glThis->gl_context) == False) {
 	ERR("Error in setting current context (context %p drawable %ld)!\n",
-	    odev->ctx, odev->drawable);
+	    glThis->gl_context, glThis->drawable);
     }
     LEAVE_GL();
-#else
-    ERR("This function should not be called in the current state of the code...\n");
-#endif
 }
 
 static void fill_opengl_primcaps(D3DPRIMCAPS *pc)
@@ -1083,7 +1080,7 @@
     glColor3f(1.0, 1.0, 1.0);
     LEAVE_GL();
 
-    fill_device_capabilities(d3d->ddraw);    
+    /* fill_device_capabilities(d3d->ddraw); */    
     
     ICOM_INIT_INTERFACE(object, IDirect3DDevice,  VTABLE_IDirect3DDevice);
     ICOM_INIT_INTERFACE(object, IDirect3DDevice2, VTABLE_IDirect3DDevice2);
Index: direct3d/main.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/direct3d/main.c,v
retrieving revision 1.9
diff -u -r1.9 main.c
--- direct3d/main.c	21 Nov 2002 21:04:16 -0000	1.9
+++ direct3d/main.c	23 Nov 2002 10:12:59 -0000
@@ -426,7 +426,7 @@
 				    &ret_val,
 				    pUnkOuter);
 
-    *lplpDirect3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial, &ret_val);
+    *lplpDirect3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial, ret_val);
 
     TRACE(" returning interface %p.\n", *lplpDirect3DMaterial);
     
@@ -457,7 +457,7 @@
 				    &ret_val,
 				    pUnkOuter);
 
-    *lplpDirect3DMaterial2 = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial2, &ret_val);
+    *lplpDirect3DMaterial2 = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial2, ret_val);
 
     TRACE(" returning interface %p.\n", *lplpDirect3DMaterial2);
     
Index: direct3d/mesa.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/direct3d/mesa.c,v
retrieving revision 1.13
diff -u -r1.13 mesa.c
--- direct3d/mesa.c	21 Nov 2002 21:04:16 -0000	1.13
+++ direct3d/mesa.c	23 Nov 2002 10:13:00 -0000
@@ -281,7 +281,7 @@
     XCAST(AddRef) Thunk_IDirect3DImpl_3_AddRef,
     XCAST(Release) Thunk_IDirect3DImpl_3_Release,
     XCAST(EnumDevices) GL_IDirect3DImpl_3_EnumDevices,
-    XCAST(CreateLight) Main_IDirect3DImpl_3_2T_1T_CreateLight,
+    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,
@@ -308,7 +308,7 @@
     XCAST(QueryInterface) Thunk_IDirect3DImpl_2_QueryInterface,
     XCAST(AddRef) Thunk_IDirect3DImpl_2_AddRef,
     XCAST(Release) Thunk_IDirect3DImpl_2_Release,
-    XCAST(EnumDevices) Thunk_IDirect3DImpl_2_EnumDevices,
+    XCAST(EnumDevices) GL_IDirect3DImpl_2_EnumDevices,
     XCAST(CreateLight) Thunk_IDirect3DImpl_2_CreateLight,
     XCAST(CreateMaterial) Thunk_IDirect3DImpl_2_CreateMaterial,
     XCAST(CreateViewport) Thunk_IDirect3DImpl_2_CreateViewport,
@@ -334,7 +334,7 @@
     XCAST(AddRef) Thunk_IDirect3DImpl_1_AddRef,
     XCAST(Release) Thunk_IDirect3DImpl_1_Release,
     XCAST(Initialize) Main_IDirect3DImpl_1_Initialize,
-    XCAST(EnumDevices) Thunk_IDirect3DImpl_1_EnumDevices,
+    XCAST(EnumDevices) GL_IDirect3DImpl_1_EnumDevices,
     XCAST(CreateLight) Thunk_IDirect3DImpl_1_CreateLight,
     XCAST(CreateMaterial) Thunk_IDirect3DImpl_1_CreateMaterial,
     XCAST(CreateViewport) Thunk_IDirect3DImpl_1_CreateViewport,


More information about the wine-patches mailing list