[8/20] WineD3D: Do not activate vertex shaders needlessly

Stefan Dösinger stefan at codeweavers.com
Sat Jan 6 11:21:35 CST 2007


Keep a flag in the device to store if a vertex shader was active at the last 
draw, if the current draw doesn't use a shader, and there wasn't one active 
before there is no need to deactivate the shader.
-------------- next part --------------
From f7e595798e2f1c6f44299dca41d7fa4dcaec96c7 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Fri, 5 Jan 2007 18:09:38 +0100
Subject: [PATCH] WineD3D: Do not deactivate vshaders needlessly

---
 dlls/wined3d/state.c           |   21 ++++++++++++---------
 dlls/wined3d/wined3d_private.h |    1 +
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index cdb250e..0e36a08 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -2675,19 +2675,22 @@ static void vertexdeclaration(DWORD stat
         IWineD3DVertexShader_CompileShader(stateblock->vertexShader);
     }
 
-    /* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
-     * application
-     */
-    if(!isStateDirty(device, STATE_PIXELSHADER)) {
+    if(useVertexShaderFunction || device->last_was_vshader) {
         BOOL usePixelShaderFunction = device->ps_selected_mode != SHADER_NONE && 
-                                        stateblock->pixelShader &&
-                                        ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function;
+                                      stateblock->pixelShader &&
+                                      ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function;
 
-        device->shader_backend->shader_select((IWineD3DDevice *) device, usePixelShaderFunction, useVertexShaderFunction);
+        /* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
+         * application
+         */
+        if(!isStateDirty(device, STATE_PIXELSHADER)) {
+            device->shader_backend->shader_select((IWineD3DDevice *) device, usePixelShaderFunction, useVertexShaderFunction);
 
-        if(!isStateDirty(stateblock->wineD3DDevice, STATE_VERTEXSHADERCONSTANT) && (useVertexShaderFunction || usePixelShaderFunction)) {
-            shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock);
+            if(!isStateDirty(stateblock->wineD3DDevice, STATE_VERTEXSHADERCONSTANT) && (useVertexShaderFunction || usePixelShaderFunction)) {
+                shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock);
+            }
         }
+        device->last_was_vshader = useVertexShaderFunction;
     }
 
     if(updateFog) {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 27f95c8..83a8f17 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -583,6 +583,7 @@ #define                         NEEDS_DI
     BOOL                    last_was_notclipped;
     BOOL                    untransformed;
     BOOL                    last_was_pshader;
+    BOOL                    last_was_vshader;
     BOOL                    last_was_foggy_shader;
     BOOL                    namedArraysLoaded, numberedArraysLoaded;
 
-- 
1.4.2.4



More information about the wine-patches mailing list