Commit 68f1431a by John Kessenich

Merge pull request #121 from amdrexu/feature

Parser & SPV: Implement two extensions regarding GLSL sparse texture.
parents 863aa667 48edadfd
...@@ -1884,6 +1884,14 @@ void TGlslangToSpvTraverser::handleFunctionEntry(const glslang::TIntermAggregate ...@@ -1884,6 +1884,14 @@ void TGlslangToSpvTraverser::handleFunctionEntry(const glslang::TIntermAggregate
void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& node, std::vector<spv::Id>& arguments) void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& node, std::vector<spv::Id>& arguments)
{ {
const glslang::TIntermSequence& glslangArguments = node.getSequence(); const glslang::TIntermSequence& glslangArguments = node.getSequence();
glslang::TSampler sampler = {};
bool cubeCompare = false;
if (node.isTexture()) {
sampler = glslangArguments[0]->getAsTyped()->getType().getSampler();
cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow;
}
for (int i = 0; i < (int)glslangArguments.size(); ++i) { for (int i = 0; i < (int)glslangArguments.size(); ++i) {
builder.clearAccessChain(); builder.clearAccessChain();
glslangArguments[i]->traverse(this); glslangArguments[i]->traverse(this);
...@@ -1902,6 +1910,51 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& ...@@ -1902,6 +1910,51 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
if (i == 0) if (i == 0)
lvalue = true; lvalue = true;
break; break;
case glslang::EOpSparseTexture:
if ((cubeCompare && i == 3) || (! cubeCompare && i == 2))
lvalue = true;
break;
case glslang::EOpSparseTextureClamp:
if ((cubeCompare && i == 4) || (! cubeCompare && i == 3))
lvalue = true;
break;
case glslang::EOpSparseTextureLod:
case glslang::EOpSparseTextureOffset:
if (i == 3)
lvalue = true;
break;
case glslang::EOpSparseTextureFetch:
if ((sampler.dim != glslang::EsdRect && i == 3) || (sampler.dim == glslang::EsdRect && i == 2))
lvalue = true;
break;
case glslang::EOpSparseTextureFetchOffset:
if ((sampler.dim != glslang::EsdRect && i == 4) || (sampler.dim == glslang::EsdRect && i == 3))
lvalue = true;
break;
case glslang::EOpSparseTextureLodOffset:
case glslang::EOpSparseTextureGrad:
case glslang::EOpSparseTextureOffsetClamp:
if (i == 4)
lvalue = true;
break;
case glslang::EOpSparseTextureGradOffset:
case glslang::EOpSparseTextureGradClamp:
if (i == 5)
lvalue = true;
break;
case glslang::EOpSparseTextureGradOffsetClamp:
if (i == 6)
lvalue = true;
break;
case glslang::EOpSparseTextureGather:
if ((sampler.shadow && i == 3) || (! sampler.shadow && i == 2))
lvalue = true;
break;
case glslang::EOpSparseTextureGatherOffset:
case glslang::EOpSparseTextureGatherOffsets:
if ((sampler.shadow && i == 4) || (! sampler.shadow && i == 3))
lvalue = true;
break;
default: default:
break; break;
} }
...@@ -1963,6 +2016,8 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -1963,6 +2016,8 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
return builder.createTextureQueryCall(spv::OpImageQueryLod, params); return builder.createTextureQueryCall(spv::OpImageQueryLod, params);
case glslang::EOpTextureQueryLevels: case glslang::EOpTextureQueryLevels:
return builder.createTextureQueryCall(spv::OpImageQueryLevels, params); return builder.createTextureQueryCall(spv::OpImageQueryLevels, params);
case glslang::EOpSparseTexelsResident:
return builder.createUnaryOp(spv::OpImageSparseTexelsResident, builder.makeBoolType(), arguments[0]);
default: default:
assert(0); assert(0);
break; break;
...@@ -1990,7 +2045,11 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -1990,7 +2045,11 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
operands.push_back(*opIt); operands.push_back(*opIt);
builder.createNoResultOp(spv::OpImageWrite, operands); builder.createNoResultOp(spv::OpImageWrite, operands);
return spv::NoResult; return spv::NoResult;
} else { } else if (node->isSparseImage()) {
spv::MissingFunctionality("sparse image functions");
return spv::NoResult;
}
else {
// Process image atomic operations // Process image atomic operations
// GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer, // GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer,
...@@ -2010,7 +2069,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2010,7 +2069,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
} }
// Check for texture functions other than queries // Check for texture functions other than queries
bool sparse = node->isSparseTexture();
bool cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow; bool cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow;
// check for bias argument // check for bias argument
...@@ -2021,6 +2080,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2021,6 +2080,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
++nonBiasArgCount; ++nonBiasArgCount;
if (cracked.grad) if (cracked.grad)
nonBiasArgCount += 2; nonBiasArgCount += 2;
if (cracked.lodClamp)
++nonBiasArgCount;
if (sparse)
++nonBiasArgCount;
if ((int)arguments.size() > nonBiasArgCount) if ((int)arguments.size() > nonBiasArgCount)
bias = true; bias = true;
...@@ -2032,9 +2095,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2032,9 +2095,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
int extraArgs = 0; int extraArgs = 0;
// sort out where Dref is coming from // sort out where Dref is coming from
if (sampler.shadow && sampler.dim == glslang::EsdCube && sampler.arrayed) if (cubeCompare) {
params.Dref = arguments[2]; params.Dref = arguments[2];
else if (sampler.shadow && cracked.gather) { ++extraArgs;
} else if (sampler.shadow && cracked.gather) {
params.Dref = arguments[2]; params.Dref = arguments[2];
++extraArgs; ++extraArgs;
} else if (sampler.shadow) { } else if (sampler.shadow) {
...@@ -2066,6 +2130,14 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2066,6 +2130,14 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
params.offsets = arguments[2 + extraArgs]; params.offsets = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
} }
if (cracked.lodClamp) {
params.lodClamp = arguments[2 + extraArgs];
++extraArgs;
}
if (sparse) {
params.texelOut = arguments[2 + extraArgs];
++extraArgs;
}
if (bias) { if (bias) {
params.bias = arguments[2 + extraArgs]; params.bias = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
...@@ -2080,7 +2152,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2080,7 +2152,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
} }
} }
return builder.createTextureCall(precision, convertGlslangToSpvType(node->getType()), cracked.fetch, cracked.proj, cracked.gather, params); return builder.createTextureCall(precision, convertGlslangToSpvType(node->getType()), sparse, cracked.fetch, cracked.proj, cracked.gather, params);
} }
spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAggregate* node) spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAggregate* node)
......
...@@ -1222,7 +1222,7 @@ Id Builder::createBuiltinCall(Decoration /*precision*/, Id resultType, Id builti ...@@ -1222,7 +1222,7 @@ Id Builder::createBuiltinCall(Decoration /*precision*/, Id resultType, Id builti
// Accept all parameters needed to create a texture instruction. // Accept all parameters needed to create a texture instruction.
// Create the correct instruction based on the inputs, and make the call. // Create the correct instruction based on the inputs, and make the call.
Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, bool proj, bool gather, const TextureParameters& parameters) Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather, const TextureParameters& parameters)
{ {
static const int maxTextureArgs = 10; static const int maxTextureArgs = 10;
Id texArgs[maxTextureArgs] = {}; Id texArgs[maxTextureArgs] = {};
...@@ -1275,6 +1275,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1275,6 +1275,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
mask = (ImageOperandsMask)(mask | ImageOperandsSampleMask); mask = (ImageOperandsMask)(mask | ImageOperandsSampleMask);
texArgs[numArgs++] = parameters.sample; texArgs[numArgs++] = parameters.sample;
} }
if (parameters.lodClamp) {
mask = (ImageOperandsMask)(mask | ImageOperandsMinLodMask);
texArgs[numArgs++] = parameters.lodClamp;
}
if (mask == ImageOperandsMaskNone) if (mask == ImageOperandsMaskNone)
--numArgs; // undo speculative reservation for the mask argument --numArgs; // undo speculative reservation for the mask argument
else else
...@@ -1286,35 +1290,68 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1286,35 +1290,68 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
Op opCode; Op opCode;
opCode = OpImageSampleImplicitLod; opCode = OpImageSampleImplicitLod;
if (fetch) { if (fetch) {
opCode = OpImageFetch; if (sparse)
opCode = OpImageSparseFetch;
else
opCode = OpImageFetch;
} else if (gather) { } else if (gather) {
if (parameters.Dref) if (parameters.Dref)
opCode = OpImageDrefGather; if (sparse)
opCode = OpImageSparseDrefGather;
else
opCode = OpImageDrefGather;
else else
opCode = OpImageGather; if (sparse)
opCode = OpImageSparseGather;
else
opCode = OpImageGather;
} else if (xplicit) { } else if (xplicit) {
if (parameters.Dref) { if (parameters.Dref) {
if (proj) if (proj)
opCode = OpImageSampleProjDrefExplicitLod; if (sparse)
opCode = OpImageSparseSampleProjDrefExplicitLod;
else
opCode = OpImageSampleProjDrefExplicitLod;
else else
opCode = OpImageSampleDrefExplicitLod; if (sparse)
opCode = OpImageSparseSampleDrefExplicitLod;
else
opCode = OpImageSampleDrefExplicitLod;
} else { } else {
if (proj) if (proj)
opCode = OpImageSampleProjExplicitLod; if (sparse)
opCode = OpImageSparseSampleProjExplicitLod;
else
opCode = OpImageSampleProjExplicitLod;
else else
opCode = OpImageSampleExplicitLod; if (sparse)
opCode = OpImageSparseSampleExplicitLod;
else
opCode = OpImageSampleExplicitLod;
} }
} else { } else {
if (parameters.Dref) { if (parameters.Dref) {
if (proj) if (proj)
opCode = OpImageSampleProjDrefImplicitLod; if (sparse)
opCode = OpImageSparseSampleProjDrefImplicitLod;
else
opCode = OpImageSampleProjDrefImplicitLod;
else else
opCode = OpImageSampleDrefImplicitLod; if (sparse)
opCode = OpImageSparseSampleDrefImplicitLod;
else
opCode = OpImageSampleDrefImplicitLod;
} else { } else {
if (proj) if (proj)
opCode = OpImageSampleProjImplicitLod; if (sparse)
opCode = OpImageSparseSampleProjImplicitLod;
else
opCode = OpImageSampleProjImplicitLod;
else else
opCode = OpImageSampleImplicitLod; if (sparse)
opCode = OpImageSparseSampleImplicitLod;
else
opCode = OpImageSampleImplicitLod;
} }
} }
...@@ -1335,6 +1372,15 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1335,6 +1372,15 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
} }
} }
Id typeId0 = 0;
Id typeId1 = 0;
if (sparse) {
typeId0 = resultType;
typeId1 = getDerefTypeId(parameters.texelOut);
resultType = makeStructResultType(typeId0, typeId1);
}
// Build the SPIR-V instruction // Build the SPIR-V instruction
Instruction* textureInst = new Instruction(getUniqueId(), resultType, opCode); Instruction* textureInst = new Instruction(getUniqueId(), resultType, opCode);
for (int op = 0; op < optArgNum; ++op) for (int op = 0; op < optArgNum; ++op)
...@@ -1348,10 +1394,16 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1348,10 +1394,16 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
Id resultId = textureInst->getResultId(); Id resultId = textureInst->getResultId();
// When a smear is needed, do it, as per what was computed if (sparse) {
// above when resultType was changed to a scalar type. // Decode the return type that was a special structure
if (resultType != smearedType) createStore(createCompositeExtract(resultId, typeId1, 1), parameters.texelOut);
resultId = smearScalar(precision, resultId, smearedType); resultId = createCompositeExtract(resultId, typeId0, 0);
} else {
// When a smear is needed, do it, as per what was computed
// above when resultType was changed to a scalar type.
if (resultType != smearedType)
resultId = smearScalar(precision, resultId, smearedType);
}
return resultId; return resultId;
} }
......
...@@ -310,10 +310,12 @@ public: ...@@ -310,10 +310,12 @@ public:
Id gradY; Id gradY;
Id sample; Id sample;
Id comp; Id comp;
Id texelOut;
Id lodClamp;
}; };
// Select the correct texture operation based on all inputs, and emit the correct instruction // Select the correct texture operation based on all inputs, and emit the correct instruction
Id createTextureCall(Decoration precision, Id resultType, bool fetch, bool proj, bool gather, const TextureParameters&); Id createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather, const TextureParameters&);
// Emit the OpTextureQuery* instruction that was passed in. // Emit the OpTextureQuery* instruction that was passed in.
// Figure out the right return value and type, and return it. // Figure out the right return value and type, and return it.
......
#version 450
#extension GL_ARB_sparse_texture2: enable
uniform sampler2D s2D;
uniform sampler3D s3D;
uniform sampler2DShadow s2DShadow;
uniform samplerCubeShadow sCubeShadow;
uniform sampler2DArrayShadow s2DArrayShadow;
uniform sampler2DRectShadow s2DRectShadow;
uniform samplerCubeArrayShadow sCubeArrayShadow;
uniform sampler2DMS s2DMS;
uniform isamplerCube isCube;
uniform isampler2DArray is2DArray;
uniform usamplerCubeArray usCubeArray;
uniform usampler2DRect us2DRect;
uniform vec2 c2;
uniform vec3 c3;
uniform vec4 c4;
uniform ivec2 offsets[4];
out vec4 outColor;
void main()
{
int resident = 0;
vec4 texel = vec4(0.0);
ivec4 itexel = ivec4(0);
uvec4 utexel = uvec4(0);
resident |= sparseTextureARB(s2D, c2, texel);
resident |= sparseTextureARB(s3D, c3, texel, 2.0);
resident |= sparseTextureARB(isCube, c3, itexel);
resident |= sparseTextureARB(s2DShadow, c3, texel.x);
resident |= sparseTextureARB(sCubeArrayShadow, c4, 1.0, texel.x);
resident |= sparseTextureLodARB(s2D, c2, 2.0, texel);
resident |= sparseTextureLodARB(usCubeArray, c4, 1.0, utexel);
resident |= sparseTextureLodARB(s2DShadow, c3, 2.0, texel.y);
resident |= sparseTextureOffsetARB(s3D, c3, ivec3(2), texel, 2.0);
resident |= sparseTextureOffsetARB(us2DRect, c2, ivec2(3), utexel);
resident |= sparseTextureOffsetARB(s2DArrayShadow, c4, ivec2(5), texel.z);
resident |= sparseTexelFetchARB(s2D, ivec2(c2), 2, texel);
resident |= sparseTexelFetchARB(us2DRect, ivec2(c2), utexel);
resident |= sparseTexelFetchARB(s2DMS, ivec2(c2), 4, texel);
resident |= sparseTexelFetchOffsetARB(s3D, ivec3(c3), 2, ivec3(4), texel);
resident |= sparseTexelFetchOffsetARB(us2DRect, ivec2(c2), ivec2(3), utexel);
resident |= sparseTextureLodOffsetARB(s2D, c2, 2.0, ivec2(5), texel);
resident |= sparseTextureLodOffsetARB(is2DArray, c3, 2.0, ivec2(6), itexel);
resident |= sparseTextureLodOffsetARB(s2DShadow, c3, 2.0, ivec2(7), texel.z);
resident |= sparseTextureGradARB(s3D, c3, c3, c3, texel);
resident |= sparseTextureGradARB(sCubeShadow, c4, c3, c3, texel.y);
resident |= sparseTextureGradARB(usCubeArray, c4, c3, c3, utexel);
resident |= sparseTextureGradOffsetARB(s2D, c2, c2, c2, ivec2(5), texel);
resident |= sparseTextureGradOffsetARB(s2DRectShadow, c3, c2, c2, ivec2(6), texel.w);
resident |= sparseTextureGradOffsetARB(is2DArray, c3, c2, c2, ivec2(2), itexel);
resident |= sparseTextureGatherARB(s2D, c2, texel);
resident |= sparseTextureGatherARB(is2DArray, c3, itexel, 2);
resident |= sparseTextureGatherARB(s2DArrayShadow, c3, 2.0, texel);
resident |= sparseTextureGatherOffsetARB(s2D, c2, ivec2(4), texel);
resident |= sparseTextureGatherOffsetARB(is2DArray, c3, ivec2(5), itexel, 2);
resident |= sparseTextureGatherOffsetARB(s2DRectShadow, c2, 2.0, ivec2(7), texel);
resident |= sparseTextureGatherOffsetsARB(s2D, c2, offsets, texel);
resident |= sparseTextureGatherOffsetsARB(is2DArray, c3, offsets, itexel, 2);
resident |= sparseTextureGatherOffsetsARB(s2DRectShadow, c2, 2.0, offsets, texel);
outColor = sparseTexelsResidentARB(resident) ? texel : vec4(itexel) + vec4(utexel);
}
\ No newline at end of file
#version 450
#extension GL_ARB_sparse_texture_clamp: enable
uniform sampler2D s2D;
uniform sampler3D s3D;
uniform sampler2DShadow s2DShadow;
uniform samplerCubeShadow sCubeShadow;
uniform sampler2DArrayShadow s2DArrayShadow;
uniform sampler2DRectShadow s2DRectShadow;
uniform samplerCubeArrayShadow sCubeArrayShadow;
uniform isamplerCube isCube;
uniform isampler2DArray is2DArray;
uniform usamplerCubeArray usCubeArray;
uniform usampler2DRect us2DRect;
uniform vec2 c2;
uniform vec3 c3;
uniform vec4 c4;
uniform float lodClamp;
out vec4 outColor;
void main()
{
int resident = 0;
vec4 texel = vec4(0.0);
ivec4 itexel = ivec4(0);
uvec4 utexel = uvec4(0);
resident |= sparseTextureClampARB(s2D, c2, lodClamp, texel);
resident |= sparseTextureClampARB(s3D, c3, lodClamp, texel, 2.0);
resident |= sparseTextureClampARB(isCube, c3, lodClamp, itexel);
resident |= sparseTextureClampARB(s2DShadow, c3, lodClamp, texel.x);
resident |= sparseTextureClampARB(sCubeArrayShadow, c4, 1.0, lodClamp, texel.x);
texel += textureClampARB(s2D, c2, lodClamp);
texel += textureClampARB(s3D, c3, lodClamp, 2.0);
itexel += textureClampARB(isCube, c3, lodClamp);
texel.x += textureClampARB(s2DShadow, c3, lodClamp);
texel.x += textureClampARB(sCubeArrayShadow, c4, 1.0, lodClamp);
resident |= sparseTextureOffsetClampARB(s3D, c3, ivec3(2), lodClamp, texel, 2.0);
resident |= sparseTextureOffsetClampARB(us2DRect, c2, ivec2(3), lodClamp, utexel);
resident |= sparseTextureOffsetClampARB(s2DArrayShadow, c4, ivec2(5), lodClamp, texel.z);
texel += textureOffsetClampARB(s3D, c3, ivec3(2), lodClamp, 2.0);
utexel += textureOffsetClampARB(us2DRect, c2, ivec2(3), lodClamp);
texel.z += textureOffsetClampARB(s2DArrayShadow, c4, ivec2(5), lodClamp);
resident |= sparseTextureGradClampARB(s3D, c3, c3, c3, lodClamp, texel);
resident |= sparseTextureGradClampARB(sCubeShadow, c4, c3, c3, lodClamp, texel.y);
resident |= sparseTextureGradClampARB(usCubeArray, c4, c3, c3, lodClamp, utexel);
texel += textureGradClampARB(s3D, c3, c3, c3, lodClamp);
texel.y += textureGradClampARB(sCubeShadow, c4, c3, c3, lodClamp);
utexel += textureGradClampARB(usCubeArray, c4, c3, c3, lodClamp);
resident |= sparseTextureGradOffsetClampARB(s2D, c2, c2, c2, ivec2(5), lodClamp, texel);
resident |= sparseTextureGradOffsetClampARB(s2DRectShadow, c3, c2, c2, ivec2(6), lodClamp, texel.w);
resident |= sparseTextureGradOffsetClampARB(is2DArray, c3, c2, c2, ivec2(2), lodClamp, itexel);
texel += textureGradOffsetClampARB(s2D, c2, c2, c2, ivec2(5), lodClamp);
texel.w += textureGradOffsetClampARB(s2DRectShadow, c3, c2, c2, ivec2(6), lodClamp);
itexel += textureGradOffsetClampARB(is2DArray, c3, c2, c2, ivec2(2), lodClamp);
outColor = sparseTexelsResidentARB(resident) ? texel : vec4(itexel) + vec4(utexel);
}
\ No newline at end of file
...@@ -66,6 +66,8 @@ spv.qualifiers.vert ...@@ -66,6 +66,8 @@ spv.qualifiers.vert
spv.shiftOps.frag spv.shiftOps.frag
spv.simpleFunctionCall.frag spv.simpleFunctionCall.frag
spv.simpleMat.vert spv.simpleMat.vert
spv.sparseTexture.frag
spv.sparseTextureClamp.frag
spv.structAssignment.frag spv.structAssignment.frag
spv.structDeref.frag spv.structDeref.frag
spv.structure.frag spv.structure.frag
......
...@@ -369,6 +369,8 @@ enum TOperator { ...@@ -369,6 +369,8 @@ enum TOperator {
EOpImageAtomicExchange, EOpImageAtomicExchange,
EOpImageAtomicCompSwap, EOpImageAtomicCompSwap,
EOpSparseImageLoad,
EOpImageGuardEnd, EOpImageGuardEnd,
// //
...@@ -398,6 +400,31 @@ enum TOperator { ...@@ -398,6 +400,31 @@ enum TOperator {
EOpTextureGather, EOpTextureGather,
EOpTextureGatherOffset, EOpTextureGatherOffset,
EOpTextureGatherOffsets, EOpTextureGatherOffsets,
EOpTextureClamp,
EOpTextureOffsetClamp,
EOpTextureGradClamp,
EOpTextureGradOffsetClamp,
EOpSparseTextureGuardBegin,
EOpSparseTexture,
EOpSparseTextureLod,
EOpSparseTextureOffset,
EOpSparseTextureFetch,
EOpSparseTextureFetchOffset,
EOpSparseTextureLodOffset,
EOpSparseTextureGrad,
EOpSparseTextureGradOffset,
EOpSparseTextureGather,
EOpSparseTextureGatherOffset,
EOpSparseTextureGatherOffsets,
EOpSparseTexelsResident,
EOpSparseTextureClamp,
EOpSparseTextureOffsetClamp,
EOpSparseTextureGradClamp,
EOpSparseTextureGradOffsetClamp,
EOpSparseTextureGuardEnd,
EOpTextureGuardEnd, EOpTextureGuardEnd,
...@@ -622,6 +649,7 @@ struct TCrackedTextureOp { ...@@ -622,6 +649,7 @@ struct TCrackedTextureOp {
bool offsets; bool offsets;
bool gather; bool gather;
bool grad; bool grad;
bool lodClamp;
}; };
// //
...@@ -637,6 +665,8 @@ public: ...@@ -637,6 +665,8 @@ public:
bool isConstructor() const; bool isConstructor() const;
bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; } bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; }
bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; } bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; }
bool isSparseTexture() const { return op > EOpSparseTextureGuardBegin && op < EOpSparseTextureGuardEnd; }
bool isSparseImage() const { return op == EOpSparseImageLoad; }
// Crack the op into the individual dimensions of texturing operation. // Crack the op into the individual dimensions of texturing operation.
void crackTexture(TSampler sampler, TCrackedTextureOp& cracked) const void crackTexture(TSampler sampler, TCrackedTextureOp& cracked) const
...@@ -649,6 +679,7 @@ public: ...@@ -649,6 +679,7 @@ public:
cracked.offsets = false; cracked.offsets = false;
cracked.gather = false; cracked.gather = false;
cracked.grad = false; cracked.grad = false;
cracked.lodClamp = false;
switch (op) { switch (op) {
case EOpImageQuerySize: case EOpImageQuerySize:
...@@ -657,25 +688,40 @@ public: ...@@ -657,25 +688,40 @@ public:
case EOpTextureQueryLod: case EOpTextureQueryLod:
case EOpTextureQueryLevels: case EOpTextureQueryLevels:
case EOpTextureQuerySamples: case EOpTextureQuerySamples:
case EOpSparseTexelsResident:
cracked.query = true; cracked.query = true;
break; break;
case EOpTexture: case EOpTexture:
case EOpSparseTexture:
break;
case EOpTextureClamp:
case EOpSparseTextureClamp:
cracked.lodClamp = true;
break; break;
case EOpTextureProj: case EOpTextureProj:
cracked.proj = true; cracked.proj = true;
break; break;
case EOpTextureLod: case EOpTextureLod:
case EOpSparseTextureLod:
cracked.lod = true; cracked.lod = true;
break; break;
case EOpTextureOffset: case EOpTextureOffset:
case EOpSparseTextureOffset:
cracked.offset = true; cracked.offset = true;
break; break;
case EOpTextureOffsetClamp:
case EOpSparseTextureOffsetClamp:
cracked.offset = true;
cracked.lodClamp = true;
break;
case EOpTextureFetch: case EOpTextureFetch:
case EOpSparseTextureFetch:
cracked.fetch = true; cracked.fetch = true;
if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D) if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D)
cracked.lod = true; cracked.lod = true;
break; break;
case EOpTextureFetchOffset: case EOpTextureFetchOffset:
case EOpSparseTextureFetchOffset:
cracked.fetch = true; cracked.fetch = true;
cracked.offset = true; cracked.offset = true;
if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D) if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D)
...@@ -686,6 +732,7 @@ public: ...@@ -686,6 +732,7 @@ public:
cracked.proj = true; cracked.proj = true;
break; break;
case EOpTextureLodOffset: case EOpTextureLodOffset:
case EOpSparseTextureLodOffset:
cracked.offset = true; cracked.offset = true;
cracked.lod = true; cracked.lod = true;
break; break;
...@@ -699,9 +746,16 @@ public: ...@@ -699,9 +746,16 @@ public:
cracked.proj = true; cracked.proj = true;
break; break;
case EOpTextureGrad: case EOpTextureGrad:
case EOpSparseTextureGrad:
cracked.grad = true; cracked.grad = true;
break; break;
case EOpTextureGradClamp:
case EOpSparseTextureGradClamp:
cracked.grad = true;
cracked.lodClamp = true;
break;
case EOpTextureGradOffset: case EOpTextureGradOffset:
case EOpSparseTextureGradOffset:
cracked.grad = true; cracked.grad = true;
cracked.offset = true; cracked.offset = true;
break; break;
...@@ -714,14 +768,23 @@ public: ...@@ -714,14 +768,23 @@ public:
cracked.offset = true; cracked.offset = true;
cracked.proj = true; cracked.proj = true;
break; break;
case EOpTextureGradOffsetClamp:
case EOpSparseTextureGradOffsetClamp:
cracked.grad = true;
cracked.offset = true;
cracked.lodClamp = true;
break;
case EOpTextureGather: case EOpTextureGather:
case EOpSparseTextureGather:
cracked.gather = true; cracked.gather = true;
break; break;
case EOpTextureGatherOffset: case EOpTextureGatherOffset:
case EOpSparseTextureGatherOffset:
cracked.gather = true; cracked.gather = true;
cracked.offset = true; cracked.offset = true;
break; break;
case EOpTextureGatherOffsets: case EOpTextureGatherOffsets:
case EOpSparseTextureGatherOffsets:
cracked.gather = true; cracked.gather = true;
cracked.offsets = true; cracked.offsets = true;
break; break;
......
...@@ -173,6 +173,8 @@ void TParseContext::initializeExtensionBehavior() ...@@ -173,6 +173,8 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[E_GL_ARB_derivative_control] = EBhDisable; extensionBehavior[E_GL_ARB_derivative_control] = EBhDisable;
extensionBehavior[E_GL_ARB_shader_texture_image_samples] = EBhDisable; extensionBehavior[E_GL_ARB_shader_texture_image_samples] = EBhDisable;
extensionBehavior[E_GL_ARB_viewport_array] = EBhDisable; extensionBehavior[E_GL_ARB_viewport_array] = EBhDisable;
extensionBehavior[E_GL_ARB_sparse_texture2] = EBhDisable;
extensionBehavior[E_GL_ARB_sparse_texture_clamp] = EBhDisable;
// extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members // extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members
// #line and #include // #line and #include
...@@ -274,6 +276,8 @@ const char* TParseContext::getPreamble() ...@@ -274,6 +276,8 @@ const char* TParseContext::getPreamble()
"#define GL_ARB_derivative_control 1\n" "#define GL_ARB_derivative_control 1\n"
"#define GL_ARB_shader_texture_image_samples 1\n" "#define GL_ARB_shader_texture_image_samples 1\n"
"#define GL_ARB_viewport_array 1\n" "#define GL_ARB_viewport_array 1\n"
"#define GL_ARB_sparse_texture2 1\n"
"#define GL_ARB_sparse_texture_clamp 1\n"
"#define GL_GOOGLE_cpp_style_line_directive 1\n" "#define GL_GOOGLE_cpp_style_line_directive 1\n"
"#define GL_GOOGLE_include_directive 1\n" "#define GL_GOOGLE_include_directive 1\n"
......
...@@ -111,6 +111,8 @@ const char* const E_GL_ARB_shader_draw_parameters = "GL_ARB_shader_draw_pa ...@@ -111,6 +111,8 @@ const char* const E_GL_ARB_shader_draw_parameters = "GL_ARB_shader_draw_pa
const char* const E_GL_ARB_derivative_control = "GL_ARB_derivative_control"; const char* const E_GL_ARB_derivative_control = "GL_ARB_derivative_control";
const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples"; const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples";
const char* const E_GL_ARB_viewport_array = "GL_ARB_viewport_array"; const char* const E_GL_ARB_viewport_array = "GL_ARB_viewport_array";
const char* const E_GL_ARB_sparse_texture2 = "GL_ARB_sparse_texture2";
const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp";
//const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members //const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
// #line and #include // #line and #include
......
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