Recompiler: an aniso point sampler filter samples points, not linearly #1117

Manually merged
github merged 1 commit from gh-pr/1117/head into gh-pr/1117/base 2026-11-26 04:43:57 +00:00
Owner

@⁠emirduran707 on GitHub · 2026-11-24 11:57 UTC · original
emirduran707:sampler-aniso-point → main · +32 −8 · 3 files · 1 commits · merged 2026-11-25 10:57 UTC

An S#'s XY_MAG_FILTER / XY_MIN_FILTER are 0 point, 1 bilinear, 2 aniso point, 3 aniso bilinear (Mesa's SQ_TEX_XY_FILTER enum, e.g. src/amd/registers/gfx8.json). A driver writes aniso point for a nearest filter when anisotropy is on: Mesa's radv_tex_filter returns max_ansio > 1 ? V_008F38_SQ_TEX_XY_FILTER_ANISO_POINT : V_008F38_SQ_TEX_XY_FILTER_POINT for VK_FILTER_NEAREST.

desc::sampler_d3d12 took every value from 2 up as anisotropic and as linear. So a point sampler with the anisotropy bits set came out as D3D12_FILTER_ANISOTROPIC, which is linear, or as plain linear with a ratio of 1. Lookup tables, G-buffer reads and other fetches meant to be point-sampled were blended. The HLSL the recompiler emits for implicit-LOD samples copies the same rule (emit.rs, "as desc::sampler_d3d12 decides").

What is in it

  • crates/xcl/src/gpu/desc.rs: only aniso bilinear (3) is anisotropic, and "linear" means bilinear or aniso bilinear (bit 0). Aniso point is point.
  • crates/xcl/src/gpu/recomp/emit.rs: the same rule in the emitted HLSL.
  • Tests:
    • decodes_ssharp used 2 for an anisotropic filter, which encoded the bug. It uses 3 now, and checks 2 as point: with the ratio set or not, and with a linear mip filter.
    • gpu_ps_image_sample_offset_implicit_lod_between_mips is now a helper. It also runs as gpu_ps_image_sample_with_an_aniso_point_filter_samples_points: aniso point min / mag at a 4× ratio must give the point filter's texels.
    • It fails without the change on the GPU below: the samples come out blended.
  • Note for #540: its sampler cases labelled "aniso" use 2 for min / mag. They become point samplers with this change, which are still valid ones, so its debug-layer check is not affected. They would need 3 to stay anisotropic.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.31044.16; Ryzen 5 5600, 32 GB; Windows 11 Pro 26300; rustc 1.100.0 x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.
  • cargo test --workspace -- --test-threads=4 at c237ebb: 742 passed, 0 failed, 41 ignored; no SKIPPED lines (both GPU sampling tests ran).

Regression run

The gpu: line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log names backend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM).

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1568 (PresentX 1568)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18276 MB

PR:

xcl-smoke v1
commit: c237ebb55c19620d16a97372a8ec1993bd7a22eb
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1571 (PresentX 1571)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18123 MB

Not tested

  • Whether the retail title's samplers use aniso point. S#s are runtime data, so a shader pack doesn't show them. The run above checks only that nothing else changed.
  • NVIDIA.

AI use

  • Claude Code with Claude Opus 5.5:
    • a sub-agent found the mismatch in an audit of desc.rs against Mesa's register database;
    • I checked the enum and radv_tex_filter in Mesa's sources;
    • Claude Code wrote the change, the tests and this description.
  • The runs above were made on my machine.

🤖 Generated with Claude Code

