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

Open
opened 2026-11-26 21:19:39 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1982
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: perf/rt-conservative-raster-preamble-stop


📝 Commits (1)

  • c367a1e runtime: stop inner_coverage_requirements scan at SPIR-V preamble boundary

📊 Changes

2 files changed (+84 additions, -0 deletions)

View changed files

📝 runtime/src/conservative_raster.h (+29 -0)
📝 runtime/test/conservative_raster_test.cpp (+55 -0)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1982 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `perf/rt-conservative-raster-preamble-stop` --- ### 📝 Commits (1) - [`c367a1e`](https://github.com/ubiquitarianism/leonida/commit/c367a1e36db2ee4ec0b379efb703b137756d2c8b) runtime: stop inner_coverage_requirements scan at SPIR-V preamble boundary ### 📊 Changes **2 files changed** (+84 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/conservative_raster.h` (+29 -0) 📝 `runtime/test/conservative_raster_test.cpp` (+55 -0) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1989
No description provided.