Fix potential resource dependency problem. (#1079)

This commit is contained in:
scottchou007 2025-01-24 00:15:26 -08:00 committed by GitHub
parent 59b7217cbc
commit bd7fd79bb8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -562,7 +562,7 @@ public:
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, &compute.commandBuffer)); VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, &compute.commandBuffer));
// Fence for compute CB sync // Fence for compute CB sync
VkFenceCreateInfo fenceCreateInfo = vks::initializers::fenceCreateInfo(VK_FENCE_CREATE_SIGNALED_BIT); VkFenceCreateInfo fenceCreateInfo = vks::initializers::fenceCreateInfo();
VK_CHECK_RESULT(vkCreateFence(device, &fenceCreateInfo, nullptr, &compute.fence)); VK_CHECK_RESULT(vkCreateFence(device, &fenceCreateInfo, nullptr, &compute.fence));
// Build a single command buffer containing the compute dispatch commands // Build a single command buffer containing the compute dispatch commands
@ -604,15 +604,15 @@ public:
{ {
// Submit compute commands // Submit compute commands
// Use a fence to ensure that compute command buffer has finished executing before using it again // Use a fence to ensure that compute command buffer has finished executing before using it again
vkWaitForFences(device, 1, &compute.fence, VK_TRUE, UINT64_MAX);
vkResetFences(device, 1, &compute.fence);
VkSubmitInfo computeSubmitInfo = vks::initializers::submitInfo(); VkSubmitInfo computeSubmitInfo = vks::initializers::submitInfo();
computeSubmitInfo.commandBufferCount = 1; computeSubmitInfo.commandBufferCount = 1;
computeSubmitInfo.pCommandBuffers = &compute.commandBuffer; computeSubmitInfo.pCommandBuffers = &compute.commandBuffer;
VK_CHECK_RESULT(vkQueueSubmit(compute.queue, 1, &computeSubmitInfo, compute.fence)); VK_CHECK_RESULT(vkQueueSubmit(compute.queue, 1, &computeSubmitInfo, compute.fence));
vkWaitForFences(device, 1, &compute.fence, VK_TRUE, UINT64_MAX);
vkResetFences(device, 1, &compute.fence);
VulkanExampleBase::prepareFrame(); VulkanExampleBase::prepareFrame();
// Command buffer to be submitted to the queue // Command buffer to be submitted to the queue