[Mesa-dev] [PATCH 04/11] i965: Simplify sampler setup by passing the stage state.

Eric Anholt eric at anholt.net
Thu May 1 14:21:26 PDT 2014


---
 src/mesa/drivers/dri/i965/brw_context.h          |  4 +---
 src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 29 +++++++-----------------
 src/mesa/drivers/dri/i965/gen7_sampler_state.c   |  9 ++++----
 3 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index f30d42c..379af38 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -994,9 +994,7 @@ struct brw_context
       /** Upload a SAMPLER_STATE table. */
       void (*upload_sampler_state_table)(struct brw_context *brw,
                                          struct gl_program *prog,
-                                         uint32_t sampler_count,
-                                         uint32_t *sst_offset,
-                                         uint32_t *sdc_offset);
+                                         struct brw_stage_state *stage_state);
 
       /**
        * Send the appropriate state packets to configure depth, stencil, and
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 afe952a..bbfd9e0 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -375,12 +375,11 @@ static void brw_update_sampler_state(struct brw_context *brw,
 static void
 brw_upload_sampler_state_table(struct brw_context *brw,
                                struct gl_program *prog,
-                               uint32_t sampler_count,
-                               uint32_t *sst_offset,
-                               uint32_t *sdc_offset)
+                               struct brw_stage_state *stage_state)
 {
    struct gl_context *ctx = &brw->ctx;
    struct brw_sampler_state *samplers;
+   uint32_t sampler_count = stage_state->sampler_count;
 
    GLbitfield SamplersUsed = prog->SamplersUsed;
 
@@ -389,7 +388,7 @@ brw_upload_sampler_state_table(struct brw_context *brw,
 
    samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
 			      sampler_count * sizeof(*samplers),
-			      32, sst_offset);
+			      32, &stage_state->sampler_offset);
    memset(samplers, 0, sampler_count * sizeof(*samplers));
 
    for (unsigned s = 0; s < sampler_count; s++) {
@@ -397,7 +396,8 @@ brw_upload_sampler_state_table(struct brw_context *brw,
          const unsigned unit = prog->SamplerUnits[s];
          if (ctx->Texture.Unit[unit]._Current)
             brw_update_sampler_state(brw, unit, s, &samplers[s],
-                                     *sst_offset, &sdc_offset[s]);
+                                     stage_state->sampler_offset,
+                                     &stage_state->sdc_offset[s]);
       }
    }
 
@@ -409,10 +409,7 @@ brw_upload_fs_samplers(struct brw_context *brw)
 {
    /* BRW_NEW_FRAGMENT_PROGRAM */
    struct gl_program *fs = (struct gl_program *) brw->fragment_program;
-   brw->vtbl.upload_sampler_state_table(brw, fs,
-                                        brw->wm.base.sampler_count,
-                                        &brw->wm.base.sampler_offset,
-                                        brw->wm.base.sdc_offset);
+   brw->vtbl.upload_sampler_state_table(brw, fs, &brw->wm.base);
 }
 
 const struct brw_tracked_state brw_fs_samplers = {
@@ -428,14 +425,9 @@ const struct brw_tracked_state brw_fs_samplers = {
 static void
 brw_upload_vs_samplers(struct brw_context *brw)
 {
-   struct brw_stage_state *stage_state = &brw->vs.base;
-
    /* BRW_NEW_VERTEX_PROGRAM */
    struct gl_program *vs = (struct gl_program *) brw->vertex_program;
-   brw->vtbl.upload_sampler_state_table(brw, vs,
-                                        stage_state->sampler_count,
-                                        &stage_state->sampler_offset,
-                                        stage_state->sdc_offset);
+   brw->vtbl.upload_sampler_state_table(brw, vs, &brw->vs.base);
 }
 
 
@@ -453,17 +445,12 @@ const struct brw_tracked_state brw_vs_samplers = {
 static void
 brw_upload_gs_samplers(struct brw_context *brw)
 {
-   struct brw_stage_state *stage_state = &brw->gs.base;
-
    /* BRW_NEW_GEOMETRY_PROGRAM */
    struct gl_program *gs = (struct gl_program *) brw->geometry_program;
    if (!gs)
       return;
 
-   brw->vtbl.upload_sampler_state_table(brw, gs,
-                                        stage_state->sampler_count,
-                                        &stage_state->sampler_offset,
-                                        stage_state->sdc_offset);
+   brw->vtbl.upload_sampler_state_table(brw, gs, &brw->gs.base);
 }
 
 
diff --git a/src/mesa/drivers/dri/i965/gen7_sampler_state.c b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
index 94091d8..8eb337d 100644
--- a/src/mesa/drivers/dri/i965/gen7_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
@@ -182,12 +182,11 @@ gen7_update_sampler_state(struct brw_context *brw, int unit, int ss_index,
 static void
 gen7_upload_sampler_state_table(struct brw_context *brw,
                                 struct gl_program *prog,
-                                uint32_t sampler_count,
-                                uint32_t *sst_offset,
-                                uint32_t *sdc_offset)
+                                struct brw_stage_state *stage_state)
 {
    struct gl_context *ctx = &brw->ctx;
    struct gen7_sampler_state *samplers;
+   uint32_t sampler_count = stage_state->sampler_count;
 
    GLbitfield SamplersUsed = prog->SamplersUsed;
 
@@ -196,7 +195,7 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
 
    samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
 			      sampler_count * sizeof(*samplers),
-			      32, sst_offset);
+			      32, &stage_state->sampler_offset);
    memset(samplers, 0, sampler_count * sizeof(*samplers));
 
    for (unsigned s = 0; s < sampler_count; s++) {
@@ -204,7 +203,7 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
          const unsigned unit = prog->SamplerUnits[s];
          if (ctx->Texture.Unit[unit]._Current)
             gen7_update_sampler_state(brw, unit, s, &samplers[s],
-                                      &sdc_offset[s]);
+                                      &stage_state->sdc_offset[s]);
       }
    }
 
-- 
1.9.2



More information about the mesa-dev mailing list