Commit d4a7a8e7 by John Kessenich

Merge pull request #81 from amdrexu/myfix

Generate correct image operand mask for Offset and ConstOffset(#77) and correct arg # for rect. texelFetchOffset.
parents 820a22fc 19c6e591
......@@ -1188,7 +1188,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
xplicit = true;
}
if (parameters.offset) {
mask = (ImageOperandsMask)(mask | ImageOperandsOffsetMask);
if (isConstant(parameters.offset))
mask = (ImageOperandsMask)(mask | ImageOperandsConstOffsetMask);
else
mask = (ImageOperandsMask)(mask | ImageOperandsOffsetMask);
texArgs[numArgs++] = parameters.offset;
}
// TBD: if Offset is constant, use ImageOperandsConstOffsetMask
......
......@@ -136,6 +136,11 @@ public:
bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
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; }
unsigned int getConstantScalar(Id resultId) const { return module.getInstruction(resultId)->getImmediateOperand(0); }
......
......@@ -41,6 +41,7 @@ void main()
v.y += textureOffset(s2DShadow, c3D, ivec2(3), c1D);
v += texelFetch(s3D, ic3D, ic1D);
v += texelFetchOffset(s2D, ic2D, 4, ivec2(3));
v += texelFetchOffset(sr, ic2D, ivec2(4));
v.y += textureLodOffset(s2DShadow, c3D, c1D, ivec2(3));
v += textureProjLodOffset(s2D, c3D, c1D, ivec2(3));
v += textureGrad(sCube, c3D, c3D, c3D);
......@@ -62,7 +63,6 @@ void main()
v += vec4(iv);
iv = texelFetch(is2DArray, ic3D, ic1D);
v += vec4(iv);
iv += texelFetch(is2Dms, ic2D, ic1D);
v += vec4(iv);
v += texelFetch(sb, ic1D);
......
#version 430
uniform sampler2D s2D;
uniform sampler2DRect sr;
uniform sampler3D s3D;
uniform samplerCube sCube;
uniform samplerCubeShadow sCubeShadow;
......@@ -39,6 +40,7 @@ void main()
v.y += textureOffset(s2DShadow, c3D, ivec2(3), c1D);
v += texelFetch(s3D, ic3D, ic1D);
v += texelFetchOffset(s2D, ic2D, 4, ivec2(3));
v += texelFetchOffset(sr, ic2D, ivec2(4));
v.y += textureLodOffset(s2DShadow, c3D, c1D, ivec2(3));
v += textureProjLodOffset(s2D, c3D, c1D, ivec2(3));
v += textureGrad(sCube, c3D, c3D, c3D);
......
......@@ -1431,7 +1431,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
int arg = -1;
switch (callNode.getOp()) {
case EOpTextureOffset: arg = 2; break;
case EOpTextureFetchOffset: arg = 3; break;
case EOpTextureFetchOffset: arg = (arg0->getType().getSampler().dim != EsdRect) ? 3 : 2; break;
case EOpTextureProjOffset: arg = 2; break;
case EOpTextureLodOffset: arg = 3; break;
case EOpTextureProjLodOffset: arg = 3; break;
......
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