[Mesa-dev] [PATCH 10/21] swr/rast: WIP Translation handling
George Kyriazis
george.kyriazis at intel.com
Wed Apr 25 19:21:49 UTC 2018
---
.../swr/rasterizer/jitter/builder_gfx_mem.cpp | 41 +++++++++++++---------
.../swr/rasterizer/jitter/builder_gfx_mem.h | 3 +-
2 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.cpp
index 6ecd969..9b70716 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.cpp
@@ -160,14 +160,6 @@ namespace SwrJit
return Builder::LOAD(Ptr, Name);
}
- LoadInst* BuilderGfxMem::LOAD(Type *Ty, Value *Ptr, const Twine &Name, JIT_MEM_CLIENT usage)
- {
- AssertGFXMemoryParams(Ptr, usage);
-
- Ptr = TranslationHelper(Ptr, Ty);
- return Builder::LOAD(Ty, Ptr, Name);
- }
-
LoadInst* BuilderGfxMem::LOAD(Value *Ptr, bool isVolatile, const Twine &Name, Type *Ty, JIT_MEM_CLIENT usage)
{
AssertGFXMemoryParams(Ptr, usage);
@@ -180,12 +172,25 @@ namespace SwrJit
{
AssertGFXMemoryParams(BasePtr, usage);
- // This call is just a pass through to the base class.
- // It needs to be here to compile due to the combination of virtual overrides and signature overloads.
- // It doesn't do anything meaningful because the implementation in the base class is going to call
- // another version of LOAD inside itself where the actual per offset translation will take place
- // and we can't just translate the BasePtr once, each address needs individual translation.
- return Builder::LOAD(BasePtr, offset, name, Ty, usage);
+ bool bNeedTranslation = false;
+ if (BasePtr->getType() == mInt64Ty)
+ {
+ SWR_ASSERT(Ty);
+ BasePtr = INT_TO_PTR(BasePtr, Ty, name);
+ bNeedTranslation = true;
+ }
+ std::vector<Value*> valIndices;
+ for (auto i : offset)
+ {
+ valIndices.push_back(C(i));
+ }
+ BasePtr = Builder::GEPA(BasePtr, valIndices, name);
+ if (bNeedTranslation)
+ {
+ BasePtr = PTR_TO_INT(BasePtr, mInt64Ty, name);
+ }
+
+ return LOAD(BasePtr, name, Ty, usage);
}
CallInst* BuilderGfxMem::MASKED_LOAD(Value *Ptr, unsigned Align, Value *Mask, Value *PassThru, const Twine &Name, Type *Ty, JIT_MEM_CLIENT usage)
@@ -196,8 +201,12 @@ namespace SwrJit
return Builder::MASKED_LOAD(Ptr, Align, Mask, PassThru, Name, Ty, usage);
}
- Value* BuilderGfxMem::TranslateGfxAddress(Value* xpGfxAddress)
+ Value* BuilderGfxMem::TranslateGfxAddress(Value* xpGfxAddress, Type* PtrTy, const Twine &Name)
{
- return INT_TO_PTR(xpGfxAddress, PointerType::get(mInt8Ty, 0));
+ if (PtrTy == nullptr)
+ {
+ PtrTy = mInt8PtrTy;
+ }
+ return INT_TO_PTR(xpGfxAddress, PtrTy, Name);
}
}
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.h b/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.h
index f8ec0ac..effbe05 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.h
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_gfx_mem.h
@@ -48,7 +48,6 @@ namespace SwrJit
virtual LoadInst* LOAD(Value *Ptr, const char *Name, Type *Ty = nullptr, JIT_MEM_CLIENT usage = MEM_CLIENT_INTERNAL);
virtual LoadInst* LOAD(Value *Ptr, const Twine &Name = "", Type *Ty = nullptr, JIT_MEM_CLIENT usage = MEM_CLIENT_INTERNAL);
- virtual LoadInst* LOAD(Type *Ty, Value *Ptr, const Twine &Name = "", JIT_MEM_CLIENT usage = MEM_CLIENT_INTERNAL);
virtual LoadInst* LOAD(Value *Ptr, bool isVolatile, const Twine &Name = "", Type *Ty = nullptr, JIT_MEM_CLIENT usage = MEM_CLIENT_INTERNAL);
virtual LoadInst* LOAD(Value *BasePtr, const std::initializer_list<uint32_t> &offset, const llvm::Twine& Name = "", Type *Ty = nullptr, JIT_MEM_CLIENT usage = MEM_CLIENT_INTERNAL);
@@ -58,7 +57,7 @@ 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);
+ Value* TranslateGfxAddress(Value* xpGfxAddress, Type* PtrTy = nullptr, const Twine &Name = "");
protected:
--
2.7.4
More information about the mesa-dev
mailing list