mirror of https://github.com/snes9xgit/snes9x.git
qt,gtk/vulkan: Add VK_EXT_present_wait support again.
This commit is contained in:
parent
191cdf462a
commit
663738341a
|
@ -235,6 +235,12 @@ bool Context::init_device()
|
|||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||
};
|
||||
|
||||
std::vector<const char *> present_wait_extensions =
|
||||
{
|
||||
VK_KHR_PRESENT_ID_EXTENSION_NAME,
|
||||
VK_KHR_PRESENT_WAIT_EXTENSION_NAME
|
||||
};
|
||||
|
||||
auto device_list = instance->enumeratePhysicalDevices().value;
|
||||
bool device_chosen = false;
|
||||
physical_device = vk::PhysicalDevice();
|
||||
|
@ -263,6 +269,17 @@ bool Context::init_device()
|
|||
if (!device_chosen)
|
||||
return false;
|
||||
|
||||
if (check_extensions(present_wait_extensions, physical_device))
|
||||
{
|
||||
for (auto &ext : present_wait_extensions)
|
||||
required_extensions.push_back(ext);
|
||||
have_present_wait = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
have_present_wait = false;
|
||||
}
|
||||
|
||||
if (auto index = find_graphics_queue(physical_device))
|
||||
graphics_queue_family_index = *index;
|
||||
else
|
||||
|
@ -272,6 +289,14 @@ bool Context::init_device()
|
|||
vk::DeviceQueueCreateInfo dqci({}, graphics_queue_family_index, priorities);
|
||||
vk::DeviceCreateInfo dci({}, dqci, {}, required_extensions);
|
||||
|
||||
vk::PhysicalDevicePresentWaitFeaturesKHR physical_device_present_wait_feature(true);
|
||||
vk::PhysicalDevicePresentIdFeaturesKHR physical_device_present_id_feature(true);
|
||||
if (have_present_wait)
|
||||
{
|
||||
dci.setPNext(&physical_device_present_wait_feature);
|
||||
physical_device_present_wait_feature.setPNext(&physical_device_present_id_feature);
|
||||
}
|
||||
|
||||
device = physical_device.createDevice(dci).value;
|
||||
queue = device.getQueue(graphics_queue_family_index, 0);
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ class Context
|
|||
vk::PhysicalDeviceProperties physical_device_props;
|
||||
vk::UniqueSurfaceKHR surface;
|
||||
std::string platform_name;
|
||||
bool have_present_wait;
|
||||
|
||||
private:
|
||||
bool init_vma();
|
||||
|
|
|
@ -364,6 +364,14 @@ bool Swapchain::swap()
|
|||
.setSwapchains(swapchain_object.get())
|
||||
.setImageIndices(current_swapchain_image);
|
||||
|
||||
vk::PresentIdKHR present_id;
|
||||
if (context.have_present_wait)
|
||||
{
|
||||
presentation_id++;
|
||||
present_id.setPresentIds(presentation_id);
|
||||
present_info.setPNext(&present_id);
|
||||
}
|
||||
|
||||
vk::Result result = queue.presentKHR(present_info);
|
||||
if (result == vk::Result::eErrorOutOfDateKHR)
|
||||
{
|
||||
|
@ -430,4 +438,12 @@ vk::RenderPass &Swapchain::get_render_pass()
|
|||
return render_pass.get();
|
||||
}
|
||||
|
||||
void Swapchain::present_wait()
|
||||
{
|
||||
if (context.have_present_wait && context.platform_name != "wayland")
|
||||
{
|
||||
device.waitForPresentKHR(swapchain_object.get(), presentation_id, 16666666);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
||||
|
|
|
@ -29,6 +29,7 @@ class Swapchain
|
|||
bool end_frame();
|
||||
void end_frame_without_swap();
|
||||
bool swap();
|
||||
void present_wait();
|
||||
void set_vsync(bool on);
|
||||
void on_render_pass_end(std::function<void()> function);
|
||||
int get_num_frames() { return num_swapchain_images; }
|
||||
|
|
|
@ -238,7 +238,10 @@ void S9xVulkanDisplayDriver::update(uint16_t *buffer, int width, int height, int
|
|||
context->swapchain->swap();
|
||||
|
||||
if (gui_config->reduce_input_lag)
|
||||
{
|
||||
context->wait_idle();
|
||||
context->swapchain->present_wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,6 +226,7 @@ void EmuCanvasVulkan::draw()
|
|||
if (config->reduce_input_lag)
|
||||
{
|
||||
context->wait_idle();
|
||||
context->swapchain->present_wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue