Commit 86e60813 by Rex Xu

Generate correct image operand mask for Offset and ConstOffset(#77)

parent 820a22fc
...@@ -1188,6 +1188,9 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1188,6 +1188,9 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
xplicit = true; xplicit = true;
} }
if (parameters.offset) { if (parameters.offset) {
if (isConstant(parameters.offset))
mask = (ImageOperandsMask)(mask | ImageOperandsConstOffsetMask);
else
mask = (ImageOperandsMask)(mask | ImageOperandsOffsetMask); mask = (ImageOperandsMask)(mask | ImageOperandsOffsetMask);
texArgs[numArgs++] = parameters.offset; texArgs[numArgs++] = parameters.offset;
} }
......
...@@ -136,6 +136,11 @@ public: ...@@ -136,6 +136,11 @@ public:
bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; } bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
bool isSampledImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampledImage; } bool isSampledImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampledImage; }
bool isConstant(Id resultId) const
{
Op opCode = getOpCode(resultId);
return opCode == OpConstantTrue || opCode == OpConstantFalse || opCode == OpConstant || opCode == OpConstantComposite || opCode == OpConstantNull;
}
bool isConstantScalar(Id resultId) const { return getOpCode(resultId) == OpConstant; } bool isConstantScalar(Id resultId) const { return getOpCode(resultId) == OpConstant; }
unsigned int getConstantScalar(Id resultId) const { return module.getInstruction(resultId)->getImmediateOperand(0); } unsigned int getConstantScalar(Id resultId) const { return module.getInstruction(resultId)->getImmediateOperand(0); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment