[Mesa-dev] [PATCH 02/10] i965: Un-hardcode border color table from upload_default_color.

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


When we begin uploading separate sampler state tables for VS and FS,
we won't be able to use &brw->wm.sdc_offset[ss_index].  By passing it in
as a parameter, we push the problem up to the caller.

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

diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index a1236b7..dde9f1f 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -208,7 +208,8 @@ void gen7_upload_3dstate_so_decl_list(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 ss_index);
+			  int unit,
+                          uint32_t *sdc_offset);
 
 /* gen6_sf_state.c */
 uint32_t
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 40a6d5b..5984e45 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -79,8 +79,10 @@ translate_wrap_mode(GLenum wrap, bool using_nearest)
  * Upload SAMPLER_BORDER_COLOR_STATE.
  */
 void
-upload_default_color(struct brw_context *brw, struct gl_sampler_object *sampler,
-		     int unit, int ss_index)
+upload_default_color(struct brw_context *brw,
+                     struct gl_sampler_object *sampler,
+                     int unit,
+                     uint32_t *sdc_offset)
 {
    struct gl_context *ctx = &brw->ctx;
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -142,7 +144,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[ss_index]);
+			    sizeof(*sdc), 32, sdc_offset);
 
       memset(sdc, 0, sizeof(*sdc));
 
@@ -179,7 +181,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[ss_index]);
+			    sizeof(*sdc), 32, sdc_offset);
 
       COPY_4V(sdc->color, color);
    }
@@ -334,7 +336,7 @@ static void brw_update_sampler_state(struct brw_context *brw,
       sampler->ss3.non_normalized_coord = 1;
    }
 
-   upload_default_color(brw, gl_sampler, unit, ss_index);
+   upload_default_color(brw, gl_sampler, unit, &brw->wm.sdc_offset[ss_index]);
 
    if (brw->gen >= 6) {
       sampler->ss2.default_color_pointer = brw->wm.sdc_offset[ss_index] >> 5;
diff --git a/src/mesa/drivers/dri/i965/gen7_sampler_state.c b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
index f09c6b3..4200f8d 100644
--- a/src/mesa/drivers/dri/i965/gen7_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
@@ -168,7 +168,7 @@ 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, ss_index);
+   upload_default_color(brw, gl_sampler, unit, &brw->wm.sdc_offset[ss_index]);
 
    sampler->ss2.default_color_pointer = brw->wm.sdc_offset[ss_index] >> 5;
 
-- 
1.8.3.4



More information about the mesa-dev mailing list