From 2a955097a655bc6deb0744f20739afb548eb2762 Mon Sep 17 00:00:00 2001 From: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com> Date: Wed, 25 Nov 2026 13:19:02 +0800 Subject: [PATCH 1/2] compute: store UINT4 through a runtime-selected buffer view --- .github/workflows/windows.yml | 2 + AGENTS.md | 1 + CMakeLists.txt | 7 ++ docs/experiments.md | 8 ++ tests/compute_heap_store_check.py | 140 ++++++++++++++++++++++++++++++ tools/compute_store_aot.py | 69 +++++++++++++-- 6 files changed, 218 insertions(+), 9 deletions(-) create mode 100644 tests/compute_heap_store_check.py diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1b963c28c3..b157d1390b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -46,6 +46,7 @@ jobs: (["tests/compute_store_check.py", *COMMON_LLVM], {}), (["tests/compute_load_format_check.py", *COMMON_LLVM], {}), (["tests/compute_heap_view_check.py", *COMMON_LLVM], {}), + (["tests/compute_heap_store_check.py", *COMMON_LLVM], {}), (["tests/pixel_aot_check.py", *COMMON_LLVM], {}), (["tests/sampled_coverage_check.py", *COMMON_LLVM], {}), (["tests/pixel_compare_gather_check.py", "--binary", "llvm-mc-15", "llvm-objcopy-15", "libLLVM-15.so.1"], {}), @@ -255,6 +256,7 @@ jobs: tests/compute_alu_bcnt64_check.py \ tests/compute_load_format_check.py \ tests/compute_heap_view_check.py \ + tests/compute_heap_store_check.py \ tests/startup_ngg_slice_check.py \ tests/startup_gfx2hlsl_handler_arity_check.py \ tests/run_checks_parallel_check.py diff --git a/AGENTS.md b/AGENTS.md index 1c8a69fbf7..a114b7c037 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -184,6 +184,7 @@ python3 -m venv out/pe-env ./out/pe-env/bin/python -B tests/compute_alu_bcnt64_check.py ./out/pe-env/bin/python -B tests/compute_load_format_check.py ./out/pe-env/bin/python -B tests/compute_heap_view_check.py +./out/pe-env/bin/python -B tests/compute_heap_store_check.py ./out/pe-env/bin/python -B tests/startup_ngg_slice_check.py ./out/pe-env/bin/python -B tests/mesh_dynamic_aot_check.py ./out/pe-env/bin/python -B tests/mesh_lane_spill_check.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 495e0bcba3..e602219142 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2585,6 +2585,8 @@ if(EXISTS "${INTAKE_PYTHON}") # Compute translator: buffer_load_format with the V# taken from a run-time heap view record. add_test(NAME compute_heap_view_controls COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/compute_heap_view_check.py" controls) + add_test(NAME compute_heap_store_controls COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_SOURCE_DIR}/tests/compute_heap_store_check.py" controls) # Startup shader translator: signed and unsigned three-source integer min, max and median. add_test(NAME startup_gfx2hlsl_int_med3_controls COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_int_med3_check.py") @@ -7565,6 +7567,11 @@ if(EXISTS "${INTAKE_PYTHON}") "$" ${adapter}) set_tests_properties(compute_store_aot_heap_view_load_${adapter} PROPERTIES TIMEOUT 180 SKIP_RETURN_CODE 77) + add_test(NAME compute_store_aot_heap_view_store_${adapter} COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_SOURCE_DIR}/tests/compute_heap_store_check.py" draw "${DXC_EXECUTABLE}" + "$" ${adapter}) + set_tests_properties(compute_store_aot_heap_view_store_${adapter} PROPERTIES TIMEOUT 120 + SKIP_RETURN_CODE 77) add_test(NAME compute_store_aot_mtbuf_store_${adapter} COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/compute_store_check.py" draw-mtbuf-store "${DXC_EXECUTABLE}" "$" ${adapter}) diff --git a/docs/experiments.md b/docs/experiments.md index d1d0918728..4a0fc77f30 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -5155,6 +5155,14 @@ ctest --preset dev --no-tests=error -R '^compute_(store_aot_descriptor_load_form python3 -B tests/compute_load_format_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` +### Heap-view UINT4 buffer stores + +The gfx1013 compute fixture translates one indexed `buffer_store_format_xyzw` that writes four raw 32-bit components to a fixed u0. `--heap-store-view SLOT_WORD TABLE_OFFSET COUNT TABLE_BUFFER_BYTES OUTPUT_BYTES` selects a 32-byte record in the [t0 view table](#heap-view-buffer-loads) using a word already loaded from b0. The caller supplies the table extent and writable u0 extent separately. The D3D12 root UAV used by the fixture carries a GPU address with no size limit. [Direct3D 12 root signatures](https://learn.microsoft.com/en-us/windows/win32/direct3d12/root-signatures-overview) + +The view must be live and describe format 75 (`BUF_FMT_32_32_32_32_UINT`) with identity channel selectors. The store uses the view base, stride, dispatch thread index and instruction byte offset. Only a complete aligned texel within the record count, stride and declared u0 extent is written. The fixture models view selection within one bound buffer. [LLVM format table](https://releases.llvm.org/15.0.0/docs/AMDGPUModifierSyntax.html#ufmt) · [AMD RDNA 2 shader ISA](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) + +Run `ctest --preset dev -R '^compute_(heap_store_controls|store_aot_heap_view_store_warp)$' --output-on-failure`. The fixture checks all 320 readback words across twelve cases. These include distinct live ranges, one texel ending exactly at the u0 limit, and a partial texel that must leave the sentinel intact. Seven mutations exercise the base, stride, record count, format, lifetime, output extent and slot limit. + ### Heap-view buffer loads The gfx1013 compute store profile can now take the t0 V# of a `buffer_load_format_x/xy/xyz/xyzw` from a run-time view record instead of a static descriptor. `--heap-view SLOT_WORD TABLE_OFFSET COUNT BUFFER_BYTES` selects it. It is slice 2 of item A of #2022 and builds on the format decoder of [descriptor-format buffer loads](#descriptor-format-buffer-loads). It excludes `--load-format-constant`: the format now comes from the record. diff --git a/tests/compute_heap_store_check.py b/tests/compute_heap_store_check.py new file mode 100644 index 0000000000..ec30f602dd --- /dev/null +++ b/tests/compute_heap_store_check.py @@ -0,0 +1,140 @@ +"""A gfx1013 formatted store selects the byte range of a fixed u0 through a run-time view record.""" +from pathlib import Path +import struct +import subprocess +import sys +import tempfile + +import compute_store_check as base + + +GROUP = (4, 1, 1) +WORDS = 320 +TABLE_BYTE = 256 +UINT4 = 0x0104BFAC # gfx10 format 75, identity XYZW selectors and RESOURCE_LEVEL set +FLOAT4 = 0x0104DFAC +STORE = "buffer_store_format_xyzw v[10:13], v8, s[20:23], 0 idxen offset:4" +PROGRAM = [ + "s_mov_b32 s12, s7", "s_mov_b32 s13, 0", "s_load_dwordx4 s[20:23], s[12:13], 0x30", + "s_load_dwordx4 s[16:19], s[12:13], 0x40", "v_lshl_add_u32 v8, s11, 2, v0", + "s_waitcnt lgkmcnt(0)", "s_buffer_load_dwordx4 s[24:27], s[16:19], null", "s_waitcnt lgkmcnt(0)", + "v_mov_b32_e32 v10, v8", "v_mov_b32_e32 v11, 0x12345678", "v_mov_b32_e32 v12, 0x80000001", + "v_mov_b32_e32 v13, 0x3f800001", STORE, "s_endpgm", +] +# V# words 0..3 and live state, then the expected *word addresses* of the four component stores. +# The addresses are literal to keep the reference independent of the generated address calculation. +CASES = ( + ("four records", (12, 24 << 16, 4, UINT4, 1), (4, 10, 16, 22)), + ("second base and short record count", (116, 32 << 16, 2, UINT4, 1), (30, 38)), + ("released view", (12, 24 << 16, 4, UINT4, 2), ()), + ("last complete texel in u0", (492, 20 << 16, 4, UINT4, 1), (124,)), + ("partial texel at end of u0", (496, 20 << 16, 4, UINT4, 1), ()), + ("wrong four-channel format", (12, 24 << 16, 4, FLOAT4, 1), ()), + ("offset plus texel wider than stride", (12, 16 << 16, 4, UINT4, 1), ()), + ("misaligned base", (14, 24 << 16, 4, UINT4, 1), ()), + ("misaligned stride", (12, 22 << 16, 4, UINT4, 1), ()), + ("unsupported high address", (12, (24 << 16) | 1, 4, UINT4, 1), ()), + ("base past the declared u0 extent", (640, 24 << 16, 4, UINT4, 1), ()), + ("live slot beyond declared count", (12, 24 << 16, 4, UINT4, 1), ()), +) +VIEW = (0, TABLE_BYTE, len(CASES) - 1, WORDS * 4, 512) +BINDING = dict(table_reg=7, descriptor_offset=0x30, constant_descriptor=0x40, source_descriptor=0x50, group_reg=11) + + +def lower(program=PROGRAM, **options): + return base.aot.lower(program, GROUP, **(BINDING | dict(heap_store_view=VIEW) | options)) + + +def controls(): + assert base.aot.descriptor_format_word(75) == UINT4 + assert "store_heap_uint4(params[0].x, tid.x, 4u, uint4(tid.x," in lower() + refuses = base.rejects + refuses("Unsupported formatted buffer store target or address mode", lower, heap_store_view=None) + refuses("Invalid heap store view binding", lower, stride=24) + refuses("Invalid heap store view binding", lower, heap_view=VIEW) + refuses("Invalid heap view binding", lower, source_descriptor=None) + refuses("Invalid heap view binding", lower, heap_store_view=(0, TABLE_BYTE, 11, TABLE_BYTE + 32, 512)) + refuses("Invalid heap store view output size", lower, heap_store_view=(*VIEW[:4], 511)) + refuses("Heap store view requires exactly one formatted UAV store", lower, + PROGRAM[:-1] + [STORE.replace("offset:4", "offset:24"), "s_endpgm"]) + refuses("Heap store view slot constant is not ready", lower, PROGRAM[:7] + PROGRAM[8:]) + refuses("Heap store view requires buffer_store_format_xyzw", lower, + base.variant(PROGRAM, (STORE, STORE.replace("xyzw v[10:13]", "xy v[10:11]")))) + refuses("Unsupported formatted buffer store target or address mode", lower, + base.variant(PROGRAM, (STORE, STORE.replace(" idxen", " offen")))) + refuses("Unverified raw UAV store", lower, base.variant(PROGRAM, (STORE, STORE.replace("s[20:23]", "s[16:19]")))) + refuses("Heap store view needs a formatted store indexed by dispatch thread ID", lower, + base.variant(PROGRAM, (STORE, STORE.replace(", v8,", ", v12,")))) + + +def verify_binary(directory, code, library): + decoded = base.aot.labelled(base.disassemble(code, library, offsets=True, cpu=b"gfx1013")) + assert lower(decoded) == lower() + container, output = directory / "store.dxbc", directory / "store.hlsl" + container.write_bytes(base.store_container(code, GROUP)) + subprocess.run([sys.executable, "-B", base.aot.__file__, container, "--output", output, "--llvm", library, + *base.binding_cli(BINDING), "--heap-store-view", *map(str, VIEW)], check=True) + assert output.read_text(encoding="ascii") == lower() + + +def draw(directory, compiler, renderer, backend): + source = lower() + table = [0] * WORDS + for slot, (_, record, _) in enumerate(CASES): + start = TABLE_BYTE // 4 + slot * 8 + table[start:start + 5] = record + hlsl, cso = directory / "store.hlsl", directory / "store.cso" + + def compile_shader(text): + hlsl.write_text(text, encoding="ascii") + subprocess.run([compiler, "-T", "cs_6_0", "-E", "main", "-Fo", cso, hlsl], check=True) + + def run(slot): + result = [base.SENTINEL] * WORDS + for thread, start in enumerate(CASES[slot][2]): + result[start:start + 4] = [thread, 0x12345678, 0x80000001, 0x3F800001] + case = directory / "store.case" + case.write_bytes(struct.pack("<321I", 1, *result) + struct.pack("<16I", slot, *([0] * 15)) + + struct.pack("<320I", *table)) + return subprocess.run([renderer, backend, "--compute-store-case", cso, case], capture_output=True, text=True) + + compile_shader(source) + for slot, (label, _, _) in enumerate(CASES): + result = run(slot) + if result.returncode == 77 and backend == "hardware": + return 77 + assert result.returncode == 0, (label, result.stderr) + mutations = ( + ("view.x + index * stride + offset", "index * stride + offset", 0), + (" || index >= view.z", "", 1), + ("uint stride = view.y >> 16u;", "uint stride = 24u;", 1), + ("const uint bytes = 512u;", "const uint bytes = 1280u;", 4), + (f"view.w != {UINT4:#x}u || ", "", 5), + ("!= 1u) return;", "== 0u) return;", 2), + (f"slot >= {VIEW[2]}u", f"slot > {VIEW[2]}u", VIEW[2]), + ) + for old, new, slot in mutations: + assert source.count(old) == 1, old + compile_shader(source.replace(old, new)) + result = run(slot) + assert result.returncode == 1 and "Compute readback differs" in result.stderr, (old, result.stderr) + print(f"{backend}: {len(CASES)} heap-store cases and {len(mutations)} shader mutations checked") + return 0 + + +if __name__ == "__main__": + controls() + mode, *args = sys.argv[1:] or ["controls"] + if mode == "controls" and not args: + print("heap-store controls passed") + elif mode in ("binary", "draw") and len(args) == 3: + with tempfile.TemporaryDirectory() as tmp: + directory = Path(tmp) + if mode == "draw": + sys.exit(draw(directory, *args)) + assembler, objcopy, library = args + code = base.assemble(directory, assembler, objcopy, PROGRAM, cpu="gfx1013") + verify_binary(directory, code, library) + else: + sys.exit("usage: compute_heap_store_check.py controls | binary " + "| draw ") diff --git a/tools/compute_store_aot.py b/tools/compute_store_aot.py index 7490623463..725c4a9a8c 100644 --- a/tools/compute_store_aot.py +++ b/tools/compute_store_aot.py @@ -650,12 +650,31 @@ def heap_view_hlsl(table_offset, view_count, buffer_bytes): ) +def heap_store_view_hlsl(table_offset, view_count, output_bytes): + """Store four UINT words through a live side-table record for the fixed raw u0 binding.""" + return f"""void store_heap_uint4(uint slot, uint index, uint offset, uint4 value) {{ + if (slot >= {view_count}u) return; + uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u; + if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return; + uint4 view = inputData.Load4(record); + if (view.w != {descriptor_format_word(75):#x}u || (view.y & 0xc000ffffu) != 0u) return; + uint stride = view.y >> 16u; + if (((view.x | stride) & 3u) != 0u || stride < offset + 16u || index >= view.z) return; + const uint bytes = {output_bytes}u; + if (view.x > bytes || offset + 16u > bytes - view.x) return; + if (index > (bytes - view.x - offset - 16u) / stride) return; + outputData.Store4(view.x + index * stride + offset, value); +}} +""" + + def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=None, stride=None, image_srv_descriptor=None, constant_descriptor=None, group_reg_y=None, group_reg_z=None, source_descriptor=None, source_stride=None, source_format=None, output_format=None, image_descriptor=None, image_format=None, image_uav_mip=None, image_float_domain=None, cpu="gfx1013", lds_bytes=0, lds_f32_mode=None, lds_f64_mode=None, mubuf_d16_xyz_mode=None, - descriptor_format_constant=None, rsrc2=None, wave_size=None, load_format_constant=None, heap_view=None): + descriptor_format_constant=None, rsrc2=None, wave_size=None, load_format_constant=None, heap_view=None, + heap_store_view=None): """v0, v1 and v2 are local X, Y and Z; group_reg, group_reg_y and group_reg_z are the group IDs. rsrc2 is the program's COMPUTE_PGM_RSRC2. When given, it places the group IDs @@ -674,6 +693,8 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N word index per formatted load, in program order, read by load_descriptor_format (see descriptor_load_hlsl). heap_view=(slot_word, table_offset, view_count, buffer_bytes) makes the same loads take the V# from a run-time view record instead of a constant format word (see heap_view_hlsl). It excludes load_format_constant. + heap_store_view uses the same t0 record layout for one indexed four-component UINT store to u0. + Its fifth argument is the writable byte extent of u0. Root UAV descriptors carry no length. gfx1013 uses RGBA32 FLOAT for full-mask image_store or image_load_mip. When both are used, image_srv_descriptor supplies the separate t0 descriptor. A full-mask 2D D16 image_store requires an RGBA16 FLOAT UAV. @@ -801,13 +822,21 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N or index not in range(CONSTANT_WORDS) for index in load_format_words)): raise ValueError("Invalid buffer load format constant") heap_slot_word = heap_table = heap_count = None - if heap_view is not None: + view_binding = heap_view + if heap_store_view is not None: + if (heap_view is not None or format_words is not None or stride is not None or output_format is not None + or image_output or not isinstance(heap_store_view, (tuple, list)) or len(heap_store_view) != 5): + raise ValueError("Invalid heap store view binding") + view_binding, output_bytes = heap_store_view[:4], heap_store_view[4] + if not isinstance(output_bytes, int) or not 4 <= output_bytes < 1 << 32 or output_bytes % 4: + raise ValueError("Invalid heap store view output size") + if view_binding is not None: if (load_format_words is not None or cpu != "gfx1013" or constant_descriptor is None or source_descriptor is None or source_stride is not None or source_format is not None - or not isinstance(heap_view, (tuple, list)) or len(heap_view) != 4 - or any(not isinstance(v, int) or isinstance(v, bool) for v in heap_view)): + or not isinstance(view_binding, (tuple, list)) or len(view_binding) != 4 + or any(not isinstance(v, int) or isinstance(v, bool) for v in view_binding)): raise ValueError("Invalid heap view binding") - heap_slot_word, heap_table, heap_count, heap_bytes = heap_view + heap_slot_word, heap_table, heap_count, heap_bytes = view_binding if (heap_slot_word not in range(CONSTANT_WORDS) or heap_table % 4 or not 0 <= heap_table < 1 << 20 or not 1 <= heap_count <= HEAP_VIEW_MAX or heap_bytes % 4 or not heap_table + HEAP_VIEW_RECORD_BYTES * heap_count <= heap_bytes < 1 << 30): @@ -2429,7 +2458,13 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N if formatted: if not idxen or offen: raise ValueError("Unsupported formatted buffer store target or address mode") - if format_words is not None: + if heap_store_view is not None: + if channels != "xyzw": + raise ValueError("Heap store view requires buffer_store_format_xyzw") + if not any(tag == ("constant_word", heap_slot_word) and reg not in pending + for reg, tag in scalar.items()): + raise ValueError("Heap store view slot constant is not ready") + elif format_words is not None: if format_store_index >= len(format_words): raise ValueError("Formatted buffer store is missing a format constant") format_index = format_words[format_store_index] @@ -2474,7 +2509,13 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N addr = m["addr"] addr_regs = list(map(int, re.findall(r"\d+", addr))) tags = [vector.get(reg) for reg in addr_regs] - if addr == "off" and not idxen and not offen and dims == (1, 1, 1) and stride is None: + if heap_store_view is not None: + if not formatted or len(tags) != 1 or not isinstance(tags[0], tuple) or tags[0][0] != "thread": + raise ValueError("Heap store view needs a formatted store indexed by dispatch thread ID") + axis = tags[0][1] + store_layout, covered = ("heap_index", axis), {axis} + address = f"tid.{AXES[axis]}" + elif addr == "off" and not idxen and not offen and dims == (1, 1, 1) and stride is None: store_layout = ("fixed",) covered = set() elif (stride is not None and idxen and not offen and len(addr_regs) == 1 @@ -2548,7 +2589,10 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N # layout, aligned stride and overlap checks give that word a single writer. final_address = address if count == 1 else f"{address} + 4u" words[-1] = f"((outputData.Load({final_address}) & 0xffff0000u) | ({words[-1]} & 0xffffu))" - if descriptor_store: + if heap_store_view is not None: + slot = hlsl_word(("constant_word", heap_slot_word)) + stores.append(f" store_heap_uint4({slot}, {address}, {offset}u, uint4({', '.join(words)}));") + elif descriptor_store: supplied = words + ["0u"] * (4 - len(words)) stores.append(" store_descriptor_format(" f"{hlsl_word(('constant_word', format_index))}, {address}, {components}u, " @@ -2567,6 +2611,8 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N raise ValueError("Unused buffer load format constant") if heap_view is not None and not format_load_index: raise ValueError("Unused heap view binding") + if heap_store_view is not None and (not layout or layout[0] != "heap_index" or len(stores) != 1): + raise ValueError("Heap store view requires exactly one formatted UAV store") if load_format_words is not None or heap_view is not None: # Every load is staged before the stores. The format words are uniform constants, so an invalid # format leaves the whole dispatch unwritten rather than publishing a placeholder result. @@ -2616,6 +2662,8 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N descriptor_hlsl += descriptor_load_hlsl() if heap_view is not None: descriptor_hlsl += heap_view_hlsl(heap_table, heap_count, heap_bytes) + if heap_store_view is not None: + descriptor_hlsl += heap_store_view_hlsl(heap_table, heap_count, output_bytes) return (f"{cbuffer}{uav} outputData : register(u0);\n{descriptor_hlsl}" f"[numthreads({dims[0]},{dims[1]},{dims[2]})]\n" f"void main(uint3 tid : SV_DispatchThreadID{local}) {{\n{body}\n}}\n") @@ -2656,6 +2704,9 @@ def main(): metavar=("SLOT_WORD", "TABLE_OFFSET", "COUNT", "BUFFER_BYTES"), help="gfx1013 formatted loads take the V# from the run-time view record at the slot in b0 word " "SLOT_WORD; the record table is at byte TABLE_OFFSET of the BUFFER_BYTES-byte t0 and holds COUNT views") + parser.add_argument("--heap-store-view", nargs=5, type=lambda n: int(n, 0), + metavar=("SLOT_WORD", "TABLE_OFFSET", "COUNT", "TABLE_BUFFER_BYTES", "OUTPUT_BYTES"), + help="select a UINT4 store view from the t0 table and bound writes by OUTPUT_BYTES of u0") parser.add_argument("--mubuf-d16-xyz-mode", choices=("preserve-w",), help="Experimental RGBA16 UINT store with caller-verified preservation of W") parser.add_argument("--image-descriptor", type=lambda n: int(n, 0), @@ -2697,7 +2748,7 @@ def main(): mubuf_d16_xyz_mode=args.mubuf_d16_xyz_mode, image_srv_descriptor=args.image_srv_descriptor, descriptor_format_constant=args.descriptor_format_constant, rsrc2=args.rsrc2, wave_size=args.wave_size, load_format_constant=args.load_format_constant, - heap_view=tuple(args.heap_view) if args.heap_view else None) + heap_view=tuple(args.heap_view) if args.heap_view else None, heap_store_view=args.heap_store_view) args.output.parent.mkdir(parents=True, exist_ok=True) args.output.write_text(source, encoding="ascii") print(json.dumps({"container_sha256": hashlib.sha256(blob).hexdigest(), From a6f41df1301edae519a293b39b27016fe69a2447 Mon Sep 17 00:00:00 2001 From: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com> Date: Wed, 25 Nov 2026 14:14:15 +0800 Subject: [PATCH 2/2] tests: exercise the per-index heap store extent on device --- docs/experiments.md | 2 +- tests/compute_heap_store_check.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/experiments.md b/docs/experiments.md index 4a0fc77f30..0802b84bf7 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -5161,7 +5161,7 @@ The gfx1013 compute fixture translates one indexed `buffer_store_format_xyzw` th The view must be live and describe format 75 (`BUF_FMT_32_32_32_32_UINT`) with identity channel selectors. The store uses the view base, stride, dispatch thread index and instruction byte offset. Only a complete aligned texel within the record count, stride and declared u0 extent is written. The fixture models view selection within one bound buffer. [LLVM format table](https://releases.llvm.org/15.0.0/docs/AMDGPUModifierSyntax.html#ufmt) · [AMD RDNA 2 shader ISA](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) -Run `ctest --preset dev -R '^compute_(heap_store_controls|store_aot_heap_view_store_warp)$' --output-on-failure`. The fixture checks all 320 readback words across twelve cases. These include distinct live ranges, one texel ending exactly at the u0 limit, and a partial texel that must leave the sentinel intact. Seven mutations exercise the base, stride, record count, format, lifetime, output extent and slot limit. +Run `ctest --preset dev -R '^compute_(heap_store_controls|store_aot_heap_view_store_(warp|hardware))$' --output-on-failure`. The fixture checks all 320 readback words across twelve cases. These include distinct live ranges, one texel ending exactly at the u0 limit, and a partial texel that must leave the sentinel intact. Eight mutations exercise the base, stride, record count, format, lifetime, output extent and slot limit. Removing the per-index extent check lets the next thread write past the last complete texel. ### Heap-view buffer loads diff --git a/tests/compute_heap_store_check.py b/tests/compute_heap_store_check.py index ec30f602dd..02141c86bb 100644 --- a/tests/compute_heap_store_check.py +++ b/tests/compute_heap_store_check.py @@ -47,6 +47,7 @@ def lower(program=PROGRAM, **options): def controls(): assert base.aot.descriptor_format_word(75) == UINT4 + # Pin the translator call here. draw() exercises the generated guards against actual UAV contents. assert "store_heap_uint4(params[0].x, tid.x, 4u, uint4(tid.x," in lower() refuses = base.rejects refuses("Unsupported formatted buffer store target or address mode", lower, heap_store_view=None) @@ -109,6 +110,7 @@ def run(slot): (" || index >= view.z", "", 1), ("uint stride = view.y >> 16u;", "uint stride = 24u;", 1), ("const uint bytes = 512u;", "const uint bytes = 1280u;", 4), + ("if (index > (bytes - view.x - offset - 16u) / stride) return;", "", 3), (f"view.w != {UINT4:#x}u || ", "", 5), ("!= 1u) return;", "== 0u) return;", 2), (f"slot >= {VIEW[2]}u", f"slot > {VIEW[2]}u", VIEW[2]),