[PR #513] [CLOSED] d3d12: a constant-buffer view's V# steps 16 bytes a row (RT-CBV-VSHARP-STRIDE) #562

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/513
Author: @oscarlosu-lab
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: pr/cbv-vsharp-stride


📝 Commits (1)

  • a29c21b d3d12: a constant-buffer view's V# steps 16 bytes a row (RT-CBV-VSHARP-STRIDE)

📊 Changes

3 files changed (+19 additions, -6 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+9 -3)
📝 runtime/shims/d3d12_vulkan_device.cpp (+8 -1)
📝 runtime/test/d3d12_compute_test.cpp (+2 -2)

📄 Description

Claimed in the coordination issue as: RT-CBV-VSHARP-STRIDE

What and why

CreateConstantBufferView wrote the CBV's raw GFX10 V# with STRIDE 0. A translated buffer access with idxen adds index × V# STRIDE to the address (tools/rdna2spirv.py, buffer addressing), so a program that indexes its constant buffer by 16-byte row read row 0 for every index.

ThatRecompDev/five-star-recomp (GPL-3.0), commit 4c6bce59b, measured this on the retail title: the UI's batch programs read each vertex's matrix rows from their CBV by index (row batch × 4 + k); with stride 0 both screen coordinates came out equal and every vector shape of the UI fell on the line x = y (the diagonal across the first-run screens, letters drawn as shapes). Their fix gives a buffer view's record the element stride: 16 for a CBV, the structure for a structured view, the element for a typed one, 0 for raw. In Leonida the structured and typed buffer SRV/UAV paths already write their stride and raw views keep 0, so the CBV is the only gap.

Change

  • runtime/shims/d3d12_vulkan_device.cpp: the CBV V#'s STRIDE is 16 (kConstantBufferRow). NUM_RECORDS stays the view's size in bytes with OOB_SELECT RAW: RAW bounds a MUBUF access by its offset, not index × STRIDE (docs/design.md, Buffer bounds checking), so that bound is unchanged. An s_buffer_load bound becomes NUM_RECORDS × STRIDE, past the end of any constant a program declares.
  • runtime/test/d3d12_compute_test.cpp: the decoded CBV words expect STRIDE 16.
  • docs/d3d12_vulkan.md: describes the CBV V#; the known-gaps list still said CBVs and buffer SRVs were not written.

Tested

Windows 11, MSVC 19.52 x64, NVIDIA GeForce RTX 3060 (driver 621.35): runtime builds with no warnings in the touched files; d3d12_compute_test, d3d12_descriptor_test and d3d12_vulkan_device_test pass. scripts/check_no_game_data.py and tests/test_docs_links.py pass. Not yet measured on a retail boot here; I will add the result when we have it.

AI-assisted (Claude Code). No game files.


🔄 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/513 **Author:** [@oscarlosu-lab](https://github.com/oscarlosu-lab) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/cbv-vsharp-stride` --- ### 📝 Commits (1) - [`a29c21b`](https://github.com/ubiquitarianism/leonida/commit/a29c21b59487595f84b8696dcb99f978a11630d6) d3d12: a constant-buffer view's V# steps 16 bytes a row (RT-CBV-VSHARP-STRIDE) ### 📊 Changes **3 files changed** (+19 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+9 -3) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+8 -1) 📝 `runtime/test/d3d12_compute_test.cpp` (+2 -2) </details> ### 📄 Description Claimed in the coordination issue as: RT-CBV-VSHARP-STRIDE ### What and why `CreateConstantBufferView` wrote the CBV's raw GFX10 V# with STRIDE 0. A translated buffer access with `idxen` adds index × V# STRIDE to the address (`tools/rdna2spirv.py`, buffer addressing), so a program that indexes its constant buffer by 16-byte row read row 0 for every index. ThatRecompDev/five-star-recomp (GPL-3.0), commit `4c6bce59b`, measured this on the retail title: the UI's batch programs read each vertex's matrix rows from their CBV by index (row batch × 4 + k); with stride 0 both screen coordinates came out equal and every vector shape of the UI fell on the line x = y (the diagonal across the first-run screens, letters drawn as shapes). Their fix gives a buffer view's record the element stride: 16 for a CBV, the structure for a structured view, the element for a typed one, 0 for raw. In Leonida the structured and typed buffer SRV/UAV paths already write their stride and raw views keep 0, so the CBV is the only gap. ### Change - `runtime/shims/d3d12_vulkan_device.cpp`: the CBV V#'s STRIDE is 16 (`kConstantBufferRow`). NUM_RECORDS stays the view's size in bytes with OOB_SELECT RAW: RAW bounds a MUBUF access by its offset, not index × STRIDE (`docs/design.md`, Buffer bounds checking), so that bound is unchanged. An `s_buffer_load` bound becomes NUM_RECORDS × STRIDE, past the end of any constant a program declares. - `runtime/test/d3d12_compute_test.cpp`: the decoded CBV words expect STRIDE 16. - `docs/d3d12_vulkan.md`: describes the CBV V#; the known-gaps list still said CBVs and buffer SRVs were not written. ### Tested Windows 11, MSVC 19.52 x64, NVIDIA GeForce RTX 3060 (driver 621.35): runtime builds with no warnings in the touched files; `d3d12_compute_test`, `d3d12_descriptor_test` and `d3d12_vulkan_device_test` pass. `scripts/check_no_game_data.py` and `tests/test_docs_links.py` pass. Not yet measured on a retail boot here; I will add the result when we have it. AI-assisted (Claude Code). No game files. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:18 +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#562
No description provided.