From d9a450121ea22be5c534c1ced16b86ca79f93764 Mon Sep 17 00:00:00 2001 From: GregF Date: Thu, 3 Aug 2017 17:27:02 -0600 Subject: [PATCH] Mem2Reg: Allow Image and Sampler types as base target types. --- source/opt/mem_pass.cpp | 12 ++++++++---- source/opt/mem_pass.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) 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. -- 2.7.4