diff options
| author | Takoroka <137927095+Takoroka@users.noreply.github.com> | 2026-10-28 07:47:45 -0400 |
|---|---|---|
| committer | Takoroka <137927095+Takoroka@users.noreply.github.com> | 2026-10-28 07:47:45 -0400 |
| commit | 32d876ded1aefc52f839d65570e3e3c43ec04415 (patch) | |
| tree | 9030b5090a857d943b5b0341c499af7184abb192 /src/video_core | |
| parent | 598bb7750c71ea1378724ddfe9418f27330fa279 (diff) | |
nx2: read debug switches once; key scripts from a file
Several debug switches were read with std::getenv on every macro call, QMD,
semaphore write or draw. The UCRT getenv locks and scans the environment,
thousands of times a frame; a long EDEN_NX2_KEY_SCRIPT made title 4 crawl
at 2 fps. Each is now read once. EDEN_NX2_KEY_SCRIPT=@<file> reads the
script from a file. gdbrsp.py gains 'hits' (log registers, frame chain and
object words at breakpoints, following the stopped thread).
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/engines/kepler_compute.cpp | 11 | ||||
| -rw-r--r-- | src/video_core/macro.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/native_query_trace.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 8 |
4 files changed, 19 insertions, 9 deletions
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp index dc3f9b25b6..4954fe613a 100644 --- a/src/video_core/engines/kepler_compute.cpp +++ b/src/video_core/engines/kepler_compute.cpp @@ -134,7 +134,8 @@ bool KeplerCompute::ProcessNativeMethod(Core::System& system, u32 method, u32 ar }); if (!result.success) { native_macro->native_execution_failed = true; - if (std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS")) { + if (static const bool diagnostics = std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS") != nullptr; + diagnostics) { std::ofstream dump("native-compute-mme.bin", std::ios::binary); dump.write(reinterpret_cast<const char*>(native_macro->native_code.data()), sizeof(native_macro->native_code)); } @@ -162,7 +163,8 @@ bool KeplerCompute::ProcessNativeMethod(Core::System& system, u32 method, u32 ar LOG_DEBUG(HW_GPU, "Native inline QMD: address={:#x}, program={:#x}, control={:#x}, grid={}/{}/{}", address, program, control, native_registers[0xc8 + 12], native_registers[0xc8 + 13] & 0xffff, native_registers[0xc8 + 14] & 0xffff); - if (std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS")) { + if (static const bool diagnostics = std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS") != nullptr; + diagnostics) { std::ofstream dump("native-inline-qmd.bin", std::ios::binary); dump.write(reinterpret_cast<const char*>(native_registers.data() + 0xc8), 256); std::ofstream registers("native-inline-compute-registers.bin", std::ios::binary); @@ -203,7 +205,8 @@ bool KeplerCompute::ProcessNativeMethod(Core::System& system, u32 method, u32 ar memory_manager.GpuToCpuAddress(qmd_address).value_or(0), method, argument, 0); if (method == 0xae || (method == 0xaf && !(argument & 2)) || (method == 0xb0 && ((argument & 15) == 0 || (argument & 15) == 1))) return true; - if ((argument & 15) == 12 && std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS")) { + static const bool qmd_diagnostics = std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS") != nullptr; + if ((argument & 15) == 12 && qmd_diagnostics) { static u32 captured{}; if (captured++ == 0 && memory_manager.IsFullyMappedRange(qmd_address, 256)) { std::array<u32, 64> descriptor{}; @@ -288,7 +291,7 @@ bool KeplerCompute::ProcessNativeMethod(Core::System& system, u32 method, u32 ar if (memory_manager.IsFullyMappedRange(qmd_address, sizeof(qmd))) { memory_manager.ReadBlockUnsafe(qmd_address, qmd.data(), sizeof(qmd)); } - if (std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS") && memory_manager.IsFullyMappedRange(qmd_address, sizeof(qmd))) { + if (qmd_diagnostics && memory_manager.IsFullyMappedRange(qmd_address, sizeof(qmd))) { std::ofstream dump("native-qmd.bin", std::ios::binary); dump.write(reinterpret_cast<const char*>(qmd.data()), sizeof(qmd)); std::ofstream macros("native-dispatch-mme.bin", std::ios::binary); diff --git a/src/video_core/macro.cpp b/src/video_core/macro.cpp index 06c649260d..e6279deab4 100644 --- a/src/video_core/macro.cpp +++ b/src/video_core/macro.cpp @@ -1346,7 +1346,8 @@ void MacroEngine::Execute(Core::System& system, Engines::Maxwell3D& maxwell3d, u maxwell3d.RefreshParameters(); const auto context = reinterpret_cast<std::uintptr_t>(this); static std::unordered_set<std::uintptr_t> captured_contexts; - if (std::getenv("EDEN_NATIVE_FRAME_CAPTURE") && captured_contexts.insert(context).second) { + static const bool capture = std::getenv("EDEN_NATIVE_FRAME_CAPTURE") != nullptr; + if (capture && captured_contexts.insert(context).second) { std::ofstream dump("native-graphics-mme-" + std::to_string(context) + ".bin", std::ios::binary); dump.write(reinterpret_cast<const char*>(native_code.data()), sizeof(native_code)); } @@ -1393,7 +1394,8 @@ void MacroEngine::Execute(Core::System& system, Engines::Maxwell3D& maxwell3d, u }); if (!result.success) { native_execution_failed = true; - if (std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS")) { + if (static const bool diagnostics = std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS") != nullptr; + diagnostics) { std::ofstream dump("native-mme-" + std::to_string(method) + ".bin", std::ios::binary); dump.write(reinterpret_cast<const char*>(native_code.data()), sizeof(native_code)); } diff --git a/src/video_core/native_query_trace.h b/src/video_core/native_query_trace.h index eae258dc04..036c3de936 100644 --- a/src/video_core/native_query_trace.h +++ b/src/video_core/native_query_trace.h @@ -30,7 +30,8 @@ inline State& GetState() { // 10=DMA destination (value=source, flags=line bytes), 11=inline write. // Keep this opt-in and bounded. inline void TraceNativeQuery(u32 event, u64 asid, u64 gpu, u64 cpu, u32 type, u64 value, u32 flags) { - if (!std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS")) return; + static const bool diagnostics = std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS") != nullptr; + if (!diagnostics) return; auto& state = NativeQueryDiagnostics::GetState(); const std::scoped_lock lock{state.mutex}; if (state.records++ < 1000000 || event == 4 || event == 5) { diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 1b0493c4b5..609ac12fb4 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -288,7 +288,10 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) { submitted = true; static u32 native_capture_count{}; if (maxwell3d->GetNativeMacroEngine().native_turing && - std::getenv("EDEN_NATIVE_DRAW_CAPTURE") && native_capture_count < 16) { + native_capture_count < 16 && [] { + static const bool capture = std::getenv("EDEN_NATIVE_DRAW_CAPTURE") != nullptr; + return capture; + }()) { const u32 capture = native_capture_count++; const auto prefix = fmt::format("native-draw-{}", capture); const auto dump = [&](const std::string& name, GPUVAddr address, size_t size) { @@ -1252,7 +1255,8 @@ std::optional<FramebufferTextureInfo> RasterizerVulkan::AccelerateDisplay( const auto [image_view, scaled] = texture_cache.TryFindFramebufferImageView(config, framebuffer_addr); static u32 display_trace_count{}; - if (std::getenv("EDEN_NATIVE_FRAME_CAPTURE") && display_trace_count++ < 64) { + static const bool frame_capture = std::getenv("EDEN_NATIVE_FRAME_CAPTURE") != nullptr; + if (frame_capture && display_trace_count++ < 64) { LOG_INFO(HW_GPU, "Native display source: address={:#x}, offset={:#x}, dimensions={}x{}, stride={}, accelerated={}, mask={:#x}", framebuffer_addr, config.offset, config.width, config.height, pixel_stride, image_view != nullptr, config.layer_stack_mask); |
