[GPU] Double-buffer readback_resolve.

Introduce "fast" readback resolve that reads from previous frame's
resolve buffers, quick swap between buffers each frame to avoid
copies so minimal performance impact and mostly correct bahavior.
Checks if previous frame had a buffer for the current resolve and
falls through to the slow path, which also allows to support
"screenshot" features in the games that do that without stalling
on normal resolve operations.

Re-enabled readback_memexport as separate feature, was previously
bundled with readback_resolve (probably not intentionally) and
ensures destination address is writeable to avoid memory access
related crashes and unnecessary work.

readback_resolve cvar changes from bool to string ternary with
"none", "fast" and "full" options, defaulting to the new "fast"
mode.
This commit is contained in:
Herman S.
2025-10-31 21:20:37 +09:00
committed by Radosław Gliński
parent 93adb2bb95
commit e2c33686cc
8 changed files with 482 additions and 124 deletions

View File

@@ -50,7 +50,7 @@ DECLARE_bool(guide_button);
DECLARE_bool(clear_memory_page_state);
DECLARE_bool(readback_resolve);
DECLARE_string(readback_resolve);
DECLARE_bool(readback_memexport);
@@ -1832,10 +1832,10 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
xe::threading::Sleep(delay);
break;
case ButtonFunctions::ReadbackResolve:
ToggleGPUSetting(GPUSetting::ReadbackResolve);
CycleReadbackResolve();
notificationTitle = "Toggle Readback Resolve";
notificationDesc = cvars::readback_resolve ? "Enabled" : "Disabled";
notificationTitle = "Readback Resolve Mode";
notificationDesc = cvars::readback_resolve;
// Extra Sleep
xe::threading::Sleep(delay);
@@ -2019,15 +2019,23 @@ void EmulatorWindow::ToggleGPUSetting(gpu::GPUSetting setting) {
SaveGPUSetting(GPUSetting::ClearMemoryPageState,
!cvars::clear_memory_page_state);
break;
case GPUSetting::ReadbackResolve:
SaveGPUSetting(GPUSetting::ReadbackResolve, !cvars::readback_resolve);
break;
case GPUSetting::ReadbackMemexport:
SaveGPUSetting(GPUSetting::ReadbackMemexport, !cvars::readback_memexport);
break;
}
}
void EmulatorWindow::CycleReadbackResolve() {
const std::string& current = cvars::readback_resolve;
if (current == "fast") {
gpu::SetReadbackResolveMode("full");
} else if (current == "full") {
gpu::SetReadbackResolveMode("none");
} else {
gpu::SetReadbackResolveMode("fast");
}
}
void EmulatorWindow::DisplayHotKeysConfig() {
std::string msg = "";
std::string msg_passthru = "";
@@ -2066,8 +2074,7 @@ void EmulatorWindow::DisplayHotKeysConfig() {
msg.insert(0, msg_passthru);
msg += "\n";
msg += "Readback Resolve: " +
xe::string_util::BoolToString(cvars::readback_resolve);
msg += "Readback Resolve: " + cvars::readback_resolve;
msg += "\n";
msg += "Clear Memory Page State: " +

View File

@@ -280,6 +280,7 @@ class EmulatorWindow {
bool vibrate = true);
void GamepadHotKeys();
void ToggleGPUSetting(gpu::GPUSetting setting);
void CycleReadbackResolve();
void DisplayHotKeysConfig();
static std::string CanonicalizeFileExtension(