Skip to content

[upstream #1117] Recompiler: an aniso point sampler filter samples points, not linearly - #42

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1117
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1117

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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 Tests: verify desc::image_d3d12 and sampler_d3d12 against D3D12 xcl-dev/xcl#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


Mirror of xcl-dev#1117 (auto-synced, do not edit).

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 <noreply@anthropic.com>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1117 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1117 branch November 25, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants