dzn: Don't dirty bindings if root signature doesn't change
authorJesse Natalie <jenatali@microsoft.com>
Fri, 3 Mar 2023 16:47:32 +0000 (08:47 -0800)
committerMarge Bot <emma+marge@anholt.net>
Thu, 23 Mar 2023 21:48:44 +0000 (21:48 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21913>

src/microsoft/vulkan/dzn_cmd_buffer.c
src/microsoft/vulkan/dzn_private.h

index a5a82bb..28cf783 100644 (file)
@@ -3016,20 +3016,24 @@ dzn_cmd_buffer_update_pipeline(struct dzn_cmd_buffer *cmdbuf, uint32_t bindpoint
       cmdbuf->state.pipeline ? cmdbuf->state.pipeline->state : NULL;
 
    if (cmdbuf->state.bindpoint[bindpoint].dirty & DZN_CMD_BINDPOINT_DIRTY_PIPELINE) {
-      /* Changing root signature always requires re-binding descriptor heaps */
-      cmdbuf->state.bindpoint[bindpoint].dirty |= DZN_CMD_BINDPOINT_DIRTY_HEAPS;
+      if (cmdbuf->state.bindpoint[bindpoint].root_sig != pipeline->root.sig) {
+         cmdbuf->state.bindpoint[bindpoint].root_sig = pipeline->root.sig;
+         /* Changing root signature always requires re-binding descriptor heaps */
+         cmdbuf->state.bindpoint[bindpoint].dirty |= DZN_CMD_BINDPOINT_DIRTY_HEAPS;
+         if (bindpoint == VK_PIPELINE_BIND_POINT_GRAPHICS)
+            ID3D12GraphicsCommandList1_SetGraphicsRootSignature(cmdbuf->cmdlist, pipeline->root.sig);
+         else
+            ID3D12GraphicsCommandList1_SetComputeRootSignature(cmdbuf->cmdlist, pipeline->root.sig);
+      }
       if (bindpoint == VK_PIPELINE_BIND_POINT_GRAPHICS) {
          struct dzn_graphics_pipeline *gfx =
             (struct dzn_graphics_pipeline *)pipeline;
-         ID3D12GraphicsCommandList1_SetGraphicsRootSignature(cmdbuf->cmdlist, pipeline->root.sig);
          ID3D12GraphicsCommandList1_IASetPrimitiveTopology(cmdbuf->cmdlist, gfx->ia.topology);
          dzn_graphics_pipeline_get_state(gfx, &cmdbuf->state.pipeline_variant);
          if (gfx->multiview.native_view_instancing)
             ID3D12GraphicsCommandList1_SetViewInstanceMask(cmdbuf->cmdlist, gfx->multiview.view_mask);
          else
             ID3D12GraphicsCommandList1_SetViewInstanceMask(cmdbuf->cmdlist, 1);
-      } else {
-         ID3D12GraphicsCommandList1_SetComputeRootSignature(cmdbuf->cmdlist, pipeline->root.sig);
       }
    }
 
index ea4324a..7d300c3 100644 (file)
@@ -597,6 +597,7 @@ struct dzn_cmd_buffer_state {
    uint32_t dirty;
    struct {
       struct dzn_pipeline *pipeline;
+      ID3D12RootSignature *root_sig;
       struct dzn_descriptor_state desc_state;
       uint32_t dirty;
    } bindpoint[NUM_BIND_POINT];