i965: Add a "sampler state index" parameter to update_sampler_state().
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 24 Aug 2012 08:12:53 +0000 (01:12 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 25 Aug 2012 19:01:10 +0000 (12:01 -0700)
This represents the index into the sampler state table or sampler
default color table (the two are identical).

Right now, this is still the texture unit, but that will change shortly.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
src/mesa/drivers/dri/i965/gen7_sampler_state.c

index 2540cd574b2d55407bdab57f7b97cea54e1fc4f3..4e78fae5e9bc00ea1518d34b95f2d6ed97026ed6 100644 (file)
@@ -225,7 +225,7 @@ void gen7_create_constant_surface(struct brw_context *brw,
 uint32_t translate_wrap_mode(GLenum wrap, bool using_nearest);
 void upload_default_color(struct brw_context *brw,
                          struct gl_sampler_object *sampler,
-                         int unit);
+                         int unit, int ss_index);
 
 /* gen6_sf_state.c */
 uint32_t
index 27f0d706e6a3e6ae3a90c00903bbb00cc9591c5c..10deb1da0fb554b049f9eeb3e831a913a3a2367e 100644 (file)
@@ -80,7 +80,7 @@ translate_wrap_mode(GLenum wrap, bool using_nearest)
  */
 void
 upload_default_color(struct brw_context *brw, struct gl_sampler_object *sampler,
-                    int unit)
+                    int unit, int ss_index)
 {
    struct intel_context *intel = &brw->intel;
    struct gl_context *ctx = &intel->ctx;
@@ -109,7 +109,7 @@ upload_default_color(struct brw_context *brw, struct gl_sampler_object *sampler,
       struct gen5_sampler_default_color *sdc;
 
       sdc = brw_state_batch(brw, AUB_TRACE_SAMPLER_DEFAULT_COLOR,
-                           sizeof(*sdc), 32, &brw->wm.sdc_offset[unit]);
+                           sizeof(*sdc), 32, &brw->wm.sdc_offset[ss_index]);
 
       memset(sdc, 0, sizeof(*sdc));
 
@@ -146,7 +146,7 @@ upload_default_color(struct brw_context *brw, struct gl_sampler_object *sampler,
       struct brw_sampler_default_color *sdc;
 
       sdc = brw_state_batch(brw, AUB_TRACE_SAMPLER_DEFAULT_COLOR,
-                           sizeof(*sdc), 32, &brw->wm.sdc_offset[unit]);
+                           sizeof(*sdc), 32, &brw->wm.sdc_offset[ss_index]);
 
       COPY_4V(sdc->color, color);
    }
@@ -158,6 +158,7 @@ upload_default_color(struct brw_context *brw, struct gl_sampler_object *sampler,
  */
 static void brw_update_sampler_state(struct brw_context *brw,
                                     int unit,
+                                     int ss_index,
                                     struct brw_sampler_state *sampler)
 {
    struct intel_context *intel = &brw->intel;
@@ -300,20 +301,20 @@ static void brw_update_sampler_state(struct brw_context *brw,
       sampler->ss3.non_normalized_coord = 1;
    }
 
-   upload_default_color(brw, gl_sampler, unit);
+   upload_default_color(brw, gl_sampler, unit, ss_index);
 
    if (intel->gen >= 6) {
-      sampler->ss2.default_color_pointer = brw->wm.sdc_offset[unit] >> 5;
+      sampler->ss2.default_color_pointer = brw->wm.sdc_offset[ss_index] >> 5;
    } else {
       /* reloc */
       sampler->ss2.default_color_pointer = (intel->batch.bo->offset +
-                                           brw->wm.sdc_offset[unit]) >> 5;
+                                           brw->wm.sdc_offset[ss_index]) >> 5;
 
       drm_intel_bo_emit_reloc(intel->batch.bo,
                              brw->sampler.offset +
-                             unit * sizeof(struct brw_sampler_state) +
+                             ss_index * sizeof(struct brw_sampler_state) +
                              offsetof(struct brw_sampler_state, ss2),
-                             intel->batch.bo, brw->wm.sdc_offset[unit],
+                             intel->batch.bo, brw->wm.sdc_offset[ss_index],
                              I915_GEM_DOMAIN_SAMPLER, 0);
    }
 
@@ -351,7 +352,7 @@ brw_upload_samplers(struct brw_context *brw)
 
    for (i = 0; i < brw->sampler.count; i++) {
       if (ctx->Texture.Unit[i]._ReallyEnabled)
-        brw_update_sampler_state(brw, i, &samplers[i]);
+        brw_update_sampler_state(brw, i, i, &samplers[i]);
    }
 
    brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
index 3c8daf9a1538e45ef7a10656d89bb79885d3fd38..c3b67e851408e06f34169de36877e6e327d8a1c1 100644 (file)
@@ -33,7 +33,7 @@
  * Sets the sampler state for a single unit.
  */
 static void
-gen7_update_sampler_state(struct brw_context *brw, int unit,
+gen7_update_sampler_state(struct brw_context *brw, int unit, int ss_index,
                          struct gen7_sampler_state *sampler)
 {
    struct intel_context *intel = &brw->intel;
@@ -168,9 +168,9 @@ gen7_update_sampler_state(struct brw_context *brw, int unit,
       sampler->ss3.non_normalized_coord = 1;
    }
 
-   upload_default_color(brw, gl_sampler, unit);
+   upload_default_color(brw, gl_sampler, unit, ss_index);
 
-   sampler->ss2.default_color_pointer = brw->wm.sdc_offset[unit] >> 5;
+   sampler->ss2.default_color_pointer = brw->wm.sdc_offset[ss_index] >> 5;
 
    if (sampler->ss0.min_filter != BRW_MAPFILTER_NEAREST)
       sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MIN |
@@ -206,7 +206,7 @@ gen7_upload_samplers(struct brw_context *brw)
 
    for (i = 0; i < brw->sampler.count; i++) {
       if (ctx->Texture.Unit[i]._ReallyEnabled)
-        gen7_update_sampler_state(brw, i, &samplers[i]);
+        gen7_update_sampler_state(brw, i, i, &samplers[i]);
    }
 
    brw->state.dirty.cache |= CACHE_NEW_SAMPLER;