swr/rast: Add TranslateGfxAddress for shader
authorGeorge Kyriazis <george.kyriazis@intel.com>
Mon, 23 Apr 2018 23:00:10 +0000 (18:00 -0500)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 27 Apr 2018 19:36:41 +0000 (14:36 -0500)
Also add GFX_MEM_CLIENT_SHADER

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.cpp
src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.h
src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h

index 9b707162b3f2bbc2e7bff055fed3a862f3c8713d..03e34db31819c787a7ce34edc34463c9e8bc04cc 100644 (file)
@@ -201,7 +201,7 @@ namespace SwrJit
         return Builder::MASKED_LOAD(Ptr, Align, Mask, PassThru, Name, Ty, usage);
     }
 
-    Value* BuilderGfxMem::TranslateGfxAddress(Value* xpGfxAddress, Type* PtrTy, const Twine &Name)
+    Value* BuilderGfxMem::TranslateGfxAddress(Value* xpGfxAddress, Type* PtrTy, const Twine &Name, JIT_MEM_CLIENT /* usage */)
     {
         if (PtrTy == nullptr)
         {
index effbe05da139c02c18f491d6a0329a58d7e14a6d..d1a25c42acc6e95fb8c62c1ff1ed91c513b04eae 100644 (file)
@@ -57,7 +57,22 @@ namespace SwrJit
 
         virtual Value *GATHERDD(Value* src, Value* pBase, Value* indices, Value* mask, uint8_t scale = 1, JIT_MEM_CLIENT usage = MEM_CLIENT_INTERNAL);
 
-        Value* TranslateGfxAddress(Value* xpGfxAddress, Type* PtrTy = nullptr, const Twine &Name = "");
+        Value* TranslateGfxAddress(Value* xpGfxAddress, Type* PtrTy = nullptr, const Twine &Name = "", JIT_MEM_CLIENT usage = MEM_CLIENT_INTERNAL);
+        template <typename T>
+        Value* TranslateGfxAddress(Value* xpGfxBaseAddress, const std::initializer_list<T> &offset, Type* PtrTy = nullptr, const Twine &Name = "", JIT_MEM_CLIENT usage = GFX_MEM_CLIENT_SHADER)
+        {
+            AssertGFXMemoryParams(xpGfxBaseAddress, usage);
+            SWR_ASSERT(xpGfxBaseAddress->getType()->isPointerTy() == false);
+
+            if (!PtrTy)
+            {
+                PtrTy = mInt8PtrTy;
+            }
+
+            Value* ptr = INT_TO_PTR(xpGfxBaseAddress, PtrTy);
+            ptr = GEP(ptr, offset);
+            return TranslateGfxAddress(PTR_TO_INT(ptr, mInt64Ty), PtrTy, Name, usage);
+        }
 
 
     protected:
index 9ccac4f80024ca3224f33704271eb05e30c1f853..3823a136bb8642c09b44c3db8a42fee41bff9b6b 100644 (file)
@@ -35,7 +35,8 @@ typedef enum _JIT_MEM_CLIENT
 {
     MEM_CLIENT_INTERNAL,
     GFX_MEM_CLIENT_FETCH,
-    GFX_MEM_CLIENT_SAMPLER
+    GFX_MEM_CLIENT_SAMPLER,
+    GFX_MEM_CLIENT_SHADER,
 } JIT_MEM_CLIENT;
 
 protected: