[3/10] WineD3D: Move decoding the vertex declaration to the vertexshader state handler

Stefan Dösinger stefandoesinger at gmx.at
Tue Jan 2 14:31:08 CST 2007


Basically an unmodifed version of the patch yesterday.

Ivan, I forgot to put the device into a local variable in this patch,  
and I saw this after creating 7 patches on top of it. Another patch  
in this patch series will do that, I hope that is ok with you.

Regarding the concern of storing the decoded strided data after  
finishing drawing: This is intentional, the decoded vertex  
declaration will remain valid after the draw is finished and the  
arrays loaded. Future draws can use it, if the state is not dirtified  
again.

Wrt the upward references: When we have multithreading with multiple  
contexts we will need a per-context tracking of most of the stuff we  
have in the device now(last_was_rhw, ...). This structure does not  
exist yet, and I do not see a point in passing the device impl to  
every function when we can get it from the stateblock too.

-------------- next part --------------
From 6e653326c236779fb70af301b30aa44bb41802c2 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Stefan_D=C3=B6singer?= <stefan at imac.local>
Date: Tue, 2 Jan 2007 19:18:52 +0100
Subject: [PATCH] WineD3D: Move decoding the vertex declaration to the vertex decl state

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

diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 23c2d88..9fce659 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;
 
@@ -1980,6 +1980,7 @@ void drawPrimitive(IWineD3DDevice *iface
         StateTable[dirtyState].apply(dirtyState, This->stateBlock);
     }
     This->numDirtyEntries = 0; /* This makes the whole list clean */
+    fixup = This->streamFixedUp;
 
     if (TRACE_ON(d3d_draw) && wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
         check_fbo_status(iface);
@@ -1990,44 +1991,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 fae9d6b..fcb42a8 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 9ca13c1..15958f3 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -669,6 +669,7 @@ #define                         NEEDS_DI
     /* Stream source management */
     WineDirect3DVertexStridedData strided_streams;
     WineDirect3DVertexStridedData *up_strided;
+    BOOL                      streamFixedUp;
 
 } IWineD3DDeviceImpl;
 
-- 
1.4.2.4

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



More information about the wine-patches mailing list