WineD3D: Add emtpy vertex declaration and related states to the state table

Stefan Dösinger stefandoesinger at gmx.at
Mon Jan 1 17:35:07 CST 2007


This patch adds a vertex declaration, vertex shader and stream source  
state to the state table. They are all grouped to the  
vertexdeclaration state. Dirtification calls are also added.

Vertex shader and vertex declaration will remain grouped because  
vertex shaders can contain a declaration, and the resulting gl shader  
depends on the vdecl which can be outside of the shader too.

Stream sources will be broken out later(not in this patchset)
-------------- next part --------------
From 5c5575c3a3bbbd6094660b9289f3bf764c587499 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Stefan_D=C3=B6singer?= <stefan at imac.local>
Date: Tue, 26 Dec 2006 23:27:44 +0100
Subject: [PATCH] WineD3D: Add an empty vertex declaration handler to the state table

---
 dlls/wined3d/device.c          |   22 +++++++++++++++++-----
 dlls/wined3d/state.c           |    9 +++++++++
 dlls/wined3d/wined3d_private.h |   11 ++++++++++-
 3 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d2898d3..3cfd40f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2146,7 +2146,6 @@ static UINT WINAPI IWineD3DDeviceImpl_Ge
  *****/
 static HRESULT WINAPI IWineD3DDeviceImpl_SetFVF(IWineD3DDevice *iface, DWORD fvf) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    HRESULT hr = WINED3D_OK;
 
     /* Update the current state block */
     This->updateStateBlock->fvf              = fvf;
@@ -2154,7 +2153,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     This->updateStateBlock->set.fvf          = TRUE;
 
     TRACE("(%p) : FVF Shader FVF set to %x\n", This, fvf);
-    return hr;
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
+    return WINED3D_OK;
 }
 
 
@@ -2238,6 +2238,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl
         IWineD3DVertexBuffer_Release(oldSrc);
     }
 
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
+
     return WINED3D_OK;
 }
 
@@ -3228,6 +3230,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     if (NULL != oldDecl) {
         IWineD3DVertexDeclaration_Release(oldDecl);
     }
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
     return WINED3D_OK;
 }
 
@@ -3261,9 +3264,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     }
 
     TRACE("(%p) : setting pShader(%p)\n", This, pShader);
-    /**
-     * TODO: merge HAL shaders context switching from prototype
-     */
+
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VSHADER);
+
     return WINED3D_OK;
 }
 
@@ -4718,6 +4721,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     This->stateBlock->streamStride[0] = VertexStreamZeroStride;
     This->stateBlock->streamIsUP = TRUE;
 
+    /* Mark the state dirty until we have nicer tracking */
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
+
     drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* start vertex */, 0  /* NumVertices */,
                   0 /* indxStart*/, 0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */, NULL);
 
@@ -4761,6 +4767,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     This->stateBlock->streamIsUP = TRUE;
     This->stateBlock->streamStride[0] = VertexStreamZeroStride;
 
+    /* Mark the state dirty until we have nicer tracking */
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
+
     drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* vertexStart */, NumVertices, 0 /* indxStart */, idxStride, pIndexData, MinVertexIndex, NULL);
 
     /* MSDN specifies stream zero settings and index buffer must be set to NULL */
@@ -4772,7 +4781,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl
 }
 
 static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided (IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData) {
+    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
 
+    /* Mark the state dirty until we have nicer tracking */
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
     drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0, 0, 0, 0, NULL, 0, DrawPrimStrideData);
     return WINED3D_OK;
 }
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 28ec973..bc7252d 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1847,6 +1847,10 @@ static void transform_worldex(DWORD stat
 	WARN("World matrix 1 - 255 not supported yet\n");
 }
 
+static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateBlock) {
+    TRACE("To be filled later\n");
+}
+
 const struct StateEntry StateTable[] =
 {
       /* State name                                         representative,                                     apply function */
@@ -2860,4 +2864,9 @@ const struct StateEntry StateTable[] =
     { /*509, WINED3DTS_WORLDMATRIX(253)             */      STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)),        transform_worldex   },
     { /*510, WINED3DTS_WORLDMATRIX(254)             */      STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)),        transform_worldex   },
     { /*511, WINED3DTS_WORLDMATRIX(255)             */      STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)),        transform_worldex   },
+      /* Various Vertex states follow */
+    { /*   , STATE_STREAMSRC                        */      STATE_VDECL,                                        vertexdeclaration   },
+    { /*   , STATE_VDECL                            */      STATE_VDECL,                                        vertexdeclaration   },
+    { /*   , STATE_VSHADER                          */      STATE_VDECL,                                        vertexdeclaration   },
+	
 };
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 99d70c9..0915b73 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -426,7 +426,16 @@ #define STATE_IS_PIXELSHADER(a) ((a) == 
 #define STATE_TRANSFORM(a) (STATE_PIXELSHADER + (a))
 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)))
 
-#define STATE_HIGHEST (STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)))
+#define STATE_STREAMSRC (STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)) + 1)
+#define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
+
+#define STATE_VDECL (STATE_STREAMSRC + 1)
+#define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
+
+#define STATE_VSHADER (STATE_VDECL + 1)
+#define STATE_IS_VSHADER(a) ((a) == STATE_VSHADER)
+
+#define STATE_HIGHEST (STATE_VSHADER)
 
 struct StateEntry
 {
-- 
1.4.2.4

-------------- next part --------------



More information about the wine-patches mailing list