Skip to content

Rework synchronization in port of my framework #1380

@SaschaWillems

Description

@SaschaWillems

Back when I started doing Vulkan samples, I did use vkQueueWaitIdle to "sync" frame presentation. That made it easier to write samples, but kills any chance of CPU/GPU parallelism like frames-in-flight. This makes all samples based on the port of my framework sub-optimal from Vulkan's Point-of-View:

void ApiVulkanSample::submit_frame()
{
	if (get_render_context().has_swapchain())
	{
            ...
	}

	// DO NOT USE
	// vkDeviceWaitIdle and vkQueueWaitIdle are extremely expensive functions, and are used here purely for demonstrating the vulkan API
	// without having to concern ourselves with proper syncronization. These functions should NEVER be used inside the render loop like this (every frame).
	VK_CHECK(get_device().get_queue_by_present(0).wait_idle());
}

Removing this will require duplicating resources shared by CPU and GPU (e.g. uniform buffers) in all samples and redoing the semaphore/fence setup.

That's something I'm currently fixing in my own samples link, and after that I'd be willing to also do that for the Khronos samples.

Will probably be a larger effort (at least weeks, more prob. months) but in the end it'll be worth it to show how to properly use Vulkan.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions