From 8b4f441e841dfc940e8cbe3704eadba4eb1871c3 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 30 Jan 2023 20:11:58 -0600 Subject: [PATCH] nvk: Break nvk_cmd_pool into its own file Part-of: --- src/nouveau/vulkan/meson.build | 2 ++ src/nouveau/vulkan/nvk_cmd_buffer.c | 52 +---------------------------------- src/nouveau/vulkan/nvk_cmd_buffer.h | 16 +---------- src/nouveau/vulkan/nvk_cmd_pool.c | 54 +++++++++++++++++++++++++++++++++++++ src/nouveau/vulkan/nvk_cmd_pool.h | 21 +++++++++++++++ 5 files changed, 79 insertions(+), 66 deletions(-) create mode 100644 src/nouveau/vulkan/nvk_cmd_pool.c create mode 100644 src/nouveau/vulkan/nvk_cmd_pool.h diff --git a/src/nouveau/vulkan/meson.build b/src/nouveau/vulkan/meson.build index f6446b1..3073d62 100644 --- a/src/nouveau/vulkan/meson.build +++ b/src/nouveau/vulkan/meson.build @@ -14,6 +14,8 @@ nvk_files = files( 'nvk_cmd_dispatch.c', 'nvk_cmd_draw.c', 'nvk_cmd_meta.c', + 'nvk_cmd_pool.c', + 'nvk_cmd_pool.h', 'nvk_compute_pipeline.c', 'nvk_descriptor_set.h', 'nvk_descriptor_set.c', diff --git a/src/nouveau/vulkan/nvk_cmd_buffer.c b/src/nouveau/vulkan/nvk_cmd_buffer.c index b3aeead..e9c6c0c 100644 --- a/src/nouveau/vulkan/nvk_cmd_buffer.c +++ b/src/nouveau/vulkan/nvk_cmd_buffer.c @@ -1,5 +1,6 @@ #include "nvk_cmd_buffer.h" +#include "nvk_cmd_pool.h" #include "nvk_descriptor_set.h" #include "nvk_descriptor_set_layout.h" #include "nvk_device.h" @@ -181,57 +182,6 @@ nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd_buffer, unsigned size, } VKAPI_ATTR VkResult VKAPI_CALL -nvk_CreateCommandPool(VkDevice _device, - const VkCommandPoolCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkCommandPool *pCmdPool) -{ - VK_FROM_HANDLE(nvk_device, device, _device); - struct nvk_cmd_pool *pool; - - pool = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*pool), 8, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - if (pool == NULL) - return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); - - VkResult result = vk_command_pool_init(&device->vk, &pool->vk, - pCreateInfo, pAllocator); - if (result != VK_SUCCESS) { - vk_free2(&device->vk.alloc, pAllocator, pool); - return result; - } - - *pCmdPool = nvk_cmd_pool_to_handle(pool); - - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL -nvk_DestroyCommandPool(VkDevice _device, - VkCommandPool commandPool, - const VkAllocationCallbacks *pAllocator) -{ - VK_FROM_HANDLE(nvk_device, device, _device); - VK_FROM_HANDLE(nvk_cmd_pool, pool, commandPool); - - if (!pool) - return; - - vk_command_pool_finish(&pool->vk); - vk_free2(&device->vk.alloc, pAllocator, pool); -} - -VKAPI_ATTR void VKAPI_CALL -nvk_TrimCommandPool(VkDevice device, - VkCommandPool commandPool, - VkCommandPoolTrimFlags flags) -{ - VK_FROM_HANDLE(nvk_cmd_pool, pool, commandPool); - - vk_command_pool_trim(&pool->vk, flags); -} - -VKAPI_ATTR VkResult VKAPI_CALL nvk_BeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo) { diff --git a/src/nouveau/vulkan/nvk_cmd_buffer.h b/src/nouveau/vulkan/nvk_cmd_buffer.h index eb91723..f670cf8 100644 --- a/src/nouveau/vulkan/nvk_cmd_buffer.h +++ b/src/nouveau/vulkan/nvk_cmd_buffer.h @@ -6,26 +6,12 @@ #include "nouveau_push.h" #include "nvk_descriptor_set.h" -#include "vulkan/runtime/vk_command_buffer.h" -#include "vulkan/runtime/vk_command_pool.h" +#include "vk_command_buffer.h" struct nvk_image_view; #define NVK_CMD_BUF_SIZE 64*1024 -struct nvk_cmd_pool { - struct vk_command_pool vk; -}; - -VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_cmd_pool, vk.base, VkCommandPool, - VK_OBJECT_TYPE_COMMAND_POOL) - -static inline struct nvk_device * -nvk_cmd_pool_device(struct nvk_cmd_pool *pool) -{ - return (struct nvk_device *)pool->vk.base.device; -} - /** Root descriptor table. This gets pushed to the GPU directly */ struct nvk_root_descriptor_table { union { diff --git a/src/nouveau/vulkan/nvk_cmd_pool.c b/src/nouveau/vulkan/nvk_cmd_pool.c new file mode 100644 index 0000000..5de6ca3 --- /dev/null +++ b/src/nouveau/vulkan/nvk_cmd_pool.c @@ -0,0 +1,54 @@ +#include "nvk_cmd_pool.h" + +#include "nvk_device.h" + +VKAPI_ATTR VkResult VKAPI_CALL +nvk_CreateCommandPool(VkDevice _device, + const VkCommandPoolCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkCommandPool *pCmdPool) +{ + VK_FROM_HANDLE(nvk_device, device, _device); + struct nvk_cmd_pool *pool; + + pool = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*pool), 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (pool == NULL) + return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); + + VkResult result = vk_command_pool_init(&device->vk, &pool->vk, + pCreateInfo, pAllocator); + if (result != VK_SUCCESS) { + vk_free2(&device->vk.alloc, pAllocator, pool); + return result; + } + + *pCmdPool = nvk_cmd_pool_to_handle(pool); + + return VK_SUCCESS; +} + +VKAPI_ATTR void VKAPI_CALL +nvk_DestroyCommandPool(VkDevice _device, + VkCommandPool commandPool, + const VkAllocationCallbacks *pAllocator) +{ + VK_FROM_HANDLE(nvk_device, device, _device); + VK_FROM_HANDLE(nvk_cmd_pool, pool, commandPool); + + if (!pool) + return; + + vk_command_pool_finish(&pool->vk); + vk_free2(&device->vk.alloc, pAllocator, pool); +} + +VKAPI_ATTR void VKAPI_CALL +nvk_TrimCommandPool(VkDevice device, + VkCommandPool commandPool, + VkCommandPoolTrimFlags flags) +{ + VK_FROM_HANDLE(nvk_cmd_pool, pool, commandPool); + + vk_command_pool_trim(&pool->vk, flags); +} diff --git a/src/nouveau/vulkan/nvk_cmd_pool.h b/src/nouveau/vulkan/nvk_cmd_pool.h new file mode 100644 index 0000000..584e8c4 --- /dev/null +++ b/src/nouveau/vulkan/nvk_cmd_pool.h @@ -0,0 +1,21 @@ +#ifndef NVK_CMD_POOL_H +#define NVK_CMD_POOL_H + +#include "nvk_private.h" + +#include "vk_command_pool.h" + +struct nvk_cmd_pool { + struct vk_command_pool vk; +}; + +VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_cmd_pool, vk.base, VkCommandPool, + VK_OBJECT_TYPE_COMMAND_POOL) + +static inline struct nvk_device * +nvk_cmd_pool_device(struct nvk_cmd_pool *pool) +{ + return (struct nvk_device *)pool->vk.base.device; +} + +#endif /* NVK_CMD_POOL_H */ -- 2.7.4