[Mesa-dev] [PATCH 10/23] i965: Delete gen7_upload_sampler_state_table and vtable mechanism.

Kenneth Graunke kenneth at whitecape.org
Tue Jul 29 16:29:15 PDT 2014


brw_upload_sampler_state_table now handles all generations, so we don't
need the vtable mechanism either.

There's still a lot of code duplication; the next patches will address
that.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_context.c        |  3 --
 src/mesa/drivers/dri/i965/brw_context.h        |  5 ---
 src/mesa/drivers/dri/i965/brw_sampler_state.c  | 13 ++-----
 src/mesa/drivers/dri/i965/brw_state.h          |  2 --
 src/mesa/drivers/dri/i965/gen7_sampler_state.c | 50 --------------------------
 5 files changed, 3 insertions(+), 70 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index c47ad36..89f5df5 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -639,15 +639,12 @@ brwCreateContext(gl_api api,
    brw->wm.base.stage = MESA_SHADER_FRAGMENT;
    if (brw->gen >= 8) {
       gen8_init_vtable_surface_functions(brw);
-      gen7_init_vtable_sampler_functions(brw);
       brw->vtbl.emit_depth_stencil_hiz = gen8_emit_depth_stencil_hiz;
    } else if (brw->gen >= 7) {
       gen7_init_vtable_surface_functions(brw);
-      gen7_init_vtable_sampler_functions(brw);
       brw->vtbl.emit_depth_stencil_hiz = gen7_emit_depth_stencil_hiz;
    } else {
       gen4_init_vtable_surface_functions(brw);
-      gen4_init_vtable_sampler_functions(brw);
       brw->vtbl.emit_depth_stencil_hiz = brw_emit_depth_stencil_hiz;
    }
 
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index f730cff..1bbcf46 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -929,11 +929,6 @@ struct brw_context
                                         unsigned mocs,
                                         bool rw);
 
-      /** Upload a SAMPLER_STATE table. */
-      void (*upload_sampler_state_table)(struct brw_context *brw,
-                                         struct gl_program *prog,
-                                         struct brw_stage_state *stage_state);
-
       /**
        * Send the appropriate state packets to configure depth, stencil, and
        * HiZ buffers (i965+ only)
diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c
index dc351bd..1bc8922 100644
--- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
@@ -451,7 +451,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);
+   brw_upload_sampler_state_table(brw, fs, &brw->wm.base);
 }
 
 const struct brw_tracked_state brw_fs_samplers = {
@@ -469,7 +469,7 @@ brw_upload_vs_samplers(struct brw_context *brw)
 {
    /* BRW_NEW_VERTEX_PROGRAM */
    struct gl_program *vs = (struct gl_program *) brw->vertex_program;
-   brw->vtbl.upload_sampler_state_table(brw, vs, &brw->vs.base);
+   brw_upload_sampler_state_table(brw, vs, &brw->vs.base);
 }
 
 
@@ -492,7 +492,7 @@ brw_upload_gs_samplers(struct brw_context *brw)
    if (!gs)
       return;
 
-   brw->vtbl.upload_sampler_state_table(brw, gs, &brw->gs.base);
+   brw_upload_sampler_state_table(brw, gs, &brw->gs.base);
 }
 
 
@@ -505,10 +505,3 @@ const struct brw_tracked_state brw_gs_samplers = {
    },
    .emit = brw_upload_gs_samplers,
 };
-
-
-void
-gen4_init_vtable_sampler_functions(struct brw_context *brw)
-{
-   brw->vtbl.upload_sampler_state_table = brw_upload_sampler_state_table;
-}
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 64652cb..0fda360 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -249,13 +249,11 @@ void upload_default_color(struct brw_context *brw,
 			  struct gl_sampler_object *sampler,
 			  int unit,
                           uint32_t *sdc_offset);
-void gen4_init_vtable_sampler_functions(struct brw_context *brw);
 
 /* gen7_sampler_state.c */
 void gen7_update_sampler_state(struct brw_context *brw,
                                int unit,
                                struct gen7_sampler_state *sampler_state);
-void gen7_init_vtable_sampler_functions(struct brw_context *brw);
 
 /* gen6_sf_state.c */
 void
diff --git a/src/mesa/drivers/dri/i965/gen7_sampler_state.c b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
index 66af26a..276c2b9 100644
--- a/src/mesa/drivers/dri/i965/gen7_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
@@ -177,53 +177,3 @@ gen7_update_sampler_state(struct brw_context *brw, int unit,
                                     BRW_ADDRESS_ROUNDING_ENABLE_V_MAG |
                                     BRW_ADDRESS_ROUNDING_ENABLE_R_MAG;
 }
-
-
-static void
-gen7_upload_sampler_state_table(struct brw_context *brw,
-                                struct gl_program *prog,
-                                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;
-   static const uint16_t packet_headers[] = {
-      [MESA_SHADER_VERTEX] = _3DSTATE_SAMPLER_STATE_POINTERS_VS,
-      [MESA_SHADER_GEOMETRY] = _3DSTATE_SAMPLER_STATE_POINTERS_GS,
-      [MESA_SHADER_FRAGMENT] = _3DSTATE_SAMPLER_STATE_POINTERS_PS,
-   };
-
-   GLbitfield SamplersUsed = prog->SamplersUsed;
-
-   if (sampler_count == 0)
-      return;
-
-   samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
-			      sampler_count * sizeof(*samplers),
-			      32, &stage_state->sampler_offset);
-   memset(samplers, 0, sampler_count * sizeof(*samplers));
-
-   for (unsigned s = 0; s < sampler_count; s++) {
-      if (SamplersUsed & (1 << s)) {
-         const unsigned unit = prog->SamplerUnits[s];
-         if (ctx->Texture.Unit[unit]._Current)
-            gen7_update_sampler_state(brw, unit, &samplers[s]);
-      }
-   }
-
-  if (brw->gen == 7 && !brw->is_haswell && !brw->is_baytrail &&
-      stage_state->stage == MESA_SHADER_VERTEX) {
-      gen7_emit_vs_workaround_flush(brw);
-  }
-
-   BEGIN_BATCH(2);
-   OUT_BATCH(packet_headers[stage_state->stage] << 16 | (2 - 2));
-   OUT_BATCH(stage_state->sampler_offset);
-   ADVANCE_BATCH();
-}
-
-void
-gen7_init_vtable_sampler_functions(struct brw_context *brw)
-{
-   brw->vtbl.upload_sampler_state_table = gen7_upload_sampler_state_table;
-}
-- 
2.0.2



More information about the mesa-dev mailing list