i965: Simplify sampler setup by passing the stage state.
authorEric Anholt <eric@anholt.net>
Mon, 28 Apr 2014 16:23:57 +0000 (09:23 -0700)
committerEric Anholt <eric@anholt.net>
Sat, 3 May 2014 00:01:40 +0000 (17:01 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
src/mesa/drivers/dri/i965/gen7_sampler_state.c

index f30d42c552ec95f902f6a870ee2555450fa10e12..379af38cba01d6d91d09fdb8648cd8f556188d1b 100644 (file)
@@ -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
index afe952a01ad99671c04c0c3459e9b249030bb53a..bbfd9e053d8def686ffc08cc86b6f8fea68132ea 100644 (file)
@@ -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);
 }
 
 
index 94091d8cecf4958b17eaa9390652532e8288b88c..8eb337d5492e557d4911a41bea508e23d14c32c7 100644 (file)
@@ -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]);
       }
    }