GenRegister msgPayloads[4];
GenRegister dst[insn.getDstNum()], src[insn.getSrcNum()];
uint32_t srcNum = insn.getSrcNum();
- uint32_t samplerOffset = 0;
- if (srcNum == 4) {
- /* We have the clamp border workaround. */
- samplerOffset = insn.getSrc(srcNum - 1).value() * 8;
- srcNum--;
- }
for( int i = 0; i < 4; ++i)
msgPayloads[i] = sel.selReg(sel.reg(FAMILY_DWORD), TYPE_U32);
src[valueID] = sel.selReg(insn.getSrc(valueID), insn.getSrcType());
uint32_t bti = insn.getImageIndex();
- uint32_t sampler = insn.getSamplerIndex() + samplerOffset;
+ /* We have the clamp border workaround. */
+ uint32_t sampler = insn.getSamplerIndex() + insn.getSamplerOffset() * 8;
sel.SAMPLE(dst, insn.getDstNum(), src, srcNum, msgPayloads, 4, bti, sampler);
return true;
public TupleDstPolicy<SampleInstruction>
{
public:
- SampleInstruction(uint8_t imageIdx, Tuple dstTuple, Tuple srcTuple, bool dstIsFloat, bool srcIsFloat, uint8_t sampler) {
+ SampleInstruction(uint8_t imageIdx, Tuple dstTuple, Tuple srcTuple, bool dstIsFloat, bool srcIsFloat, uint8_t sampler, uint8_t samplerOffset) {
this->opcode = OP_SAMPLE;
this->dst = dstTuple;
this->src = srcTuple;
this->srcIsFloat = srcIsFloat;
this->samplerIdx = sampler;
this->imageIdx = imageIdx;
+ this->samplerOffset = samplerOffset;
}
INLINE bool wellFormed(const Function &fn, std::string &why) const;
INLINE void out(std::ostream &out, const Function &fn) const {
INLINE Type getSrcType(void) const { return this->srcIsFloat ? TYPE_FLOAT : TYPE_S32; }
INLINE Type getDstType(void) const { return this->dstIsFloat ? TYPE_FLOAT : TYPE_U32; }
INLINE const uint8_t getSamplerIndex(void) const { return this->samplerIdx; }
-
- uint16_t srcIsFloat:1;
- uint16_t dstIsFloat:1;
- uint16_t samplerIdx:4;
- uint16_t imageIdx:8;
+ INLINE const uint8_t getSamplerOffset(void) const { return this->samplerOffset; }
+ uint8_t srcIsFloat:1;
+ uint8_t dstIsFloat:1;
+ uint8_t samplerIdx:4;
+ uint8_t samplerOffset:2;
+ uint8_t imageIdx;
static const uint32_t srcNum = 4;
static const uint32_t dstNum = 4;
};
DECL_MEM_FN(SampleInstruction, Type, getSrcType(void), getSrcType())
DECL_MEM_FN(SampleInstruction, Type, getDstType(void), getDstType())
DECL_MEM_FN(SampleInstruction, const uint8_t, getSamplerIndex(void), getSamplerIndex())
+DECL_MEM_FN(SampleInstruction, const uint8_t, getSamplerOffset(void), getSamplerOffset())
DECL_MEM_FN(SampleInstruction, const uint8_t, getImageIndex(void), getImageIndex())
DECL_MEM_FN(TypedWriteInstruction, Type, getSrcType(void), getSrcType())
DECL_MEM_FN(TypedWriteInstruction, Type, getCoordType(void), getCoordType())
}
// SAMPLE
- Instruction SAMPLE(uint8_t imageIndex, Tuple dst, Tuple src, bool dstIsFloat, bool srcIsFloat, uint8_t sampler) {
- return internal::SampleInstruction(imageIndex, dst, src, dstIsFloat, srcIsFloat, sampler).convert();
+ Instruction SAMPLE(uint8_t imageIndex, Tuple dst, Tuple src, bool dstIsFloat, bool srcIsFloat, uint8_t sampler, uint8_t samplerOffset) {
+ return internal::SampleInstruction(imageIndex, dst, src, dstIsFloat, srcIsFloat, sampler, samplerOffset).convert();
}
Instruction TYPED_WRITE(uint8_t imageIndex, Tuple src, Type srcType, Type coordType) {
const uint8_t getImageIndex() const;
const uint8_t getSamplerIndex(void) const;
+ const uint8_t getSamplerOffset(void) const;
Type getSrcType(void) const;
Type getDstType(void) const;
/*! Return true if the given instruction is an instance of this class */
/*! typed write */
Instruction TYPED_WRITE(uint8_t imageIndex, Tuple src, Type srcType, Type coordType);
/*! sample textures */
- Instruction SAMPLE(uint8_t imageIndex, Tuple dst, Tuple src, bool dstIsFloat, bool srcIsFloat, uint8_t sampler);
+ Instruction SAMPLE(uint8_t imageIndex, Tuple dst, Tuple src, bool dstIsFloat, bool srcIsFloat, uint8_t sampler, uint8_t samplerOffset);
/*! get image information , such as width/height/depth/... */
Instruction GET_IMAGE_INFO(int infoType, Register dst, uint8_t imageIndex, Register infoReg);
/*! get sampler information */
srcTupleData.push_back(ucoord);
srcTupleData.push_back(vcoord);
srcTupleData.push_back(wcoord);
+ uint8_t samplerOffset = 0;
#ifdef GEN7_SAMPLER_CLAMP_BORDER_WORKAROUND
GBE_ASSERT(AI != AE); Constant *CPV = dyn_cast<Constant>(*AI);
assert(CPV);
auto x = processConstant<ir::Immediate>(CPV, InsertExtractFunctor(ctx));
GBE_ASSERTM(x.type == ir::TYPE_U32 || x.type == ir::TYPE_S32, "Invalid sampler type");
- ir::Register offsetReg(x.data.u32);
- srcTupleData.push_back(offsetReg);
-#else
- ir::Register offsetReg(0);
+ samplerOffset = x.data.u32;
#endif
- srcTupleData.push_back(offsetReg);
const ir::Tuple dstTuple = ctx.arrayTuple(&dstTupleData[0], elemNum);
- const ir::Tuple srcTuple = ctx.arrayTuple(&srcTupleData[0], 4);
+ const ir::Tuple srcTuple = ctx.arrayTuple(&srcTupleData[0], 3);
ir::Type srcType = ir::TYPE_S32, dstType = ir::TYPE_U32;
GBE_ASSERT(0); // never been here.
}
- ctx.SAMPLE(surfaceID, dstTuple, srcTuple, dstType == ir::TYPE_FLOAT, srcType == ir::TYPE_FLOAT, sampler);
+ ctx.SAMPLE(surfaceID, dstTuple, srcTuple, dstType == ir::TYPE_FLOAT,
+ srcType == ir::TYPE_FLOAT, sampler, samplerOffset);
break;
}
case GEN_OCL_WRITE_IMAGE0: