Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Commit 2e84e58

Browse files
committed
Option to disable v-sync via r_swapInterval (swapchain present mode selection)
1 parent 4067087 commit 2e84e58

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

neo/renderer/Vulkan/RenderBackend_VK.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern idCVar r_forceZPassStencilShadows;
5858
extern idCVar r_useStencilShadowPreload;
5959
extern idCVar r_singleTriangle;
6060
extern idCVar r_useLightDepthBounds;
61+
extern idCVar r_swapInterval;
6162

6263
void PrintState( uint64 stateBits, uint64 * stencilBits );
6364

@@ -682,10 +683,21 @@ ChoosePresentMode
682683
=============
683684
*/
684685
VkPresentModeKHR ChoosePresentMode( idList< VkPresentModeKHR > & modes ) {
685-
const VkPresentModeKHR desiredMode = VK_PRESENT_MODE_MAILBOX_KHR;
686+
VkPresentModeKHR desiredMode = VK_PRESENT_MODE_FIFO_KHR;
686687

687-
for ( int i = 0; i < modes.Num(); ++i ) {
688-
if ( modes[ i ] == desiredMode ) {
688+
if (r_swapInterval.GetInteger() < 1) {
689+
for (int i = 0; i < modes.Num(); i++) {
690+
if (modes[i] == VK_PRESENT_MODE_MAILBOX_KHR) {
691+
return VK_PRESENT_MODE_MAILBOX_KHR;
692+
}
693+
if ((modes[i] != VK_PRESENT_MODE_MAILBOX_KHR) && (modes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR)) {
694+
return VK_PRESENT_MODE_IMMEDIATE_KHR;
695+
}
696+
}
697+
}
698+
699+
for (int i = 0; i < modes.Num(); ++i) {
700+
if (modes[i] == desiredMode) {
689701
return desiredMode;
690702
}
691703
}

0 commit comments

Comments
 (0)