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);