MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Tools / demo_flush_init_cmd

Function demo_flush_init_cmd

cube/cube.c:794–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792}
793
794static void demo_flush_init_cmd(struct demo *demo) {
795 VkResult U_ASSERT_ONLY err;
796
797 // This function could get called twice if the texture uses a staging buffer
798 // In that case the second call should be ignored
799 if (demo->cmd == VK_NULL_HANDLE) return;
800
801 err = vkEndCommandBuffer(demo->cmd);
802 assert(!err);
803
804 VkFence fence;
805 VkFenceCreateInfo fence_ci = {.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .pNext = NULL, .flags = 0};
806 if (demo->force_errors) {
807 // Remove sType to intentionally force validation layer errors.
808 fence_ci.sType = 0;
809 }
810 err = vkCreateFence(demo->device, &fence_ci, NULL, &fence);
811 assert(!err);
812 demo_name_object(demo, VK_OBJECT_TYPE_FENCE, (uint64_t)fence, "InitFence");
813
814 const VkCommandBuffer cmd_bufs[] = {demo->cmd};
815 VkSubmitInfo submit_info = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
816 .pNext = NULL,
817 .waitSemaphoreCount = 0,
818 .pWaitSemaphores = NULL,
819 .pWaitDstStageMask = NULL,
820 .commandBufferCount = 1,
821 .pCommandBuffers = cmd_bufs,
822 .signalSemaphoreCount = 0,
823 .pSignalSemaphores = NULL};
824
825 err = vkQueueSubmit(demo->graphics_queue, 1, &submit_info, fence);
826 assert(!err);
827
828 err = vkWaitForFences(demo->device, 1, &fence, VK_TRUE, UINT64_MAX);
829 assert(!err);
830
831 vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, cmd_bufs);
832 vkDestroyFence(demo->device, fence, NULL);
833 demo->cmd = VK_NULL_HANDLE;
834}
835
836static void demo_set_image_layout(struct demo *demo, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout old_image_layout,
837 VkImageLayout new_image_layout, VkAccessFlagBits srcAccessMask, VkPipelineStageFlags src_stages,

Callers 1

demo_prepareFunction · 0.85

Calls 1

demo_name_objectFunction · 0.85

Tested by

no test coverage detected