shader_library: read indexes in blocks and reject incomplete reads (RT-SHADER-INDEX-BLOCK-READ) #1218
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1218"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-24T20:29:40Z.
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
mainthe 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 publicShaderLibrary::loadcall 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.The larger index improved in all 12 pairs on both baselines. The small control favored the change in only 6/12 pairs on
main. Baseline58be9cdf8, #1108 patch fromf6ea7b667. This measures the first shader-library load on synthetic data. Game startup and frame rate were not timed.Tested
gta6rt.exein RelWithDebInfo. Native Windows CTestsshader_libraryandmodspassed. 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_computeandd3d12_fspx_computepassed on both Windows adapters below. The latter creates compute PSOs from the optional FSPX index, dispatches them and verifies readback.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
Imported from ubiquitarianism/leonida. Originally posted by Snooozs on 2026-11-24T20:58:04Z.
Read the whole diff and tested
2b67760c4merged on main66d4f5aa3(clean), Windows 10 Pro 19045, VS 2022 RelWithDebInfo, CPU only:shader_library.h: 2 of 2 runs fail at line 666 (!loaded), so the silently shortened index reproduces on Windows 10 tooshader_library_testpassI did not measure load times. Nothing to change from my side.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:01:52Z.
#1218 | head
2b67760c45(merged cleanly with maina8465211fb) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(shader_library|d3d12_compute|d3d12_fspx_compute)$" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main:shader_libraryfails atline 666: !loaded(LockFileExbyte lock at+64 KiBis silently ignored bystd::istreambuf_iterator, accepting the truncated{}prefix) | green on PR+main: 3/3 CTests pass (shader_libraryrejecting the locked-tail index withindex.json could not be read, plusd3d12_computeandd3d12_fspx_computeon RTX 3090 with0Khronos validation errors);check_no_game_data.py0violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yesImported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:12:21Z.
Verified by OreoFR
a8465211f+ PR head2b67760c4(merged with --no-ff, no conflict; tested in a package with other PRs that share no file with it)ctest -R ^shader_library$(red: the PR's test with src/shader_library.h from main)CHECK(!loaded))runtime/src/shader_library.handruntime/test/shader_library_test.cppwith the open #2566; a rebase may be needed if #2566 lands first.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T02:09:42Z.
Verified by OreoFR: link check
59e65849b+ this PR (head2b67760c4, the head verified earlier) merged with --no-ff, built without the XMA decoder (LEONIDA_CARGO=OFF, noLEONIDA_XMA2_DECODER_LIB: configure reports the XMA2 and Opus decoders not built), RelWithDebInfo, Ninja, MSVC 19.44.35230 (VS 2022 BuildTools),LEONIDA_REQUIRE_VULKAN=ONgta6rt.exelinks; imports unchanged vs main built the same way (dumpbin /imports: 25 DLLs, 655 functions, no WS2_32)AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T08:10:21Z.
Merged after OreoFR's red/green check (check: green with this PR merged onto
main, red without it;gta6rt.exestill links with unchanged imports when the PR touches the runtime) and a re-check here: no conflict withmain02c3ef96d, same head as checked, not frozen, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known onmainor Vulkan).AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.