summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2014-09-04 08:01:25 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-09-04 11:53:04 +0800
commit9ce75d4de41e8359f411ce5ab3dbd2cd363364b2 (patch)
tree96e63bf32d8826d6de3402373fccdb7674399ea8 /backend
parent56d2cf2e02b6933478f080548f6960751ff18741 (diff)
GBE: fixup/refine a bug for image1D array's extra binding index handling.
Due to hardware limitation on Gen7/Gen75 when sampling a surface with clamp address mode and nearest filter mode on a integer image1Darray type surface, we have to bind one buffer to to bti. The previous implementation hard coded it to 128 + original index and when check whether it is such type bti in driver layer, assume the bti reserved is 3 which is wrong now. This patch fixed those hard coded functions and use the macros defined in the program.h. Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
Diffstat (limited to 'backend')
-rw-r--r--backend/src/backend/gen_insn_selection.cpp2
-rw-r--r--backend/src/backend/program.h2
-rw-r--r--backend/src/llvm/llvm_gen_backend.cpp13
3 files changed, 12 insertions, 5 deletions
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index abbff77..d631579 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -3862,7 +3862,7 @@ namespace gbe
msgLen = srcNum;
}
// We switch to a fixup bti for linear filter on a image1d array sampling.
- uint32_t bti = insn.getImageIndex() + (insn.getSamplerOffset() == 2 ? 128 : 0);
+ uint32_t bti = insn.getImageIndex() + (insn.getSamplerOffset() == 2 ? BTI_MAX_IMAGE_NUM : 0);
if (bti > 253) {
std::cerr << "Too large bti " << bti;
return false;
diff --git a/backend/src/backend/program.h b/backend/src/backend/program.h
index 254df92..c63ae6a 100644
--- a/backend/src/backend/program.h
+++ b/backend/src/backend/program.h
@@ -66,6 +66,8 @@ enum gbe_get_arg_info_value {
#define BTI_CONSTANT 0
#define BTI_PRIVATE 1
#define BTI_RESERVED_NUM 2
+#define BTI_MAX_IMAGE_NUM 128
+#define BTI_MAX_ID (BTI_MAX_IMAGE_NUM + BTI_RESERVED_NUM - 1)
/*! Constant buffer values (ie values to setup in the constant buffer) */
enum gbe_curbe_type {
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 1604ede..738f7d3 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -500,6 +500,11 @@ namespace gbe
ir::ImmediateIndex processConstantImmIndex(Constant *CPV, int32_t index = 0u);
const ir::Immediate &processConstantImm(Constant *CPV, int32_t index = 0u);
+ uint32_t incBtiBase() {
+ GBE_ASSERT(btiBase <= BTI_MAX_ID);
+ return btiBase++;
+ }
+
bool runOnFunction(Function &F) {
// Do not codegen any 'available_externally' functions at all, they have
// definitions outside the translation unit.
@@ -1363,7 +1368,7 @@ namespace gbe
globalPointer.insert(std::make_pair(I, btiBase));
ctx.appendSurface(btiBase, reg);
ctx.input(argName, ir::FunctionArgument::GLOBAL_POINTER, reg, llvmInfo, ptrSize, align, btiBase);
- btiBase++;
+ incBtiBase();
break;
case ir::MEM_LOCAL:
ctx.input(argName, ir::FunctionArgument::LOCAL_POINTER, reg, llvmInfo, ptrSize, align, 0xfe);
@@ -1374,7 +1379,7 @@ namespace gbe
break;
case ir::IMAGE:
ctx.input(argName, ir::FunctionArgument::IMAGE, reg, llvmInfo, ptrSize, align, 0x0);
- ctx.getFunction().getImageSet()->append(reg, &ctx, btiBase++);
+ ctx.getFunction().getImageSet()->append(reg, &ctx, incBtiBase());
break;
default: GBE_ASSERT(addrSpace != ir::MEM_PRIVATE);
}
@@ -1720,12 +1725,12 @@ namespace gbe
if(v.getName().equals(StringRef("__gen_ocl_printf_buf"))) {
ctx.appendSurface(btiBase, ir::ocl::printfbptr);
ctx.getFunction().getPrintfSet()->setBufBTI(btiBase);
- globalPointer.insert(std::make_pair(&v, btiBase++));
+ globalPointer.insert(std::make_pair(&v, incBtiBase()));
regTranslator.newScalarProxy(ir::ocl::printfbptr, const_cast<GlobalVariable*>(&v));
} else if(v.getName().equals(StringRef("__gen_ocl_printf_index_buf"))) {
ctx.appendSurface(btiBase, ir::ocl::printfiptr);
ctx.getFunction().getPrintfSet()->setIndexBufBTI(btiBase);
- globalPointer.insert(std::make_pair(&v, btiBase++));
+ globalPointer.insert(std::make_pair(&v, incBtiBase()));
regTranslator.newScalarProxy(ir::ocl::printfiptr, const_cast<GlobalVariable*>(&v));
} else if(v.getName().str().substr(0, 4) == ".str") {
/* When there are multi printf statements in multi kernel fucntions within the same