Mesa (master): mesa/main/ff_frag: Don't retrieve format if not necessary.

Marek Olšák mareko at kemper.freedesktop.org
Sat Apr 8 20:08:03 UTC 2017


Module: Mesa
Branch: master
Commit: c9b2938aeccfe131329b25e378264cc1d0080be2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c9b2938aeccfe131329b25e378264cc1d0080be2

Author: Gustaw Smolarczyk <wielkiegie at gmail.com>
Date:   Thu Mar 30 20:09:28 2017 +0200

mesa/main/ff_frag: Don't retrieve format if not necessary.

Signed-off-by: Gustaw Smolarczyk <wielkiegie at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Signed-off-by: Marek Olšák <marek.olsak at amd.com>

---

 src/mesa/main/ff_fragment_shader.cpp | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 2b4d99c879..e1fe9b58c0 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -402,24 +402,21 @@ static GLuint make_state_key( struct gl_context *ctx,  struct state_key *key )
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
       const struct gl_texture_object *texObj = texUnit->_Current;
       const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine;
-      const struct gl_sampler_object *samp;
-      GLenum format;
 
       if (!texObj)
          continue;
 
-      samp = _mesa_get_samplerobj(ctx, i);
-      format = _mesa_texture_base_format(texObj);
-
       key->unit[i].enabled = 1;
       inputs_referenced |= VARYING_BIT_TEX(i);
 
       key->unit[i].source_index = texObj->TargetIndex;
 
-      key->unit[i].shadow =
-         ((samp->CompareMode == GL_COMPARE_R_TO_TEXTURE) &&
-          ((format == GL_DEPTH_COMPONENT) || 
-           (format == GL_DEPTH_STENCIL_EXT)));
+      const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, i);
+      if (samp->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
+         const GLenum format = _mesa_texture_base_format(texObj);
+         key->unit[i].shadow = (format == GL_DEPTH_COMPONENT ||
+				format == GL_DEPTH_STENCIL_EXT);
+      }
 
       key->unit[i].NumArgsRGB = comb->_NumArgsRGB;
       key->unit[i].NumArgsA = comb->_NumArgsA;




More information about the mesa-commit mailing list