Finish up memory stuff

For now, of course.
This commit is contained in:
Bill Currie 2020-02-11 09:37:04 +09:00
parent 1baee0cbba
commit 29b1d6baf8
7 changed files with 71 additions and 1 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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)
{