[WINED3D 10/9] GLSL shader cleanup patch.

Jason Green jave27 at gmail.com
Fri Jun 9 11:04:10 CDT 2006


- Based on comments from H. Verbeet
- Changed the distinction from .rgba & .xyzw masks to only use .xyzw
in GLSL shaders.  They are interchangeable, and only served to make
the trace look more intuitive, but they don't always apply as-is, so
we'll just leave everything to .xyzw.
- Got rid of the "UseProgramObjectARB(0)" call in drawprim.  If there
is no shader set on the next primitive, then that primitive will call
UseProgramObjectARB(0) when it begins to draw.
-------------- next part --------------
From nobody Mon Sep 17 00:00:00 2001
From: Jason <jason at jave02.(none)>
Date: Fri, 9 Jun 2006 12:02:06 -0400
Subject: [PATCH] GLSL shader cleanup patch.

- Based on comments from H. Verbeet
- Changed the distinction from .rgba & .xyzw masks to only use .xyzw in GLSL shaders.  They are interchangeable, and only served to make the trace look more intuitive, but they don't always apply as-is, so we'll just leave everything to .xyzw.
- Got rid of the "UseProgramObjectARB(0)" call in drawprim.  If there is no shader set on the next primitive, then that primitive will call UseProgramObjectARB(0) when it begins to draw.

---

 dlls/wined3d/drawprim.c    |   23 +++++++----------------
 dlls/wined3d/glsl_shader.c |   24 ++++++++----------------
 2 files changed, 15 insertions(+), 32 deletions(-)

b6361efed65cb3a300dfd8110a5da0c379aea985
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index f12e046..b3c719b 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -1922,17 +1922,14 @@ #endif
 
         /* Bind the correct GLSL shader program based on the currently set vertex & pixel shaders. */
         if (wined3d_settings.shader_mode == SHADER_GLSL) {
-            GLhandleARB programId;
-            
             set_glsl_shader_program(iface);
-            programId = This->stateBlock->shaderPrgId;    
-
-            if (programId != 0) {
-                /* Start using this program ID */
-                TRACE_(d3d_shader)("Using GLSL program %u\n", programId);
-                GL_EXTCALL(glUseProgramObjectARB(programId));
-                checkGLcall("glUseProgramObjectARB");
-            } 
+            /* Start using this program ID (if it's 0, there is no shader program to use, so 
+             * glUseProgramObjectARB(0) will disable the use of any shaders) */
+            if (This->stateBlock->shaderPrgId) {
+                TRACE_(d3d_shader)("Using GLSL program %u\n", This->stateBlock->shaderPrgId);
+            }
+            GL_EXTCALL(glUseProgramObjectARB(This->stateBlock->shaderPrgId));
+            checkGLcall("glUseProgramObjectARB");
         }
         
         if (useVertexShaderFunction) {
@@ -2017,12 +2014,6 @@ #endif
         if (usePixelShaderFunction && wined3d_settings.shader_mode == SHADER_ARB) {
             glDisable(GL_FRAGMENT_PROGRAM_ARB);
         }
-
-        /* Cleanup GLSL program */
-        if (wined3d_settings.shader_mode == SHADER_GLSL
-            && (useVertexShaderFunction || usePixelShaderFunction)) {
-            GL_EXTCALL(glUseProgramObjectARB(0));
-        }
     }
 }
 
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index eb9adeb..c48b38a 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -271,32 +271,24 @@ void shader_glsl_get_register_name(
 
 /* Writes the GLSL writemask for the destination register */
 void shader_glsl_get_output_register_swizzle(
-    IWineD3DBaseShader *shader,
     const DWORD param,
     char *write_mask) {
    
-    IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl*) shader; 
-    BOOL pshader = shader_is_pshader_version(This->baseShader.hex_version);
-    
     *write_mask = 0;
     if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) {
         strcat(write_mask, ".");
-        if (param & D3DSP_WRITEMASK_0) strcat(write_mask, pshader ? "r" : "x");
-        if (param & D3DSP_WRITEMASK_1) strcat(write_mask, pshader ? "g" : "y");
-        if (param & D3DSP_WRITEMASK_2) strcat(write_mask, pshader ? "b" : "z");
-        if (param & D3DSP_WRITEMASK_3) strcat(write_mask, pshader ? "a" : "w");
+        if (param & D3DSP_WRITEMASK_0) strcat(write_mask, "x");
+        if (param & D3DSP_WRITEMASK_1) strcat(write_mask, "y");
+        if (param & D3DSP_WRITEMASK_2) strcat(write_mask, "z");
+        if (param & D3DSP_WRITEMASK_3) strcat(write_mask, "w");
     }
 }
 
 void shader_glsl_get_input_register_swizzle(
-    IWineD3DBaseShader *shader,
     const DWORD param,
     BOOL is_color,
     char *reg_mask) {
     
-    IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl*) shader; 
-    BOOL pshader = shader_is_pshader_version(This->baseShader.hex_version);
-    
     char swizzle_reg_chars_color_fix[5];
     char swizzle_reg_chars[5];
     const char* swizzle_regs = NULL;
@@ -308,8 +300,8 @@ void shader_glsl_get_input_register_swiz
     DWORD swizzle_z = (swizzle >> 4) & 0x03;
     DWORD swizzle_w = (swizzle >> 6) & 0x03;
 
-    strcpy(swizzle_reg_chars_color_fix, pshader ? "bgra" : "zyxw");
-    strcpy(swizzle_reg_chars, pshader ? "rgba" : "xyzw");
+    strcpy(swizzle_reg_chars_color_fix, "zyxw");
+    strcpy(swizzle_reg_chars, "xyzw");
 
     if (is_color) {
       swizzle_regs = swizzle_reg_chars_color_fix;
@@ -363,10 +355,10 @@ void shader_glsl_add_param(
     shader_glsl_get_register_name(param, addr_token, reg_name, &is_color, arg);
     
     if (is_input) {
-        shader_glsl_get_input_register_swizzle(arg->shader, param, is_color, reg_mask);
+        shader_glsl_get_input_register_swizzle(param, is_color, reg_mask);
         shader_glsl_gen_modifier(param, reg_name, reg_mask, out_str);
     } else {
-        shader_glsl_get_output_register_swizzle(arg->shader, param, reg_mask);
+        shader_glsl_get_output_register_swizzle(param, reg_mask);
         sprintf(out_str, "%s%s", reg_name, reg_mask);
     }
 }
-- 
1.3.3


More information about the wine-patches mailing list