forked from MoonsideGames/Refresh
Compare commits
No commits in common. "864d381d2ace9af3439881b15cf33040667e1af0" and "329ffab6b8dab0bc736432cc4423373a5c97daa9" have entirely different histories.
864d381d2a
...
329ffab6b8
|
@ -8,7 +8,7 @@ option(BUILD_SHARED_LIBS "Build shared library" ON)
|
|||
|
||||
# Version
|
||||
SET(LIB_MAJOR_VERSION "1")
|
||||
SET(LIB_MINOR_VERSION "10")
|
||||
SET(LIB_MINOR_VERSION "9")
|
||||
SET(LIB_REVISION "0")
|
||||
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ extern "C" {
|
|||
/* Version API */
|
||||
|
||||
#define REFRESH_MAJOR_VERSION 1
|
||||
#define REFRESH_MINOR_VERSION 10
|
||||
#define REFRESH_MINOR_VERSION 9
|
||||
#define REFRESH_PATCH_VERSION 0
|
||||
|
||||
#define REFRESH_COMPILED_VERSION ( \
|
||||
|
@ -376,14 +376,6 @@ typedef struct Refresh_TextureSlice
|
|||
uint32_t level;
|
||||
} Refresh_TextureSlice;
|
||||
|
||||
typedef struct Refresh_IndirectDrawCommand
|
||||
{
|
||||
uint32_t vertexCount;
|
||||
uint32_t instanceCount;
|
||||
uint32_t firstVertex;
|
||||
uint32_t firstInstance;
|
||||
} Refresh_IndirectDrawCommand;
|
||||
|
||||
/* State structures */
|
||||
|
||||
typedef struct Refresh_SamplerStateCreateInfo
|
||||
|
@ -674,7 +666,6 @@ REFRESHAPI void Refresh_DrawPrimitives(
|
|||
);
|
||||
|
||||
/* Similar to Refresh_DrawPrimitives, but draw parameters are set from a buffer.
|
||||
* The buffer layout should match the layout of Refresh_IndirectDrawCommand.
|
||||
*
|
||||
* buffer: A buffer containing draw parameters.
|
||||
* offsetInBytes: The offset to start reading from the draw buffer.
|
||||
|
@ -1168,9 +1159,15 @@ 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
|
||||
Refresh_Device *device,
|
||||
uint8_t fixed
|
||||
);
|
||||
|
||||
/* Acquires a texture to use for presentation.
|
||||
|
|
|
@ -789,11 +789,13 @@ void Refresh_UnclaimWindow(
|
|||
}
|
||||
|
||||
Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
|
||||
Refresh_Device *device
|
||||
Refresh_Device *device,
|
||||
uint8_t fixed
|
||||
) {
|
||||
NULL_RETURN_NULL(device);
|
||||
return device->AcquireCommandBuffer(
|
||||
device->driverData
|
||||
device->driverData,
|
||||
fixed
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -470,7 +470,8 @@ struct Refresh_Device
|
|||
);
|
||||
|
||||
Refresh_CommandBuffer* (*AcquireCommandBuffer)(
|
||||
Refresh_Renderer *driverData
|
||||
Refresh_Renderer *driverData,
|
||||
uint8_t fixed
|
||||
);
|
||||
|
||||
Refresh_Texture* (*AcquireSwapchainTexture)(
|
||||
|
|
|
@ -1500,6 +1500,10 @@ typedef struct VulkanCommandPool VulkanCommandPool;
|
|||
typedef struct VulkanCommandBuffer
|
||||
{
|
||||
VkCommandBuffer commandBuffer;
|
||||
uint8_t fixed;
|
||||
uint8_t submitted;
|
||||
uint8_t renderPassInProgress;
|
||||
|
||||
VulkanCommandPool *commandPool;
|
||||
|
||||
VulkanPresentData *presentDatas;
|
||||
|
@ -4658,7 +4662,11 @@ 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;
|
||||
}
|
||||
|
||||
result = renderer->vkBeginCommandBuffer(
|
||||
commandBuffer->commandBuffer,
|
||||
|
@ -6726,11 +6734,9 @@ static Refresh_Buffer* VULKAN_CreateBuffer(
|
|||
static VulkanTransferBuffer* VULKAN_INTERNAL_AcquireTransferBuffer(
|
||||
VulkanRenderer *renderer,
|
||||
VulkanCommandBuffer *commandBuffer,
|
||||
VkDeviceSize requiredSize,
|
||||
VkDeviceSize alignment
|
||||
VkDeviceSize requiredSize
|
||||
) {
|
||||
VkDeviceSize size;
|
||||
VkDeviceSize offset;
|
||||
uint32_t i;
|
||||
VulkanTransferBuffer *transferBuffer;
|
||||
|
||||
|
@ -6739,11 +6745,9 @@ 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 (offset + requiredSize <= transferBuffer->buffer->size)
|
||||
if (transferBuffer->offset + requiredSize <= transferBuffer->buffer->size)
|
||||
{
|
||||
transferBuffer->offset = offset;
|
||||
return transferBuffer;
|
||||
}
|
||||
}
|
||||
|
@ -6755,9 +6759,8 @@ 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 (offset + requiredSize <= transferBuffer->buffer->size)
|
||||
if (transferBuffer->offset + requiredSize <= transferBuffer->buffer->size)
|
||||
{
|
||||
if (commandBuffer->transferBufferCount == commandBuffer->transferBufferCapacity)
|
||||
{
|
||||
|
@ -6775,7 +6778,6 @@ static VulkanTransferBuffer* VULKAN_INTERNAL_AcquireTransferBuffer(
|
|||
renderer->transferBufferPool.availableBufferCount -= 1;
|
||||
SDL_UnlockMutex(renderer->transferBufferPool.lock);
|
||||
|
||||
transferBuffer->offset = offset;
|
||||
return transferBuffer;
|
||||
}
|
||||
}
|
||||
|
@ -6845,8 +6847,7 @@ static void VULKAN_SetTextureData(
|
|||
textureSlice->rectangle.w,
|
||||
textureSlice->rectangle.h,
|
||||
vulkanTexture->format
|
||||
),
|
||||
VULKAN_INTERNAL_BytesPerPixel(vulkanTexture->format)
|
||||
)
|
||||
);
|
||||
|
||||
if (transferBuffer == NULL)
|
||||
|
@ -6943,7 +6944,7 @@ static void VULKAN_SetTextureDataYUV(
|
|||
uint32_t dataLength
|
||||
) {
|
||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||
VulkanTexture *tex = (VulkanTexture*) y;
|
||||
VulkanTexture *tex;
|
||||
|
||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*)commandBuffer;
|
||||
VulkanTransferBuffer *transferBuffer;
|
||||
|
@ -6956,8 +6957,7 @@ static void VULKAN_SetTextureDataYUV(
|
|||
transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer(
|
||||
renderer,
|
||||
vulkanCommandBuffer,
|
||||
yDataLength + uvDataLength,
|
||||
VULKAN_INTERNAL_BytesPerPixel(tex->format)
|
||||
yDataLength + uvDataLength
|
||||
);
|
||||
|
||||
if (transferBuffer == NULL)
|
||||
|
@ -6983,6 +6983,8 @@ static void VULKAN_SetTextureDataYUV(
|
|||
|
||||
/* Y */
|
||||
|
||||
tex = (VulkanTexture*) y;
|
||||
|
||||
SDL_memcpy(
|
||||
stagingBufferPointer,
|
||||
dataPtr,
|
||||
|
@ -7334,8 +7336,7 @@ static void VULKAN_SetBufferData(
|
|||
transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer(
|
||||
renderer,
|
||||
vulkanCommandBuffer,
|
||||
dataLength,
|
||||
renderer->physicalDeviceProperties.properties.limits.optimalBufferCopyOffsetAlignment
|
||||
dataLength
|
||||
);
|
||||
|
||||
if (transferBuffer == NULL)
|
||||
|
@ -8476,6 +8477,8 @@ static void VULKAN_BeginRenderPass(
|
|||
VK_SUBPASS_CONTENTS_INLINE
|
||||
);
|
||||
|
||||
vulkanCommandBuffer->renderPassInProgress = 1;
|
||||
|
||||
SDL_stack_free(clearValues);
|
||||
|
||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||
|
@ -8612,6 +8615,7 @@ static void VULKAN_EndRenderPass(
|
|||
vulkanCommandBuffer->renderPassDepthTexture = NULL;
|
||||
|
||||
vulkanCommandBuffer->currentGraphicsPipeline = NULL;
|
||||
vulkanCommandBuffer->renderPassInProgress = 0;
|
||||
}
|
||||
|
||||
static void VULKAN_BindGraphicsPipeline(
|
||||
|
@ -9186,7 +9190,8 @@ static VulkanCommandBuffer* VULKAN_INTERNAL_GetInactiveCommandBufferFromPool(
|
|||
}
|
||||
|
||||
static Refresh_CommandBuffer* VULKAN_AcquireCommandBuffer(
|
||||
Refresh_Renderer *driverData
|
||||
Refresh_Renderer *driverData,
|
||||
uint8_t fixed
|
||||
) {
|
||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||
VkResult result;
|
||||
|
@ -9209,8 +9214,33 @@ 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;
|
||||
|
@ -9614,7 +9644,6 @@ static void VULKAN_INTERNAL_CleanCommandBuffer(
|
|||
uint32_t i;
|
||||
VulkanUniformBuffer *uniformBuffer;
|
||||
DescriptorSetData *descriptorSetData;
|
||||
VkResult result;
|
||||
|
||||
/* Bound uniform buffers are now available */
|
||||
|
||||
|
@ -9744,35 +9773,12 @@ static void VULKAN_INTERNAL_CleanCommandBuffer(
|
|||
|
||||
SDL_UnlockMutex(renderer->acquireCommandBufferLock);
|
||||
|
||||
/* Reset presentation data */
|
||||
/* Resent 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)
|
||||
{
|
||||
|
@ -9904,6 +9910,7 @@ static void VULKAN_Submit(
|
|||
);
|
||||
}
|
||||
|
||||
((VulkanCommandBuffer*)pCommandBuffers[i])->submitted = 1;
|
||||
renderer->submittedCommandBuffers[renderer->submittedCommandBufferCount] = (VulkanCommandBuffer*) pCommandBuffers[i];
|
||||
renderer->submittedCommandBufferCount += 1;
|
||||
|
||||
|
@ -9941,9 +9948,13 @@ static void VULKAN_Submit(
|
|||
|
||||
for (i = renderer->submittedCommandBufferCount - 1; i >= 0; i -= 1)
|
||||
{
|
||||
vulkanResult = renderer->vkGetFenceStatus(
|
||||
/* If we set a timeout of 0, we can query the command buffer state */
|
||||
vulkanResult = renderer->vkWaitForFences(
|
||||
renderer->logicalDevice,
|
||||
renderer->submittedCommandBuffers[i]->inFlightFence
|
||||
1,
|
||||
&renderer->submittedCommandBuffers[i]->inFlightFence,
|
||||
VK_TRUE,
|
||||
0
|
||||
);
|
||||
|
||||
if (vulkanResult == VK_SUCCESS)
|
||||
|
@ -10526,7 +10537,6 @@ 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 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue