aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/engines
diff options
context:
space:
mode:
authorJonas <104419015+jojo-chaechae@users.noreply.github.com>2026-11-03 04:36:01 +0600
committerGitHub <noreply@github.com>2026-11-03 04:36:01 +0600
commit8362c44ff835d7be73d2adad9ce3e2d4467a6aeb (patch)
treec1eb12a54510bbeaed67a8a524b5ce9e8576cfcd /src/video_core/engines
parent155bf34fc297b6b8e4c281ecf7ea5d9ce3140762 (diff)
parentfe3c344573140b7864c9a86f204eb9c0dce0d548 (diff)
Merge pull request #334 from snowstormxd/codex/upstream-mkw-test
MKW performance improvements
Diffstat (limited to 'src/video_core/engines')
-rw-r--r--src/video_core/engines/draw_manager.cpp3
-rw-r--r--src/video_core/engines/maxwell_3d.cpp13
-rw-r--r--src/video_core/engines/maxwell_3d.h11
3 files changed, 22 insertions, 5 deletions
diff --git a/src/video_core/engines/draw_manager.cpp b/src/video_core/engines/draw_manager.cpp
index 974a9a6e9a..564220b71c 100644
--- a/src/video_core/engines/draw_manager.cpp
+++ b/src/video_core/engines/draw_manager.cpp
@@ -313,6 +313,8 @@ void Maxwell3D::DrawManager::UpdateTopology(Maxwell3D& maxwell3d) {
}
void Maxwell3D::DrawManager::ProcessDraw(Maxwell3D& maxwell3d, bool draw_indexed, u32 instance_count) {
+ draw_state.draw_element_count =
+ draw_indexed ? draw_state.index_buffer.count : draw_state.vertex_buffer.count;
LOG_TRACE(HW_GPU, "called, topology={}, count={}", draw_state.topology, draw_indexed ? draw_state.index_buffer.count : draw_state.vertex_buffer.count);
UpdateTopology(maxwell3d);
if (maxwell3d.ShouldExecute()) {
@@ -321,6 +323,7 @@ void Maxwell3D::DrawManager::ProcessDraw(Maxwell3D& maxwell3d, bool draw_indexed
}
void Maxwell3D::DrawManager::ProcessDrawIndirect(Maxwell3D& maxwell3d) {
+ draw_state.draw_element_count = 0;
LOG_TRACE(HW_GPU, "called, topology={}, is_indexed={}, includes_count={}, buffer_size={}, max_draw_count={}", draw_state.topology, indirect_state.is_indexed, indirect_state.include_count, indirect_state.buffer_size, indirect_state.max_draw_counts);
UpdateTopology(maxwell3d);
if (maxwell3d.ShouldExecute()) {
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 4ef7d42979..92313988bd 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -518,6 +518,10 @@ void Maxwell3D::DumpRecentWrites(u32 method) {
}
LOG_ERROR(HW_GPU, "Write to {:#x} while macro {:#x} collects parameters ({} so far); last writes:",
method, executing_macro, macro_params.size());
+ if (!record_write_history) {
+ LOG_ERROR(HW_GPU, "Register write history disabled; EDEN_NX2_3D_HISTORY=1 enables it");
+ return;
+ }
for (size_t i = 0; i < recent_writes.size(); ++i) {
const auto& w = recent_writes[(recent_write_index + i) % recent_writes.size()];
if (w.amount != 0) {
@@ -818,7 +822,6 @@ struct Maxwell3D::FrontState {
Regs::ShadowRamControl control{};
u32 executing_macro{};
std::vector<u32> parameters;
- std::vector<u32> fifo;
u64 calls{};
/// A method the draw manager handles was sent since the back last ran DrawDeferred: only
/// then can it have a deferred instanced draw to issue at the end of a macro.
@@ -1095,9 +1098,9 @@ void Maxwell3D::FrontRunMacro(Core::System& system, VideoCommon::GpuSplit& split
engine.native_jit = std::make_shared<TuringMacroJit>();
}
engine.native_jit->Prepare(engine.native_code, engine.native_code_generation);
- fs.fifo.assign(fs.parameters.begin(), fs.parameters.end());
+ const size_t parameter_count = fs.parameters.size();
const auto result = engine.native_jit->Execute(
- start, fs.fifo, std::span<u32>{native_data_ram},
+ start, fs.parameters, std::span<u32>{native_data_ram},
[&fs](u32 address) { return address < Regs::NUM_REGS ? fs.regs[address] : 0U; },
[&](u32 address, u32 value) {
if (address >= MacroRegistersStart) {
@@ -1113,7 +1116,7 @@ void Maxwell3D::FrontRunMacro(Core::System& system, VideoCommon::GpuSplit& split
if (!result.success) {
engine.native_execution_failed = true;
LOG_ERROR(HW_GPU, "Native MME (JIT, split front) failed: start={:#x}, consumed={}/{}, error={}",
- start, result.consumed, fs.parameters.size(), result.error);
+ start, result.consumed, parameter_count, result.error);
}
}
fs.parameters.clear();
@@ -1148,7 +1151,7 @@ void Maxwell3D::FrontDmaRead(VideoCommon::GpuSplit& split, FrontState& fs, u32 m
for (u32 i = 0; i < words; ++i) {
const u32 word = memory_manager.Read<u32>(source + u64{i} * sizeof(u32));
if (method == 0x158) {
- fs.fifo.push_back(word);
+ fs.parameters.push_back(word);
} else if (ram + i < native_data_ram.size()) {
native_data_ram[ram + i] = word;
}
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index c5d1eb3230..7646ddbbe3 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -3064,6 +3064,7 @@ public:
Maxwell3D::Regs::PrimitiveTopology topology{};
DrawMode draw_mode{};
bool draw_indexed{};
+ u32 draw_element_count{}; // Zero for indirect draws whose count is not known yet.
u32 base_index{};
Maxwell3D::Regs::VertexBuffer vertex_buffer;
Maxwell3D::Regs::IndexBuffer index_buffer;
@@ -3352,7 +3353,17 @@ private:
};
std::array<RecentWrite, 48> recent_writes{};
size_t recent_write_index = 0;
+ const bool record_write_history{
+#ifdef NDEBUG
+ std::getenv("EDEN_NX2_3D_HISTORY") != nullptr
+#else
+ true
+#endif
+ };
void RecordWrite(u32 method, u32 argument, u32 amount, u32 pending) {
+ if (!record_write_history) {
+ return;
+ }
recent_writes[recent_write_index++ % recent_writes.size()] = {method, argument, amount, pending};
}
void DumpRecentWrites(u32 method);