[GPU] Unified clear_memory_page_state to be used in D3D12 & Vulkan

This commit is contained in:
Gliniak 2023-08-02 22:37:11 +02:00 committed by Radosław Gliński
parent 91f976e524
commit 2a4d7feaae
6 changed files with 35 additions and 15 deletions

View File

@ -52,9 +52,9 @@ DECLARE_string(hid);
DECLARE_bool(guide_button);
DECLARE_bool(d3d12_readback_resolve);
DECLARE_bool(clear_memory_page_state);
DECLARE_bool(d3d12_clear_memory_page_state);
DECLARE_bool(d3d12_readback_resolve);
DEFINE_bool(fullscreen, false, "Whether to launch the emulator in fullscreen.",
"Display");
@ -1265,7 +1265,7 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
ToggleGPUSetting(gpu_cvar::ClearMemoryPageState);
// Assume the user wants ClearCaches as well
if (cvars::d3d12_clear_memory_page_state) {
if (cvars::clear_memory_page_state) {
GpuClearCaches();
}
@ -1407,8 +1407,8 @@ void EmulatorWindow::GamepadHotKeys() {
void EmulatorWindow::ToggleGPUSetting(gpu_cvar value) {
switch (value) {
case gpu_cvar::ClearMemoryPageState:
D3D12SaveGPUSetting(D3D12GPUSetting::ClearMemoryPageState,
!cvars::d3d12_clear_memory_page_state);
CommonSaveGPUSetting(CommonGPUSetting::ClearMemoryPageState,
!cvars::clear_memory_page_state);
break;
case gpu_cvar::ReadbackResolve:
D3D12SaveGPUSetting(D3D12GPUSetting::ReadbackResolve,
@ -1479,7 +1479,7 @@ void EmulatorWindow::DisplayHotKeysConfig() {
msg += "\n";
msg += "Clear Memory Page State: " +
xe::string_util::BoolToString(cvars::d3d12_clear_memory_page_state);
xe::string_util::BoolToString(cvars::clear_memory_page_state);
msg += "\n";
msg += "Controller Hotkeys: " +

View File

@ -45,9 +45,22 @@ DEFINE_bool(
"of the guest thread that wrote the new read position.",
"GPU");
DEFINE_bool(clear_memory_page_state, false,
"Refresh state of memory pages to enable gpu written data. (Use "
"for 'Team Ninja' Games to fix missing character models)",
"GPU");
namespace xe {
namespace gpu {
void CommonSaveGPUSetting(CommonGPUSetting setting, uint64_t value) {
switch (setting) {
case CommonGPUSetting::ClearMemoryPageState:
OVERRIDE_bool(clear_memory_page_state, (bool)value);
break;
}
}
using namespace xe::gpu::xenos;
CommandProcessor::CommandProcessor(GraphicsSystem* graphics_system,

View File

@ -33,6 +33,12 @@ class ByteStream;
namespace gpu {
enum class CommonGPUSetting {
ClearMemoryPageState,
};
void CommonSaveGPUSetting(CommonGPUSetting setting, uint64_t value);
class GraphicsSystem;
class Shader;

View File

@ -49,19 +49,14 @@ DEFINE_bool(d3d12_submit_on_primary_buffer_end, true,
"Submit the command list when a PM4 primary buffer ends if it's "
"possible to submit immediately to try to reduce frame latency.",
"D3D12");
DEFINE_bool(d3d12_clear_memory_page_state, false,
"Refresh state of memory pages to enable gpu written data. (Use "
"for 'Team Ninja' Games to fix missing character models)",
"D3D12");
DECLARE_bool(clear_memory_page_state);
namespace xe {
namespace gpu {
void D3D12SaveGPUSetting(D3D12GPUSetting setting, uint64_t value) {
switch (setting) {
case D3D12GPUSetting::ClearMemoryPageState:
OVERRIDE_bool(d3d12_clear_memory_page_state, (bool)value);
break;
case D3D12GPUSetting::ReadbackResolve:
OVERRIDE_bool(d3d12_readback_resolve, (bool)value);
break;
@ -3564,7 +3559,7 @@ bool D3D12CommandProcessor::EndSubmission(bool is_swap) {
}
if (is_closing_frame) {
if (cvars::d3d12_clear_memory_page_state) {
if (cvars::clear_memory_page_state) {
shared_memory_->SetSystemPageBlocksValidWithGpuDataWritten();
}
// Close the capture after submitting.

View File

@ -45,7 +45,6 @@ namespace gpu {
enum class D3D12GPUSetting {
ReadbackResolve,
ClearMemoryPageState,
};
void D3D12SaveGPUSetting(D3D12GPUSetting setting, uint64_t value);

View File

@ -38,6 +38,9 @@
#include "xenia/ui/vulkan/vulkan_presenter.h"
#include "xenia/ui/vulkan/vulkan_provider.h"
#include "xenia/ui/vulkan/vulkan_util.h"
DECLARE_bool(clear_memory_page_state);
namespace xe {
namespace gpu {
namespace vulkan {
@ -3125,6 +3128,10 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {
}
if (is_closing_frame) {
if (cvars::clear_memory_page_state) {
shared_memory_->SetSystemPageBlocksValidWithGpuDataWritten();
}
frame_open_ = false;
// Submission already closed now, so minus 1.
closed_frame_submissions_[(frame_current_++) % kMaxFramesInFlight] =