From ab775457178be9bb4f2f9f768e3971e9c555f0d6 Mon Sep 17 00:00:00 2001 From: Beq Date: Tue, 9 May 2023 16:31:06 +0100 Subject: [PATCH] FIX Opensim VarRregions with non-power of 2 sizes flood logs --- indra/newview/llsurface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index 956808586e..593e3bd964 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -171,6 +171,16 @@ void LLSurface::create(const S32 grids_per_edge, mMetersPerEdge = mMetersPerGrid * (mGridsPerEdge - 1); // Aurora Sim sTextureSize = width; + + // Trap non-power of 2 widths to avoid GLtexture issues. + if ((sTextureSize & (sTextureSize - 1)) != 0) + { + // Not a power of 2, find the next power of 2 + sTextureSize = 1 << static_cast( pow( 2, static_cast( ceil(log2(sTextureSize)) ) ) ); + } + + // Clamp to maximum limit + sTextureSize = std::min(sTextureSize, 1024); // Aurora Sim mOriginGlobal.setVec(origin_global);