From 29b1d6baf8f94d31f4472798f6699abac5e832d5 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 11 Feb 2020 09:37:04 +0900 Subject: [PATCH] Finish up memory stuff For now, of course. --- include/QF/Vulkan/buffer.h | 4 ++++ include/QF/Vulkan/funclist.h | 8 +++++++- include/QF/Vulkan/image.h | 4 ++++ include/QF/Vulkan/memory.h | 1 + libs/video/renderer/vulkan/buffer.c | 22 ++++++++++++++++++++++ libs/video/renderer/vulkan/image.c | 22 ++++++++++++++++++++++ libs/video/renderer/vulkan/memory.c | 11 +++++++++++ 7 files changed, 71 insertions(+), 1 deletion(-) diff --git a/include/QF/Vulkan/buffer.h b/include/QF/Vulkan/buffer.h index 09ff14c2b..ef11ae8b7 100644 --- a/include/QF/Vulkan/buffer.h +++ b/include/QF/Vulkan/buffer.h @@ -50,4 +50,8 @@ QFV_CreateBufferTransitionSet (qfv_buffertransition_t **transitions, qfv_bufferview_t *QFV_CreateBufferView (qfv_buffer_t *buffer, VkFormat format, VkDeviceSize offset, VkDeviceSize size); +void QFV_DestroyBufferView (qfv_bufferview_t *view); + +void QFV_DestroyBuffer (qfv_buffer_t *buffer); + #endif//__QF_Vulkan_buffer_h diff --git a/include/QF/Vulkan/funclist.h b/include/QF/Vulkan/funclist.h index aded86eb6..1f00d0b54 100644 --- a/include/QF/Vulkan/funclist.h +++ b/include/QF/Vulkan/funclist.h @@ -107,17 +107,23 @@ DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyFence) DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroySemaphore) DEVICE_LEVEL_VULKAN_FUNCTION (vkFreeCommandBuffers) DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyCommandPool) + DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateBuffer) DEVICE_LEVEL_VULKAN_FUNCTION (vkGetBufferMemoryRequirements) -DEVICE_LEVEL_VULKAN_FUNCTION (vkAllocateMemory) DEVICE_LEVEL_VULKAN_FUNCTION (vkBindBufferMemory) DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateBufferView) +DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyBufferView) +DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyBuffer) DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateImage) DEVICE_LEVEL_VULKAN_FUNCTION (vkGetImageMemoryRequirements) DEVICE_LEVEL_VULKAN_FUNCTION (vkBindImageMemory) DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateImageView) +DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyImageView) +DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyImage) +DEVICE_LEVEL_VULKAN_FUNCTION (vkAllocateMemory) +DEVICE_LEVEL_VULKAN_FUNCTION (vkFreeMemory) DEVICE_LEVEL_VULKAN_FUNCTION (vkMapMemory) DEVICE_LEVEL_VULKAN_FUNCTION (vkUnmapMemory) DEVICE_LEVEL_VULKAN_FUNCTION (vkFlushMappedMemoryRanges) diff --git a/include/QF/Vulkan/image.h b/include/QF/Vulkan/image.h index 9c927e6b6..4258fe2e0 100644 --- a/include/QF/Vulkan/image.h +++ b/include/QF/Vulkan/image.h @@ -57,4 +57,8 @@ qfv_imageview_t *QFV_CreateImageView (qfv_image_t *image, VkImageViewType type, VkFormat format, VkImageAspectFlags aspect); +void QFV_DestroyImageView (qfv_imageview_t *view); + +void QFV_DestroyImage (qfv_image_t *image); + #endif//__QF_Vulkan_image_h diff --git a/include/QF/Vulkan/memory.h b/include/QF/Vulkan/memory.h index bae79d9b7..55b87f6c6 100644 --- a/include/QF/Vulkan/memory.h +++ b/include/QF/Vulkan/memory.h @@ -12,6 +12,7 @@ typedef struct qfv_mappedmemrange_s { VkDeviceSize size; } qfv_mappedmemrange_t; +void QFV_FreeMemory (qfv_memory_t *memory); void *QFV_MapMemory (qfv_memory_t *memory, VkDeviceSize offset, VkDeviceSize size); void QFV_UnmapMemory (qfv_memory_t *memory); diff --git a/libs/video/renderer/vulkan/buffer.c b/libs/video/renderer/vulkan/buffer.c index f2053c5db..e2d598b81 100644 --- a/libs/video/renderer/vulkan/buffer.c +++ b/libs/video/renderer/vulkan/buffer.c @@ -184,3 +184,25 @@ QFV_CreateBufferView (qfv_buffer_t *buffer, VkFormat format, dfunc->vkCreateBufferView (dev, &createInfo, 0, &view->view); return view; } + +void +QFV_DestroyBufferView (qfv_bufferview_t *view) +{ + qfv_device_t *device = view->device; + VkDevice dev = device->dev; + qfv_devfuncs_t *dfunc = device->funcs; + + dfunc->vkDestroyBufferView (dev, view->view, 0); + free (view); +} + +void +QFV_DestroyBuffer (qfv_buffer_t *buffer) +{ + qfv_device_t *device = buffer->device; + VkDevice dev = device->dev; + qfv_devfuncs_t *dfunc = device->funcs; + + dfunc->vkDestroyBuffer (dev, buffer->buffer, 0); + free (buffer); +} diff --git a/libs/video/renderer/vulkan/image.c b/libs/video/renderer/vulkan/image.c index 4564fd2fe..63b836be5 100644 --- a/libs/video/renderer/vulkan/image.c +++ b/libs/video/renderer/vulkan/image.c @@ -212,3 +212,25 @@ QFV_CreateImageView (qfv_image_t *image, VkImageViewType type, VkFormat format, dfunc->vkCreateImageView (dev, &createInfo, 0, &view->view); return view; } + +void +QFV_DestroyImageView (qfv_imageview_t *view) +{ + qfv_device_t *device = view->device; + VkDevice dev = device->dev; + qfv_devfuncs_t *dfunc = device->funcs; + + dfunc->vkDestroyImageView (dev, view->view, 0); + free (view); +} + +void +QFV_DestroyImage (qfv_image_t *image) +{ + qfv_device_t *device = image->device; + VkDevice dev = device->dev; + qfv_devfuncs_t *dfunc = device->funcs; + + dfunc->vkDestroyImage (dev, image->image, 0); + free (image); +} diff --git a/libs/video/renderer/vulkan/memory.c b/libs/video/renderer/vulkan/memory.c index 4ed912edb..c18a8144f 100644 --- a/libs/video/renderer/vulkan/memory.c +++ b/libs/video/renderer/vulkan/memory.c @@ -60,6 +60,17 @@ #include "util.h" +void +QFV_FreeMemory (qfv_memory_t *memory) +{ + qfv_device_t *device = memory->device; + VkDevice dev = device->dev; + qfv_devfuncs_t *dfunc = device->funcs; + + dfunc->vkFreeMemory (dev, memory->object, 0); + free (memory); +} + void * QFV_MapMemory (qfv_memory_t *memory, VkDeviceSize offset, VkDeviceSize size) {