i965: Make upload_sampler_state_table a virtual function.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 26 Jun 2013 05:29:19 +0000 (22:29 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 19 Aug 2013 20:16:59 +0000 (13:16 -0700)
This allows us to coalesce the brw_samplers and gen7_samplers atoms.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_vtbl.c
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
src/mesa/drivers/dri/i965/gen7_sampler_state.c

index 1715c56aa72e9d2cfe8c42fc156ed2188da93247..5280b8831fe7d365f7b860b86f1773883d8d250f 100644 (file)
@@ -815,6 +815,12 @@ struct brw_context
                                      uint32_t *out_offset,
                                       bool dword_pitch);
 
+      /** Upload a SAMPLER_STATE table. */
+      void (*upload_sampler_state_table)(struct brw_context *brw,
+                                         uint32_t *sampler_count,
+                                         uint32_t *sst_offset,
+                                         uint32_t *sdc_offset);
+
       /**
        * Send the appropriate state packets to configure depth, stencil, and
        * HiZ buffers (i965+ only)
index dde9f1f4423a75734b65e9207156ac57d2691d6f..6eaa4a64d1ec54e0a5e2a4c78694bd2ef4c606ae 100644 (file)
@@ -111,7 +111,6 @@ extern const struct brw_tracked_state gen7_cc_viewport_state_pointer;
 extern const struct brw_tracked_state gen7_clip_state;
 extern const struct brw_tracked_state gen7_disable_stages;
 extern const struct brw_tracked_state gen7_ps_state;
-extern const struct brw_tracked_state gen7_samplers;
 extern const struct brw_tracked_state gen7_sbe_state;
 extern const struct brw_tracked_state gen7_sf_clip_viewport;
 extern const struct brw_tracked_state gen7_sf_state;
@@ -210,6 +209,10 @@ 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_init_vtable_sampler_functions(struct brw_context *brw);
 
 /* gen6_sf_state.c */
 uint32_t
index 06511ee765f5862433566adc03ea61371530f4d8..3f34d39268d8faea330c5640ef326b672506bdb2 100644 (file)
@@ -206,7 +206,7 @@ static const struct brw_tracked_state *gen7_atoms[] =
    &brw_vs_binding_table,
    &brw_wm_binding_table,
 
-   &gen7_samplers,
+   &brw_samplers,
    &gen6_multisample_state,
 
    &gen7_disable_stages,
index 9cddbc28fb6b2e29c4e630beca8ac0d60e5ce29c..aee88e0ea4f4a9bae524a2f0e9a923b905c79efb 100644 (file)
@@ -161,9 +161,11 @@ void brwInitVtbl( struct brw_context *brw )
    assert(brw->gen >= 4);
    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 if (brw->gen >= 4) {
       gen4_init_vtable_surface_functions(brw);
+      gen4_init_vtable_sampler_functions(brw);
       brw->vtbl.emit_depth_stencil_hiz = brw_emit_depth_stencil_hiz;
    }
 }
index e2b4b8dad366c793c3591f5fa7cdbc3bc20c2b30..78366ca19f423f77366c0dd1bdfc7c79b3ca7c69 100644 (file)
@@ -410,15 +410,15 @@ brw_upload_sampler_state_table(struct brw_context *brw,
 static void
 brw_upload_samplers(struct brw_context *brw)
 {
-   brw_upload_sampler_state_table(brw,
-                                  &brw->wm.sampler_count,
-                                  &brw->wm.sampler_offset,
-                                  brw->wm.sdc_offset);
-
-   brw_upload_sampler_state_table(brw,
-                                  &brw->vs.sampler_count,
-                                  &brw->vs.sampler_offset,
-                                  brw->vs.sdc_offset);
+   brw->vtbl.upload_sampler_state_table(brw,
+                                        &brw->wm.sampler_count,
+                                        &brw->wm.sampler_offset,
+                                        brw->wm.sdc_offset);
+
+   brw->vtbl.upload_sampler_state_table(brw,
+                                        &brw->vs.sampler_count,
+                                        &brw->vs.sampler_offset,
+                                        brw->vs.sdc_offset);
 }
 
 const struct brw_tracked_state brw_samplers = {
@@ -432,4 +432,8 @@ const struct brw_tracked_state brw_samplers = {
    .emit = brw_upload_samplers,
 };
 
-
+void
+gen4_init_vtable_sampler_functions(struct brw_context *brw)
+{
+   brw->vtbl.upload_sampler_state_table = brw_upload_sampler_state_table;
+}
index 45bee7850c2dc6dc4aa64a394b702f2914524284..c7b69d5d6c6cbe74433bad3259d4028474a54f65 100644 (file)
@@ -222,27 +222,8 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
    brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
 }
 
-static void
-gen7_upload_samplers(struct brw_context *brw)
+void
+gen7_init_vtable_sampler_functions(struct brw_context *brw)
 {
-   gen7_upload_sampler_state_table(brw,
-                                   &brw->wm.sampler_count,
-                                   &brw->wm.sampler_offset,
-                                   brw->wm.sdc_offset);
-
-   gen7_upload_sampler_state_table(brw,
-                                   &brw->vs.sampler_count,
-                                   &brw->vs.sampler_offset,
-                                   brw->vs.sdc_offset);
+   brw->vtbl.upload_sampler_state_table = gen7_upload_sampler_state_table;
 }
-
-const struct brw_tracked_state gen7_samplers = {
-   .dirty = {
-      .mesa = _NEW_TEXTURE,
-      .brw = BRW_NEW_BATCH |
-             BRW_NEW_VERTEX_PROGRAM |
-             BRW_NEW_FRAGMENT_PROGRAM,
-      .cache = 0
-   },
-   .emit = gen7_upload_samplers,
-};