Repository navigation
Recompiler: an aniso point sampler filter samples points, not linearly - #1117
emirduran707 wants to merge 1 commit into
Conversation
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>
|
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. |
|
Thanks @thehollowedone, that also confirms that both halves are needed (the emitter alone still blends at 25.75). The failed AI-assisted (Claude Code, Claude Opus 5.5). |
|
Test run of Tested
Not tested
AI use
|
|
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
Not tested
AI use
|
|
Tested — c237ebb on Windows 11 Pro build 26300, RTX 3070 Ti (driver 610.88),
Result: 1 passed, 0 failed, 0 ignored, 719 filtered out. The test's GPU guard reports 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. |
An S#'s
XY_MAG_FILTER/XY_MIN_FILTERare 0 point, 1 bilinear, 2 aniso point, 3 aniso bilinear (Mesa'sSQ_TEX_XY_FILTERenum, e.g.src/amd/registers/gfx8.json). A driver writes aniso point for a nearest filter when anisotropy is on: Mesa'sradv_tex_filterreturnsmax_ansio > 1 ? V_008F38_SQ_TEX_XY_FILTER_ANISO_POINT : V_008F38_SQ_TEX_XY_FILTER_POINTforVK_FILTER_NEAREST.desc::sampler_d3d12took every value from 2 up as anisotropic and as linear. So a point sampler with the anisotropy bits set came out asD3D12_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, "asdesc::sampler_d3d12decides").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.decodes_ssharpused 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_mipsis now a helper. It also runs asgpu_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.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.cargo test --workspace -- --test-threads=4at c237ebb: 742 passed, 0 failed, 41 ignored; noSKIPPEDlines (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 namesbackend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM).main:
PR:
Not tested
AI use
desc.rsagainst Mesa's register database;radv_tex_filterin Mesa's sources;🤖 Generated with Claude Code