Implement GL_EXT_fragment_invocation_density

including SPV generation using SPV_EXT_fragment_invocation_density.
This is an alias of the functionality in SPV_NV_shading_rate, and thus in some
cases we can only have one set of the tokens present (switch statements), so
we have picked the EXT version. This required updating the expected test
results for SPV_NV_shading_rate.

Also updated the known-good for spirv-headers so that the validator in
spirv-tools knows about the new extension.
This commit is contained in:
Daniel Koch
2018-11-26 10:01:58 -05:00
parent 83fe01e274
commit 5154db5183
18 changed files with 215 additions and 12 deletions

View File

@@ -0,0 +1,45 @@
spv.fragmentDensity-es.frag
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 18
Capability Shader
Capability FragmentDensityEXT
Extension "SPV_EXT_fragment_invocation_density"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 11 14 16
ExecutionMode 4 OriginUpperLeft
Source ESSL 310
SourceExtension "GL_EXT_fragment_invocation_density"
Name 4 "main"
Name 9 "FragSize"
Name 11 "gl_FragSizeEXT"
Name 14 "FragInvocationCount"
Name 16 "gl_FragInvocationCountEXT"
Decorate 9(FragSize) Location 0
Decorate 11(gl_FragSizeEXT) Flat
Decorate 11(gl_FragSizeEXT) BuiltIn FragSizeEXT
Decorate 14(FragInvocationCount) Location 2
Decorate 16(gl_FragInvocationCountEXT) Flat
Decorate 16(gl_FragInvocationCountEXT) BuiltIn FragInvocationCountEXT
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypeVector 6(int) 2
8: TypePointer Output 7(ivec2)
9(FragSize): 8(ptr) Variable Output
10: TypePointer Input 7(ivec2)
11(gl_FragSizeEXT): 10(ptr) Variable Input
13: TypePointer Output 6(int)
14(FragInvocationCount): 13(ptr) Variable Output
15: TypePointer Input 6(int)
16(gl_FragInvocationCountEXT): 15(ptr) Variable Input
4(main): 2 Function None 3
5: Label
12: 7(ivec2) Load 11(gl_FragSizeEXT)
Store 9(FragSize) 12
17: 6(int) Load 16(gl_FragInvocationCountEXT)
Store 14(FragInvocationCount) 17
Return
FunctionEnd

View File

@@ -0,0 +1,7 @@
spv.fragmentDensity-neg.frag
ERROR: 0:10: 'gl_FragSizeEXT' : required extension not requested: GL_EXT_fragment_invocation_density
ERROR: 0:11: 'gl_FragInvocationCountEXT' : required extension not requested: GL_EXT_fragment_invocation_density
ERROR: 2 compilation errors. No code generated.
SPIR-V is not generated for failed compile or link

View File

@@ -0,0 +1,48 @@
spv.fragmentDensity.frag
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 21
Capability Shader
Capability FragmentDensityEXT
Extension "SPV_EXT_fragment_invocation_density"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 13 17 19
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_EXT_fragment_invocation_density"
Name 4 "main"
Name 9 "FragSize"
Name 13 "gl_FragSizeEXT"
Name 17 "FragInvocationCount"
Name 19 "gl_FragInvocationCountEXT"
Decorate 9(FragSize) Location 0
Decorate 13(gl_FragSizeEXT) Flat
Decorate 13(gl_FragSizeEXT) BuiltIn FragSizeEXT
Decorate 17(FragInvocationCount) Location 2
Decorate 19(gl_FragInvocationCountEXT) Flat
Decorate 19(gl_FragInvocationCountEXT) BuiltIn FragInvocationCountEXT
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 2
8: TypePointer Output 7(fvec2)
9(FragSize): 8(ptr) Variable Output
10: TypeInt 32 1
11: TypeVector 10(int) 2
12: TypePointer Input 11(ivec2)
13(gl_FragSizeEXT): 12(ptr) Variable Input
16: TypePointer Output 10(int)
17(FragInvocationCount): 16(ptr) Variable Output
18: TypePointer Input 10(int)
19(gl_FragInvocationCountEXT): 18(ptr) Variable Input
4(main): 2 Function None 3
5: Label
14: 11(ivec2) Load 13(gl_FragSizeEXT)
15: 7(fvec2) ConvertSToF 14
Store 9(FragSize) 15
20: 10(int) Load 19(gl_FragInvocationCountEXT)
Store 17(FragInvocationCount) 20
Return
FunctionEnd

View File

@@ -0,0 +1,9 @@
spv.fragmentDensity.vert
ERROR: 0:10: 'gl_FragSizeEXT' : undeclared identifier
ERROR: 0:10: 'assign' : cannot convert from ' temp float' to 'layout( location=0) smooth out highp 2-component vector of uint'
ERROR: 0:11: 'gl_FragInvocationCountEXT' : undeclared identifier
ERROR: 0:11: 'assign' : cannot convert from ' temp float' to 'layout( location=2) smooth out highp int'
ERROR: 4 compilation errors. No code generated.
SPIR-V is not generated for failed compile or link

View File

@@ -4,7 +4,7 @@ spv.shadingRate.frag
// Id's are bound by 21
Capability Shader
Capability ShadingRateNV
Capability FragmentDensityEXT
Extension "SPV_NV_shading_rate"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
@@ -19,10 +19,10 @@ spv.shadingRate.frag
Name 19 "gl_InvocationsPerPixelNV"
Decorate 9(FragmentSize) Location 0
Decorate 13(gl_FragmentSizeNV) Flat
Decorate 13(gl_FragmentSizeNV) BuiltIn FragmentSizeNV
Decorate 13(gl_FragmentSizeNV) BuiltIn FragSizeEXT
Decorate 17(InvocationsPerPixel) Location 2
Decorate 19(gl_InvocationsPerPixelNV) Flat
Decorate 19(gl_InvocationsPerPixelNV) BuiltIn InvocationsPerPixelNV
Decorate 19(gl_InvocationsPerPixelNV) BuiltIn FragInvocationCountEXT
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32