Repository navigation
Shader tests: cover each way a DXIL program header is refused - #300
Closed
SkippySteve wants to merge 1 commit into
Closed
SkippySteve wants to merge 1 commit into
SkippySteve wants to merge 1 commit into
Conversation
DxilProgram::parse has five rejections (program size, DXIL magic, bitcode bounds, LLVM magic, bitcode offset) and trims a part to the program's own size before reading the trailer, but the tests only reached the LLVM-magic rejection. Synthetic headers now hit each one by name, check that padding after the program is not taken for an Xbox trailer, and that an unknown program kind is kept rather than refused. Tests only; runs on any host.
Author
|
superseded by #326 (combined shader DX/parser robustness) |
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.
DxilProgram::parse(crates/victory-shader/src/dxil.rs) can refuse a program in five ways: a size the part cannot hold, a missingDXILmagic, bitcode out of bounds, no LLVM magic, and a bitcode offset inside the header. It also cuts the part down to the program's own size before reading the trailer. The tests only reached the LLVM-magic case.This adds synthetic-header tests for:
u32::MAXdwords (thechecked_mulpath), plus a truncated headerDXBCwhereDXILshould bexbopthere would otherwise flag a PC program as Xbox)ShaderKind::Unknownand not refusedEach rejection test checks its exact
Malformedmessage, so a check that moves or merges with another shows up. I checked that the tests catch real regressions: dropping&part[..size]and thes >= 24bound makes two of the new tests fail.The change is tests only, with no code changes. Everything is built from synthetic bytes, with no shader or game data.
Testing (Linux,
x86_64-unknown-linux-gnu):cargo test -p victory-shader: 62 passedcargo clippy -p victory-shader --tests: only theconstant_colordead-code warning thatmainalready hascargo fmt --check: clean