diff --git a/docs/design.md b/docs/design.md index ebee74ad03..e33fc6926a 100644 --- a/docs/design.md +++ b/docs/design.md @@ -462,6 +462,7 @@ How the generated SPIR-V expects the runtime to work: | Typed image stores | `image_store` (2D, 2D array, 3D, cube) writes the dmask components (missing ones = 0). The image's numeric type lives in the T# (word 1 FORMAT [28:20], 512 GFX10 formats), so it is decided at run time. A 512-bit table built from `tools/gfx10_formats.json` (30 UINT and 15 SINT formats) picks a **sint**, **uint** or **float** view (bindings 8 + 3·dim + class; dim 0 = 2D, 1 = 2D array, 2 = 3D; class 0 float, 1 uint, 2 sint). Views have Unknown format (`shaderStorageImageWriteWithoutFormat`). **The runtime binds every storage image into all three arrays of its dimension, or at least the one matching its format.** The earlier path wrote only component 0 as `r32ui`, which was wrong for every other format. GPU-checked with `runtime/test/shaders/cs_imgstore.asm` through `runtime/test/vk_store_test.cpp`: rgba8 unorm, r32 uint and r32 sint images, every texel correct. A cube storage image is bound as a six-layer 2D array (bindings 11/12/13 for float/uint/sint, `OpTypeImage ... 2D 0 1 0 2 Unknown`, `%v3int` coordinates (x, y, face)); `tfe` and `lwe` are refused. CPU-checked by `tests/semantic/test_image_cube_store_glc.py`. GPU-checked with `runtime/test/shaders/cs_imgstore_cube.asm` through `vk_store_test cube` (GPU-CUBE-STORE): rgba8 unorm, r32 uint and r32 sint cube images, each a cube-compatible 8x8 image of six layers bound through a six-layer 2D-array view at index 1-3 of bindings 11/12/13, and every texel of every face exact (the face selects the layer) on an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and a Radeon 610M (`gfx1036`, RDNA2, RADV Mesa 26.2.6), natively and under `LEONIDA_W64_EMULATE=1`; the same fixture with the face held at 0 fails on both. | | Typed image loads | A noncoherent cube `image_load` reads the 2D-array sampled binding (3) with integer coordinates and layer. Its T# format selects the float, uint or sint alias, including for D16. The [RDNA2 ISA §8.2.1](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture) assigns D16 conversion to the image format. The synthetic `cube_load_d16.asm` checks the generated views and format choices on the CPU. `image_load` on 1D/2D/2D-array/3D images uses the same T# FORMAT tables as stores, and fetches every format with `OpImageFetch` from the sampled array of its dimension (bindings 0, 3, 6, 5): UINT/SINT formats through **uint/sint aliases of that array** (same set and binding, an `OpTypeImage` of `%uint`/`%int`; Vulkan allows several variables on one binding when the descriptor type fits), everything else through the float array. A lookup miss (index 0) takes the float path, since the fallback there is RGBA8_UNORM. Results are the raw bits of the dmask components. **The runtime binds each image's view in its own format at its index of the sampled array** (what `bind_image` in `runtime/shims/d3d12_vulkan_device.cpp` already does for SRVs and UAVs), so the view's numeric type matches the alias that reads it. No storage image is read, so shaders that only load need neither `shaderStorageImageReadWithoutFormat` (missing on Intel Xe-LP, #619) nor `shaderStorageImageWriteWithoutFormat` (SHADER-151). Until 2026-11-22 integer formats were read with `OpImageRead` from the uint/sint storage arrays (bindings 8–19), which hold only unordered-access views and 256 entries: a read-only integer texture found the fallback there, or an index past the array's end. Like the float path, the fetch goes through the texture path, so it sees writes made before the dispatch, not ones made earlier in the same dispatch. **d16 loads take the same branch** (#1136) and pack the dmask components two per VGPR, low half first: f16 (round to nearest even, integer ops, no `PackHalf2x16`) from the float array, the low 16 bits of each value from the uint/sint aliases (truncated). **d16 loads take the same branch** (#1136) and pack the dmask components two per VGPR, low half first: f16 (round to nearest even, integer ops, no `PackHalf2x16`) from the float array, each value from the uint/sint aliases saturated to the 16-bit range of its signedness (`saturate_int16`). For odd component counts (1 or 3 in `dmask`), the trailing destination VGPR preserves its existing high 16 bits (`write_lo16`), matching native `gfx1036` hardware where a seeded `0x5a5a` high half survived 1-component UINT/SINT `image_load` and `image_load_mip`; until 2026-11-22 the unused high half was zeroed. Before #1136, a d16 load always read the float view, so a `Texture2D` `Load` returned garbage. CPU-checked by `tests/test_image_load_typed.py` (capabilities, bindings and component types for every dimension; the branch for all 512 FORMAT values, found and missed). GPU-checked with `runtime/test/shaders/cs_imgload.asm` through `vk_store_test load`, on a device made without `shaderStorageImageReadWithoutFormat`: r32 uint and r32 sint images filled before the dispatch, both read with `image_load` and their sum stored, every texel exact on an RTX 2080 Ti (NVIDIA 621.14, Windows 11), clean under the validation layer with GPU-assisted validation; the test fails a module that declares `StorageImageReadWithoutFormat`. d16: CPU-checked by `tests/test_image_load_d16_typed.py` (the uint/sint fetches go through the aliases, no storage image is read, the SPIR-V validates); GPU-checked with `runtime/test/shaders/cs_imgload_d16.asm` through `vk_store_test load`: both pre-filled texels read with d16 loads (the sint one sign-extended from bit 15 in the shader) and their sum stored, every texel exact on the RTX 2080 Ti with GPU-assisted validation (#1136 checked its first form, a store and d16 read-back in one dispatch, on an RTX 5070, and `cs_imgload_d16` passes unchanged on an AMD RX 7600 (gfx1102, RADV Mesa 27.0.0-devel) in `run_gpu_tests.py`). GPU-checked with `runtime/test/shaders/cs_imgload_d16.asm` through `vk_store_test load`: both pre-filled texels read with d16 loads (the sint one sign-extended from bit 15 in the shader) and their sum stored, every texel exact on the RTX 2080 Ti with GPU-assisted validation (#1136 checked its first form, a store and d16 read-back in one dispatch, on an RTX 5070). 2D `image_load_mip` uses the same numeric-type selection and passes the address register's mip to each fetch. Its D16 form packs the selected components in ascending order, two per VGPR. An RGBA8 two-level texture was checked on RTX 5080 and Radeon Graphics: all four exported halves matched the CPU reference for UINT, SINT and UNORM, and forcing level 0 changed every pixel. Checked on RTX 5080 and Radeon Graphics with R8G8B8A8 UINT, SINT and UNORM textures: level 1 matched the CPU reference at every pixel with GPU-assisted validation, and forcing level 0 changed all 4096 pixels for each format. Native gfx1036 saturated 32-bit UINT/SINT texels to the unsigned/signed 16-bit range in both D16 load forms; the translated 2D load matched both limits on RTX 5080 and Radeon Graphics. Native gfx1036 does the same on every dimension (SHADER-387, `tools/image_d16_probe.py`): 32_UINT and 32_32_UINT texels saturate to [0, 0xffff] and 32_SINT and 32_32_SINT texels to [-32768, 32767], never truncate, in 1D, 2D, 2D-array and 3D images, through `image_load` and `image_load_mip` alike; two-channel results pack x low and y high, and a one-channel result keeps the seeded high half. The translated d16 loads on 1D, 2D-array and 3D images still lack GPU checks. | | Resident `image_load tfe` | When no lane faults, the status VGPR retains its prior value. The status follows the data VGPRs, with D16 packing two components per data VGPR. `cs_imgload_tfe` and `cs_imgload_d16_tfe` seed both status registers and check that the translated loads preserve them on fully resident images (GPU-checked on RTX 4070 Ti, Windows driver 630.20). The ordinary image-load lowering covers the resident case. Reporting sparse texel faults requires a separate lowering. [AMD RDNA 2 ISA §8.2.1, TFE and D16](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf), [LLVM AMDGPU instruction selection](https://github.com/llvm/llvm-project/blob/llvmorg-16.0.6/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp#L1804-L1833) | +| Resident `buffer_load*`/`tbuffer_load*` `tfe` | With `tfe` the VDATA range holds one status dword after the data VGPRs (`buffer_load_dword v[4:5]`, `buffer_load_dwordx2 v[6:8]`, the sub-dword and `_d16` loads, and `buffer_load_format_*`/`tbuffer_load_format_*`; the status register is `vdst[data_count]`). The ISA writes it only when the fetch NACKs (RDNA ISA, the MUBUF/MTBUF TFE field and PRT); a Vulkan buffer range cannot NACK, so, exactly as for resident `image_load tfe`, the status VGPR keeps its prior value and the ordinary load lowering covers it: the data VGPRs are written as without `tfe`, no instruction writes the status one, and `vgpr_dest_registers` still counts it as a destination. `llvm-mc` (`-mcpu=gfx1013`) accepts `tfe` on every MUBUF `buffer_load_*` form and rejects it on stores and atomics (and, an assembler gap, on MTBUF `tbuffer_load_format_*`, whose encoding does have the TFE bit — bit 55 in the ISA XML); `buffer_store_*` and `buffer_atomic_*` (and the global/smem paths) keep refusing it, as the ISA defines no status dword for them. CPU-checked by `tests/semantic/test_buffer_load_tfe.py` (data VGPRs loaded, status VGPRs' seeded values preserved for dword/x2/sub-dword/d16/MTBUF-format loads; stores and atomics still `Unsupported`). GPU fixture `runtime/test/shaders/cs_buf_tfe.asm` seeds the status VGPRs of `buffer_load_dword`/`dwordx2`/`ushort` `tfe` loads and stores data and status words to `out` (llvm-mc's gfx1013 assembler rejects `tfe` on MTBUF, so the MTBUF form is CPU-checked only); **not GPU-verified** (no GPU in this environment). | | Packed 2D mip-load addresses | For `image_load_mip` with `a16`, the first VGPR holds unsigned X (low half) and Y (high half). The low half of the second VGPR selects the mip and its high half is unused. Both ordinary and D16 results use the same address. LLVM gfx1030 assembles both forms in `tests/semantic/fixtures/packed_mip_load_2d.asm`. `tests/test_image_load_typed.py` checks the texel and mip operands of the float, UINT and SINT fetches, including noncontiguous address registers. [AMD RDNA 2 ISA, MIMG A16 field](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) | | 1D and 3D texture UAVs (D3D-78) | Storage bindings are 17–19 for 1D and 26–28 for 1D arrays (SPIR-V `1D`, arrayed), leaving multisample SRV bindings 20–25 unchanged. 1D arrays are storage-only: `image_load` and `image_store` use `(x, layer)` relative to the view. Ordinary 1D and 3D loads use sampled aliases; `image_load ... glc` in either dimension, or any `image_load` on a 1D array, reads the Unknown-format storage view. A layer-created 3D UAV sets reserved bit 31 of T# word 4; word 7 tagged with `0xd7800000` (mask `0xff800000`) holds `WSize - 1` in bits [21:11] and `FirstWSlice` in bits [10:0], including for whole-mip UAVs. Vulkan rebases/checks Z for storage operations. The typed sampled aliases below use the tag to rebase Z and return zero outside the range or for nonzero UAV LOD; an untagged SRV keeps its original coordinates and LOD. For non-`glc` `image_load` on a tagged R32_UINT T# whose SGPR group also feeds volume atomics in the shader, the read uses their formatted storage view (binding 7) so it can observe the atomic result in the same dispatch. Other sampled loads retain the visibility rule below. 3D atomics run only in active lanes with a resolved R32_UINT UAV; `glc` returns the old value and inactive lanes keep their destination. `cs_texture_uav.asm` and `d3d12_texture_uav_test` check coherent and sampled reads, dynamic `image_load_mip`, an untouched base mip, and active/inactive add and compare-and-swap with `glc` on an RTX 4090. | | Packed RGB9E5 UAV backing (#1287 and D3D-78) | Emulated RGB9E5 still encodes the logical shared-exponent FORMAT in the T#. A sampled view reads E5B9G9R9; a raw storage view uses R32_UINT, with any selected W range applied only to that storage view. On 1D-family and 3D UAVs, bit 22 of the synthetic word 7 marks this backing (tag mask `0xff800000`, lower 22 W bits unchanged). The translator does not implement re-packing for generic `image_store` or unpacking for formatless storage loads: these operations respectively suppress writes or take the fallback, not a view of the wrong numeric type. R32_UINT atomics require a logical R32_UINT volume UAV. The packed bit does not affect slicing or untagged SRVs; `d3d12_r9g9b9e5_uav_test` checks raw stores and sampled readback with the real set 0. | diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index 39a3179a46..2e45128e3f 100644 --- a/runtime/test/shaders/check.py +++ b/runtime/test/shaders/check.py @@ -227,7 +227,9 @@ def not_found_message(build, missing): # the end of an access decides (a start check, Mesa's GFX10 column, reads more); x4 loads and stores per dword, typed all or nothing ("cs_oob_tail", [0, 0, 0x5eed0010, 0, 0xbeef0000, 0xeeeeeeee, 0, 0x5eed0010]), # swizzled MUBUF addressing (measured natively on gfx1036) and ADD_TID_ENABLE on lanes 0 and 1, derived in the .asm header - ("cs_buf_swizzle", [0x5eed0024, 0x5eed0044, 0x5eed004c, 0x5eed0008, 0x5eed000c, 0, 0xbeef0000, 0xbeef0001])] + ("cs_buf_swizzle", [0x5eed0024, 0x5eed0044, 0x5eed004c, 0x5eed0008, 0x5eed000c, 0, 0xbeef0000, 0xbeef0001]), + # tfe status VGPRs keep their seeds on resident buffer loads (derived in the .asm header) + ("cs_buf_tfe", [0x5eed0100, 0x5eed0055, 0x5eed0101, 0x5eed0102, 0x5eed0066, 0x00000102, 0x5eed0077])] CMPX_CLASS_WORDS = [0xEEEEEEEE] * 3 + [0x22] + [0x11] * 4 # cs_fmt_1010102.asm: descriptor loads, immediate-format load, raw input words and the two packed stores. FMT_1010102_WORDS = [0, 0x3F800000, 0, 0x3F800000, 0x3F800000, 0, 0x3F800000, 0, diff --git a/runtime/test/shaders/cs_buf_tfe.asm b/runtime/test/shaders/cs_buf_tfe.asm new file mode 100644 index 0000000000..d81dd9fae6 --- /dev/null +++ b/runtime/test/shaders/cs_buf_tfe.asm @@ -0,0 +1,36 @@ +; Resident buffer_load* tfe on the GPU (docs/design.md, "Resident buffer_load*/tbuffer_load* tfe"; CPU-checked by +; tests/semantic/test_buffer_load_tfe.py, which also covers the MTBUF tbuffer_load_format_* form llvm-mc cannot +; assemble). With tfe the VDATA range holds one status dword after the data VGPRs; the ISA writes it only when the +; fetch NACKs, which a Vulkan buffer cannot produce, so it keeps its prior value. Heap bytes 0x40..0x4f are seeded +; with 0x5eed0100..0x5eed0103 and the three status VGPRs with their own seeds; the V# has base 0x40, stride 0, +; NUM_RECORDS 0x10 and word3 0x31016fac (OOB_SELECT 3, RAW), as in cs_buf_tail.asm: +; buffer_load_dword v[4:5] v20=0 offen tfe -> v4 = 0x5eed0100, v5 keeps 0x5eed0055 +; buffer_load_dwordx2 v[6:8] v21=4 offen tfe -> v6 = 0x5eed0101, v7 = 0x5eed0102, v8 keeps 0x5eed0066 +; buffer_load_ushort v[9:10] v22=8 offen tfe -> v9 = 0x0102, v10 keeps 0x5eed0077 +; and v[4:10] is written to out[0..6]. Every lane loads the same addresses, so all lanes store the same words. +; Run: vk_compute_test cs_buf_tfe.spv 1 dump -> out[0..6] = 0x5eed0100 0x5eed0055 0x5eed0101 0x5eed0102 +; 0x5eed0066 0x00000102 0x5eed0077. +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32 v1, 0x5eed0100 +v_mov_b32 v2, 0x5eed0101 +v_mov_b32 v3, 0x5eed0102 +buffer_store_dwordx4 v[1:4], off, s[0:3], 0 offset:64 +s_waitcnt vmcnt(0) +s_mov_b32 s4, 0x40 +s_mov_b32 s5, 0 +s_mov_b32 s6, 0x10 +s_mov_b32 s7, 0x31016fac +v_mov_b32 v20, 0 +v_mov_b32 v21, 4 +v_mov_b32 v22, 8 +v_mov_b32 v5, 0x5eed0055 +v_mov_b32 v8, 0x5eed0066 +v_mov_b32 v10, 0x5eed0077 +buffer_load_dword v[4:5], v20, s[4:7], 0 offen tfe +buffer_load_dwordx2 v[6:8], v21, s[4:7], 0 offen tfe +buffer_load_ushort v[9:10], v22, s[4:7], 0 offen tfe +s_waitcnt vmcnt(0) +buffer_store_dwordx4 v[4:7], off, s[0:3], 0 +buffer_store_dwordx2 v[8:9], off, s[0:3], 0 offset:16 +buffer_store_dword v10, off, s[0:3], 0 offset:24 +s_endpgm diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index f87290ec65..a1f6f06ad5 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -1052,7 +1052,8 @@ def run_suite(a, work: str) -> int: results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the " "clamped and the calculated LOD within 1/16")) elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_smem_sconst_off", "cs_buf_tail", "cs_oob_select", "cs_oob_tail", - "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8", "cs_pk_mul_lo_const", "cs_buf_load_sub", "cs_buf_fmt8"): + "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8", "cs_pk_mul_lo_const", "cs_buf_load_sub", "cs_buf_fmt8", + "cs_buf_tfe"): # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement. # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either. @@ -1080,6 +1081,9 @@ def run_suite(a, work: str) -> int: # TEST-510: sub-dword MUBUF loads (RAW end check by element size) and GFX10_FORMAT_8_UINT "cs_buf_load_sub": [0x80, 0xFFFFFF80, 0x1FF, 0xFFFF807F, 0xAB01, 0xCD, 0, 0], "cs_buf_fmt8": [0x7F, 0x80, 0xFF, 0x01, 0, 0, 0xFF, 1], + # tfe status VGPRs keep their seeds on resident buffer loads (derived in the .asm header) + "cs_buf_tfe": [0x5EED0100, 0x5EED0055, 0x5EED0101, 0x5EED0102, 0x5EED0066, 0x00000102, + 0x5EED0077], }[name] words = dump_words(msg) vals = words[:len(want)] if words else [] diff --git a/tests/semantic/test_buffer_load_sub.py b/tests/semantic/test_buffer_load_sub.py index 6808d68b71..30fcdbde5c 100644 --- a/tests/semantic/test_buffer_load_sub.py +++ b/tests/semantic/test_buffer_load_sub.py @@ -157,7 +157,6 @@ def test_inactive_lane_preserves_vdst(self): def test_rejected_sub_dword_forms(self): for line in ("buffer_load_ushort v5, v1, s[4:7], 0 offen lds", - "buffer_load_ushort v5, v1, s[4:7], 0 offen tfe", "buffer_load_ushort v5, v1, s[4:7], 0 offen d16"): with self.subTest(line=line): with self.assertRaises(rdna2spirv.Unsupported): diff --git a/tests/semantic/test_buffer_load_tfe.py b/tests/semantic/test_buffer_load_tfe.py new file mode 100644 index 0000000000..bcf7ede0ed --- /dev/null +++ b/tests/semantic/test_buffer_load_tfe.py @@ -0,0 +1,146 @@ +"""Semantic interpreter tests for tfe on MUBUF/MTBUF loads. + +Covers the RDNA2 ISA rule implemented in tools/rdna2spirv.py (docs/design.md, "Resident buffer_load* tfe"): +with tfe the VDATA range holds one status dword after the data VGPRs. The ISA writes it only when the fetch +NACKs (PRT, "Partially Resident Textures"); a Vulkan buffer range cannot NACK, so — exactly like the resident +image_load tfe case — the status VGPR keeps its prior value and the ordinary load lowering covers it. + + - buffer_load_dword / dwordx2, buffer_load_ushort and tbuffer_load_format_x with tfe: the data VGPRs get the + loaded data and the status VGPR (vdst[data_count]) keeps the value the shader seeded. + - tfe stays refused on stores (buffer_store_dword, buffer_store_byte) and atomics (buffer_atomic_add): the ISA + defines no status dword for them and llvm-mc rejects the modifier there. + +Standard library only; no GPU, no LLVM, no game files. +""" +from __future__ import annotations + +import os +import struct +import sys +import tempfile +import unittest +import warnings + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.dirname(os.path.dirname(HERE)) +sys.dont_write_bytecode = True +sys.path.insert(0, os.environ.get("LEONIDA_TOOLS_DIR") or os.path.join(ROOT, "tools")) +sys.path.insert(0, HERE) + +import rdna2spirv # noqa: E402 +import spirv_mini_interp as si # noqa: E402 + +STUB_DXBC = b"DXBC" + bytes(24) + struct.pack(" buffer-device-address loads. addr = V#.base + soffset + inst_offset + (offen ? vaddr : 0) + (idxen ? vindex * V#.stride : 0), byte exact. Each dword is loaded only when it is in range per the V#'s OOB_SELECT (buffer_address; docs/design.md, Buffer bounds checking): for modes 0 and 3 dword i ends inside the stride / num_records, else it is 0 and memory is - not read; modes 1 and 2 check the index / num_records once. Inactive lanes don't load.""" - if any(m in mods for m in ("lds", "tfe")) or "format" in op: + not read; modes 1 and 2 check the index / num_records once. Inactive lanes don't load. With tfe the VDATA + range holds one more dword after the data, the fetch status (RDNA ISA: written only when the fetch NACKs, + which a Vulkan buffer cannot, so it keeps its prior value — the resident image_load tfe case).""" + if "lds" in mods or "format" in op: raise Unsupported(op + " form") n = 1 if op.endswith("dword") else int(op.rsplit("x", 1)[1]) vd = a[0] @@ -2431,12 +2435,14 @@ def guarded(cond, dwords): def buffer_load_sub(self, op, a, mods): """buffer_load_{u,s}byte / buffer_load_{u,s}short vD, vaddr, s[V#], soffset [offen|idxen] offset:N. Loads 1 or 2 bytes from V#.base + offsets, zero- or sign-extended to 32 bits. Out-of-bounds lanes - (OOB_SELECT with element size 1 or 2) return 0 without reading memory; inactive lanes keep vD.""" - if any(m in mods for m in ("lds", "tfe", "d16")): + (OOB_SELECT with element size 1 or 2) return 0 without reading memory; inactive lanes keep vD. tfe's status + dword follows the data VGPR and is left unwritten, as for buffer_load.""" + if any(m in mods for m in ("lds", "d16")): raise Unsupported(op + " form") nbytes, signed = self.BUFFER_SUB[op] vd = a[0] - if vd["k"] != "vgpr" or vd.get("n", 1) != 1: + # tfe's status dword is part of the VDATA range: one data VGPR plus it. + if vd["k"] != "vgpr" or vd.get("n", 1) != 1 + int("tfe" in mods): raise Unsupported(op + " destination") addr, _, in_b, step = self.buffer_address(a, mods, elem=nbytes) act = self.active_b() @@ -2477,7 +2483,7 @@ def buffer_load_sub(self, op, a, mods): self.emit(f"{lbl_end} = OpLabel") res = self.tmp() self.emit(f"{res} = OpPhi %uint {val} {lbl_do} {self.cu(0)} {pre_label}") - self.dst(vd, res) + self.dst({"k": "vgpr", "r": vd["r"], "n": 1}, res) # GFX10 buffer formats (from Mesa src/amd/registers/gfx10-rsrc.json, GFX10_FORMAT): # code: (bytes, kind, component bit widths from bit 0) @@ -3136,6 +3142,8 @@ def buffer_atomic(self, op, a, mods): address). With 'glc' the pre-op value is returned in vdata. Inactive lanes don't touch memory and keep vdata; active OOB or unaligned (addr % 4 != 0) lanes leave memory untouched and write 0 with glc (measured on gfx1036).""" kind = op[len("buffer_atomic_"):] + if "tfe" in mods: + raise Unsupported(op + " form") # an atomic is no fetch: the ISA defines no status dword (llvm-mc rejects it) if kind in ("and_x2", "or_x2", "xor_x2", "swap_x2"): return self.buffer_atomic_x2(op, kind[:-3], a, mods) if kind in ("fmin", "fmax"): @@ -3562,7 +3570,7 @@ def buffer_load_format(self, op, a, mods, fixed_fmt=None): self.fixed_format_codes.add(fixed_fmt) else: self.dynamic_format = True - if any(m in mods for m in ("lds", "tfe", "d16")): + if any(m in mods for m in ("lds", "d16")): raise Unsupported(op + " form") d16 = "_d16_" in op ncomp = len(op.rsplit("_", 1)[1])