diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index ce536e29b6..420289468a 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -121,10 +121,19 @@ void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u3 void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { const u32 method = method_call.method; + u32 argument = method_call.argument; + if (method >= 0x60 && method < MacroRegistersStart) { + if (regs.shadow_ram_control == Regs::ShadowRamControl::Replay) { + argument = shadow_regs.reg_array[method]; + } else if (regs.shadow_ram_control == Regs::ShadowRamControl::Track || + regs.shadow_ram_control == Regs::ShadowRamControl::TrackWithFilter) { + shadow_regs.reg_array[method] = argument; + } + } if (method == cb_data_state.current) { - regs.reg_array[method] = method_call.argument; - ProcessCBData(method_call.argument); + regs.reg_array[method] = argument; + ProcessCBData(argument); return; } else if (cb_data_state.current != null_cb_data) { FinishCBData(); @@ -147,7 +156,7 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { executing_macro = method; } - macro_params.push_back(method_call.argument); + macro_params.push_back(argument); // Call the macro when there are no more parameters in the command buffer if (method_call.IsLastCall()) { @@ -160,8 +169,8 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { ASSERT_MSG(method < Regs::NUM_REGS, "Invalid Maxwell3D register, increase the size of the Regs structure"); - if (regs.reg_array[method] != method_call.argument) { - regs.reg_array[method] = method_call.argument; + if (regs.reg_array[method] != argument) { + regs.reg_array[method] = argument; for (const auto& table : dirty.tables) { dirty.flags[table[method]] = true; @@ -170,11 +179,11 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { switch (method) { case MAXWELL3D_REG_INDEX(macros.data): { - ProcessMacroUpload(method_call.argument); + ProcessMacroUpload(argument); break; } case MAXWELL3D_REG_INDEX(macros.bind): { - ProcessMacroBind(method_call.argument); + ProcessMacroBind(argument); break; } case MAXWELL3D_REG_INDEX(firmware[4]): { @@ -250,7 +259,7 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { } case MAXWELL3D_REG_INDEX(data_upload): { const bool is_last_call = method_call.IsLastCall(); - upload_state.ProcessData(method_call.argument, is_last_call); + upload_state.ProcessData(argument, is_last_call); if (is_last_call) { OnMemoryWrite(); } diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 8a9e9992e1..fa34484207 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -531,6 +531,13 @@ public: Fill = 0x1b02, }; + enum class ShadowRamControl : u32 { + Track = 0, + TrackWithFilter = 1, + Passthrough = 2, + Replay = 3, + }; + struct RenderTargetConfig { u32 address_high; u32 address_low; @@ -674,7 +681,9 @@ public: u32 bind; } macros; - INSERT_UNION_PADDING_WORDS(0x17); + ShadowRamControl shadow_ram_control; + + INSERT_UNION_PADDING_WORDS(0x16); Upload::Registers upload; struct { @@ -1263,7 +1272,10 @@ public: }; std::array reg_array; }; - } regs{}; + }; + + Regs regs{}; + Regs shadow_regs{}; static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size"); static_assert(std::is_trivially_copyable_v, "Maxwell3D Regs must be trivially copyable"); @@ -1458,6 +1470,7 @@ private: "Field " #field_name " has invalid position") ASSERT_REG_POSITION(macros, 0x45); +ASSERT_REG_POSITION(shadow_ram_control, 0x49); ASSERT_REG_POSITION(upload, 0x60); ASSERT_REG_POSITION(exec_upload, 0x6C); ASSERT_REG_POSITION(data_upload, 0x6D);