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

Merged
leonida/mandy
quietfold merged 1 commit from perf/rt-conservative-raster-preamble-stop into main 2026-11-28 17:55:49 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 17:20:28 +00:00

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)
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] reviewed 2026-11-25 17:20:38 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
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

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.

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

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.

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

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).

**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 description provided.