vk: Emit PIPELINE_SELECT on demand
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Thu, 11 Jun 2015 22:21:49 +0000 (15:21 -0700)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Thu, 11 Jun 2015 22:21:49 +0000 (15:21 -0700)
src/vulkan/device.c
src/vulkan/private.h

index 9e872de89b679ed5470b5fde10b3d07e6edfde02..e44fb2b1cd93604334a6cfda0f2cf0977a99b5c4 100644 (file)
@@ -2424,10 +2424,8 @@ VkResult anv_BeginCommandBuffer(
 {
    struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
 
-   anv_batch_emit(&cmd_buffer->batch, GEN8_PIPELINE_SELECT,
-                  .PipelineSelection = _3D);
-
    anv_cmd_buffer_emit_state_base_address(cmd_buffer);
+   cmd_buffer->current_pipeline = UINT32_MAX;
 
    return VK_SUCCESS;
 }
@@ -3071,6 +3069,14 @@ anv_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
 
    uint32_t vb_emit = cmd_buffer->vb_dirty & pipeline->vb_used;
 
+   assert((pipeline->active_stages & VK_SHADER_STAGE_COMPUTE_BIT) == 0);
+
+   if (cmd_buffer->current_pipeline != _3D) {
+      anv_batch_emit(&cmd_buffer->batch, GEN8_PIPELINE_SELECT,
+                     .PipelineSelection = _3D);
+      cmd_buffer->current_pipeline = _3D;
+   }
+
    if (vb_emit) {
       const uint32_t num_buffers = __builtin_popcount(vb_emit);
       const uint32_t num_dwords = 1 + num_buffers * 4;
index 3e4dc796420ba010bf656619f74c702ebdd45648..8bc5fd108800dabbca12653e53fcd6f7c20ebc7f 100644 (file)
@@ -650,6 +650,7 @@ struct anv_cmd_buffer {
    struct anv_state_stream                      dynamic_state_stream;
 
    /* State required while building cmd buffer */
+   uint32_t                                     current_pipeline;
    uint32_t                                     vb_dirty;
    uint32_t                                     dirty;
    uint32_t                                     descriptors_dirty;