Skip to content

Performance Research G06 Shader Deduplication and Prewarm

github-actions[bot] edited this page Sep 15, 2026 · 1 revision

Shader-source deduplication, SPIR-V persistence, and prewarming

G06 — Implementation and validation notes

Field Value
Evidence state Historical cache-hit evidence; runtime/stutter qualification remains build-specific
Inspected source 322986f4c5502b3fa887a9605ac8cd88e9b2c579
First experiment Exact-source deduplication independent of driver pipeline caching
Scope Addendum dated September 15, 2026; not a current-main benchmark or implementation status

Unproven performance research · Performance research — common test protocol · Performance research — reproducible checks

Evidence and implementation reasoning

Existing implementation, distinct remaining question. The retained prewarm document records an older diagnostic with 141 stage-module misses, 463.419 ms of glslang work, a single frame containing 18.217 ms of compilation, and 20 different-key/same-source recompilations. It also records successful warm artifact reuse. Those records establish a concrete compiler-work mechanism, not a current-head FPS guarantee. Prewarm research.

Three layers must remain separate. Generated-source identity can deduplicate compilation; SPIR-V persistence can avoid recompiling known source across runs; driver pipeline caching/precreation addresses later pipeline creation. A SPIR-V hit does not eliminate GLSL generation, reflection, module construction, or graphics-pipeline creation. Khronos documents and measures pipeline cache reuse as a separate mechanism. Pipeline management.

Implementation details. Keys need complete effective source, stage, target, compiler/generator policy, and relevant options. Validate cache bounds and stage/layout information. Use immutable in-memory hits during gameplay, transactional writes outside the hot path, and a full compile fallback on invalid data. Source bytes must remain authoritative behind any hash.

Expected gain. Reduced cold/first-encounter or repeat-run hitches; often little steady-state gain once everything is already warm. Keep cold, source-warm, artifact-warm, and driver-pipeline-warm test conditions distinct.

Acceptance. Exact current-head cold/warm fixed routes, new areas beyond the trained route, corruption, failed module/reflection construction, eviction, renderer switching, shutdown, and peak memory. Successful cache hits alone do not clear adverse frame tails.

First patch boundary

Distinguish source deduplication, SPIR-V persistence and driver pipeline precreation. Keep gameplay-path file I/O out of the first implementation.

generate exact source -> validated artifact lookup -> compile on miss -> common module/reflection path

Locate the inspected seam before editing; names or ownership may have changed since the pinned review:

git grep -n -E 'spirv|glslang|prewarm|reflection' -- hw/xbox/nv2a/pgraph/vk docs/performance

Proposed focused tests

These are implementation gates to add or exercise, not claims that production tests already exist or passed. Retained standalone checks are on the checks page.

Test ID Setup / deliberate control Required oracle
G06.01 Two different state keys generating byte-identical stage/source under identical compiler options. The second eligible compile is reused; output and module inputs match.
G06.02 Fresh empty cache, warm validated cache, changed compiler/ABI, corrupt/truncated record and module-construction failure. Exact hits reuse; invalid data falls back transactionally and partial resources are released.
G06.03 Renderer switch, live setting toggle, shutdown and a route encountering new shaders. Lifetimes/writeback remain valid; compile, reflection and pipeline stalls are measured separately.

Counters and rejection criteria

Collect: source_identities, state_keys, compile_hits, compile_misses, compile_ns, reflection_ns, module_ns, pipeline_ns, cache_bytes. Keep exact counts separate from sampled durations; use an uninstrumented build for performance qualification.

Reject or hold: A high cache-hit rate is reuse evidence, not a tail-latency result. Retain adverse historical tail results and requalify the exact repaired candidate.

Follow the common protocol for source identities, previous-main/fixed-baseline controls, raw results, confidence and retail/XISO qualification. No gain becomes proven from a model, cache hit, local operation count, or shifted wait label alone.

Clone this wiki locally