summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-11-22 11:28:29 -0800
committerGitHub <noreply@github.com>2017-11-22 11:28:29 -0800
commit56e49feea3956d66e41b819c26628c65b3c28197 (patch)
tree039be32cb8f13a5cc72175465d3a0e9a37db8ce4 /tests/bugs
parent37315c96ea48045fae60f0e1cb1a3293f3ddd962 (diff)
Fix emitting of loop attributes for HLSL pass-through (#296)
Fixes #295. The code previously had a white list of attributes that it passed through, implemented in `emit.cpp` in an ad hoc fashion. The fix here is to just pass through whatever attributes the user wrote, and then let the downstream compiler diagnose if any of them are errorneous.
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/gh-295.hlsl40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/bugs/gh-295.hlsl b/tests/bugs/gh-295.hlsl
new file mode 100644
index 000000000..724684662
--- /dev/null
+++ b/tests/bugs/gh-295.hlsl
@@ -0,0 +1,40 @@
+//TEST:COMPARE_HLSL: -profile vs_4_0 -target dxbc-assembly -no-checking
+
+// Confirm that we pass through `[fastopt]` attributes
+//
+// This shader does indexing into the elements of
+// a vector, fetched from a `cbuffer`, based on
+// a loop counter (or a loop with a small trip
+// count), so `fxc` seems to want to unroll the
+// loop. The `[fastopt]` attribute changes this
+// behavior and results in a `loop` instruction
+// in the DX bytecode, so we can use this to
+// test whether Slang is passing through the
+// attribute or not.
+
+// Import Slang code so that we aren't just in
+// the 100% pass-through mode.
+#ifdef __SLANG__
+__import empty;
+#endif
+
+cbuffer C
+{
+ float4 b[4];
+}
+float test(float x, float c)
+{
+ [fastopt]
+ for(int ii = 0; ii < 2; ++ii)
+ {
+ x = x*x + c + b[ii][ii];
+ }
+ return x;
+}
+
+float4 main(float4 a : A) : SV_Position
+{
+ a.x = test(a.x, a.y);
+
+ return a;
+}