[Mesa-dev] [PATCH 22/31] swr/rast: Be more explicit when fetching next component

George Kyriazis george.kyriazis at intel.com
Tue Feb 13 22:42:40 UTC 2018


Use a new function to denote that we want to get offset to next component
and hide the fact that GEP is used underneath.
---
 src/gallium/drivers/swr/rasterizer/jitter/builder_mem.cpp | 13 +++++++++----
 src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h   |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.cpp
index a8c2f2c..491fb98 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.cpp
@@ -129,6 +129,11 @@ namespace SwrJit
         return vResult;
     }
 
+    Value* Builder::OFFSET_TO_NEXT_COMPONENT(Value* base, Constant *offset)
+    {
+        return GEP(base, offset);
+    }
+
     //////////////////////////////////////////////////////////////////////////
     /// @brief Generate a masked gather operation in LLVM IR.  If not  
     /// supported on the underlying platform, emulate it with loads
@@ -396,7 +401,7 @@ namespace SwrJit
             if (info.numComps > 2)
             {
                 // offset base to the next components(zw) in the vertex to gather
-                pSrcBase = GEP(pSrcBase, C((char)4));
+                pSrcBase = OFFSET_TO_NEXT_COMPONENT(pSrcBase, C((char)4));
 
                 vGatherResult[1] = GATHERPS(vGatherMaskedVal, pSrcBase, byteOffsets, vMask);
                 // e.g. result of second 8x32bit integer gather for 16bit components
@@ -429,7 +434,7 @@ namespace SwrJit
                 vGatherComponents[swizzleIndex] = GATHERPS(vGatherComponents[swizzleIndex], pSrcBase, byteOffsets, vMask);
 
                 // offset base to the next component to gather
-                pSrcBase = GEP(pSrcBase, C((char)4));
+                pSrcBase = OFFSET_TO_NEXT_COMPONENT(pSrcBase, C((char)4));
             }
         }
         break;
@@ -474,7 +479,7 @@ namespace SwrJit
             if (info.numComps > 2)
             {
                 // offset base to the next components(zw) in the vertex to gather
-                pSrcBase = GEP(pSrcBase, C((char)4));
+                pSrcBase = OFFSET_TO_NEXT_COMPONENT(pSrcBase, C((char)4));
 
                 vGatherResult[1] = GATHERDD(vGatherMaskedVal, pSrcBase, byteOffsets, vMask);
                 // e.g. result of second 8x32bit integer gather for 16bit components
@@ -508,7 +513,7 @@ namespace SwrJit
                 vGatherComponents[swizzleIndex] = GATHERDD(vGatherComponents[swizzleIndex], pSrcBase, byteOffsets, vMask);
 
                 // offset base to the next component to gather
-                pSrcBase = GEP(pSrcBase, C((char)4));
+                pSrcBase = OFFSET_TO_NEXT_COMPONENT(pSrcBase, C((char)4));
             }
         }
         break;
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h b/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h
index f31cb4a..4e78098 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h
@@ -44,6 +44,8 @@ Value *MASKLOADD(Value* src, Value* mask);
 void Gather4(const SWR_FORMAT format, Value* pSrcBase, Value* byteOffsets,
     Value* mask, Value* vGatherComponents[], bool bPackedOutput);
 
+virtual Value* OFFSET_TO_NEXT_COMPONENT(Value* base, Constant *offset);
+
 virtual Value *GATHERPS(Value *src, Value *pBase, Value *indices, Value *mask, uint8_t scale = 1);
 Value *GATHERPS_16(Value *src, Value *pBase, Value *indices, Value *mask, uint8_t scale = 1);
 
-- 
2.7.4



More information about the mesa-dev mailing list