Henri Verbeet : wined3d: Only set fragment pipe uniforms if they' re needed by the shader.

Alexandre Julliard julliard at winehq.org
Fri Aug 16 14:23:46 CDT 2013


Module: wine
Branch: master
Commit: c1af40505402ea4e5e4233a4ac739117a00429c7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c1af40505402ea4e5e4233a4ac739117a00429c7

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri Aug 16 09:12:29 2013 +0200

wined3d: Only set fragment pipe uniforms if they're needed by the shader.

In principle the GL driver also checks the location, but it turns out to be
slightly faster to do it ourselves.

---

 dlls/wined3d/glsl_shader.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index cbf2c60..e61b479 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -908,16 +908,26 @@ static void shader_glsl_load_constants(void *shader_priv, const struct wined3d_c
 
         for (i = 0; i < MAX_TEXTURES; ++i)
         {
+            if (prog->ps.bumpenv_mat_location[i] == -1)
+                continue;
+
             GL_EXTCALL(glUniformMatrix2fvARB(prog->ps.bumpenv_mat_location[i], 1, 0,
-                        (const float *)&state->texture_states[i][WINED3D_TSS_BUMPENV_MAT00]));
-            GL_EXTCALL(glUniform1fARB(prog->ps.bumpenv_lum_scale_location[i],
-                        *(const float *)&state->texture_states[i][WINED3D_TSS_BUMPENV_LSCALE]));
-            GL_EXTCALL(glUniform1fARB(prog->ps.bumpenv_lum_offset_location[i],
-                        *(const float *)&state->texture_states[i][WINED3D_TSS_BUMPENV_LOFFSET]));
+                    (const float *)&state->texture_states[i][WINED3D_TSS_BUMPENV_MAT00]));
+
+            if (prog->ps.bumpenv_lum_scale_location[i] != -1)
+            {
+                GL_EXTCALL(glUniform1fvARB(prog->ps.bumpenv_lum_scale_location[i], 1,
+                        (const float *)&state->texture_states[i][WINED3D_TSS_BUMPENV_LSCALE]));
+                GL_EXTCALL(glUniform1fvARB(prog->ps.bumpenv_lum_offset_location[i], 1,
+                        (const float *)&state->texture_states[i][WINED3D_TSS_BUMPENV_LOFFSET]));
+            }
         }
 
-        D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_TEXTUREFACTOR], col);
-        GL_EXTCALL(glUniform4fARB(prog->ps.tex_factor_location, col[0], col[1], col[2], col[3]));
+        if (prog->ps.tex_factor_location != -1)
+        {
+            D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_TEXTUREFACTOR], col);
+            GL_EXTCALL(glUniform4fvARB(prog->ps.tex_factor_location, 1, col));
+        }
 
         if (state->render_states[WINED3D_RS_SPECULARENABLE])
             GL_EXTCALL(glUniform4fARB(prog->ps.specular_enable_location, 1.0f, 1.0f, 1.0f, 0.0f));




More information about the wine-cvs mailing list