Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions src/gpu/vulkan/SDL_gpu_vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,10 +1235,6 @@ struct VulkanRenderer
SDL_Mutex *descriptorSetLayoutFetchLock;
SDL_Mutex *windowLock;

// We don't want transfer commands to block each other,
// but we want all transfers to block during defrag.
SDL_RWLock *defragLock;

Uint8 defragInProgress;

VulkanMemoryAllocation **allocationsToDefrag;
Expand Down Expand Up @@ -8897,8 +8893,6 @@ static void VULKAN_UploadToTexture(
VulkanTextureSubresource *vulkanTextureSubresource;
VkBufferImageCopy imageCopy;

SDL_LockRWLockForReading(renderer->defragLock);

// Note that the transfer buffer does not need a barrier, as it is synced by the client
vulkanTextureSubresource = VULKAN_INTERNAL_PrepareTextureSubresourceForWrite(
renderer,
Expand Down Expand Up @@ -8940,8 +8934,6 @@ static void VULKAN_UploadToTexture(
VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, transferBufferContainer->activeBuffer);
VULKAN_INTERNAL_TrackTexture(vulkanCommandBuffer, vulkanTextureSubresource->parent);
VULKAN_INTERNAL_TrackTextureTransfer(vulkanCommandBuffer, vulkanTextureSubresource->parent);

SDL_UnlockRWLock(renderer->defragLock);
}

static void VULKAN_UploadToBuffer(
Expand All @@ -8956,8 +8948,6 @@ static void VULKAN_UploadToBuffer(
VulkanBufferContainer *bufferContainer = (VulkanBufferContainer *)destination->buffer;
VkBufferCopy bufferCopy;

SDL_LockRWLockForReading(renderer->defragLock);

// Note that the transfer buffer does not need a barrier, as it is synced by the client
VulkanBuffer *vulkanBuffer = VULKAN_INTERNAL_PrepareBufferForWrite(
renderer,
Expand Down Expand Up @@ -8987,8 +8977,6 @@ static void VULKAN_UploadToBuffer(
VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, transferBufferContainer->activeBuffer);
VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, vulkanBuffer);
VULKAN_INTERNAL_TrackBufferTransfer(vulkanCommandBuffer, vulkanBuffer);

SDL_UnlockRWLock(renderer->defragLock);
}

// Readback
Expand All @@ -9005,8 +8993,6 @@ static void VULKAN_DownloadFromTexture(
VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)destination->transfer_buffer;
VkBufferImageCopy imageCopy;

SDL_LockRWLockForReading(renderer->defragLock);

vulkanTextureSubresource = VULKAN_INTERNAL_FetchTextureSubresource(
textureContainer,
source->layer,
Expand Down Expand Up @@ -9051,8 +9037,6 @@ static void VULKAN_DownloadFromTexture(
VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, transferBufferContainer->activeBuffer);
VULKAN_INTERNAL_TrackTexture(vulkanCommandBuffer, vulkanTextureSubresource->parent);
VULKAN_INTERNAL_TrackTextureTransfer(vulkanCommandBuffer, vulkanTextureSubresource->parent);

SDL_UnlockRWLock(renderer->defragLock);
}

static void VULKAN_DownloadFromBuffer(
Expand All @@ -9066,8 +9050,6 @@ static void VULKAN_DownloadFromBuffer(
VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)destination->transfer_buffer;
VkBufferCopy bufferCopy;

SDL_LockRWLockForReading(renderer->defragLock);

// Note that transfer buffer does not need a barrier, as it is synced by the client
VULKAN_INTERNAL_BufferTransitionFromDefaultUsage(
renderer,
Expand Down Expand Up @@ -9095,8 +9077,6 @@ static void VULKAN_DownloadFromBuffer(
VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, transferBufferContainer->activeBuffer);
VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, bufferContainer->activeBuffer);
VULKAN_INTERNAL_TrackBufferTransfer(vulkanCommandBuffer, bufferContainer->activeBuffer);

SDL_UnlockRWLock(renderer->defragLock);
}

static void VULKAN_CopyTextureToTexture(
Expand All @@ -9114,8 +9094,6 @@ static void VULKAN_CopyTextureToTexture(
VulkanTextureSubresource *dstSubresource;
VkImageCopy imageCopy;

SDL_LockRWLockForReading(renderer->defragLock);

srcSubresource = VULKAN_INTERNAL_FetchTextureSubresource(
(VulkanTextureContainer *)source->texture,
source->layer,
Expand Down Expand Up @@ -9179,8 +9157,6 @@ static void VULKAN_CopyTextureToTexture(
VULKAN_INTERNAL_TrackTexture(vulkanCommandBuffer, dstSubresource->parent);
VULKAN_INTERNAL_TrackTextureTransfer(vulkanCommandBuffer, srcSubresource->parent);
VULKAN_INTERNAL_TrackTextureTransfer(vulkanCommandBuffer, dstSubresource->parent);

SDL_UnlockRWLock(renderer->defragLock);
}

static void VULKAN_CopyBufferToBuffer(
Expand All @@ -9196,8 +9172,6 @@ static void VULKAN_CopyBufferToBuffer(
VulkanBufferContainer *dstContainer = (VulkanBufferContainer *)destination->buffer;
VkBufferCopy bufferCopy;

SDL_LockRWLockForReading(renderer->defragLock);

VulkanBuffer *dstBuffer = VULKAN_INTERNAL_PrepareBufferForWrite(
renderer,
vulkanCommandBuffer,
Expand Down Expand Up @@ -9238,8 +9212,6 @@ static void VULKAN_CopyBufferToBuffer(
VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, dstBuffer);
VULKAN_INTERNAL_TrackBufferTransfer(vulkanCommandBuffer, srcContainer->activeBuffer);
VULKAN_INTERNAL_TrackBufferTransfer(vulkanCommandBuffer, dstBuffer);

SDL_UnlockRWLock(renderer->defragLock);
}

static void VULKAN_GenerateMipmaps(
Expand All @@ -9253,8 +9225,6 @@ static void VULKAN_GenerateMipmaps(
VulkanTextureSubresource *dstTextureSubresource;
VkImageBlit blit;

SDL_LockRWLockForReading(renderer->defragLock);

// Blit each slice sequentially. Barriers, barriers everywhere!
for (Uint32 layerOrDepthIndex = 0; layerOrDepthIndex < container->header.info.layer_count_or_depth; layerOrDepthIndex += 1) {
for (Uint32 level = 1; level < container->header.info.num_levels; level += 1) {
Expand Down Expand Up @@ -9340,8 +9310,6 @@ static void VULKAN_GenerateMipmaps(

}
}

SDL_UnlockRWLock(renderer->defragLock);
}

static void VULKAN_EndCopyPass(
Expand Down Expand Up @@ -11039,7 +11007,6 @@ static bool VULKAN_INTERNAL_DefragmentMemory(
commandBuffer->isDefrag = 1;

SDL_LockMutex(renderer->allocatorLock);
SDL_LockRWLockForWriting(renderer->defragLock);

// Find an allocation that doesn't have any pending transfer operations
Sint32 indexToDefrag = -1;
Expand All @@ -11052,7 +11019,6 @@ static bool VULKAN_INTERNAL_DefragmentMemory(

if (indexToDefrag == -1) {
// Nothing is available to defrag, but it's not an error
SDL_UnlockRWLock(renderer->defragLock);
SDL_UnlockMutex(renderer->allocatorLock);
return true;
}
Expand Down Expand Up @@ -11082,7 +11048,6 @@ static bool VULKAN_INTERNAL_DefragmentMemory(
currentRegion->vulkanBuffer->container != NULL ? currentRegion->vulkanBuffer->container->debugName : NULL);

if (newBuffer == NULL) {
SDL_UnlockRWLock(renderer->defragLock);
SDL_UnlockMutex(renderer->allocatorLock);
SDL_LogError(SDL_LOG_CATEGORY_GPU, "%s", "Failed to allocate defrag buffer!");
return false;
Expand Down Expand Up @@ -11148,7 +11113,6 @@ static bool VULKAN_INTERNAL_DefragmentMemory(
&currentRegion->vulkanTexture->container->header.info);

if (newTexture == NULL) {
SDL_UnlockRWLock(renderer->defragLock);
SDL_UnlockMutex(renderer->allocatorLock);
SDL_LogError(SDL_LOG_CATEGORY_GPU, "%s", "Failed to allocate defrag buffer!");
return false;
Expand Down Expand Up @@ -11225,7 +11189,6 @@ static bool VULKAN_INTERNAL_DefragmentMemory(
}
}

SDL_UnlockRWLock(renderer->defragLock);
SDL_UnlockMutex(renderer->allocatorLock);

return true;
Expand Down
Loading