Skip to content
cccskills
FreePublished on GitHub

nsight-graphics-analyzer

Drive NVIDIA Nsight Graphics 2026.1+ from the command line for GPU performance analysis, frame capture, frame trace inspection, draw-call inspection, NVTX/D3DPERF stage timing, replay metadata extraction, and GPU Trace drill-downs. Use when the user mentions nsight, ngfx, GPU trace, frame capture, frame trace, gpu profiling, GPU performance, or asks why a frame is slow on the GPU. Captures frames from a target game (Graphics Capture or GPU Trace), auto-exports the GPU Trace TSV bundle, and exposes small JSON queries the agent can read cheaply. Wraps `ngfx.exe`, `ngfx-capture.exe`, `ngfx-replay.exe`.

The English summary is being prepared. Showing the original description.

FrostyLeaves/nsight-graphics-analyzer17 stars(GitHub 17 + cccskills 0)

Run score Not tested

See how to install

Files included (74)

  • SKILL.md17.6 KB
  • agents/openai.yaml296 B
  • references/parameters.md8.3 KB
  • scripts/nsight.py1.1 KB
  • scripts/nsight/__init__.py235 B
  • scripts/nsight/_io.py2.8 KB
  • scripts/nsight/_version.py242 B
  • scripts/nsight/analyze/__init__.py75 B
  • scripts/nsight/analyze/actions.py4.1 KB
  • scripts/nsight/analyze/headlines.py1.6 KB
  • scripts/nsight/analyze/stages.py3.8 KB
  • scripts/nsight/analyze/summary.py7.8 KB
  • scripts/nsight/artifacts/__init__.py54 B
  • scripts/nsight/artifacts/layout.py1.4 KB
  • scripts/nsight/artifacts/writer.py571 B
  • scripts/nsight/cli.py29.9 KB
  • scripts/nsight/commands/__init__.py91 B
  • scripts/nsight/commands/attach.py1.2 KB
  • scripts/nsight/commands/capabilities.py295 B
  • scripts/nsight/commands/capture.py10.0 KB
  • scripts/nsight/commands/cpp_capture.py3.1 KB
  • scripts/nsight/commands/doctor.py1.7 KB
  • scripts/nsight/commands/export_functions.py2.4 KB
  • scripts/nsight/commands/export_metadata.py981 B
  • scripts/nsight/commands/export_screenshot.py938 B
  • scripts/nsight/commands/gputrace_actions.py908 B
  • scripts/nsight/commands/gputrace_bandwidth.py694 B
  • scripts/nsight/commands/gputrace_capture.py16.3 KB
  • scripts/nsight/commands/gputrace_draws.py641 B
  • scripts/nsight/commands/gputrace_geometry.py704 B
  • scripts/nsight/commands/gputrace_metric.py844 B
  • scripts/nsight/commands/gputrace_overdraw.py725 B
  • scripts/nsight/commands/gputrace_shader_bound.py709 B
  • scripts/nsight/commands/gputrace_stages.py813 B
  • scripts/nsight/commands/gputrace_stalls.py636 B
  • scripts/nsight/commands/gputrace_texture_cache.py723 B
  • scripts/nsight/commands/gputrace.py2.0 KB
  • scripts/nsight/commands/kill.py584 B
  • scripts/nsight/commands/launch.py1.3 KB
  • scripts/nsight/commands/locate.py639 B
  • scripts/nsight/commands/replay_analyze.py3.5 KB
  • scripts/nsight/commands/replay_perf.py3.0 KB
  • scripts/nsight/commands/trigger_hotkey.py9.9 KB
  • scripts/nsight/env/__init__.py80 B
  • scripts/nsight/env/caps.py8.8 KB
  • scripts/nsight/env/locate.py7.3 KB
  • scripts/nsight/env/procs.py4.7 KB
  • scripts/nsight/parse/__init__.py620 B
  • scripts/nsight/parse/d3dperf_events.py4.7 KB
  • scripts/nsight/parse/frame.py519 B
  • scripts/nsight/parse/gputrace_frame.py1.2 KB
  • scripts/nsight/parse/regimes.py3.7 KB
  • scripts/nsight/parse/repro_info.py484 B
  • scripts/nsight/parse/tsv.py1.1 KB
  • scripts/nsight/queries/__init__.py71 B
  • scripts/nsight/queries/_diagnose_lib.py4.8 KB
  • scripts/nsight/queries/actions.py2.0 KB
  • scripts/nsight/queries/bandwidth.py7.0 KB
  • scripts/nsight/queries/draws.py7.3 KB
  • scripts/nsight/queries/geometry.py7.5 KB
  • scripts/nsight/queries/metric.py3.6 KB
  • scripts/nsight/queries/overdraw.py7.5 KB
  • scripts/nsight/queries/shader_bound.py9.1 KB
  • scripts/nsight/queries/stages.py3.3 KB
  • scripts/nsight/queries/stalls.py6.7 KB
  • scripts/nsight/queries/texture_cache.py6.8 KB
  • scripts/nsight/runner/__init__.py246 B
  • scripts/nsight/runner/attach.py2.1 KB
  • scripts/nsight/runner/common.py2.0 KB
  • scripts/nsight/runner/cpp.py2.4 KB
  • scripts/nsight/runner/gpu_trace.py11.0 KB
  • scripts/nsight/runner/graphics.py4.8 KB
  • scripts/nsight/runner/invoke.py3.8 KB
  • scripts/nsight/runner/replay.py1.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Nsight Graphics 2026 Skill

