[PR #1097] [CLOSED] d3d12: check field offsets within structured buffer SRV records (SHADER-BUFFER-BOUNDS) #1131

Closed
opened 2026-11-26 20:20:11 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1097
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: split/shader-buffer-bounds


📝 Commits (1)

  • 8fc4abb d3d12: check field offsets within structured buffer SRV records (SHADER-BUFFER-BOUNDS)

📊 Changes

4 files changed (+23 additions, -10 deletions)

View changed files

📝 docs/buffer_bounds.md (+3 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+2 -1)
📝 runtime/test/d3d12_compute_test.cpp (+14 -6)
📝 runtime/test/glsl/cs_user_data.comp (+4 -3)

📄 Description

Claimed in the coordination issue as: SHADER-BUFFER-BOUNDS (claim).

Part of the split of #984 into small pull requests.

Depends on: none
Overlaps: #220 validates SRV descriptions, #513 changes CBV stride, and #1068 widens translator address arithmetic. This change selects the descriptor bounds mode for structured buffer SRVs.

What and why

A structured buffer SRV used the typed view's index-only bounds mode. A four-byte field starting at the end of an indexed record could therefore read the next record. Select mode 0 for structured SRVs, matching the structured UAV encoding. Raw views keep byte bounds. Typed views keep record-index bounds.

The synthetic GPU fixture reads the same field offset through a structured view and a typed view. With 16-byte records, offset 16 must read zero for the structured view. The typed control reads the next value for each valid index.

Tested

Cross-built with clang-cl 23 and the xwin SDK. Ran under CachyOS Linux 7.3, Proton Experimental (Wine 11), Ryzen 5 5600X, 16 GB RAM, RTX 4070 12 GB and NVIDIA 620.73.

cmake --build runtime/build/boot --target gta6rt d3d12_compute_test -j6
spirv-val --target-env vulkan1.3 runtime/build/boot/generated/cs_user_data.spv
(cd runtime/build/boot && "$WINE" d3d12_compute_test.exe)
Configuration Descriptor and readback results
Main plus tests The structured descriptor assertion failed on the first of two structured views. The fixture stopped before GPU readback.
Child Both structured descriptors encoded mode 0. The GPU returned 64/64 zero values through the structured view and the expected 24 values and 40 zeros through the typed view (64/64).

The fixture skipped its native D3D12 CachedPSO comparison under Wine. Native Windows, AMD, Intel and a game boot were not tested.
GPUs tested: NVIDIA GeForce RTX 4070.
AI-assisted: yes

Checklist

  • One commit on upstream main at the cut. Clean merge check.
  • One descriptor change with structured and typed controls.
  • Changed-file game-data guard and whitespace check passed.
  • No translator rule changed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1097 **Author:** [@Moriz82](https://github.com/Moriz82) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `split/shader-buffer-bounds` --- ### 📝 Commits (1) - [`8fc4abb`](https://github.com/ubiquitarianism/leonida/commit/8fc4abbf015f4b7859c652dd10462fec26c5974b) d3d12: check field offsets within structured buffer SRV records (SHADER-BUFFER-BOUNDS) ### 📊 Changes **4 files changed** (+23 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `docs/buffer_bounds.md` (+3 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+2 -1) 📝 `runtime/test/d3d12_compute_test.cpp` (+14 -6) 📝 `runtime/test/glsl/cs_user_data.comp` (+4 -3) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-BUFFER-BOUNDS ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140526569)). Part of the split of #984 into small pull requests. Depends on: none Overlaps: #220 validates SRV descriptions, #513 changes CBV stride, and #1068 widens translator address arithmetic. This change selects the descriptor bounds mode for structured buffer SRVs. ### What and why A structured buffer SRV used the typed view's index-only bounds mode. A four-byte field starting at the end of an indexed record could therefore read the next record. Select mode 0 for structured SRVs, matching the structured UAV encoding. Raw views keep byte bounds. Typed views keep record-index bounds. The synthetic GPU fixture reads the same field offset through a structured view and a typed view. With 16-byte records, offset 16 must read zero for the structured view. The typed control reads the next value for each valid index. ### Tested Cross-built with clang-cl 23 and the xwin SDK. Ran under CachyOS Linux 7.3, Proton Experimental (Wine 11), Ryzen 5 5600X, 16 GB RAM, RTX 4070 12 GB and NVIDIA 620.73. ```sh cmake --build runtime/build/boot --target gta6rt d3d12_compute_test -j6 spirv-val --target-env vulkan1.3 runtime/build/boot/generated/cs_user_data.spv (cd runtime/build/boot && "$WINE" d3d12_compute_test.exe) ``` | Configuration | Descriptor and readback results | | --- | --- | | Main plus tests | The structured descriptor assertion failed on the first of two structured views. The fixture stopped before GPU readback. | | Child | Both structured descriptors encoded mode 0. The GPU returned 64/64 zero values through the structured view and the expected 24 values and 40 zeros through the typed view (64/64). | The fixture skipped its native D3D12 CachedPSO comparison under Wine. Native Windows, AMD, Intel and a game boot were not tested. GPUs tested: NVIDIA GeForce RTX 4070. AI-assisted: yes ### Checklist - [x] One commit on upstream main at the cut. Clean merge check. - [x] One descriptor change with structured and typed controls. - [x] Changed-file game-data guard and whitespace check passed. - [x] No translator rule changed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:20:11 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1131
No description provided.