summaryrefslogtreecommitdiff
path: root/src/video_core/engines
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2022-11-09 17:58:10 +0100
committerGravatar Fernando Sahmkow2023-01-01 16:43:57 -0500
commitaad0cbf024fb8077a9b375a093c60a7e2ab1db3d (patch)
tree8c6a86c92ed8cedbafb5f34dd9f72283eaaf4342 /src/video_core/engines
parentMacroHLE: Add Index Buffer size estimation. (diff)
downloadyuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.tar.gz
yuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.tar.xz
yuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.zip
MacroHLE: Add HLE replacement for base vertex and base instance.
Diffstat (limited to 'src/video_core/engines')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp15
-rw-r--r--src/video_core/engines/maxwell_3d.h17
2 files changed, 30 insertions, 2 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index a0dd7400d..50d8a94b1 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -182,8 +182,14 @@ u32 Maxwell3D::GetMaxCurrentVertices() {
182size_t Maxwell3D::EstimateIndexBufferSize() { 182size_t Maxwell3D::EstimateIndexBufferSize() {
183 GPUVAddr start_address = regs.index_buffer.StartAddress(); 183 GPUVAddr start_address = regs.index_buffer.StartAddress();
184 GPUVAddr end_address = regs.index_buffer.EndAddress(); 184 GPUVAddr end_address = regs.index_buffer.EndAddress();
185 return std::min<size_t>(memory_manager.GetMemoryLayoutSize(start_address), 185 constexpr std::array<size_t, 4> max_sizes = {
186 static_cast<size_t>(end_address - start_address)); 186 std::numeric_limits<u8>::max(), std::numeric_limits<u16>::max(),
187 std::numeric_limits<u32>::max(), std::numeric_limits<u32>::max()};
188 const size_t byte_size = regs.index_buffer.FormatSizeInBytes();
189 return std::min<size_t>(
190 memory_manager.GetMemoryLayoutSize(start_address, byte_size * max_sizes[byte_size]) /
191 byte_size,
192 static_cast<size_t>(end_address - start_address));
187} 193}
188 194
189u32 Maxwell3D::ProcessShadowRam(u32 method, u32 argument) { 195u32 Maxwell3D::ProcessShadowRam(u32 method, u32 argument) {
@@ -572,4 +578,9 @@ u32 Maxwell3D::GetRegisterValue(u32 method) const {
572 return regs.reg_array[method]; 578 return regs.reg_array[method];
573} 579}
574 580
581void Maxwell3D::setHLEReplacementName(u32 bank, u32 offset, HLEReplaceName name) {
582 const u64 key = (static_cast<u64>(bank) << 32) | offset;
583 replace_table.emplace(key, name);
584}
585
575} // namespace Tegra::Engines 586} // namespace Tegra::Engines
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index cfe1e4883..397e88f67 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -3020,6 +3020,23 @@ public:
3020 /// Store temporary hw register values, used by some calls to restore state after a operation 3020 /// Store temporary hw register values, used by some calls to restore state after a operation
3021 Regs shadow_state; 3021 Regs shadow_state;
3022 3022
3023 // None Engine
3024 enum class EngineHint : u32 {
3025 None = 0x0,
3026 OnHLEMacro = 0x1,
3027 };
3028
3029 EngineHint engine_state{EngineHint::None};
3030
3031 enum class HLEReplaceName : u32 {
3032 BaseVertex = 0x0,
3033 BaseInstance = 0x1,
3034 };
3035
3036 void setHLEReplacementName(u32 bank, u32 offset, HLEReplaceName name);
3037
3038 std::unordered_map<u64, HLEReplaceName> replace_table;
3039
3023 static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size"); 3040 static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size");
3024 static_assert(std::is_trivially_copyable_v<Regs>, "Maxwell3D Regs must be trivially copyable"); 3041 static_assert(std::is_trivially_copyable_v<Regs>, "Maxwell3D Regs must be trivially copyable");
3025 3042