Commit 65a7fb70 by Rex Xu

Implement the extension GL_EXT_spirv_intrinsics

- Add support of SPIR-V execution mode qualifiers. - Add support of SPIR-V storage class qualifier. - Add support of SPIR-V decorate qualifiers. - Add support of SPIR-V type specifier. - Add support of SPIR-V intruction qualifiers. - Add support of spirv_by_reference/spirv_literal parameter qualifier. - Add shader stage macros introduced by this extension.
parent 3d935ea2
...@@ -131,6 +131,7 @@ template("glslang_sources_common") { ...@@ -131,6 +131,7 @@ template("glslang_sources_common") {
"glslang/Include/PoolAlloc.h", "glslang/Include/PoolAlloc.h",
"glslang/Include/ResourceLimits.h", "glslang/Include/ResourceLimits.h",
"glslang/Include/ShHandle.h", "glslang/Include/ShHandle.h",
"glslang/Include/SpirvIntrinsics.h",
"glslang/Include/Types.h", "glslang/Include/Types.h",
"glslang/Include/arrays.h", "glslang/Include/arrays.h",
"glslang/Include/intermediate.h", "glslang/Include/intermediate.h",
...@@ -151,6 +152,7 @@ template("glslang_sources_common") { ...@@ -151,6 +152,7 @@ template("glslang_sources_common") {
"glslang/MachineIndependent/Scan.h", "glslang/MachineIndependent/Scan.h",
"glslang/MachineIndependent/ScanContext.h", "glslang/MachineIndependent/ScanContext.h",
"glslang/MachineIndependent/ShaderLang.cpp", "glslang/MachineIndependent/ShaderLang.cpp",
"glslang/MachineIndependent/SpirvIntrinsics.cpp",
"glslang/MachineIndependent/SymbolTable.cpp", "glslang/MachineIndependent/SymbolTable.cpp",
"glslang/MachineIndependent/SymbolTable.h", "glslang/MachineIndependent/SymbolTable.h",
"glslang/MachineIndependent/Versions.cpp", "glslang/MachineIndependent/Versions.cpp",
......
...@@ -3,7 +3,9 @@ WARNING: 0:1: '#define' : missing space after macro name ...@@ -3,7 +3,9 @@ WARNING: 0:1: '#define' : missing space after macro name
ERROR: 0:3: 'preprocessor evaluation' : bad expression ERROR: 0:3: 'preprocessor evaluation' : bad expression
ERROR: 0:3: '#if' : unexpected tokens following directive ERROR: 0:3: '#if' : unexpected tokens following directive
ERROR: 0:6: 'string' : End of line in string 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: 0:6: '' : syntax error, unexpected INT, expecting COMMA or SEMICOLON
ERROR: 5 compilation errors. No code generated. ERROR: 5 compilation errors. No code generated.
......
...@@ -18,8 +18,12 @@ ERROR: 0:117: '#error' : bad5 ...@@ -18,8 +18,12 @@ ERROR: 0:117: '#error' : bad5
ERROR: 0:120: '#if' : unexpected tokens following directive ERROR: 0:120: '#if' : unexpected tokens following directive
ERROR: 0:121: '#error' : bad6 ERROR: 0:121: '#error' : bad6
ERROR: 0:122: '#endif' : unexpected tokens following directive ERROR: 0:122: '#endif' : unexpected tokens following directive
ERROR: 0:135: 'string literal' : required extension not requested: GL_EXT_debug_printf ERROR: 0:135: 'string literal' : required extension not requested: Possible extensions include:
ERROR: 0:136: 'string literal' : required extension not requested: GL_EXT_debug_printf 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: 'length' : no matching overloaded function found
ERROR: 0:136: '=' : cannot convert from ' const float' to ' global int' ERROR: 0:136: '=' : cannot convert from ' const float' to ' global int'
ERROR: 0:138: ''' : character literals not supported ERROR: 0:138: ''' : character literals not supported
......
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
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
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
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
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
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
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
#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);
}
#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;
}
#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;
}
#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);
}
#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);
}
#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);
}
#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);
}
...@@ -73,6 +73,7 @@ set(MACHINEINDEPENDENT_SOURCES ...@@ -73,6 +73,7 @@ set(MACHINEINDEPENDENT_SOURCES
MachineIndependent/RemoveTree.cpp MachineIndependent/RemoveTree.cpp
MachineIndependent/Scan.cpp MachineIndependent/Scan.cpp
MachineIndependent/ShaderLang.cpp MachineIndependent/ShaderLang.cpp
MachineIndependent/SpirvIntrinsics.cpp
MachineIndependent/SymbolTable.cpp MachineIndependent/SymbolTable.cpp
MachineIndependent/Versions.cpp MachineIndependent/Versions.cpp
MachineIndependent/intermOut.cpp MachineIndependent/intermOut.cpp
...@@ -160,6 +161,7 @@ set(GLSLANG_HEADERS ...@@ -160,6 +161,7 @@ set(GLSLANG_HEADERS
Include/PoolAlloc.h Include/PoolAlloc.h
Include/ResourceLimits.h Include/ResourceLimits.h
Include/ShHandle.h Include/ShHandle.h
Include/SpirvIntrinsics.h
Include/Types.h) Include/Types.h)
add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS}) add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS})
......
...@@ -65,6 +65,10 @@ enum TBasicType { ...@@ -65,6 +65,10 @@ enum TBasicType {
EbtAccStruct, EbtAccStruct,
EbtReference, EbtReference,
EbtRayQuery, EbtRayQuery,
#ifndef GLSLANG_WEB
// SPIR-V type defined by spirv_type
EbtSpirvType,
#endif
// HLSL types that live only temporarily. // HLSL types that live only temporarily.
EbtString, EbtString,
...@@ -91,6 +95,9 @@ enum TStorageQualifier { ...@@ -91,6 +95,9 @@ enum TStorageQualifier {
EvqUniform, // read only, shared with app EvqUniform, // read only, shared with app
EvqBuffer, // read/write, shared with app EvqBuffer, // read/write, shared with app
EvqShared, // compute shader's read/write 'shared' qualifier EvqShared, // compute shader's read/write 'shared' qualifier
#ifndef GLSLANG_WEB
EvqSpirvStorageClass, // spirv_storage_class
#endif
EvqPayload, EvqPayload,
EvqPayloadIn, EvqPayloadIn,
...@@ -321,6 +328,9 @@ __inline const char* GetStorageQualifierString(TStorageQualifier q) ...@@ -321,6 +328,9 @@ __inline const char* GetStorageQualifierString(TStorageQualifier q)
case EvqGlobal: return "global"; break; case EvqGlobal: return "global"; break;
case EvqConst: return "const"; break; case EvqConst: return "const"; break;
case EvqConstReadOnly: return "const (read only)"; break; case EvqConstReadOnly: return "const (read only)"; break;
#ifndef GLSLANG_WEB
case EvqSpirvStorageClass: return "spirv_storage_class"; break;
#endif
case EvqVaryingIn: return "in"; break; case EvqVaryingIn: return "in"; break;
case EvqVaryingOut: return "out"; break; case EvqVaryingOut: return "out"; break;
case EvqUniform: return "uniform"; break; case EvqUniform: return "uniform"; break;
......
...@@ -194,6 +194,10 @@ template <class K, class D, class HASH = std::hash<K>, class PRED = std::equal_t ...@@ -194,6 +194,10 @@ template <class K, class D, class HASH = std::hash<K>, class PRED = std::equal_t
class TUnorderedMap : public std::unordered_map<K, D, HASH, PRED, pool_allocator<std::pair<K const, D> > > { class TUnorderedMap : public std::unordered_map<K, D, HASH, PRED, pool_allocator<std::pair<K const, D> > > {
}; };
template <class K, class CMP = std::less<K> >
class TSet : public std::set<K, CMP, pool_allocator<K> > {
};
// //
// Persistent string memory. Should only be used for strings that survive // Persistent string memory. Should only be used for strings that survive
// across compiles/links. // across compiles/links.
......
//
// Copyright(C) 2021 Advanced Micro Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#pragma once
#ifndef GLSLANG_WEB
//
// GL_EXT_spirv_intrinsics
//
#include "Common.h"
namespace glslang {
class TIntermTyped;
class TIntermConstantUnion;
class TType;
// SPIR-V requirements
struct TSpirvRequirement {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
// capability = [..]
TSet<TString> extensions;
// extension = [..]
TSet<int> capabilities;
};
// SPIR-V execution modes
struct TSpirvExecutionMode {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
// spirv_execution_mode
TMap<int, TVector<const TIntermConstantUnion*>> modes;
// spirv_execution_mode_id
TMap<int, TVector<const TIntermConstantUnion*> > modeIds;
};
// SPIR-V decorations
struct TSpirvDecorate {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
// spirv_decorate
TMap<int, TVector<const TIntermConstantUnion*> > decorates;
// spirv_decorate_id
TMap<int, TVector<const TIntermConstantUnion*> > decorateIds;
// spirv_decorate_string
TMap<int, TVector<const TIntermConstantUnion*> > decorateStrings;
};
// SPIR-V instruction
struct TSpirvInstruction {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TSpirvInstruction() { set = ""; id = -1; }
bool operator==(const TSpirvInstruction& rhs) const { return set == rhs.set && id == rhs.id; }
bool operator!=(const TSpirvInstruction& rhs) const { return !operator==(rhs); }
// spirv_instruction
TString set;
int id;
};
// SPIR-V type parameter
struct TSpirvTypeParameter {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TSpirvTypeParameter(const TIntermConstantUnion* arg) { isConstant = true; constant = arg; }
TSpirvTypeParameter(const TType* arg) { isConstant = false; type = arg; }
bool operator==(const TSpirvTypeParameter& rhs) const
{
return isConstant == rhs.isConstant && ((isConstant && constant == rhs.constant) || (!isConstant && type == rhs.type));
}
bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); }
bool isConstant;
union {
const TIntermConstantUnion* constant;
const TType* type;
};
};
typedef TVector<TSpirvTypeParameter> TSpirvTypeParameters;
// SPIR-V type
struct TSpirvType {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
bool operator==(const TSpirvType& rhs) const
{
return spirvInst == rhs.spirvInst && typeParams == rhs.typeParams;
}
bool operator!=(const TSpirvType& rhs) const { return !operator==(rhs); }
// spirv_type
TSpirvInstruction spirvInst;
TSpirvTypeParameters typeParams;
};
} // end namespace glslang
#endif // GLSLANG_WEB
...@@ -71,6 +71,9 @@ enum TOperator { ...@@ -71,6 +71,9 @@ enum TOperator {
EOpFunctionCall, EOpFunctionCall,
EOpFunction, // For function definition EOpFunction, // For function definition
EOpParameters, // an aggregate listing the parameters to a function EOpParameters, // an aggregate listing the parameters to a function
#ifndef GLSLANG_WEB
EOpSpirvInst,
#endif
// //
// Unary operators // Unary operators
...@@ -1616,8 +1619,15 @@ public: ...@@ -1616,8 +1619,15 @@ public:
virtual TIntermUnary* getAsUnaryNode() { return this; } virtual TIntermUnary* getAsUnaryNode() { return this; }
virtual const TIntermUnary* getAsUnaryNode() const { return this; } virtual const TIntermUnary* getAsUnaryNode() const { return this; }
virtual void updatePrecision(); virtual void updatePrecision();
#ifndef GLSLANG_WEB
void setSpirvInstruction(const TSpirvInstruction& inst) { spirvInst = inst; }
const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
#endif
protected: protected:
TIntermTyped* operand; TIntermTyped* operand;
#ifndef GLSLANG_WEB
TSpirvInstruction spirvInst;
#endif
}; };
typedef TVector<TIntermNode*> TIntermSequence; typedef TVector<TIntermNode*> TIntermSequence;
...@@ -1648,6 +1658,10 @@ public: ...@@ -1648,6 +1658,10 @@ public:
bool getDebug() const { return debug; } bool getDebug() const { return debug; }
void setPragmaTable(const TPragmaTable& pTable); void setPragmaTable(const TPragmaTable& pTable);
const TPragmaTable& getPragmaTable() const { return *pragmaTable; } const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
#ifndef GLSLANG_WEB
void setSpirvInstruction(const TSpirvInstruction& inst) { spirvInst = inst; }
const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
#endif
protected: protected:
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
...@@ -1658,6 +1672,9 @@ protected: ...@@ -1658,6 +1672,9 @@ protected:
bool optimize; bool optimize;
bool debug; bool debug;
TPragmaTable* pragmaTable; TPragmaTable* pragmaTable;
#ifndef GLSLANG_WEB
TSpirvInstruction spirvInst;
#endif
}; };
// //
......
...@@ -472,6 +472,20 @@ public: ...@@ -472,6 +472,20 @@ public:
void handleLoopAttributes(const TAttributes& attributes, TIntermNode*); void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
// Function attributes // Function attributes
void handleFunctionAttributes(const TSourceLoc&, const TAttributes&, TFunction*); void handleFunctionAttributes(const TSourceLoc&, const TAttributes&, TFunction*);
// GL_EXT_spirv_intrinsics
TSpirvRequirement* makeSpirvRequirement(const TSourceLoc& loc, const TString& name,
const TIntermAggregate* extensions, const TIntermAggregate* capabilities);
TSpirvRequirement* mergeSpirvRequirements(const TSourceLoc& loc, TSpirvRequirement* spirvReq1,
TSpirvRequirement* spirvReq2);
TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TIntermConstantUnion* constant);
TSpirvTypeParameters* makeSpirvTypeParameters(const TPublicType& type);
TSpirvTypeParameters* mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1,
TSpirvTypeParameters* spirvTypeParams2);
TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, const TString& value);
TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, int value);
TSpirvInstruction* mergeSpirvInstruction(const TSourceLoc& loc, TSpirvInstruction* spirvInst1,
TSpirvInstruction* spirvInst2);
#endif #endif
void checkAndResizeMeshViewDim(const TSourceLoc&, TType&, bool isBlockMember); void checkAndResizeMeshViewDim(const TSourceLoc&, TType&, bool isBlockMember);
......
...@@ -586,6 +586,18 @@ void TScanContext::fillInKeywordMap() ...@@ -586,6 +586,18 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["f64mat4x2"] = F64MAT4X2; (*KeywordMap)["f64mat4x2"] = F64MAT4X2;
(*KeywordMap)["f64mat4x3"] = F64MAT4X3; (*KeywordMap)["f64mat4x3"] = F64MAT4X3;
(*KeywordMap)["f64mat4x4"] = F64MAT4X4; (*KeywordMap)["f64mat4x4"] = F64MAT4X4;
// GL_EXT_spirv_intrinsics
(*KeywordMap)["spirv_instruction"] = SPIRV_INSTRUCTION;
(*KeywordMap)["spirv_execution_mode"] = SPIRV_EXECUTION_MODE;
(*KeywordMap)["spirv_execution_mode_id"] = SPIRV_EXECUTION_MODE_ID;
(*KeywordMap)["spirv_decorate"] = SPIRV_DECORATE;
(*KeywordMap)["spirv_decorate_id"] = SPIRV_DECORATE_ID;
(*KeywordMap)["spirv_decorate_string"] = SPIRV_DECORATE_STRING;
(*KeywordMap)["spirv_type"] = SPIRV_TYPE;
(*KeywordMap)["spirv_storage_class"] = SPIRV_STORAGE_CLASS;
(*KeywordMap)["spirv_by_reference"] = SPIRV_BY_REFERENCE;
(*KeywordMap)["spirv_literal"] = SPIRV_LITERAL;
#endif #endif
(*KeywordMap)["sampler2D"] = SAMPLER2D; (*KeywordMap)["sampler2D"] = SAMPLER2D;
...@@ -1747,6 +1759,21 @@ int TScanContext::tokenizeIdentifier() ...@@ -1747,6 +1759,21 @@ int TScanContext::tokenizeIdentifier()
return keyword; return keyword;
else else
return identifierOrType(); return identifierOrType();
case SPIRV_INSTRUCTION:
case SPIRV_EXECUTION_MODE:
case SPIRV_EXECUTION_MODE_ID:
case SPIRV_DECORATE:
case SPIRV_DECORATE_ID:
case SPIRV_DECORATE_STRING:
case SPIRV_TYPE:
case SPIRV_STORAGE_CLASS:
case SPIRV_BY_REFERENCE:
case SPIRV_LITERAL:
if (parseContext.symbolTable.atBuiltInLevel() ||
parseContext.extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
return keyword;
return identifierOrType();
#endif #endif
default: default:
......
...@@ -77,6 +77,7 @@ void TType::buildMangledName(TString& mangledName) const ...@@ -77,6 +77,7 @@ void TType::buildMangledName(TString& mangledName) const
case EbtAtomicUint: mangledName += "au"; break; case EbtAtomicUint: mangledName += "au"; break;
case EbtAccStruct: mangledName += "as"; break; case EbtAccStruct: mangledName += "as"; break;
case EbtRayQuery: mangledName += "rq"; break; case EbtRayQuery: mangledName += "rq"; break;
case EbtSpirvType: mangledName += "spv-t"; break;
#endif #endif
case EbtSampler: case EbtSampler:
switch (sampler.type) { switch (sampler.type) {
...@@ -390,6 +391,9 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf) ...@@ -390,6 +391,9 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
implicitThis = copyOf.implicitThis; implicitThis = copyOf.implicitThis;
illegalImplicitThis = copyOf.illegalImplicitThis; illegalImplicitThis = copyOf.illegalImplicitThis;
defaultParamCount = copyOf.defaultParamCount; defaultParamCount = copyOf.defaultParamCount;
#ifndef GLSLANG_WEB
spirvInst = copyOf.spirvInst;
#endif
} }
TFunction* TFunction::clone() const TFunction* TFunction::clone() const
......
...@@ -319,6 +319,15 @@ public: ...@@ -319,6 +319,15 @@ public:
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; } virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
virtual const TParameter& operator[](int i) const { return parameters[i]; } virtual const TParameter& operator[](int i) const { return parameters[i]; }
#ifndef GLSLANG_WEB
virtual void setSpirvInstruction(const TSpirvInstruction& inst)
{
relateToOperator(EOpSpirvInst);
spirvInst = inst;
}
virtual const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
#endif
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE) #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override; virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif #endif
...@@ -342,6 +351,10 @@ protected: ...@@ -342,6 +351,10 @@ protected:
// This is important for a static member function that has member variables in scope, // This is important for a static member function that has member variables in scope,
// but is not allowed to use them, or see hidden symbols instead. // but is not allowed to use them, or see hidden symbols instead.
int defaultParamCount; int defaultParamCount;
#ifndef GLSLANG_WEB
TSpirvInstruction spirvInst; // SPIR-V instruction qualifiers
#endif
}; };
// //
......
...@@ -333,6 +333,7 @@ void TParseVersions::initializeExtensionBehavior() ...@@ -333,6 +333,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_shader_image_int64] = EBhDisable; extensionBehavior[E_GL_EXT_shader_image_int64] = EBhDisable;
extensionBehavior[E_GL_EXT_terminate_invocation] = EBhDisable; extensionBehavior[E_GL_EXT_terminate_invocation] = EBhDisable;
extensionBehavior[E_GL_EXT_shared_memory_block] = EBhDisable; extensionBehavior[E_GL_EXT_shared_memory_block] = EBhDisable;
extensionBehavior[E_GL_EXT_spirv_intrinsics] = EBhDisable;
// OVR extensions // OVR extensions
extensionBehavior[E_GL_OVR_multiview] = EBhDisable; extensionBehavior[E_GL_OVR_multiview] = EBhDisable;
...@@ -493,6 +494,7 @@ void TParseVersions::getPreamble(std::string& preamble) ...@@ -493,6 +494,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_ray_tracing 1\n" "#define GL_EXT_ray_tracing 1\n"
"#define GL_EXT_ray_query 1\n" "#define GL_EXT_ray_query 1\n"
"#define GL_EXT_ray_flags_primitive_culling 1\n" "#define GL_EXT_ray_flags_primitive_culling 1\n"
"#define GL_EXT_spirv_intrinsics 1\n"
"#define GL_AMD_shader_ballot 1\n" "#define GL_AMD_shader_ballot 1\n"
"#define GL_AMD_shader_trinary_minmax 1\n" "#define GL_AMD_shader_trinary_minmax 1\n"
...@@ -602,6 +604,29 @@ void TParseVersions::getPreamble(std::string& preamble) ...@@ -602,6 +604,29 @@ void TParseVersions::getPreamble(std::string& preamble)
preamble += "\n"; preamble += "\n";
} }
#endif #endif
#ifndef GLSLANG_WEB
// GL_EXT_spirv_intrinsics
if (!isEsProfile()) {
switch (language) {
case EShLangVertex: preamble += "#define GL_VERTEX_SHADER 1 \n"; break;
case EShLangTessControl: preamble += "#define GL_TESSELLATION_CONTROL_SHADER 1 \n"; break;
case EShLangTessEvaluation: preamble += "#define GL_TESSELLATION_EVALUATION_SHADER 1 \n"; break;
case EShLangGeometry: preamble += "#define GL_GEOMETRY_SHADER 1 \n"; break;
case EShLangFragment: preamble += "#define GL_FRAGMENT_SHADER 1 \n"; break;
case EShLangCompute: preamble += "#define GL_COMPUTE_SHADER 1 \n"; break;
case EShLangRayGen: preamble += "#define GL_RAY_GENERATION_SHADER_EXT 1 \n"; break;
case EShLangIntersect: preamble += "#define GL_INTERSECTION_SHADER_EXT 1 \n"; break;
case EShLangAnyHit: preamble += "#define GL_ANY_HIT_SHADER_EXT 1 \n"; break;
case EShLangClosestHit: preamble += "#define GL_CLOSEST_HIT_SHADER_EXT 1 \n"; break;
case EShLangMiss: preamble += "#define GL_MISS_SHADER_EXT 1 \n"; break;
case EShLangCallable: preamble += "#define GL_CALLABLE_SHADER_EXT 1 \n"; break;
case EShLangTaskNV: preamble += "#define GL_TASK_SHADER_NV 1 \n"; break;
case EShLangMeshNV: preamble += "#define GL_MESH_SHADER_NV 1 \n"; break;
default: break;
}
}
#endif
} }
// //
......
...@@ -205,6 +205,7 @@ const char* const E_GL_EXT_shader_image_int64 = "GL_EXT_shader_ima ...@@ -205,6 +205,7 @@ const char* const E_GL_EXT_shader_image_int64 = "GL_EXT_shader_ima
const char* const E_GL_EXT_null_initializer = "GL_EXT_null_initializer"; const char* const E_GL_EXT_null_initializer = "GL_EXT_null_initializer";
const char* const E_GL_EXT_shared_memory_block = "GL_EXT_shared_memory_block"; const char* const E_GL_EXT_shared_memory_block = "GL_EXT_shared_memory_block";
const char* const E_GL_EXT_subgroup_uniform_control_flow = "GL_EXT_subgroup_uniform_control_flow"; const char* const E_GL_EXT_subgroup_uniform_control_flow = "GL_EXT_subgroup_uniform_control_flow";
const char* const E_GL_EXT_spirv_intrinsics = "GL_EXT_spirv_intrinsics";
// Arrays of extensions for the above viewportEXTs duplications // Arrays of extensions for the above viewportEXTs duplications
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -696,6 +696,10 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node) ...@@ -696,6 +696,10 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
case EOpConstructReference: out.debug << "Construct reference type"; break; case EOpConstructReference: out.debug << "Construct reference type"; break;
#ifndef GLSLANG_WEB
case EOpSpirvInst: out.debug << "spirv_instruction"; break;
#endif
default: out.debug.message(EPrefixError, "Bad unary op"); default: out.debug.message(EPrefixError, "Bad unary op");
} }
...@@ -1126,6 +1130,10 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node ...@@ -1126,6 +1130,10 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpIsHelperInvocation: out.debug << "IsHelperInvocation"; break; case EOpIsHelperInvocation: out.debug << "IsHelperInvocation"; break;
case EOpDebugPrintf: out.debug << "Debug printf"; break; case EOpDebugPrintf: out.debug << "Debug printf"; break;
#ifndef GLSLANG_WEB
case EOpSpirvInst: out.debug << "spirv_instruction"; break;
#endif
default: out.debug.message(EPrefixError, "Bad aggregation op"); default: out.debug.message(EPrefixError, "Bad aggregation op");
} }
......
...@@ -330,6 +330,8 @@ public: ...@@ -330,6 +330,8 @@ public:
binaryDoubleOutput(false), binaryDoubleOutput(false),
subgroupUniformControlFlow(false), subgroupUniformControlFlow(false),
usePhysicalStorageBuffer(false), usePhysicalStorageBuffer(false),
spirvRequirement(nullptr),
spirvExecutionMode(nullptr),
uniformLocationBase(0) uniformLocationBase(0)
#endif #endif
{ {
...@@ -868,6 +870,15 @@ public: ...@@ -868,6 +870,15 @@ public:
void setSubgroupUniformControlFlow() { subgroupUniformControlFlow = true; } void setSubgroupUniformControlFlow() { subgroupUniformControlFlow = true; }
bool getSubgroupUniformControlFlow() const { return subgroupUniformControlFlow; } bool getSubgroupUniformControlFlow() const { return subgroupUniformControlFlow; }
// GL_EXT_spirv_intrinsics
void insertSpirvRequirement(const TSpirvRequirement* spirvReq);
bool hasSpirvRequirement() const { return spirvRequirement != nullptr; }
const TSpirvRequirement& getSpirvRequirement() const { return *spirvRequirement; }
void insertSpirvExecutionMode(int executionMode, const TIntermAggregate* args = nullptr);
void insertSpirvExecutionModeId(int executionMode, const TIntermAggregate* args);
bool hasSpirvExecutionMode() const { return spirvExecutionMode != nullptr; }
const TSpirvExecutionMode& getSpirvExecutionMode() const { return *spirvExecutionMode; }
#endif // GLSLANG_WEB #endif // GLSLANG_WEB
void addBlockStorageOverride(const char* nameStr, TBlockStorageClass backing) void addBlockStorageOverride(const char* nameStr, TBlockStorageClass backing)
...@@ -1122,6 +1133,9 @@ protected: ...@@ -1122,6 +1133,9 @@ protected:
bool subgroupUniformControlFlow; bool subgroupUniformControlFlow;
bool usePhysicalStorageBuffer; bool usePhysicalStorageBuffer;
TSpirvRequirement* spirvRequirement;
TSpirvExecutionMode* spirvExecutionMode;
std::unordered_map<std::string, int> uniformLocationOverrides; std::unordered_map<std::string, int> uniformLocationOverrides;
int uniformLocationBase; int uniformLocationBase;
TNumericFeatures numericFeatures; TNumericFeatures numericFeatures;
......
...@@ -1191,9 +1191,12 @@ int TPpContext::tokenize(TPpToken& ppToken) ...@@ -1191,9 +1191,12 @@ int TPpContext::tokenize(TPpToken& ppToken)
// HLSL allows string literals. // HLSL allows string literals.
// GLSL allows string literals with GL_EXT_debug_printf. // GLSL allows string literals with GL_EXT_debug_printf.
if (ifdepth == 0 && parseContext.intermediate.getSource() != EShSourceHlsl) { if (ifdepth == 0 && parseContext.intermediate.getSource() != EShSourceHlsl) {
parseContext.requireExtensions(ppToken.loc, 1, &E_GL_EXT_debug_printf, "string literal"); const char* const string_literal_EXTs[] = { E_GL_EXT_debug_printf, E_GL_EXT_spirv_intrinsics };
if (!parseContext.extensionTurnedOn(E_GL_EXT_debug_printf)) const int Num_string_literal_EXTs = sizeof(string_literal_EXTs) / sizeof(string_literal_EXTs[0]);
continue; parseContext.requireExtensions(ppToken.loc, 2, string_literal_EXTs, "string literal");
if (!parseContext.extensionTurnedOn(E_GL_EXT_debug_printf) &&
!parseContext.extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
continue;
} }
break; break;
case '\'': case '\'':
......
...@@ -356,6 +356,13 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -356,6 +356,13 @@ INSTANTIATE_TEST_SUITE_P(
"spv.int64.frag", "spv.int64.frag",
"spv.intcoopmat.comp", "spv.intcoopmat.comp",
"spv.intOps.vert", "spv.intOps.vert",
"spv.intrinsicsSpirvByReference.vert",
"spv.intrinsicsSpirvDecorate.frag",
"spv.intrinsicsSpirvExecutionMode.frag",
"spv.intrinsicsSpirvInstruction.vert",
"spv.intrinsicsSpirvLiteral.vert",
"spv.intrinsicsSpirvStorageClass.rchit",
"spv.intrinsicsSpirvType.rgen",
"spv.layer.tese", "spv.layer.tese",
"spv.layoutNested.vert", "spv.layoutNested.vert",
"spv.length.frag", "spv.length.frag",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment