From f7250ab12a9710d8edf8cae7aeb3a44eb4e281b0 Mon Sep 17 00:00:00 2001 From: TheSpydog Date: Sat, 14 Jan 2023 18:03:58 +0000 Subject: [PATCH] Remove fixed command buffers + minor cleanup (#33) Removes the `fixed` parameter from AcquireCommandBuffer, and removes a couple other unused bools from the VulkanCommandBuffer struct. Co-authored-by: Caleb Cornett Reviewed-on: https://gitea.moonside.games/MoonsideGames/Refresh/pulls/33 Co-authored-by: TheSpydog Co-committed-by: TheSpydog --- include/Refresh.h | 8 +------- src/Refresh.c | 6 ++---- src/Refresh_Driver.h | 3 +-- src/Refresh_Driver_Vulkan.c | 21 ++------------------- 4 files changed, 6 insertions(+), 32 deletions(-) diff --git a/include/Refresh.h b/include/Refresh.h index 9a1d361..a64524a 100644 --- a/include/Refresh.h +++ b/include/Refresh.h @@ -1168,15 +1168,9 @@ REFRESHAPI Refresh_TextureFormat Refresh_GetSwapchainFormat( * A command buffer may only be used on the thread that * it was acquired on. Using it on any other thread is an error. * - * fixed: - * If a command buffer is designated as fixed, it can be - * acquired once, have commands recorded into it, and - * be re-submitted indefinitely. - * */ REFRESHAPI Refresh_CommandBuffer* Refresh_AcquireCommandBuffer( - Refresh_Device *device, - uint8_t fixed + Refresh_Device *device ); /* Acquires a texture to use for presentation. diff --git a/src/Refresh.c b/src/Refresh.c index 809269e..c78b721 100644 --- a/src/Refresh.c +++ b/src/Refresh.c @@ -789,13 +789,11 @@ void Refresh_UnclaimWindow( } Refresh_CommandBuffer* Refresh_AcquireCommandBuffer( - Refresh_Device *device, - uint8_t fixed + Refresh_Device *device ) { NULL_RETURN_NULL(device); return device->AcquireCommandBuffer( - device->driverData, - fixed + device->driverData ); } diff --git a/src/Refresh_Driver.h b/src/Refresh_Driver.h index b48378f..2d483f7 100644 --- a/src/Refresh_Driver.h +++ b/src/Refresh_Driver.h @@ -470,8 +470,7 @@ struct Refresh_Device ); Refresh_CommandBuffer* (*AcquireCommandBuffer)( - Refresh_Renderer *driverData, - uint8_t fixed + Refresh_Renderer *driverData ); Refresh_Texture* (*AcquireSwapchainTexture)( diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index 77eb353..96f7fc1 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -1500,10 +1500,6 @@ typedef struct VulkanCommandPool VulkanCommandPool; typedef struct VulkanCommandBuffer { VkCommandBuffer commandBuffer; - uint8_t fixed; - uint8_t submitted; - uint8_t renderPassInProgress; - VulkanCommandPool *commandPool; VulkanPresentData *presentDatas; @@ -4662,11 +4658,7 @@ static void VULKAN_INTERNAL_BeginCommandBuffer( beginInfo.pNext = NULL; beginInfo.flags = 0; beginInfo.pInheritanceInfo = NULL; - - if (!commandBuffer->fixed) - { - beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - } + beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; result = renderer->vkBeginCommandBuffer( commandBuffer->commandBuffer, @@ -8484,8 +8476,6 @@ static void VULKAN_BeginRenderPass( VK_SUBPASS_CONTENTS_INLINE ); - vulkanCommandBuffer->renderPassInProgress = 1; - SDL_stack_free(clearValues); for (i = 0; i < colorAttachmentCount; i += 1) @@ -8622,7 +8612,6 @@ static void VULKAN_EndRenderPass( vulkanCommandBuffer->renderPassDepthTexture = NULL; vulkanCommandBuffer->currentGraphicsPipeline = NULL; - vulkanCommandBuffer->renderPassInProgress = 0; } static void VULKAN_BindGraphicsPipeline( @@ -9197,8 +9186,7 @@ static VulkanCommandBuffer* VULKAN_INTERNAL_GetInactiveCommandBufferFromPool( } static Refresh_CommandBuffer* VULKAN_AcquireCommandBuffer( - Refresh_Renderer *driverData, - uint8_t fixed + Refresh_Renderer *driverData ) { VulkanRenderer *renderer = (VulkanRenderer*) driverData; VkResult result; @@ -9221,10 +9209,6 @@ static Refresh_CommandBuffer* VULKAN_AcquireCommandBuffer( commandBuffer->fragmentUniformBuffer = NULL; commandBuffer->computeUniformBuffer = NULL; - commandBuffer->fixed = fixed; - commandBuffer->submitted = 0; - - commandBuffer->renderPassInProgress = 0; commandBuffer->renderPassColorTargetCount = 0; VULKAN_INTERNAL_BeginCommandBuffer(renderer, commandBuffer); @@ -9920,7 +9904,6 @@ static void VULKAN_Submit( ); } - ((VulkanCommandBuffer*)pCommandBuffers[i])->submitted = 1; renderer->submittedCommandBuffers[renderer->submittedCommandBufferCount] = (VulkanCommandBuffer*) pCommandBuffers[i]; renderer->submittedCommandBufferCount += 1;