mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1278] [CLOSED] pe_shader_containers: find console programs stored compressed (TOOLS-PE-SHADER-CONTAINERS) #1312
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1312
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1278
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:split/tools-pe-shader-containers📝 Commits (1)
6e0743ape_shader_containers: find console programs stored compressed (TOOLS-PE-SHADER-CONTAINERS)📊 Changes
3 files changed (+121 additions, -1 deletions)
View changed files
📝
docs/embedded_shaders.md(+10 -0)📝
tests/test_pe_shader_containers.py(+106 -0)📝
tools/pe_shader_containers.py(+5 -1)📄 Description
Rebased onto
bfef489cat6e0743af. Main already recognizes the compressed envelope. This diff deduplicates a container discovered both as a plain hit and as a stored deflate block, with synthetic coverage. All 25 container tests passed.Claimed in the coordination issue as: TOOLS-PE-SHADER-CONTAINERS (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 is the parent integration. #694 (open, OLD-9775; #53 is its draft twin) numbers the stems of a multi-image
--extractin sequence and stages the--jsonwrite. Merged three-way with it (its diff applied to the base, then merged into this branch) there are two one-line conflicts, both where each side adds an import at the same place (import zlibhere;import tempfilein the tool andfrom unittest import mockin the test there). Everything else merges, the two changes toextract()included. #387 (open; #303 is closed) adds themake_game.pystep that runs this tool on the executable; it does not change the tool, and this pull request does not add a build step. Its diff does not apply to this base, so no merge was tried.What and why
tools/pe_shader_containers.pylists the DXBC containers that lie in an image as they are. A console program can also be stored compressed, and the scan did not see those: the image has noDXBCmagic for a compressed one.The record is: a u32 stored size, the u32 constant
0x000DDCE7, the stored size again, the u32 size of the container, then a raw deflate stream of the whole DXBC container. Both stored sizes count from the constant, so they include those 12 bytes. The stream is plain deflate; nothing is decrypted.inspect()now also looks for the constant and takes a record only when all of this holds:has_xbch). The same record form also stores containers with nothing for the RDNA2 pipeline to translate; those are not listed.Such a record is listed after the plain containers, so those keep their order and therefore the file names
--extractgives them. Itsoffsetis that of the constant,stored_sizeis the stored size, andsize,sha256, the chunk list and the name describe the inflated container, which is what--extractwrites. A stream made of stored blocks holds the container as it is, where the plain scan finds it already; that container is listed once.The layout is the one the five-star-recomp project describes for the shader records of the game's effect tables (its note on shader containers); no code is taken from it. One point differs from that description and comes from the integration branch instead: there the stored size counts the 12 header bytes, and the tool requires the stream to end exactly at that size. That was not re-measured for this pull request. The integration reports reading two such pixel programs in the retail executable with this rule; here the rule is exercised on hand-built records only. If the size did not include the header, every real record would be rejected (the stream would be cut 12 bytes short), and the tool would behave as it does today.
The same scan also runs where the tool is used today, on
XboxBvhBuilder.dllin the BVH step. Whether that DLL holds such a record was not checked; a record that passes all the tests above would add a program to that step's output.Tested
Linux (CachyOS, kernel 7.3.5), Python 3.14. One commit on
6293c1c4f.python3 -I tests/test_pe_shader_containers.py: 24 tests pass (19 before, 5 new, inPackedContainerTests):stored_size, and the size, SHA-256, chunk list and name of the inflated container;--extract --json --verbosethroughmain(): the inflated container is written, the plain container keeps the first place inindex.json, and the JSON rows carry the fields above;6293c1c4fwith only the test file replaced): 3 tests fail, the first, the control of the second and the fourth; the compressed program is not found (['PlainCS'] != ['PlainCS', 'PackedPS'],1 container(s)). The other two new tests pass there too.python3 -I tests/test_bvh_shaders_stage.py(13 tests; it runs the tool on synthetic DLLs) andtests/test_bvh_gpu_smoke.py(13 tests): pass.ci.ymlruns it (compileall, everytests/test_*.pyoutsidetests/semantic, the semantic suite, the tracked-file guard), on the committed tree: one failing file,tests/test_imhex_patterns.py, which fails on the base commit too and is the only one there. Semantic suite: 470 files, 6,168 tests, 0 files failed, the same counts as the base.python3 -I scripts/check_no_game_data.py: passes.Not run: any game file (the executable, the DLLs), so no count of real records; the
make_game.pyBVH step on a real DLL; native Windows or macOS; the runtime build (no C++ or build file changes).GPUs tested: none (a file scanner).
AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.
Checklist
6293c1c4f, one commit.docs/embedded_shaders.md.docs/design.md.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.