Implement SPV_KHR_subgroup_vote

doc.cpp: Add capabilities, scope to the opcodes. Add opcode and
capability strings.
GLSL.ext.KHR.h: Add extension
string.
GlslangToSpv.cpp: Fix handling of opcodes to generate
appropriate SPIR-V.
spirv.hpp: Add capability and opcode
enums.
spv.shaderGroupVote.comp.out: Update SPIR-V output for test
shader.
This commit is contained in:
Ashwin Kolhe
2017-01-18 14:16:49 -08:00
parent 33dadd1287
commit c720f3e639
5 changed files with 50 additions and 34 deletions

View File

@@ -32,5 +32,5 @@ static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shade
// 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";
#endif // #ifndef GLSLextKHR_H

View File

@@ -4136,6 +4136,11 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
op == glslang::EOpReadInvocation) {
builder.addExtension(spv::E_SPV_KHR_shader_ballot);
builder.addCapability(spv::CapabilitySubgroupBallotKHR);
} else if (op == glslang::EOpAnyInvocation ||
op == glslang::EOpAllInvocations ||
op == glslang::EOpAllInvocationsEqual) {
builder.addExtension(spv::E_SPV_KHR_subgroup_vote);
builder.addCapability(spv::CapabilitySubgroupVoteKHR);
} else {
builder.addCapability(spv::CapabilityGroups);
#ifdef AMD_EXTENSIONS
@@ -4158,20 +4163,14 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
switch (op) {
case glslang::EOpAnyInvocation:
opCode = spv::OpGroupAny;
opCode = spv::OpSubgroupAnyKHR;
break;
case glslang::EOpAllInvocations:
opCode = spv::OpGroupAll;
opCode = spv::OpSubgroupAllKHR;
break;
case glslang::EOpAllInvocationsEqual:
{
spv::Id groupAll = builder.createOp(spv::OpGroupAll, typeId, spvGroupOperands);
spv::Id groupAny = builder.createOp(spv::OpGroupAny, typeId, spvGroupOperands);
return builder.createBinOp(spv::OpLogicalOr, typeId, groupAll,
builder.createUnaryOp(spv::OpLogicalNot, typeId, groupAny));
}
opCode = spv::OpSubgroupAllEqualKHR;
break;
case glslang::EOpReadInvocation:
opCode = spv::OpSubgroupReadInvocationKHR;
if (builder.isVectorType(typeId))

View File

@@ -819,6 +819,7 @@ const char* CapabilityString(int info)
case 4423: return "SubgroupBallotKHR";
case 4427: return "DrawParameters";
case 4431: return "SubgroupVoteKHR";
#ifdef NV_EXTENSIONS
case 5251: return "GeometryShaderPassthroughNV";
@@ -1158,6 +1159,9 @@ const char* OpcodeString(int op)
case 4421: return "OpSubgroupBallotKHR";
case 4422: return "OpSubgroupFirstInvocationKHR";
case 4428: return "OpSubgroupAnyKHR";
case 4429: return "OpSubgroupAllKHR";
case 4430: return "OpSubgroupAllEqualKHR";
case 4432: return "OpSubgroupReadInvocationKHR";
#ifdef AMD_EXTENSIONS
@@ -2771,6 +2775,18 @@ void Parameterize()
InstructionDesc[OpSubgroupFirstInvocationKHR].operands.push(OperandId, "'Value'");
InstructionDesc[OpSubgroupAnyKHR].capabilities.push_back(CapabilitySubgroupVoteKHR);
InstructionDesc[OpSubgroupAnyKHR].operands.push(OperandScope, "'Execution'");
InstructionDesc[OpSubgroupAnyKHR].operands.push(OperandId, "'Predicate'");
InstructionDesc[OpSubgroupAllKHR].capabilities.push_back(CapabilitySubgroupVoteKHR);
InstructionDesc[OpSubgroupAllKHR].operands.push(OperandScope, "'Execution'");
InstructionDesc[OpSubgroupAllKHR].operands.push(OperandId, "'Predicate'");
InstructionDesc[OpSubgroupAllEqualKHR].capabilities.push_back(CapabilitySubgroupVoteKHR);
InstructionDesc[OpSubgroupAllEqualKHR].operands.push(OperandScope, "'Execution'");
InstructionDesc[OpSubgroupAllEqualKHR].operands.push(OperandId, "'Predicate'");
InstructionDesc[OpSubgroupReadInvocationKHR].capabilities.push_back(CapabilityGroups);
InstructionDesc[OpSubgroupReadInvocationKHR].operands.push(OperandId, "'Value'");
InstructionDesc[OpSubgroupReadInvocationKHR].operands.push(OperandId, "'Index'");

View File

@@ -605,6 +605,7 @@ enum Capability {
CapabilityMultiViewport = 57,
CapabilitySubgroupBallotKHR = 4423,
CapabilityDrawParameters = 4427,
CapabilitySubgroupVoteKHR = 4431,
CapabilityMax = 0x7fffffff,
};
@@ -906,6 +907,9 @@ enum Op {
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
OpSubgroupReadInvocationKHR = 4432,
OpSubgroupAllKHR = 4428,
OpSubgroupAnyKHR = 4429,
OpSubgroupAllEqualKHR = 4430,
OpMax = 0x7fffffff,
};