mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-14 16:33:52 +00:00
fix(rendering): sync async upload batches before rendering
Wait on in-flight upload batch fences at the start of each frame and insert a memory barrier (transfer→fragment shader) so the graphics queue sees completed layout transitions from the transfer queue. Fixes VK_IMAGE_LAYOUT_UNDEFINED validation errors for freshly loaded textures.
This commit is contained in:
parent
1379e74c40
commit
1feb6ea63f
1 changed files with 16 additions and 0 deletions
|
|
@ -1840,6 +1840,22 @@ VkCommandBuffer VkContext::beginFrame(uint32_t& imageIndex) {
|
|||
|
||||
vkBeginCommandBuffer(frame.commandBuffer, &beginInfo);
|
||||
|
||||
// If async upload batches are still in flight (submitted to the transfer queue),
|
||||
// wait for their fences and insert a memory barrier so the graphics queue sees
|
||||
// the completed layout transitions and transfer writes.
|
||||
if (!inFlightBatches_.empty()) {
|
||||
waitAllUploads();
|
||||
|
||||
VkMemoryBarrier memBarrier{};
|
||||
memBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
|
||||
memBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
memBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||
vkCmdPipelineBarrier(frame.commandBuffer,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||
0, 1, &memBarrier, 0, nullptr, 0, nullptr);
|
||||
}
|
||||
|
||||
return frame.commandBuffer;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue