vulkan: Remove waiting extensions.

I guess these aren't widely supported.
This commit is contained in:
BearOso 2024-09-05 18:09:11 -05:00
parent 15ae9de25b
commit 645a4712e7
5 changed files with 9 additions and 79 deletions

View File

@ -245,26 +245,6 @@ bool Context::init_device(int preferred_device)
}
}
std::vector<const char *> present_wait_extensions =
{
VK_KHR_PRESENT_ID_EXTENSION_NAME,
VK_KHR_PRESENT_WAIT_EXTENSION_NAME
};
if (check_extensions(present_wait_extensions, physical_device))
{
for (auto &ext : present_wait_extensions)
required_extensions.push_back(ext);
supports_VK_KHR_present_wait = true;
}
else
{
supports_VK_KHR_present_wait = false;
}
auto extension_properties = physical_device.enumerateDeviceExtensionProperties().value;
physical_device.getProperties(&physical_device_props);
graphics_queue_family_index = find_graphics_queue(physical_device);
if (graphics_queue_family_index == UINT32_MAX)
return false;
@ -273,14 +253,6 @@ bool Context::init_device(int preferred_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 (supports_VK_KHR_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);

View File

@ -51,8 +51,6 @@ class Context
vk::PhysicalDeviceProperties physical_device_props;
vk::UniqueSurfaceKHR surface;
bool supports_VK_KHR_present_wait = false;
private:
bool init_vma();
bool init_device(int preferred_device = 0);

View File

@ -22,7 +22,12 @@ Swapchain::~Swapchain()
void Swapchain::set_vsync(bool new_setting)
{
vsync = new_setting;
if (vsync != new_setting)
{
vsync = new_setting;
if (swapchain_object)
recreate();
}
}
void Swapchain::on_render_pass_end(std::function<void ()> function)
@ -80,7 +85,6 @@ bool Swapchain::recreate(int new_width, int new_height)
if (swapchain_object)
{
device.waitIdle();
wait_on_frames();
}
return create(num_swapchain_images, new_width, new_height);
@ -269,8 +273,6 @@ bool Swapchain::create_resources()
.setLayers(1)
.setRenderPass(render_pass.get());
image.framebuffer = device.createFramebufferUnique(framebuffer_create_info).value;
image.fence = device.createFenceUnique(fence_create_info).value;
}
current_swapchain_image = 0;
@ -350,25 +352,6 @@ bool Swapchain::swap()
.setSwapchains(swapchain_object.get())
.setImageIndices(current_swapchain_image);
vk::SwapchainPresentModeInfoEXT present_mode_info;
auto present_mode = get_present_mode();
present_mode_info.setPresentModes(present_mode);
auto &present_fence = image_data[current_swapchain_image].fence.get();
device.resetFences(present_fence);
vk::SwapchainPresentFenceInfoEXT present_fence_info(present_fence);
present_info.setPNext(&present_mode_info);
present_mode_info.setPNext(&present_fence_info);
vk::PresentIdKHR present_id;
if (context.supports_VK_KHR_present_wait)
{
presentation_id++;
present_id.setPresentIds(presentation_id);
present_fence_info.setPNext(&present_id);
}
vk::Result result = queue.presentKHR(present_info);
if (result == vk::Result::eErrorOutOfDateKHR)
{
@ -425,27 +408,6 @@ void Swapchain::end_render_pass()
get_cmd().endRenderPass();
}
bool Swapchain::wait_on_frame(int frame_num)
{
auto result = device.waitForFences({ image_data[frame_num].fence.get() }, true, 33000000);
return (result == vk::Result::eSuccess);
}
void Swapchain::wait_on_frames()
{
for (auto i = 0; i < image_data.size(); i++)
wait_on_frame(i);
if (context.supports_VK_KHR_present_wait)
{
auto result = device.waitForPresentKHR(swapchain_object.get(), presentation_id, 16666666);
if (result != vk::Result::eSuccess)
{
printf("Error waiting on present: %s\n", vk::to_string(result).c_str());
}
}
}
vk::Extent2D Swapchain::get_extents()
{
return extents;

View File

@ -20,11 +20,9 @@ class Swapchain
bool begin_frame();
void begin_render_pass();
void end_render_pass();
bool wait_on_frame(int frame_num);
bool end_frame();
void end_frame_without_swap();
bool swap();
void wait_on_frames();
void set_vsync(bool on);
void on_render_pass_end(std::function<void()> function);
int get_num_frames() { return num_swapchain_images; }
@ -51,7 +49,6 @@ class Swapchain
struct ImageData
{
vk::Image image;
vk::UniqueFence fence;
vk::UniqueImageView image_view;
vk::UniqueFramebuffer framebuffer;
};

View File

@ -179,6 +179,8 @@ void EmuCanvasVulkan::draw()
if (!window->isVisible())
return;
context->swapchain->set_vsync(config->enable_vsync);
if (S9xImGuiDraw(width() * devicePixelRatioF(), height() * devicePixelRatioF()))
{
auto draw_data = ImGui::GetDrawData();
@ -203,11 +205,10 @@ void EmuCanvasVulkan::draw()
if (retval)
{
throttle();
context->swapchain->set_vsync(config->enable_vsync);
context->swapchain->swap();
if (config->reduce_input_lag)
{
context->swapchain->wait_on_frames();
context->wait_idle();
}
}
}