Repository navigation
fix(ShaderConverter): read subprograms from their referenced segments - #385
Open
nichinichisou0609 wants to merge 2 commits into
Open
nichinichisou0609 wants to merge 2 commits into
nichinichisou0609 wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shader export currently decompresses only the first segment for each platform and reads every subprogram offset from that segment. For example, an entry with
segment = 1andoffset = 0is read from the index table at the start of segment 0. The change reads the program at the start of segment 1 instead. In the regression fixtures, valid multi-segment exports previously fail during subprogram parsing; after the fix, the exported text contains the expected payloads in blob-index order.The patch decompresses all segments described by each platform's offsets and length arrays.
ShaderProgramaccepts optional segment readers while preserving its existing two-argument constructor. It reads the entry's segment field for Unity 2019.3 and later; earlier entries use segment 0. Flat arrays and a single segment remain supported. Inconsistent segment-array lengths and references to unavailable segments raiseValueError; multiple entries may still reference the same record.The public evidence for this scope is:
ConvertSerializedShaderselectsitem[0]from nested arrays, andShaderProgramreads offsets using one reader. These are the two places that lose segment selection.The 19 new regression cases construct complete subprogram records in memory. The full-export cases use real LZ4 compression and the normal subprogram parser, covering:
ShaderProgramconstructor.Validation on Linux x86_64 with CPython 3.9.25 / pytest 8.4.2 and CPython 3.13.16 / pytest 9.1.1, using lz4 4.4.5. Both the compiled
UnityPyBoostpath and the Python fallback were exercised:417d595ruff checkandruff format --checkThe ten baseline failures comprise three valid multi-segment export cases, two calls to the new optional segment-reader argument, and five error-reporting cases for malformed metadata. The nine passing baseline cases cover explicit single-reader parsing and single-segment export. To reproduce the checks from the repository root after installing
.[tests]and Ruff:The scope is segment selection for subprogram records that the existing parser understands. It does not add player-subprogram or parameter parsing, new GPU program decoders, or reconstruction of a compilable shader. The tests select layout branches using 5.3, 2018.4, 2019.2, 2019.3, and 2022.3 version values; these are synthetic fixtures, not exports from those Editors. Windows/macOS CI and an Editor-generated asset matrix remain unverified.
The 5.3 constructor fixture supplies an explicit little-endian reader; it does not validate the separate legacy
m_SubProgramBlobexport entry point. Additional checks of that entry point reproduce an existing byte-order failure on both417d595and this change: the entry point constructs a reader without specifying its endianness. That path is unchanged by this patch.