**@⁠emirduran707** on GitHub · 2026-11-24 11:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/1117) `emirduran707:sampler-aniso-point` → `main` · +32 −8 · 3 files · 1 commits · merged 2026-11-25 10:57 UTC An S#'s `XY_MAG_FILTER` / `XY_MIN_FILTER` are 0 point, 1 bilinear, 2 aniso point, 3 aniso bilinear (Mesa's `SQ_TEX_XY_FILTER` enum, e.g. `src/amd/registers/gfx8.json`). A driver writes **aniso point for a nearest filter when anisotropy is on**: Mesa's `radv_tex_filter` returns `max_ansio > 1 ? V_008F38_SQ_TEX_XY_FILTER_ANISO_POINT : V_008F38_SQ_TEX_XY_FILTER_POINT` for `VK_FILTER_NEAREST`. `desc::sampler_d3d12` took every value from 2 up as anisotropic and as linear. So a point sampler with the anisotropy bits set came out as `D3D12_FILTER_ANISOTROPIC`, which is linear, or as plain linear with a ratio of 1. Lookup tables, G-buffer reads and other fetches meant to be point-sampled were blended. The HLSL the recompiler emits for implicit-LOD samples copies the same rule (`emit.rs`, "as `desc::sampler_d3d12` decides"). **What is in it** - `crates/xcl/src/gpu/desc.rs`: only aniso bilinear (3) is anisotropic, and "linear" means bilinear or aniso bilinear (bit 0). Aniso point is point. - `crates/xcl/src/gpu/recomp/emit.rs`: the same rule in the emitted HLSL. - Tests: - `decodes_ssharp` used 2 for an anisotropic filter, which encoded the bug. It uses 3 now, and checks 2 as point: with the ratio set or not, and with a linear mip filter. - `gpu_ps_image_sample_offset_implicit_lod_between_mips` is now a helper. It also runs as `gpu_ps_image_sample_with_an_aniso_point_filter_samples_points`: aniso point min / mag at a 4× ratio must give the point filter's texels. - It fails without the change on the GPU below: the samples come out blended. - Note for #540: its sampler cases labelled "aniso" use 2 for min / mag. They become point samplers with this change, which are still valid ones, so its debug-layer check is not affected. They would need 3 to stay anisotropic. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.31044.16; Ryzen 5 5600, 32 GB; Windows 11 Pro 26300; rustc 1.100.0 `x86_64-pc-windows-msvc`; DXC 1.9.2602.17; debug for the suite, release for the runs. - `cargo test --workspace -- --test-threads=4` at c237ebb: 742 passed, 0 failed, 41 ignored; no `SKIPPED` lines (both GPU sampling tests ran). **Regression run** The `gpu:` line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log names `backend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM)`. main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1568 (PresentX 1568) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18276 MB ``` PR: ``` xcl-smoke v1 commit: c237ebb55c19620d16a97372a8ec1993bd7a22eb gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1571 (PresentX 1571) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18123 MB ``` **Not tested** - Whether the retail title's samplers use aniso point. S#s are runtime data, so a shader pack doesn't show them. The run above checks only that nothing else changed. - NVIDIA. **AI use** - Claude Code with Claude Opus 5.5: - a sub-agent found the mismatch in an audit of `desc.rs` against Mesa's register database; - I checked the enum and `radv_tex_filter` in Mesa's sources; - Claude Code wrote the change, the tests and this description. - The runs above were made on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An S#'s XY_MAG_FILTER / XY_MIN_FILTER are 0 point, 1 bilinear, 2 aniso
point, 3 aniso bilinear (Mesa's SQ_TEX_XY_FILTER), and a driver writes aniso
point for a nearest filter when anisotropy is on (radv_tex_filter: NEAREST
with max_aniso > 1). sampler_d3d12 took any value from 2 up as anisotropic
and as linear, so a point sampler with the anisotropy bits set came out
D3D12_FILTER_ANISOTROPIC (linear), or linear with a ratio of 1: lookup
tables and G-buffer reads meant to be point-sampled were blended. The HLSL
the recompiler emits for implicit-LOD samples copies the same rule.

Now only aniso bilinear (3) is anisotropic, and linear means bilinear or
aniso bilinear (bit 0): aniso point is point, in desc.rs and in emit.rs.
decodes_ssharp used 2 for an anisotropic filter; it uses 3 now, and checks
2 as point. The GPU test of implicit-LOD sampling between mips runs once
more with aniso point min / mag at a 4x ratio and must give the point
filter's texels; it fails without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:43:55 +00:00
github manually merged commit c237ebb55c into gh-pr/1117/base 2026-11-26 04:43:57 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 12:04 UTC · original

Independent NVIDIA check at c237ebb, Windows 11, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11. The workspace build, descriptor test, and both pixel-readback tests passed with zero skips. I repeated the pixel tests with Graphics Tools enabled in the scratch runner. Both draws left the D3D12 info queue empty.

Keeping the new fixture, I restored the parent’s emitter alone, then its emitter and descriptor code together. Both controls reached the draw with an empty info queue and failed the pixel assertion at (0,0). Expected 26, observed 25.75 with the older emitter alone and 6.904297 with both older files.

Synthetic inputs only. AI-assisted. Codex (GPT-6) ran the tests and added the scratch validation check.

**@⁠thehollowedone** on GitHub · 2026-11-24 12:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/1117#issuecomment-7130919108) Independent NVIDIA check at [c237ebb](https://github.com/ivall/xcl/commit/c237ebb55c19620d16a97372a8ec1993bd7a22eb), Windows 11, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11. The workspace build, descriptor test, and both pixel-readback tests passed with zero skips. I repeated the pixel tests with Graphics Tools enabled in the scratch runner. Both draws left the D3D12 info queue empty. Keeping the new fixture, I restored [the parent’s](https://github.com/ivall/xcl/commit/47efa2ecea0a12934719ae69b81930cf02a4b1c3) emitter alone, then its emitter and descriptor code together. Both controls reached the draw with an empty info queue and failed the pixel assertion at (0,0). Expected 26, observed 25.75 with the older emitter alone and 6.904297 with both older files. Synthetic inputs only. AI-assisted. Codex (GPT-6) ran the tests and added the scratch validation check.
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-24 12:06 UTC · original

Thanks @⁠thehollowedone, that also confirms that both halves are needed (the emitter alone still blends at 25.75).

The failed CI run is a timing flake outside this change: hle::kernelx::tests::fine_timer_makes_short_sleeps_short measured Sleep(1) at 5.198 ms against its 5 ms limit on the runner (job log of run 45388910570). It passes locally, and this PR doesn't touch kernelx or the timer. Could a maintainer re-run the job? I can't from a fork.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠emirduran707** on GitHub · 2026-11-24 12:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/1117#issuecomment-7130986832) Thanks @⁠thehollowedone, that also confirms that both halves are needed (the emitter alone still blends at 25.75). The failed `CI` run is a timing flake outside this change: `hle::kernelx::tests::fine_timer_makes_short_sleeps_short` measured `Sleep(1)` at 5.198 ms against its 5 ms limit on the runner (job log of run 45388910570). It passes locally, and this PR doesn't touch kernelx or the timer. Could a maintainer re-run the job? I can't from a fork. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠throny on GitHub · 2026-11-24 12:27 UTC · original

Test run of c237ebb on NVIDIA Ada, merged onto main 47efa2e (clean merge): pass.

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17 (Windows SDK 10.0.26100.0); debug. XCL_SAMPLE_* unset.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored (lib: 699 / 0 / 21), first run.
  • SKIPPED on this adapter: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).
  • The new gpu_ps_image_sample_with_an_aniso_point_filter_samples_points runs on the GPU here and passes, as does the existing implicit-LOD test it shares its body with.

Not tested

  • A retail title with this change (no smoke run from me); AMD / wave64 hardware; the new test against main's code (no negative control).

AI use

  • Claude Code (Claude Fable 5.2) read the diff, ran the suite and wrote this report.
**@⁠throny** on GitHub · 2026-11-24 12:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/1117#issuecomment-7131473312) Test run of `c237ebb` on NVIDIA Ada, merged onto `main` `47efa2e` (clean merge): pass. **Tested** - Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 `stable-x86_64-pc-windows-msvc`; DXC 1.9.2602.17 (Windows SDK 10.0.26100.0); debug. `XCL_SAMPLE_*` unset. - `cargo build --workspace && cargo test --workspace -- --test-threads=4`: 742 passed, 0 failed, 41 ignored (lib: 699 / 0 / 21), first run. - `SKIPPED` on this adapter: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64). - The new `gpu_ps_image_sample_with_an_aniso_point_filter_samples_points` runs on the GPU here and passes, as does the existing implicit-LOD test it shares its body with. **Not tested** - A retail title with this change (no smoke run from me); AMD / wave64 hardware; the new test against `main`'s code (no negative control). **AI use** - Claude Code (Claude Fable 5.2) read the diff, ran the suite and wrote this report.
Author
Owner

@⁠JoaoPauluu on GitHub · 2026-11-24 13:56 UTC · original

A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. c237ebb as it is (based on 47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).
  • gpu::recomp::tests::gpu_ps_image_sample_with_an_aniso_point_filter_samples_points: ok, no SKIPPED.

