Let an embedder observe guest execution and GX timing - #22
Open
dougchansan wants to merge 1 commit into
Open
Conversation
The core and the GX paths already know where time goes; none of it was reachable from outside. Three headers of optional pointers an embedder installs, and probes at the points that already funnel. Granularity is the design: the guest PC is published on a 4096-dispatch cadence, guest time is measured once per timing slice, and the FIFO scope wraps a batch rather than each opcode. All pointers are null unless installed, so an unobserved build pays one predictable branch. Rebased from main onto moderngekko-vendor: main currently fails to configure for a ModernGekko consumer at Externals/tinygltf, with or without these changes.
dougchansan
force-pushed
the
feat/staticrecomp-observers
branch
from
September 7, 2026 04:57
e5086e0 to
842d6fa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groundwork for ExpansionPak/ModernGekko#37, where every diagnostics zone reads 0.00 ms because nothing below the diagnostics library can report into it.
Retargeted from
maintomoderngekko-vendor.maindoes not configure for a ModernGekko consumer — it fails atExternals/tinygltfwithNo SOURCES given to target, with or without these changes (verified against plainmainat78bdce82).moderngekko-vendoris also the branch upstream ModernGekko pins.Change
Three headers of optional pointers an embedder installs, null unless installed:
StaticRecompObserver.h— guest PC, guest execution time, and the core's existing dispatch/fallback/exception tallies.VideoZoneObserver.h— FIFO, vertex, texture and shader time, plus draw/vertex/texture/EFB/shader tallies.MmioObserver.h— MMIO read and write tallies, its own header soCore/HWgains no dependency on the others.Probes at the points that already funnel: the dispatch loop,
RunFifo,RunVertices,TexDecoder_Decode, the fourShaderCache::Compile*Shadermethods,CopyRenderTargetToTexture, and MMIORead/Write. 210 insertions, 1 deletion.Cost
Granularity is the design. The guest PC is published on a 4096-dispatch cadence, guest time is measured once per timing slice, and the FIFO scope wraps a batch rather than each opcode. Cumulative counters are republished per slice rather than incremented per event. Measured rates that justify this: dispatches ~2.5M/s, MMIO ~26.6k/s, draw calls ~13.1k/s.
guest_cpu_nsis cumulative because the core has no notion of a frame; the consumer differences it.Verification
Clean clone of ModernGekko's diagnostics branch with
vendor/dolphinon this branch, x86_64 Linux, gcc 13.3.0, RelWithDebInfo:Mario Kart Double Dash
GM4E01, windowed Vulkan, trace level:Previously the zone table read
(no zone timings recorded), every counter was 0, and the verdict wasInsufficient evidenceat0.0% instrumented.hotspots.csvwent from header-only to 512 rows, topped by0x800EB638, which matches the core's own top dispatch site. Report contents remain free of usernames, paths and addresses.Overhead across
basic/detailed/traceis indistinguishable; repeated runs land within run-to-run host variance.Not covered
Pipelines:
CreatePipelinehas 30 call sites and 8 backend implementations, so counting it needs the virtual wrapped inAbstractGfx— including D3D11/D3D12, which cannot be compiled or verified here. A documented zero beats an unverifiable cross-backend rename.TextureDecodeBytesneeds a per-format bits-per-pixel lookup rather than a tally, andGuestInstructionswould need new counting on the 2.5M/s dispatch path. Both left out rather than approximated.Note
The six VideoCommon and MMIO files are byte-identical between this branch and the revision ModernGekko pins, so they carry over as tested.
StaticRecompCore_Run.cppdiffers and was re-expressed against this branch's loop — that version is what the verification above was built from.