diff --git a/src/panfrost/vulkan/bifrost/panvk_cmd_desc_state.h b/src/panfrost/vulkan/bifrost/panvk_cmd_desc_state.h index 1e04bd468a5..1ec98e473f6 100644 --- a/src/panfrost/vulkan/bifrost/panvk_cmd_desc_state.h +++ b/src/panfrost/vulkan/bifrost/panvk_cmd_desc_state.h @@ -16,7 +16,7 @@ #include "panvk_descriptor_set.h" #include "panvk_macros.h" -#include "panvk_pipeline.h" +#include "panvk_shader.h" #include "vk_command_buffer.h" diff --git a/src/panfrost/vulkan/bifrost/panvk_pipeline.h b/src/panfrost/vulkan/bifrost/panvk_pipeline.h deleted file mode 100644 index 50dce0e773e..00000000000 --- a/src/panfrost/vulkan/bifrost/panvk_pipeline.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright © 2021 Collabora Ltd. - * SPDX-License-Identifier: MIT - */ - -#ifndef PANVK_PIPELINE_H -#define PANVK_PIPELINE_H - -#ifndef PAN_ARCH -#error "PAN_ARCH must be defined" -#endif - -#include -#include - -#include "vk_graphics_state.h" -#include "vk_object.h" - -#include "util/pan_ir.h" - -#include "pan_blend.h" -#include "pan_desc.h" - -#include "panvk_mempool.h" -#include "panvk_shader.h" - -#define MAX_RTS 8 - -enum panvk_pipeline_type { - PANVK_PIPELINE_GRAPHICS, - PANVK_PIPELINE_COMPUTE, -}; - -struct panvk_pipeline { - struct vk_object_base base; - enum panvk_pipeline_type type; - - const struct vk_pipeline_layout *layout; -}; - -VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline, base, VkPipeline, - VK_OBJECT_TYPE_PIPELINE) - -struct panvk_graphics_pipeline { - struct panvk_pipeline base; - - struct panvk_shader *vs; - struct panvk_shader *fs; - struct panvk_shader_link link; - - struct { - struct vk_dynamic_graphics_state dynamic; - struct vk_vertex_input_state vi; - struct vk_sample_locations_state sl; - struct vk_render_pass_state rp; - } state; -}; - -static struct panvk_graphics_pipeline * -panvk_pipeline_to_graphics_pipeline(struct panvk_pipeline *pipeline) -{ - if (pipeline->type != PANVK_PIPELINE_GRAPHICS) - return NULL; - - return container_of(pipeline, struct panvk_graphics_pipeline, base); -} - -struct panvk_compute_pipeline { - struct panvk_pipeline base; - - struct panvk_shader *cs; -}; - -static struct panvk_compute_pipeline * -panvk_pipeline_to_compute_pipeline(struct panvk_pipeline *pipeline) -{ - if (pipeline->type != PANVK_PIPELINE_COMPUTE) - return NULL; - - return container_of(pipeline, struct panvk_compute_pipeline, base); -} - -#endif diff --git a/src/panfrost/vulkan/bifrost/panvk_vX_cmd_desc_state.c b/src/panfrost/vulkan/bifrost/panvk_vX_cmd_desc_state.c index 6def302e248..ac2c02d48d9 100644 --- a/src/panfrost/vulkan/bifrost/panvk_vX_cmd_desc_state.c +++ b/src/panfrost/vulkan/bifrost/panvk_vX_cmd_desc_state.c @@ -14,7 +14,6 @@ #include "panvk_buffer.h" #include "panvk_cmd_desc_state.h" #include "panvk_entrypoints.h" -#include "panvk_pipeline.h" #include "pan_pool.h" diff --git a/src/panfrost/vulkan/bifrost/panvk_vX_pipeline.c b/src/panfrost/vulkan/bifrost/panvk_vX_pipeline.c deleted file mode 100644 index 1dcbc4f2494..00000000000 --- a/src/panfrost/vulkan/bifrost/panvk_vX_pipeline.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright © 2021 Collabora Ltd. - * - * Derived from tu_pipeline.c which is: - * Copyright © 2016 Red Hat. - * Copyright © 2016 Bas Nieuwenhuizen - * Copyright © 2015 Intel Corporation - * - * 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_cmd_buffer.h" -#include "panvk_device.h" -#include "panvk_entrypoints.h" -#include "panvk_pipeline.h" -#include "panvk_priv_bo.h" -#include "panvk_shader.h" - -#include "nir/nir.h" -#include "nir/nir_builder.h" -#include "spirv/nir_spirv.h" -#include "util/blend.h" -#include "util/mesa-sha1.h" -#include "util/u_atomic.h" -#include "util/u_debug.h" -#include "vk_blend.h" -#include "vk_format.h" -#include "vk_pipeline_cache.h" -#include "vk_pipeline_layout.h" -#include "vk_render_pass.h" -#include "vk_util.h" - -#include "panfrost/util/pan_lower_framebuffer.h" - -#include "pan_shader.h" - -static VkResult -init_pipeline_shader(struct panvk_pipeline *pipeline, - const VkPipelineShaderStageCreateInfo *stage_info, - const VkAllocationCallbacks *alloc, - struct panvk_shader **shader) -{ - struct panvk_device *dev = to_panvk_device(pipeline->base.device); - - *shader = - panvk_per_arch(shader_create)(dev, stage_info, pipeline->layout, alloc); - if (!*shader) - return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY); - - return VK_SUCCESS; -} - -static void -cleanup_pipeline_shader(struct panvk_pipeline *pipeline, - struct panvk_shader *shader, - const VkAllocationCallbacks *alloc) -{ - struct panvk_device *dev = to_panvk_device(pipeline->base.device); - - if (shader != NULL) - panvk_per_arch(shader_destroy)(dev, shader, alloc); -} - -static VkResult -panvk_graphics_pipeline_create(struct panvk_device *dev, - struct vk_pipeline_cache *cache, - const VkGraphicsPipelineCreateInfo *create_info, - const VkAllocationCallbacks *alloc, - struct panvk_pipeline **out) -{ - VK_FROM_HANDLE(vk_pipeline_layout, layout, create_info->layout); - struct vk_graphics_pipeline_all_state all; - struct vk_graphics_pipeline_state state = {}; - VkResult result; - - result = vk_graphics_pipeline_state_fill(&dev->vk, &state, create_info, NULL, - 0, &all, NULL, 0, NULL); - if (result) - return result; - - struct panvk_graphics_pipeline *gfx_pipeline = vk_object_zalloc( - &dev->vk, alloc, sizeof(*gfx_pipeline), VK_OBJECT_TYPE_PIPELINE); - - if (!gfx_pipeline) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *out = &gfx_pipeline->base; - gfx_pipeline->base.layout = layout; - gfx_pipeline->base.type = PANVK_PIPELINE_GRAPHICS; - gfx_pipeline->state.dynamic.vi = &gfx_pipeline->state.vi; - gfx_pipeline->state.dynamic.ms.sample_locations = &gfx_pipeline->state.sl; - vk_dynamic_graphics_state_fill(&gfx_pipeline->state.dynamic, &state); - gfx_pipeline->state.rp = *state.rp; - - for (uint32_t i = 0; i < create_info->stageCount; i++) { - struct panvk_shader **shader = NULL; - switch (create_info->pStages[i].stage) { - case VK_SHADER_STAGE_VERTEX_BIT: - shader = &gfx_pipeline->vs; - break; - - case VK_SHADER_STAGE_FRAGMENT_BIT: - shader = &gfx_pipeline->fs; - break; - - default: - assert(!"Unsupported graphics pipeline stage"); - } - - VkResult result = init_pipeline_shader( - &gfx_pipeline->base, &create_info->pStages[i], alloc, shader); - if (result != VK_SUCCESS) - return result; - } - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL -panvk_per_arch(CreateGraphicsPipelines)( - VkDevice device, VkPipelineCache pipelineCache, uint32_t count, - const VkGraphicsPipelineCreateInfo *pCreateInfos, - const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) -{ - VK_FROM_HANDLE(panvk_device, dev, device); - VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache); - - for (uint32_t i = 0; i < count; i++) { - struct panvk_pipeline *pipeline; - VkResult result = panvk_graphics_pipeline_create( - dev, cache, &pCreateInfos[i], pAllocator, &pipeline); - - if (result != VK_SUCCESS) { - for (uint32_t j = 0; j < i; j++) { - panvk_DestroyPipeline(device, pPipelines[j], pAllocator); - pPipelines[j] = VK_NULL_HANDLE; - } - - return result; - } - - pPipelines[i] = panvk_pipeline_to_handle(pipeline); - } - - return VK_SUCCESS; -} - -static VkResult -panvk_compute_pipeline_create(struct panvk_device *dev, - struct vk_pipeline_cache *cache, - const VkComputePipelineCreateInfo *create_info, - const VkAllocationCallbacks *alloc, - struct panvk_pipeline **out) -{ - VK_FROM_HANDLE(vk_pipeline_layout, layout, create_info->layout); - struct panvk_compute_pipeline *compute_pipeline = vk_object_zalloc( - &dev->vk, alloc, sizeof(*compute_pipeline), VK_OBJECT_TYPE_PIPELINE); - - if (!compute_pipeline) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *out = &compute_pipeline->base; - compute_pipeline->base.layout = layout; - compute_pipeline->base.type = PANVK_PIPELINE_COMPUTE; - - VkResult result = - init_pipeline_shader(&compute_pipeline->base, &create_info->stage, alloc, - &compute_pipeline->cs); - if (result != VK_SUCCESS) - return result; - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL -panvk_per_arch(CreateComputePipelines)( - VkDevice device, VkPipelineCache pipelineCache, uint32_t count, - const VkComputePipelineCreateInfo *pCreateInfos, - const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) -{ - VK_FROM_HANDLE(panvk_device, dev, device); - VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache); - - for (uint32_t i = 0; i < count; i++) { - struct panvk_pipeline *pipeline; - VkResult result = panvk_compute_pipeline_create( - dev, cache, &pCreateInfos[i], pAllocator, &pipeline); - - if (result != VK_SUCCESS) { - for (uint32_t j = 0; j < i; j++) { - panvk_DestroyPipeline(device, pPipelines[j], pAllocator); - pPipelines[j] = VK_NULL_HANDLE; - } - - return result; - } - - pPipelines[i] = panvk_pipeline_to_handle(pipeline); - } - - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL -panvk_per_arch(DestroyPipeline)(VkDevice _device, VkPipeline _pipeline, - const VkAllocationCallbacks *pAllocator) -{ - VK_FROM_HANDLE(panvk_device, device, _device); - VK_FROM_HANDLE(panvk_pipeline, pipeline, _pipeline); - - if (pipeline->type == PANVK_PIPELINE_GRAPHICS) { - struct panvk_graphics_pipeline *gfx_pipeline = - panvk_pipeline_to_graphics_pipeline(pipeline); - - panvk_shader_link_cleanup(&device->mempools.rw, &gfx_pipeline->link); - cleanup_pipeline_shader(pipeline, gfx_pipeline->vs, pAllocator); - cleanup_pipeline_shader(pipeline, gfx_pipeline->fs, pAllocator); - } else { - struct panvk_compute_pipeline *compute_pipeline = - panvk_pipeline_to_compute_pipeline(pipeline); - - cleanup_pipeline_shader(pipeline, compute_pipeline->cs, pAllocator); - } - - vk_object_free(&device->vk, pAllocator, pipeline); -} diff --git a/src/panfrost/vulkan/jm/panvk_cmd_buffer.h b/src/panfrost/vulkan/jm/panvk_cmd_buffer.h index 13192c782f3..a5173bcc674 100644 --- a/src/panfrost/vulkan/jm/panvk_cmd_buffer.h +++ b/src/panfrost/vulkan/jm/panvk_cmd_buffer.h @@ -21,7 +21,6 @@ #include "panvk_device.h" #include "panvk_macros.h" #include "panvk_mempool.h" -#include "panvk_pipeline.h" #include "panvk_shader.h" #include "pan_jc.h" @@ -32,6 +31,7 @@ #define MAX_BIND_POINTS 2 /* compute + graphics */ #define MAX_VBS 16 +#define MAX_RTS 8 struct panvk_batch { struct list_head node; diff --git a/src/panfrost/vulkan/jm/panvk_vX_cmd_buffer.c b/src/panfrost/vulkan/jm/panvk_vX_cmd_buffer.c index f86a4b7a380..99a8c46381d 100644 --- a/src/panfrost/vulkan/jm/panvk_vX_cmd_buffer.c +++ b/src/panfrost/vulkan/jm/panvk_vX_cmd_buffer.c @@ -37,7 +37,6 @@ #include "panvk_entrypoints.h" #include "panvk_instance.h" #include "panvk_physical_device.h" -#include "panvk_pipeline.h" #include "panvk_priv_bo.h" #include "pan_blitter.h" @@ -502,41 +501,6 @@ panvk_per_arch(cmd_bind_shaders)(struct vk_command_buffer *vk_cmd, } } -VKAPI_ATTR void VKAPI_CALL -panvk_per_arch(CmdBindPipeline)(VkCommandBuffer commandBuffer, - VkPipelineBindPoint pipelineBindPoint, - VkPipeline _pipeline) -{ - VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer); - VK_FROM_HANDLE(panvk_pipeline, pipeline, _pipeline); - - switch (pipelineBindPoint) { - case VK_PIPELINE_BIND_POINT_GRAPHICS: { - struct panvk_graphics_pipeline *gfx_pipeline = - panvk_pipeline_to_graphics_pipeline(pipeline); - - vk_cmd_set_dynamic_graphics_state(&cmdbuf->vk, - &gfx_pipeline->state.dynamic); - - panvk_cmd_bind_shader(cmdbuf, MESA_SHADER_VERTEX, gfx_pipeline->vs); - panvk_cmd_bind_shader(cmdbuf, MESA_SHADER_FRAGMENT, gfx_pipeline->fs); - break; - } - - case VK_PIPELINE_BIND_POINT_COMPUTE: { - const struct panvk_compute_pipeline *compute_pipeline = - panvk_pipeline_to_compute_pipeline(pipeline); - - panvk_cmd_bind_shader(cmdbuf, MESA_SHADER_COMPUTE, compute_pipeline->cs); - break; - } - - default: - assert(!"Unsupported bind point"); - break; - } -} - VKAPI_ATTR void VKAPI_CALL panvk_per_arch(CmdPushDescriptorSetKHR)( VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, diff --git a/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c b/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c index e92bad906e8..22a86e518d0 100644 --- a/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c +++ b/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c @@ -19,7 +19,6 @@ #include "panvk_image.h" #include "panvk_image_view.h" #include "panvk_instance.h" -#include "panvk_pipeline.h" #include "panvk_priv_bo.h" #include "panvk_shader.h" diff --git a/src/panfrost/vulkan/meson.build b/src/panfrost/vulkan/meson.build index 556e46a5944..096db32bf92 100644 --- a/src/panfrost/vulkan/meson.build +++ b/src/panfrost/vulkan/meson.build @@ -59,7 +59,6 @@ bifrost_files = [ 'bifrost/panvk_vX_cmd_desc_state.c', 'bifrost/panvk_vX_meta_desc_copy.c', 'bifrost/panvk_vX_nir_lower_descriptors.c', - 'bifrost/panvk_vX_pipeline.c', ] valhall_archs = [9, 10] diff --git a/src/panfrost/vulkan/panvk_blend.h b/src/panfrost/vulkan/panvk_blend.h index c616ab842b2..0aa2f2699cd 100644 --- a/src/panfrost/vulkan/panvk_blend.h +++ b/src/panfrost/vulkan/panvk_blend.h @@ -18,7 +18,6 @@ struct vk_color_blend_state; struct panvk_device; -struct panvk_graphics_pipeline; struct panvk_blend_shader { struct pan_blend_shader_key key; diff --git a/src/panfrost/vulkan/panvk_shader.h b/src/panfrost/vulkan/panvk_shader.h index 5da80253beb..fed3cb45434 100644 --- a/src/panfrost/vulkan/panvk_shader.h +++ b/src/panfrost/vulkan/panvk_shader.h @@ -144,14 +144,6 @@ panvk_shader_get_dev_addr(const struct panvk_shader *shader) return shader != NULL ? panvk_priv_mem_dev_addr(shader->code_mem) : 0; } -struct panvk_shader *panvk_per_arch(shader_create)( - struct panvk_device *dev, const VkPipelineShaderStageCreateInfo *stage_info, - const struct vk_pipeline_layout *layout, const VkAllocationCallbacks *alloc); - -void panvk_per_arch(shader_destroy)(struct panvk_device *dev, - struct panvk_shader *shader, - const VkAllocationCallbacks *alloc); - void panvk_per_arch(link_shaders)(struct panvk_pool *desc_pool, struct panvk_shader *vs, struct panvk_shader *fs, diff --git a/src/panfrost/vulkan/panvk_vX_blend.c b/src/panfrost/vulkan/panvk_vX_blend.c index 6903119f303..2681983825f 100644 --- a/src/panfrost/vulkan/panvk_vX_blend.c +++ b/src/panfrost/vulkan/panvk_vX_blend.c @@ -9,13 +9,13 @@ #include "vk_blend.h" #include "vk_format.h" +#include "vk_graphics_state.h" #include "vk_log.h" #include "pan_shader.h" #include "panvk_blend.h" #include "panvk_device.h" -#include "panvk_pipeline.h" #include "panvk_shader.h" DERIVE_HASH_TABLE(pan_blend_shader_key); diff --git a/src/panfrost/vulkan/panvk_vX_shader.c b/src/panfrost/vulkan/panvk_vX_shader.c index 250d361fb21..c913bc497c8 100644 --- a/src/panfrost/vulkan/panvk_vX_shader.c +++ b/src/panfrost/vulkan/panvk_vX_shader.c @@ -769,92 +769,6 @@ panvk_shader_get_executable_internal_representations( return incomplete_text ? VK_INCOMPLETE : vk_outarray_status(&out); } -struct panvk_shader * -panvk_per_arch(shader_create)(struct panvk_device *dev, - const VkPipelineShaderStageCreateInfo *stage_info, - const struct vk_pipeline_layout *layout, - const VkAllocationCallbacks *alloc) -{ - struct panvk_physical_device *phys_dev = - to_panvk_physical_device(dev->vk.physical); - struct panvk_shader *shader; - - shader = vk_zalloc2(&dev->vk.alloc, alloc, sizeof(*shader), 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - if (!shader) - return NULL; - - /* TODO these are made-up */ - const struct spirv_to_nir_options spirv_options = { - .ubo_addr_format = nir_address_format_32bit_index_offset, - .ssbo_addr_format = dev->vk.enabled_features.robustBufferAccess - ? nir_address_format_64bit_bounded_global - : nir_address_format_64bit_global_32bit_offset, - .phys_ssbo_addr_format = nir_address_format_64bit_global, - }; - - nir_shader *nir; - VkResult result = vk_pipeline_shader_stage_to_nir( - &dev->vk, stage_info, &spirv_options, - GENX(pan_shader_get_compiler_options)(), NULL, &nir); - if (result != VK_SUCCESS) { - panvk_per_arch(shader_destroy)(dev, shader, alloc); - return NULL; - } - - panvk_preprocess_nir(&phys_dev->vk, nir); - - struct vk_pipeline_robustness_state rs = { - .storage_buffers = - dev->vk.enabled_features.robustBufferAccess - ? VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT - : VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, - .uniform_buffers = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, - .vertex_inputs = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, - .images = VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT, - }; - - struct panfrost_compile_inputs inputs = { - .gpu_id = phys_dev->kmod.props.gpu_prod_id, - .no_ubo_to_push = true, - .no_idvs = true, /* TODO */ - }; - - panvk_lower_nir(dev, nir, layout->set_count, layout->set_layouts, &rs, - &inputs, shader); - - result = panvk_compile_nir(dev, nir, 0, &inputs, shader); - - if (result != VK_SUCCESS) - goto err; - - result = panvk_shader_upload(dev, shader, alloc); - - if (result != VK_SUCCESS) - goto err; - - ralloc_free(nir); - return shader; - -err: - ralloc_free(nir); - panvk_per_arch(shader_destroy)(dev, shader, alloc); - return NULL; -} - -void -panvk_per_arch(shader_destroy)(struct panvk_device *dev, - struct panvk_shader *shader, - const VkAllocationCallbacks *alloc) -{ - panvk_pool_free_mem(&dev->mempools.rw, shader->rsd); - panvk_pool_free_mem(&dev->mempools.rw, shader->desc_info.others.map); - panvk_pool_free_mem(&dev->mempools.exec, shader->code_mem); - - free((void *)shader->bin_ptr); - vk_free2(&dev->vk.alloc, alloc, shader); -} - static mali_pixel_format get_varying_format(gl_shader_stage stage, gl_varying_slot loc, enum pipe_format pfmt)