[9/16] WineD3D: Move decoding the vertex declaration to the device

Stefan Dösinger stefandoesinger at gmx.at
Mon Jan 1 18:14:39 CST 2007


From 09aa75573ef26451bf0e5fc430ebb1f007648286 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Stefan_D=C3=B6singer?= <stefan at imac.local>
Date: Wed, 27 Dec 2006 14:36:41 +0100
Subject: [PATCH] WineD3D: Move decoding the vertex declaration to the state table

---
 dlls/wined3d/drawprim.c        |   40 +-----------------------------------
 dlls/wined3d/state.c           |   45 ++++++++++++++++++++++++++++++++++++++--
 dlls/wined3d/wined3d_private.h |    1 +
 3 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 6ec3574..12d2a11 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -1943,7 +1943,7 @@ void drawPrimitive(IWineD3DDevice *iface
     BOOL                          usePixelShaderFunction = FALSE;
     IWineD3DSwapChainImpl         *swapchain;
     int                           i;
-    BOOL                          fixup = FALSE;
+    BOOL                          fixup;
     DWORD                         dirtyState, idx;
     BYTE                          shift;
 
@@ -1990,44 +1990,6 @@ void drawPrimitive(IWineD3DDevice *iface
     }
     This->depth_copy_state = WINED3D_DCS_INITIAL;
 
-    if(This->up_strided) {
-
-        /* Note: this is a ddraw fixed-function code path */
-
-        TRACE("================ Strided Input ===================\n");
-		memcpy(&This->strided_streams, This->up_strided, sizeof(This->strided_streams));
-        drawPrimitiveTraceDataLocations(&This->strided_streams);
-        fixup = FALSE;
-    }
-
-    else if (This->stateBlock->vertexDecl || This->stateBlock->vertexShader) {
-
-        /* Note: This is a fixed function or shader codepath.
-         * This means it must handle both types of strided data.
-         * Shaders must go through here to zero the strided data, even if they
-         * don't set any declaration at all */
-
-        TRACE("================ Vertex Declaration  ===================\n");
-        memset(&This->strided_streams, 0, sizeof(This->strided_streams));
-
-        if (This->stateBlock->vertexDecl != NULL ||
-            ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration != NULL)            
-
-            primitiveDeclarationConvertToStridedData(iface, useVertexShaderFunction, 
-                &This->strided_streams, &fixup);
-
-    } else {
-
-        /* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion)
-         * It is reachable through d3d8, but only for fixed-function.
-         * It will not work properly for shaders. */
-
-        TRACE("================ FVF ===================\n");
-        memset(&This->strided_streams, 0, sizeof(This->strided_streams));
-        primitiveConvertToStridedData(iface, &This->strided_streams, &fixup);
-        drawPrimitiveTraceDataLocations(&This->strided_streams);
-    }
-
     /* Setup transform matrices and sort out */
     primitiveInitState(iface, &This->strided_streams, useVertexShaderFunction, &lighting_changed, &lighting_original);
 
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index bc7252d..2b32b42 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1847,8 +1847,49 @@ 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");
+static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) {
+    BOOL useVertexShaderFunction = FALSE;
+    stateblock->wineD3DDevice->streamFixedUp = FALSE;
+ 	
+    /* Shaders can be implemented using ARB_PROGRAM, GLSL, or software - 
+     * here simply check whether a shader was set, or the user disabled shaders
+     */
+    if (stateblock->wineD3DDevice->vs_selected_mode != SHADER_NONE && stateblock->vertexShader && 
+       ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL) 
+        useVertexShaderFunction = TRUE;
+
+        if(stateblock->wineD3DDevice->up_strided) {
+
+        /* Note: this is a ddraw fixed-function code path */
+        TRACE("================ Strided Input ===================\n");
+        memcpy(&stateblock->wineD3DDevice->strided_streams, stateblock->wineD3DDevice->up_strided, sizeof(stateblock->wineD3DDevice->strided_streams));
+        stateblock->wineD3DDevice->streamFixedUp = FALSE;
+    }
+    else if (stateblock->vertexDecl || stateblock->vertexShader) {
+        /* Note: This is a fixed function or shader codepath.
+         * This means it must handle both types of strided data.
+         * Shaders must go through here to zero the strided data, even if they
+         * don't set any declaration at all
+         */
+        TRACE("================ Vertex Declaration  ===================\n");
+        memset(&stateblock->wineD3DDevice->strided_streams, 0, sizeof(stateblock->wineD3DDevice->strided_streams));
+ 
+        if (stateblock->vertexDecl != NULL ||
+            ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->vertexDeclaration != NULL) {
+            
+            primitiveDeclarationConvertToStridedData((IWineD3DDevice *) stateblock->wineD3DDevice, useVertexShaderFunction, 
+                &stateblock->wineD3DDevice->strided_streams, &stateblock->wineD3DDevice->streamFixedUp);
+        }
+    } else {
+        /* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion)
+         * It is reachable through d3d8, but only for fixed-function.
+         * It will not work properly for shaders.
+         */
+        TRACE("================ FVF ===================\n");
+        memset(&stateblock->wineD3DDevice->strided_streams, 0, sizeof(stateblock->wineD3DDevice->strided_streams));
+        primitiveConvertToStridedData((IWineD3DDevice *) stateblock->wineD3DDevice, &stateblock->wineD3DDevice->strided_streams,
+ 									   &stateblock->wineD3DDevice->streamFixedUp);
+     }
 }
 
 const struct StateEntry StateTable[] =
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 03cd9cd..542b496 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -670,6 +670,7 @@ #define                         NEEDS_DI
     WineDirect3DVertexStridedData strided_streams;
     WineDirect3DVertexStridedData *up_strided;
     UINT                      baseVIndex;
+    BOOL                      streamFixedUp;
 
 } IWineD3DDeviceImpl;
 
-- 
1.4.2.4



More information about the wine-patches mailing list