Not tested

  • whether the new test fails without the fix on this stack; the rest of the suite on this head; native Windows; AMD / native wave64.

AI use

  • Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
**@⁠JoaoPauluu** on GitHub · 2026-11-24 13:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/1117#issuecomment-7133584108) A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `c237ebb` as it is (based on `47efa2e`), no uncommitted changes. The lib test binary runs under Wine, one test per process (`--exact`). - `gpu::recomp::tests::gpu_ps_image_sample_with_an_aniso_point_filter_samples_points`: **ok**, no SKIPPED. **Not tested** - whether the new test fails without the fix on this stack; the rest of the suite on this head; native Windows; AMD / native wave64. **AI use** - Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
Author
Owner

@⁠wanchudao on GitHub · 2026-11-24 15:42 UTC · original

Tested — c237ebb on Windows 11 Pro build 26300, RTX 3070 Ti (driver 610.88),
rustc 1.100.0, MSVC 14.44.35207, and DXC 1.9.2602.17.

cargo test -p xcl --lib gpu_ps_image_sample_with_an_aniso_point_filter_samples_points -- --nocapture

Result: 1 passed, 0 failed, 0 ignored, 719 filtered out. The test's GPU guard reports
an early return as SKIPPED. The log has no such line. This adds an RTX 3070 Ti run
of the synthetic sampler test.

Not tested — AMD hardware or whether this filter is selected in a retail run.

AI use — DeepSeek Harness (DeepSeek V4.1 Flash) ran the test and drafted this report.
OpenAI Codex (GPT-6.2 Sol) checked the archived result and revised it.

**@⁠wanchudao** on GitHub · 2026-11-24 15:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/1117#issuecomment-7136465952) **Tested** — c237ebb on Windows 11 Pro build 26300, RTX 3070 Ti (driver 610.88), rustc 1.100.0, MSVC 14.44.35207, and DXC 1.9.2602.17. `cargo test -p xcl --lib gpu_ps_image_sample_with_an_aniso_point_filter_samples_points -- --nocapture` Result: 1 passed, 0 failed, 0 ignored, 719 filtered out. The test's GPU guard reports an early return as `SKIPPED`. The log has no such line. This adds an RTX 3070 Ti run of the synthetic sampler test. **Not tested** — AMD hardware or whether this filter is selected in a retail run. **AI use** — DeepSeek Harness (DeepSeek V4.1 Flash) ran the test and drafted this report. OpenAI Codex (GPT-6.2 Sol) checked the archived result and revised it.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 08:15 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 08:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1117#issuecomment-7156814131) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠iGoldenNinja on GitHub · 2026-11-25 11:24 UTC · original

Independent RTX 5080 before/after on the merge, Windows 11 Pro 25H2 (26200.9974), NVIDIA driver 617.14, Rust 1.98.1, DXC/DXIL 1.9.2609.5. On first parent c55ba167295333c81b7024a307e654ec818c475f with only the sampler tests copied, the aniso-point fixture failed on actual GPU readback at (0,0), returning 6.904297 for 26. Clean f087b998d0d51a9f11bbfa0761967a63e778edd9 passed all 256 pixel checks, the ordinary implicit-LOD sampling control and the S# decoder. GPU cases ran without skips. Last verified stage was synthetic D3D12 pixel readback. Pinned report

**@⁠iGoldenNinja** on GitHub · 2026-11-25 11:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/1117#issuecomment-7160997316) Independent RTX 5080 before/after on the merge, Windows 11 Pro 25H2 (26200.9974), NVIDIA driver 617.14, Rust 1.98.1, DXC/DXIL 1.9.2609.5. On first parent `c55ba167295333c81b7024a307e654ec818c475f` with only the sampler tests copied, the aniso-point fixture failed on actual GPU readback at (0,0), returning **6.904297** for **26**. Clean `f087b998d0d51a9f11bbfa0761967a63e778edd9` passed all 256 pixel checks, the ordinary implicit-LOD sampling control and the S# decoder. GPU cases ran without skips. Last verified stage was synthetic D3D12 pixel readback. [Pinned report](https://github.com/iGoldenNinja/xcl-shader-checks/blob/e6793d0a5241ca27bcc522e73005cb4c280446f0/observed/f087b998-5080.md)
This discussion has been locked. Commenting is limited to contributors.
No description provided.