Skip to content

Commit 00a6032

Browse files
jamienicoljimblandy
authored andcommitted
[naga spv-out] Handle nested arrays when adding matrix decorations
Previously we only checked whether the outermost array's subtype was a Matrix when determining whether to add ColMajor and MatrixStride decorations, meaning arrays of arrays of matrices would not be decorated.
1 parent 6f5014f commit 00a6032

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

naga/src/back/spv/writer.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,12 +1800,13 @@ impl Writer {
18001800
}
18011801
}
18021802

1803-
// Matrices and arrays of matrices both require decorations,
1804-
// so "see through" an array to determine if they're needed.
1805-
let member_array_subty_inner = match arena[member.ty].inner {
1806-
crate::TypeInner::Array { base, .. } => &arena[base].inner,
1807-
ref other => other,
1808-
};
1803+
// Matrices and (potentially nested) arrays of matrices both require decorations,
1804+
// so "see through" any arrays to determine if they're needed.
1805+
let mut member_array_subty_inner = &arena[member.ty].inner;
1806+
while let crate::TypeInner::Array { base, .. } = *member_array_subty_inner {
1807+
member_array_subty_inner = &arena[base].inner;
1808+
}
1809+
18091810
if let crate::TypeInner::Matrix {
18101811
columns: _,
18111812
rows,

naga/tests/out/spv/globals.spvasm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ OpDecorate %45 DescriptorSet 0
4444
OpDecorate %45 Binding 6
4545
OpDecorate %46 Block
4646
OpMemberDecorate %46 0 Offset 0
47+
OpMemberDecorate %46 0 ColMajor
48+
OpMemberDecorate %46 0 MatrixStride 16
4749
OpDecorate %48 DescriptorSet 0
4850
OpDecorate %48 Binding 7
4951
OpDecorate %49 Block
5052
OpMemberDecorate %49 0 Offset 0
53+
OpMemberDecorate %49 0 ColMajor
54+
OpMemberDecorate %49 0 MatrixStride 8
5155
OpDecorate %116 BuiltIn LocalInvocationId
5256
%2 = OpTypeVoid
5357
%3 = OpTypeBool

0 commit comments

Comments
 (0)