i965/state: Emit pipeline select when changing pipelines
authorJordan Justen <jordan.l.justen@intel.com>
Wed, 22 Apr 2015 18:43:50 +0000 (11:43 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Sat, 2 May 2015 07:50:00 +0000 (00:50 -0700)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_misc_state.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_upload.c

index 1d5ef82abe3d433d9e203ec1b89ff952b0380206..542ec3d030f33f92b04aa8cf984d405f8fc828e7 100644 (file)
@@ -1148,6 +1148,8 @@ struct brw_context
       struct brw_state_flags pipelines[BRW_NUM_PIPELINES];
    } state;
 
+   enum brw_pipeline last_pipeline;
+
    struct brw_cache cache;
 
    /** IDs for meta stencil blit shader programs. */
index 78a46cb050dde3fb81644ee3e7e7feb08f60dbfb..67a693b5ec16b755dd9d4d34fbe5b69ab9380cde 100644 (file)
@@ -854,6 +854,22 @@ const struct brw_tracked_state brw_line_stipple = {
 };
 
 
+void
+brw_emit_select_pipeline(struct brw_context *brw, enum brw_pipeline pipeline)
+{
+   const bool is_965 = brw->gen == 4 && !brw->is_g4x;
+   const uint32_t _3DSTATE_PIPELINE_SELECT =
+      is_965 ? CMD_PIPELINE_SELECT_965 : CMD_PIPELINE_SELECT_GM45;
+
+   /* Select the pipeline */
+   BEGIN_BATCH(1);
+   OUT_BATCH(_3DSTATE_PIPELINE_SELECT << 16 |
+             (brw->gen >= 9 ? (3 << 8) : 0) |
+             (pipeline == BRW_COMPUTE_PIPELINE ? 2 : 0));
+   ADVANCE_BATCH();
+}
+
+
 /***********************************************************************
  * Misc invariant state packets
  */
@@ -863,12 +879,7 @@ brw_upload_invariant_state(struct brw_context *brw)
 {
    const bool is_965 = brw->gen == 4 && !brw->is_g4x;
 
-   /* Select the 3D pipeline (as opposed to media) */
-   const uint32_t _3DSTATE_PIPELINE_SELECT =
-      is_965 ? CMD_PIPELINE_SELECT_965 : CMD_PIPELINE_SELECT_GM45;
-   BEGIN_BATCH(1);
-   OUT_BATCH(_3DSTATE_PIPELINE_SELECT << 16 | (brw->gen >= 9 ? (3 << 8) : 0));
-   ADVANCE_BATCH();
+   brw_select_pipeline(brw, BRW_RENDER_PIPELINE);
 
    if (brw->gen < 6) {
       /* Disable depth offset clamping. */
index 565946d46675572bf9b980f5e03e741c7fc61348..5c27b3d367e5a9a37f876eb08bea8e3893c8ec18 100644 (file)
@@ -185,6 +185,18 @@ void brw_upload_compute_state(struct brw_context *brw);
 void brw_compute_state_finished(struct brw_context *brw);
 void brw_init_state(struct brw_context *brw);
 void brw_destroy_state(struct brw_context *brw);
+void brw_emit_select_pipeline(struct brw_context *brw,
+                              enum brw_pipeline pipeline);
+
+static inline void
+brw_select_pipeline(struct brw_context *brw, enum brw_pipeline pipeline)
+{
+   if (unlikely(brw->last_pipeline != pipeline)) {
+      assert(pipeline < BRW_NUM_PIPELINES);
+      brw_emit_select_pipeline(brw, pipeline);
+      brw->last_pipeline = pipeline;
+   }
+}
 
 /***********************************************************************
  * brw_state_cache.c
index 15d6953a7ef71087289efcedd80fb3c3fd72ec23..686a3da795ab41fd1f6d22572bc375b9733a08d8 100644 (file)
@@ -406,6 +406,9 @@ void brw_init_state( struct brw_context *brw )
 {
    struct gl_context *ctx = &brw->ctx;
 
+   /* Force the first brw_select_pipeline to emit pipeline select */
+   brw->last_pipeline = BRW_NUM_PIPELINES;
+
    STATIC_ASSERT(ARRAY_SIZE(gen4_atoms) <= ARRAY_SIZE(brw->render_atoms));
    STATIC_ASSERT(ARRAY_SIZE(gen6_atoms) <= ARRAY_SIZE(brw->render_atoms));
    STATIC_ASSERT(ARRAY_SIZE(gen7_render_atoms) <=
@@ -656,6 +659,8 @@ brw_upload_pipeline_state(struct brw_context *brw,
    static int dirty_count = 0;
    struct brw_state_flags state = brw->state.pipelines[pipeline];
 
+   brw_select_pipeline(brw, pipeline);
+
    if (0) {
       /* Always re-emit all state. */
       brw->NewGLState = ~0;