Repository navigation
Conversation
…PE-SHADER-CONTAINERS) The scan found only containers that lie in the image as they are. A console program can also be stored as a compressed record: a stored size, the constant 0x000DDCE7, the stored size again, the size of the container and a raw deflate stream of the whole DXBC container. Such a program was not listed and not extracted. inspect() now also looks for that record. It is taken only when both stored sizes agree and fit, the stream ends exactly where the record does and inflates to exactly one container of the named size, and that container holds an XBCH program. It is listed after the plain containers, which keep their order and file names, with the offset of the constant, stored_size, and the size and SHA-256 of the inflated container. --extract writes the inflated container. A container that a stream of stored blocks holds as it is stays listed once. tests/test_pe_shader_containers.py gets five tests with hand-built records; three of them fail on the base. The standard-library tests and the translator suite add no failing file. No game file was read for this change: the record layout is taken from the integration branch, and it is exercised here on synthetic records only. AI-assisted (Claude Code). Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
f5d2d44 to
6e0743a
Compare
|
Reviewed 6e0743a: ran tests/test_pe_shader_containers.py on the PR tree (25/25) and on main with the PR's test file: only test_stored_blocks_list_the_container_once fails there -- main lists and extracts a stored-block container twice (PackedPS.dxbc plus PackedPS_02.dxbc, identical bytes), which this PR fixes. Probes over compressed, stored-block and mixed-block envelopes show the dedup only drops a packed record whose bit-identical plain copy is already listed inside its span, so nothing is lost. Nit: the SGD5 scan itself (validation, offsets, stored_size, extraction) is on main since 273b3bd, so this PR's delta is the dedup plus tests and docs; the message reads as if the scan were new -- consider rewording. Fixtures synthetic, check_no_game_data.py clean, no GPU or game files involved. AI-assisted review. Recommendation: Merge |
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