From: GregF Date: Thu, 3 Aug 2017 23:27:02 +0000 (-0600) Subject: Mem2Reg: Allow Image and Sampler types as base target types. X-Git-Tag: upstream/2018.6~836 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d9a450121ea22be5c534c1ced16b86ca79f93764;p=platform%2Fupstream%2FSPIRV-Tools.git Mem2Reg: Allow Image and Sampler types as base target types. --- diff --git a/source/opt/mem_pass.cpp b/source/opt/mem_pass.cpp index fb97a04..9ca91f2 100644 --- a/source/opt/mem_pass.cpp +++ b/source/opt/mem_pass.cpp @@ -33,7 +33,7 @@ const uint32_t kTypePointerTypeIdInIdx = 1; } // namespace anonymous -bool MemPass::IsMathType( +bool MemPass::IsBaseTargetType( const ir::Instruction* typeInst) const { switch (typeInst->opcode()) { case SpvOpTypeInt: @@ -41,6 +41,9 @@ bool MemPass::IsMathType( case SpvOpTypeBool: case SpvOpTypeVector: case SpvOpTypeMatrix: + case SpvOpTypeImage: + case SpvOpTypeSampler: + case SpvOpTypeSampledImage: return true; default: break; @@ -50,17 +53,18 @@ bool MemPass::IsMathType( bool MemPass::IsTargetType( const ir::Instruction* typeInst) const { - if (IsMathType(typeInst)) + if (IsBaseTargetType(typeInst)) return true; if (typeInst->opcode() == SpvOpTypeArray) - return IsMathType(def_use_mgr_->GetDef(typeInst->GetSingleWordOperand(1))); + return IsBaseTargetType( + def_use_mgr_->GetDef(typeInst->GetSingleWordOperand(1))); if (typeInst->opcode() != SpvOpTypeStruct) return false; // All struct members must be math type int nonMathComp = 0; typeInst->ForEachInId([&nonMathComp,this](const uint32_t* tid) { ir::Instruction* compTypeInst = def_use_mgr_->GetDef(*tid); - if (!IsMathType(compTypeInst)) ++nonMathComp; + if (!IsBaseTargetType(compTypeInst)) ++nonMathComp; }); return nonMathComp == 0; } diff --git a/source/opt/mem_pass.h b/source/opt/mem_pass.h index f670289..4f28cc8 100644 --- a/source/opt/mem_pass.h +++ b/source/opt/mem_pass.h @@ -43,7 +43,7 @@ class MemPass : public Pass { protected: // Returns true if |typeInst| is a scalar type // or a vector or matrix - bool IsMathType(const ir::Instruction* typeInst) const; + bool IsBaseTargetType(const ir::Instruction* typeInst) const; // Returns true if |typeInst| is a math type or a struct or array // of a math type.