SPV: Implement new extensions GL_KHX_device_group and GL_KHX_multiview.
These correspond to SPV_KHR_device_group and SPV_KHR_multiview.
Also, bring tests up to date with Khronos internals, and some misc. related changes.
diff --git a/SPIRV/GLSL.ext.KHR.h b/SPIRV/GLSL.ext.KHR.h
index 4614a3c..a8f20c3 100644
--- a/SPIRV/GLSL.ext.KHR.h
+++ b/SPIRV/GLSL.ext.KHR.h
@@ -27,10 +27,17 @@
#ifndef GLSLextKHR_H
#define GLSLextKHR_H
-// SPV_KHR_shader_ballot
-static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
+enum BuiltIn;
+enum Op;
+enum Capability;
-// SPV_KHR_shader_draw_parameters
-static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
-static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
+static const int GLSLextKHRVersion = 100;
+static const int GLSLextKHRRevision = 1;
+
+static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
+static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
+static const char* const E_SPV_KHR_device_group = "SPV_KHR_device_group";
+static const char* const E_SPV_KHR_multiview = "SPV_KHR_multiview";
+static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
+
#endif // #ifndef GLSLextKHR_H
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 13bc305..a7b0f05 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -628,6 +628,16 @@
return spv::BuiltInBaryCoordPullModelAMD;
#endif
+ case glslang::EbvDeviceIndex:
+ builder.addExtension(spv::E_SPV_KHR_device_group);
+ builder.addCapability(spv::CapabilityDeviceGroup);
+ return spv::BuiltinDeviceIndex;
+
+ case glslang::EbvViewIndex:
+ builder.addExtension(spv::E_SPV_KHR_multiview);
+ builder.addCapability(spv::CapabilityMultiView);
+ return spv::BuiltinViewIndex;
+
#ifdef NV_EXTENSIONS
case glslang::EbvViewportMaskNV:
builder.addExtension(spv::E_SPV_NV_viewport_array2);
diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp
index 91e3b89..52af6a7 100755
--- a/SPIRV/doc.cpp
+++ b/SPIRV/doc.cpp
@@ -48,6 +48,7 @@
namespace spv {
extern "C" {
// Include C-based headers that don't have a namespace
+ #include "GLSL.ext.KHR.h"
#ifdef AMD_EXTENSIONS
#include "GLSL.ext.AMD.h"
#endif
@@ -318,15 +319,13 @@
case 42: return "VertexIndex"; // TBD: put next to VertexId?
case 43: return "InstanceIndex"; // TBD: put next to InstanceId?
- case BuiltInCeiling:
- default: return "Bad";
-
case 4416: return "SubgroupEqMaskKHR";
case 4417: return "SubgroupGeMaskKHR";
case 4418: return "SubgroupGtMaskKHR";
case 4419: return "SubgroupLeMaskKHR";
case 4420: return "SubgroupLtMaskKHR";
-
+ case 4438: return "DeviceIndex";
+ case 4440: return "ViewIndex";
case 4424: return "BaseVertex";
case 4425: return "BaseInstance";
case 4426: return "DrawIndex";
@@ -340,6 +339,7 @@
case 4997: return "BaryCoordSmoothSampleAMD";
case 4998: return "BaryCoordPullModelAMD";
#endif
+
#ifdef NV_EXTENSIONS
case 5253: return "ViewportMaskNV";
case 5257: return "SecondaryPositionNV";
@@ -347,6 +347,9 @@
case 5260: return "PositionPerViewNV";
case 5261: return "ViewportMaskPerViewNV";
#endif
+
+ case BuiltInCeiling:
+ default: return "Bad";
}
}
@@ -823,13 +826,13 @@
case 56: return "StorageImageWriteWithoutFormat";
case 57: return "MultiViewport";
- case CapabilityCeiling:
- default: return "Bad";
-
case 4423: return "SubgroupBallotKHR";
case 4427: return "DrawParameters";
case 4431: return "SubgroupVoteKHR";
+ case 4437: return "DeviceGroup";
+ case 4439: return "MultiView";
+
#ifdef NV_EXTENSIONS
case 5251: return "GeometryShaderPassthroughNV";
case 5254: return "ShaderViewportIndexLayerNV";
@@ -838,6 +841,8 @@
case 5262: return "PerViewAttributesNV";
#endif
+ case CapabilityCeiling:
+ default: return "Bad";
}
}
@@ -1166,10 +1171,6 @@
case 319: return "OpAtomicFlagClear";
case 320: return "OpImageSparseRead";
- case OpcodeCeiling:
- default:
- return "Bad";
-
case 4421: return "OpSubgroupBallotKHR";
case 4422: return "OpSubgroupFirstInvocationKHR";
case 4428: return "OpSubgroupAllKHR";
@@ -1187,6 +1188,10 @@
case 5006: return "OpGroupUMaxNonUniformAMD";
case 5007: return "OpGroupSMaxNonUniformAMD";
#endif
+
+ case OpcodeCeiling:
+ default:
+ return "Bad";
}
}
diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp
index c7b3d5f..6bfd014 100755
--- a/SPIRV/spirv.hpp
+++ b/SPIRV/spirv.hpp
@@ -428,6 +428,8 @@
BuiltInBaseVertex = 4424,
BuiltInBaseInstance = 4425,
BuiltInDrawIndex = 4426,
+ BuiltinDeviceIndex = 4438,
+ BuiltinViewIndex = 4440,
BuiltInMax = 0x7fffffff,
};
@@ -606,6 +608,8 @@
CapabilitySubgroupBallotKHR = 4423,
CapabilityDrawParameters = 4427,
CapabilitySubgroupVoteKHR = 4431,
+ CapabilityDeviceGroup = 4437,
+ CapabilityMultiView = 4439,
CapabilityMax = 0x7fffffff,
};
@@ -906,10 +910,10 @@
OpImageSparseRead = 320,
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
- OpSubgroupReadInvocationKHR = 4432,
- OpSubgroupAllKHR = 4428,
- OpSubgroupAnyKHR = 4429,
+ OpSubgroupAllKHR = 4428,
+ OpSubgroupAnyKHR = 4429,
OpSubgroupAllEqualKHR = 4430,
+ OpSubgroupReadInvocationKHR = 4432,
OpMax = 0x7fffffff,
};
diff --git a/Test/baseResults/spv.deviceGroup.frag.out b/Test/baseResults/spv.deviceGroup.frag.out
new file mode 100755
index 0000000..beaf906
--- /dev/null
+++ b/Test/baseResults/spv.deviceGroup.frag.out
@@ -0,0 +1,38 @@
+spv.deviceGroup.frag
+Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 17
+
+ Capability Shader
+ Capability DeviceGroup
+ Extension "SPV_KHR_device_group"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 9
+ ExecutionMode 4 OriginUpperLeft
+ Source GLSL 450
+ SourceExtension "GL_KHX_device_group"
+ Name 4 "main"
+ Name 9 "color"
+ Name 12 "gl_DeviceIndexKHR"
+ Decorate 12(gl_DeviceIndexKHR) BuiltIn DeviceIndex
+ 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: TypeInt 32 1
+ 11: TypePointer UniformConstant 10(int)
+12(gl_DeviceIndexKHR): 11(ptr) Variable UniformConstant
+ 15: 6(float) Constant 0
+ 4(main): 2 Function None 3
+ 5: Label
+ 13: 10(int) Load 12(gl_DeviceIndexKHR)
+ 14: 6(float) ConvertSToF 13
+ 16: 7(fvec4) CompositeConstruct 14 15 15 15
+ Store 9(color) 16
+ Return
+ FunctionEnd
diff --git a/Test/baseResults/spv.drawParams.vert.out b/Test/baseResults/spv.drawParams.vert.out
new file mode 100755
index 0000000..b75efe0
--- /dev/null
+++ b/Test/baseResults/spv.drawParams.vert.out
@@ -0,0 +1,59 @@
+spv.drawParams.vert
+Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 29
+
+ Capability Shader
+ Capability DrawParameters
+ Extension "SPV_KHR_shader_draw_parameters"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 10 13 16 21
+ Source GLSL 450
+ SourceExtension "GL_ARB_shader_draw_parameters"
+ Name 4 "main"
+ Name 8 "a"
+ Name 10 "gl_BaseVertexARB"
+ Name 12 "b"
+ Name 13 "gl_BaseInstanceARB"
+ Name 15 "c"
+ Name 16 "gl_DrawIDARB"
+ Name 21 "pos"
+ Decorate 10(gl_BaseVertexARB) BuiltIn BaseVertex
+ Decorate 13(gl_BaseInstanceARB) BuiltIn BaseInstance
+ Decorate 16(gl_DrawIDARB) BuiltIn DrawIndex
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Function 6(int)
+ 9: TypePointer Input 6(int)
+10(gl_BaseVertexARB): 9(ptr) Variable Input
+13(gl_BaseInstanceARB): 9(ptr) Variable Input
+16(gl_DrawIDARB): 9(ptr) Variable Input
+ 18: TypeFloat 32
+ 19: TypeVector 18(float) 3
+ 20: TypePointer Output 19(fvec3)
+ 21(pos): 20(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 8(a): 7(ptr) Variable Function
+ 12(b): 7(ptr) Variable Function
+ 15(c): 7(ptr) Variable Function
+ 11: 6(int) Load 10(gl_BaseVertexARB)
+ Store 8(a) 11
+ 14: 6(int) Load 13(gl_BaseInstanceARB)
+ Store 12(b) 14
+ 17: 6(int) Load 16(gl_DrawIDARB)
+ Store 15(c) 17
+ 22: 6(int) Load 8(a)
+ 23: 18(float) ConvertSToF 22
+ 24: 6(int) Load 12(b)
+ 25: 18(float) ConvertSToF 24
+ 26: 6(int) Load 15(c)
+ 27: 18(float) ConvertSToF 26
+ 28: 19(fvec3) CompositeConstruct 23 25 27
+ Store 21(pos) 28
+ Return
+ FunctionEnd
diff --git a/Test/baseResults/spv.multiView.frag.out b/Test/baseResults/spv.multiView.frag.out
new file mode 100755
index 0000000..bfd8b48
--- /dev/null
+++ b/Test/baseResults/spv.multiView.frag.out
@@ -0,0 +1,38 @@
+spv.multiView.frag
+Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 17
+
+ Capability Shader
+ Capability MultiView
+ Extension "SPV_KHR_multiview"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 9
+ ExecutionMode 4 OriginUpperLeft
+ Source GLSL 450
+ SourceExtension "GL_KHX_multiview"
+ Name 4 "main"
+ Name 9 "color"
+ Name 12 "gl_ViewIndexKHR"
+ Decorate 12(gl_ViewIndexKHR) BuiltIn ViewIndex
+ 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: TypeInt 32 1
+ 11: TypePointer UniformConstant 10(int)
+12(gl_ViewIndexKHR): 11(ptr) Variable UniformConstant
+ 15: 6(float) Constant 0
+ 4(main): 2 Function None 3
+ 5: Label
+ 13: 10(int) Load 12(gl_ViewIndexKHR)
+ 14: 6(float) ConvertSToF 13
+ 16: 7(fvec4) CompositeConstruct 14 15 15 15
+ Store 9(color) 16
+ Return
+ FunctionEnd
diff --git a/Test/baseResults/spv.specConstant.vert.out b/Test/baseResults/spv.specConstant.vert.out
index a6750e5..ea4e542 100644
--- a/Test/baseResults/spv.specConstant.vert.out
+++ b/Test/baseResults/spv.specConstant.vert.out
@@ -13,7 +13,7 @@
Source GLSL 400
Name 4 "main"
Name 9 "arraySize"
- Name 14 "foo(vf4[s1516];"
+ Name 14 "foo(vf4[s1518];"
Name 13 "p"
Name 17 "builtin_spec_constant("
Name 20 "color"
@@ -104,10 +104,10 @@
Store 20(color) 46
48: 10 Load 22(ucol)
Store 47(param) 48
- 49: 2 FunctionCall 14(foo(vf4[s1516];) 47(param)
+ 49: 2 FunctionCall 14(foo(vf4[s1518];) 47(param)
Return
FunctionEnd
-14(foo(vf4[s1516];): 2 Function None 12
+14(foo(vf4[s1518];): 2 Function None 12
13(p): 11(ptr) FunctionParameter
15: Label
54: 24(ptr) AccessChain 53(dupUcol) 23
diff --git a/Test/spv.deviceGroup.frag b/Test/spv.deviceGroup.frag
new file mode 100644
index 0000000..9bc6b56
--- /dev/null
+++ b/Test/spv.deviceGroup.frag
@@ -0,0 +1,9 @@
+#version 450
+
+#extension GL_KHX_device_group : enable
+
+out vec4 color;
+
+void main() {
+ color = vec4(gl_DeviceIndexKHR, 0, 0, 0);
+}
diff --git a/Test/spv.drawParams.vert b/Test/spv.drawParams.vert
new file mode 100644
index 0000000..f2e3c1e
--- /dev/null
+++ b/Test/spv.drawParams.vert
@@ -0,0 +1,13 @@
+#version 450
+
+#extension GL_ARB_shader_draw_parameters : enable
+
+out vec3 pos;
+
+void main()
+{
+ int a = gl_BaseVertexARB;
+ int b = gl_BaseInstanceARB;
+ int c = gl_DrawIDARB;
+ pos = vec3(a, b, c);
+}
diff --git a/Test/spv.multiView.frag b/Test/spv.multiView.frag
new file mode 100644
index 0000000..99348e2
--- /dev/null
+++ b/Test/spv.multiView.frag
@@ -0,0 +1,9 @@
+#version 450
+
+#extension GL_KHX_multiview : enable
+
+out vec4 color;
+
+void main() {
+ color = vec4(gl_ViewIndexKHR, 0, 0, 0);
+}
diff --git a/glslang/Include/BaseTypes.h b/glslang/Include/BaseTypes.h
index f0e3c37..9ac587f 100644
--- a/glslang/Include/BaseTypes.h
+++ b/glslang/Include/BaseTypes.h
@@ -203,6 +203,9 @@
EbvBaryCoordPullModel,
#endif
+ EbvViewIndex,
+ EbvDeviceIndex,
+
#ifdef NV_EXTENSIONS
EbvViewportMaskNV,
EbvSecondaryPositionNV,
@@ -210,6 +213,7 @@
EbvPositionPerViewNV,
EbvViewportMaskPerViewNV,
#endif
+
// HLSL built-ins that live only temporarily, until they get remapped
// to one of the above.
EbvFragDepthGreater,
diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h
index 4a14843..52aa999 100644
--- a/glslang/Include/Types.h
+++ b/glslang/Include/Types.h
@@ -188,6 +188,8 @@
case EbtFloat: break;
case EbtInt: s.append("i"); break;
case EbtUint: s.append("u"); break;
+ case EbtInt64: s.append("i64"); break;
+ case EbtUint64: s.append("u64"); break;
default: break; // some compilers want this
}
if (image) {
diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h
index c7ddb1f..0d3292b 100644
--- a/glslang/Include/revision.h
+++ b/glslang/Include/revision.h
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
-#define GLSLANG_REVISION "Overload400-PrecQual.1845"
-#define GLSLANG_DATE "24-Feb-2017"
+#define GLSLANG_REVISION "Overload400-PrecQual.1853"
+#define GLSLANG_DATE "27-Feb-2017"
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index b9fa082..1e99eb5 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -85,6 +85,8 @@
prefixes[EbtFloat] = "";
prefixes[EbtInt] = "i";
prefixes[EbtUint] = "u";
+ prefixes[EbtInt64] = "i64";
+ prefixes[EbtUint64] = "u64";
postfixes[2] = "2";
postfixes[3] = "3";
postfixes[4] = "4";
@@ -103,6 +105,7 @@
{
}
+
//
// Add all context-independent built-in functions and variables that are present
// for the given version and profile. Share common ones across stages, otherwise
@@ -3698,6 +3701,11 @@
"\n");
}
+ if (profile != EEsProfile) {
+ commonBuiltins.append("uniform int gl_ViewIndexKHR;");
+ commonBuiltins.append("uniform int gl_DeviceIndexKHR;"); // GL_KHX_device_group
+ }
+
// printf("%s\n", commonBuiltins.c_str());
// printf("%s\n", stageBuiltins[EShLangFragment].c_str());
}
@@ -5308,6 +5316,13 @@
symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
}
+
+ if (profile != EEsProfile) {
+ symbolTable.setFunctionExtensions("gl_DeviceIndexKHR", 1, &E_GL_KHX_device_group);
+ BuiltInVariable("gl_DeviceIndexKHR", EbvDeviceIndex, symbolTable);
+ symbolTable.setFunctionExtensions("gl_ViewIndexKHR", 1, &E_GL_KHX_multiview);
+ BuiltInVariable("gl_ViewIndexKHR", EbvViewIndex, symbolTable);
+ }
break;
case EShLangCompute:
diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp
index 0bcd3af..637ed93 100644
--- a/glslang/MachineIndependent/Versions.cpp
+++ b/glslang/MachineIndependent/Versions.cpp
@@ -232,6 +232,10 @@
extensionBehavior[E_GL_OES_tessellation_point_size] = EBhDisable;
extensionBehavior[E_GL_OES_texture_buffer] = EBhDisable;
extensionBehavior[E_GL_OES_texture_cube_map_array] = EBhDisable;
+
+ // KHX extensions
+ extensionBehavior[E_GL_KHX_device_group] = EBhDisable;
+ extensionBehavior[E_GL_KHX_multiview] = EBhDisable;
}
// Get code that is not part of a shared symbol table, is specific to this shader,
diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h
index b99033f..26712d0 100644
--- a/glslang/MachineIndependent/Versions.h
+++ b/glslang/MachineIndependent/Versions.h
@@ -132,6 +132,10 @@
const char* const E_GL_EXT_shader_non_constant_global_initializers = "GL_EXT_shader_non_constant_global_initializers";
const char* const E_GL_EXT_shader_image_load_formatted = "GL_EXT_shader_image_load_formatted";
+// KHX extensions
+const char* const E_GL_KHX_device_group = "GL_KHX_device_group";
+const char* const E_GL_KHX_multiview = "GL_KHX_multiview";
+
// #line and #include
const char* const E_GL_GOOGLE_cpp_style_line_directive = "GL_GOOGLE_cpp_style_line_directive";
const char* const E_GL_GOOGLE_include_directive = "GL_GOOGLE_include_directive";
diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp
index b04ec51..10577bd 100644
--- a/gtests/Spv.FromFile.cpp
+++ b/gtests/Spv.FromFile.cpp
@@ -225,7 +225,9 @@
"spv.dataOutIndirect.vert",
"spv.deepRvalue.frag",
"spv.depthOut.frag",
+ "spv.deviceGroup.frag",
"spv.discard-dce.frag",
+ "spv.drawParams.vert",
"spv.doWhileLoop.frag",
"spv.earlyReturnDiscard.frag",
"spv.flowControl.frag",
@@ -234,8 +236,10 @@
"spv.functionCall.frag",
"spv.functionNestedOpaque.vert",
"spv.functionSemantics.frag",
+ "spv.GeometryShaderPassthrough.geom",
"spv.interpOps.frag",
"spv.int64.frag",
+ "spv.intOps.vert",
"spv.layoutNested.vert",
"spv.length.frag",
"spv.localAggregates.frag",
@@ -248,16 +252,17 @@
"spv.merge-unreachable.frag",
"spv.multiStruct.comp",
"spv.multiStructFuncall.frag",
+ "spv.multiView.frag",
"spv.newTexture.frag",
"spv.noDeadDecorations.vert",
"spv.nonSquare.vert",
+ "spv.noWorkgroup.comp",
"spv.offsets.frag",
"spv.Operations.frag",
- "spv.intOps.vert",
- "spv.noWorkgroup.comp",
"spv.precision.frag",
"spv.prepost.frag",
"spv.qualifiers.vert",
+ "spv.sampleMaskOverrideCoverage.frag",
"spv.shaderBallot.comp",
"spv.shaderDrawParams.vert",
"spv.shaderGroupVote.comp",