vulkan,radv: Remove vk_shader_module_clone
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Sat, 12 Nov 2022 17:48:22 +0000 (18:48 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 14 Nov 2022 20:56:27 +0000 (20:56 +0000)
The helper used ralloc which is unusual for vulkan objects, did not
handle allocation failures properly and was only useful for RADV.

Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19700>

src/amd/vulkan/radv_pipeline_rt.c
src/vulkan/runtime/vk_shader_module.c
src/vulkan/runtime/vk_shader_module.h

index ba11317..cb7d91f 100644 (file)
@@ -142,7 +142,18 @@ radv_rt_pipeline_library_create(VkDevice _device, VkPipelineCache _cache,
                                  PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT);
 
          if (module) {
-            struct vk_shader_module *new_module = vk_shader_module_clone(NULL, module);
+            struct vk_shader_module *new_module =
+               ralloc_size(NULL, sizeof(struct vk_shader_module) + module->size);
+            if (!new_module)
+               goto fail;
+
+            vk_object_base_init(&device->vk, &new_module->base, VK_OBJECT_TYPE_SHADER_MODULE);
+
+            new_module->nir = NULL;
+            memcpy(new_module->sha1, module->sha1, sizeof(module->sha1));
+            new_module->size = module->size;
+            memcpy(new_module->data, module->data, module->size);
+
             pipeline->stages[i].module = vk_shader_module_to_handle(new_module);
             pipeline->stages[i].pNext = NULL;
          } else {
index 7519d52..b9ca8a9 100644 (file)
@@ -135,21 +135,3 @@ vk_shader_module_to_nir(struct vk_device *device,
                                           spirv_options, nir_options,
                                           mem_ctx, nir_out);
 }
-
-struct vk_shader_module *
-vk_shader_module_clone(void *mem_ctx, const struct vk_shader_module *src)
-{
-   struct vk_shader_module *dst =
-      ralloc_size(mem_ctx, sizeof(struct vk_shader_module) + src->size);
-
-   vk_object_base_init(src->base.device, &dst->base, VK_OBJECT_TYPE_SHADER_MODULE);
-
-   dst->nir = NULL;
-
-   memcpy(dst->sha1, src->sha1, sizeof(src->sha1));
-
-   dst->size = src->size;
-   memcpy(dst->data, src->data, src->size);
-
-   return dst;
-}
index 430abaf..4748450 100644 (file)
@@ -62,9 +62,6 @@ vk_shader_module_to_nir(struct vk_device *device,
                         const struct nir_shader_compiler_options *nir_options,
                         void *mem_ctx, struct nir_shader **nir_out);
 
-struct vk_shader_module *vk_shader_module_clone(void *mem_ctx,
-                                                const struct vk_shader_module *src);
-
 /* this should only be used for stack-allocated, temporary objects */
 #define vk_shader_module_handle_from_nir(_nir) \
    ((VkShaderModule)(uintptr_t)&(struct vk_shader_module) { \