summaryrefslogtreecommitdiff
path: root/tests/render/unused-discard.slang
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-10 11:31:16 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-11 09:38:28 -0700
commitd86748d3e0767c01d9be6def86df63febb82c2eb (patch)
tree1ba432b042edcd38c1ba40d6cbc57cea55737bd5 /tests/render/unused-discard.slang
parent7d2c2f1bf75ed89bc97f35d5b095356db9b2b725 (diff)
Don't emitting an imported declaration unless it is used.
This helps avoid the problem where we emit a function that does a `discard` and thus get a GLSL compilation failure in a vertex shader (that doesn't even call the function).
Diffstat (limited to 'tests/render/unused-discard.slang')
-rw-r--r--tests/render/unused-discard.slang27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/render/unused-discard.slang b/tests/render/unused-discard.slang
new file mode 100644
index 000000000..034735840
--- /dev/null
+++ b/tests/render/unused-discard.slang
@@ -0,0 +1,27 @@
+//TEST_IGNORE_FILE:
+
+// This file implements the "library" code
+// that both the HLSL and GLSL shaders share.
+//
+// This code is written in Slang (more or less
+// just HLSL), and will be translated as needed
+// for each of the targets.
+
+float3 transformColor(float3 color)
+{
+ float3 result;
+
+ result.x = sin(20.0 * (color.x + color.y));
+ result.y = saturate(cos(color.z * 30.0));
+ result.z = sin(color.x * color.y * color.z * 100.0);
+
+ result = 0.5 * (result + 1);
+
+ return result;
+}
+
+void doConditionalDiscard(float3 color)
+{
+ if(color.x < 0.5)
+ discard;
+}