Skip to content

Commit

Permalink
Merge pull request #134 from tfoleyNV/gh-133
Browse files Browse the repository at this point in the history
Don't add `flat` qualifier to integer fragment output
  • Loading branch information
Tim Foley authored Jul 21, 2017
2 parents 3fa85ed + 0048a81 commit 6992d0e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/slang/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
21 changes: 21 additions & 0 deletions tests/bugs/gh-133.slang
Original file line number Diff line number Diff line change
@@ -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;
}
28 changes: 28 additions & 0 deletions tests/bugs/gh-133.slang.glsl
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 6992d0e

Please sign in to comment.