From d1987803b7e8017c74ca284ac072a7f7ec6f89ed Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Date: Tue, 29 Oct 2024 14:51:56 +0100 Subject: [PATCH] Check argument constness with SparseTextureOffset functions There are a few checks that were missing for sparse variants of these functions. --- glslang/MachineIndependent/ParseHelper.cpp | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index a92d1634d2..62b9ee161e 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -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; @@ -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()) { @@ -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() &&