Recompiler: D16 image reads of UNORM / SNORM texels round once to nearest #2030
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2030
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2030"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@upipibi on GitHub · 2026-11-25 01:16 UTC · original
upipibi:fix/image-d16-norm-single-round→main· +573 −26 · 5 files · 5 commits · openKnown: this PR's D16 normalization uses a 64-bit divide (
d16_fmtindxil/lower_mem.rs,norm16_repinrecomp/emit.rs), so every shader with a D16 load declares Int64 (SFI00x8000) in both backends. A 32-bit fix with tests is onupipibi/xclbranchfix/d16-norm16-no-int64(af15e87, one commit on #2027's head; RTX 3070:gpu_buffer_d162/2 withXCL_DIRECT_DXIL=0and=1, lib suite 1170 passed, 0 failed; a no-GPU test checks that the Int64 flag is clear for all 20 UNORM / SNORM D16 buffer and tbuffer loads). It isn't pushed here because a push needs a new title smoke pair, which I can't make. On this PR it cherry-picks with one doc-comment conflict inlower_mem.rs; #2030's image D16 path uses the same helpers.Stacked on #2027: the commits from
Recompiler: D16 image reads …on belong to this PR. It uses #2027'sd16_fmt/norm16_rep. Part of #2026.image_load,image_sample*andimage_gather4*withD16=1packed each channel withf32tof16of the f32 the view returned. That's rounded twice, and on D3D12 the second time toward zero. RDNA2 roundscode / (2^w − 1)once, to nearest even (boykopovar/AnyPS5#22750 measured all 256 8-bit codes on gfx1036). So 123 of the 256 8_8_8_8_UNORM codes came back one unit in the last place low: code 9 gave0x2884, where RDNA2 gives0x2885.What is in it
dxil/lower_image.rs: the T#'s format info (FMT_INFO[min(fmt, 77)]) is read once per image instruction. The D16 float channel of a sample or gather, a load, and an MSAA load goes throughLw::d16_fmtwith its component. A gather's four values all belong to the one component DMASK names.recomp/emit.rs: the same in the HLSL path ({t}_finfo, andd16_fmtin thef16/ loadhalfclosures).recomp/tests.rs:gpu_image_d16_loads_of_unorm8_round_oncecovers all 256 codes of a 64×1 8_8_8_8_UNORM texture against exact single rounding.Formats whose components have different widths (2_10_10_10, 5_6_5) use the width of the channel in the result's position. With a T# swizzle that reorders them, that can be the wrong width. Uniform formats (8_8_8_8, 16_16, …) are exact either way. Float texels are unchanged, since D3D's truncation already matches RDNA2's toward-zero packing of 32-bit float texels.
2d4b3a5: D16 samples whose sampler can filter (linear/anisotropic min or mag, or linear mip; S# word 2, static samplers decided at translation time) keep the host's blended value, packed withf16_rtz; gathers, point samples and loads keepd16_fmt. The HLSLimage_get_lodD16 result goes back tof32tof16. Testgpu_image_d16_filtered_samples_keep_the_blend(review by WebIdentity1 / raylitebull).c4ed6ae: the same rule in the two direct-DXIL paths #1951 added, which still packed D16 with plainf32_to_f16.mimg_gather4_lod(image_gather4_l) packs each tap withd16_fmt.mimg_unorm_sample(UNORM=1samples) uses the same filter decision as the normalized path, now shared asd16_filters/d16_sample. The HLSL path already gave the rightgather4_lvalues (a level-0Gatherthroughd16_fmt) and doesn't translateUNORM=1samples. Tests:gpu_image_d16_gather4_l_of_unorm8_rounds_once(both paths, 1024 taps over all 256 codes) andgpu_image_d16_unnormalized_samples_round_texels_once(direct path; point sampler on all 256 codes, bilinear equalsf16_rtzof the f32 sample).Tested
c4ed6ae, RTX 3070 (616.56): before the commit, the direct path fails both new tests (498 of 1024 gather taps and 123 of 256 point codes one unit low, e.g. code 9 gives0x2884, want0x2885); the HLSL path passes the gather test. After it,d16tests 10 of 10 withXCL_DIRECT_DXIL=0and=1;gpu_suite (--skip gpu_sparse_vram) 149 passed, 0 failed, 1 ignored on both paths.0d5c2f6(rebased ontomain426a5a74, the firstmainwith green CI after5478c4a7, whose two failing tests main fixed in0d13b071), RTX 3070 (616.56):gpu_suite (--skip gpu_sparse_vram) 147 passed, 0 failed withXCL_DIRECT_DXIL=0and with=1.main426a5a74gives 143 passed on both. Main's image_load-after-store path (#2156) goes through this PR's D16 conversion too.2d4b3a5, RTX 3070 (616.56): the new filtered-sample test fails ondb52da7(126 of 128 values: 0x3804 where 0x3800 is right) and passes with the fix, on both paths;d16tests 8 of 8 on both paths;gpu_suite: 136 passed withXCL_DIRECT_DXIL=0; with1, 135 passed and 1 failed:gpu_image_get_resinfo_1d_array, which fails onmaintoo (#2046). CI Build and test: passing.2d4b3a5, AMD Radeon RX 6800M (RDNA2, native wave64), driver 30.0.13002.13003, run by luckyteagirl (comment):gpu_image_d16_filtered_samples_keep_the_blendpasses withXCL_DIRECT_DXIL=0and1. Withrecomp/emit.rsanddxil/lower_image.rstaken fromdb52da7, it fails on each backend with 126 of 128 checks differing (63 heap trilinear and 63 static bilinear lanes).gpu_image_d16_loads_of_unorm8_round_oncealso passes on both backends (atdb52da7and with direct DXIL at2d4b3a5).main5ce558f(rebased; #1947 now keys the translated cache on thegpu/dxilsources, so there is noTRANSLATOR_VERSIONbump):maingives 123 of 256 one ULP low withXCL_DIRECT_DXIL=0and1. This branch passes with both.gpu_tests (--skip gpu_sparse_vram), with the whole stack (#2027, #2030, #2042): 135 passed withXCL_DIRECT_DXIL=0; with1, 134 passed and 1 failed,gpu_image_get_resinfo_1d_array, which fails the same way onmain5ce558f(#2046 fixes it).dxil::andbuffer_formatunits: 138 passed.Regression run
Pair for the current head
c4ed6aeagainstmain1a0bbe3, run by thehollowedone (comment, thanks): RTX 3080 Ti (621.35), stockscripts/smoke.ps1, clean release builds, 60 s offline. Pasted unedited.Earlier: Toons29's pair, comment, was for
2d4b3a5, before the rebases..Not tested
f32tof16truncates (the 3070 does); on one that rounds to nearest, all 8-bit codes come out right either way. Not covered by GPU tests: the static-sampler branch ofUNORM=1samples,UNORM=1gathers without a LOD,gather4_lwith compare or border colour, SNORM and 16-bit formats on these two paths.2d4b3a5), so its_lzsamples keep the host's value; not checked against RDNA2.AI use
🤖 Generated with Claude Code
@nnonno91 on GitHub · 2026-11-25 01:22 UTC · original
Tested
Independent Windows/D3D12 check on exact head
2d941f0c62772661a3c844f5f7767122ee31f39e. Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62, native wave64), and GeForce RTX 5090 (32.0.16.1742, split wave64). Rust 1.100.0 x64 MSVC, DXC/DXIL 1.8.2502.11, unoptimized dev/test profiles with debug info off.cargo build --workspace --lockedpassed at the PR head.cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_image_d16_loads_of_unorm8_round_once -- --exact --test-threads=1 --nocapturepassed on each adapter withXCL_DIRECT_DXIL=0and1(1 passed, 0 failed, 0 ignored, 0 skipped per run). With only the regression test added to parentd7bd99057d01219b23acb0ec52a68d2e11e88c77, all four runs failed as expected with 123 of 256 values differing.cargo test --locked -p xcl --test d16_image_gpu_probe -- --exact d16_texture_load_sample_gather_match_exact_rounding --test-threads=1 --nocaptureused a temporary synthetic RGBA8_UNORM and RGBA8_SNORM texture, all 256 raw codes per format, and an exact CPU binary16 reference. It covered D16IMAGE_LOAD, pointIMAGE_SAMPLE_LZ, andIMAGE_GATHER4_LZfor each of the four component masks. Each 2×2 gather footprint held four copies of the same texel. All runs passed on both revisions, both GPUs, and both backends (1 passed, 0 failed, 0 ignored, 0 skipped per process). The parent probe explicitly expected the old rounding error.Counts are per adapter and backend and were identical in all four combinations.
Not tested
Linear filtering, multisampling, mixed-width formats or swizzles, real-title smoke runs, and the full workspace test suite.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) prepared and ran the temporary probe, checked the outputs, and drafted this report.
@raylitebull on GitHub · 2026-11-25 01:34 UTC · original
Confirmed two items needed on
2d941f0before merge:d16_fmtre-quantizes interpolated/filteredimage_sample*texels instead of preserving filtered half values (checking S# filter mode so point-sampled/load/gather keepd16_fmtwhile linear/mip-filtered samples keep float-to-f16 packing).main/#2027once#2027is updated (dropping the manualTRANSLATOR_VERSIONbump inkernel.rsafter#1947), clear conflicts, and add pairedxcl-smoke v1blocks forPR description.@WebIdentity1 on GitHub · 2026-11-25 01:19 UTC · original · edited 2026-11-25 02:01 UTC
Rebased-head source follow-up
Checked
0791d7ea496b5aa1a6183bea2e7f8e41ce86e11d: the rebase/source-hash change is present, but the filtered-sample gate below is still absent. HLSL's sample packing closure still unconditionally usesd16_fmt; Direct DXIL's sample result packing does too. Please retain the point/load/gather improvement while carrying the filter-aware correction through the rebase, as requested in the review. This follow-up is source inspection only; I have not rerun this new head. The fail/pass GPU evidence and candidate below remain tied to2d941f0and its overlay. Assisted by Codex (GPT-6).Confirmed a filtered-sample regression on
2d941f0c62772661a3c844f5f7767122ee31f39e, with a small filter-aware candidate below. This complements the independent load/point/gather checks above.d16_fmtreconstructs an integer normalized texel code. That is appropriate for unfiltered texels, but a linear sample need not be an original code: D3D12 linear filtering computes a weighted average. At the midpoint of black and white RGBA8_UNORM texels, both backends currently produce half 0x3804 instead of 0x3800: the filtered 0.5 has been rounded back to code 128/255. Quarter positions expose the same extra quantization.The candidate checks S# word 2 using the same min/mag/mip decoding as
desc::sampler_d3d12. Point-only samplers retaind16_fmt; if filtering can interpolate, sample results keep the priorf32tof16packing of the filtered value. Load and gather paths retain the PR's normalization fix. It does not simply revert every sample to the old packing.Tested — native Windows 10 Home 19045, Ryzen 7 7800X3D, Rust 1.98.1 MSVC, DXC 1.8.2502.11, debug. RTX 3090 driver 591.74 (split-wave64) and AMD Radeon(TM) Graphics iGPU driver 32.0.21030.2001 (native-wave64). Adapter names were printed and verified.
For each of the four GPU/backend configurations:
Fixture detail: hardware filtering is not bit-exact ideal f32 arithmetic. On the 3090 the sample near 0.75 is slightly below it, so prior toward-zero packing yields 0x39ff; AMD gives 0x3a00. The final oracle checks exact exponent rebiasing/mantissa truncation of the separately sampled f32 result, with a small f32 sanity bound. Two earlier fixture versions wrongly required ideal quarter values (first in f32, then in half) and were corrected; their NVIDIA failures are not counted as proof of this bug. The final unchanged-head comparison still fails 64/64 on both GPUs/backends.
Not tested — full workspace, retail smoke/gameplay, compile-time or memory effects, SNORM filtered samples, mip interpolation, anisotropic/reduction/comparison filters, or all native console D16 sampling rounding rules. Mixed filter modes conservatively use previous float packing when interpolation is possible. This is an adoptable candidate and failing/passing regression, not a merge-readiness claim. No source push or competing PR.
AI use — Codex (GPT-6) investigated, wrote the candidate/regression, corrected the fixture against observed GPU precision, ran native tests, reviewed the diff, and prepared this report.
Candidate and regression: 3 files, 71 additions / 2 deletions
@JoaoPauluu on GitHub · 2026-11-25 02:20 UTC · original
A run with vkd3d-proton as the host D3D12 (DXIL → SPIR-V through dxil-spirv, then the NVIDIA Vulkan driver), so the DXIL goes through a different compiler than the native-Windows runs here: this PR's test passes.
Tested
x86_64-pc-windows-gnu.7009727as it is (merge base withmain5ce558f), no uncommitted changes. The lib test binary runs under Wine, one test per process.gpu_image_d16_loads_of_unorm8_round_once: ok, not skippedgpu_buffer_d16_loads_of_16_bit_norms_round_oncepasses on this head too.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 04:12 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!
@JJAutoCompare on GitHub · 2026-11-25 01:27 UTC · original · edited 2026-11-25 04:17 UTC
Arc A770 verification of clean head
2d941f0c62772661a3c844f5f7767122ee31f39e. The checked-in D16 image-load test matched the reference FP16 value for all 256R8G8B8A8_UNORMchannel codes on both backends.Tested
cargo test --locked -p xcl --lib --no-runbuilt outside the GPU lock withCARGO_BUILD_JOBS=2,CARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0, andCARGO_PROFILE_TEST_DEBUG=0.XCL_ADAPTER=A770underL:/XclTooling/Invoke-ArcTest.ps1, using the same command for each backend setting:XCL_DIRECT_DXIL=0(HLSL/DXC), 1 passed, 0 failed, 0 ignored, 0 explicit GPU skips.XCL_DIRECT_DXIL=1(direct DXIL), 1 passed, 0 failed, 0 ignored, 0 explicit GPU skips.Not tested
Filtered sampling, gathers, MSAA, other texture formats or GPUs, buffer loads from #2027, the full suite, and retail-title smoke runs.
AI use
Codex (
gpt-6.2-sol) ran the focused test and wrote this report.Follow-up on 7009727
Tested
PR #2030 was open at
7009727951604107093a31e9bdc8775a0979a7d8. I switched the existing worktree from its initial detached revision to the live head and confirmed it was clean and detached before and after testing. The previous Arc report names2d941f0c62772661a3c844f5f7767122ee31f39e. I found no Arc fixture report for the live head before this run.STOR-WINLAB, Windows 11 Enterprise Evaluation 25H2 x64 (26200.9974), AMD Ryzen 7 3800X, Intel Arc A770 (driver 32.0.101.9175), Rust and Cargo 1.100.0 (
stable-x86_64-pc-windows-msvc, rustc0ef1bc386), DXC and DXIL 1.9.2609.5.cargo test --locked -p xcl --lib --no-runexited 0 outside the Arc mutex. Cargo used the unoptimized test profile with two build jobs, incremental compilation disabled, and dev/test debug info disabled.I ran the following command in a separate
Invoke-ArcTest.ps1 -Test { … }invocation for each setting, withXCL_ADAPTER=A770.XCL_DIRECT_DXIL=0)XCL_DIRECT_DXIL=1)The stock fixture checks all 256
R8G8B8A8_UNORMchannel codes against the expected single round to FP16. The lock logs record each setting and confirm release. The stock runner selects direct DXIL without a fallback at1and HLSL/DXC at0. Both processes log the DXC/DXIL version because the readiness check looks up DXC on either path.Raw stdout, stderr and independent exit files are under
L:/XclTooling/pr2030with stemsbuild-7009727,gpu-7009727-direct-0andgpu-7009727-direct-1. The exclusive target slot is released.Not tested
Filtered sampling, gathers, MSAA, SNORM and other formats, buffer loads, other GPUs, the broader suite, or retail-title smoke runs.
AI use
T3 Code / Codex (
gpt-6.2-sol) verified the head, ran the fixture, and wrote this report.@luckyteagirl on GitHub · 2026-11-25 05:18 UTC · original
RX 6800M focused check on the live PR head
db52da7a5ee9e77b59ae1479c99b79a4c9e9407f(clean detached worktree).Tested: Windows 11 build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (RDNA2), driver
30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. WithXCL_ADAPTER=6800MandXCL_REQUIRE_GPU=1, I rancargo test --locked -p xcl --lib -j 2 gpu::recomp::tests::gpu_image_d16_loads_of_unorm8_round_once -- --test-threads=1 --show-outputonce withXCL_DIRECT_DXIL=0and once with1.The checked-in test covers all 256 RGBA8_UNORM codes for the unfiltered image-load path. This is RDNA2 coverage for that path. I did not test filtered sampling, the issue already identified by reviewers on this head, or other formats, the full suite, or a retail title. There is no smoke block from this run.
AI use: OpenAI Codex (GPT-6, exact variant not exposed in this session) checked the live head, ran the focused GPU tests, and drafted this report.
@upipibi on GitHub · 2026-11-25 06:14 UTC · original
Thanks WebIdentity1 and raylitebull.
2d4b3a5adds the filter gate on both paths (WebIdentity1's candidate fix checked the same thing).desc::sampler_filtersreads S# word 2 the waysampler_d3d12maps it. A min or mag filter that isn't point, or a linear mip filter, can blend.f16_rtz, the truncation float channels already get sincedb52da7, so the result doesn't depend on the host'sf32tof16rounding.d16_fmt.image_get_lodD16 result had also picked upd16_fmt, which would round an LOD as if it were a texel code. It is back tof32tof16, as in the direct DXIL path.New test
gpu_image_d16_filtered_samples_keep_the_blend: an RGBA8_UNORM texture, linear samples between codes 0 and 255 through a heap sampler and a static one, plus point samples of codes 9 and 128 (0x2885, 0x3804). On an RTX 3070 (616.56) it fails ondb52da7with 126 of 128 values off on both paths (0x3804 where 0x3800 is right half way) and passes with the fix. Fullgpu_suite: HLSL 136 passed, 0 failed; direct DXIL 135 passed, 1 failed. The failure isgpu_image_get_resinfo_1d_array, which fails onmaintoo and is fixed by #2046.On the other points: this branch is stacked on #2027 and merges cleanly with
main, and it no longer changesTRANSLATOR_VERSION. Thexcl-smokepair needs a retail title, which I don't have, so that part is still open.Not tested: SNORM filtered samples, comparison or PCF filtering, anisotropic or min/max reduction, other GPUs. A sampler that is linear for minification but magnifies is treated as filtered, which is conservative.
AI-assisted (Claude Code).
@luckyteagirl on GitHub · 2026-11-25 08:43 UTC · original
RX 6800M follow-up on the updated exact head
2d4b3a5c4600b7d88ccc10ad7c6c476301143289(parentdb52da7a5ee9e77b59ae1479c99b79a4c9e9407f). This checks the filtered-sample correction added after my earlier unfiltered-load report. Final worktree is clean.Environment: Native Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M (RDNA2), driver
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5.XCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64, matchingXCL_DXC_DIR. Command form:cargo test --locked -p xcl --lib -j 2 <filter> -- --test-threads=1 --show-output.Fixed head:
gpu_image_d16_filtered_samples_keep_the_blendpassed 1/0/0 withXCL_DIRECT_DXIL=0(HLSL) and 1/0/0 with=1(direct DXIL), no explicit skips.gpu_image_d16_loads_of_unorm8_round_oncealso passed 1/0/0 with direct DXIL.Test-only negative control: I kept the new test and checked out only
recomp/emit.rsanddxil/lower_image.rsfrom parentdb52da7, then rebuilt. On this RX 6800M, the new test failed 0/1/0 on each backend. In each run, 63 heap trilinear + 63 static bilinear lanes reported differing values (126 of 128 checks), while the fixed head passed. I restored both files, rebuilt, and repeated both green filtered-sample runs above.Scope: Focused debug GPU tests. No full suite or retail-title smoke on this head; these results establish the synthetic filtered and unfiltered cases, not title-level D16 use. The negative control changes shader code shape as well as the filter gate, so it demonstrates a behavioral regression on the parent files without isolating a single emitted operation.
AI use: OpenAI Codex ran the RX 6800M tests and parent-code control, counted the mismatch lines, restored and verified the exact clean head, and prepared this report.
@Toons29 on GitHub · 2026-11-25 10:18 UTC · original
Regression run of
2d4b3a5con the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon568e7db7, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 104 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.@thehollowedone on GitHub · 2026-11-25 12:32 UTC · original
Here is the requested
scripts/smoke.ps1pair from clean release builds of main 1a0bbe3 and PR head c4ed6ae.RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC. The 60 s offline runs used separate copies of the same starting profile and DXIL seed, no input, PSO preload off, a 16 GiB job commit cap, and a 12 GiB system commit floor.
On the exact head,
cargo test --offline --locked -p xcl --lib gpu_image_d16_ -- --nocapture --test-threads=1reported 4 passed, 0 failed, 0 ignored with each ofXCL_DIRECT_DXIL=0and=1. The unnormalized-coordinate case runs only in direct DXIL and returns early in HLSL, so three fixtures executed GPU work under HLSL and four under direct DXIL.The smoke pair covers startup. AMD hardware, Wine, and world load were outside this test.
AI-assisted. Codex (GPT-6, exact variant unavailable) ran the tests and drafted this report.
@DavidM1911 on GitHub · 2026-11-26 07:05 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: 1 failure under parallel scheduling; clean on--test-threads=1rerun (1314 passed, 0 failed, 27 ignored, 90s). Intermittent single-test flake — tracked in #1978.Thanks!
— Devin
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.