Merge branch 'feature2' of https://github.com/amdrexu/glslang into amdrexu-feature2

This commit is contained in:
John Kessenich
2016-05-05 16:32:39 -06:00
10 changed files with 155 additions and 2 deletions

View File

@@ -3252,6 +3252,18 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
libCall = spv::GLSLstd450Bad;
break;
case glslang::EOpAnyInvocation:
builder.addCapability(spv::CapabilityGroups);
unaryOp = spv::OpGroupAny;
break;
case glslang::EOpAllInvocations:
builder.addCapability(spv::CapabilityGroups);
unaryOp = spv::OpGroupAll;
break;
case glslang::EOpAllInvocationsEqual:
builder.addCapability(spv::CapabilityGroups);
break;
default:
return 0;
}
@@ -3261,8 +3273,27 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
std::vector<spv::Id> args;
args.push_back(operand);
id = builder.createBuiltinCall(typeId, stdBuiltins, libCall, args);
} else
id = builder.createUnaryOp(unaryOp, typeId, operand);
} else {
if (op == glslang::EOpAnyInvocation || op == glslang::EOpAllInvocations || op == glslang::EOpAllInvocationsEqual) {
std::vector<spv::Id> operands;
operands.push_back(builder.makeUintConstant(spv::ScopeSubgroup));
operands.push_back(operand);
if (op == glslang::EOpAnyInvocation || op == glslang::EOpAllInvocations)
id = builder.createOp(unaryOp, typeId, operands);
else if (op == glslang::EOpAllInvocationsEqual) {
spv::Id groupAll = builder.createOp(spv::OpGroupAll, typeId, operands);
spv::Id groupAny = builder.createOp(spv::OpGroupAny, typeId, operands);
id = builder.createBinOp(spv::OpLogicalOr,
typeId,
groupAll,
builder.createUnaryOp(spv::OpLogicalNot, typeId, groupAny));
}
}
else
id = builder.createUnaryOp(unaryOp, typeId, operand);
}
return builder.setPrecision(id, precision);
}