Skip to content

Commit

Permalink
Fix potential resource dependency problem. (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottchou007 authored Jan 24, 2025
1 parent 59b7217 commit bd7fd79
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/computeraytracing/computeraytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ class VulkanExample : public VulkanExampleBase
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, &compute.commandBuffer));

// 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));

// Build a single command buffer containing the compute dispatch commands
Expand Down Expand Up @@ -604,15 +604,15 @@ class VulkanExample : public VulkanExampleBase
{
// Submit compute commands
// 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();
computeSubmitInfo.commandBufferCount = 1;
computeSubmitInfo.pCommandBuffers = &compute.commandBuffer;

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();

// Command buffer to be submitted to the queue
Expand Down

0 comments on commit bd7fd79

Please sign in to comment.