diff options
| author | Dave Parks <davep@lindenlab.com> | 2024-08-27 11:53:54 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-27 09:53:54 -0700 | 
| commit | 8406d1052c70d1d9f964ec86f6f5468aa9f57bb1 (patch) | |
| tree | 646b8f456833ea3c8f911449c1101296d239c696 | |
| parent | 50dc4cbdf9640601ca164086bee4f3a7b91868ca (diff) | |
#2428 Fix for crash when applying PBR material (#2430)
Also attempt to fix some occasional bad texture memory tracking.
| -rw-r--r-- | indra/llrender/llimagegl.cpp | 10 | ||||
| -rw-r--r-- | indra/newview/llface.cpp | 7 | 
2 files changed, 12 insertions, 5 deletions
| diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 058afa0cf2..e4b176ff69 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -70,12 +70,15 @@ static U64 sTextureBytes = 0;  void LLImageGLMemory::alloc_tex_image(U32 width, U32 height, U32 pixformat)  {      U32 texUnit = gGL.getCurrentTexUnitIndex(); +    llassert(texUnit == 0); // allocations should always be done on tex unit 0      U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture();      U64 size = LLImageGL::dataFormatBytes(pixformat, width, height);      llassert(size >= 0);      sTexMemMutex.lock(); + +    // it is a precondition that no existing allocation exists for this texture      llassert(sTextureAllocs.find(texName) == sTextureAllocs.end());      sTextureAllocs[texName] = size; @@ -89,7 +92,7 @@ void LLImageGLMemory::free_tex_image(U32 texName)  {      sTexMemMutex.lock();      auto iter = sTextureAllocs.find(texName); -    if (iter != sTextureAllocs.end()) +    if (iter != sTextureAllocs.end()) // sometimes a texName will be "freed" before allocated (e.g. first call to setManualImage for a given texName)      {          llassert(iter->second <= sTextureBytes); // sTextureBytes MUST NOT go below zero @@ -114,6 +117,7 @@ void LLImageGLMemory::free_tex_images(U32 count, const U32* texNames)  void LLImageGLMemory::free_cur_tex_image()  {      U32 texUnit = gGL.getCurrentTexUnitIndex(); +    llassert(texUnit == 0); // frees should always be done on tex unit 0      U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture();      free_tex_image(texName);  } @@ -1215,8 +1219,8 @@ void LLImageGL::deleteTextures(S32 numTextures, const U32 *textures)          if (!sFreeList[idx].empty())          { -            glDeleteTextures((GLsizei) sFreeList[idx].size(), sFreeList[idx].data());              free_tex_images((GLsizei) sFreeList[idx].size(), sFreeList[idx].data()); +            glDeleteTextures((GLsizei)sFreeList[idx].size(), sFreeList[idx].data());              sFreeList[idx].resize(0);          }      } @@ -2405,7 +2409,7 @@ bool LLImageGL::scaleDown(S32 desired_discard)      { // use a PBO to downscale the texture          U64 size = getBytes(desired_discard);          llassert(size <= 2048 * 2048 * 4); // we shouldn't be using this method to downscale huge textures, but it'll work -        gGL.getTexUnit(0)->bind(this); +        gGL.getTexUnit(0)->bind(this, false, true);          if (sScratchPBO == 0)          { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index a8001699fe..9e504402c8 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -577,8 +577,11 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color)                  }              }              // Draw the selection marker using the correctly chosen vertex buffer -            vertex_buffer->setBuffer(); -            vertex_buffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); +            if (vertex_buffer) +            { +                vertex_buffer->setBuffer(); +                vertex_buffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); +            }          }          gGL.popMatrix(); | 
