Skip to content

Pass storage buffer strides and structured slots to XDL so Direct3D 12 reads StructuredBuffer<T> correctly - #723

Merged
stanoddly merged 4 commits into
mainfrom
d3d12-structured-buffer-views
Nov 12, 2026
Merged

stanoddly merged 4 commits into
mainfrom
d3d12-structured-buffer-views

Conversation

@botoddly

@botoddly botoddly commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

SDL's Direct3D 12 driver views every storage buffer as raw, so a shader's StructuredBuffer<T> or RWStructuredBuffer<T> is read through a view of the wrong kind. On an AMD Radeon RX Vega 11 every index then reads element 0. stanoddly/XDL#35 lets XDL create structured views when it knows each buffer's stride and each shader's structured slots. This passes them:

  • The shader compiler records which storage buffer slots are StructuredBuffer<T> or RWStructuredBuffer<T>, from the reflected shape rather than the element size, as ShaderBindingLayout.StructuredStorageBuffers and ReadWriteStructuredStorageBuffers.
  • GpuDevice.CreateBufferCore takes a stride. Storage buffers pass Unsafe.SizeOf<T>(), and other buffers pass 0.
  • CreateShaderCore and CreateComputePipelineCore take the slot masks. SdlGpuDevice sets the XDL_PROP_* properties only when a value is nonzero, checks each call, and destroys the properties in finally.
  • The stub device records strides and masks. Tests cover reflection of mixed structured and byte address buffers, buffer strides, and the masks of graphics shaders and compute pipelines.
  • docs/shaders.md explains the stride and its Direct3D 12 limits.

Draft until nuget.org lists XdlSharp 3.4.20.5

This moves to XdlSharp 3.4.20.5 (stanoddly/XdlSharp#6), which binds the four property names. Its Release run succeeded and tagged v3.4.20.5, but nuget.org does not list it yet, so CI cannot restore it until then.

Testing

…2 reads StructuredBuffer<T> through structured views
… and qualify the Direct3D 12 stride limits in the shader docs
@botoddly
botoddly marked this pull request as ready for review November 12, 2026 16:11
@stanoddly
stanoddly merged commit af100b0 into main Nov 12, 2026
3 checks passed
@stanoddly
stanoddly deleted the d3d12-structured-buffer-views branch November 12, 2026 16:21
@github-actions

Copy link
Copy Markdown

📦 Development package Pixely 0.0.173 is available.

Workflow run (attempt 1)

@github-actions

Copy link
Copy Markdown

✅ Development package validation passed on all platforms.

Workflow run (attempt 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants