compute: read the buffer load V# from a run-time heap view record (Part of #2022) #2166

Merged
tedin7 merged 4 commits from upstream-pr/2174 into main 2026-11-25 05:58:27 +00:00
tedin7 commented 2026-11-25 02:52:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:52:20Z.


Part of #2022

What this unblocks: slice 2 of item A. Formatted buffer loads in compute_store_aot.py can take base, stride, num_records and the format from a V# view record chosen at run time, with range and lifetime controls, on top of the #2150 decoder.

Scope, stated plainly:

  • --heap-view SLOT_WORD TABLE_OFFSET COUNT BUFFER_BYTES reads a 32-byte record per view (V# words 0 to 3 plus a live state word) from a side table inside t0.
  • Refused, nothing stored: slot past the declared count, view not live or released, zero stride, unknown format, opcode width different from the format.
  • Zero read, still valid: index not below num_records, opcode wider than the stride, element leaving the buffer.
  • Not done: the records are not yet their own resource and the lookup is not ResourceDescriptorHeap[index] (SM 6.6). That needs a heap-indexed root signature and stays open under #2022 and #1143. This is not application coverage.

Tests: tests/compute_heap_view_check.py (controls, LLVM 15 round trip, WARP/hardware draw with 11-slot tables for the xy and xyzw opcodes, wrong references and mutated sources that must fail). Registered in CMake, the workflow and AGENTS.md; docs in docs/experiments.md#heap-view-buffer-loads.

Verification:

  • Linux: python3 -B tests/compute_heap_view_check.py controls, compute_load_format_check.py, compute_entry_layout_check.py, compute_alu_bcnt64_check.py, compute_alu_cmp_ne_check.py, docs_links_check.py, bidi_controls_check.py, run_checks_parallel_check.py, git diff --check: all pass.
  • Win2025: python3 x2w_pipe.py win2025 2174 --wait 3600 at head ab3bf742. Debug (--preset dev) PASS and Release /O2 (--preset release) PASS, ctest 63/63 passed including compute_heap_view_controls and compute_store_aot_heap_view_load_warp.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6596096152 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:52:20Z. --- Part of #2022 What this unblocks: slice 2 of item A. Formatted buffer loads in `compute_store_aot.py` can take base, stride, `num_records` and the format from a V# view record chosen at run time, with range and lifetime controls, on top of the #2150 decoder. Scope, stated plainly: - `--heap-view SLOT_WORD TABLE_OFFSET COUNT BUFFER_BYTES` reads a 32-byte record per view (V# words 0 to 3 plus a live state word) from a side table inside t0. - Refused, nothing stored: slot past the declared count, view not live or released, zero stride, unknown format, opcode width different from the format. - Zero read, still valid: index not below `num_records`, opcode wider than the stride, element leaving the buffer. - Not done: the records are not yet their own resource and the lookup is not `ResourceDescriptorHeap[index]` (SM 6.6). That needs a heap-indexed root signature and stays open under #2022 and #1143. This is not application coverage. Tests: `tests/compute_heap_view_check.py` (controls, LLVM 15 round trip, WARP/hardware draw with 11-slot tables for the xy and xyzw opcodes, wrong references and mutated sources that must fail). Registered in CMake, the workflow and AGENTS.md; docs in `docs/experiments.md#heap-view-buffer-loads`. Verification: - Linux: `python3 -B tests/compute_heap_view_check.py controls`, `compute_load_format_check.py`, `compute_entry_layout_check.py`, `compute_alu_bcnt64_check.py`, `compute_alu_cmp_ne_check.py`, `docs_links_check.py`, `bidi_controls_check.py`, `run_checks_parallel_check.py`, `git diff --check`: all pass. - Win2025: `python3 x2w_pipe.py win2025 2174 --wait 3600` at head ab3bf742. Debug (`--preset dev`) PASS and Release `/O2` (`--preset release`) PASS, ctest 63/63 passed including `compute_heap_view_controls` and `compute_store_aot_heap_view_load_warp`. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-25 04:04:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:39:12Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab3bf7425f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051511651 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#pullrequestreview-6051511651). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T03:39:12Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `ab3bf7425f` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot commented 2026-11-25 04:04:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:31:45Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T03:39:15.244776Z ab3bf74 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7151998933 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#issuecomment-7151998933). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T03:31:45Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"ab3bf7425fa34e3fc331746f68ae6078419d0453","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T03:39:15.244776Z">2026-11-25T03:39:15.244776Z</relative-time> | `ab3bf74` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-25 04:04:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:39:13Z.

Code review location: tools/compute_store_aot.py; line 633

@@ -601,12 +601,55 @@ def descriptor_load_hlsl():
     )
 
 
+HEAP_VIEW_RECORD_BYTES = 32
+HEAP_VIEW_LIVE = 1
+HEAP_VIEW_MAX = 64
+
+
+def heap_view_hlsl(table_offset, view_count, buffer_bytes):
+    """Retrieve the guest V# of one heap view from a side record table and bound the read by it.
+
+    The runtime writes one 32-byte record per heap view: V# words 0 to 3 (base byte offset, stride in
+    word 1 bits 29:16, num_records, format word), then a state word that is 1 only while the view is live,
+    then three reserved words. Words 1 to 3 follow the GFX10 V# layout of the public LLVM AMDGPU
+    documentation and Mesa's ac_build_buffer_descriptor; the record around them is this project's own.
+
+    load_heap_view_format sets valid to false, and returns zeros, for a slot beyond the table, a record that is not live, a zero stride or an unhandled format. lower() makes an
+    invalid load suppress every store, as for the constant format word. A live view whose index is not below
+    num_records, whose opcode needs more than one stride, or whose bytes leave the buffer_bytes of t0, reads as zero
+    and stays valid: the buffer-format unit's out-of-range result is zero (RDNA 2 ISA, buffer addressing).
+    """
+    return (
+        "uint4 load_heap_view_format(uint slot, uint index, uint instOffset, uint channels, out bool valid) {\n"
+        "    valid = false;\n"
+        "    uint4 zero = uint4(0u, 0u, 0u, 0u);\n"
+        f"    const uint length = {buffer_bytes}u;\n"
+        f"    if (slot >= {view_count}u) return zero;\n"
+        f"    uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u;\n"
+        f"    if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return zero;\n"
+        "    uint4 v = inputData.Load4(record);\n"
+        "    uint stride = (v.y >> 16u) & 0x3fffu;\n"
+        "    if (stride == 0u) return zero;\n"
+        "    bool inRange = index < v.z && index < 0x40000u && instOffset + 4u * channels <= stride && v.x <= length;\n"

P2 Badge Derive the index limit from the view's actual byte range

For a dispatch reaching index 262144, this fixed ceiling makes valid elements read zero. For example, a live two-channel view with base 0, stride 16, num_records=300000 and BUFFER_BYTES=4800000 contains the requested bytes at address 4194304, but this predicate sets inRange to false and the invocation stores zeros. lower() accepts a group size of eight, so a legal dispatch of 32769 groups reaches this case. Use an overflow-safe bound derived from the buffer length and stride rather than treating every index at or above 2^18 as out of range.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4690089785 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#discussion_r4690089785). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T03:39:13Z. **Code review location:** `tools/compute_store_aot.py`; line 633 ~~~~diff @@ -601,12 +601,55 @@ def descriptor_load_hlsl(): ) +HEAP_VIEW_RECORD_BYTES = 32 +HEAP_VIEW_LIVE = 1 +HEAP_VIEW_MAX = 64 + + +def heap_view_hlsl(table_offset, view_count, buffer_bytes): + """Retrieve the guest V# of one heap view from a side record table and bound the read by it. + + The runtime writes one 32-byte record per heap view: V# words 0 to 3 (base byte offset, stride in + word 1 bits 29:16, num_records, format word), then a state word that is 1 only while the view is live, + then three reserved words. Words 1 to 3 follow the GFX10 V# layout of the public LLVM AMDGPU + documentation and Mesa's ac_build_buffer_descriptor; the record around them is this project's own. + + load_heap_view_format sets valid to false, and returns zeros, for a slot beyond the table, a record that is not live, a zero stride or an unhandled format. lower() makes an + invalid load suppress every store, as for the constant format word. A live view whose index is not below + num_records, whose opcode needs more than one stride, or whose bytes leave the buffer_bytes of t0, reads as zero + and stays valid: the buffer-format unit's out-of-range result is zero (RDNA 2 ISA, buffer addressing). + """ + return ( + "uint4 load_heap_view_format(uint slot, uint index, uint instOffset, uint channels, out bool valid) {\n" + " valid = false;\n" + " uint4 zero = uint4(0u, 0u, 0u, 0u);\n" + f" const uint length = {buffer_bytes}u;\n" + f" if (slot >= {view_count}u) return zero;\n" + f" uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u;\n" + f" if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return zero;\n" + " uint4 v = inputData.Load4(record);\n" + " uint stride = (v.y >> 16u) & 0x3fffu;\n" + " if (stride == 0u) return zero;\n" + " bool inRange = index < v.z && index < 0x40000u && instOffset + 4u * channels <= stride && v.x <= length;\n" ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Derive the index limit from the view's actual byte range** For a dispatch reaching index 262144, this fixed ceiling makes valid elements read zero. For example, a live two-channel view with base 0, stride 16, `num_records=300000` and `BUFFER_BYTES=4800000` contains the requested bytes at address 4194304, but this predicate sets `inRange` to false and the invocation stores zeros. `lower()` accepts a group size of eight, so a legal dispatch of 32769 groups reaches this case. Use an overflow-safe bound derived from the buffer length and stride rather than treating every index at or above 2^18 as out of range. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 04:04:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:39:13Z.

Code review location: tools/compute_store_aot.py; line 632

@@ -601,12 +601,55 @@ def descriptor_load_hlsl():
     )
 
 
+HEAP_VIEW_RECORD_BYTES = 32
+HEAP_VIEW_LIVE = 1
+HEAP_VIEW_MAX = 64
+
+
+def heap_view_hlsl(table_offset, view_count, buffer_bytes):
+    """Retrieve the guest V# of one heap view from a side record table and bound the read by it.
+
+    The runtime writes one 32-byte record per heap view: V# words 0 to 3 (base byte offset, stride in
+    word 1 bits 29:16, num_records, format word), then a state word that is 1 only while the view is live,
+    then three reserved words. Words 1 to 3 follow the GFX10 V# layout of the public LLVM AMDGPU
+    documentation and Mesa's ac_build_buffer_descriptor; the record around them is this project's own.
+
+    load_heap_view_format sets valid to false, and returns zeros, for a slot beyond the table, a record that is not live, a zero stride or an unhandled format. lower() makes an
+    invalid load suppress every store, as for the constant format word. A live view whose index is not below
+    num_records, whose opcode needs more than one stride, or whose bytes leave the buffer_bytes of t0, reads as zero
+    and stays valid: the buffer-format unit's out-of-range result is zero (RDNA 2 ISA, buffer addressing).
+    """
+    return (
+        "uint4 load_heap_view_format(uint slot, uint index, uint instOffset, uint channels, out bool valid) {\n"
+        "    valid = false;\n"
+        "    uint4 zero = uint4(0u, 0u, 0u, 0u);\n"
+        f"    const uint length = {buffer_bytes}u;\n"
+        f"    if (slot >= {view_count}u) return zero;\n"
+        f"    uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u;\n"
+        f"    if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return zero;\n"
+        "    uint4 v = inputData.Load4(record);\n"
+        "    uint stride = (v.y >> 16u) & 0x3fffu;\n"
+        "    if (stride == 0u) return zero;\n"

P2 Badge Enforce DWORD alignment on runtime view addresses

For a live view with an unaligned base or stride, these guards allow load_descriptor_format() to receive an address that violates its inputData.Load4(addr) DWORD-alignment requirement. A supported R16_UINT/buffer_load_format_x view with base 2, stride 4 and eight records passes every range check and loads at address 2; base 0 and stride 6 similarly produces address 6 for index 1. The static path enforces aligned strides, but heap views explicitly exclude that validation without replacing it at runtime. Reject misaligned records or implement unaligned word extraction before decoding to avoid undefined or incorrect readback.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4690089795 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#discussion_r4690089795). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T03:39:13Z. **Code review location:** `tools/compute_store_aot.py`; line 632 ~~~~diff @@ -601,12 +601,55 @@ def descriptor_load_hlsl(): ) +HEAP_VIEW_RECORD_BYTES = 32 +HEAP_VIEW_LIVE = 1 +HEAP_VIEW_MAX = 64 + + +def heap_view_hlsl(table_offset, view_count, buffer_bytes): + """Retrieve the guest V# of one heap view from a side record table and bound the read by it. + + The runtime writes one 32-byte record per heap view: V# words 0 to 3 (base byte offset, stride in + word 1 bits 29:16, num_records, format word), then a state word that is 1 only while the view is live, + then three reserved words. Words 1 to 3 follow the GFX10 V# layout of the public LLVM AMDGPU + documentation and Mesa's ac_build_buffer_descriptor; the record around them is this project's own. + + load_heap_view_format sets valid to false, and returns zeros, for a slot beyond the table, a record that is not live, a zero stride or an unhandled format. lower() makes an + invalid load suppress every store, as for the constant format word. A live view whose index is not below + num_records, whose opcode needs more than one stride, or whose bytes leave the buffer_bytes of t0, reads as zero + and stays valid: the buffer-format unit's out-of-range result is zero (RDNA 2 ISA, buffer addressing). + """ + return ( + "uint4 load_heap_view_format(uint slot, uint index, uint instOffset, uint channels, out bool valid) {\n" + " valid = false;\n" + " uint4 zero = uint4(0u, 0u, 0u, 0u);\n" + f" const uint length = {buffer_bytes}u;\n" + f" if (slot >= {view_count}u) return zero;\n" + f" uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u;\n" + f" if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return zero;\n" + " uint4 v = inputData.Load4(record);\n" + " uint stride = (v.y >> 16u) & 0x3fffu;\n" + " if (stride == 0u) return zero;\n" ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Enforce DWORD alignment on runtime view addresses** For a live view with an unaligned base or stride, these guards allow `load_descriptor_format()` to receive an address that violates its `inputData.Load4(addr)` DWORD-alignment requirement. A supported `R16_UINT`/`buffer_load_format_x` view with base 2, stride 4 and eight records passes every range check and loads at address 2; base 0 and stride 6 similarly produces address 6 for index 1. The static path enforces aligned strides, but heap views explicitly exclude that validation without replacing it at runtime. Reject misaligned records or implement unaligned word extraction before decoding to avoid undefined or incorrect readback. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-25 05:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:46:38Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051993108 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#pullrequestreview-6051993108). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:46:38Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 05:04:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:46:40Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051993309 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#pullrequestreview-6051993309). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:46:40Z. **Review:** COMMENTED --- _No description provided._
RavenCurseBurg commented 2026-11-25 05:04:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T04:54:12Z.


While preparing the adjacent store fixture for #2022 B, I noticed that XYZW_VIEWS labels its index past num_records row 32_32_32_32_UINT but passes format 77. I checked both names with LLVM 15.0.7 targeting gfx1013. With otherwise identical tbuffer_load_format_xyzw operands, UINT assembled to 40d05bea00054203 (format 75) and FLOAT to 40d06bea00054203 (77). The tree's tools/disasm_rdna2.py table agrees. The raw four-dword readback can pass for either. If this row is intended as UINT coverage, could you switch the code to 75? If it is intended as FLOAT, the label can say FLOAT. Our store fixture will use 75.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153268154 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#issuecomment-7153268154). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T04:54:12Z. --- While preparing the adjacent store fixture for #2022 B, I noticed that `XYZW_VIEWS` labels its `index past num_records` row `32_32_32_32_UINT` but passes format 77. I checked both names with LLVM 15.0.7 targeting gfx1013. With otherwise identical `tbuffer_load_format_xyzw` operands, UINT assembled to `40d05bea00054203` (format 75) and FLOAT to `40d06bea00054203` (77). The tree's `tools/disasm_rdna2.py` table agrees. The raw four-dword readback can pass for either. If this row is intended as UINT coverage, could you switch the code to 75? If it is intended as FLOAT, the label can say FLOAT. Our store fixture will use 75.
tedin7 commented 2026-11-25 05:04:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:46:38Z.

Code review location: tools/compute_store_aot.py; line 633

@@ -601,12 +601,55 @@ def descriptor_load_hlsl():
     )
 
 
