lavapipe: break out pipeline layout creation for reuse
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 6 Mar 2023 20:21:54 +0000 (15:21 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 31 Mar 2023 13:19:27 +0000 (13:19 +0000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22233>

src/gallium/frontends/lavapipe/lvp_descriptor_set.c
src/gallium/frontends/lavapipe/lvp_private.h

index a1680cb..4482f25 100644 (file)
@@ -223,18 +223,13 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDescriptorSetLayout(
    return VK_SUCCESS;
 }
 
-VKAPI_ATTR VkResult VKAPI_CALL lvp_CreatePipelineLayout(
-    VkDevice                                    _device,
-    const VkPipelineLayoutCreateInfo*           pCreateInfo,
-    const VkAllocationCallbacks*                pAllocator,
-    VkPipelineLayout*                           pPipelineLayout)
+struct lvp_pipeline_layout *
+lvp_pipeline_layout_create(struct lvp_device *device,
+                           const VkPipelineLayoutCreateInfo*           pCreateInfo,
+                           const VkAllocationCallbacks*                pAllocator)
 {
-   LVP_FROM_HANDLE(lvp_device, device, _device);
-   struct lvp_pipeline_layout *layout;
-
-   layout = vk_pipeline_layout_zalloc(&device->vk, sizeof(*layout),
-                                      pCreateInfo);
-
+   struct lvp_pipeline_layout *layout = vk_pipeline_layout_zalloc(&device->vk, sizeof(*layout),
+                                                                  pCreateInfo);
    for (uint32_t set = 0; set < layout->vk.set_count; set++) {
       if (layout->vk.set_layouts[set] == NULL)
          continue;
@@ -299,6 +294,17 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreatePipelineLayout(
       layout->push_constant_stages |= (range->stageFlags & BITFIELD_MASK(MESA_SHADER_STAGES));
    }
    layout->push_constant_size = align(layout->push_constant_size, 16);
+   return layout;
+}
+
+VKAPI_ATTR VkResult VKAPI_CALL lvp_CreatePipelineLayout(
+    VkDevice                                    _device,
+    const VkPipelineLayoutCreateInfo*           pCreateInfo,
+    const VkAllocationCallbacks*                pAllocator,
+    VkPipelineLayout*                           pPipelineLayout)
+{
+   LVP_FROM_HANDLE(lvp_device, device, _device);
+   struct lvp_pipeline_layout *layout = lvp_pipeline_layout_create(device, pCreateInfo, pAllocator);
    *pPipelineLayout = lvp_pipeline_layout_to_handle(layout);
 
    return VK_SUCCESS;
index c0b3233..8cf0c3f 100644 (file)
@@ -399,6 +399,12 @@ struct lvp_pipeline_layout {
    } stage[MESA_SHADER_STAGES];
 };
 
+
+struct lvp_pipeline_layout *
+lvp_pipeline_layout_create(struct lvp_device *device,
+                           const VkPipelineLayoutCreateInfo*           pCreateInfo,
+                           const VkAllocationCallbacks*                pAllocator);
+
 struct lvp_access_info {
    uint64_t images_read;
    uint64_t images_written;