Mesa (main): anv: move CreateComputePipelines to common code
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 19 03:28:38 UTC 2022
Module: Mesa
Branch: main
Commit: ffc798c364bd72b2cbf4c26aa9bc782d8e4ecbb2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffc798c364bd72b2cbf4c26aa9bc782d8e4ecbb2
Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date: Sat Jan 22 22:33:35 2022 +0200
anv: move CreateComputePipelines to common code
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>
---
src/intel/vulkan/anv_genX.h | 3 ++
src/intel/vulkan/anv_pipeline.c | 85 ++++++++++++++++++++++++++++++++++-
src/intel/vulkan/anv_private.h | 5 ---
src/intel/vulkan/genX_pipeline.c | 96 +++-------------------------------------
4 files changed, 93 insertions(+), 96 deletions(-)
diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h
index 88e7258651f..d64593076e0 100644
--- a/src/intel/vulkan/anv_genX.h
+++ b/src/intel/vulkan/anv_genX.h
@@ -174,3 +174,6 @@ genX(graphics_pipeline_emit)(struct anv_graphics_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
const VkPipelineRenderingCreateInfo *rendering_info,
const VkRenderingSelfDependencyInfoMESA *rsd_info);
+
+void
+genX(compute_pipeline_emit)(struct anv_compute_pipeline *pipeline);
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index cc5d4d98dc1..e42e881f45b 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1802,7 +1802,7 @@ fail:
return result;
}
-VkResult
+static VkResult
anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline,
struct vk_pipeline_cache *cache,
const VkComputePipelineCreateInfo *info)
@@ -1979,6 +1979,89 @@ anv_rendering_uses_color_attachment(const VkPipelineRenderingCreateInfo *renderi
return false;
}
+static VkResult
+anv_compute_pipeline_create(struct anv_device *device,
+ struct vk_pipeline_cache *cache,
+ const VkComputePipelineCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkPipeline *pPipeline)
+{
+ struct anv_compute_pipeline *pipeline;
+ VkResult result;
+
+ assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO);
+
+ pipeline = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*pipeline), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (pipeline == NULL)
+ return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
+
+ result = anv_pipeline_init(&pipeline->base, device,
+ ANV_PIPELINE_COMPUTE, pCreateInfo->flags,
+ pAllocator);
+ if (result != VK_SUCCESS) {
+ vk_free2(&device->vk.alloc, pAllocator, pipeline);
+ return result;
+ }
+
+ anv_batch_set_storage(&pipeline->base.batch, ANV_NULL_ADDRESS,
+ pipeline->batch_data, sizeof(pipeline->batch_data));
+
+ result = anv_pipeline_compile_cs(pipeline, cache, pCreateInfo);
+ if (result != VK_SUCCESS) {
+ anv_pipeline_finish(&pipeline->base, device, pAllocator);
+ vk_free2(&device->vk.alloc, pAllocator, pipeline);
+ return result;
+ }
+
+ anv_genX(&device->info, compute_pipeline_emit)(pipeline);
+
+ *pPipeline = anv_pipeline_to_handle(&pipeline->base);
+
+ return pipeline->base.batch.status;
+}
+
+VkResult anv_CreateComputePipelines(
+ VkDevice _device,
+ VkPipelineCache pipelineCache,
+ uint32_t count,
+ const VkComputePipelineCreateInfo* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
+ VkPipeline* pPipelines)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ ANV_FROM_HANDLE(vk_pipeline_cache, pipeline_cache, pipelineCache);
+
+ VkResult result = VK_SUCCESS;
+
+ unsigned i;
+ for (i = 0; i < count; i++) {
+ VkResult res = anv_compute_pipeline_create(device, pipeline_cache,
+ &pCreateInfos[i],
+ pAllocator, &pPipelines[i]);
+
+ if (res == VK_SUCCESS)
+ continue;
+
+ /* Bail out on the first error != VK_PIPELINE_COMPILE_REQUIRED as it
+ * is not obvious what error should be report upon 2 different failures.
+ * */
+ result = res;
+ if (res != VK_PIPELINE_COMPILE_REQUIRED)
+ break;
+
+ pPipelines[i] = VK_NULL_HANDLE;
+
+ if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT)
+ break;
+ }
+
+ for (; i < count; i++)
+ pPipelines[i] = VK_NULL_HANDLE;
+
+ return result;
+}
+
/**
* Copy pipeline state not marked as dynamic.
* Dynamic state is pipeline state which hasn't been provided at pipeline
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 7202799d66b..2f052e1335c 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -3542,11 +3542,6 @@ anv_pipeline_finish(struct anv_pipeline *pipeline,
struct anv_device *device,
const VkAllocationCallbacks *pAllocator);
-VkResult
-anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline,
- struct vk_pipeline_cache *cache,
- const VkComputePipelineCreateInfo *info);
-
VkResult
anv_ray_tracing_pipeline_init(struct anv_ray_tracing_pipeline *pipeline,
struct anv_device *device,
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index 9ec9f329188..77112eadccf 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -2771,10 +2771,10 @@ genX(graphics_pipeline_emit)(struct anv_graphics_pipeline *pipeline,
#if GFX_VERx10 >= 125
-static void
-emit_compute_state(struct anv_compute_pipeline *pipeline,
- const struct anv_device *device)
+void
+genX(compute_pipeline_emit)(struct anv_compute_pipeline *pipeline)
{
+ struct anv_device *device = pipeline->base.device;
const struct brw_cs_prog_data *cs_prog_data = get_cs_prog_data(pipeline);
anv_pipeline_setup_l3_config(&pipeline->base, cs_prog_data->base.total_shared > 0);
@@ -2791,10 +2791,10 @@ emit_compute_state(struct anv_compute_pipeline *pipeline,
#else /* #if GFX_VERx10 >= 125 */
-static void
-emit_compute_state(struct anv_compute_pipeline *pipeline,
- const struct anv_device *device)
+void
+genX(compute_pipeline_emit)(struct anv_compute_pipeline *pipeline)
{
+ struct anv_device *device = pipeline->base.device;
const struct intel_device_info *devinfo = &device->info;
const struct brw_cs_prog_data *cs_prog_data = get_cs_prog_data(pipeline);
@@ -2896,90 +2896,6 @@ emit_compute_state(struct anv_compute_pipeline *pipeline,
#endif /* #if GFX_VERx10 >= 125 */
-static VkResult
-compute_pipeline_create(
- VkDevice _device,
- struct vk_pipeline_cache * cache,
- const VkComputePipelineCreateInfo* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkPipeline* pPipeline)
-{
- ANV_FROM_HANDLE(anv_device, device, _device);
- struct anv_compute_pipeline *pipeline;
- VkResult result;
-
- assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO);
-
- pipeline = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*pipeline), 8,
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
- if (pipeline == NULL)
- return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
-
- result = anv_pipeline_init(&pipeline->base, device,
- ANV_PIPELINE_COMPUTE, pCreateInfo->flags,
- pAllocator);
- if (result != VK_SUCCESS) {
- vk_free2(&device->vk.alloc, pAllocator, pipeline);
- return result;
- }
-
- anv_batch_set_storage(&pipeline->base.batch, ANV_NULL_ADDRESS,
- pipeline->batch_data, sizeof(pipeline->batch_data));
-
- result = anv_pipeline_compile_cs(pipeline, cache, pCreateInfo);
- if (result != VK_SUCCESS) {
- anv_pipeline_finish(&pipeline->base, device, pAllocator);
- vk_free2(&device->vk.alloc, pAllocator, pipeline);
- if (result == VK_PIPELINE_COMPILE_REQUIRED)
- *pPipeline = VK_NULL_HANDLE;
- return result;
- }
-
- emit_compute_state(pipeline, device);
-
- *pPipeline = anv_pipeline_to_handle(&pipeline->base);
-
- return pipeline->base.batch.status;
-}
-
-VkResult genX(CreateComputePipelines)(
- VkDevice _device,
- VkPipelineCache pipelineCache,
- uint32_t count,
- const VkComputePipelineCreateInfo* pCreateInfos,
- const VkAllocationCallbacks* pAllocator,
- VkPipeline* pPipelines)
-{
- VK_FROM_HANDLE(vk_pipeline_cache, pipeline_cache, pipelineCache);
-
- VkResult result = VK_SUCCESS;
-
- unsigned i;
- for (i = 0; i < count; i++) {
- VkResult res = compute_pipeline_create(_device, pipeline_cache,
- &pCreateInfos[i],
- pAllocator, &pPipelines[i]);
-
- if (res == VK_SUCCESS)
- continue;
-
- /* Bail out on the first error != VK_PIPELINE_COMPILE_REQUIRED_EX as it
- * is not obvious what error should be report upon 2 different failures.
- * */
- result = res;
- if (res != VK_PIPELINE_COMPILE_REQUIRED)
- break;
-
- if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT)
- break;
- }
-
- for (; i < count; i++)
- pPipelines[i] = VK_NULL_HANDLE;
-
- return result;
-}
-
#if GFX_VERx10 >= 125
static void
More information about the mesa-commit
mailing list