compute: lower gfx1013 buffer_load_format from the descriptor format #2142
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2150"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-25T01:44:53Z.
Refs #2022 (item A, first slice, as scoped in this comment)
Summary
compute_store_aotrefused gfx1013buffer_load_format_*. It now reads the t0 format at run time from V# word 3, the same way the descriptor-format stores (#1542) read theirs.Format input: a ready
s_buffer_loadconstant word, named once per formatted load with--load-format-constant, in program order.Decode: one HLSL function,
load_descriptor_format(formatWord, addr, channels). It accepts the same fixed bits as the stores (the GFX10 identity0x01000FACand the legacy identity0x00000FAC) and the same formats:8_8_8_8_UNORM,16_16_UNORMand10_10_10_2_UNORM;16_16_FLOATand16_16_16_16_FLOAT;Conversions: all integer arithmetic, so the result does not depend on the GPU's float division.
x / (2^n - 1), rounded to nearest even binary32 by long division.max(x / 32767, -1), rounded the same way.Whether the RDNA buffer-format unit rounds the same way is not verified.
Invalid loads publish nothing (per the review on #2022). A load is valid only when its opcode reads exactly the format's channel count, the format is handled, and the fixed bits are an identity value.
load_descriptor_formatreports that validity. Every load is staged before the first store, and if any load is invalid the invocation returns before storing. The format words are uniform constants, so the whole dispatch leaves u0 unwritten, and zero data from a valid read stays distinguishable from a refusal.Still refused:
d16_forms (I dropped them from the slice the comment described);offen, a missingidxen, a misaligned offset, and a read that leaves the stride;--source-format, and a missing, unready or unused format word.Not in this PR: the descriptor is still the static t0 binding. Taking it from the heap at run time is slice 2, so the programs counted in #2022 are not unblocked yet.
Harness: a
--compute-store-casefile may now end with 320 t0 words (tests/compute_check.cpp). Without them, t0 keeps its generatedinput_word(i)words, so existing cases are unchanged.Fixture
compute_store_aot_descriptor_load_format_{warp,hardware}andcompute_load_format_controls(tests/compute_load_format_check.py).Program: source-built gfx1013 assembly in LLVM 15 spelling. A group of four makes fourteen loads from an 80-byte t0 record into a 120-byte u0 record: one per format kind plus two legacy words, each with its matching opcode width.
Inputs: threads 0 to 3 carry chosen edge values:
1/65535;Threads 4 to 7 are pseudo-random.
Reference: a Python model that rounds with
Fraction.Readback: all 320 words for one group and for two.
Invalid formats: four runs each make one load invalid, and each must leave all 320 words at the sentinel:
8_SNORM;xyzopcode on32_32_32_32_UINT;xyopcode on32_FLOAT;DST_SEL.On those runs, a reference that publishes zeros for the invalid load must fail, and so must one with the D3D (0, 0, 0, 1) fill for the
xyopcode.Negative controls:
2^n, and a truncated UNORM;controlsfails.LLVM 15: assembles the fixture.
lowerof the disassembly and the CLI output both matchlowerof the source.Results
Run at
f3a6819(on38fa531), Windows 10 build 19045, debug layer enabled, 0 debug errors and 0 debug warnings on every dispatch.tests/compute_load_format_check.py drawOther checks:
tests/compute_load_format_check.py binarywith LLVM 15 (llvm-mc -mcpu=gfx1013): pass.tests/compute_load_format_check.py controls: pass.tests/compute_store_check.py binarywith LLVM 15: pass.tests/compute_store_check.py draw-descriptor-store-formaton WARP: pass. It uses the 16-constant case form.tests/compute_alu_xor3_check.py drawon WARP: pass.form_coverage_check,docs_links_check,bidi_controls_checkandshader_census_check: pass.CTest at
f3a6819. The pull-request CI uses theprsmoke preset, which does not run these tests, so this local output is the readback evidence:Each draw run ends with
descriptor_load_format: 6 dispatches, 13 wrong references and 11 mutated sources checked.No capability skips. The first WARP run took 46 s, so the new tests have a 120 s timeout.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:09:06Z.
Review: COMMENTED
Review of head
95d75de097(comment only).Scope read:
tools/compute_store_aot.py(newdescriptor_load_hlsl, load lowering,--load-format-constant),tests/compute_check.cpp(optional t0 source words),tests/compute_load_format_check.py, CMake/CI wiring, docs.Commands run locally (Linux, worktree at the head SHA):
git diff --stat origin/main...HEAD: 8 files, +644/-9.python3 -B tests/compute_load_format_check.py controls: passes.python3 tests/docs_links_check.py: self-test passed, 18 files, 399 links.python3 tests/bidi_controls_check.py: 1438 files, no bidi controls.git diff --check origin/main...HEAD: clean.gh pr checks 2150: Linux checks, fixture assembly and "Build and test on Windows" pass; /O2 and chart publish skipped; PR is MERGEABLE, title is neutral.Mutation (local, reverted with
git checkout -- .):descriptor_ratio(r != 0u || odd->odd) and snorm16 clamp (<= -32767->< -32767):controlsstill passes. That is expected, sincecontrolsonly inspects translation text. These mutations can only be caught by thecompute_store_aot_descriptor_load_format_<adapter>GPU readback, which has its own mutation list. I did not rerun that on Win2025.Findings:
compute_store_aot_descriptor_load_format_*test by name. Please paste the WARP ctest line in the PR body so the readback evidence is checkable.descriptor_snorm16_load(uint half)reuseshalfas a parameter name. It matches the existingdescriptor_rmw16usage and compiles, but a different name would be safer.main(), thedescriptor_format_constant=andrsrc2=lines have lost their indentation. This is cosmetic, not a behaviour change.Notes: the whole-dispatch suppression on an invalid format is documented in the docstring and
docs/experiments.md, and the unused-constant and not-ready-constant checks fail closed. I found no clean-room concerns; sources cited are public AMD ISA docs.Not run: Win2025 WARP/GPU proof (relying on the PR's stated results and the green Windows CI job).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:20:16Z.
Review: COMMENTED
Review of head
f3a6819f6b681edad9c4ab3efbb37638dc9d0e53. P1=0, P2=0.Checked
descriptor_ratio: the long division gives exponent126 - lead, 24 mantissa bits plus one round bit, and stickyr != 0. Ties go to even and a carry reaches the exponent. The loop runs at most 41 of its 48 steps for d < 2^16, so it always finishes.descriptor_half: the denormal exponent istop + 103and the mantissa shift is23 - top. Inf and NaN payloads are preserved.(int)(x << 16) >> 16.returnsuppresses every store, as agreed on #2022.Commands run locally
python3 tests/compute_load_format_check.pyprinted nothing and exited 0.python3 tests/docs_links_check.py: 18 files, 399 links.python3 tests/bidi_controls_check.py: clean.git diff --check origin/main...HEAD: clean.Mutations
126uto125u, dropped the sticky bit in the rounding, and SNORM clamp<= -32767to< -32767.controlsmode exited 0 for all three. It never runs the HLSL, so only the Windowsdrawmode can catch them.compute_store_aot_descriptor_load_format_*is wired into CTest andwindows.yml.win2025helper refused ("PowerShell -EncodedCommand length (22904 chars) exceeds Windows cmd.exe 8,191-char limit"). The Windows job on this head is green. I could not confirm from here that the WARP test ran rather than hit its skip code (77).Nits
tools/compute_store_aot.py, read-bounds check:read_bytes = 4 * componentsrejects a load whose real footprint is smaller. For example,8_8_8_8xyzw at offset 0 uses 4 bytes but needs 16 insidesource_stride. This is safe (it only refuses), but it is stricter than the format. A one-line comment would help.controlsmode checks only the Python reference, so it can't catch HLSL regressions. A sentence indocs/experiments.mdsaying so would avoid false confidence.The PR body says the RDNA buffer-format unit's rounding is unverified, and I agree that is the open risk.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-25T02:17:07Z.
@tedin7 thanks for the review. All three nits are addressed in
f3a6819:prsmoke preset, which doesn't include this test, so the description now carries the local CTest output for the controls and both adapters.halfparameter:descriptor_snorm16_loadnow takesbits16.main(): the twolower()argument lines are indented like the rest of the call.No behaviour change. Controls, the LLVM 15 round trip and both readbacks pass again.
On the two mutations you noted (the tie rule in
descriptor_ratioand<= -32767to< -32767), neither can change a result here:x / dnever ends in an exact binary tie.-32767 / 32767is exactly -1.0 either way.The GPU mutation list therefore covers rounding with the never-rounds-up form, and SNORM with the sign and divisor forms.