From 29b6cc46afed2d6dadc6191986cb07ac6693eae1 Mon Sep 17 00:00:00 2001 From: JJenkx Date: Wed, 21 Oct 2026 19:13:36 -0400 Subject: [PATCH] perf(agc): read APS5_NO_QUEUED_DRAW_READ_ORDER once in the held-read check DrawPipeline::HeldReads called std::getenv on every call. It runs for each StorageTexture::FlushPending, which InPlaceDrawInput calls while the draw committer records a draw. On Windows, UCRT's getenv takes the environment lock and scans the block on each call: on the title screen of Spirit of the Island (PPSA13934), 375 of the draw committer's 5124 steady-state samples (7.3 %) were in ucrtbase under HeldReads, against under 0.3 % for the range scan itself. The variable is now read once into a static, as WaitMemory.cpp already does for the same variable. Co-Authored-By: Claude Opus 5.5 --- .../libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp b/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp index a1a5ebaab141..1c9839e0b116 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp @@ -467,7 +467,8 @@ std::uint64_t DrawPipeline::DrainRequestsByOpcode(std::uint32_t opcode) { } bool DrawPipeline::HeldReads(std::uint64_t address, std::size_t bytes) { - if (bytes == 0 || std::getenv("APS5_NO_QUEUED_DRAW_READ_ORDER") != nullptr) return false; + static const bool unordered = std::getenv("APS5_NO_QUEUED_DRAW_READ_ORDER") != nullptr; + if (bytes == 0 || unordered) return false; const auto end = address + bytes; auto& pipeline = Queue0(); std::lock_guard lock(pipeline.mutex);