summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-07-24 14:19:07 -0700
committerGitHub <noreply@github.com>2024-07-24 14:19:07 -0700
commitfe28d9c71339a6d140ca9dd1ef29e9e398221838 (patch)
tree58770ad4ffe7f3da2adca63af407e58662637832
parent657213f13d49f0d2caaa8b64c1245ec8c75fc4d7 (diff)
Fix checking of var with matrix layout modifier. (#4737)
-rw-r--r--source/slang/slang-check-decl.cpp2
-rw-r--r--tests/bugs/gh-4633.slang14
2 files changed, 14 insertions, 2 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 482f15aca..23c10ddc2 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -1605,8 +1605,6 @@ namespace Slang
matrixType->getColumnCount(),
getASTBuilder()->getIntVal(getASTBuilder()->getIntType(), matrixLayout));
varDecl->type.type = newMatrixType;
- if (varDecl->initExpr)
- varDecl->initExpr = coerce(CoercionSite::Initializer, varDecl->type, varDecl->initExpr);
}
}
diff --git a/tests/bugs/gh-4633.slang b/tests/bugs/gh-4633.slang
new file mode 100644
index 000000000..9eeac2895
--- /dev/null
+++ b/tests/bugs/gh-4633.slang
@@ -0,0 +1,14 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-compute -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+ // Test that use `row_major` on a local variable with init expr
+ // works.
+ row_major float4x3 m = float4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
+ outputBuffer[0] = m[1][2]; // Expect: 6
+ // BUFFER: 6
+} \ No newline at end of file