nvk: Split pipeline binding into helpers
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 31 Jan 2023 02:11:52 +0000 (20:11 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:56 +0000 (21:31 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/nvk_cmd_buffer.c
src/nouveau/vulkan/nvk_cmd_buffer.h
src/nouveau/vulkan/nvk_cmd_dispatch.c
src/nouveau/vulkan/nvk_cmd_draw.c

index 9d69e78..cb52fe4 100644 (file)
@@ -371,23 +371,22 @@ nvk_CmdBindPipeline(VkCommandBuffer commandBuffer,
    VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer);
    VK_FROM_HANDLE(nvk_pipeline, pipeline, _pipeline);
 
+   for (unsigned s = 0; s < ARRAY_SIZE(pipeline->shaders); s++) {
+      if (!pipeline->shaders[s].bo)
+         continue;
+
+      nouveau_ws_push_ref(cmd->push, pipeline->shaders[s].bo,
+                          NOUVEAU_WS_BO_RD);
+   }
+
    switch (pipelineBindPoint) {
    case VK_PIPELINE_BIND_POINT_GRAPHICS:
-      for (unsigned s = 0; s < ARRAY_SIZE(pipeline->shaders); s++) {
-         if (!pipeline->shaders[s].bo)
-            continue;
-
-         nouveau_ws_push_ref(cmd->push, pipeline->shaders[s].bo,
-                             NOUVEAU_WS_BO_RD);
-      }
-      cmd->state.gfx.pipeline = (struct nvk_graphics_pipeline *)pipeline;
+      assert(pipeline->type == NVK_PIPELINE_GRAPHICS);
+      nvk_cmd_bind_graphics_pipeline(cmd, (void *)pipeline);
       break;
    case VK_PIPELINE_BIND_POINT_COMPUTE:
       assert(pipeline->type == NVK_PIPELINE_COMPUTE);
-      nouveau_ws_push_ref(cmd->push,
-                          pipeline->shaders[MESA_SHADER_COMPUTE].bo,
-                          NOUVEAU_WS_BO_RD);
-      cmd->state.cs.pipeline = (struct nvk_compute_pipeline *)pipeline;
+      nvk_cmd_bind_compute_pipeline(cmd, (void *)pipeline);
       break;
    default:
       unreachable("Unhandled bind point");
index d4d145d..c326be5 100644 (file)
@@ -100,6 +100,11 @@ void nvk_cmd_buffer_begin_graphics(struct nvk_cmd_buffer *cmd,
 void nvk_cmd_buffer_begin_compute(struct nvk_cmd_buffer *cmd,
                                   const VkCommandBufferBeginInfo *pBeginInfo);
 
+void nvk_cmd_bind_graphics_pipeline(struct nvk_cmd_buffer *cmd,
+                                    struct nvk_graphics_pipeline *pipeline);
+void nvk_cmd_bind_compute_pipeline(struct nvk_cmd_buffer *cmd,
+                                   struct nvk_compute_pipeline *pipeline);
+
 static inline struct nvk_descriptor_state *
 nvk_get_descriptors_state(struct nvk_cmd_buffer *cmd,
                           VkPipelineBindPoint bind_point)
index 64ed69c..229cee4 100644 (file)
@@ -72,6 +72,13 @@ gp100_cp_launch_desc_set_cb(uint32_t *qmd, unsigned index,
    NVC0C0_QMDV02_01_DEF_SET(qmd, CONSTANT_BUFFER_VALID, index, TRUE);
 }
 
+void
+nvk_cmd_bind_compute_pipeline(struct nvk_cmd_buffer *cmd,
+                              struct nvk_compute_pipeline *pipeline)
+{
+   cmd->state.cs.pipeline = pipeline;
+}
+
 VKAPI_ATTR void VKAPI_CALL
 nvk_CmdDispatch(VkCommandBuffer commandBuffer,
                 uint32_t groupCountX,
index 4299f7a..cc172e2 100644 (file)
@@ -5,3 +5,10 @@ nvk_cmd_buffer_begin_graphics(struct nvk_cmd_buffer *cmd,
                               const VkCommandBufferBeginInfo *pBeginInfo)
 {
 }
+
+void
+nvk_cmd_bind_graphics_pipeline(struct nvk_cmd_buffer *cmd,
+                               struct nvk_graphics_pipeline *pipeline)
+{
+   cmd->state.gfx.pipeline = pipeline;
+}