Repository navigation
d16 image_sample_lz and image_gather4_lz on 2D_ARRAY and CUBE round by the T# format (BUILD-1916) - #6264
d16 image_sample_lz and image_gather4_lz on 2D_ARRAY and CUBE round by the T# format (BUILD-1916)#6264BetterJdue wants to merge 3 commits into
Conversation
…ADER-308 follow-up) Review on ItsNotRexed#4318: image_sample_lz and image_gather4_lz with d16 on 2D_ARRAY and CUBE images read the float view directly, not through image_read_typed, and still rounded every float-class result to nearest even. They now narrow through Gen.d16_fmt_pair: Gen.d16_norm_f16 with the T#'s format class (Gen.fmt_float_flags), the rule the 2D reads use (UNORM/SNORM: the exact quotient rounded once; 32_FLOAT: toward zero). tools/d16_image_probe.py --dims 2d_array,cube measures those reads on the hardware (image_load, point image_sample_lz, image_gather4_lz; f32 and d16; UNORM16, SNORM16, 32_FLOAT, 16_FLOAT; wave32 and wave64). On an RX 6700 (gfx1031) they follow the same rule as 2D on every lane and gather tap. tests/semantic/test_image_d16_rounding.py checks the format tables and that every d16 half of the 2D reads and of these array and cube forms goes through Gen.d16_norm_f16. runtime/test/shaders/ps_d16_array_sample.asm and ps_d16_cube_sample.asm run the translated forms on a GPU through new vk_texture_test d16_array / d16_cube modes (the 12-layer array in R32_SFLOAT, R16_UNORM or R16_SNORM), every d16 half checked. docs/design.md: the 32_FLOAT tie is narrowed toward zero, not to even; the leftover "still inferred" sentences go; the array and cube forms and what checks the image path are listed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested Ran For the A/B control, I translated the same synthetic inputs with AI-assisted verification and reporting. All fixtures and inputs were synthetic. |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
Follow-up to #4318: tools/rdna2spirv.py now routes d16 image_sample_lz and image_gather4_lz on 2D_ARRAY/CUBE images through the new Gen.d16_fmt_pair (Gen.d16_norm_f16 with T# format class from Gen.fmt_float_flags), so 32_FLOAT narrows toward zero and UNORM/SNORM halfway quotients round once. Adds tests/semantic/test_image_d16_rounding.py, new array/cube shader fixtures and vk_texture_test d16_array|d16_cube modes, extends tools/d16_image_probe.py --dims 2d_array,cube, and updates docs/design.md.
Why merge
Closes a real rounding mismatch (e.g. 32_FLOAT 0x3f7ff001 gave 0x3c00 instead of 0x3bff) on array/cube d16 reads, bringing them in line with the already-correct 2D path and measured hardware.
Verdict: Approve
SummaryFollow-up to #4318: Why mergeCloses a real rounding mismatch (e.g. 32_FLOAT Verdict: Approve |
|
Tested
|
Conflicts: docs/design.md (the d16 row: keep main's removal of the duplicated sentences, keep this branch's 2D_ARRAY/CUBE text) and runtime/test/vk_texture_test.cpp (keep both the fetch-* and the d16_array/d16_cube modes).
Conflict: docs/design.md. ItsNotRexed#6828 dropped the whole "d16 and f16 format narrowing" contract row, which this branch edits and docs/shader_validation.md still points to; keep the row.
|
Merged
Re-tested
AI-assisted verification using synthetic inputs. |
Claimed in the coordination issue as: BUILD-1916 (claim)
What and why
Follow-up to #4318, from @kacper-serewis's review. #4318 made the d16 image reads that go through
Gen.image_read_typednarrow by the T#'s format. Onmain561b65a8, d16image_sample_lzandimage_gather4_lzon 2D_ARRAY and CUBE images read the float view directly and still packed with nearest even (pack_f16_pair_int): a 32_FLOAT0x3f7ff001read0x3c00instead of0x3bff, and the UNORM/SNORM halfway quotients were not corrected.tools/rdna2spirv.py: those forms narrow through the newGen.d16_fmt_pair, which isGen.d16_norm_f16withGen.fmt_float_flagsof T# word 1, the rule the 2D reads use (UNORM/SNORM: the exact quotient rounded once; 32_FLOAT: toward zero). Other ops and dimensions are unchanged.tools/d16_image_probe.py --dims 2d_array,cube: measures 2D_ARRAY and CUBEimage_load, pointimage_sample_lzandimage_gather4_lz, f32 and d16, throughtools/hw_oracle. Four array layers, all six cube faces. Each gather tap's texel is identified from the f32 gather of the same footprint, so the tap order and face edges don't matter.tests/semantic/test_image_d16_rounding.py: the CPU-side translator test asked for on d16 image results round like typed buffer loads, and 32_FLOAT truncates (SHADER-308) #4318. It checks the T# format tables (Gen.float_format_masks) and that every d16 half of the 2D reads and of the 2D_ARRAY/CUBE sample and gather goes throughGen.d16_norm_f16, then runsspirv-valon the modules.runtime/test/shaders/ps_d16_array_sample.asm,ps_d16_cube_sample.asmand the newvk_texture_test d16_array|d16_cube f32|unorm16|snorm16modes run the translated forms on a GPU. The 12-layer array at binding 3 is in R32_SFLOAT, R16_UNORM or R16_SNORM, and the T# carries that format. Every d16 half (one sample and three gather taps per pixel) is checked against the measured rule.scripts/run_gpu_tests.pyruns both fixtures in all three formats.docs/design.md("d16 and f16 format narrowing"):0x3f7ff000tie is now described as narrowed toward zero, not to even.Tested
AMD Radeon RX 6700 (gfx1031, discrete RDNA2), AMD Windows driver 32.0.21045.29003 (Vulkan
driverInfo26.11.2), Windows 11 Pro 26300. Basemain561b65a8.Hardware (
python -I tools/d16_image_probe.py --dims 2d_array,cube, wave32 and wave64, 0 words differ between them):0x3f7ff001gives0x3bff0x3f7ff001gives0x3bffSo the array and cube reads follow the 2D rule exactly. The f32 controls held (the f32 load is the texel's f32, the point sample equals the load).
Translated, on the same GPU through Vulkan (
python -I scripts/run_gpu_tests.py --filter ps_d16):tools/rdna2spirv.pyfrommainps_d16_array_sampleps_d16_cube_sampleThe 768 texels hold 56 f32 halfway points (or the 2 UNORM16/SNORM16 halfway values) plus others. Every module passes
spirv-val.CPU:
test_image_d16_rounding: 8/8. Withmain's translator the 5 array/cube cases fail. With the translator from before d16 image results round like typed buffer loads, and 32_FLOAT truncates (SHADER-308) #4318 (00b9b568), 7 of 8 fail.tests/test_d16_image_probe.py: 21/21, two of them on the hardware.tests/test_run_gpu_tests*.py: 68/68.561b65a8without the patch:python -m unittest discover -s tests/semantic: 6,158 vs 6,150 tests, OK on both.pytest tests/test_translate.py: 635 vs 633 passed (the two new fixtures).tests/test_rdna2_decode.py's llvm-mc parity fails onmaintoo (cs_w32_permlane_fi.asm,op_sel), not on these fixtures.Not run: the shader corpus (no game files here), the full GPU suite, and the other sample kinds on these dimensions (
image_sample_l, ...), which still use the generic rule and are not measured.Not changed, noted: on the hardware, a dmask
0x1d16 point sample on 2D_ARRAY/CUBE keeps the VGPR's high half (65,536/65,536 lanes), as the 2D reads do. The generic sample path here writes the whole VGPR (high half 0), so that is still the case after this change.AI-assisted: yes
Checklist
docs/design.md, with how it was confirmed.AI-assisted verification using synthetic inputs.