+HEAP_VIEW_RECORD_BYTES = 32
+HEAP_VIEW_LIVE = 1
+HEAP_VIEW_MAX = 64
+
+
+def heap_view_hlsl(table_offset, view_count, buffer_bytes):
+    """Retrieve the guest V# of one heap view from a side record table and bound the read by it.
+
+    The runtime writes one 32-byte record per heap view: V# words 0 to 3 (base byte offset, stride in
+    word 1 bits 29:16, num_records, format word), then a state word that is 1 only while the view is live,
+    then three reserved words. Words 1 to 3 follow the GFX10 V# layout of the public LLVM AMDGPU
+    documentation and Mesa's ac_build_buffer_descriptor; the record around them is this project's own.
+
+    load_heap_view_format sets valid to false, and returns zeros, for a slot beyond the table, a record that is not live, a zero stride or an unhandled format. lower() makes an
+    invalid load suppress every store, as for the constant format word. A live view whose index is not below
+    num_records, whose opcode needs more than one stride, or whose bytes leave the buffer_bytes of t0, reads as zero
+    and stays valid: the buffer-format unit's out-of-range result is zero (RDNA 2 ISA, buffer addressing).
+    """
+    return (
+        "uint4 load_heap_view_format(uint slot, uint index, uint instOffset, uint channels, out bool valid) {\n"
+        "    valid = false;\n"
+        "    uint4 zero = uint4(0u, 0u, 0u, 0u);\n"
+        f"    const uint length = {buffer_bytes}u;\n"
+        f"    if (slot >= {view_count}u) return zero;\n"
+        f"    uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u;\n"
+        f"    if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return zero;\n"
+        "    uint4 v = inputData.Load4(record);\n"
+        "    uint stride = (v.y >> 16u) & 0x3fffu;\n"
+        "    if (stride == 0u) return zero;\n"
+        "    bool inRange = index < v.z && index < 0x40000u && instOffset + 4u * channels <= stride && v.x <= length;\n"

Fixed in dfc6c2c0 (fix 5bf90a9f). The fixed 2^18 ceiling is gone; the bound is now index <= (buffer length - base) / stride, which cannot wrap. Note: the fixture buffer is 1280 bytes, so a dispatch cannot reach index 2^18; the controls assert the new bound on the generated source and two mutations (index bound, buffer end) fail on WARP.

Verification: python3 -B tests/compute_heap_view_check.py controls, compute_load_format_check.py, docs_links_check.py on Linux; x2w_pipe.py win2025 2174 --force: dev 63/63 and release 63/63 passed, no skips.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4690507662 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#discussion_r4690507662). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:46:38Z. **Code review location:** `tools/compute_store_aot.py`; line 633 ~~~~diff @@ -601,12 +601,55 @@ def descriptor_load_hlsl(): ) +HEAP_VIEW_RECORD_BYTES = 32 +HEAP_VIEW_LIVE = 1 +HEAP_VIEW_MAX = 64 + + +def heap_view_hlsl(table_offset, view_count, buffer_bytes): + """Retrieve the guest V# of one heap view from a side record table and bound the read by it. + + The runtime writes one 32-byte record per heap view: V# words 0 to 3 (base byte offset, stride in + word 1 bits 29:16, num_records, format word), then a state word that is 1 only while the view is live, + then three reserved words. Words 1 to 3 follow the GFX10 V# layout of the public LLVM AMDGPU + documentation and Mesa's ac_build_buffer_descriptor; the record around them is this project's own. + + load_heap_view_format sets valid to false, and returns zeros, for a slot beyond the table, a record that is not live, a zero stride or an unhandled format. lower() makes an + invalid load suppress every store, as for the constant format word. A live view whose index is not below + num_records, whose opcode needs more than one stride, or whose bytes leave the buffer_bytes of t0, reads as zero + and stays valid: the buffer-format unit's out-of-range result is zero (RDNA 2 ISA, buffer addressing). + """ + return ( + "uint4 load_heap_view_format(uint slot, uint index, uint instOffset, uint channels, out bool valid) {\n" + " valid = false;\n" + " uint4 zero = uint4(0u, 0u, 0u, 0u);\n" + f" const uint length = {buffer_bytes}u;\n" + f" if (slot >= {view_count}u) return zero;\n" + f" uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u;\n" + f" if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return zero;\n" + " uint4 v = inputData.Load4(record);\n" + " uint stride = (v.y >> 16u) & 0x3fffu;\n" + " if (stride == 0u) return zero;\n" + " bool inRange = index < v.z && index < 0x40000u && instOffset + 4u * channels <= stride && v.x <= length;\n" ~~~~ --- Fixed in dfc6c2c0 (fix 5bf90a9f). The fixed 2^18 ceiling is gone; the bound is now index <= (buffer length - base) / stride, which cannot wrap. Note: the fixture buffer is 1280 bytes, so a dispatch cannot reach index 2^18; the controls assert the new bound on the generated source and two mutations (index bound, buffer end) fail on WARP. Verification: python3 -B tests/compute_heap_view_check.py controls, compute_load_format_check.py, docs_links_check.py on Linux; x2w_pipe.py win2025 2174 --force: dev 63/63 and release 63/63 passed, no skips. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 05:04:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:46:40Z.

Code review location: tools/compute_store_aot.py; line 632

@@ -601,12 +601,55 @@ def descriptor_load_hlsl():
     )
 
 
