vk: Defer setting viewport dynamic state
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Thu, 11 Jun 2015 22:04:09 +0000 (15:04 -0700)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Thu, 11 Jun 2015 22:04:09 +0000 (15:04 -0700)
We can't emit this until we've done a 3D pipeline select.

src/vulkan/device.c
src/vulkan/private.h

index f5ca70b83ec8415542bdfa211d0b3e70e0ef82fd..9e872de89b679ed5470b5fde10b3d07e6edfde02 100644 (file)
@@ -2663,20 +2663,11 @@ void anv_CmdBindDynamicStateObject(
     VkDynamicStateObject                        dynamicState)
 {
    struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
-   struct anv_dynamic_vp_state *vp_state;
 
    switch (stateBindPoint) {
    case VK_STATE_BIND_POINT_VIEWPORT:
-      vp_state = (struct anv_dynamic_vp_state *) dynamicState;
-      /* We emit state immediately, but set cmd_buffer->vp_state to indicate
-       * that vp state has been set in this command buffer. */
-      cmd_buffer->vp_state = vp_state;
-      anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_SCISSOR_STATE_POINTERS,
-                     .ScissorRectPointer = vp_state->scissor.offset);
-      anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
-                     .CCViewportPointer = vp_state->cc_vp.offset);
-      anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP,
-                     .SFClipViewportPointer = vp_state->sf_clip_vp.offset);
+      cmd_buffer->vp_state = (struct anv_dynamic_vp_state *) dynamicState;
+      cmd_buffer->dirty |= ANV_CMD_BUFFER_VP_DIRTY;
       break;
    case VK_STATE_BIND_POINT_RASTER:
       cmd_buffer->rs_state = (struct anv_dynamic_rs_state *) dynamicState;
@@ -3111,6 +3102,15 @@ anv_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
    if (cmd_buffer->descriptors_dirty)
       flush_descriptor_sets(cmd_buffer);
 
+   if (cmd_buffer->dirty & ANV_CMD_BUFFER_VP_DIRTY) {
+      anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_SCISSOR_STATE_POINTERS,
+                     .ScissorRectPointer = cmd_buffer->vp_state->scissor.offset);
+      anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
+                     .CCViewportPointer = cmd_buffer->vp_state->cc_vp.offset);
+      anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP,
+                     .SFClipViewportPointer = cmd_buffer->vp_state->sf_clip_vp.offset);
+   }
+
    if (cmd_buffer->dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_RS_DIRTY)) {
       anv_batch_emit_merge(&cmd_buffer->batch,
                            cmd_buffer->rs_state->state_sf, pipeline->state_sf);
index 9f1345fd8eda3f31aa579619a7f786c6d9f62efa..3e4dc796420ba010bf656619f74c702ebdd45648 100644 (file)
@@ -617,6 +617,7 @@ struct anv_buffer {
 #define ANV_CMD_BUFFER_RS_DIRTY                 (1 << 2)
 #define ANV_CMD_BUFFER_DS_DIRTY                 (1 << 3)
 #define ANV_CMD_BUFFER_CB_DIRTY                 (1 << 4)
+#define ANV_CMD_BUFFER_VP_DIRTY                 (1 << 5)
 
 struct anv_vertex_binding {
    struct anv_buffer *                          buffer;