gpu: keep CreateSamplerX's values in the host's ranges (port of VIctory#474) #129

Closed
wilu222 wants to merge 0 commits from upstream-pr/129 into main
wilu222 commented 2026-11-26 23:32:48 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by wilu222 on 2026-11-26T23:32:48Z.


Port of Marvisak/VIctory#474 (by nathanbzrr), which this tree does not have yet. The code and tests are written for this tree.

Fields::host in crates/victory-gpu/src/sampler.rs passed the console's sampler words to D3D12_SAMPLER_DESC unchecked, including values the host refuses:

  • a NaN or infinite MinLOD/MaxLOD, or a MaxLOD below MinLOD: now finite (NaN becomes 0 for the minimum and the minimum for the maximum) and ordered
  • a MipLODBias outside -16..15.99: now clamped (NaN becomes 0)
  • an address mode outside 1..=5: now clamp
  • a comparison function on a sampler that does not compare: now NEVER; comparison samplers keep theirs

A sampler without a mip filter still has both LODs at its minimum, as before.

Tested (RTX 5070, driver 617.42, Windows 10 19045, Rust 1.98.1)

  • Two new tests, lod_bounds_reach_the_host_finite_and_ordered and bias_address_and_comparison_stay_in_host_ranges: both fail on main and pass here; console_descriptions_decode still passes
  • cargo clippy --workspace --all-targets --locked -- -D warnings and the same with --all-features: clean
  • cargo test --workspace --locked --no-fail-fast: 632 passed, 26 failed, 14 ignored; main (1361e19) gives 630 passed with the same 26 failures (GPU tests in victory-shader and depth_bounds_pipeline_loads_and_filters_draws)

Not tested: in game.

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:5518583859 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/129). Originally posted by [wilu222](https://github.com/wilu222) on 2026-11-26T23:32:48Z. --- Port of Marvisak/VIctory#474 (by nathanbzrr), which this tree does not have yet. The code and tests are written for this tree. `Fields::host` in `crates/victory-gpu/src/sampler.rs` passed the console's sampler words to `D3D12_SAMPLER_DESC` unchecked, including values the host refuses: - a NaN or infinite `MinLOD`/`MaxLOD`, or a `MaxLOD` below `MinLOD`: now finite (NaN becomes 0 for the minimum and the minimum for the maximum) and ordered - a `MipLODBias` outside `-16..15.99`: now clamped (NaN becomes 0) - an address mode outside `1..=5`: now clamp - a comparison function on a sampler that does not compare: now `NEVER`; comparison samplers keep theirs A sampler without a mip filter still has both LODs at its minimum, as before. **Tested** (RTX 5070, driver 617.42, Windows 10 19045, Rust 1.98.1) - Two new tests, `lod_bounds_reach_the_host_finite_and_ordered` and `bias_address_and_comparison_stay_in_host_ranges`: both fail on `main` and pass here; `console_descriptions_decode` still passes - `cargo clippy --workspace --all-targets --locked -- -D warnings` and the same with `--all-features`: clean - `cargo test --workspace --locked --no-fail-fast`: 632 passed, 26 failed, 14 ignored; `main` (`1361e19`) gives 630 passed with the same 26 failures (GPU tests in `victory-shader` and `depth_bounds_pipeline_loads_and_filters_draws`) **Not tested:** in game.
wilu222 commented 2026-11-27 00:42:17 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by wilu222 on 2026-11-27T00:42:17Z.


Closing: an in-game check (RTX 5070, about 7 minutes of the prologue) found the title never creates a sampler with these values, so the change fixes nothing observable for it.

<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7206683135 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/129#issuecomment-7206683135). Originally posted by [wilu222](https://github.com/wilu222) on 2026-11-27T00:42:17Z. --- Closing: an in-game check (RTX 5070, about 7 minutes of the prologue) found the title never creates a sampler with these values, so the change fixes nothing observable for it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
uiliannn/VItoriaBr!129
No description provided.