fix format; remove unnecessary parameters; rename some spec op mode guard class; remove support of float point comparison and composite type comparison; update the tests.

This commit is contained in:
qining
2016-03-31 13:57:28 -04:00
parent 135452061a
commit 5c61d8e0f9
4 changed files with 63 additions and 258 deletions

View File

@@ -3855,21 +3855,19 @@ spv::Id TGlslangToSpvTraverser::createSpvConstantFromConstUnionArray(const glsla
}
namespace {
class SpecConstOpCodeGenerationSettingGuard{
public:
SpecConstOpCodeGenerationSettingGuard(spv::Builder* builder,
bool shouldGeneratingForSpecConst)
class SpecConstantOpModeGuard {
public:
SpecConstantOpModeGuard(spv::Builder* builder)
: builder_(builder) {
previous_flag_ = builder->isInSpecConstCodeGenMode();
shouldGeneratingForSpecConst ? builder->setToSpecConstCodeGenMode()
: builder->setToNormalCodeGenMode();
builder->setToSpecConstCodeGenMode();
}
~SpecConstOpCodeGenerationSettingGuard() {
~SpecConstantOpModeGuard() {
previous_flag_ ? builder_->setToSpecConstCodeGenMode()
: builder_->setToNormalCodeGenMode();
}
private:
private:
spv::Builder* builder_;
bool previous_flag_;
};
@@ -3877,7 +3875,8 @@ class SpecConstOpCodeGenerationSettingGuard{
// Create constant ID from const initializer sub tree.
spv::Id TGlslangToSpvTraverser::createSpvConstantFromConstSubTree(
glslang::TIntermTyped* subTree) {
glslang::TIntermTyped* subTree)
{
const glslang::TType& glslangType = subTree->getType();
spv::Id typeId = convertGlslangToSpvType(glslangType);
bool is_spec_const = subTree->getType().getQualifier().isSpecConstant();
@@ -3909,7 +3908,7 @@ spv::Id TGlslangToSpvTraverser::createSpvConstantFromConstSubTree(
// Spec constants defined with binary operations and other constants requires
// OpSpecConstantOp instruction.
SpecConstOpCodeGenerationSettingGuard set_to_spec_const_mode(&builder, true);
SpecConstantOpModeGuard set_to_spec_const_mode(&builder);
bn->traverse(this);
return accessChainLoad(bn->getType());
@@ -3920,7 +3919,7 @@ spv::Id TGlslangToSpvTraverser::createSpvConstantFromConstSubTree(
// Spec constants defined with unary operations and other constants requires
// OpSpecConstantOp instruction.
SpecConstOpCodeGenerationSettingGuard set_to_spec_const_mode(&builder, true);
SpecConstantOpModeGuard set_to_spec_const_mode(&builder);
un->traverse(this);
return accessChainLoad(un->getType());

View File

@@ -1229,90 +1229,8 @@ Id Builder::createOp(Op opCode, Id typeId, const std::vector<Id>& operands)
return op->getResultId();
}
Id Builder::createSpecConstantOp(Op opCode, Id typeId, const std::vector<Id>& operands, const std::vector<unsigned>& literals) {
switch(opCode) {
// OpCodes that do not need any capababilities.
case OpSConvert:
case OpFConvert:
case OpSNegate:
case OpNot:
case OpIAdd:
case OpISub:
case OpIMul:
case OpUDiv:
case OpSDiv:
case OpUMod:
case OpSRem:
case OpSMod:
case OpShiftRightLogical:
case OpShiftRightArithmetic:
case OpShiftLeftLogical:
case OpBitwiseOr:
case OpBitwiseXor:
case OpBitwiseAnd:
case OpVectorShuffle:
case OpCompositeExtract:
case OpCompositeInsert:
case OpLogicalOr:
case OpLogicalAnd:
case OpLogicalNot:
case OpLogicalEqual:
case OpLogicalNotEqual:
case OpSelect:
case OpIEqual:
case OpULessThan:
case OpSLessThan:
case OpUGreaterThan:
case OpSGreaterThan:
case OpULessThanEqual:
case OpSLessThanEqual:
case OpUGreaterThanEqual:
case OpSGreaterThanEqual:
// Added temporarily to enable compsite type spec constants comparison.
// Remove this comment after Spec being updated.
case OpAll:
case OpAny:
case OpFOrdEqual:
case OpFUnordEqual:
case OpFOrdNotEqual:
case OpFUnordNotEqual:
break;
// OpCodes that need Shader capability.
case OpQuantizeToF16:
addCapability(CapabilityShader);
break;
// OpCodes that need Kernel capability.
case OpConvertFToS:
case OpConvertSToF:
case OpConvertFToU:
case OpConvertUToF:
case OpUConvert:
case OpConvertPtrToU:
case OpConvertUToPtr:
case OpGenericCastToPtr:
case OpPtrCastToGeneric:
case OpBitcast:
case OpFNegate:
case OpFAdd:
case OpFSub:
case OpFMul:
case OpFDiv:
case OpFRem:
case OpFMod:
case OpAccessChain:
case OpInBoundsAccessChain:
case OpPtrAccessChain:
case OpInBoundsPtrAccessChain:
addCapability(CapabilityKernel);
break;
default:
// Invalid OpCode for Spec Constant operations.
return NoResult;
}
Id Builder::createSpecConstantOp(Op opCode, Id typeId, const std::vector<Id>& operands, const std::vector<unsigned>& literals)
{
Instruction* op = new Instruction(getUniqueId(), typeId, OpSpecConstantOp);
op->addImmediateOperand((unsigned) opCode);
for (auto it = operands.cbegin(); it != operands.cend(); ++it)