Merge pull request #2625 from amdrexu/feature

Implement the extension GL_EXT_spirv_intrinsics
This commit is contained in:
Greg Fischer 2021-06-16 14:52:35 -06:00 committed by GitHub
commit 71612a7e5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 7337 additions and 3967 deletions

View file

@ -3,7 +3,9 @@ WARNING: 0:1: '#define' : missing space after macro name
ERROR: 0:3: 'preprocessor evaluation' : bad expression
ERROR: 0:3: '#if' : unexpected tokens following directive
ERROR: 0:6: 'string' : End of line in string
ERROR: 0:6: 'string literal' : required extension not requested: GL_EXT_debug_printf
ERROR: 0:6: 'string literal' : required extension not requested: Possible extensions include:
GL_EXT_debug_printf
GL_EXT_spirv_intrinsics
ERROR: 0:6: '' : syntax error, unexpected INT, expecting COMMA or SEMICOLON
ERROR: 5 compilation errors. No code generated.

View file

@ -18,8 +18,12 @@ ERROR: 0:117: '#error' : bad5
ERROR: 0:120: '#if' : unexpected tokens following directive
ERROR: 0:121: '#error' : bad6
ERROR: 0:122: '#endif' : unexpected tokens following directive
ERROR: 0:135: 'string literal' : required extension not requested: GL_EXT_debug_printf
ERROR: 0:136: 'string literal' : required extension not requested: GL_EXT_debug_printf
ERROR: 0:135: 'string literal' : required extension not requested: Possible extensions include:
GL_EXT_debug_printf
GL_EXT_spirv_intrinsics
ERROR: 0:136: 'string literal' : required extension not requested: Possible extensions include:
GL_EXT_debug_printf
GL_EXT_spirv_intrinsics
ERROR: 0:136: 'length' : no matching overloaded function found
ERROR: 0:136: '=' : cannot convert from ' const float' to ' global int'
ERROR: 0:138: ''' : character literals not supported

View file

@ -0,0 +1,56 @@
spv.intrinsicsSpirvByReference.vert
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 30
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 15 17 26
Source GLSL 450
SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main"
Name 10 "func(f1;"
Name 9 "f"
Name 15 "vec2Out"
Name 17 "floatIn"
Name 26 "floatOut"
Name 27 "param"
Decorate 15(vec2Out) Location 0
Decorate 17(floatIn) Location 0
Decorate 26(floatOut) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypePointer Function 6(float)
8: TypeFunction 2 7(ptr)
12: 6(float) Constant 1056964608
13: TypeVector 6(float) 2
14: TypePointer Output 13(fvec2)
15(vec2Out): 14(ptr) Variable Output
16: TypePointer Input 6(float)
17(floatIn): 16(ptr) Variable Input
19: TypeInt 32 0
20: 19(int) Constant 1
21: TypePointer Output 6(float)
24: 19(int) Constant 0
26(floatOut): 21(ptr) Variable Output
4(main): 2 Function None 3
5: Label
27(param): 7(ptr) Variable Function
18: 6(float) Load 17(floatIn)
22: 21(ptr) AccessChain 15(vec2Out) 20
23: 6(float) ExtInst 1(GLSL.std.450) 35(Modf) 18 22
25: 21(ptr) AccessChain 15(vec2Out) 24
Store 25 23
28: 6(float) Load 26(floatOut)
Store 27(param) 28
29: 2 FunctionCall 10(func(f1;) 27(param)
Return
FunctionEnd
10(func(f1;): 2 Function None 8
9(f): 7(ptr) FunctionParameter
11: Label
Store 9(f) 12
Return
FunctionEnd

View file

@ -0,0 +1,88 @@
spv.intrinsicsSpirvDecorate.frag
Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 43
Capability Shader
Extension "SPV_AMD_shader_explicit_vertex_parameter"
1: ExtInstImport "GLSL.std.450"
14: ExtInstImport "SPV_AMD_shader_explicit_vertex_parameter"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8 10 18 20 22 25 28 31 34 39
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main"
Name 8 "floatOut"
Name 10 "floatIn"
Name 18 "vec2Out"
Name 20 "gl_BaryCoordNoPerspAMD"
Name 22 "gl_BaryCoordNoPerspCentroidAMD"
Name 25 "gl_BaryCoordNoPerspSampleAMD"
Name 28 "gl_BaryCoordSmoothAMD"
Name 31 "gl_BaryCoordSmoothCentroidAMD"
Name 34 "gl_BaryCoordSmoothSampleAMD"
Name 39 "gl_BaryCoordPullModelAMD"
Decorate 8(floatOut) Location 0
Decorate 10(floatIn) Location 0
Decorate 10(floatIn) ExplicitInterpAMD
Decorate 18(vec2Out) Location 1
Decorate 20(gl_BaryCoordNoPerspAMD) Location 0
Decorate 20(gl_BaryCoordNoPerspAMD) BuiltIn BaryCoordNoPerspAMD
Decorate 22(gl_BaryCoordNoPerspCentroidAMD) Location 1
Decorate 22(gl_BaryCoordNoPerspCentroidAMD) BuiltIn BaryCoordNoPerspCentroidAMD
Decorate 25(gl_BaryCoordNoPerspSampleAMD) Location 2
Decorate 25(gl_BaryCoordNoPerspSampleAMD) BuiltIn BaryCoordNoPerspSampleAMD
Decorate 28(gl_BaryCoordSmoothAMD) Location 3
Decorate 28(gl_BaryCoordSmoothAMD) BuiltIn BaryCoordSmoothAMD
Decorate 31(gl_BaryCoordSmoothCentroidAMD) Location 4
Decorate 31(gl_BaryCoordSmoothCentroidAMD) BuiltIn BaryCoordSmoothCentroidAMD
Decorate 34(gl_BaryCoordSmoothSampleAMD) Location 5
Decorate 34(gl_BaryCoordSmoothSampleAMD) BuiltIn BaryCoordSmoothSampleAMD
Decorate 39(gl_BaryCoordPullModelAMD) Location 6
Decorate 39(gl_BaryCoordPullModelAMD) BuiltIn BaryCoordPullModelAMD
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypePointer Output 6(float)
8(floatOut): 7(ptr) Variable Output
9: TypePointer Input 6(float)
10(floatIn): 9(ptr) Variable Input
12: TypeInt 32 0
13: 12(int) Constant 1
16: TypeVector 6(float) 2
17: TypePointer Output 16(fvec2)
18(vec2Out): 17(ptr) Variable Output
19: TypePointer Input 16(fvec2)
20(gl_BaryCoordNoPerspAMD): 19(ptr) Variable Input
22(gl_BaryCoordNoPerspCentroidAMD): 19(ptr) Variable Input
25(gl_BaryCoordNoPerspSampleAMD): 19(ptr) Variable Input
28(gl_BaryCoordSmoothAMD): 19(ptr) Variable Input
31(gl_BaryCoordSmoothCentroidAMD): 19(ptr) Variable Input
34(gl_BaryCoordSmoothSampleAMD): 19(ptr) Variable Input
37: TypeVector 6(float) 3
38: TypePointer Input 37(fvec3)
39(gl_BaryCoordPullModelAMD): 38(ptr) Variable Input
4(main): 2 Function None 3
5: Label
11: 6(float) Load 10(floatIn)
15: 6(float) ExtInst 14(SPV_AMD_shader_explicit_vertex_parameter) 1(InterpolateAtVertexAMD) 11 13
Store 8(floatOut) 15
21: 16(fvec2) Load 20(gl_BaryCoordNoPerspAMD)
23: 16(fvec2) Load 22(gl_BaryCoordNoPerspCentroidAMD)
24: 16(fvec2) FAdd 21 23
26: 16(fvec2) Load 25(gl_BaryCoordNoPerspSampleAMD)
27: 16(fvec2) FAdd 24 26
29: 16(fvec2) Load 28(gl_BaryCoordSmoothAMD)
30: 16(fvec2) FAdd 27 29
32: 16(fvec2) Load 31(gl_BaryCoordSmoothCentroidAMD)
33: 16(fvec2) FAdd 30 32
35: 16(fvec2) Load 34(gl_BaryCoordSmoothSampleAMD)
36: 16(fvec2) FAdd 33 35
40: 37(fvec3) Load 39(gl_BaryCoordPullModelAMD)
41: 16(fvec2) VectorShuffle 40 40 0 1
42: 16(fvec2) FAdd 36 41
Store 18(vec2Out) 42
Return
FunctionEnd

View file

@ -0,0 +1,36 @@
spv.intrinsicsSpirvExecutionMode.frag
Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 12
Capability Shader
Capability StencilExportEXT
Extension "SPV_EXT_shader_stencil_export"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8 10
ExecutionMode 4 OriginUpperLeft
ExecutionMode 4 StencilRefReplacingEXT
Source GLSL 450
SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main"
Name 8 "gl_FragStencilRef"
Name 10 "color"
Decorate 8(gl_FragStencilRef) Location 0
Decorate 8(gl_FragStencilRef) BuiltIn FragStencilRefEXT
Decorate 10(color) Flat
Decorate 10(color) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Output 6(int)
8(gl_FragStencilRef): 7(ptr) Variable Output
9: TypePointer Input 6(int)
10(color): 9(ptr) Variable Input
4(main): 2 Function None 3
5: Label
11: 6(int) Load 10(color)
Store 8(gl_FragStencilRef) 11
Return
FunctionEnd

View file

@ -0,0 +1,59 @@
spv.intrinsicsSpirvInstruction.vert
Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 30
Capability Shader
Capability Int64
Capability ShaderClockKHR
Extension "SPV_AMD_shader_trinary_minmax"
Extension "SPV_KHR_shader_clock"
1: ExtInstImport "GLSL.std.450"
28: ExtInstImport "SPV_AMD_shader_trinary_minmax"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 9 13 18 21
Source GLSL 450
SourceExtension "GL_ARB_gpu_shader_int64"
SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main"
Name 9 "uvec2Out"
Name 13 "i64Out"
Name 18 "vec2Out"
Name 21 "vec3In"
Decorate 9(uvec2Out) Location 0
Decorate 13(i64Out) Location 1
Decorate 18(vec2Out) Location 2
Decorate 21(vec3In) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypeVector 6(int) 2
8: TypePointer Output 7(ivec2)
9(uvec2Out): 8(ptr) Variable Output
11: TypeInt 64 1
12: TypePointer Output 11(int64_t)
13(i64Out): 12(ptr) Variable Output
15: TypeFloat 32
16: TypeVector 15(float) 2
17: TypePointer Output 16(fvec2)
18(vec2Out): 17(ptr) Variable Output
19: TypeVector 15(float) 3
20: TypePointer Input 19(fvec3)
21(vec3In): 20(ptr) Variable Input
4(main): 2 Function None 3
5: Label
10: 7(ivec2) ReadClockKHR
Store 9(uvec2Out) 10
14: 11(int64_t) ReadClockKHR
Store 13(i64Out) 14
22: 19(fvec3) Load 21(vec3In)
23: 16(fvec2) VectorShuffle 22 22 0 1
24: 19(fvec3) Load 21(vec3In)
25: 16(fvec2) VectorShuffle 24 24 1 2
26: 19(fvec3) Load 21(vec3In)
27: 16(fvec2) VectorShuffle 26 26 2 0
29: 16(fvec2) ExtInst 28(SPV_AMD_shader_trinary_minmax) 1(FMin3AMD) 23 25 27
Store 18(vec2Out) 29
Return
FunctionEnd

View file

@ -0,0 +1,29 @@
spv.intrinsicsSpirvLiteral.vert
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 12
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main"
Source GLSL 450
SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main"
Name 9 "vec4Out"
Name 10 "vec4In"
Decorate 9(vec4Out) Location 1
Decorate 10(vec4In) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
4(main): 2 Function None 3
5: Label
9(vec4Out): 8(ptr) Variable Function
10(vec4In): 8(ptr) Variable Function
11: 7(fvec4) Load 10(vec4In) None
Store 9(vec4Out) 11 Volatile
Return
FunctionEnd

View file

@ -0,0 +1,30 @@
spv.intrinsicsSpirvStorageClass.rchit
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 13
Capability RayTracingKHR
Capability RayTracingProvisionalKHR
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint ClosestHitKHR 4 "main"
Source GLSL 460
SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main"
Name 9 "payload"
Decorate 9(payload) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer RayPayloadKHR 7(fvec4)
9(payload): 8(ptr) Variable RayPayloadKHR
10: 6(float) Constant 0
11: 6(float) Constant 1065353216
12: 7(fvec4) ConstantComposite 10 11 10 11
4(main): 2 Function None 3
5: Label
Store 9(payload) 12
Return
FunctionEnd

View file

@ -0,0 +1,45 @@
spv.intrinsicsSpirvType.rgen
Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 21
Capability RayQueryKHR
Capability RayTraversalPrimitiveCullingKHR
Capability RayTracingKHR
Extension "SPV_KHR_ray_query"
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint RayGenerationKHR 4 "main"
Source GLSL 460
SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main"
Name 8 "rq"
Name 11 "as"
Decorate 11(as) Location 0
Decorate 11(as) DescriptorSet 0
Decorate 11(as) Binding 0
2: TypeVoid
3: TypeFunction 2
7: TypePointer Function 6
10: TypePointer UniformConstant 9
11(as): 10(ptr) Variable UniformConstant
13: TypeInt 32 0
14: 13(int) Constant 0
15: TypeFloat 32
16: TypeVector 15(float) 3
17: 15(float) Constant 0
18: 16(fvec3) ConstantComposite 17 17 17
19: 15(float) Constant 1065353216
20: 16(fvec3) ConstantComposite 19 19 19
4(main): 2 Function None 3
5: Label
8(rq): 7(ptr) Variable Function
6: TypeRayQueryKHR
9: TypeAccelerationStructureKHR
12: 9 Load 11(as)
RayQueryInitializeKHR 8(rq) 12 14 14 18 17 20 19
RayQueryTerminateKHR 8(rq)
Return
FunctionEnd

View file

@ -0,0 +1,21 @@
#version 450 core
#extension GL_EXT_spirv_intrinsics: enable
spirv_instruction (set = "GLSL.std.450", id = 35) // modf
float modf(float x, spirv_by_reference float i);
layout(location = 0) in float floatIn;
layout(location = 0) out vec2 vec2Out;
layout(location = 1) out float floatOut;
void func(spirv_by_reference float f)
{
f = 0.5;
}
void main()
{
vec2Out.x = modf(floatIn, vec2Out.y);
func(floatOut);
}

View file

@ -0,0 +1,37 @@
#version 450 core
#extension GL_EXT_spirv_intrinsics: enable
#define GL_AMD_shader_explicit_vertex_parameter 1
spirv_decorate (extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], 11, 4992)
in vec2 gl_BaryCoordNoPerspAMD;
spirv_decorate (extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], 11, 4993)
in vec2 gl_BaryCoordNoPerspCentroidAMD;
spirv_decorate (extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], 11, 4994)
in vec2 gl_BaryCoordNoPerspSampleAMD;
spirv_decorate (extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], 11, 4995)
in vec2 gl_BaryCoordSmoothAMD;
spirv_decorate (extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], 11, 4996)
in vec2 gl_BaryCoordSmoothCentroidAMD;
spirv_decorate (extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], 11, 4997)
in vec2 gl_BaryCoordSmoothSampleAMD;
spirv_decorate (extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], 11, 4998)
in vec3 gl_BaryCoordPullModelAMD;
#define __explicitInterpAMD spirv_decorate(extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], 4999)
spirv_instruction(extensions = ["SPV_AMD_shader_explicit_vertex_parameter"], set = "SPV_AMD_shader_explicit_vertex_parameter", id = 1)
float interpolateAtVertexAMD(float interpolant, uint vertexIdx);
layout(location = 0) in __explicitInterpAMD float floatIn;
layout(location = 0) out float floatOut;
layout(location = 1) out vec2 vec2Out;
void main()
{
floatOut = interpolateAtVertexAMD(floatIn, 1);
vec2Out = gl_BaryCoordNoPerspAMD + gl_BaryCoordNoPerspCentroidAMD + gl_BaryCoordNoPerspSampleAMD +
gl_BaryCoordSmoothAMD + gl_BaryCoordSmoothCentroidAMD + gl_BaryCoordSmoothSampleAMD +
gl_BaryCoordPullModelAMD.xy;
}

View file

@ -0,0 +1,17 @@
#version 450 core
#extension GL_EXT_spirv_intrinsics: enable
#define GL_ARB_shader_stencil_export 1
spirv_execution_mode(5027); // StencilRefReplacingEXT
spirv_decorate(extensions = ["SPV_EXT_shader_stencil_export"], capabilities = [5013], 11, 5014)
out int gl_FragStencilRef;
layout(location = 0) in flat int color;
void main()
{
gl_FragStencilRef = color;
}

View file

@ -0,0 +1,26 @@
#version 450 core
#extension GL_EXT_spirv_intrinsics: enable
#extension GL_ARB_gpu_shader_int64: enable
spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056)
uvec2 clockRealtime2x32EXT(void);
spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056)
int64_t clockRealtimeEXT(void);
spirv_instruction (extensions = ["SPV_AMD_shader_trinary_minmax"], set = "SPV_AMD_shader_trinary_minmax", id = 1)
vec2 min3(vec2 x, vec2 y, vec2 z);
layout(location = 0) in vec3 vec3In;
layout(location = 0) out uvec2 uvec2Out;
layout(location = 1) out int64_t i64Out;
layout(location = 2) out vec2 vec2Out;
void main()
{
uvec2Out = clockRealtime2x32EXT();
i64Out = clockRealtimeEXT();
vec2Out = min3(vec3In.xy, vec3In.yz, vec3In.zx);
}

View file

@ -0,0 +1,17 @@
#version 450 core
#extension GL_EXT_spirv_intrinsics: enable
spirv_instruction(id = 61)
vec4 load(spirv_by_reference vec4 pointer, spirv_literal int memoryOperands);
spirv_instruction(id = 62)
void store(spirv_by_reference vec4 pointer, vec4 object, spirv_literal int memoryOperands);
layout(location = 0) in vec4 vec4In;
layout(location = 1) out vec4 vec4Out;
void main()
{
store(vec4Out, load(vec4In, /*None=*/0x0), /*Volatile=*/0x1);
}

View file

@ -0,0 +1,12 @@
#version 460
#extension GL_EXT_spirv_intrinsics: enable
#define rayPayloadEXT spirv_storage_class(extensions = ["SPV_KHR_ray_tracing"], capabilities = [5353], 5338)
layout(location = 1) rayPayloadEXT vec4 payload;
void main()
{
payload = vec4(0.0, 1.0, 0.0, 1.0);
}

View file

@ -0,0 +1,22 @@
#version 460 core
#extension GL_EXT_spirv_intrinsics: enable
#define rayQueryEXT spirv_type (extensions = ["SPV_KHR_ray_query"], capabilities = [4472], id = 4472)
#define accelerationStructureEXT spirv_type (extensions = ["SPV_KHR_ray_query"], capabilities = [4472], id = 5341)
spirv_instruction (extensions = ["SPV_KHR_ray_query"], capabilities = [4472, 4478], id = 4473)
void rayQueryInitializeEXT(spirv_by_reference rayQueryEXT rayQuery, accelerationStructureEXT topLevel, uint rayFlags, uint cullMask, vec3 origin, float tMin, vec3 direction, float tMax);
spirv_instruction (extensions = ["SPV_KHR_ray_query"], capabilities = [4478], id = 4474)
void rayQueryTerminateEXT(spirv_by_reference rayQueryEXT rayQuery);
layout(binding = 0) uniform accelerationStructureEXT as;
void main()
{
rayQueryEXT rq;
rayQueryInitializeEXT(rq, as, 0, 0, vec3(0.0), 0.0, vec3(1.0), 1.0);
rayQueryTerminateEXT(rq);
}