[Mesa-dev] [PATCH 06/10] i965: Move CACHE_NEW_SAMPLER to BRW_NEW_SAMPLER_STATE_TABLE.

Kenneth Graunke kenneth at whitecape.org
Tue Nov 25 04:43:38 PST 2014


This flag signifies that we've emitted a new SAMPLER_STATE table.
Given that we haven't cached those in years, CACHE_NEW_SAMPLER isn't
a great name.  Putting it in the BRW_NEW_* hierarchy would make more
sense; BRW_NEW_SAMPLER_STATE_TABLE better reflects its actual purpose.

When this flag is raised, the pointer to the SAMPLER_STATE table has
changed, so we need to re-issue any packets which point to it (unit
state on Gen4-5, 3DSTATE_SAMPLER_STATE_POINTERS on Gen6, and the
per-stage variants on Gen7+).

Saves 2 * sizeof(void *) bytes per context, as we remove useless
aux_compare/aux_free function pointers.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_context.h        | 4 ++--
 src/mesa/drivers/dri/i965/brw_sampler_state.c  | 2 +-
 src/mesa/drivers/dri/i965/brw_state_upload.c   | 2 +-
 src/mesa/drivers/dri/i965/brw_vs_state.c       | 6 +++---
 src/mesa/drivers/dri/i965/brw_wm_state.c       | 6 +++---
 src/mesa/drivers/dri/i965/gen6_sampler_state.c | 3 ++-
 6 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index cd1daee..fac22dc 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -187,6 +187,7 @@ enum brw_state_id {
    BRW_STATE_CC_VP,
    BRW_STATE_SF_VP,
    BRW_STATE_CLIP_VP,
+   BRW_STATE_SAMPLER_STATE_TABLE,
    BRW_NUM_STATE_BITS
 };
 
