diff options
| author | Rye <rye@alchemyviewer.org> | 2025-10-28 22:20:37 -0400 |
|---|---|---|
| committer | Rye <rye@alchemyviewer.org> | 2025-10-31 07:46:07 -0400 |
| commit | 14bf0509efad36650e6157975cd5e0d77e64183b (patch) | |
| tree | 2a7692d99ab33cb2b217e211c73cb9750bef802b /indra/llrender | |
| parent | 3d8cb2343b113a27b856be329b4edd37c74945f1 (diff) | |
Fix invalid calls to glLineWidth on some linux GL drivers
Signed-off-by: Rye <rye@alchemyviewer.org>
Diffstat (limited to 'indra/llrender')
| -rw-r--r-- | indra/llrender/llgl.cpp | 7 | ||||
| -rw-r--r-- | indra/llrender/llgl.h | 2 | ||||
| -rw-r--r-- | indra/llrender/llrender.cpp | 18 | ||||
| -rw-r--r-- | indra/llrender/llrender.h | 5 | ||||
| -rw-r--r-- | indra/llrender/llrender2dutils.cpp | 15 |
5 files changed, 34 insertions, 13 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index f5f70c2935..7b8eb7809e 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1261,6 +1261,13 @@ bool LLGLManager::initGL() glGetIntegerv(GL_MAX_VARYING_VECTORS, &mMaxVaryingVectors); glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &mMaxUniformBlockSize); + // If outside the allowed range, glLineWidth fails with "invalid value". + // On Darwin, the range is [1, 1]. + GLfloat line_width_range[2]{0.f}; + glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, line_width_range); + mMinSmoothLineWidth = line_width_range[0]; + mMaxSmoothLineWidth = line_width_range[1]; + // sanity clamp max uniform block size to 64k just in case // there's some implementation that reports a crazy value mMaxUniformBlockSize = llmin(mMaxUniformBlockSize, 65536); diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index e2e6e92e59..b7cd3df3c8 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -90,6 +90,8 @@ public: F32 mMaxAnisotropy = 0.f; S32 mMaxUniformBlockSize = 0; S32 mMaxVaryingVectors = 0; + F32 mMinSmoothLineWidth = 1.f; + F32 mMaxSmoothLineWidth = 1.f; // GL 4.x capabilities bool mHasCubeMapArray = false; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 3f1dc3d3c1..970a9f6975 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1923,6 +1923,24 @@ void LLRender::diffuseColor4ub(U8 r, U8 g, U8 b, U8 a) } } +void LLRender::setLineWidth(F32 width) +{ + gGL.flush(); + + if(sGLCoreProfile) + { + width = 1.f; + } + else + { + width = llclamp(width, gGLManager.mMinSmoothLineWidth, gGLManager.mMaxSmoothLineWidth); + } + if(mLineWidth != width) + { + mLineWidth = width; + glLineWidth(width); + } +} void LLRender::debugTexUnits(void) { diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 8da0bde578..bc1fb3ce40 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -467,6 +467,8 @@ public: LLLightState* getLight(U32 index); void setAmbientLightColor(const LLColor4& color); + void setLineWidth(F32 width); + LLTexUnit* getTexUnit(U32 index); U32 getCurrentTexUnitIndex(void) const { return mCurrTextureUnitIndex; } @@ -512,7 +514,8 @@ private: U32 mCount; U32 mMode; U32 mCurrTextureUnitIndex; - bool mCurrColorMask[4]; + bool mCurrColorMask[4]; + F32 mLineWidth = 1.f; LLPointer<LLVertexBuffer> mBuffer; LLStrider<LLVector4a> mVerticesp; diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp index 5b08c29d64..e9d2212a67 100644 --- a/indra/llrender/llrender2dutils.cpp +++ b/indra/llrender/llrender2dutils.cpp @@ -833,8 +833,7 @@ void gl_line_3d( const LLVector3& start, const LLVector3& end, const LLColor4& c { gGL.color4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], color.mV[VALPHA]); - gGL.flush(); - glLineWidth(2.5f); + gGL.setLineWidth(2.5f); gGL.begin(LLRender::LINES); { @@ -843,7 +842,7 @@ void gl_line_3d( const LLVector3& start, const LLVector3& end, const LLColor4& c } gGL.end(); - LLRender2D::setLineWidth(1.f); + gGL.setLineWidth(1.f); } void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, bool filled, F32 start_angle, F32 end_angle) @@ -1798,16 +1797,8 @@ void LLRender2D::loadIdentity() // static void LLRender2D::setLineWidth(F32 width) { - gGL.flush(); - // If outside the allowed range, glLineWidth fails with "invalid value". - // On Darwin, the range is [1, 1]. - static GLfloat range[2]{0.0}; - if (range[1] == 0) - { - glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, range); - } width *= lerp(LLRender::sUIGLScaleFactor.mV[VX], LLRender::sUIGLScaleFactor.mV[VY], 0.5f); - glLineWidth(llclamp(width, range[0], range[1])); + gGL.setLineWidth(width); } LLPointer<LLUIImage> LLRender2D::getUIImageByID(const LLUUID& image_id, S32 priority) |