Wrapper around NVIDIA Nsight Graphics 2026.1+. The agent captures GPU frames, gets 3 small JSON artifacts, and uses drill-down subcommands to answer follow-up questions without ever loading the raw 300+ MB TSV bundle.

When to use

User intents that should trigger this skill:

  • "Why is this frame slow on the GPU?" / "Profile GPU performance" / "Grab a frame to inspect"
  • "Capture a frame from this game" / "frame trace" / "GPU Trace"
  • "What draw calls does this frame make?" / "API stream"
  • "How fast does this .ngfx-capture replay?" / "replay perf"
  • "Inspect markers / stages / metrics in this .ngfx-gputrace"
  • "Generate a C++ capture so I can edit and replay it"

Trigger keywords: nsight, ngfx, nsight graphics, GPU trace, frame capture, frame trace, gpu profiling, frame profiling.

Quick start (90% case)

# 1. capture a 200 ms GPU Trace 30 s after launch (game must already be loaded)
python "<SKILL_DIR>/scripts/nsight.py" gputrace-capture \
  --exe "C:\Game\game.exe" --wd "C:\Game" \
  --start-after-ms 30000 --max-duration-ms 200 \
  --architecture Ada --metric-set-name "Throughput Metrics" \
  --time-every-action \
  --out "D:\captures\game.ngfx-gputrace"

# 2. the wrapper writes 3 small JSON next to the .ngfx-gputrace:
#    <session>/game.gputrace.summary.json  (~50 KB)
#    <session>/game.gputrace.stages.json   (~3  KB)
#    <session>/game.gputrace.actions.json  (~15 KB)

# 3. drill into the dominant stage from summary.json's analysis.hotspots
python "<SKILL_DIR>/scripts/nsight.py" gputrace-stages \
  "<session>/game.ngfx-gputrace" --parent "Render Camera" --top 10

Replace <SKILL_DIR> with the directory containing this SKILL.md. For any subcommand's full flag list run python scripts/nsight.py <cmd> --help.

Three rules to never break:

  • GPUTRACE_REGIMES.xls is 300+ MB — never Read it directly. Drill through gputrace-stages / gputrace-actions / gputrace-metric.
  • Anti-cheat games (EAC/BattlEye/Vanguard) refuse capture and exit with code 4. Try cpp-capture or disable the anti-cheat per game policy.
  • If a capture fails with a permission error, re-run from an elevated PowerShell. doctor reports is_admin.

Tool layout

A single Python entry point dispatches to 25 subcommands. Full flag list for any subcommand: python "<SKILL_DIR>/scripts/nsight.py" <cmd> --help.

GroupSubcommandsPurpose
Envlocate / doctor / capabilities / killDetect install, self-check, dump per-binary flags, kill residuals
Run no-capturelaunch / attachRun game under ngfx with no capture taken
Capturecapture / cpp-capture / gputrace-captureGraphics Capture / C++ Capture / GPU Trace + 3 JSON
Triggertrigger-hotkeySynthesize F11 (or another F-key) into a target window so the agent — not a human — fires a --start-after-hotkey capture
Post-processgputraceRebuild 3 JSON from existing trace
Drillgputrace-stages / gputrace-actions / gputrace-metricStage tree / leaf-marker top-N / metric aggregate
Diagnose (7)gputrace-{stalls,bandwidth,shader-bound,texture-cache,overdraw,geometry,draws}Focused verdict[]-producing diagnostic commands
Replayexport-{metadata,functions,screenshot} / replay-perf / replay-analyzeMetadata / API stream / PNG extraction; replay timing; combined

