Skip to content

Fix type resolution for arrays of StructuredBuffer parameters#792

Draft
jhelferty-nv wants to merge 4 commits intoshader-slang:mainfrom
jhelferty-nv:gh-123
Draft

Fix type resolution for arrays of StructuredBuffer parameters#792
jhelferty-nv wants to merge 4 commits intoshader-slang:mainfrom
jhelferty-nv:gh-123

Conversation

@jhelferty-nv
Copy link
Contributor

Fixes #123

Adds support for passing arrays of StructuredBuffer and RWStructuredBuffer as function parameters. The array type resolver in array_to_array_scalarconvertable now recognizes when the marshall element is a resource type with an unknown element type and matches it against a concrete target, mirroring how single buffer parameters already resolve.

Also adds tests confirming that structs with array fields (scalar and struct), nested structs with arrays, array broadcasting, and both read-only and read-write structured buffer arrays work correctly.

jhelferty-nv and others added 3 commits February 12, 2026 16:34
… SlangPy

Add five new tests covering struct-with-array-field scenarios from
issue shader-slang#123. Four pass (struct with scalar array, struct array, nested
struct with array, broadcast array to scalar), confirming the tensor
refactor resolved most cases. The array-of-StructuredBuffer test is
marked xfail as it hits a type resolution bug in SlangPy.

Co-authored-by: Cursor <cursoragent@cursor.com>
When a Python list of Buffer objects was passed to a Slang function
expecting e.g. StructuredBuffer<int>[4], type resolution failed because
the marshall type Array[StructuredBuffer<Unknown>] could not match the
target Array[StructuredBuffer<int>]. Single buffers already handled this
via BufferMarshall.resolve_types, but the array-level matcher in
array_to_array_scalarconvertable had no equivalent logic.

Add a check in array_to_array_scalarconvertable that recognizes when the
marshall element is a resource type with Unknown element type and the
target element is the same resource kind with a concrete type, accepting
the target type in that case.

Also removes the xfail marker from test_array_of_structured_buffers now
that it passes.

Fixes shader-slang#123

Co-authored-by: Cursor <cursoragent@cursor.com>
Covers the read-write variant of the array-of-structured-buffers case
from issue shader-slang#123. The test writes to each buffer element and verifies
the results were written back correctly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@jhelferty-nv jhelferty-nv self-assigned this Feb 13, 2026
ByteAddressBufferType always has uint8 as its element type, never
UnknownType, so including it was dead code.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Significant issues with any complex types passing arrays to SlangPy

1 participant

Comments