summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/slang/lower.cpp9
-rw-r--r--tests/bugs/gh-133.slang21
-rw-r--r--tests/bugs/gh-133.slang.glsl28
3 files changed, 56 insertions, 2 deletions
diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp
index 174c93c1d..9c2c38b60 100644
--- a/source/slang/lower.cpp
+++ b/source/slang/lower.cpp
@@ -3582,9 +3582,14 @@ struct LoweringVisitor
else if (isIntegralType(varType))
{
if (info.direction == VaryingParameterDirection::Input
- && shared->entryPointRequest->profile.GetStage() == Stage::Vertex)
+ && shared->entryPointRequest->profile.GetStage() != Stage::Fragment)
{
- // Don't add extra qualification to VS inputs
+ // Don't add extra qualification to vertex shader inputs
+ }
+ else if (info.direction == VaryingParameterDirection::Output
+ && shared->entryPointRequest->profile.GetStage() == Stage::Fragment)
+ {
+ // Don't add extra qualification to fragment shader outputs
}
else
{
diff --git a/tests/bugs/gh-133.slang b/tests/bugs/gh-133.slang
new file mode 100644
index 000000000..56a896ec9
--- /dev/null
+++ b/tests/bugs/gh-133.slang
@@ -0,0 +1,21 @@
+//TEST:CROSS_COMPILE: -profile ps_5_0 -entry main -target spirv-assembly
+
+// Ensure that an integer output from
+// a fragment shader doesn't get a `flat` qualifier
+
+struct Fragment
+{
+ uint foo;
+};
+
+cbuffer U
+{
+ uint bar;
+}
+
+Fragment main() : SV_Target
+{
+ Fragment result;
+ result.foo = bar;
+ return result;
+}
diff --git a/tests/bugs/gh-133.slang.glsl b/tests/bugs/gh-133.slang.glsl
new file mode 100644
index 000000000..82f5fda49
--- /dev/null
+++ b/tests/bugs/gh-133.slang.glsl
@@ -0,0 +1,28 @@
+#version 420
+//TEST_IGNORE_FILE:
+
+struct Fragment
+{
+ uint foo;
+};
+
+uniform U
+{
+ uint bar;
+};
+
+Fragment main_()
+{
+ Fragment result;
+ result.foo = bar;
+ return result;
+}
+
+layout(location = 0)
+out uint SLANG_out_main_result_foo;
+
+void main()
+{
+ Fragment main_result = main_();
+ SLANG_out_main_result_foo = main_result.foo;
+}