mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 22:40:50 +00:00
fix sequence of destroing buffers
This commit is contained in:
parent
ca29093f64
commit
9e71e69d1c
5 changed files with 41 additions and 20 deletions
|
@ -106,7 +106,6 @@ void
|
|||
QVk_FreeBuffer(qvkbuffer_t *buffer)
|
||||
{
|
||||
buffer_destroy(&buffer->resource);
|
||||
buffer->resource.buffer = VK_NULL_HANDLE;
|
||||
buffer->currentOffset = 0;
|
||||
}
|
||||
|
||||
|
@ -114,7 +113,6 @@ void
|
|||
QVk_FreeStagingBuffer(qvkstagingbuffer_t *buffer)
|
||||
{
|
||||
buffer_destroy(&buffer->resource);
|
||||
buffer->resource.buffer = VK_NULL_HANDLE;
|
||||
buffer->currentOffset = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -750,12 +750,15 @@ static void CreateDrawBuffers()
|
|||
// internal helper
|
||||
static void DestroyDrawBuffer(qvktexture_t *drawBuffer)
|
||||
{
|
||||
if (drawBuffer->imageView != VK_NULL_HANDLE)
|
||||
{
|
||||
vkDestroyImageView(vk_device.logical, drawBuffer->imageView, NULL);
|
||||
drawBuffer->imageView = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (drawBuffer->resource.image != VK_NULL_HANDLE)
|
||||
{
|
||||
image_destroy(&drawBuffer->resource);
|
||||
vkDestroyImageView(vk_device.logical, drawBuffer->imageView, NULL);
|
||||
drawBuffer->resource.image = VK_NULL_HANDLE;
|
||||
drawBuffer->imageView = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,15 +431,18 @@ static void QVk_ReleaseTexture(qvktexture_t *texture)
|
|||
vkDeviceWaitIdle(vk_device.logical);
|
||||
}
|
||||
|
||||
if (texture->imageView != VK_NULL_HANDLE)
|
||||
{
|
||||
vkDestroyImageView(vk_device.logical, texture->imageView, NULL);
|
||||
texture->imageView = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (texture->resource.image != VK_NULL_HANDLE)
|
||||
image_destroy(&texture->resource);
|
||||
if (texture->imageView != VK_NULL_HANDLE)
|
||||
vkDestroyImageView(vk_device.logical, texture->imageView, NULL);
|
||||
|
||||
if (texture->descriptorSet != VK_NULL_HANDLE)
|
||||
vkFreeDescriptorSets(vk_device.logical, vk_descriptorPool, 1, &texture->descriptorSet);
|
||||
|
||||
texture->resource.image = VK_NULL_HANDLE;
|
||||
texture->imageView = VK_NULL_HANDLE;
|
||||
texture->descriptorSet = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -179,12 +179,21 @@ VkResult
|
|||
buffer_destroy(BufferResource_t *buf)
|
||||
{
|
||||
assert(!buf->is_mapped);
|
||||
if(buf->memory != VK_NULL_HANDLE)
|
||||
vkFreeMemory(vk_device.logical, buf->memory, NULL);
|
||||
|
||||
// buffer should be destroed before bound memory
|
||||
if(buf->buffer != VK_NULL_HANDLE)
|
||||
{
|
||||
vkDestroyBuffer(vk_device.logical, buf->buffer, NULL);
|
||||
buf->buffer = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
// buffer desroed, we can free up memory
|
||||
if(buf->memory != VK_NULL_HANDLE)
|
||||
{
|
||||
vkFreeMemory(vk_device.logical, buf->memory, NULL);
|
||||
buf->memory = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
buf->size = 0;
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
@ -193,12 +202,20 @@ buffer_destroy(BufferResource_t *buf)
|
|||
VkResult
|
||||
image_destroy(ImageResource_t *img)
|
||||
{
|
||||
if(img->memory != VK_NULL_HANDLE)
|
||||
vkFreeMemory(vk_device.logical, img->memory, NULL);
|
||||
// image should be destroed before bound memory
|
||||
if(img->image != VK_NULL_HANDLE)
|
||||
{
|
||||
vkDestroyImage(vk_device.logical, img->image, NULL);
|
||||
img->image = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
// image destroed, we can free up memory
|
||||
if(img->memory != VK_NULL_HANDLE)
|
||||
{
|
||||
vkFreeMemory(vk_device.logical, img->memory, NULL);
|
||||
img->memory = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
img->size = 0;
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
|
@ -77,7 +77,7 @@ void QVk_CreateValidationLayers()
|
|||
.pUserData = NULL
|
||||
};
|
||||
|
||||
if( vk_validation->value > 1 )
|
||||
if(vk_validation->value)
|
||||
{
|
||||
callbackInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
|
||||
|
|
Loading…
Reference in a new issue