Fix type resolution for arrays of StructuredBuffer parameters#792
Draft
jhelferty-nv wants to merge 4 commits intoshader-slang:mainfrom
Draft
Fix type resolution for arrays of StructuredBuffer parameters#792jhelferty-nv wants to merge 4 commits intoshader-slang:mainfrom
jhelferty-nv wants to merge 4 commits intoshader-slang:mainfrom
Conversation
… 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>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
ByteAddressBufferType always has uint8 as its element type, never UnknownType, so including it was dead code. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.