Implement GL_EXT_demote_to_helper_invocation
diff --git a/SPIRV/GLSL.ext.EXT.h b/SPIRV/GLSL.ext.EXT.h
index e29c055..40164b6 100644
--- a/SPIRV/GLSL.ext.EXT.h
+++ b/SPIRV/GLSL.ext.EXT.h
@@ -34,5 +34,6 @@
static const char* const E_SPV_EXT_shader_viewport_index_layer = "SPV_EXT_shader_viewport_index_layer";
static const char* const E_SPV_EXT_fragment_fully_covered = "SPV_EXT_fragment_fully_covered";
static const char* const E_SPV_EXT_fragment_invocation_density = "SPV_EXT_fragment_invocation_density";
+static const char* const E_SPV_EXT_demote_to_helper_invocation = "SPV_EXT_demote_to_helper_invocation";
#endif // #ifndef GLSLextEXT_H
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 16d90b8..7b1393c 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -3111,6 +3111,12 @@
builder.clearAccessChain();
break;
+ case glslang::EOpDemote:
+ builder.createNoResultOp(spv::OpDemoteToHelperInvocationEXT);
+ builder.addExtension(spv::E_SPV_EXT_demote_to_helper_invocation);
+ builder.addCapability(spv::CapabilityDemoteToHelperInvocationEXT);
+ break;
+
default:
assert(0);
break;
@@ -7610,6 +7616,13 @@
builder.createNoResultOp(spv::OpEndInvocationInterlockEXT);
return 0;
+ case glslang::EOpIsHelperInvocation:
+ {
+ std::vector<spv::Id> args; // Dummy arguments
+ spv::Id id = builder.createOp(spv::OpIsHelperInvocationEXT, typeId, args);
+ return id;
+ }
+
default:
logger->missingFunctionality("unknown operation with no arguments");
return 0;
diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp
index 3e68345..f1f042d 100644
--- a/SPIRV/doc.cpp
+++ b/SPIRV/doc.cpp
@@ -1367,6 +1367,8 @@
case OpCooperativeMatrixStoreNV: return "OpCooperativeMatrixStoreNV";
case OpCooperativeMatrixMulAddNV: return "OpCooperativeMatrixMulAddNV";
case OpCooperativeMatrixLengthNV: return "OpCooperativeMatrixLengthNV";
+ case OpDemoteToHelperInvocationEXT: return "OpDemoteToHelperInvocationEXT";
+ case OpIsHelperInvocationEXT: return "OpIsHelperInvocationEXT";
case OpBeginInvocationInterlockEXT: return "OpBeginInvocationInterlockEXT";
case OpEndInvocationInterlockEXT: return "OpEndInvocationInterlockEXT";
@@ -2784,6 +2786,8 @@
InstructionDesc[OpCooperativeMatrixMulAddNV].operands.push(OperandId, "'C'");
InstructionDesc[OpCooperativeMatrixLengthNV].operands.push(OperandId, "'Type'");
+
+ InstructionDesc[OpDemoteToHelperInvocationEXT].setResultAndType(false, false);
}
}; // end spv namespace
diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp
index bbaf47c..a584aaf 100644
--- a/SPIRV/spirv.hpp
+++ b/SPIRV/spirv.hpp
@@ -455,6 +455,7 @@
DecorationHlslCounterBufferGOOGLE = 5634,
DecorationHlslSemanticGOOGLE = 5635,
DecorationUserSemantic = 5635,
+ DecorationUserTypeGOOGLE = 5636,
DecorationMax = 0x7fffffff,
};
@@ -632,7 +633,7 @@
MemorySemanticsOutputMemoryKHRShift = 12,
MemorySemanticsMakeAvailableKHRShift = 13,
MemorySemanticsMakeVisibleKHRShift = 14,
- MemorySemanticsVolatileShift = 15,
+ MemorySemanticsVolatileShift = 15,
MemorySemanticsMax = 0x7fffffff,
};
@@ -650,8 +651,8 @@
MemorySemanticsImageMemoryMask = 0x00000800,
MemorySemanticsOutputMemoryKHRMask = 0x00001000,
MemorySemanticsMakeAvailableKHRMask = 0x00002000,
- MemorySemanticsMakeVisibleKHRMask = 0x00004000,
- MemorySemanticsVolatileMask = 0x00008000,
+ MemorySemanticsMakeVisibleKHRMask = 0x00004000,
+ MemorySemanticsVolatileMask = 0x00008000,
};
enum MemoryAccessShift {
@@ -845,6 +846,7 @@
CapabilityFragmentShaderShadingRateInterlockEXT = 5372,
CapabilityShaderSMBuiltinsNV = 5373,
CapabilityFragmentShaderPixelInterlockEXT = 5378,
+ CapabilityDemoteToHelperInvocationEXT = 5379,
CapabilitySubgroupShuffleINTEL = 5568,
CapabilitySubgroupBufferBlockIOINTEL = 5569,
CapabilitySubgroupImageBlockIOINTEL = 5570,
@@ -1233,6 +1235,8 @@
OpCooperativeMatrixLengthNV = 5362,
OpBeginInvocationInterlockEXT = 5364,
OpEndInvocationInterlockEXT = 5365,
+ OpDemoteToHelperInvocationEXT = 5380,
+ OpIsHelperInvocationEXT = 5381,
OpSubgroupShuffleINTEL = 5571,
OpSubgroupShuffleDownINTEL = 5572,
OpSubgroupShuffleUpINTEL = 5573,
@@ -1907,6 +1911,8 @@
case OpSubgroupAvcSicGetInterRawSadsINTEL: *hasResult = true; *hasResultType = true; break;
case OpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break;
case OpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break;
+ case OpDemoteToHelperInvocationEXT: *hasResult = false; *hasResultType = false; break;
+ case OpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break;
}
}
#endif /* SPV_ENABLE_UTILITY_CODE */