SPV: SampleMask does not depend on SampleRateShading.

Fixes #1158.
Fixes #1159.
This commit is contained in:
John Kessenich 2017-11-20 16:32:49 -07:00
parent e2c15b4f6e
commit cbdf871d7f
11 changed files with 175 additions and 4 deletions

View File

@ -479,7 +479,6 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
return spv::BuiltInSamplePosition;
case glslang::EbvSampleMask:
builder.addCapability(spv::CapabilitySampleRateShading);
return spv::BuiltInSampleMask;
case glslang::EbvLayer:

View File

@ -210,7 +210,6 @@ gl_FragCoord origin is upper left
// Id's are bound by 88
Capability Shader
Capability SampleRateShading
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 68 78 82 86

View File

@ -4,7 +4,6 @@ spv.arbPostDepthCoverage.frag
// Id's are bound by 18
Capability Shader
Capability SampleRateShading
Capability SampleMaskPostDepthCoverage
Extension "SPV_KHR_post_depth_coverage"
1: ExtInstImport "GLSL.std.450"

View File

@ -0,0 +1,32 @@
spv.sample.frag
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 13
Capability Shader
Capability SampleRateShading
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 11
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "color"
Name 11 "samp"
Decorate 9(color) Location 0
Decorate 11(samp) Sample
Decorate 11(samp) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(color): 8(ptr) Variable Output
10: TypePointer Input 7(fvec4)
11(samp): 10(ptr) Variable Input
4(main): 2 Function None 3
5: Label
12: 7(fvec4) Load 11(samp)
Store 9(color) 12
Return
FunctionEnd

View File

@ -0,0 +1,52 @@
spv.sampleId.frag
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 26
Capability Shader
Capability SampleRateShading
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8 18 20
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 8 "gl_SampleID"
Name 18 "color"
Name 20 "samp"
Decorate 8(gl_SampleID) Flat
Decorate 8(gl_SampleID) BuiltIn SampleId
Decorate 18(color) Location 0
Decorate 20(samp) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Input 6(int)
8(gl_SampleID): 7(ptr) Variable Input
10: 6(int) Constant 3
11: TypeBool
15: TypeFloat 32
16: TypeVector 15(float) 4
17: TypePointer Output 16(fvec4)
18(color): 17(ptr) Variable Output
19: TypePointer Input 16(fvec4)
20(samp): 19(ptr) Variable Input
23: 15(float) Constant 1073741824
4(main): 2 Function None 3
5: Label
9: 6(int) Load 8(gl_SampleID)
12: 11(bool) SLessThan 9 10
SelectionMerge 14 None
BranchConditional 12 13 22
13: Label
21: 16(fvec4) Load 20(samp)
Store 18(color) 21
Branch 14
22: Label
24: 16(fvec4) Load 20(samp)
25: 16(fvec4) VectorTimesScalar 24 23
Store 18(color) 25
Branch 14
14: Label
Return
FunctionEnd

View File

@ -4,7 +4,6 @@ spv.sampleMaskOverrideCoverage.frag
// Id's are bound by 20
Capability Shader
Capability SampleRateShading
Extension "SPV_NV_sample_mask_override_coverage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450

View File

@ -0,0 +1,55 @@
spv.samplePosition.frag
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 30
Capability Shader
Capability SampleRateShading
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 22 24
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "gl_SamplePosition"
Name 22 "color"
Name 24 "samp"
Decorate 9(gl_SamplePosition) BuiltIn SamplePosition
Decorate 22(color) Location 0
Decorate 24(samp) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 2
8: TypePointer Input 7(fvec2)
9(gl_SamplePosition): 8(ptr) Variable Input
10: TypeInt 32 0
11: 10(int) Constant 1
12: TypePointer Input 6(float)
15: 6(float) Constant 1056964608
16: TypeBool
20: TypeVector 6(float) 4
21: TypePointer Output 20(fvec4)
22(color): 21(ptr) Variable Output
23: TypePointer Input 20(fvec4)
24(samp): 23(ptr) Variable Input
27: 6(float) Constant 1073741824
4(main): 2 Function None 3
5: Label
13: 12(ptr) AccessChain 9(gl_SamplePosition) 11
14: 6(float) Load 13
17: 16(bool) FOrdLessThan 14 15
SelectionMerge 19 None
BranchConditional 17 18 26
18: Label
25: 20(fvec4) Load 24(samp)
Store 22(color) 25
Branch 19
26: Label
28: 20(fvec4) Load 24(samp)
29: 20(fvec4) VectorTimesScalar 28 27
Store 22(color) 29
Branch 19
19: Label
Return
FunctionEnd

9
Test/spv.sample.frag Normal file
View File

@ -0,0 +1,9 @@
#version 450
layout(location = 0) in sample vec4 samp;
layout(location = 0) out vec4 color;
void main()
{
color = samp;
}

12
Test/spv.sampleId.frag Normal file
View File

@ -0,0 +1,12 @@
#version 450
layout(location = 0) in vec4 samp;
layout(location = 0) out vec4 color;
void main()
{
if (gl_SampleID < 3)
color = samp;
else
color = 2 * samp;
}

View File

@ -0,0 +1,12 @@
#version 450
layout(location = 0) in vec4 samp;
layout(location = 0) out vec4 color;
void main()
{
if (gl_SamplePosition.y < 0.5)
color = samp;
else
color = 2 * samp;
}

View File

@ -280,6 +280,9 @@ INSTANTIATE_TEST_CASE_P(
"spv.precisionNonESSamp.frag",
"spv.prepost.frag",
"spv.qualifiers.vert",
"spv.sample.frag",
"spv.sampleId.frag",
"spv.samplePosition.frag",
"spv.sampleMaskOverrideCoverage.frag",
"spv.shaderBallot.comp",
"spv.shaderDrawParams.vert",