From f4197f93b4fd85c206ae74cc3d467926e524a0da Mon Sep 17 00:00:00 2001 From: ShoufengYang <88227393+ShoufengYang@users.noreply.github.com> Date: Tue, 3 Aug 2021 23:22:48 +0800 Subject: [PATCH] Fixed the first frame render error. The compute commands should be submit before the graphic command. If not, there is a logical error that cause the first frame render error. Since the graphic rendering need to sample the compute shader 's output image. --- .../computeraytracing/computeraytracing.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/computeraytracing/computeraytracing.cpp b/examples/computeraytracing/computeraytracing.cpp index f99893bc..be96bc45 100644 --- a/examples/computeraytracing/computeraytracing.cpp +++ b/examples/computeraytracing/computeraytracing.cpp @@ -666,15 +666,6 @@ public: void draw() { - VulkanExampleBase::prepareFrame(); - - // Command buffer to be submitted to the queue - submitInfo.commandBufferCount = 1; - submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer]; - VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); - - VulkanExampleBase::submitFrame(); - // 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); @@ -685,6 +676,15 @@ public: computeSubmitInfo.pCommandBuffers = &compute.commandBuffer; VK_CHECK_RESULT(vkQueueSubmit(compute.queue, 1, &computeSubmitInfo, compute.fence)); + + VulkanExampleBase::prepareFrame(); + + // Command buffer to be submitted to the queue + submitInfo.commandBufferCount = 1; + submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer]; + VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); + + VulkanExampleBase::submitFrame(); } void prepare() @@ -720,4 +720,4 @@ public: } }; -VULKAN_EXAMPLE_MAIN() \ No newline at end of file +VULKAN_EXAMPLE_MAIN()