resource acquire fixes
continuous-integration/drone/push Build is passing Details

pull/41/head
cosmonaut 2023-05-15 17:17:27 -07:00
parent 74112396ec
commit 2ef3c04e8e
1 changed files with 35 additions and 31 deletions

View File

@ -833,7 +833,7 @@ typedef struct VulkanSwapchainData
/* Swapchain images */ /* Swapchain images */
VkExtent2D extent; VkExtent2D extent;
VulkanTexture *textures; VulkanTextureContainer *textureContainers;
uint32_t imageCount; uint32_t imageCount;
/* Synchronization primitives */ /* Synchronization primitives */
@ -3695,17 +3695,19 @@ static void VULKAN_INTERNAL_DestroySwapchain(
{ {
VULKAN_INTERNAL_RemoveRenderTargetsContainingTexture( VULKAN_INTERNAL_RemoveRenderTargetsContainingTexture(
renderer, renderer,
&swapchainData->textures[i] swapchainData->textureContainers[i].vulkanTexture
); );
renderer->vkDestroyImageView( renderer->vkDestroyImageView(
renderer->logicalDevice, renderer->logicalDevice,
swapchainData->textures[i].view, swapchainData->textureContainers[i].vulkanTexture->view,
NULL NULL
); );
SDL_free(swapchainData->textureContainers[i].vulkanTexture);
} }
SDL_free(swapchainData->textures); SDL_free(swapchainData->textureContainers);
renderer->vkDestroySwapchainKHR( renderer->vkDestroySwapchainKHR(
renderer->logicalDevice, renderer->logicalDevice,
@ -4946,11 +4948,11 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain(
NULL NULL
); );
swapchainData->textures = SDL_malloc( swapchainData->textureContainers = SDL_malloc(
sizeof(VulkanTexture) * swapchainData->imageCount sizeof(VulkanTextureContainer) * swapchainData->imageCount
); );
if (!swapchainData->textures) if (!swapchainData->textureContainers)
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
renderer->vkDestroySurfaceKHR( renderer->vkDestroySurfaceKHR(
@ -4985,7 +4987,9 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain(
for (i = 0; i < swapchainData->imageCount; i += 1) for (i = 0; i < swapchainData->imageCount; i += 1)
{ {
swapchainData->textures[i].image = swapchainImages[i]; swapchainData->textureContainers[i].vulkanTexture = SDL_malloc(sizeof(VulkanTexture));
swapchainData->textureContainers[i].vulkanTexture->image = swapchainImages[i];
imageViewCreateInfo.image = swapchainImages[i]; imageViewCreateInfo.image = swapchainImages[i];
@ -4993,7 +4997,7 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain(
renderer->logicalDevice, renderer->logicalDevice,
&imageViewCreateInfo, &imageViewCreateInfo,
NULL, NULL,
&swapchainData->textures[i].view &swapchainData->textureContainers[i].vulkanTexture->view
); );
if (vulkanResult != VK_SUCCESS) if (vulkanResult != VK_SUCCESS)
@ -5004,30 +5008,30 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain(
NULL NULL
); );
SDL_stack_free(swapchainImages); SDL_stack_free(swapchainImages);
SDL_free(swapchainData->textures); SDL_free(swapchainData->textureContainers);
SDL_free(swapchainData); SDL_free(swapchainData);
LogVulkanResultAsError("vkCreateImageView", vulkanResult); LogVulkanResultAsError("vkCreateImageView", vulkanResult);
return 0; return 0;
} }
swapchainData->textures[i].resourceAccessType = RESOURCE_ACCESS_NONE; swapchainData->textureContainers[i].vulkanTexture->resourceAccessType = RESOURCE_ACCESS_NONE;
/* Swapchain memory is managed by the driver */ /* Swapchain memory is managed by the driver */
swapchainData->textures[i].usedRegion = NULL; swapchainData->textureContainers[i].vulkanTexture->usedRegion = NULL;
swapchainData->textures[i].dimensions = swapchainData->extent; swapchainData->textureContainers[i].vulkanTexture->dimensions = swapchainData->extent;
swapchainData->textures[i].format = swapchainData->swapchainFormat; swapchainData->textureContainers[i].vulkanTexture->format = swapchainData->swapchainFormat;
swapchainData->textures[i].is3D = 0; swapchainData->textureContainers[i].vulkanTexture->is3D = 0;
swapchainData->textures[i].isCube = 0; swapchainData->textureContainers[i].vulkanTexture->isCube = 0;
swapchainData->textures[i].layerCount = 1; swapchainData->textureContainers[i].vulkanTexture->layerCount = 1;
swapchainData->textures[i].levelCount = 1; swapchainData->textureContainers[i].vulkanTexture->levelCount = 1;
swapchainData->textures[i].sampleCount = REFRESH_SAMPLECOUNT_1; swapchainData->textureContainers[i].vulkanTexture->sampleCount = REFRESH_SAMPLECOUNT_1;
swapchainData->textures[i].usageFlags = swapchainData->textureContainers[i].vulkanTexture->usageFlags =
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
swapchainData->textures[i].aspectFlags = VK_IMAGE_ASPECT_COLOR_BIT; swapchainData->textureContainers[i].vulkanTexture->aspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
swapchainData->textures[i].resourceAccessType = RESOURCE_ACCESS_NONE; swapchainData->textureContainers[i].vulkanTexture->resourceAccessType = RESOURCE_ACCESS_NONE;
swapchainData->textures[i].msaaTex = NULL; swapchainData->textureContainers[i].vulkanTexture->msaaTex = NULL;
} }
SDL_stack_free(swapchainImages); SDL_stack_free(swapchainImages);
@ -7064,7 +7068,7 @@ static Refresh_Buffer* VULKAN_CreateBuffer(
bufferContainer->vulkanBuffer = buffer; bufferContainer->vulkanBuffer = buffer;
buffer->container = bufferContainer; buffer->container = bufferContainer;
return (Refresh_Buffer*) buffer; return (Refresh_Buffer*) bufferContainer;
} }
/* Setters */ /* Setters */
@ -9721,7 +9725,7 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture(
WindowData *windowData; WindowData *windowData;
VulkanSwapchainData *swapchainData; VulkanSwapchainData *swapchainData;
VkResult acquireResult = VK_SUCCESS; VkResult acquireResult = VK_SUCCESS;
VulkanTexture *swapchainTexture = NULL; VulkanTextureContainer *swapchainTextureContainer = NULL;
VulkanPresentData *presentData; VulkanPresentData *presentData;
windowData = VULKAN_INTERNAL_FetchWindowData(windowHandle); windowData = VULKAN_INTERNAL_FetchWindowData(windowHandle);
@ -9784,7 +9788,7 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture(
} }
} }
swapchainTexture = &swapchainData->textures[swapchainImageIndex]; swapchainTextureContainer = &swapchainData->textureContainers[swapchainImageIndex];
VULKAN_INTERNAL_ImageMemoryBarrier( VULKAN_INTERNAL_ImageMemoryBarrier(
renderer, renderer,
@ -9796,8 +9800,8 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture(
0, 0,
1, 1,
0, 0,
swapchainTexture->image, swapchainTextureContainer->vulkanTexture->image,
&swapchainTexture->resourceAccessType &swapchainTextureContainer->vulkanTexture->resourceAccessType
); );
/* Set up present struct */ /* Set up present struct */
@ -9846,7 +9850,7 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture(
*pWidth = swapchainData->extent.width; *pWidth = swapchainData->extent.width;
*pHeight = swapchainData->extent.height; *pHeight = swapchainData->extent.height;
return (Refresh_Texture*) swapchainTexture; return (Refresh_Texture*) swapchainTextureContainer;
} }
static Refresh_TextureFormat VULKAN_GetSwapchainFormat( static Refresh_TextureFormat VULKAN_GetSwapchainFormat(
@ -10228,8 +10232,8 @@ static void VULKAN_Submit(
0, 0,
1, 1,
0, 0,
currentCommandBuffer->presentDatas[j].windowData->swapchainData->textures[swapchainImageIndex].image, currentCommandBuffer->presentDatas[j].windowData->swapchainData->textureContainers[swapchainImageIndex].vulkanTexture->image,
&currentCommandBuffer->presentDatas[j].windowData->swapchainData->textures[swapchainImageIndex].resourceAccessType &currentCommandBuffer->presentDatas[j].windowData->swapchainData->textureContainers[swapchainImageIndex].vulkanTexture->resourceAccessType
); );
} }