shader_library: read indexes in blocks and reject incomplete reads (RT-SHADER-INDEX-BLOCK-READ) #1218

Open
github-bot wants to merge 1 commit from github-bot/gh-1218 into main AGit
Owner

@⁠sodove on GitHub · 2026-11-24 20:29 UTC · original
sodove:perf/shader-index-block-read → main · +52 −3 · 2 files · 1 commits · open

Claimed in the coordination issue as: RT-SHADER-INDEX-BLOCK-READ (claim).

Depends on: none. #1108 changes how the JSON parser moves subtrees and applies independently.

What changed

The first pipeline that needs the shader library waits for ShaderLibrary::load. Its main and optional indexes now read in 16 KiB blocks. The reader keeps native Unicode paths and shared reads on Windows, and checks the file error indicator before parsing.

This also fixes a reproducible Windows failure. An index started with a valid JSON object and had a locked byte after 64 KiB of readable input. On main the load succeeded with just the readable prefix. The regression test now requires a read error and an unloaded library.

Measured

Native Windows 11 x64, Ryzen 5 9600X, MSVC 19.44 /O2. Each sample timed the complete public ShaderLibrary::load call with warm filesystem cache, including parsing and building the lookup table. After the timer stopped, the harness looked up every synthetic entry and checked its name, stage key, local size and push-constant size. One warm-up round, then 12 paired rounds with alternating revision order.

Synthetic index Entries Bytes main → this PR main + #1108 → both
Compact 26,503 2,563,635 86.78 → 74.08 ms 56.73 → 45.67 ms
Indented, with bindings and sampler metadata 26,503 13,668,393 345.43 → 295.47 ms 202.24 → 139.22 ms
Small control 64 5,795 0.366 → 0.343 ms 0.293 → 0.270 ms

The larger index improved in all 12 pairs on both baselines. The small control favored the change in only 6/12 pairs on main. Baseline 58be9cdf8, #1108 patch from f6ea7b667. This measures the first shader-library load on synthetic data. Game startup and frame rate were not timed.

Tested

  • Built gta6rt.exe in RelWithDebInfo. Native Windows CTests shader_library and mods passed. The Windows lock test failed at the successful-load assertion on the unmodified reader. The shader-library suite also passed on GCC 15.2, Linux x86-64.
  • d3d12_compute and d3d12_fspx_compute passed on both Windows adapters below. The latter creates compute PSOs from the optional FSPX index, dispatches them and verifies readback.
  • 45 additional path and boundary checks per revision, including Unicode directories, UTF-8 BOMs, exact and partial blocks, trailing invalid bytes, and an unreadable-as-JSON optional index alongside a valid main index.
  • Full semantic suite passed, 6,168 tests in 470 files. Both changed paths passed the game-data check. The merge with #1108 is clean.

GPUs tested: RTX 5070 Ti (NVIDIA 610.74), Ryzen 5 9600X integrated Radeon (AMD 32.0.21045.29003), Windows 11.

AI-assisted: yes (OpenAI Codex).

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • Only runtime source and a synthetic regression test.
  • No translator rule changed.
**@⁠sodove** on GitHub · 2026-11-24 20:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1218) `sodove:perf/shader-index-block-read` → `main` · +52 −3 · 2 files · 1 commits · open Claimed in the coordination issue as: RT-SHADER-INDEX-BLOCK-READ ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). Depends on: none. #1108 changes how the JSON parser moves subtrees and applies independently. ### What changed The first pipeline that needs the shader library waits for `ShaderLibrary::load`. Its main and optional indexes now read in 16 KiB blocks. The reader keeps native Unicode paths and shared reads on Windows, and checks the file error indicator before parsing. This also fixes a reproducible Windows failure. An index started with a valid JSON object and had a locked byte after 64 KiB of readable input. On `main` the load succeeded with just the readable prefix. The regression test now requires a read error and an unloaded library. ### Measured Native Windows 11 x64, Ryzen 5 9600X, MSVC 19.44 `/O2`. Each sample timed the complete public `ShaderLibrary::load` call with warm filesystem cache, including parsing and building the lookup table. After the timer stopped, the harness looked up every synthetic entry and checked its name, stage key, local size and push-constant size. One warm-up round, then 12 paired rounds with alternating revision order. | Synthetic index | Entries | Bytes | main → this PR | main + #1108 → both | |---|---:|---:|---:|---:| | Compact | 26,503 | 2,563,635 | 86.78 → 74.08 ms | 56.73 → 45.67 ms | | Indented, with bindings and sampler metadata | 26,503 | 13,668,393 | 345.43 → 295.47 ms | 202.24 → 139.22 ms | | Small control | 64 | 5,795 | 0.366 → 0.343 ms | 0.293 → 0.270 ms | The larger index improved in all 12 pairs on both baselines. The small control favored the change in only 6/12 pairs on `main`. Baseline `58be9cdf8`, #1108 patch from `f6ea7b667`. This measures the first shader-library load on synthetic data. Game startup and frame rate were not timed. ### Tested - Built `gta6rt.exe` in RelWithDebInfo. Native Windows CTests `shader_library` and `mods` passed. The Windows lock test failed at the successful-load assertion on the unmodified reader. The shader-library suite also passed on GCC 15.2, Linux x86-64. - `d3d12_compute` and `d3d12_fspx_compute` passed on both Windows adapters below. The latter creates compute PSOs from the optional FSPX index, dispatches them and verifies readback. - 45 additional path and boundary checks per revision, including Unicode directories, UTF-8 BOMs, exact and partial blocks, trailing invalid bytes, and an unreadable-as-JSON optional index alongside a valid main index. - Full semantic suite passed, 6,168 tests in 470 files. Both changed paths passed the game-data check. The merge with #1108 is clean. GPUs tested: RTX 5070 Ti (NVIDIA 610.74), Ryzen 5 9600X integrated Radeon (AMD 32.0.21045.29003), Windows 11. AI-assisted: yes (OpenAI Codex). ### Checklist - [x] Based on current main and merges cleanly. - [x] One topic. - [x] Only runtime source and a synthetic regression test. - [x] No translator rule changed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:43:17 +00:00
Author
Owner

@⁠Snooozs on GitHub · 2026-11-24 20:58 UTC · original

Read the whole diff and tested 2b67760c4 merged on main 66d4f5aa3 (clean), Windows 10 Pro 19045, VS 2022 RelWithDebInfo, CPU only:

  • the new test with main's shader_library.h: 2 of 2 runs fail at line 666 (!loaded), so the silently shortened index reproduces on Windows 10 too
  • with the PR: 5 of 5 runs of shader_library_test pass

I did not measure load times. Nothing to change from my side.

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

**@⁠Snooozs** on GitHub · 2026-11-24 20:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1218#issuecomment-7144296675) Read the whole diff and tested `2b67760c4` merged on main `66d4f5aa3` (clean), Windows 10 Pro 19045, VS 2022 RelWithDebInfo, CPU only: - the new test with main's `shader_library.h`: 2 of 2 runs fail at line 666 (`!loaded`), so the silently shortened index reproduces on Windows 10 too - with the PR: 5 of 5 runs of `shader_library_test` pass I did not measure load times. Nothing to change from my side. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1218/head:github-bot/gh-1218'
git switch 'github-bot/gh-1218'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1218'
git switch 'github-bot/gh-1218'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1218'
git switch 'github-bot/gh-1218'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1218'
git switch 'main'
git merge --squash 'github-bot/gh-1218'
git switch 'main'
git merge --ff-only 'github-bot/gh-1218'
git switch 'main'
git merge 'github-bot/gh-1218'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.