renderer_vulkan: Prefer immediate over mailbox present mode
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include "common/logging/log.h"
|
||||
#include "common/microprofile.h"
|
||||
#include "core/settings.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
|
||||
@ -112,11 +113,13 @@ void Swapchain::Create(u32 width, u32 height) {
|
||||
// Wait for maximum of 1 second
|
||||
constexpr u64 ACQUIRE_TIMEOUT = 1000000000;
|
||||
|
||||
MICROPROFILE_DEFINE(Vulkan_Acquire, "Vulkan", "Swapchain Acquire", MP_RGB(185, 66, 245));
|
||||
void Swapchain::AcquireNextImage(vk::Semaphore signal_acquired) {
|
||||
if (NeedsRecreation()) [[unlikely]] {
|
||||
return;
|
||||
}
|
||||
|
||||
MICROPROFILE_SCOPE(Vulkan_Acquire);
|
||||
vk::Device device = instance.GetDevice();
|
||||
vk::Result result = device.acquireNextImageKHR(swapchain, ACQUIRE_TIMEOUT, signal_acquired,
|
||||
VK_NULL_HANDLE, ¤t_image);
|
||||
@ -135,11 +138,13 @@ void Swapchain::AcquireNextImage(vk::Semaphore signal_acquired) {
|
||||
}
|
||||
}
|
||||
|
||||
MICROPROFILE_DEFINE(Vulkan_Present, "Vulkan", "Swapchain Present", MP_RGB(66, 185, 245));
|
||||
void Swapchain::Present(vk::Semaphore wait_for_present) {
|
||||
if (NeedsRecreation()) [[unlikely]] {
|
||||
return;
|
||||
}
|
||||
|
||||
MICROPROFILE_SCOPE(Vulkan_Present);
|
||||
const vk::PresentInfoKHR present_info = {.waitSemaphoreCount = 1,
|
||||
.pWaitSemaphores = &wait_for_present,
|
||||
.swapchainCount = 1,
|
||||
@ -185,11 +190,18 @@ void Swapchain::Configure(u32 width, u32 height) {
|
||||
// FIFO is guaranteed by the Vulkan standard to be available
|
||||
present_mode = vk::PresentModeKHR::eFifo;
|
||||
if (!Settings::values.use_vsync_new) {
|
||||
auto iter = std::ranges::find_if(
|
||||
modes, [](vk::PresentModeKHR mode) { return vk::PresentModeKHR::eMailbox == mode; });
|
||||
const auto FindMode = [&modes](vk::PresentModeKHR requested) {
|
||||
auto it =
|
||||
std::find_if(modes.begin(), modes.end(),
|
||||
[&requested](vk::PresentModeKHR mode) { return mode == requested; });
|
||||
|
||||
// Prefer Mailbox when vsync is disabled for lowest latency
|
||||
if (iter != modes.end()) {
|
||||
return it != modes.end();
|
||||
};
|
||||
|
||||
// Prefer Immediate when vsync is disabled for fastest acquire
|
||||
if (FindMode(vk::PresentModeKHR::eImmediate)) {
|
||||
present_mode = vk::PresentModeKHR::eImmediate;
|
||||
} else if (FindMode(vk::PresentModeKHR::eMailbox)) {
|
||||
present_mode = vk::PresentModeKHR::eMailbox;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/microprofile.h"
|
||||
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
||||
@ -86,12 +87,14 @@ TaskScheduler::~TaskScheduler() {
|
||||
device.destroyCommandPool(command_pool);
|
||||
}
|
||||
|
||||
MICROPROFILE_DEFINE(Vulkan_Synchronize, "Vulkan", "Scheduler Synchronize", MP_RGB(100, 52, 235));
|
||||
void TaskScheduler::Synchronize(u32 slot) {
|
||||
const auto& command = commands[slot];
|
||||
vk::Device device = instance.GetDevice();
|
||||
|
||||
const u64 completed_counter = GetFenceCounter();
|
||||
if (command.fence_counter > completed_counter) {
|
||||
MICROPROFILE_SCOPE(Vulkan_Synchronize);
|
||||
if (instance.IsTimelineSemaphoreSupported()) {
|
||||
const vk::SemaphoreWaitInfo wait_info = {
|
||||
.semaphoreCount = 1, .pSemaphores = &timeline, .pValues = &command.fence_counter};
|
||||
@ -113,6 +116,7 @@ void TaskScheduler::Synchronize(u32 slot) {
|
||||
device.resetDescriptorPool(command.descriptor_pool);
|
||||
}
|
||||
|
||||
MICROPROFILE_DEFINE(Vulkan_Submit, "Vulkan", "Scheduler Queue Submit", MP_RGB(66, 245, 170));
|
||||
void TaskScheduler::Submit(SubmitMode mode) {
|
||||
if (False(mode & SubmitMode::Shutdown)) {
|
||||
renderer.FlushBuffers();
|
||||
@ -134,6 +138,8 @@ void TaskScheduler::Submit(SubmitMode mode) {
|
||||
command_buffers[command_buffer_count++] = command.render_command_buffer;
|
||||
|
||||
const auto QueueSubmit = [this](const vk::SubmitInfo& info, vk::Fence fence) {
|
||||
MICROPROFILE_SCOPE(Vulkan_Submit);
|
||||
|
||||
try {
|
||||
vk::Queue queue = instance.GetGraphicsQueue();
|
||||
queue.submit(info, fence);
|
||||
|
Reference in New Issue
Block a user