Exit codes: 0 success, 2 user error, 3 Nsight not found, 4 underlying tool failed, 5 wrapper-side timeout. stdout is JSON for query commands; pass --out FILE to redirect.

Parameter Decision Guide

For decisions beyond the Quick Start path — picking a start trigger, tuning trace quality vs cost, navigating drill-down after capture, or reaching for an advanced ngfx flag — Read references/parameters.md. That file contains five decision tables:

  • A. User goal → command → required flags → what to read
  • B. GPU Trace start trigger choice (--start-after-ms vs --start-after-frames vs --start-after-hotkey vs SDK)
  • C. Trace quality vs cost trade-off (--time-every-action, --set-gpu-clocks, --real-time-shader-profiler, etc.)
  • D. Drill-down workflow once the three JSON artifacts are written
  • E. Advanced 1:1 ngfx flags (rare; skip unless asked)

⚠️ One red-line warning that belongs in the body, not the reference: --multi-pass-metrics is unusable through this wrapper (Nsight 2025.3 + 2026.1, verified May 2026). Combined with the mandatory --auto-export it deterministically writes an unloadable .ngfx-gputrace. The wrapper still accepts the flag for forensic / bug-report purposes but emits a runtime WARNING and returns bundle_complete=False. Full investigation in DESIGN.md → Investigations.

Capabilities-driven feature gating

The wrapper checks every conditional flag against the live ngfx install and exits with code 4 + a clear message if your build lacks that flag — preventing cryptic ngfx parse errors. Run python scripts/nsight.py capabilities to see what's available locally; wrapper_features.<key> maps each wrapper flag to its underlying ngfx flag.

Subcommand reference

Full flag list for any subcommand: python scripts/nsight.py <cmd> --help. This section is the agent-facing purpose only; flag detail lives in --help.

gputrace-capture

Wraps ngfx.exe --activity "GPU Trace Profiler" --auto-export .... Always writes <session>/<file>.ngfx-gputrace + BASE/ + 3 JSON artifacts. Use --dry-run to preview the ngfx command line.

trigger-hotkey

Synthesize a function-key press (default F11) into a target window via Win32 SendInput. Pair with gputrace-capture --start-after-hotkey run in the background to let the agent — not a human — fire the trigger once an external workflow has reached the desired scene. See the Agent-triggered capture workflow pattern below.

gputrace

Re-runs the parser pipeline against an existing trace + BASE/. Use after a skill upgrade to regenerate JSON without re-launching the game.

gputrace-stages

Stage-tree drill. --parent REGEX returns children of all matching parents grouped by name. --depth N restricts to a specific depth.

gputrace-actions

Top-N leaf markers (deepest D3DPERF_EVENTS nodes). --filter matches the leaf's own name; --in-marker matches any ancestor in the path. --with-metrics adds the headline block via one streaming REGIMES pass (~1-2 s). Important: read the definition field — actions are leaf markers, not raw draw calls.

gputrace-metric

Aggregate one metric. --name PATTERN is a regex over the metric catalog; --all-matches allows multi-match output. --in-marker REGEX returns per-marker windows in addition to the global aggregate.

Diagnostic command family (7 commands)

gputrace-stalls, gputrace-bandwidth, gputrace-shader-bound, gputrace-overdraw, gputrace-geometry, gputrace-texture-cache, gputrace-draws — focused diagnostic commands. Each returns a verdict[] array of {tag, severity, message}, severity ∈ {info, medium, high}. Thresholds are heuristics; treat verdicts as investigation starters, not absolute judgments. Most accept --in-marker REGEX to scope to a subtree (gputrace-stalls and gputrace-draws are whole-frame only).

Recommended investigation order on an unknown frame:

  1. gputrace-stalls — rule out CPU-bound / pipeline-bubble first; if the GPU isn't busy, the rest of the analysis doesn't matter.
  2. gputrace-bandwidth — memory-bound vs compute-bound axis.
  3. Branch:
    • memory-bound → gputrace-texture-cache to localize
    • compute-bound → gputrace-shader-bound for SM utilization detail
  4. gputrace-overdraw — opaque-pass quality.
  5. gputrace-geometry — vertex/primitive frontend.
  6. gputrace-draws — CPU-side state-churn / small-batch signals.

