Repository navigation
Shaders: an immediate sampler's LOD bias stays in D3D12's range - #327
Closed
SkippySteve wants to merge 1 commit into
Closed
SkippySteve wants to merge 1 commit into
SkippySteve wants to merge 1 commit into
Conversation
The sampler word's LOD bias is a 14-bit signed 5.8 field, so it decodes to anything from -32 to 31.996. D3D12 takes a static sampler's MipLODBias only from -16 to 15.99 (D3D12_MIP_LOD_BIAS_MIN/MAX) and refuses a root signature holding one outside that, which would lose the whole pipeline. Clamp the decoded bias to that range; values inside it are unchanged. The test covers both clamped ends and in-range values on either side, and runs on every 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.
An immediate sampler's LOD bias comes from bits 0-13 of sampler word 2. That field is signed 5.8 fixed point, so
StaticSampler::from_wordscan decode any value from -32 to 31.996. D3D12 only accepts a static sampler'sMipLODBiasbetween -16 and 15.99 (D3D12_MIP_LOD_BIAS_MIN/D3D12_MIP_LOD_BIAS_MAX). A root signature that holds a static sampler outside that range is refused, and the whole pipeline is lost with it.This change clamps the decoded bias to D3D12's range. Values already inside it come through unchanged. The module doc now says so.
Testing (Linux)
cargo test -p victory-shader: 58 passed, including the newlod_bias_stays_in_the_host_range. It covers 15.996, 31.996 and -32, which are clamped, and -16, 14.5 and -0.5, which are kept.cargo clippy -p victory-shader --all-targets: no new warnings. The one remaining warning,constant_colornever used, was already there before this change.cargo fmt --checkshows no diff for this file, andcargo xtask policypasses.No game data was used; the test builds its sampler words in code.