Mesa (master): i965: Shorten sampler loops in precompile key setup.

Kenneth Graunke kwg at kemper.freedesktop.org
Tue Aug 20 08:20:15 UTC 2013


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Aug 14 18:55:15 2013 -0700

i965: Shorten sampler loops in precompile key setup.

Now that we have the number of samplers available, we don't need to
iterate over all 16.  This should be particularly helpful for vertex
shaders.

v2: Use the correct shader program (caught by Paul Berry).

This needs to initialize the exact same set of sampler swizzles as
the actual key setup, or else we end up doing recompiles due to some
being XYZW and others being 0.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Paul Berry <stereotype441 at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_fs.cpp |    3 ++-
 src/mesa/drivers/dri/i965/brw_vs.c   |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index d111cbd..52fa6f4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3157,7 +3157,8 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
 
    key.clamp_fragment_color = ctx->API == API_OPENGL_COMPAT;
 
-   for (int i = 0; i < MAX_SAMPLERS; i++) {
+   unsigned sampler_count = _mesa_fls(fp->Base.SamplersUsed);
+   for (unsigned i = 0; i < sampler_count; i++) {
       if (fp->Base.ShadowSamplers & (1 << i)) {
          /* Assume DEPTH_TEXTURE_MODE is the default: X, X, X, 1 */
          key.tex.swizzles[i] =
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index dcd14a3..ee77b01 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -530,7 +530,8 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
    key.base.program_string_id = bvp->id;
    key.base.clamp_vertex_color = ctx->API == API_OPENGL_COMPAT;
 
-   for (int i = 0; i < MAX_SAMPLERS; i++) {
+   unsigned sampler_count = _mesa_fls(vp->Base.SamplersUsed);
+   for (unsigned i = 0; i < sampler_count; i++) {
       if (vp->Base.ShadowSamplers & (1 << i)) {
          /* Assume DEPTH_TEXTURE_MODE is the default: X, X, X, 1 */
          key.base.tex.swizzles[i] =




More information about the mesa-commit mailing list