diff options
| author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-04-02 01:50:21 +0300 | 
|---|---|---|
| committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-04-02 16:18:33 +0300 | 
| commit | d77954ef50f300846eb14034a8dde3e4d7064dcf (patch) | |
| tree | b400a6992e660eafb1f930330428cb60743a7640 /indra | |
| parent | 939817d560434cdc2888ef478b965f5625a381b7 (diff) | |
#3597 Improve error handling at LLGLSLShader::disableTexture()
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llrender/llglslshader.cpp | 27 | 
1 files changed, 22 insertions, 5 deletions
| diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index b3f32fdc83..50e40a3eb6 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -1247,23 +1247,40 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)          llassert(false);          return -1;      } +      S32 index = mTexture[uniform]; -    if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE) +    if (index < 0) +    { +        // Invalid texture index - nothing to disable +        return index; +    } + +    LLTexUnit* tex_unit = gGL.getTexUnit(index); +    if (!tex_unit)      { -        if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode) +        // Invalid texture unit +        LL_WARNS_ONCE("Shader") << "Invalid texture unit at index: " << index << LL_ENDL; +        return index; +    } + +    LLTexUnit::eTextureType curr_type = tex_unit->getCurrType(); +    if (curr_type != LLTexUnit::TT_NONE) +    { +        if (gDebugGL && curr_type != mode)          {              if (gDebugSession)              { -                gFailLog << "Texture channel " << index << " texture type corrupted." << std::endl; +                gFailLog << "Texture channel " << index << " texture type corrupted. Expected: " << mode << ", Found: " << curr_type << std::endl;                  ll_fail("LLGLSLShader::disableTexture failed");              }              else              { -                LL_ERRS() << "Texture channel " << index << " texture type corrupted." << LL_ENDL; +                LL_ERRS() << "Texture channel " << index << " texture type corrupted. Expected: " << mode << ", Found: " << curr_type << LL_ENDL;              }          } -        gGL.getTexUnit(index)->disable(); +        tex_unit->disable();      } +      return index;  } | 
