Skip to content

Commit

Permalink
Check argument constness with SparseTextureOffset functions
Browse files Browse the repository at this point in the history
There are a few checks that were missing for sparse variants of these
functions.
  • Loading branch information
rg3igalia committed Oct 29, 2024
1 parent e8bce4d commit d198780
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions glslang/MachineIndependent/ParseHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2310,18 +2310,26 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
case EOpTextureProjLodOffset:
case EOpTextureGradOffset:
case EOpTextureProjGradOffset:
case EOpSparseTextureOffset:
case EOpSparseTextureFetchOffset:
case EOpSparseTextureLodOffset:
case EOpSparseTextureGradOffset:
{
// Handle texture-offset limits checking
// Pick which argument has to hold constant offsets
int arg = -1;
switch (callNode.getOp()) {
case EOpTextureOffset: arg = 2; break;
case EOpTextureFetchOffset: arg = (arg0->getType().getSampler().isRect()) ? 2 : 3; break;
case EOpTextureProjOffset: arg = 2; break;
case EOpTextureLodOffset: arg = 3; break;
case EOpTextureProjLodOffset: arg = 3; break;
case EOpTextureGradOffset: arg = 4; break;
case EOpTextureProjGradOffset: arg = 4; break;
case EOpSparseTextureOffset: // fallthrough
case EOpTextureOffset: arg = 2; break;
case EOpSparseTextureFetchOffset: // fallthrough
case EOpTextureFetchOffset: arg = (arg0->getType().getSampler().isRect()) ? 2 : 3; break;
case EOpTextureProjOffset: arg = 2; break;
case EOpSparseTextureLodOffset: // fallthrough
case EOpTextureLodOffset: arg = 3; break;
case EOpTextureProjLodOffset: arg = 3; break;
case EOpSparseTextureGradOffset: // fallthrough
case EOpTextureGradOffset: arg = 4; break;
case EOpTextureProjGradOffset: arg = 4; break;
default:
assert(0);
break;
Expand All @@ -2347,6 +2355,8 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
}
}

// This check does not apply to sparse because
// GL_ARB_sparse_texture2 always includes this function.
if (callNode.getOp() == EOpTextureOffset) {
TSampler s = arg0->getType().getSampler();
if (s.is2D() && s.isArrayed() && s.isShadow()) {
Expand All @@ -2367,6 +2377,9 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
}
}

// This check does not apply to sparse because
// GL_ARB_sparse_texture2 does not define sparseTextureLodOffsetARB
// with a sampler2DArrayShadow.
if (callNode.getOp() == EOpTextureLodOffset) {
TSampler s = arg0->getType().getSampler();
if (s.is2D() && s.isArrayed() && s.isShadow() &&
Expand Down

0 comments on commit d198780

Please sign in to comment.