[Mesa-dev] [PATCH 03/10] i965: Un-hardcode border color table from update_sampler_state().

Kenneth Graunke kenneth at whitecape.org
Wed Aug 14 18:55:09 PDT 2013


Like the previous patch, this simply pushes direct access to brw->wm up
one level in the call chain.  Rather than passing the whole array, we
just pass a pointer to the correct spot in the array, similar to what we
do for the actual sampler state structure.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 14 ++++++++------
 src/mesa/drivers/dri/i965/gen7_sampler_state.c   | 10 ++++++----
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
index 5984e45..ad78864 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -194,7 +194,8 @@ upload_default_color(struct brw_context *brw,
 static void brw_update_sampler_state(struct brw_context *brw,
 				     int unit,
                                      int ss_index,
-				     struct brw_sampler_state *sampler)
+                                     struct brw_sampler_state *sampler,
+                                     uint32_t *sdc_offset)
 {
    struct gl_context *ctx = &brw->ctx;
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -336,20 +337,20 @@ static void brw_update_sampler_state(struct brw_context *brw,
       sampler->ss3.non_normalized_coord = 1;
    }
 
-   upload_default_color(brw, gl_sampler, unit, &brw->wm.sdc_offset[ss_index]);
+   upload_default_color(brw, gl_sampler, unit, sdc_offset);
 
    if (brw->gen >= 6) {
-      sampler->ss2.default_color_pointer = brw->wm.sdc_offset[ss_index] >> 5;
+      sampler->ss2.default_color_pointer = *sdc_offset >> 5;
    } else {
       /* reloc */
       sampler->ss2.default_color_pointer = (brw->batch.bo->offset +
-					    brw->wm.sdc_offset[ss_index]) >> 5;
+					    *sdc_offset) >> 5;
 
       drm_intel_bo_emit_reloc(brw->batch.bo,
 			      brw->sampler.offset +
 			      ss_index * sizeof(struct brw_sampler_state) +
 			      offsetof(struct brw_sampler_state, ss2),
-			      brw->batch.bo, brw->wm.sdc_offset[ss_index],
+			      brw->batch.bo, *sdc_offset,
 			      I915_GEM_DOMAIN_SAMPLER, 0);
    }
 
@@ -396,7 +397,8 @@ brw_upload_samplers(struct brw_context *brw)
          const unsigned unit = (fs->SamplersUsed & (1 << s)) ?
             fs->SamplerUnits[s] : vs->SamplerUnits[s];
          if (ctx->Texture.Unit[unit]._ReallyEnabled)
-            brw_update_sampler_state(brw, unit, s, &samplers[s]);
+            brw_update_sampler_state(brw, unit, s, &samplers[s],
+                                     &brw->wm.sdc_offset[s]);
       }
    }
 
diff --git a/src/mesa/drivers/dri/i965/gen7_sampler_state.c b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
index 4200f8d..dd2493c 100644
--- a/src/mesa/drivers/dri/i965/gen7_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
@@ -34,7 +34,8 @@
  */
 static void
 gen7_update_sampler_state(struct brw_context *brw, int unit, int ss_index,
-			  struct gen7_sampler_state *sampler)
+			  struct gen7_sampler_state *sampler,
+                          uint32_t *sdc_offset)
 {
    struct gl_context *ctx = &brw->ctx;
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -168,9 +169,9 @@ gen7_update_sampler_state(struct brw_context *brw, int unit, int ss_index,
       sampler->ss3.non_normalized_coord = 1;
    }
 
-   upload_default_color(brw, gl_sampler, unit, &brw->wm.sdc_offset[ss_index]);
+   upload_default_color(brw, gl_sampler, unit, sdc_offset);
 
-   sampler->ss2.default_color_pointer = brw->wm.sdc_offset[ss_index] >> 5;
+   sampler->ss2.default_color_pointer = *sdc_offset >> 5;
 
    if (sampler->ss0.min_filter != BRW_MAPFILTER_NEAREST)
       sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MIN |
@@ -212,7 +213,8 @@ gen7_upload_samplers(struct brw_context *brw)
          const unsigned unit = (fs->SamplersUsed & (1 << s)) ?
             fs->SamplerUnits[s] : vs->SamplerUnits[s];
          if (ctx->Texture.Unit[unit]._ReallyEnabled)
-            gen7_update_sampler_state(brw, unit, s, &samplers[s]);
+            gen7_update_sampler_state(brw, unit, s, &samplers[s],
+                                      &brw->wm.sdc_offset[s]);
       }
    }
 
-- 
1.8.3.4



More information about the mesa-dev mailing list