|
| 1 | +# Issue #132 complete VSM debug-view qualification v1 |
| 2 | + |
| 3 | +This evidence qualifies the debug-view acceptance criterion implemented at |
| 4 | +`840eb49fa3190183c01cae29d81945045fe69ea5` on an Apple M1 Max using |
| 5 | +Metal and Bloom's native high-end profile. It covers virtual pages, physical |
| 6 | +occupancy, misses, invalidations, clip levels, and per-light cost. |
| 7 | + |
| 8 | +These are page-grid diagnostics, not geometry rendered into the game view. |
| 9 | +Their rectangular shapes deliberately represent virtual or physical cache |
| 10 | +cells. |
| 11 | + |
| 12 | +## Capture contract |
| 13 | + |
| 14 | +An opt-in intermediate capture now writes four mutually consistent artifacts: |
| 15 | + |
| 16 | +- `virtual-shadow-pages.png` is a 32 by 96-cell virtual address-space map. |
| 17 | + The three 32 by 32 clip levels are stacked vertically from near to far. |
| 18 | +- `virtual-shadow-physical.png` is the compact physical pool, in physical-slot |
| 19 | + order. It exposes occupancy, fragmentation, and eviction placement. |
| 20 | +- `virtual-shadow-legend.png` is a machine-readable six-cell palette. |
| 21 | +- `virtual-shadow-report.json` is a same-frame VSM state and cost snapshot. |
| 22 | + Using a capture-time sidecar avoids comparing post-measurement images with |
| 23 | + telemetry serialized one frame earlier. |
| 24 | + |
| 25 | +The stable palette is: |
| 26 | + |
| 27 | +| State | RGB | Meaning | |
| 28 | +| --- | --- | --- | |
| 29 | +| free | `#080808` | no virtual owner / unallocated slot | |
| 30 | +| miss-unrendered | `#ffb423` | resident miss that has never produced valid depth | |
| 31 | +| invalidated | `#ff37be` | previously rendered depth made dirty | |
| 32 | +| clip-level-0 | `#46d26e` | valid near-level page | |
| 33 | +| clip-level-1 | `#4696ff` | valid middle-level page | |
| 34 | +| clip-level-2 | `#be64ff` | valid far-level page | |
| 35 | + |
| 36 | +The report also publishes a directional-light cost row containing requests, |
| 37 | +hits, misses, invalidations, renders, residency, dirty pages, rebases, dynamic |
| 38 | +overlay draws, owned physical depth bytes, shared pool bytes, shared metadata |
| 39 | +and staging bytes, and the page render budget. |
| 40 | + |
| 41 | +## Automated fail-closed gate |
| 42 | + |
| 43 | +`tools/quality/vsm_debug_views.py` decodes the PNGs without third-party |
| 44 | +dependencies and rejects: |
| 45 | + |
| 46 | +- an unknown or reordered color; |
| 47 | +- partial cells or incorrect virtual/physical dimensions; |
| 48 | +- disagreement between the virtual and physical non-free page counts; |
| 49 | +- occupancy, dirty-state, or per-level clean counts that disagree with the |
| 50 | + same-frame report; |
| 51 | +- missing explicitly required miss or invalidation states; |
| 52 | +- changed artifact filenames or palette metadata; |
| 53 | +- any per-light counter or byte cost inconsistent with the top-level state. |
| 54 | + |
| 55 | +Seven unit tests include negative controls for missing required event colors, |
| 56 | +unknown colors, a reordered legend, per-light cost disagreement, and clip |
| 57 | +level disagreement. Rust tests independently prove that never-rendered and |
| 58 | +previously-rendered dirty pages receive different colors, all three clean |
| 59 | +levels retain stable colors, free slots remain distinct, and the legend is |
| 60 | +exact. |
| 61 | + |
| 62 | +## Live GPU captures |
| 63 | + |
| 64 | +Three captures exercise complementary states. Pixel counts below are |
| 65 | +normalized to page cells; the output scale is four pixels per cell. |
| 66 | + |
| 67 | +| Capture | Resident | Free virtual | Miss | Invalidated | Level 0 | Level 1 | Level 2 | |
| 68 | +| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | |
| 69 | +| early dynamic fill | 224 | 2,848 | 212 | 0 | 5 | 7 | 0 | |
| 70 | +| frame-30 light transition | 236 | 2,836 | 126 | 102 | 4 | 4 | 0 | |
| 71 | +| settled static contact scene | 224 | 2,848 | 0 | 0 | 144 | 64 | 16 | |
| 72 | + |
| 73 | +Every capture had zero unknown-color pixels. Virtual and physical page counts |
| 74 | +were identical for every non-free state. The static control exactly exposed |
| 75 | +the expected 144/64/16 near/middle/far demand distribution with zero dirty |
| 76 | +pages. The transition captured 102 still-dirty previously rendered pages in |
| 77 | +magenta and 126 never-rendered pages in amber. Its event counters recorded |
| 78 | +105 invalidations and 12 new cache misses; pages rendered during the frame |
| 79 | +correctly left the dirty-color population. |
| 80 | + |
| 81 | +The transition per-light row reconciled to 236 resident pages, 228 dirty |
| 82 | +pages, eight rendered pages, 224 requests, 212 hits, 12 misses, 105 |
| 83 | +invalidations, eight dynamic overlay draws, the hard eight-page render budget, |
| 84 | +16,448,256 bytes of depth owned by resident pages, a fixed 17,842,176-byte |
| 85 | +physical pool, and 2,109,648 shared metadata/staging bytes. |
| 86 | + |
| 87 | +Reproduction from `examples/quality-motion`: |
| 88 | + |
| 89 | +```sh |
| 90 | +export BLOOM_VSM=1 |
| 91 | + |
| 92 | +export BLOOM_QUALITY_INTERMEDIATES=/tmp/vsm-debug-miss |
| 93 | +./main --vsm-dynamic \ |
| 94 | + --quality-run 1 1 0.016666667 \ |
| 95 | + /tmp/vsm-debug-miss.png /tmp/vsm-debug-miss-telemetry.json \ |
| 96 | + /tmp/vsm-debug-miss |
| 97 | + |
| 98 | +export BLOOM_QUALITY_INTERMEDIATES=/tmp/vsm-debug-invalidation |
| 99 | +./main --vsm-dynamic --vsm-light-motion \ |
| 100 | + --quality-run 1 28 0.016666667 \ |
| 101 | + /tmp/vsm-debug-invalidation.png \ |
| 102 | + /tmp/vsm-debug-invalidation-telemetry.json \ |
| 103 | + /tmp/vsm-debug-invalidation |
| 104 | + |
| 105 | +export BLOOM_QUALITY_INTERMEDIATES=/tmp/vsm-debug-static |
| 106 | +./main --vsm-contact-detail \ |
| 107 | + --quality-run 120 1 0.016666667 \ |
| 108 | + /tmp/vsm-debug-static.png /tmp/vsm-debug-static-telemetry.json \ |
| 109 | + /tmp/vsm-debug-static |
| 110 | + |
| 111 | +cd ../.. |
| 112 | +python3 tools/quality/vsm_debug_views.py \ |
| 113 | + --virtual /tmp/vsm-debug-invalidation/virtual-shadow-pages.png \ |
| 114 | + --physical /tmp/vsm-debug-invalidation/virtual-shadow-physical.png \ |
| 115 | + --legend /tmp/vsm-debug-invalidation/virtual-shadow-legend.png \ |
| 116 | + --telemetry /tmp/vsm-debug-invalidation/virtual-shadow-report.json \ |
| 117 | + --require-invalidation \ |
| 118 | + --output /tmp/vsm-debug-invalidation-result.json |
| 119 | +``` |
| 120 | + |
| 121 | +Run the validator with `--require-miss` for the early-fill capture and without |
| 122 | +an event requirement for the static control. |
| 123 | + |
| 124 | +## Rendering and performance isolation |
| 125 | + |
| 126 | +This checkpoint changes no shader, render pass, texture, buffer, bind group, |
| 127 | +draw submission, page request, cache policy, VSM sampling, or CSM fallback. |
| 128 | +The page-state images were already generated only when an intermediate |
| 129 | +capture was requested; the change separates their dirty-state colors and adds |
| 130 | +a legend plus a same-frame JSON sidecar in that same post-measurement path. |
| 131 | +Normal frames execute none of the image generation, PNG encoding, or sidecar |
| 132 | +I/O. The expanded capability JSON is serialized only when explicitly queried. |
| 133 | + |
| 134 | +Consequently the production frame graph and final game image are unchanged, |
| 135 | +and the diagnostic work remains excluded from measured performance windows. |
| 136 | +Strict Clippy correctness/suspicious/performance policy and the quality |
| 137 | +contract passed. The complete quick lane passed with FFI parity on every |
| 138 | +backend, 349 shared unit tests plus one ignored, negotiated headless device |
| 139 | +construction, 59 GPU goldens plus two hardware-policy ignores, four render |
| 140 | +target tests, Web/WASM checking, 39 quality tests, and all 20 canonical |
| 141 | +examples. |
| 142 | + |
| 143 | +Machine-readable evidence is in |
| 144 | +`docs/evidence/issue-132-debug-views-v1.json`. |
0 commit comments