[PATCH 3/4] wined3d: Use local reg_maps variables where possible.

Henri Verbeet hverbeet at codeweavers.com
Sun Dec 5 16:46:54 CST 2010


---
 dlls/wined3d/arb_program_shader.c |   16 +++++++++-------
 dlls/wined3d/glsl_shader.c        |   26 +++++++++++++++-----------
 dlls/wined3d/shader.c             |    4 ++--
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 05e4fcd..d7626af 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -732,11 +732,12 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
         if (max_constantsF < 96)
             max_constantsF = gl_info->limits.arb_vs_float_constants;
 
-        if(This->baseShader.reg_maps.usesrelconstF) {
+        if (reg_maps->usesrelconstF)
+        {
             DWORD highest_constf = 0, clip_limit;
 
             max_constantsF -= reserved_vs_const(shader_data, reg_maps, gl_info);
-            max_constantsF -= count_bits(This->baseShader.reg_maps.integer_constants);
+            max_constantsF -= count_bits(reg_maps->integer_constants);
 
             for(i = 0; i < This->baseShader.limits.constant_float; i++)
             {
@@ -821,7 +822,8 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
      * local constants do not declare the loaded constants as an array because ARB compilers usually
      * do not optimize unused constants away
      */
-    if(This->baseShader.reg_maps.usesrelconstF) {
+    if (reg_maps->usesrelconstF)
+    {
         /* Need to PARAM the environment parameters (constants) so we can use relative addressing */
         shader_addline(buffer, "PARAM C[%d] = { program.env[0..%d] };\n",
                     max_constantsF, max_constantsF - 1);
@@ -830,7 +832,8 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
             DWORD idx, mask;
             idx = i >> 5;
             mask = 1 << (i & 0x1f);
-            if(!shader_constant_is_local(This, i) && (This->baseShader.reg_maps.constf[idx] & mask)) {
+            if (!shader_constant_is_local(This, i) && (reg_maps->constf[idx] & mask))
+            {
                 shader_addline(buffer, "PARAM C%d = program.env[%d];\n",i, i);
             }
         }
@@ -3588,7 +3591,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
         priv_ctx.target_version = ARB;
     }
 
-    if(This->baseShader.reg_maps.highest_render_target > 0)
+    if (reg_maps->highest_render_target > 0)
     {
         shader_addline(buffer, "OPTION ARB_draw_buffers;\n");
     }
@@ -4169,8 +4172,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
             const char *one = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_ONE);
             for(i = 0; i < min(8, MAX_REG_TEXCRD); i++)
             {
-                if (This->baseShader.reg_maps.texcoord_mask[i]
-                        && This->baseShader.reg_maps.texcoord_mask[i] != WINED3DSP_WRITEMASK_ALL)
+                if (reg_maps->texcoord_mask[i] && reg_maps->texcoord_mask[i] != WINED3DSP_WRITEMASK_ALL)
                     shader_addline(buffer, "MOV result.texcoord[%u].w, %s\n", i, one);
             }
         }
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 8b55eb8..6d92a3c 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -951,25 +951,29 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
         }
         else
         {
-            if(This->baseShader.reg_maps.usesrelconstF) {
-                /* Subtract the other potential uniforms from the max available (bools, ints, and 1 row of projection matrix).
-                 * Subtract another uniform for immediate values, which have to be loaded via uniform by the driver as well.
-                 * The shader code only uses 0.5, 2.0, 1.0, 128 and -128 in vertex shader code, so one vec4 should be enough
-                 * (Unfortunately the Nvidia driver doesn't store 128 and -128 in one float).
+            if (reg_maps->usesrelconstF)
+            {
+                /* Subtract the other potential uniforms from the max
+                 * available (bools, ints, and 1 row of projection matrix).
+                 * Subtract another uniform for immediate values, which have
+                 * to be loaded via uniform by the driver as well. The shader
+                 * code only uses 0.5, 2.0, 1.0, 128 and -128 in vertex
+                 * shader code, so one vec4 should be enough. (Unfortunately
+                 * the Nvidia driver doesn't store 128 and -128 in one float).
                  *
-                 * Writing gl_ClipVertex requires one uniform for each clipplane as well.
-                 */
+                 * Writing gl_ClipVertex requires one uniform for each
+                 * clipplane as well. */
                 max_constantsF = gl_info->limits.glsl_vs_float_constants - 3;
                 if(ctx_priv->cur_vs_args->clip_enabled)
                 {
                     max_constantsF -= gl_info->limits.clipplanes;
                 }
-                max_constantsF -= count_bits(This->baseShader.reg_maps.integer_constants);
+                max_constantsF -= count_bits(reg_maps->integer_constants);
                 /* Strictly speaking a bool only uses one scalar, but the nvidia(Linux) compiler doesn't pack them properly,
                  * so each scalar requires a full vec4. We could work around this by packing the booleans ourselves, but
                  * for now take this into account when calculating the number of available constants
                  */
-                max_constantsF -= count_bits(This->baseShader.reg_maps.boolean_constants);
+                max_constantsF -= count_bits(reg_maps->boolean_constants);
                 /* Set by driver quirks in directx.c */
                 max_constantsF -= gl_info->reserved_glsl_constants;
             }
@@ -985,10 +989,10 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
     /* Always declare the full set of constants, the compiler can remove the unused ones because d3d doesn't(yet)
      * support indirect int and bool constant addressing. This avoids problems if the app uses e.g. i0 and i9.
      */
-    if (This->baseShader.limits.constant_int > 0 && This->baseShader.reg_maps.integer_constants)
+    if (This->baseShader.limits.constant_int > 0 && reg_maps->integer_constants)
         shader_addline(buffer, "uniform ivec4 %cI[%u];\n", prefix, This->baseShader.limits.constant_int);
 
-    if (This->baseShader.limits.constant_bool > 0 && This->baseShader.reg_maps.boolean_constants)
+    if (This->baseShader.limits.constant_bool > 0 && reg_maps->boolean_constants)
         shader_addline(buffer, "uniform bool %cB[%u];\n", prefix, This->baseShader.limits.constant_bool);
 
     if (!pshader)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index ef6816f..59fe937 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -1864,7 +1864,7 @@ HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *
         return hr;
     }
 
-    map = shader->baseShader.reg_maps.input_registers;
+    map = reg_maps->input_registers;
     for (i = 0; map; map >>= 1, ++i)
     {
         if (!(map & 1) || !shader->baseShader.input_signature[i].semantic_name) continue;
@@ -1886,7 +1886,7 @@ HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *
 
     vertexshader_set_limits(shader);
 
-    shader->baseShader.load_local_constsF = shader->baseShader.reg_maps.usesrelconstF
+    shader->baseShader.load_local_constsF = reg_maps->usesrelconstF
             && !list_empty(&shader->baseShader.constantsF);
 
     return WINED3D_OK;
-- 
1.7.2.2




More information about the wine-patches mailing list