From d86748d3e0767c01d9be6def86df63febb82c2eb Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 10 Jul 2017 11:31:16 -0700 Subject: 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). --- tests/render/unused-discard.slang | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/render/unused-discard.slang (limited to 'tests/render/unused-discard.slang') 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; +} -- cgit v1.2.3