replay-perf

Replays a .ngfx-capture N times via ngfx-replay -n N --perf-report-dir and parses iteration_times.csv. Useful for replay-cost regression; not for original-app GPU performance (that's gputrace-capture).

How to read the artifacts

Read summary.json first. Four fields that matter:

  • analysis.frame_budget.verdict → 60fps / 30fps / below_30fps
  • analysis.throughput.dominant → most loaded subsystem
  • analysis.hotspots.slowest_stage → where to drill
  • analysis.warnings → natural-language flags

Then pick a drill direction: stage > 50% GPU → drill it; throughput dominated by dram/pcie → memory-heavy; sm dominant → shaders. Always drill via subcommands, never by reading BASE/*.xls directly (REGIMES is 300+ MB).

Top-level JSON shapes:

summary.json:  source, session, summary{frame/marker/metric counts},
               analysis{frame_budget, throughput, hotspots, warnings},
               headline_metrics, metrics[], hardware_context
stages.json:   source, headline_metrics, roots[], top_stages[]
               each: name, depth, total_duration_ns, fraction_of_gpu, headline
actions.json:  source, definition, top_20_slowest_actions[]
               each: name, path, instance_count, duration fields, headline

Diagnostic verdict thresholds — use these to interpret verdict[] beyond just severity:

CommandKey signalHealthyRed
overdrawoverdraw_ratio~1.0 (1.5-3 typical)> 3
overdrawzcull_rejection_rate> 0.3< 0.3 (ZCull defeated)
overdrawlate_z_attrition_rate< 0.3high (PS work thrown away)
bandwidthper-tier % of peak< 60%≥ 80% saturated (60-80% pressure)
bandwidthdominant tier vs SMbalancedtier ≥ SM by 15pp → memory-bound
bandwidthPCIe sustained< 30%≥ 30% (host↔device thrash)
shader-boundsm_stall_ratiolowhigh (memory latency / dep chains)
shader-boundasync-compute usebalancedcompute ≥ 30% but < 10% async (underused)
geometrypixels_per_prim≥ 16< 4 (micro-triangles)
texture-cachel1tex__t_sector_hit_rate.pct≥ 70%< 50% (thrashing)
texture-cachemiss_to_dramlow≥ 10% (DRAM burned on misses)
stallsgr_idle_pctlowhigh (GPU not fed)
stallsmarker_coverage_pcthighlow (idle BETWEEN markers → CPU bound / waits)
drawssmall_leaf_pct (< 5 μs)lowhigh (batching candidates)

Workflow patterns

First-pass perf analysis

gputrace-capture → read summary.json → 1-2 drill rounds → write Markdown report. Stop drilling once the bottleneck is at the engine-marker level (e.g. "GPUDriven.RenderMesh(Bush)") or attributable to a metric pattern (e.g. dram throughput > 80%).

Deep bottleneck dive (single stage > 80% of frame time)

gputrace-stages --parent "<stage>" --top 20
gputrace-actions --in-marker "<stage>" --top 20 --with-metrics
gputrace-metric --name "dramc__throughput" --in-marker "<stage>"
gputrace-metric --name "sm__throughput" --in-marker "<stage>"

Capture-once-then-iterate

gputrace-capture --exe ... --out trace.ngfx-gputrace
# now drill repeatedly; no re-launch needed
gputrace-stages "<session>/trace.ngfx-gputrace" ...
gputrace-actions "<session>/trace.ngfx-gputrace" ...

Reanalyze an old trace

gputrace "<session>/old-trace.ngfx-gputrace"   # rebuilds 3 JSON

cpp-capture for repro (deterministic C++ replay code)

cpp-capture --exe ... --wait-seconds 10 --out D:\repro

Attach to a running game (can't relaunch, e.g. multiplayer)

attach --activity "GPU Trace Profiler" --pid 12345
# user presses F11 in the running app

Agent-triggered capture in a larger workflow

Use this when: the agent is orchestrating a wider workflow — launching the game, running automated tests / bot actions / other skills, then deciding when to capture — and only the agent (not a human at the keyboard) knows when the target scene is on screen. Timer-based triggers (--start-after-ms / --start-after-frames) don't fit because the runtime of the surrounding workflow is unpredictable.

Why F11 simulation is the only option: ngfx's GPU Trace activity exposes exactly five start triggers (--start-after-ms / --start-after-frames / --start-after-submits / --start-after-hotkey / --start-with-ngfx-sdk / --start-on-replay-begin). ngfx-rpc.exe is the UI↔replayer IPC, not a trace-trigger RPC, and --start-with-ngfx-sdk requires the game to link the NGFX SDK and call NGFX_GPUTrace_StartTrace. For an unmodified target, hotkey is the only externally addressable trigger, and trigger-hotkey synthesizes it without a human.

Pattern:

# 1. Launch ngfx + game in the background, armed for F11 trigger.
#    DO NOT wait on this command — it blocks until the trace is written.
python scripts/nsight.py gputrace-capture \
  --exe "C:\Game\game.exe" --wd "C:\Game" \
  --start-after-hotkey \
  --max-duration-ms 200 \
  --architecture <arch> --metric-set-name "Throughput Metrics" \
  --time-every-action \
  --out "D:\captures\game.ngfx-gputrace"
# (Run via your harness's background-task primitive; capture the task ID.)

# 2. Attach a streaming watcher to the background task's output so the
#    agent is notified when the bundle is written. The wrapper prints
#    "GPU Trace report saved to ..." then "bundle_complete=True". Watch
#    for those lines (and also for "error", "fatal", "denied" to fail fast).

# 3. The agent now runs the rest of the workflow (other skills, automated
#    tests, scripted gameplay) — no polling. The capture is dormant in
#    the game process; F11 has not been pressed yet.

# 4. When the workflow signals "ready to capture":
python scripts/nsight.py trigger-hotkey --process game
# Returns JSON with foreground_ok / sent fields. exit 0 = key delivered.

# 5. ngfx hook receives F11, runs the 200 ms trace, writes the bundle,
#    wrapper post-processes into 3 JSON. The streaming watcher from step 2
#    fires; the agent reads summary.json and drills as usual.

Notes:

  • Background launch is mandatory. gputrace-capture blocks until the bundle is written, which is "forever" from the agent's point of view (it depends on when step 4 fires). The agent must run step 1 asynchronously.
  • Watch for completion, do not poll. The wrapper writes bundle_complete=True
    • the saved path to its stdout/stderr; pipe that into your harness's streaming notification primitive so the agent reacts to the event rather than guessing.
  • Windowed/borderless mode preferred. SendInput is reliable against windowed and borderless-window games. Exclusive-fullscreen + DRM combinations can swallow synthetic keystrokes; if trigger-hotkey reports sent=true but no trace appears, switch the game to borderless-window and retry.
  • Foreground stealing is restricted on Windows. trigger-hotkey calls AllowSetForegroundWindow(ASFW_ANY) + SetForegroundWindow, which works from an elevated shell (doctor reports is_admin=true) and usually from a non-elevated shell that recently saw user input. If it can't bring the window forward it still sends the key (ngfx's hook is global) and emits a stderr WARNING. Pass --no-foreground to skip the foreground step entirely if you'd rather not steal focus.
  • Use --use-scancode if the default fails. Some engines / DRM shims only honour hardware scancodes (KEYEVENTF_SCANCODE). The flag toggles the wParam encoding without other changes.
  • ngfx 2026.1.x cleanup-phase crash is benign. After the trace is written, ngfx exits with rc 0xC0000409 after trace_written=True and bundle_complete=True. The wrapper detects this and still produces the 3 JSON. Don't treat the non-zero rc as failure; check bundle_complete instead.
  • Disambiguating multiple instances. If tasklist finds more than one process matching --process, trigger-hotkey refuses and lists the PIDs; re-run with --pid <N>. Always use --pid when ngfx itself launched the game (you have the PID from the capture-task output).

Out of scope

  • Per-API-call timing (no vkCmdDraw durations — Nsight 2026.1 removed GPUTrace.pyd; actions in this skill are leaf markers, not raw draw calls). Use RenderDoc/PIX for per-API timing.
  • HTML/PDF report generation — agent writes Markdown directly.
  • Capture diff (compare two runs) — future work.
  • Cross-platform — Windows only.
  • Auto-installing Nsight — doctor only detects.
  • Remote capture (ngfx-rpc) — use ngfx-rpc.exe manually if needed.
  • NVTX marker injection — game-side, not skill-side.
  • GUI launching — open ngfx-ui.exe manually for visual inspection.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

Report a problem with this skill