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

@@ -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))