From 5f87d778aa8c8174ec8ce0a339f23123862e1e83 Mon Sep 17 00:00:00 2001 From: Lionel Ulmer Date: Fri, 3 Jan 2003 19:10:48 +0000 Subject: [PATCH] - some additionnal flags logged - fixes in the vertex buffer thunking + optimized flag support --- dlls/ddraw/d3d_private.h | 1 + dlls/ddraw/d3dcommon.c | 15 ++++++++++++++ dlls/ddraw/d3ddevice/mesa.c | 38 +++++++++++++++++++++++++++++++----- dlls/ddraw/d3dvertexbuffer.c | 15 ++++++++++++-- dlls/ddraw/direct3d/main.c | 4 ++++ dlls/ddraw/direct3d/mesa.c | 2 -- dlls/ddraw/mesa.c | 7 +++++-- dlls/ddraw/mesa_private.h | 2 +- include/d3d.h | 7 ++++++- 9 files changed, 78 insertions(+), 13 deletions(-) diff --git a/dlls/ddraw/d3d_private.h b/dlls/ddraw/d3d_private.h index 53316fa29ae..66c392d056b 100644 --- a/dlls/ddraw/d3d_private.h +++ b/dlls/ddraw/d3d_private.h @@ -226,6 +226,7 @@ extern const char *_get_renderstate(D3DRENDERSTATETYPE type); extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat); extern void dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol); extern void dump_D3DLIGHT7(LPD3DLIGHT7 lpLight); +extern void dump_DPFLAGS(DWORD dwFlags); #define dump_mat(mat) \ TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \ diff --git a/dlls/ddraw/d3dcommon.c b/dlls/ddraw/d3dcommon.c index 6694bfa0cbb..81265f37c98 100644 --- a/dlls/ddraw/d3dcommon.c +++ b/dlls/ddraw/d3dcommon.c @@ -204,3 +204,18 @@ dump_D3DLIGHT7(LPD3DLIGHT7 lpLight) DPRINTF(" - dvTheta : %f\n", lpLight->dvTheta); DPRINTF(" - dvPhi : %f\n", lpLight->dvPhi); } + +void +dump_DPFLAGS(DWORD dwFlags) +{ + static const flag_info flags[] = + { + FE(D3DDP_WAIT), + FE(D3DDP_OUTOFORDER), + FE(D3DDP_DONOTCLIP), + FE(D3DDP_DONOTUPDATEEXTENTS), + FE(D3DDP_DONOTLIGHT) + }; + + DDRAW_dump_flags(dwFlags, flags, sizeof(flags)/sizeof(flags[0])); +} diff --git a/dlls/ddraw/d3ddevice/mesa.c b/dlls/ddraw/d3ddevice/mesa.c index ef70ed8ba2f..05af2e2f04f 100644 --- a/dlls/ddraw/d3ddevice/mesa.c +++ b/dlls/ddraw/d3ddevice/mesa.c @@ -831,11 +831,13 @@ GL_IDirect3DDeviceImpl_2_DrawPrimitive(LPDIRECT3DDEVICE2 iface, DWORD dwFlags) { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - TRACE("(%p/%p)->(%08x,%08x,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags); - ENTER_GL(); + TRACE("(%p/%p)->(%08x,%08x,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags); + if (TRACE_ON(ddraw)) { + TRACE(" - flags : "); dump_DPFLAGS(dwFlags); + } + draw_primitive(This, dwVertexCount, NULL, d3dvtVertexType, d3dptPrimitiveType, lpvVertices); - LEAVE_GL(); return DD_OK; } @@ -852,10 +854,11 @@ GL_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(LPDIRECT3DDEVICE2 iface, { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); TRACE("(%p/%p)->(%08x,%08x,%p,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwIndices, dwIndexCount, dwFlags); + if (TRACE_ON(ddraw)) { + TRACE(" - flags : "); dump_DPFLAGS(dwFlags); + } - ENTER_GL(); draw_primitive(This, dwIndexCount, dwIndices, d3dvtVertexType, d3dptPrimitiveType, lpvVertices); - LEAVE_GL(); return DD_OK; } @@ -1291,7 +1294,11 @@ GL_IDirect3DDeviceImpl_7_3T_DrawPrimitive(LPDIRECT3DDEVICE7 iface, DWORD dwFlags) { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); + TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags); + if (TRACE_ON(ddraw)) { + TRACE(" - flags : "); dump_DPFLAGS(dwFlags); + } draw_primitive_7(This, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, 0, dwVertexCount, NULL, dwVertexCount, dwFlags); @@ -1309,7 +1316,11 @@ GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitive(LPDIRECT3DDEVICE7 iface, DWORD dwFlags) { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); + TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwIndices, dwIndexCount, dwFlags); + if (TRACE_ON(ddraw)) { + TRACE(" - flags : "); dump_DPFLAGS(dwFlags); + } draw_primitive_7(This, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, 0, dwVertexCount, dwIndices, dwIndexCount, dwFlags); @@ -1325,8 +1336,13 @@ GL_IDirect3DDeviceImpl_7_3T_DrawPrimitiveStrided(LPDIRECT3DDEVICE7 iface, DWORD dwFlags) { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); + TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, dwFlags); + if (TRACE_ON(ddraw)) { + TRACE(" - flags : "); dump_DPFLAGS(dwFlags); + } draw_primitive_strided_7(This, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, 0, dwVertexCount, NULL, dwVertexCount, dwFlags); + return DD_OK; } @@ -1341,8 +1357,14 @@ GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE7 iface, DWORD dwFlags) { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); + TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, lpIndex, dwIndexCount, dwFlags); + if (TRACE_ON(ddraw)) { + TRACE(" - flags : "); dump_DPFLAGS(dwFlags); + } + draw_primitive_strided_7(This, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, 0, dwVertexCount, lpIndex, dwIndexCount, dwFlags); + return DD_OK; } @@ -1358,6 +1380,9 @@ GL_IDirect3DDeviceImpl_7_3T_DrawPrimitiveVB(LPDIRECT3DDEVICE7 iface, IDirect3DVertexBufferImpl *vb_impl = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, lpD3DVertexBuf); TRACE("(%p/%p)->(%08x,%p,%08lx,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, dwFlags); + if (TRACE_ON(ddraw)) { + TRACE(" - flags : "); dump_DPFLAGS(dwFlags); + } draw_primitive_7(This, d3dptPrimitiveType, vb_impl->desc.dwFVF, vb_impl->vertices, dwStartVertex, dwNumVertices, NULL, dwNumVertices, dwFlags); @@ -1378,6 +1403,9 @@ GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE7 iface, IDirect3DVertexBufferImpl *vb_impl = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, lpD3DVertexBuf); TRACE("(%p/%p)->(%08x,%p,%08lx,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, lpwIndices, dwIndexCount, dwFlags); + if (TRACE_ON(ddraw)) { + TRACE(" - flags : "); dump_DPFLAGS(dwFlags); + } draw_primitive_7(This, d3dptPrimitiveType, vb_impl->desc.dwFVF, vb_impl->vertices, dwStartVertex, dwNumVertices, lpwIndices, dwIndexCount, dwFlags); diff --git a/dlls/ddraw/d3dvertexbuffer.c b/dlls/ddraw/d3dvertexbuffer.c index 76a6bc22741..bac00dec80d 100644 --- a/dlls/ddraw/d3dvertexbuffer.c +++ b/dlls/ddraw/d3dvertexbuffer.c @@ -99,6 +99,8 @@ Main_IDirect3DVertexBufferImpl_7_1T_Lock(LPDIRECT3DVERTEXBUFFER7 iface, DDRAW_dump_lockflag(dwFlags); } + if (This->desc.dwCaps & D3DVBCAPS_OPTIMIZED) return D3DERR_VERTEXBUFFEROPTIMIZED; + if (lpdwSize != NULL) *lpdwSize = This->vertex_buffer_size; *lplpData = This->vertices; @@ -135,9 +137,14 @@ Main_IDirect3DVertexBufferImpl_7_1T_GetVertexBufferDesc(LPDIRECT3DVERTEXBUFFER7 { DWORD size; ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface); + TRACE("(%p/%p)->(%p)\n", This, iface, lpD3DVertexBufferDesc); - size = (lpD3DVertexBufferDesc->dwSize < This->desc.dwSize) ? lpD3DVertexBufferDesc->dwSize : This->desc.dwSize; - memcpy(lpD3DVertexBufferDesc,&This->desc,size); + + size = lpD3DVertexBufferDesc->dwSize; + memset(lpD3DVertexBufferDesc, 0, size); + memcpy(lpD3DVertexBufferDesc, &This->desc, + (size < This->desc.dwSize) ? size : This->desc.dwSize); + return DD_OK; } @@ -148,6 +155,9 @@ Main_IDirect3DVertexBufferImpl_7_Optimize(LPDIRECT3DVERTEXBUFFER7 iface, { ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface); FIXME("(%p/%p)->(%p,%08lx): stub!\n", This, iface, lpD3DDevice, dwFlags); + + This->desc.dwCaps |= D3DVBCAPS_OPTIMIZED; + return DD_OK; } @@ -297,6 +307,7 @@ HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d { IDirect3DVertexBufferImpl *object; static const flag_info flags[] = { + FE(D3DVBCAPS_DONOTCLIP), FE(D3DVBCAPS_OPTIMIZED), FE(D3DVBCAPS_SYSTEMMEMORY), FE(D3DVBCAPS_WRITEONLY) diff --git a/dlls/ddraw/direct3d/main.c b/dlls/ddraw/direct3d/main.c index a8306296e9d..b0d6df79859 100644 --- a/dlls/ddraw/direct3d/main.c +++ b/dlls/ddraw/direct3d/main.c @@ -466,6 +466,10 @@ Thunk_IDirect3DImpl_3_CreateVertexBuffer(LPDIRECT3D3 iface, LPDIRECT3DVERTEXBUFFER7 ret_val; TRACE("(%p)->(%p,%p,%08lx,%p) thunking to IDirect3D7 interface.\n", iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags, lpUnk); + + /* dwFlags is not used in the D3D7 interface, use the vertex buffer description instead */ + if (dwFlags & D3DDP_DONOTCLIP) lpD3DVertBufDesc->dwCaps |= D3DVBCAPS_DONOTCLIP; + ret = IDirect3D7_CreateVertexBuffer(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface), lpD3DVertBufDesc, &ret_val, diff --git a/dlls/ddraw/direct3d/mesa.c b/dlls/ddraw/direct3d/mesa.c index 7300b799276..9b50edc097e 100644 --- a/dlls/ddraw/direct3d/mesa.c +++ b/dlls/ddraw/direct3d/mesa.c @@ -40,8 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); -#define MAX_LIGHTS 8 - HRESULT WINAPI GL_IDirect3DImpl_3_2T_1T_EnumDevices(LPDIRECT3D3 iface, LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, diff --git a/dlls/ddraw/mesa.c b/dlls/ddraw/mesa.c index d530dfb2623..1c384784729 100644 --- a/dlls/ddraw/mesa.c +++ b/dlls/ddraw/mesa.c @@ -464,9 +464,12 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType, glStencilMask(dwRenderState); break; + case D3DRENDERSTATE_CLIPPING: /* 136 */ + /* Nothing to do here... Even if what we receive is already clipped by the application, + we cannot tell OpenGL to not re-clip it. */ + break; + case D3DRENDERSTATE_LIGHTING: /* 137 */ - /* There will be more to do here once we really support D3D7 Lighting. - Should be enough for now to prevent warnings :-) */ if (dwRenderState) glEnable(GL_LIGHTING); else diff --git a/dlls/ddraw/mesa_private.h b/dlls/ddraw/mesa_private.h index 466af33fb79..c40d64822fb 100644 --- a/dlls/ddraw/mesa_private.h +++ b/dlls/ddraw/mesa_private.h @@ -91,7 +91,7 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType, typedef struct IDirect3DGLImpl { struct IDirect3DImpl parent; - int free_lights; + DWORD free_lights; void (*light_released)(IDirect3DImpl *, GLenum light_num); } IDirect3DGLImpl; diff --git a/include/d3d.h b/include/d3d.h index aea2fa2a38a..1b53c5529fc 100644 --- a/include/d3d.h +++ b/include/d3d.h @@ -183,6 +183,12 @@ typedef struct IDirect3DVertexBuffer7 IDirect3DVertexBuffer7, *LPDIRECT3DVERTEXB #define D3DNEXT_HEAD 0x02l #define D3DNEXT_TAIL 0x04l +#define D3DDP_WAIT 0x00000001l +#define D3DDP_OUTOFORDER 0x00000002l +#define D3DDP_DONOTCLIP 0x00000004l +#define D3DDP_DONOTUPDATEEXTENTS 0x00000008l +#define D3DDP_DONOTLIGHT 0x00000010l + /* ******************************************************************** Types and structures ******************************************************************** */ @@ -1015,5 +1021,4 @@ ICOM_DEFINE(IDirect3DVertexBuffer7,IUnknown) #define IDirect3DVertexBuffer7_Optimize(p,a,b) ICOM_CALL2(Optimize,p,a,b) #define IDirect3DVertexBuffer7_ProcessVerticesStrided(p,a,b,c,d,e,f,g) ICOM_CALL7(ProcessVerticesStrided,p,a,b,c,d,e,f,g) - #endif /* __WINE_D3D_H */