|
|
|
@ -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,
|
|
|
|
@ -6734,9 +6726,11 @@ static Refresh_Buffer* VULKAN_CreateBuffer(
|
|
|
|
|
static VulkanTransferBuffer* VULKAN_INTERNAL_AcquireTransferBuffer(
|
|
|
|
|
VulkanRenderer *renderer,
|
|
|
|
|
VulkanCommandBuffer *commandBuffer,
|
|
|
|
|
VkDeviceSize requiredSize
|
|
|
|
|
VkDeviceSize requiredSize,
|
|
|
|
|
VkDeviceSize alignment
|
|
|
|
|
) {
|
|
|
|
|
VkDeviceSize size;
|
|
|
|
|
VkDeviceSize offset;
|
|
|
|
|
uint32_t i;
|
|
|
|
|
VulkanTransferBuffer *transferBuffer;
|
|
|
|
|
|
|
|
|
@ -6745,9 +6739,11 @@ static VulkanTransferBuffer* VULKAN_INTERNAL_AcquireTransferBuffer(
|
|
|
|
|
for (i = 0; i < commandBuffer->transferBufferCount; i += 1)
|
|
|
|
|
{
|
|
|
|
|
transferBuffer = commandBuffer->transferBuffers[i];
|
|
|
|
|
offset = transferBuffer->offset + alignment - (transferBuffer->offset % alignment);
|
|
|
|
|
|
|
|
|
|
if (transferBuffer->offset + requiredSize <= transferBuffer->buffer->size)
|
|
|
|
|
if (offset + requiredSize <= transferBuffer->buffer->size)
|
|
|
|
|
{
|
|
|
|
|
transferBuffer->offset = offset;
|
|
|
|
|
return transferBuffer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -6759,8 +6755,9 @@ static VulkanTransferBuffer* VULKAN_INTERNAL_AcquireTransferBuffer(
|
|
|
|
|
for (i = 0; i < renderer->transferBufferPool.availableBufferCount; i += 1)
|
|
|
|
|
{
|
|
|
|
|
transferBuffer = renderer->transferBufferPool.availableBuffers[i];
|
|
|
|
|
offset = transferBuffer->offset + alignment - (transferBuffer->offset % alignment);
|
|
|
|
|
|
|
|
|
|
if (transferBuffer->offset + requiredSize <= transferBuffer->buffer->size)
|
|
|
|
|
if (offset + requiredSize <= transferBuffer->buffer->size)
|
|
|
|
|
{
|
|
|
|
|
if (commandBuffer->transferBufferCount == commandBuffer->transferBufferCapacity)
|
|
|
|
|
{
|
|
|
|
@ -6778,6 +6775,7 @@ static VulkanTransferBuffer* VULKAN_INTERNAL_AcquireTransferBuffer(
|
|
|
|
|
renderer->transferBufferPool.availableBufferCount -= 1;
|
|
|
|
|
SDL_UnlockMutex(renderer->transferBufferPool.lock);
|
|
|
|
|
|
|
|
|
|
transferBuffer->offset = offset;
|
|
|
|
|
return transferBuffer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -6847,7 +6845,8 @@ static void VULKAN_SetTextureData(
|
|
|
|
|
textureSlice->rectangle.w,
|
|
|
|
|
textureSlice->rectangle.h,
|
|
|
|
|
vulkanTexture->format
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
VULKAN_INTERNAL_BytesPerPixel(vulkanTexture->format)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (transferBuffer == NULL)
|
|
|
|
@ -6944,7 +6943,7 @@ static void VULKAN_SetTextureDataYUV(
|
|
|
|
|
uint32_t dataLength
|
|
|
|
|
) {
|
|
|
|
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
|
|
|
|
VulkanTexture *tex;
|
|
|
|
|
VulkanTexture *tex = (VulkanTexture*) y;
|
|
|
|
|
|
|
|
|
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*)commandBuffer;
|
|
|
|
|
VulkanTransferBuffer *transferBuffer;
|
|
|
|
@ -6957,7 +6956,8 @@ static void VULKAN_SetTextureDataYUV(
|
|
|
|
|
transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer(
|
|
|
|
|
renderer,
|
|
|
|
|
vulkanCommandBuffer,
|
|
|
|
|
yDataLength + uvDataLength
|
|
|
|
|
yDataLength + uvDataLength,
|
|
|
|
|
VULKAN_INTERNAL_BytesPerPixel(tex->format)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (transferBuffer == NULL)
|
|
|
|
@ -6983,8 +6983,6 @@ static void VULKAN_SetTextureDataYUV(
|
|
|
|
|
|
|
|
|
|
/* Y */
|
|
|
|
|
|
|
|
|
|
tex = (VulkanTexture*) y;
|
|
|
|
|
|
|
|
|
|
SDL_memcpy(
|
|
|
|
|
stagingBufferPointer,
|
|
|
|
|
dataPtr,
|
|
|
|
@ -7336,7 +7334,8 @@ static void VULKAN_SetBufferData(
|
|
|
|
|
transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer(
|
|
|
|
|
renderer,
|
|
|
|
|
vulkanCommandBuffer,
|
|
|
|
|
dataLength
|
|
|
|
|
dataLength,
|
|
|
|
|
renderer->physicalDeviceProperties.properties.limits.optimalBufferCopyOffsetAlignment
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (transferBuffer == NULL)
|
|
|
|
@ -8477,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)
|
|
|
|
@ -8615,7 +8612,6 @@ static void VULKAN_EndRenderPass(
|
|
|
|
|
vulkanCommandBuffer->renderPassDepthTexture = NULL;
|
|
|
|
|
|
|
|
|
|
vulkanCommandBuffer->currentGraphicsPipeline = NULL;
|
|
|
|
|
vulkanCommandBuffer->renderPassInProgress = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void VULKAN_BindGraphicsPipeline(
|
|
|
|
@ -9190,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;
|
|
|
|
@ -9214,33 +9209,8 @@ static Refresh_CommandBuffer* VULKAN_AcquireCommandBuffer(
|
|
|
|
|
commandBuffer->fragmentUniformBuffer = NULL;
|
|
|
|
|
commandBuffer->computeUniformBuffer = NULL;
|
|
|
|
|
|
|
|
|
|
commandBuffer->fixed = fixed;
|
|
|
|
|
commandBuffer->submitted = 0;
|
|
|
|
|
|
|
|
|
|
commandBuffer->renderPassInProgress = 0;
|
|
|
|
|
commandBuffer->renderPassColorTargetCount = 0;
|
|
|
|
|
|
|
|
|
|
result = renderer->vkResetCommandBuffer(
|
|
|
|
|
commandBuffer->commandBuffer,
|
|
|
|
|
VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
LogVulkanResultAsError("vkResetCommandBuffer", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = renderer->vkResetFences(
|
|
|
|
|
renderer->logicalDevice,
|
|
|
|
|
1,
|
|
|
|
|
&commandBuffer->inFlightFence
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
LogVulkanResultAsError("vkResetFences", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VULKAN_INTERNAL_BeginCommandBuffer(renderer, commandBuffer);
|
|
|
|
|
|
|
|
|
|
return (Refresh_CommandBuffer*) commandBuffer;
|
|
|
|
@ -9644,6 +9614,7 @@ static void VULKAN_INTERNAL_CleanCommandBuffer(
|
|
|
|
|
uint32_t i;
|
|
|
|
|
VulkanUniformBuffer *uniformBuffer;
|
|
|
|
|
DescriptorSetData *descriptorSetData;
|
|
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
|
|
/* Bound uniform buffers are now available */
|
|
|
|
|
|
|
|
|
@ -9773,12 +9744,35 @@ static void VULKAN_INTERNAL_CleanCommandBuffer(
|
|
|
|
|
|
|
|
|
|
SDL_UnlockMutex(renderer->acquireCommandBufferLock);
|
|
|
|
|
|
|
|
|
|
/* Resent presentation data */
|
|
|
|
|
/* Reset presentation data */
|
|
|
|
|
|
|
|
|
|
commandBuffer->presentDataCount = 0;
|
|
|
|
|
commandBuffer->waitSemaphoreCount = 0;
|
|
|
|
|
commandBuffer->signalSemaphoreCount = 0;
|
|
|
|
|
|
|
|
|
|
/* Reset Vulkan state */
|
|
|
|
|
|
|
|
|
|
result = renderer->vkResetCommandBuffer(
|
|
|
|
|
commandBuffer->commandBuffer,
|
|
|
|
|
VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
LogVulkanResultAsError("vkResetCommandBuffer", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = renderer->vkResetFences(
|
|
|
|
|
renderer->logicalDevice,
|
|
|
|
|
1,
|
|
|
|
|
&commandBuffer->inFlightFence
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
LogVulkanResultAsError("vkResetFences", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove this command buffer from the submitted list */
|
|
|
|
|
for (i = 0; i < renderer->submittedCommandBufferCount; i += 1)
|
|
|
|
|
{
|
|
|
|
@ -9910,7 +9904,6 @@ static void VULKAN_Submit(
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
((VulkanCommandBuffer*)pCommandBuffers[i])->submitted = 1;
|
|
|
|
|
renderer->submittedCommandBuffers[renderer->submittedCommandBufferCount] = (VulkanCommandBuffer*) pCommandBuffers[i];
|
|
|
|
|
renderer->submittedCommandBufferCount += 1;
|
|
|
|
|
|
|
|
|
@ -9948,13 +9941,9 @@ static void VULKAN_Submit(
|
|
|
|
|
|
|
|
|
|
for (i = renderer->submittedCommandBufferCount - 1; i >= 0; i -= 1)
|
|
|
|
|
{
|
|
|
|
|
/* If we set a timeout of 0, we can query the command buffer state */
|
|
|
|
|
vulkanResult = renderer->vkWaitForFences(
|
|
|
|
|
vulkanResult = renderer->vkGetFenceStatus(
|
|
|
|
|
renderer->logicalDevice,
|
|
|
|
|
1,
|
|
|
|
|
&renderer->submittedCommandBuffers[i]->inFlightFence,
|
|
|
|
|
VK_TRUE,
|
|
|
|
|
0
|
|
|
|
|
renderer->submittedCommandBuffers[i]->inFlightFence
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (vulkanResult == VK_SUCCESS)
|
|
|
|
@ -10537,6 +10526,7 @@ static uint8_t VULKAN_INTERNAL_CreateLogicalDevice(
|
|
|
|
|
SDL_zero(deviceFeatures);
|
|
|
|
|
deviceFeatures.fillModeNonSolid = VK_TRUE;
|
|
|
|
|
deviceFeatures.samplerAnisotropy = VK_TRUE;
|
|
|
|
|
deviceFeatures.multiDrawIndirect = VK_TRUE;
|
|
|
|
|
|
|
|
|
|
/* creating the logical device */
|
|
|
|
|
|
|
|
|
|