From: Faith Ekstrand Date: Tue, 31 Jan 2023 02:11:47 +0000 (-0600) Subject: nvk: Implement VkPipelineLayout X-Git-Tag: upstream/23.3.3~4591 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04e52c25ac91071f032963f5d49755db768698b8;p=platform%2Fupstream%2Fmesa.git nvk: Implement VkPipelineLayout Part-of: --- diff --git a/src/nouveau/vulkan/meson.build b/src/nouveau/vulkan/meson.build index 2cd2358..6035e5d 100644 --- a/src/nouveau/vulkan/meson.build +++ b/src/nouveau/vulkan/meson.build @@ -20,6 +20,8 @@ nvk_files = files( 'nvk_instance.h', 'nvk_physical_device.c', 'nvk_physical_device.h', + 'nvk_pipeline_layout.c', + 'nvk_pipeline_layout.h', 'nvk_private.h', 'nvk_sampler.c', 'nvk_sampler.h', diff --git a/src/nouveau/vulkan/nvk_pipeline_layout.c b/src/nouveau/vulkan/nvk_pipeline_layout.c new file mode 100644 index 0000000..d943e5a --- /dev/null +++ b/src/nouveau/vulkan/nvk_pipeline_layout.c @@ -0,0 +1,55 @@ +#include "nvk_pipeline_layout.h" + +#include "nvk_descriptor_set_layout.h" +#include "nvk_device.h" + +#include "util/mesa-sha1.h" + +VKAPI_ATTR VkResult VKAPI_CALL nvk_CreatePipelineLayout( + VkDevice _device, const VkPipelineLayoutCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkPipelineLayout *pPipelineLayout) { + VK_FROM_HANDLE(nvk_device, device, _device); + struct nvk_pipeline_layout *layout; + + layout = vk_object_alloc(&device->vk, pAllocator, sizeof(*layout), + VK_OBJECT_TYPE_PIPELINE_LAYOUT); + if (layout == NULL) + return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); + + layout->num_sets = pCreateInfo->setLayoutCount; + + for (uint32_t s = 0; s < pCreateInfo->setLayoutCount; s++) { + VK_FROM_HANDLE(nvk_descriptor_set_layout, set_layout, + pCreateInfo->pSetLayouts[s]); + layout->set[s].layout = nvk_descriptor_set_layout_ref(set_layout); + } + + struct mesa_sha1 sha1_ctx; + _mesa_sha1_init(&sha1_ctx); + _mesa_sha1_update(&sha1_ctx, &layout->num_sets, sizeof(layout->num_sets)); + for (uint32_t s = 0; s < pCreateInfo->setLayoutCount; s++) { + _mesa_sha1_update(&sha1_ctx, layout->set[s].layout->sha1, + sizeof(layout->set[s].layout->sha1)); + } + _mesa_sha1_final(&sha1_ctx, layout->sha1); + + *pPipelineLayout = nvk_pipeline_layout_to_handle(layout); + + return VK_SUCCESS; +} + +VKAPI_ATTR void VKAPI_CALL +nvk_DestroyPipelineLayout(VkDevice _device, VkPipelineLayout pipelineLayout, + const VkAllocationCallbacks *pAllocator) { + VK_FROM_HANDLE(nvk_device, device, _device); + VK_FROM_HANDLE(nvk_pipeline_layout, layout, pipelineLayout); + + if (!layout) + return; + + for (uint32_t s = 0; s < layout->num_sets; s++) + nvk_descriptor_set_layout_unref(device, layout->set[s].layout); + + vk_object_free(&device->vk, pAllocator, layout); +} diff --git a/src/nouveau/vulkan/nvk_pipeline_layout.h b/src/nouveau/vulkan/nvk_pipeline_layout.h new file mode 100644 index 0000000..5b148ce --- /dev/null +++ b/src/nouveau/vulkan/nvk_pipeline_layout.h @@ -0,0 +1,25 @@ +#ifndef NVK_PIPELINE_LAYOUT +#define NVK_PIPELINE_LAYOUT 1 + +#include "nvk_private.h" + +#include "vulkan/runtime/vk_object.h" + +struct nvk_descriptor_set_layout; + +struct nvk_pipeline_layout { + struct vk_object_base base; + + unsigned char sha1[20]; + + uint32_t num_sets; + + struct { + struct nvk_descriptor_set_layout *layout; + } set[NVK_MAX_SETS]; +}; + +VK_DEFINE_HANDLE_CASTS(nvk_pipeline_layout, base, VkPipelineLayout, + VK_OBJECT_TYPE_PIPELINE_LAYOUT) + +#endif diff --git a/src/nouveau/vulkan/nvk_private.h b/src/nouveau/vulkan/nvk_private.h index d0fa48f..6224192 100644 --- a/src/nouveau/vulkan/nvk_private.h +++ b/src/nouveau/vulkan/nvk_private.h @@ -12,6 +12,7 @@ #include #include +#define NVK_MAX_SETS 8 #define NVK_MIN_UBO_ALIGNMENT 16 /**