+HEAP_VIEW_RECORD_BYTES = 32
+HEAP_VIEW_LIVE = 1
+HEAP_VIEW_MAX = 64
+
+
+def heap_view_hlsl(table_offset, view_count, buffer_bytes):
+    """Retrieve the guest V# of one heap view from a side record table and bound the read by it.
+
+    The runtime writes one 32-byte record per heap view: V# words 0 to 3 (base byte offset, stride in
+    word 1 bits 29:16, num_records, format word), then a state word that is 1 only while the view is live,
+    then three reserved words. Words 1 to 3 follow the GFX10 V# layout of the public LLVM AMDGPU
+    documentation and Mesa's ac_build_buffer_descriptor; the record around them is this project's own.
+
+    load_heap_view_format sets valid to false, and returns zeros, for a slot beyond the table, a record that is not live, a zero stride or an unhandled format. lower() makes an
+    invalid load suppress every store, as for the constant format word. A live view whose index is not below
+    num_records, whose opcode needs more than one stride, or whose bytes leave the buffer_bytes of t0, reads as zero
+    and stays valid: the buffer-format unit's out-of-range result is zero (RDNA 2 ISA, buffer addressing).
+    """
+    return (
+        "uint4 load_heap_view_format(uint slot, uint index, uint instOffset, uint channels, out bool valid) {\n"
+        "    valid = false;\n"
+        "    uint4 zero = uint4(0u, 0u, 0u, 0u);\n"
+        f"    const uint length = {buffer_bytes}u;\n"
+        f"    if (slot >= {view_count}u) return zero;\n"
+        f"    uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u;\n"
+        f"    if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return zero;\n"
+        "    uint4 v = inputData.Load4(record);\n"
+        "    uint stride = (v.y >> 16u) & 0x3fffu;\n"
+        "    if (stride == 0u) return zero;\n"

Fixed in dfc6c2c0 (fix 5bf90a9f). A live view whose base, stride or instruction offset is not a multiple of 4 is now refused (valid=false, stores suppressed) before the DWORD load. New fixture views: unaligned base and unaligned stride, on xy and xyzw, plus two mutations that fail on WARP.

Verification: python3 -B tests/compute_heap_view_check.py controls, compute_load_format_check.py, docs_links_check.py on Linux; x2w_pipe.py win2025 2174 --force: dev 63/63 and release 63/63 passed, no skips.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4690507848 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#discussion_r4690507848). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:46:40Z. **Code review location:** `tools/compute_store_aot.py`; line 632 ~~~~diff @@ -601,12 +601,55 @@ def descriptor_load_hlsl(): ) +HEAP_VIEW_RECORD_BYTES = 32 +HEAP_VIEW_LIVE = 1 +HEAP_VIEW_MAX = 64 + + +def heap_view_hlsl(table_offset, view_count, buffer_bytes): + """Retrieve the guest V# of one heap view from a side record table and bound the read by it. + + The runtime writes one 32-byte record per heap view: V# words 0 to 3 (base byte offset, stride in + word 1 bits 29:16, num_records, format word), then a state word that is 1 only while the view is live, + then three reserved words. Words 1 to 3 follow the GFX10 V# layout of the public LLVM AMDGPU + documentation and Mesa's ac_build_buffer_descriptor; the record around them is this project's own. + + load_heap_view_format sets valid to false, and returns zeros, for a slot beyond the table, a record that is not live, a zero stride or an unhandled format. lower() makes an + invalid load suppress every store, as for the constant format word. A live view whose index is not below + num_records, whose opcode needs more than one stride, or whose bytes leave the buffer_bytes of t0, reads as zero + and stays valid: the buffer-format unit's out-of-range result is zero (RDNA 2 ISA, buffer addressing). + """ + return ( + "uint4 load_heap_view_format(uint slot, uint index, uint instOffset, uint channels, out bool valid) {\n" + " valid = false;\n" + " uint4 zero = uint4(0u, 0u, 0u, 0u);\n" + f" const uint length = {buffer_bytes}u;\n" + f" if (slot >= {view_count}u) return zero;\n" + f" uint record = {table_offset}u + slot * {HEAP_VIEW_RECORD_BYTES}u;\n" + f" if (inputData.Load(record + 16u) != {HEAP_VIEW_LIVE}u) return zero;\n" + " uint4 v = inputData.Load4(record);\n" + " uint stride = (v.y >> 16u) & 0x3fffu;\n" + " if (stride == 0u) return zero;\n" ~~~~ --- Fixed in dfc6c2c0 (fix 5bf90a9f). A live view whose base, stride or instruction offset is not a multiple of 4 is now refused (valid=false, stores suppressed) before the DWORD load. New fixture views: unaligned base and unaligned stride, on xy and xyzw, plus two mutations that fail on WARP. Verification: python3 -B tests/compute_heap_view_check.py controls, compute_load_format_check.py, docs_links_check.py on Linux; x2w_pipe.py win2025 2174 --force: dev 63/63 and release 63/63 passed, no skips. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 06:01:19 +00:00
stan495 commented 2026-11-25 06:01:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T05:42:18Z.

Review: APPROVED


Verified head 5ba80892 on Windows x64 (dev preset, MSVC 19.44.35228.0, SDK/DXC 10.0.26100.0):

  • cmake --build --preset dev --target offscreen_check -> succeeded
  • ctest --preset dev --no-tests=error -R '^(compute_heap_view_controls|compute_store_aot_heap_view_load_)' -V -> 3/3 passed (compute_heap_view_controls, compute_store_aot_heap_view_load_hardware, compute_store_aot_heap_view_load_warp)
    • heap_view_load: 56 dispatches, 6 wrong references and 14 mutated sources checked (debug_layer=enabled, debug_errors=0 debug_warnings=0).
    • Hardware: AMD Radeon RX 7900 XTX (vendor=1002 device=744c, driver 32.0.32029.2010)
    • WARP: Microsoft Basic Render Driver (vendor=1414 device=008c, driver 10.0.26100.9818)

Verdict: Approved at 5ba80892.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052426455 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#pullrequestreview-6052426455). Originally posted by [stan495](https://github.com/stan495) on 2026-11-25T05:42:18Z. **Review:** APPROVED --- Verified head `5ba80892` on Windows x64 (`dev` preset, MSVC `19.44.35228.0`, SDK/DXC `10.0.26100.0`): - `cmake --build --preset dev --target offscreen_check` -> succeeded - `ctest --preset dev --no-tests=error -R '^(compute_heap_view_controls|compute_store_aot_heap_view_load_)' -V` -> 3/3 passed (`compute_heap_view_controls`, `compute_store_aot_heap_view_load_hardware`, `compute_store_aot_heap_view_load_warp`) - `heap_view_load`: 56 dispatches, 6 wrong references and 14 mutated sources checked (`debug_layer=enabled`, `debug_errors=0 debug_warnings=0`). - Hardware: `AMD Radeon RX 7900 XTX` (`vendor=1002 device=744c`, driver `32.0.32029.2010`) - WARP: `Microsoft Basic Render Driver` (`vendor=1414 device=008c`, driver `10.0.26100.9818`) Verdict: Approved at `5ba80892`.
tedin7 commented 2026-11-25 06:01:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:05:26Z.


Thank you @RavenCurseBurg, good catch and a clear write-up.

Fixed in 5ba80892: the 32_32_32_32_UINT, index past num_records row in XYZW_VIEWS (tests/compute_heap_view_check.py) now passes format 75, matching its label and the tools/disasm_rdna2.py table.

Verification:

  • python3 -I tests/compute_heap_view_check.py: self-test passed
  • python3 -I tests/docs_links_check.py: 18 Markdown files, 404 links OK
  • Win2025 3-slot WARP: dev 63/63 passed, release 63/63 passed (includes compute_heap_view_controls, compute_store_aot_heap_view_load_warp)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153440273 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#issuecomment-7153440273). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T05:05:26Z. --- Thank you @RavenCurseBurg, good catch and a clear write-up. Fixed in 5ba80892: the `32_32_32_32_UINT, index past num_records` row in `XYZW_VIEWS` (`tests/compute_heap_view_check.py`) now passes format 75, matching its label and the `tools/disasm_rdna2.py` table. Verification: - `python3 -I tests/compute_heap_view_check.py`: self-test passed - `python3 -I tests/docs_links_check.py`: 18 Markdown files, 404 links OK - Win2025 3-slot WARP: dev 63/63 passed, release 63/63 passed (includes `compute_heap_view_controls`, `compute_store_aot_heap_view_load_warp`) AI-assisted; commands listed were executed locally.
RavenCurseBurg commented 2026-11-25 06:01:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T05:40:54Z.


I checked out 5ba8089240c09b81c7e16c1ab355bccf533f4e8e in a clean worktree and ran python -B tests/compute_heap_view_check.py draw <dxc> <offscreen_check> warp, then the same command with hardware on Windows x64. Both runs passed all 56 dispatches and detected all six wrong references and fourteen mutated shaders, including the corrected UINT4 case. I used DXC v1.9.2609 and the source-built offscreen_check from ab9a020c. This independently checks the load-side record layout used by the item B store fixture.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154033337 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#issuecomment-7154033337). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T05:40:54Z. --- I checked out `5ba8089240c09b81c7e16c1ab355bccf533f4e8e` in a clean worktree and ran `python -B tests/compute_heap_view_check.py draw <dxc> <offscreen_check> warp`, then the same command with `hardware` on Windows x64. Both runs passed all 56 dispatches and detected all six wrong references and fourteen mutated shaders, including the corrected UINT4 case. I used DXC v1.9.2609 and the source-built [`offscreen_check` from `ab9a020c`](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45551525537). This independently checks the load-side record layout used by the item B store fixture.
legacy-code-archaeologist commented 2026-11-25 06:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T05:58:12Z.


Ran head 5ba80892. Windows 11 build 26100, debug layer unavailable. Adapters: WARP 10.0.26100.8972, NVIDIA Quadro M1000M 32.0.15.7371, Intel HD Graphics 530 31.0.101.2111, the hardware ones selected with XBOX2WINDOWS_ADAPTER.

Test WARP Quadro M1000M Intel HD 530
compute_heap_view_controls pass n/a n/a
compute_store_aot_heap_view_load_{warp,hardware} pass, 56/56 dispatches mismatches=0 (21 s) pass, same (33 s) pass, same (35 s)

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154310760 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2174#issuecomment-7154310760). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-25T05:58:12Z. --- Ran head `5ba80892`. Windows 11 build 26100, debug layer unavailable. Adapters: WARP 10.0.26100.8972, NVIDIA Quadro M1000M 32.0.15.7371, Intel HD Graphics 530 31.0.101.2111, the hardware ones selected with `XBOX2WINDOWS_ADAPTER`. | Test | WARP | Quadro M1000M | Intel HD 530 | |---|---|---|---| | `compute_heap_view_controls` | pass | n/a | n/a | | `compute_store_aot_heap_view_load_{warp,hardware}` | pass, 56/56 dispatches `mismatches=0` (21 s) | pass, same (33 s) | pass, same (35 s) | _AI-assisted._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2166
No description provided.