summaryrefslogtreecommitdiff
path: root/tests/cross-compile/matrix-mult.slang.glsl
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-10-23 10:37:07 -0700
committerGitHub <noreply@github.com>2017-10-23 10:37:07 -0700
commitab64cf2ec05980d72cb2bad45e629d10ebbefdc1 (patch)
treebdf1f19164485979e29185f3f1bef4ebb5300787 /tests/cross-compile/matrix-mult.slang.glsl
parent624d122a3a110922cd54aab7bbf13f1cac8fbbff (diff)
Fix output for matrix multiple in GLSL code (#228)
When Slang sees a matrix multiplication `M * v` in GLSL code it should (obviously) output GLSL code that also does `M * v`, but there was a bug introduced where the type-checker manages to resolve the operation and recognize it as a matrix-vector multiply, and then the code-generation logic says "oh, I'm generating output for GLSL, and that is reversed from HLSL/Slang, so I'd better reverse these operands!" and outputs `v * M`... which isn't what we want. I've fixed the problem in an expedient way, by having the front-end resolve the operation to what it believes is an intrinsic multiply operation, rather than a matrix-vector operation. If we ever support cross compilation *from* GLSL (unlikely), we've need to fix this up so that we have both real matrix-vector multiplies and "reversed" multiplies where the operands folow the GLSL convention). I've added two tests here to confirm the fix. The one under `tests/bugs` catches the actual issue described above, and confirms the fix. The other one under `tests/cross-compile` is just to make sure that we *do* properly reverse the operands to a matrix-vector product when converting from Slang to GLSL.
Diffstat (limited to 'tests/cross-compile/matrix-mult.slang.glsl')
-rw-r--r--tests/cross-compile/matrix-mult.slang.glsl25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/cross-compile/matrix-mult.slang.glsl b/tests/cross-compile/matrix-mult.slang.glsl
new file mode 100644
index 000000000..0349d854e
--- /dev/null
+++ b/tests/cross-compile/matrix-mult.slang.glsl
@@ -0,0 +1,25 @@
+//TEST_IGNORE_FILE:
+
+layout(binding = 0)
+uniform C
+{
+ mat4x3 m;
+};
+
+vec4 main_(vec3 v)
+{
+ return v * m;
+}
+
+layout(location = 0)
+in vec3 SLANG_in_v;
+
+layout(location = 0)
+out vec4 SLANG_out_main_result;
+
+void main()
+{
+ vec3 v = SLANG_in_v;
+ vec4 main_result = main_(v);
+ SLANG_out_main_result = main_result;
+}