aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGeorge Kyriazis <[email protected]>2018-05-01 16:33:19 -0500
committerGeorge Kyriazis <[email protected]>2018-05-11 11:25:47 -0500
commit8238c791dcd244c5d242b0e61cbc744ed64e5e23 (patch)
tree18403f2e5b9b29288549a8a0ab45166ceefff541 /src
parent8cb55dae2e796445635303f03a0e1e6c01a767d5 (diff)
swr/rast: Add Builder::GetVectorType()
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/swr/rasterizer/jitter/builder.cpp44
-rw-r--r--src/gallium/drivers/swr/rasterizer/jitter/builder.h1
2 files changed, 45 insertions, 0 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp
index 32487353f86..e1c5d80c806 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp
@@ -170,4 +170,48 @@ namespace SwrJit
return (pGenIntrin->getMetadata("is_evaluate") != nullptr);
}
+ //////////////////////////////////////////////////////////////////////////
+ /// @brief Packetizes the type. Assumes SOA conversion.
+ Type* Builder::GetVectorType(Type* pType)
+ {
+ if (pType->isVectorTy())
+ {
+ return pType;
+ }
+
+ // [N x float] should packetize to [N x <8 x float>]
+ if (pType->isArrayTy())
+ {
+ uint32_t arraySize = pType->getArrayNumElements();
+ Type* pArrayType = pType->getArrayElementType();
+ Type* pVecArrayType = GetVectorType(pArrayType);
+ Type* pVecType = ArrayType::get(pVecArrayType, arraySize);
+ return pVecType;
+ }
+
+ // {float,int} should packetize to {<8 x float>, <8 x int>}
+ if (pType->isAggregateType())
+ {
+ uint32_t numElems = pType->getStructNumElements();
+ SmallVector<Type*, 8> vecTypes;
+ for (uint32_t i = 0; i < numElems; ++i)
+ {
+ Type* pElemType = pType->getStructElementType(i);
+ Type* pVecElemType = GetVectorType(pElemType);
+ vecTypes.push_back(pVecElemType);
+ }
+ Type* pVecType = StructType::get(JM()->mContext, vecTypes);
+ return pVecType;
+ }
+
+ // [N x float]* should packetize to [N x <8 x float>]*
+ if (pType->isPointerTy() && pType->getPointerElementType()->isArrayTy())
+ {
+ return PointerType::get(GetVectorType(pType->getPointerElementType()), pType->getPointerAddressSpace());
+ }
+
+ // <ty> should packetize to <8 x <ty>>
+ Type* vecType = VectorType::get(pType, JM()->mVWidth);
+ return vecType;
+ }
}
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder.h b/src/gallium/drivers/swr/rasterizer/jitter/builder.h
index 82c5f8cde2a..6ca128d38f1 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder.h
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder.h
@@ -123,6 +123,7 @@ namespace SwrJit
bool IsTempAlloca(Value* inst);
bool SetTexelMaskEvaluate(Instruction* inst);
bool IsTexelMaskEvaluate(Instruction* inst);
+ Type* GetVectorType(Type* pType);
#include "gen_builder.hpp"
#include "gen_builder_meta.hpp"