Repository navigation
image_fuzz: accept the driver's one-ulp UNORM8 conversion in the translator oracle - #2988
Conversation
…slator oracle The translated image_load fetches a UNORM texel through a float view, so the 8-bit -> float conversion is the driver's. RDNA2 returns the correctly rounded c / 255; llvmpipe multiplies by an f32 1/255, one ulp above it for 126 of the 256 byte values (27: 0x3dd8d8da, not 0x3dd8d8d9). The comparison was bit exact and a run stops at its first mismatch, so on llvmpipe every run ended at its first R8G8B8A8_UNORM case and the other formats never ran. The translator oracle now accepts one ulp on a UNORM8 texel component, never on another format or on the sentinels of registers dmask leaves unwritten, and the summary counts how many components needed it. --oracle hw stays bit exact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent physical-GPU check of |
|
Tested I also ran AI-assisted |
|
Tested
The negative controls in the unit tests (two ulps, c/256, −0 for byte 0 still mismatching; float and sentinel cases staying bit exact) pin the allowance to exactly one ulp. AI-assisted (ZCode agent): builds and runs executed by a coding agent on this machine. |
On llvmpipe,
tools/image_fuzz.pynever gets past its firstR8G8B8A8_UNORMcase:The translated
image_loadis a plainOpImageFetchof a float view, so the UNORM8 → float conversion happens in the driver, not in the translated code. RDNA2 returns the correctly rounded c / 255, which--oracle hwalready checks bit for bit. llvmpipe computes c × f32(1/255) instead, which is one ulp above the exact quotient for 126 of the 256 byte values (27 →0x3dd8d8da, not0x3dd8d8d9). The translator oracle compared bit for bit, andrun_translatorstops at the first mismatch. So on llvmpipe every run ended at program 1 (5 of 5 seeds), and the other five formats never ran.Change
tools/image_fuzz.py:compare()accepts a UNORM8 texel component within one ulp of the exact quotient, with the same sign and finite. Float and integer formats stay bit exact, and so do the sentinels in registers that dmask leaves unwritten. The summary reports how many components needed the allowance.--oracle hw(compare_hw) is unchanged and stays bit exact.tests/test_image_fuzz.py: all 256 byte values as c × f32(1/255) match, with exactly 126 × 64 components counted. Two ulps, c / 256, and −0 for byte 0 still mismatch. One ulp on R32G32B32A32_SFLOAT, or on a UNORM8 sentinel, still mismatches.docs/shader_validation.md: one paragraph on the exception.Tested on llvmpipe (Mesa 26.0.8, LLVM 21.1.8, Ubuntu, no hardware GPU) at
673d3d16plus this commit (rebased onto16282101since;tests/test_image_fuzz.pypasses there too, 56 passed):python -I tools/image_fuzz.py --programs 300 --seed 9001→ before:0/1 programs that ran match; 1 mismatched. After:300/300 programs that ran match; 211536 R8G8B8A8_UNORM components one ulp from the exact c / 255 (the driver's conversion). Before the fix, the other five formats alone gave 200/200.--formats R8G8B8A8_UNORM --programs 60, seeds 1–3 → 60/60 each (before: 0/1 each).pytest tests/test_image_fuzz.py tests/test_image_fuzz_hw.py tests/test_docs_*.py tests/test_ci_registration.py→ 99 passed, 1 skipped. With onlytools/image_fuzz.pyreverted,test_compare_accepts_the_drivers_one_ulp_unorm8_conversionfails.image_fuzz.pyPRs, Require both SPIR-V modules before running the image fuzzer #2967 and image_fuzz: support --pc-tail-ubo / LEONIDA_PC_TAIL_UBO=1 on 128-byte devices #2574, are clean.Not checked: whether other drivers round this conversion the same way. I have no hardware GPU, and
--oracle hwneeds an AMD one.AI-assisted (Claude Code). GPU: llvmpipe only.
🤖 Generated with Claude Code