Skip to content

Commit

Permalink
Reverb issue: try to get away with only flushing
Browse files Browse the repository at this point in the history
  • Loading branch information
Detegr committed Jan 14, 2024
1 parent 69d1053 commit f7d6c10
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 64 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ set(HEADERS
set(openRBRVR_Major 0)
set(openRBRVR_Minor 5)
set(openRBRVR_Patch 0)
set(openRBRVR_Tweak 9)
set(openRBRVR_Tweak 11)
set(openRBRVR_TweakStr "-rc${openRBRVR_Tweak}")

configure_file(
Expand Down
25 changes: 6 additions & 19 deletions Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ enum VRRuntime {
OPENXR
};

enum WaitGPU {
NOWAIT,
EARLY,
MID,
LATE,
};

static float floatOrDefault(const std::string& value, float def)
{
try {
Expand Down Expand Up @@ -65,8 +58,7 @@ struct Config {
bool renderReplays3d;
D3DMULTISAMPLE_TYPE msaa;
int anisotropy;
WaitGPU waitGpuIdle;
bool waitGpuIdleFlush;
bool wmrWorkaround;
VRRuntime runtime;

auto operator<=>(const Config&) const = default;
Expand All @@ -88,8 +80,7 @@ struct Config {
"renderPauseMenu3d = {}\n"
"renderPreStage3d = {}\n"
"renderReplays3d = {}\n"
"waitGpuIdle = {}\n"
"waitGpuIdleFlush = {}\n"
"wmrWorkaround = {}\n"
"runtime = {}",
superSampling,
menuSize,
Expand All @@ -105,8 +96,7 @@ struct Config {
renderPauseMenu3d,
renderPreStage3d,
renderReplays3d,
static_cast<int>(waitGpuIdle),
waitGpuIdleFlush,
wmrWorkaround,
runtime == OPENVR ? "steamvr" : "openxr");
}

Expand Down Expand Up @@ -138,8 +128,7 @@ struct Config {
.renderReplays3d = false,
.msaa = D3DMULTISAMPLE_NONE,
.anisotropy = -1,
.waitGpuIdle = NOWAIT,
.waitGpuIdleFlush = false,
.wmrWorkaround = false,
.runtime = OPENVR,
};

Expand Down Expand Up @@ -200,10 +189,8 @@ struct Config {
cfg.renderPreStage3d = (value == "true");
} else if (key == "renderReplays3d") {
cfg.renderReplays3d = (value == "true");
} else if (key == "waitGpuIdle") {
cfg.waitGpuIdle = static_cast<WaitGPU>(intOrDefault(value, 0));
} else if (key == "waitGpuIdleFlush") {
cfg.waitGpuIdleFlush = (value == "true");
} else if (key == "wmrWorkaround") {
cfg.wmrWorkaround = (value == "true");
} else if (key == "runtime") {
cfg.runtime = value == "openxr" ? OPENXR : OPENVR;
}
Expand Down
39 changes: 5 additions & 34 deletions Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,6 @@ static void ChangeHorizonLock(bool forward)
}
}

static std::string GetGpuIdleStr(WaitGPU w)
{
switch (w) {
case NOWAIT: return "OFF";
case EARLY: return "Early";
case MID: return "Mid";
case LATE: return "Late";
default: std::unreachable();
}
}

static void ChangeGpuWait(bool forward)
{
switch (gCfg.waitGpuIdle) {
case NOWAIT: gCfg.waitGpuIdle = forward ? EARLY : LATE; break;
case EARLY: gCfg.waitGpuIdle = forward ? MID : NOWAIT; break;
case MID: gCfg.waitGpuIdle = forward ? LATE : EARLY; break;
case LATE: gCfg.waitGpuIdle = forward ? NOWAIT : MID; break;
default: std::unreachable();
}
}

static void ChangeRenderIn3dSettings(bool forward)
{
if (forward && gCfg.renderMainMenu3d) {
Expand Down Expand Up @@ -204,19 +182,12 @@ static Menu debugMenu = { "openRBRVR debug settings", {
.rightAction = [] { Toggle(gCfg.debug); },
.selectAction = [] { Toggle(gCfg.debug); },
},
{ .text = [] { return std::format("Wait GPU to be idle before submit: {}", GetGpuIdleStr(gCfg.waitGpuIdle)); },
.longText = { "Waits that the GPU is idle before submitting frames to it.", "If OpenXR mode does not start up, try enabling this option.", "Try early first and move on to later ones if the previous one seems to work." },
.menuColor = IRBRGame::EMenuColors::MENU_TEXT,
.leftAction = [] { ChangeGpuWait(false); },
.rightAction = [] { ChangeGpuWait(true); },
.selectAction = [] { ChangeGpuWait(true); },
},
{ .text = [] { return std::format("Flush GPU before waiting for it to be idle: {}", gCfg.waitGpuIdleFlush ? "ON" : "OFF"); },
.longText = { "Used with the Wait Gpu to be idle option. Without it this does nothing.", "Try OFF first, toggle to ON if OFF does not work." },
{ .text = [] { return std::format("OpenXR Reverb compatibility mode: {}", gCfg.wmrWorkaround ? "ON" : "OFF"); },
.longText = { "A workaround making OpenXR mode work with WMR OpenXR runtime.", "This has an performance impact, should be set to off if OpenXR runtime works without this option.", "Has no effect in SteamVR." },
.menuColor = IRBRGame::EMenuColors::MENU_TEXT,
.leftAction = [] { Toggle(gCfg.waitGpuIdleFlush); },
.rightAction = [] { Toggle(gCfg.waitGpuIdleFlush); },
.selectAction = [] { Toggle(gCfg.waitGpuIdleFlush); },
.leftAction = [] { Toggle(gCfg.wmrWorkaround); },
.rightAction = [] { Toggle(gCfg.wmrWorkaround); },
.selectAction = [] { Toggle(gCfg.wmrWorkaround); },
},
{ .text = id("Back to previous menu"),
.selectAction = [] { SelectMenu(0); }
Expand Down
12 changes: 2 additions & 10 deletions OpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ void OpenXR::PrepareFramesForHMD(IDirect3DDevice9* dev)
// and in DXVK there is no way to create a texture that would use this swapchain image.
// Also, if we're using anti-aliasing, this step is needed anyways.

if (gCfg.waitGpuIdle == EARLY) {
gD3DVR->WaitDeviceIdle(gCfg.waitGpuIdleFlush);
if (gCfg.wmrWorkaround) {
gD3DVR->Flush();
}

gD3DVR->CopySurfaceToVulkanImage(
Expand All @@ -453,10 +453,6 @@ void OpenXR::PrepareFramesForHMD(IDirect3DDevice9* dev)
renderWidth[RightEye],
renderHeight[RightEye]);

if (gCfg.waitGpuIdle == MID) {
gD3DVR->WaitDeviceIdle(gCfg.waitGpuIdleFlush);
}

xrReleaseSwapchainImage(swapchains[LeftEye], &releaseInfo);
xrReleaseSwapchainImage(swapchains[RightEye], &releaseInfo);

Expand Down Expand Up @@ -494,10 +490,6 @@ void OpenXR::SubmitFramesToHMD(IDirect3DDevice9* dev)
.layers = layers,
};

if (gCfg.waitGpuIdle == LATE) {
gD3DVR->WaitDeviceIdle(gCfg.waitGpuIdleFlush);
}

gD3DVR->BeginVRSubmit();
if (auto res = xrEndFrame(session, &frameEndInfo); res != XR_SUCCESS) {
Dbg(std::format("xrEndFrame failed: {}", XrResultToString(instance, res)));
Expand Down

0 comments on commit f7d6c10

Please sign in to comment.