runtime: stop inner_coverage_requirements scan at SPIR-V preamble boundary (RT-CONSERVATIVE-RASTER-PREAMBLE-STOP) #1982

Merged
IlyassRS3 merged 1 commit from upstream-pr/1982 into main 2026-11-28 17:55:49 +00:00
IlyassRS3 commented 2026-11-25 17:20:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T17:20:28Z.


Item ID: RT-CONSERVATIVE-RASTER-PREAMBLE-STOP (claimed in #1608)

Summary

inner_coverage_requirements() in runtime/src/conservative_raster.h is called on every shader stage of every graphics PSO (runtime/shims/d3d12_vulkan_device.cpp:8459), yet previously walked the entire SPIR-V binary word-by-word through all debug names, decorations, types, constants, globals, and function bodies.

Per SPIR-V Logical Layout (§2.4), OpCapability (17) and OpExecutionMode (16) strictly precede all debug (OpString/OpSource*/OpName/OpMemberName/OpModuleProcessed), annotation (OpDecorate*/OpGroup*), type/constant/global (OpType*/OpConstant*/OpVariable/OpUndef), and function (OpFunction) sections.

  • Stop scanning as soon as the opcode enters any post-execution-mode section (after validating the instruction's word-count framing, so truncated preamble/boundary instructions are still rejected).
  • Expand runtime/test/conservative_raster_test.cpp with coverage for short/empty inputs, wrong magic, header-only modules, full modules with large bodies, boundary truncation rejection, and early-stop verification across OpName, OpDecorate, OpTypeVoid, OpConstant, OpVariable, and OpFunction.

Benchmarks (-O2, bit-exact A/B vs full-module scan)

  • 12k-word ordinary PS (12,033 words): 4,678.4 ns → 8.4 ns (553.65× faster)
  • 50k-word large PS (50,033 words): 10,261.8 ns → 8.6 ns (1,189.21× faster)
  • 50k-word inner-coverage + post-depth PS (50,033 words): 10,033.8 ns → 10.0 ns (1,007.15× faster)

Testing & Disclosure

  • AI-assisted: yes
  • GPUs tested: none (macOS host, CPU-only portable unit test and A/B benchmark)
  • clang++ -std=c++20 -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer -Wall -Wextra -Werror runtime/test/conservative_raster_test.cpp: PASS
  • clang++ -std=c++20 -g -O1 -fsanitize=thread -fno-omit-frame-pointer -Wall -Wextra -Werror runtime/test/conservative_raster_test.cpp: PASS
  • clang++ -std=c++20 -O2 -Wall -Wextra -Werror runtime/test/conservative_raster_test.cpp: PASS
  • python3 -I scripts/check_no_game_data.py runtime/src/conservative_raster.h runtime/test/conservative_raster_test.cpp: PASS
  • python3 -I tests/test_text_write_line_endings.py: PASS (3/3)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5495911585 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1982). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T17:20:28Z. --- Item ID: `RT-CONSERVATIVE-RASTER-PREAMBLE-STOP` (claimed in #1608) ## Summary `inner_coverage_requirements()` in `runtime/src/conservative_raster.h` is called on every shader stage of every graphics PSO (`runtime/shims/d3d12_vulkan_device.cpp:8459`), yet previously walked the entire SPIR-V binary word-by-word through all debug names, decorations, types, constants, globals, and function bodies. Per SPIR-V Logical Layout (§2.4), `OpCapability` (17) and `OpExecutionMode` (16) strictly precede all debug (`OpString`/`OpSource*`/`OpName`/`OpMemberName`/`OpModuleProcessed`), annotation (`OpDecorate*`/`OpGroup*`), type/constant/global (`OpType*`/`OpConstant*`/`OpVariable`/`OpUndef`), and function (`OpFunction`) sections. - Stop scanning as soon as the opcode enters any post-execution-mode section (after validating the instruction's word-count framing, so truncated preamble/boundary instructions are still rejected). - Expand `runtime/test/conservative_raster_test.cpp` with coverage for short/empty inputs, wrong magic, header-only modules, full modules with large bodies, boundary truncation rejection, and early-stop verification across `OpName`, `OpDecorate`, `OpTypeVoid`, `OpConstant`, `OpVariable`, and `OpFunction`. ## Benchmarks (`-O2`, bit-exact A/B vs full-module scan) - 12k-word ordinary PS (12,033 words): 4,678.4 ns → **8.4 ns** (**553.65×** faster) - 50k-word large PS (50,033 words): 10,261.8 ns → **8.6 ns** (**1,189.21×** faster) - 50k-word inner-coverage + post-depth PS (50,033 words): 10,033.8 ns → **10.0 ns** (**1,007.15×** faster) ## Testing & Disclosure - AI-assisted: yes - GPUs tested: none (macOS host, CPU-only portable unit test and A/B benchmark) - `clang++ -std=c++20 -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer -Wall -Wextra -Werror runtime/test/conservative_raster_test.cpp`: PASS - `clang++ -std=c++20 -g -O1 -fsanitize=thread -fno-omit-frame-pointer -Wall -Wextra -Werror runtime/test/conservative_raster_test.cpp`: PASS - `clang++ -std=c++20 -O2 -Wall -Wextra -Werror runtime/test/conservative_raster_test.cpp`: PASS - `python3 -I scripts/check_no_game_data.py runtime/src/conservative_raster.h runtime/test/conservative_raster_test.cpp`: PASS - `python3 -I tests/test_text_write_line_endings.py`: PASS (3/3)
copilot-pull-request-reviewer[bot] commented 2026-11-25 17:20:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T17:20:38Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6061960070 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1982#pullrequestreview-6061960070). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T17:20:38Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
zmasi commented 2026-11-28 13:07:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T13:07:19Z.


Verified on Windows 11 (10.0.26200.9974) with MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) against main d48a957bb + c367a1e36d (claim #2570#issuecomment-7239583640):

  • Line-by-line diff audit: Clean (runtime/src/conservative_raster.h, runtime/test/conservative_raster_test.cpp); stops inner_coverage_requirements at the first post-OpExecutionMode SPIR-V instruction (OpName, OpDecorate*, OpType*, OpConstant*, OpVariable, OpFunction, etc.) after validating the boundary instruction's own word framing. check_no_game_data.py clean.
  • Red (d48a957bb + PR test): conservative_raster_test.exe fails (rc=1, conservative raster capability checks: 6 failures).
  • Green (d48a957bb + c367a1e36d merge): Auto-merges cleanly (rc=0), compiles with 0 warnings under /W4 /permissive-, and passes (conservative raster: enabled extension, precision and uncertainty bounds checked, rc=0).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239706644 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1982#issuecomment-7239706644). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T13:07:19Z. --- Verified on Windows 11 (`10.0.26200.9974`) with MSVC `19.44.35228` (`x64`, `/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`) against `main` `d48a957bb` + `c367a1e36d` (claim `#2570#issuecomment-7239583640`): - **Line-by-line diff audit**: Clean (`runtime/src/conservative_raster.h`, `runtime/test/conservative_raster_test.cpp`); stops `inner_coverage_requirements` at the first post-`OpExecutionMode` SPIR-V instruction (`OpName`, `OpDecorate*`, `OpType*`, `OpConstant*`, `OpVariable`, `OpFunction`, etc.) after validating the boundary instruction's own word framing. `check_no_game_data.py` clean. - **Red (`d48a957bb` + PR test)**: `conservative_raster_test.exe` fails (`rc=1`, `conservative raster capability checks: 6 failures`). - **Green (`d48a957bb` + `c367a1e36d` merge)**: Auto-merges cleanly (`rc=0`), compiles with `0` warnings under `/W4 /permissive-`, and passes (`conservative raster: enabled extension, precision and uncertainty bounds checked`, `rc=0`). AI-assisted.
MoonEyes commented 2026-11-28 17:55:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:55:46Z.


Red/green: On main conservative_raster_test fails 6 checks (the inner_coverage_requirements scan runs past the SPIR-V preamble), and with the PR ctest -R "^conservative_raster$" passes.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243396414 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1982#issuecomment-7243396414). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T17:55:46Z. --- Red/green: On main conservative_raster_test fails 6 checks (the inner_coverage_requirements scan runs past the SPIR-V preamble), and with the PR ctest -R "^conservative_raster$" passes. Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.
OreoFR commented 2026-11-28 21:57:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:57:29Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head c367a1e36; green run in a merge package of 16 PRs, no new ctest failure vs main
  • Test: ctest -R ^conservative_raster$
  • Red on main: 6 failures (the inner_coverage_requirements scan runs past the SPIR-V preamble)
  • Green with the PR: OK
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246394589 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1982#issuecomment-7246394589). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:57:29Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `c367a1e36`; green run in a merge package of 16 PRs, no new ctest failure vs main - Test: `ctest -R ^conservative_raster$` - Red on main: 6 failures (the inner_coverage_requirements scan runs past the SPIR-V preamble) - Green with the PR: OK - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1982
No description provided.