Skip to content

Commit d77954e

Browse files
committed
#3597 Improve error handling at LLGLSLShader::disableTexture()
1 parent 939817d commit d77954e

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

indra/llrender/llglslshader.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,23 +1247,40 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
12471247
llassert(false);
12481248
return -1;
12491249
}
1250+
12501251
S32 index = mTexture[uniform];
1251-
if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE)
1252+
if (index < 0)
1253+
{
1254+
// Invalid texture index - nothing to disable
1255+
return index;
1256+
}
1257+
1258+
LLTexUnit* tex_unit = gGL.getTexUnit(index);
1259+
if (!tex_unit)
12521260
{
1253-
if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode)
1261+
// Invalid texture unit
1262+
LL_WARNS_ONCE("Shader") << "Invalid texture unit at index: " << index << LL_ENDL;
1263+
return index;
1264+
}
1265+
1266+
LLTexUnit::eTextureType curr_type = tex_unit->getCurrType();
1267+
if (curr_type != LLTexUnit::TT_NONE)
1268+
{
1269+
if (gDebugGL && curr_type != mode)
12541270
{
12551271
if (gDebugSession)
12561272
{
1257-
gFailLog << "Texture channel " << index << " texture type corrupted." << std::endl;
1273+
gFailLog << "Texture channel " << index << " texture type corrupted. Expected: " << mode << ", Found: " << curr_type << std::endl;
12581274
ll_fail("LLGLSLShader::disableTexture failed");
12591275
}
12601276
else
12611277
{
1262-
LL_ERRS() << "Texture channel " << index << " texture type corrupted." << LL_ENDL;
1278+
LL_ERRS() << "Texture channel " << index << " texture type corrupted. Expected: " << mode << ", Found: " << curr_type << LL_ENDL;
12631279
}
12641280
}
1265-
gGL.getTexUnit(index)->disable();
1281+
tex_unit->disable();
12661282
}
1283+
12671284
return index;
12681285
}
12691286

0 commit comments

Comments
 (0)