Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ValveSoftware/vkd3d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZebediah Figura <zfigura@codeweavers.com>2022-03-30 04:05:10 +0300
committerGiovanni Mascellani <gmascellani@codeweavers.com>2022-07-26 15:48:54 +0300
commitbd8581d270023e8def2be22626297ea06f7533c3 (patch)
tree94392effcbf33d9bce67f437f04cd7f470484f41
parent0024f62637c1a05395306d9ecfacf1e5d4e09963 (diff)
tests: Add some tests for HLSL loop declaration syntax.
-rw-r--r--Makefile.am1
-rw-r--r--tests/loop-declaration-syntax.shader_test88
2 files changed, 89 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 5dc99bea..24df92c8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -116,6 +116,7 @@ vkd3d_shader_tests = \
tests/hlsl-vector-indexing.shader_test \
tests/hlsl-vector-indexing-uniform.shader_test \
tests/logic-operations.shader_test \
+ tests/loop-declaration-syntax.shader_test \
tests/majority-syntax.shader_test \
tests/math.shader_test \
tests/matrix-semantics.shader_test \
diff --git a/tests/loop-declaration-syntax.shader_test b/tests/loop-declaration-syntax.shader_test
new file mode 100644
index 00000000..723795a5
--- /dev/null
+++ b/tests/loop-declaration-syntax.shader_test
@@ -0,0 +1,88 @@
+% Variables declared in a "for" loop can shadow previous variables.
+% This does generate a warning, however.
+
+[pixel shader]
+float4 main() : sv_target
+{
+ float f[2];
+
+ for (float4 f = float4(0, 1, 0, 1);;)
+ return f;
+}
+
+[test]
+todo draw quad
+todo probe all rgba (0.0, 1.0, 0.0, 1.0)
+
+
+% They can also be used after the loop terminates.
+
+[pixel shader]
+float4 main() : sv_target
+{
+ float4 f = float4(1, 0, 0, 1);
+
+ for (float4 f = float4(0, 1, 0, 1); false;)
+ ;
+ return f;
+}
+
+[test]
+todo draw quad
+todo probe all rgba (0.0, 1.0, 0.0, 1.0)
+
+
+% Variables declared inside of a loop cannot shadow each other, though.
+
+[pixel shader fail]
+float4 main() : sv_target
+{
+ for (float4 f, f; false;)
+ ;
+ return 0;
+}
+
+
+% Anonymous struct variable declarations are legal.
+
+[pixel shader]
+float4 main() : sv_target
+{
+ for (struct {float4 f;} s = {0, 1, 0, 1};;)
+ return s.f;
+}
+
+[test]
+todo draw quad
+todo probe all rgba (0.0, 1.0, 0.0, 1.0)
+
+
+% Named struct variable declarations are not, and neither are struct type
+% definitions.
+
+[pixel shader fail]
+float4 main() : sv_target
+{
+ for (struct apple {float4 f;} s = {0, 1, 0, 1};;)
+ return s.f;
+}
+
+[pixel shader fail]
+float4 main() : sv_target
+{
+ for (struct apple {float f;}; false;)
+ ;
+ return 0;
+}
+
+
+% Typedefs are not legal. This is not particularly surprising, but they are
+% valid everywhere else that declarations are, so it's worth checking.
+
+[pixel shader fail]
+float4 main() : sv_target
+{
+ for (typedef float myfloat_t; false;)
+ ;
+ return 0;
+}