summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-04-18 00:41:00 -0400
committerGitHub <noreply@github.com>2024-04-17 21:41:00 -0700
commit355a8d8f923ef67f11092ae706b50d028b09f9ad (patch)
tree00d8e5338da2fb6ed5b9f2e6739283416464f436
parent2c66cc7ef03b4d38fc463f2c8609a81232fcb91a (diff)
commit to partially fix #3931 (#3972)
-rw-r--r--source/slang/slang-options.cpp6
-rw-r--r--tests/bugs/gh-3931.slang24
2 files changed, 28 insertions, 2 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index d9441e6da..3f17d6d44 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -1682,8 +1682,6 @@ SlangResult OptionsParser::_parse(
case OptionKind::VulkanUseEntryPointName:
case OptionKind::VulkanUseGLLayout:
case OptionKind::VulkanEmitReflection:
- case OptionKind::MatrixLayoutRow:
- case OptionKind::MatrixLayoutColumn:
case OptionKind::DefaultImageFormatUnknown:
case OptionKind::Obfuscate:
case OptionKind::OutputIncludes:
@@ -1693,6 +1691,10 @@ SlangResult OptionsParser::_parse(
case OptionKind::NoHLSLBinding:
linkage->m_optionSet.set(optionKind, true); break;
break;
+ case OptionKind::MatrixLayoutRow:
+ case OptionKind::MatrixLayoutColumn:
+ linkage->m_optionSet.setMatrixLayoutMode((optionKind == OptionKind::MatrixLayoutRow) ? MatrixLayoutMode::kMatrixLayoutMode_RowMajor : MatrixLayoutMode::kMatrixLayoutMode_ColumnMajor);
+ break;
case OptionKind::NoCodeGen:
linkage->m_optionSet.set(OptionKind::SkipCodeGen, true); break;
break;
diff --git a/tests/bugs/gh-3931.slang b/tests/bugs/gh-3931.slang
new file mode 100644
index 000000000..501e85ae2
--- /dev/null
+++ b/tests/bugs/gh-3931.slang
@@ -0,0 +1,24 @@
+//TEST:SIMPLE(filecheck=CHECK): -O0 -target spirv -emit-spirv-directly -stage compute -entry computeMain -matrix-layout-row-major
+//COM:TEST:SIMPLE(filecheck=CHECK): -O2 -target spirv -emit-spirv-directly -stage compute -entry computeMain -matrix-layout-row-major
+
+// Any level of optimization removes all OpMemberDecorations from FooBar
+// with spirv-opt 2023 or upstream (2024-04). spirv-opt 2024-1 fixes the issue.
+
+//CHECK: ColMajor
+
+struct FooBar {
+ float4x4 c;
+ int load(int row, int col)
+ {
+ return int(c[row][col]);
+ //return *(int*)int(c[row][col]); // Does not fail if using a pointer to any member to indirectly send data
+ }
+};
+RWStructuredBuffer<int> outputBuffer;
+uniform StructuredBuffer<FooBar, ScalarDataLayout> sb;
+[numthreads(4, 1, 1)]
+void computeMain(
+ int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ outputBuffer[dispatchThreadID.x] = sb[0].load(dispatchThreadID.x/4, dispatchThreadID.x%4);
+} \ No newline at end of file