From cc61d544898b1a641c9703f4470abb411d1c8752 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 2 Feb 2024 11:32:46 +0100 Subject: [PATCH] panvk: Make panvk_shader per-gen Move panvk_shader_destroy() to panvk_vX_shader.c so we can get rid of panvk_shader.c. Signed-off-by: Boris Brezillon Acked-by: Erik Faye-Lund Reviewed-by: Mary Guillemard Reviewed-by: Rebecca Mckeever Part-of: --- src/panfrost/vulkan/meson.build | 1 - src/panfrost/vulkan/panvk_shader.c | 41 ------------------------- src/panfrost/vulkan/panvk_shader.h | 21 +++++-------- src/panfrost/vulkan/panvk_vX_pipeline.c | 5 +-- src/panfrost/vulkan/panvk_vX_shader.c | 9 ++++++ 5 files changed, 20 insertions(+), 57 deletions(-) delete mode 100644 src/panfrost/vulkan/panvk_shader.c diff --git a/src/panfrost/vulkan/meson.build b/src/panfrost/vulkan/meson.build index b1ad47d6f43..8ab7065bb5f 100644 --- a/src/panfrost/vulkan/meson.build +++ b/src/panfrost/vulkan/meson.build @@ -47,7 +47,6 @@ libpanvk_files = files( 'panvk_pipeline.c', 'panvk_priv_bo.c', 'panvk_query.c', - 'panvk_shader.c', 'panvk_wsi.c', ) diff --git a/src/panfrost/vulkan/panvk_shader.c b/src/panfrost/vulkan/panvk_shader.c deleted file mode 100644 index 79ae8b9550f..00000000000 --- a/src/panfrost/vulkan/panvk_shader.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 2021 Collabora Ltd. - * - * Derived from tu_shader.c which is: - * Copyright © 2019 Google LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "panvk_shader.h" -#include "panvk_device.h" - -#include "pan_shader.h" - -#include "vk_alloc.h" -#include "vk_util.h" - -void -panvk_shader_destroy(struct panvk_device *dev, struct panvk_shader *shader, - const VkAllocationCallbacks *alloc) -{ - util_dynarray_fini(&shader->binary); - vk_free2(&dev->vk.alloc, alloc, shader); -} diff --git a/src/panfrost/vulkan/panvk_shader.h b/src/panfrost/vulkan/panvk_shader.h index 3ce81bb0bb6..0131a2deda6 100644 --- a/src/panfrost/vulkan/panvk_shader.h +++ b/src/panfrost/vulkan/panvk_shader.h @@ -6,6 +6,10 @@ #ifndef PANVK_SHADER_H #define PANVK_SHADER_H +#ifndef PAN_ARCH +#error "PAN_ARCH must be defined" +#endif + #include "util/u_dynarray.h" #include "util/pan_ir.h" @@ -62,18 +66,6 @@ struct panvk_shader { bool has_img_access; }; -struct panvk_shader * -panvk_shader_create(struct panvk_device *dev, gl_shader_stage stage, - const VkPipelineShaderStageCreateInfo *stage_info, - const struct panvk_pipeline_layout *layout, - unsigned sysval_ubo, struct pan_blend_state *blend_state, - bool static_blend_constants, - const VkAllocationCallbacks *alloc); - -void panvk_shader_destroy(struct panvk_device *dev, struct panvk_shader *shader, - const VkAllocationCallbacks *alloc); - -#ifdef PAN_ARCH bool panvk_per_arch(blend_needs_lowering)(const struct panvk_device *dev, const struct pan_blend_state *state, unsigned rt); @@ -85,9 +77,12 @@ struct panvk_shader *panvk_per_arch(shader_create)( struct pan_blend_state *blend_state, bool static_blend_constants, const VkAllocationCallbacks *alloc); +void panvk_per_arch(shader_destroy)(struct panvk_device *dev, + struct panvk_shader *shader, + const VkAllocationCallbacks *alloc); + bool panvk_per_arch(nir_lower_descriptors)( struct nir_shader *nir, struct panvk_device *dev, const struct panvk_pipeline_layout *layout, bool *has_img_access_out); -#endif #endif diff --git a/src/panfrost/vulkan/panvk_vX_pipeline.c b/src/panfrost/vulkan/panvk_vX_pipeline.c index 25c632e29fa..7b7cb19bb67 100644 --- a/src/panfrost/vulkan/panvk_vX_pipeline.c +++ b/src/panfrost/vulkan/panvk_vX_pipeline.c @@ -102,8 +102,9 @@ panvk_pipeline_builder_finish(struct panvk_pipeline_builder *builder) for (uint32_t i = 0; i < MESA_SHADER_STAGES; i++) { if (!builder->shaders[i]) continue; - panvk_shader_destroy(builder->device, builder->shaders[i], - builder->alloc); + + panvk_per_arch(shader_destroy)(builder->device, builder->shaders[i], + builder->alloc); } } diff --git a/src/panfrost/vulkan/panvk_vX_shader.c b/src/panfrost/vulkan/panvk_vX_shader.c index 69f8b000b94..f661e224739 100644 --- a/src/panfrost/vulkan/panvk_vX_shader.c +++ b/src/panfrost/vulkan/panvk_vX_shader.c @@ -399,6 +399,15 @@ panvk_per_arch(shader_create)(struct panvk_device *dev, gl_shader_stage stage, return shader; } +void +panvk_per_arch(shader_destroy)(struct panvk_device *dev, + struct panvk_shader *shader, + const VkAllocationCallbacks *alloc) +{ + util_dynarray_fini(&shader->binary); + vk_free2(&dev->vk.alloc, alloc, shader); +} + bool panvk_per_arch(blend_needs_lowering)(const struct panvk_device *dev, const struct pan_blend_state *state,