Commit Graph

4 Commits

Author SHA1 Message Date
4945add25f rdna2spirv: typed stores follow the hardware (f16 toward zero, one NORM rounding, two-component routing), all 77 codes
@AwkGrep256 ran tools/buffer_format_fuzz.py on a real RDNA2 (gfx1036, #2022): the same totals as the
Radeon 880M, 0 mismatches, and 199,144 elements of the 14 GFX10-only codes, also 0. This follows both.

- 16_FLOAT, 16_16_FLOAT and 16_16_16_16_FLOAT format stores round toward zero, saturate at +-65504 and
  keep a NaN a NaN (Gen.ufloat_encode_bits, now with an optional sign). d16 data rounding (#1759) is
  not touched.
- Every UNORM, SNORM and SCALED store rounds the exact product once (Gen.norm_encode_exact): 0.3 *
  65535 stores 19661, not 19660.
- A two-component format stored through a V# takes channel y as its second component when DST_SEL_Y is
  Y and DST_SEL_Z a constant (the runtime's X,Y,0,1: gfx1036 narrow-integer fixtures, gfx1150), and
  channel w otherwise (identity XYZW, @AwkGrep256 and gfx1150); _xy then writes (x, 0). tbuffer keeps
  (x, y). A probe with XYZW alone would have shown (x, w) for every V# and broken the runtime's
  selectors, which the oracle now also covers (XY01 runs for the two-component formats).
- Gen.FORMATS has all 77 codes: 30-35 and 37-42 (10_11_11 and 11_11_10 with UNORM..SINT) join.
- buffer_format_fuzz: the model has one store route per path, select_formats runs all 77 codes by
  default on a GFX10 device, the known-difference count is gone (0 on the 880M).

The three expectedFailure tests pass; the fixtures that baked the old behaviour (cs_fmt_sint32, test_translate
f16 and int32 store tests, test_value_semantics) take the measured words. Sizes: cs_store 206 KB on
main, 125 KB here.

Co-Authored-By: AwkGrep256 <AwkGrep256@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 17:55:37 +01:00
357945f455 test_tbuffer_store: BUF_FMT_8_USCALED is supported now; use a code that still is not
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 16:33:44 +01:00
227087d250 Fix what the merge round broke: vk_pipeline_check --isolate-batch, its CLI test, a tbuffer format example
- vk_pipeline_check.cpp: #1826's --isolate-batch parsed with the val() helper #1735 replaced, so the checker
  didn't build; it now uses number() like the other options.
- check_vk_pipeline_cli.cmake (#1735) matched "malformed JSON"; #1847's index parser names the file and position
  ("index.json: expected '{' at byte 0"), which the check now matches.
- test_tbuffer_store: BUF_FMT_8_UINT stopped being an unsupported example once #1871 added the 8/16-bit UINT/SINT
  formats; it uses BUF_FMT_8_USCALED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:06:43 -05:00
cd6e21be84 Translator: tbuffer_store_format_* with the instruction's format
tbuffer_store_format_* and its d16 forms were Unsupported, though every
tbuffer_load_format_* form translates. They now go through buffer_store
with the instruction's format, as the loads go through
buffer_load_format:
- only that format is encoded, with no branch on the V#'s FORMAT;
- the bounds check uses its element size;
- a V# whose FORMAT is 0 (INVALID) still disables the store, as measured.
  (@Vonsek covers the MTBUF loads and @opit80 the raw MUBUF accesses
  through such a V#.)

The format parsing the loads did inline becomes mtbuf_format(), shared by
both: no modifier is GFX10's default BUF_FMT_8_UNORM, and a format
FORMATS has no encoder for stays Unsupported. read_before_write_vgprs
now counts a tbuffer store's data VGPRs as reads, as for buffer_store.

cs_tbuffer_store.asm stores into 13 sentinel-filled regions through V#s
whose format differs from the instruction's or is 0, and reads them
back. Every
expected word was measured by running the same body natively on a
Radeon 680M (gfx1035, RDNA2); wave32 and wave64 gave the same 52 words:
- the instruction's format decides the encoding, the element and the
  bounds;
- components the format has but the store doesn't give are 0, and extra
  ones are dropped;
- the default format is one byte, and its neighbours are kept;
- a FORMAT-0 V# leaves the region untouched.

check.py and run_gpu_tests.py compare the dump. The semantic fixture
runs through the interpreter in tests/semantic/test_tbuffer_store.py,
which fails on the old translator (Unsupported). It also fails on
versions that take the bounds from the V#'s element (5 words differ),
take the format from the V#, fill missing components with anything
but 0 (1 word), or drop the FORMAT-0 guard (2 words).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:33:18 +02:00