[PR #1423] pso_code_base_pairs: count PSOs by code-base stage (SHADER-CODEBASE-PAIRS) #1453

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

📋 Pull Request Information

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

Base: main ← Head: feat/library-code-base-pairs


📝 Commits (1)

  • 7c2de8a pso_code_base_pairs: count PSOs by code-base stage (SHADER-CODEBASE-PAIRS)

📊 Changes

7 files changed (+398 additions, -11 deletions)

View changed files

📝 docs/boot.md (+1 -1)
📝 docs/d3d12_vulkan.md (+18 -6)
📝 docs/shader_library.md (+7 -1)
➕ tests/test_pso_code_base_pairs.py (+179 -0)
📝 tools/feature_scan.py (+2 -2)
➕ tools/pso_code_base_pairs.py (+189 -0)
📝 tools/shader_library.py (+2 -1)

📄 Description

Item: SHADER-CODEBASE-PAIRS — claimed in #14 before this PR.

The question

docs/d3d12_vulkan.md §5.2 leaves the push-constant shape open: keep one 64-bit code base at dwords 34–35 in the
144-byte block, or grow it to 168 bytes with one slot per stage, or use a per-stage buffer. It says to decide after
measuring how many real PSOs have two code-base stages. Row 14 of the docs/boot.md checklist asks the same thing,
and tools/feature_scan.py's header says the package cannot answer it: "Which stages are paired in one PSO is in the
executable, not in shaders.rpf."

It can. The pipeline library in shaders.rpf's zlib part names a program per stage slot for all 25,471 graphics
records (tools/shader_library.py), and a stage's resource-layout blob ends with the 16-byte HASH digest of the
container its code came from — the same digest shader_carve.py leaves in every container it carved to
<work>/shaders/dxbc, whose file stem is the translation index's key. So

PSO -> stage slot -> program -> layout digest -> carved container -> spirv/index.json row

and each stage of a PSO picks up that program's uses_code_base.

Answer: none, for 1.0.2.1

Over all 25,471 graphics records of library 0x65F41EDD 930.048.020:

records
PSOs with no code-base stage 25,027
PSOs with exactly one 444
PSOs with two or more 0

The 444 are 343 MS, 60 PS, 41 VS. The stage census is 13,383 VS+PS, 10,726 MS+PS, 1,336 MS, 24 VS and 2 VS+PS+slot 6.
21 records (19 VS+PS, 2 with slot 6) are left unknown: a stage's program has no carved container in the carve output,
so its code base is unknown rather than absent. The tool's per-stage program counts (38 VS, 46 PS, 260 MS, 263 CS)
are lower than the corpus's published 54 / 93 / 266 / 263 of 26,503 because the library holds a second compiled form
of 6,522 carved shaders and one program can serve two stage slots; the corpus counts are reproduced by
tools/feature_scan.py unchanged, so the join sees the same shaders.

So the 144-byte block with one code base is enough for this package, and the runtime's refusal of a PSO whose two
stages both read it (section 3.2) can stay. The docs say that now, the stale feature_scan.py header line is
corrected, and tools/shader_library.py's header note about slot 6 matches the measured 2 records (both with VS+PS).

Tool

tools/pso_code_base_pairs.py (standard library only, python -I), counts only — no shader name, listing, code or
data leaves the work folder:

python -I tools/pso_code_base_pairs.py <work>/shaders --library <package>/shaders.rpf [--out pairs.json]

Accepts the archive or a library saved with tools/shader_library.py --save; reads both spirv/index.json shapes
(an object keyed by container stem, or a list of rows keyed by their own file/name); a container carved under two
stems counts as code-base if either row does; --out refuses to name one of its own inputs (report_paths).

Testing

No GPU and nothing online. On Windows 10 Pro 22H2 (19045), Python 3.12.10, 16 cores, an RTX 2080 Ti that this change never touches:

  • python -I tests/test_pso_code_base_pairs.py — 9 tests, OK. The library, the carve folder and both index shapes are
    built from bytes with the builders in tests/test_shader_library.py: a VS+PS record with both stages on a code
    base, an MS+PS record with only the PS, an unresolved record, a container carved twice, list- and map-shaped
    indexes, archive and saved-library inputs, that the report names no shader, the --out guard and a missing folder.
  • python -I tests/test_shader_library.py (21) and python -I tests/test_text_write_line_endings.py (3) — OK.
  • python -m compileall -q tools tests, and python -I scripts/check_no_game_data.py on every file in the commit —
    clean.
  • The whole tests/ tree through the runner, python -I scripts/run_semantic_tests.py tests -j 4, at 89d7dfcf5:
    plain reports 522 files, 8,099 tests, 42 files failed; with this commit 523 files, 8,108 tests, 42 files failed. The
    two failed lists differ only by test_run_wine_tests and test_build_batch_launch, which pass alone here and fail
    under -j 4 on a loaded machine. The 42 are not touched by this commit: 30 are pytest-based files python -I
    cannot import, 6 more are script-style files the runner collects nothing from (ci.yml:87 sends both kinds to the
    pytest job), and the rest are the Windows-only failures I filed as findings on #14. Rebased onto 6fe83805a after
    that; the re-run goes in a comment below.
  • The real run above is the end-to-end check: 25,471 records, 26,503 index rows, 0 unreadable carve errors.

AI-assisted. Counts only, no game data, per the coordination issue's rules.


🔄 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/1423 **Author:** [@GTAVIB4GTAVI](https://github.com/GTAVIB4GTAVI) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/library-code-base-pairs` --- ### 📝 Commits (1) - [`7c2de8a`](https://github.com/ubiquitarianism/leonida/commit/7c2de8a936897b2322caf574c991746dfe732b01) pso_code_base_pairs: count PSOs by code-base stage (SHADER-CODEBASE-PAIRS) ### 📊 Changes **7 files changed** (+398 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/boot.md` (+1 -1) 📝 `docs/d3d12_vulkan.md` (+18 -6) 📝 `docs/shader_library.md` (+7 -1) ➕ `tests/test_pso_code_base_pairs.py` (+179 -0) 📝 `tools/feature_scan.py` (+2 -2) ➕ `tools/pso_code_base_pairs.py` (+189 -0) 📝 `tools/shader_library.py` (+2 -1) </details> ### 📄 Description Item: SHADER-CODEBASE-PAIRS — claimed in [#14](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146787349) before this PR. ## The question `docs/d3d12_vulkan.md` §5.2 leaves the push-constant shape open: keep one 64-bit code base at dwords 34–35 in the 144-byte block, or grow it to 168 bytes with one slot per stage, or use a per-stage buffer. It says to decide after measuring how many real PSOs have two code-base stages. Row 14 of the `docs/boot.md` checklist asks the same thing, and `tools/feature_scan.py`'s header says the package cannot answer it: "Which stages are paired in one PSO is in the executable, not in `shaders.rpf`." It can. The pipeline library in `shaders.rpf`'s zlib part names a program per stage slot for all 25,471 graphics records (`tools/shader_library.py`), and a stage's resource-layout blob ends with the 16-byte `HASH` digest of the container its code came from — the same digest `shader_carve.py` leaves in every container it carved to `<work>/shaders/dxbc`, whose file stem is the translation index's key. So PSO -> stage slot -> program -> layout digest -> carved container -> spirv/index.json row and each stage of a PSO picks up that program's `uses_code_base`. ## Answer: none, for 1.0.2.1 Over all 25,471 graphics records of library `0x65F41EDD` 930.048.020: | | records | |---|---:| | PSOs with no code-base stage | 25,027 | | PSOs with exactly one | 444 | | **PSOs with two or more** | **0** | The 444 are 343 MS, 60 PS, 41 VS. The stage census is 13,383 VS+PS, 10,726 MS+PS, 1,336 MS, 24 VS and 2 VS+PS+slot 6. 21 records (19 VS+PS, 2 with slot 6) are left unknown: a stage's program has no carved container in the carve output, so its code base is unknown rather than absent. The tool's per-stage program counts (38 VS, 46 PS, 260 MS, 263 CS) are lower than the corpus's published 54 / 93 / 266 / 263 of 26,503 because the library holds a second compiled form of 6,522 carved shaders and one program can serve two stage slots; the corpus counts are reproduced by `tools/feature_scan.py` unchanged, so the join sees the same shaders. So the 144-byte block with one code base is enough for this package, and the runtime's refusal of a PSO whose two stages both read it (section 3.2) can stay. The docs say that now, the stale `feature_scan.py` header line is corrected, and `tools/shader_library.py`'s header note about slot 6 matches the measured 2 records (both with VS+PS). ## Tool `tools/pso_code_base_pairs.py` (standard library only, `python -I`), counts only — no shader name, listing, code or data leaves the work folder: ``` python -I tools/pso_code_base_pairs.py <work>/shaders --library <package>/shaders.rpf [--out pairs.json] ``` Accepts the archive or a library saved with `tools/shader_library.py --save`; reads both `spirv/index.json` shapes (an object keyed by container stem, or a list of rows keyed by their own `file`/`name`); a container carved under two stems counts as code-base if either row does; `--out` refuses to name one of its own inputs (`report_paths`). ## Testing No GPU and nothing online. On Windows 10 Pro 22H2 (19045), Python 3.12.10, 16 cores, an RTX 2080 Ti that this change never touches: - `python -I tests/test_pso_code_base_pairs.py` — 9 tests, OK. The library, the carve folder and both index shapes are built from bytes with the builders in `tests/test_shader_library.py`: a VS+PS record with both stages on a code base, an MS+PS record with only the PS, an unresolved record, a container carved twice, list- and map-shaped indexes, archive and saved-library inputs, that the report names no shader, the `--out` guard and a missing folder. - `python -I tests/test_shader_library.py` (21) and `python -I tests/test_text_write_line_endings.py` (3) — OK. - `python -m compileall -q tools tests`, and `python -I scripts/check_no_game_data.py` on every file in the commit — clean. - The whole `tests/` tree through the runner, `python -I scripts/run_semantic_tests.py tests -j 4`, at `89d7dfcf5`: plain reports 522 files, 8,099 tests, 42 files failed; with this commit 523 files, 8,108 tests, 42 files failed. The two failed lists differ only by `test_run_wine_tests` and `test_build_batch_launch`, which pass alone here and fail under `-j 4` on a loaded machine. The 42 are not touched by this commit: 30 are pytest-based files `python -I` cannot import, 6 more are script-style files the runner collects nothing from (`ci.yml:87` sends both kinds to the pytest job), and the rest are the Windows-only failures I filed as findings on #14. Rebased onto `6fe83805a` after that; the re-run goes in a comment below. - The real run above is the end-to-end check: 25,471 records, 26,503 index rows, 0 unreadable carve errors. AI-assisted. Counts only, no game data, per the coordination issue's rules. --- <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#1453
No description provided.