@@ -232,6 +233,7 @@ enum brw_state_id {
 #define BRW_NEW_CC_VP                   (1ull << BRW_STATE_CC_VP)
 #define BRW_NEW_SF_VP                   (1ull << BRW_STATE_SF_VP)
 #define BRW_NEW_CLIP_VP                 (1ull << BRW_STATE_CLIP_VP)
+#define BRW_NEW_SAMPLER_STATE_TABLE     (1ull << BRW_STATE_SAMPLER_STATE_TABLE)
 
 struct brw_state_flags {
    /** State update flags signalled by mesa internals */
@@ -693,7 +695,6 @@ struct brw_gs_prog_data
 enum brw_cache_id {
    BRW_WM_PROG,
    BRW_BLORP_BLIT_PROG,
-   BRW_SAMPLER,
    BRW_SF_PROG,
    BRW_VS_PROG,
    BRW_FF_GS_PROG,
@@ -778,7 +779,6 @@ enum shader_time_shader_type {
  */
 #define CACHE_NEW_WM_PROG                (1<<BRW_WM_PROG)
 #define CACHE_NEW_BLORP_BLIT_PROG        (1<<BRW_BLORP_BLIT_PROG)
-#define CACHE_NEW_SAMPLER                (1<<BRW_SAMPLER)
 #define CACHE_NEW_SF_PROG                (1<<BRW_SF_PROG)
 #define CACHE_NEW_VS_PROG                (1<<BRW_VS_PROG)
 #define CACHE_NEW_FF_GS_PROG             (1<<BRW_FF_GS_PROG)
diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c
index 8363a48..9c5e45c 100644
--- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
@@ -512,7 +512,7 @@ brw_upload_sampler_state_table(struct brw_context *brw,
       /* Flag that the sampler state table pointer has changed; later atoms
        * will handle it.
        */
-      brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
+      brw->state.dirty.brw |= BRW_NEW_SAMPLER_STATE_TABLE;
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index db0119c..57c4519 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -523,13 +523,13 @@ static struct dirty_bit_map brw_bits[] = {
    DEFINE_BIT(BRW_NEW_CC_VP),
    DEFINE_BIT(BRW_NEW_SF_VP),
    DEFINE_BIT(BRW_NEW_CLIP_VP),
+   DEFINE_BIT(BRW_NEW_SAMPLER_STATE_TABLE),
    {0, 0, 0}
 };
 
 static struct dirty_bit_map cache_bits[] = {
    DEFINE_BIT(CACHE_NEW_WM_PROG),
    DEFINE_BIT(CACHE_NEW_BLORP_BLIT_PROG),
-   DEFINE_BIT(CACHE_NEW_SAMPLER),
    DEFINE_BIT(CACHE_NEW_SF_PROG),
    DEFINE_BIT(CACHE_NEW_VS_PROG),
    DEFINE_BIT(CACHE_NEW_FF_GS_PROG),
diff --git a/src/mesa/drivers/dri/i965/brw_vs_state.c b/src/mesa/drivers/dri/i965/brw_vs_state.c
index 351f7ef..f9ee2d0 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_state.c
@@ -159,7 +159,7 @@ brw_upload_vs_unit(struct brw_context *brw)
    /* Set the sampler state pointer, and its reloc
     */
    if (stage_state->sampler_count) {
-      /* CACHE_NEW_SAMPLER - reloc */
+      /* BRW_NEW_SAMPLER_STATE_TABLE - reloc */
       vs->vs5.sampler_state_pointer =
          (brw->batch.bo->offset64 + stage_state->sampler_offset) >> 5;
       drm_intel_bo_emit_reloc(brw->batch.bo,
@@ -190,10 +190,10 @@ const struct brw_tracked_state brw_vs_unit = {
       .brw   = BRW_NEW_BATCH |
                BRW_NEW_CURBE_OFFSETS |
                BRW_NEW_PROGRAM_CACHE |
+               BRW_NEW_SAMPLER_STATE_TABLE |
                BRW_NEW_URB_FENCE |
                BRW_NEW_VERTEX_PROGRAM,
-      .cache = CACHE_NEW_SAMPLER |
-               CACHE_NEW_VS_PROG,
+      .cache = CACHE_NEW_VS_PROG,
    },
    .emit = brw_upload_vs_unit,
 };
diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c
index 2f315c6..763ea5f 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_state.c
@@ -154,7 +154,7 @@ brw_upload_wm_unit(struct brw_context *brw)
    }
 
    if (brw->wm.base.sampler_count) {
-      /* CACHE_NEW_SAMPLER - reloc */
+      /* BRW_NEW_SAMPLER_STATE_TABLE - reloc */
       wm->wm4.sampler_state_pointer = (brw->batch.bo->offset64 +
 				       brw->wm.base.sampler_offset) >> 5;
    } else {
@@ -256,9 +256,9 @@ const struct brw_tracked_state brw_wm_unit = {
              BRW_NEW_CURBE_OFFSETS |
              BRW_NEW_FRAGMENT_PROGRAM |
              BRW_NEW_PROGRAM_CACHE |
+             BRW_NEW_SAMPLER_STATE_TABLE |
              BRW_NEW_STATS_WM,
-      .cache = CACHE_NEW_SAMPLER |
-               CACHE_NEW_WM_PROG,
+      .cache = CACHE_NEW_WM_PROG,
    },
    .emit = brw_upload_wm_unit,
 };
diff --git a/src/mesa/drivers/dri/i965/gen6_sampler_state.c b/src/mesa/drivers/dri/i965/gen6_sampler_state.c
index 288470a..a7402cf 100644
--- a/src/mesa/drivers/dri/i965/gen6_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_sampler_state.c
@@ -49,8 +49,9 @@ const struct brw_tracked_state gen6_sampler_state = {
    .dirty = {
       .mesa = 0,
       .brw = BRW_NEW_BATCH |
+             BRW_NEW_SAMPLER_STATE_TABLE |
              BRW_NEW_STATE_BASE_ADDRESS,
-      .cache = CACHE_NEW_SAMPLER
+      .cache = 0,
    },
    .emit = upload_sampler_state_pointers,
 };
-- 
2.1.3



More information about the mesa-dev mailing list