SPV: Implement extension SPV_KHR_shader_draw_parameters.
diff --git a/SPIRV/GLSL.ext.KHR.h b/SPIRV/GLSL.ext.KHR.h
index 7ce795f..344dd39 100644
--- a/SPIRV/GLSL.ext.KHR.h
+++ b/SPIRV/GLSL.ext.KHR.h
@@ -27,25 +27,10 @@
#ifndef GLSLextKHR_H
#define GLSLextKHR_H
-enum BuiltIn;
-enum Op;
-enum Capability;
-
-static const int GLSLextKHRVersion = 100;
-static const int GLSLextKHRRevision = 1;
-
// SPV_KHR_shader_ballot
-static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
+static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
-static const BuiltIn BuiltInSubgroupEqMaskKHR = static_cast<BuiltIn>(4416);
-static const BuiltIn BuiltInSubgroupGeMaskKHR = static_cast<BuiltIn>(4417);
-static const BuiltIn BuiltInSubgroupGtMaskKHR = static_cast<BuiltIn>(4418);
-static const BuiltIn BuiltInSubgroupLeMaskKHR = static_cast<BuiltIn>(4419);
-static const BuiltIn BuiltInSubgroupLtMaskKHR = static_cast<BuiltIn>(4420);
-
-static const Op OpSubgroupBallotKHR = static_cast<Op>(4421);
-static const Op OpSubgroupFirstInvocationKHR = static_cast<Op>(4422);
-
-static const Capability CapabilitySubgroupBallotKHR = static_cast<Capability>(4423);
+// SPV_KHR_shader_draw_parameters
+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 5ecb6ab..9c8b8b9 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -498,13 +498,21 @@
case glslang::EbvInstanceId: return spv::BuiltInInstanceId;
case glslang::EbvVertexIndex: return spv::BuiltInVertexIndex;
case glslang::EbvInstanceIndex: return spv::BuiltInInstanceIndex;
+
case glslang::EbvBaseVertex:
+ builder.addExtension(spv::E_SPV_KHR_shader_draw_parameters);
+ builder.addCapability(spv::CapabilityDrawParameters);
+ return spv::BuiltInBaseVertex;
+
case glslang::EbvBaseInstance:
+ builder.addExtension(spv::E_SPV_KHR_shader_draw_parameters);
+ builder.addCapability(spv::CapabilityDrawParameters);
+ return spv::BuiltInBaseInstance;
case glslang::EbvDrawId:
- // TODO: Add SPIR-V builtin ID.
- logger->missingFunctionality("shader draw parameters");
- return spv::BuiltInMax;
+ builder.addExtension(spv::E_SPV_KHR_shader_draw_parameters);
+ builder.addCapability(spv::CapabilityDrawParameters);
+ return spv::BuiltInDrawIndex;
case glslang::EbvPrimitiveId:
if (glslangIntermediate->getStage() == EShLangFragment)
diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp
index d2161dd..0e68c7e 100755
--- a/SPIRV/doc.cpp
+++ b/SPIRV/doc.cpp
@@ -48,7 +48,6 @@
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
@@ -319,6 +318,10 @@
case 4419: return "SubgroupLeMaskKHR";
case 4420: return "SubgroupLtMaskKHR";
+ case 4424: return "BaseVertex";
+ case 4425: return "BaseInstance";
+ case 4426: return "DrawIndex";
+
#ifdef AMD_EXTENSIONS
case 4992: return "BaryCoordNoPerspAMD";
case 4993: return "BaryCoordNoPerspCentroidAMD";
@@ -808,6 +811,7 @@
default: return "Bad";
case 4423: return "SubgroupBallotKHR";
+ case 4427: return "DrawParameters";
}
}
diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp
index e3d1342..bb3c3f4 100755
--- a/SPIRV/spirv.hpp
+++ b/SPIRV/spirv.hpp
@@ -47,11 +47,11 @@
typedef unsigned int Id;
#define SPV_VERSION 0x10000
-#define SPV_REVISION 6
+#define SPV_REVISION 8
static const unsigned int MagicNumber = 0x07230203;
static const unsigned int Version = 0x00010000;
-static const unsigned int Revision = 6;
+static const unsigned int Revision = 8;
static const unsigned int OpCodeMask = 0xffff;
static const unsigned int WordCountShift = 16;
@@ -420,6 +420,14 @@
BuiltInSubgroupLocalInvocationId = 41,
BuiltInVertexIndex = 42,
BuiltInInstanceIndex = 43,
+ BuiltInSubgroupEqMaskKHR = 4416,
+ BuiltInSubgroupGeMaskKHR = 4417,
+ BuiltInSubgroupGtMaskKHR = 4418,
+ BuiltInSubgroupLeMaskKHR = 4419,
+ BuiltInSubgroupLtMaskKHR = 4420,
+ BuiltInBaseVertex = 4424,
+ BuiltInBaseInstance = 4425,
+ BuiltInDrawIndex = 4426,
BuiltInMax = 0x7fffffff,
};
@@ -595,6 +603,8 @@
CapabilityStorageImageReadWithoutFormat = 55,
CapabilityStorageImageWriteWithoutFormat = 56,
CapabilityMultiViewport = 57,
+ CapabilitySubgroupBallotKHR = 4423,
+ CapabilityDrawParameters = 4427,
CapabilityMax = 0x7fffffff,
};
@@ -893,6 +903,8 @@
OpAtomicFlagTestAndSet = 318,
OpAtomicFlagClear = 319,
OpImageSparseRead = 320,
+ OpSubgroupBallotKHR = 4421,
+ OpSubgroupFirstInvocationKHR = 4422,
OpMax = 0x7fffffff,
};