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 | |
| parent | 3d8cb2343b113a27b856be329b4edd37c74945f1 (diff) | |
Fix invalid calls to glLineWidth on some linux GL drivers
Signed-off-by: Rye <rye@alchemyviewer.org>
| -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 | ||||
| -rw-r--r-- | indra/newview/llface.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llfasttimerview.cpp | 6 | ||||
| -rw-r--r-- | indra/newview/llglsandbox.cpp | 12 | ||||
| -rw-r--r-- | indra/newview/llmodelpreview.cpp | 16 | ||||
| -rw-r--r-- | indra/newview/llselectmgr.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llsnapshotlivepreview.cpp | 4 | ||||
| -rw-r--r-- | indra/newview/llspatialpartition.cpp | 20 | ||||
| -rwxr-xr-x | indra/newview/llviewerparceloverlay.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llvoavatar.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/pipeline.cpp | 21 |
15 files changed, 72 insertions, 62 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) diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index f08ef8d24a..6f825c6a81 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -646,7 +646,7 @@ void LLFace::renderOneWireframe(const LLColor4 &color, F32 fogCfx, bool wirefram LLGLEnable offset(GL_POLYGON_OFFSET_LINE); glPolygonOffset(3.f, 3.f); - glLineWidth(5.f); + gGL.setLineWidth(5.f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); renderFace(mDrawablep, this); } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 8056983c7c..cce6eeb19d 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1057,8 +1057,7 @@ void LLFastTimerView::drawLineGraph() //fatten highlighted timer if (mHoverID == idp) { - gGL.flush(); - glLineWidth(3); + gGL.setLineWidth(3); } llassert(idp->getIndex() < sTimerColors.size()); @@ -1118,8 +1117,7 @@ void LLFastTimerView::drawLineGraph() if (mHoverID == idp) { - gGL.flush(); - glLineWidth(1); + gGL.setLineWidth(1.f); } if (idp->getTreeNode().mCollapsed) diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 112008172e..cb1068943e 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -728,8 +728,7 @@ void LLViewerObjectList::renderObjectBeacons() S32 line_width = debug_beacon.mLineWidth; if (line_width != last_line_width) { - gGL.flush(); - glLineWidth( (F32)line_width ); + gGL.setLineWidth( (F32)line_width ); last_line_width = line_width; } @@ -758,8 +757,7 @@ void LLViewerObjectList::renderObjectBeacons() S32 line_width = debug_beacon.mLineWidth; if (line_width != last_line_width) { - gGL.flush(); - glLineWidth( (F32)line_width ); + gGL.setLineWidth( (F32)line_width ); last_line_width = line_width; } @@ -773,7 +771,7 @@ void LLViewerObjectList::renderObjectBeacons() } gGL.flush(); - glLineWidth(1.f); + gGL.setLineWidth(1.f); for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter) { @@ -808,7 +806,7 @@ void LLSky::renderSunMoonBeacons(const LLVector3& pos_agent, const LLVector3& di { pos_end.mV[i] = pos_agent.mV[i] + (50 * direction.mV[i]); } - glLineWidth((GLfloat)LLPipeline::DebugBeaconLineWidth); + gGL.setLineWidth((GLfloat)LLPipeline::DebugBeaconLineWidth); gGL.begin(LLRender::LINES); color.mV[3] *= 0.5f; gGL.color4fv(color.mV); @@ -819,7 +817,7 @@ void LLSky::renderSunMoonBeacons(const LLVector3& pos_agent, const LLVector3& di gGL.end(); gGL.flush(); - glLineWidth(1.f); + gGL.setLineWidth(1.f); } diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 91a7daad1d..ed5ab35439 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -3597,11 +3597,11 @@ bool LLModelPreview::render() gGL.diffuseColor4fv(PREVIEW_EDGE_COL.mV); if (show_edges) { - glLineWidth(PREVIEW_EDGE_WIDTH); + gGL.setLineWidth(PREVIEW_EDGE_WIDTH); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glLineWidth(1.f); + gGL.setLineWidth(1.f); } buffer->unmapBuffer(); } @@ -3724,12 +3724,12 @@ bool LLModelPreview::render() buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0); gGL.diffuseColor4fv(PREVIEW_PSYH_EDGE_COL.mV); - glLineWidth(PREVIEW_PSYH_EDGE_WIDTH); + gGL.setLineWidth(PREVIEW_PSYH_EDGE_WIDTH); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glLineWidth(1.f); + gGL.setLineWidth(1.f); buffer->unmapBuffer(); } @@ -3741,7 +3741,7 @@ bool LLModelPreview::render() // only do this if mDegenerate was set in the preceding mesh checks [Check this if the ordering ever breaks] if (mHasDegenerate) { - glLineWidth(PREVIEW_DEG_EDGE_WIDTH); + gGL.setLineWidth(PREVIEW_DEG_EDGE_WIDTH); glPointSize(PREVIEW_DEG_POINT_SIZE); gPipeline.enableLightsFullbright(); //show degenerate triangles @@ -3811,7 +3811,7 @@ bool LLModelPreview::render() gGL.popMatrix(); } - glLineWidth(1.f); + gGL.setLineWidth(1.f); glPointSize(1.f); gPipeline.enableLightsPreview(); gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -3933,11 +3933,11 @@ bool LLModelPreview::render() { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.diffuseColor4fv(PREVIEW_EDGE_COL.mV); - glLineWidth(PREVIEW_EDGE_WIDTH); + gGL.setLineWidth(PREVIEW_EDGE_WIDTH); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glLineWidth(1.f); + gGL.setLineWidth(1.f); } } } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 4762fc555d..a624682e11 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6614,7 +6614,7 @@ void LLSelectMgr::renderSilhouettes(bool for_hud) gGL.popMatrix(); gGL.popMatrix(); - glLineWidth(1.f); + gGL.setLineWidth(1.f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (shader) diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 9b6a87e68d..58a443ab23 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -238,11 +238,11 @@ void LLSnapshotLivePreview::drawPreviewRect(S32 offset_x, S32 offset_y, LLColor4 { F32 line_width ; glGetFloatv(GL_LINE_WIDTH, &line_width) ; - glLineWidth(2.0f * line_width) ; + gGL.setLineWidth(2.0f * line_width) ; LLColor4 color(0.0f, 0.0f, 0.0f, 1.0f) ; gl_rect_2d( mPreviewRect.mLeft + offset_x, mPreviewRect.mTop + offset_y, mPreviewRect.mRight + offset_x, mPreviewRect.mBottom + offset_y, color, false ) ; - glLineWidth(line_width) ; + gGL.setLineWidth(line_width) ; //draw four alpha rectangles to cover areas outside of the snapshot image if(!mKeepAspectRatio) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index bc57b71022..2dc2810861 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1658,13 +1658,11 @@ void renderOctree(LLSpatialGroup* group) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); gGL.diffuseColor4f(1,0,0,group->mBuilt); - gGL.flush(); - glLineWidth(5.f); + gGL.setLineWidth(5.f); const LLVector4a* bounds = group->getObjectBounds(); drawBoxOutline(bounds[0], bounds[1]); - gGL.flush(); - glLineWidth(1.f); + gGL.setLineWidth(1.f); gGL.flush(); const LLVOAvatar* lastAvatar = nullptr; @@ -1973,13 +1971,11 @@ void renderBoundingBox(LLDrawable* drawable, bool set_color = true) LLViewerObject* vobj = drawable->getVObj(); if (vobj && vobj->onActiveList()) { - gGL.flush(); - glLineWidth(llmax(4.f*sinf(gFrameTimeSeconds*2.f)+1.f, 1.f)); - //glLineWidth(4.f*(sinf(gFrameTimeSeconds*2.f)*0.25f+0.75f)); + gGL.setLineWidth(llmax(4.f*sinf(gFrameTimeSeconds*2.f)+1.f, 1.f)); + //gGL.setLineWidth(4.f*(sinf(gFrameTimeSeconds*2.f)*0.25f+0.75f)); stop_glerror(); drawBoxOutline(pos,size); - gGL.flush(); - glLineWidth(1.f); + gGL.setLineWidth(1.f); } else { @@ -2887,8 +2883,7 @@ public: if (i == 1) { - gGL.flush(); - glLineWidth(3.f); + gGL.setLineWidth(3.f); } gGL.begin(LLRender::TRIANGLES); @@ -2906,8 +2901,7 @@ public: if (i == 1) { - gGL.flush(); - glLineWidth(1.f); + gGL.setLineWidth(1.f); } } } diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp index e36ad0e722..cf92850762 100755 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -809,7 +809,7 @@ void LLViewerParcelOverlay::renderPropertyLinesOnMinimap(F32 scale_pixels_per_me const S32 GRIDS_PER_EDGE = mParcelGridsPerEdge; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - glLineWidth(1.0f); + gGL.setLineWidth(1.0f); gGL.color4fv(parcel_outline_color); for (S32 i = 0; i <= GRIDS_PER_EDGE; i++) { diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 25b7c58733..c9d6dfa1af 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -5438,7 +5438,7 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color, S32 diffuse_channel) gGL.begin(LLRender::LINES); gGL.color4f(1.f,1.f,1.f,1.f); F32 thickness = llmax(F32(5.0f-5.0f*(gFrameTimeSeconds-mLastImpostorUpdateFrameTime)),1.0f); - glLineWidth(thickness); + gGL.setLineWidth(thickness); gGL.vertex3fv((pos+left-up).mV); gGL.vertex3fv((pos-left-up).mV); gGL.vertex3fv((pos-left-up).mV); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e74da42180..be7c57015c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4342,7 +4342,7 @@ void LLPipeline::renderPhysicsDisplay() LLGLEnable polygon_offset_line(GL_POLYGON_OFFSET_LINE); glPolygonOffset(3.f, 3.f); - glLineWidth(3.f); + gGL.setLineWidth(3.f); LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -4384,7 +4384,7 @@ void LLPipeline::renderPhysicsDisplay() glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } } - glLineWidth(1.f); + gGL.setLineWidth(1.f); gDebugProgram.unbind(); } @@ -4468,8 +4468,7 @@ void LLPipeline::renderDebug() //NavMesh if ( pathfindingConsole->isRenderNavMesh() ) { - gGL.flush(); - glLineWidth(2.0f); + gGL.setLineWidth(2.0f); LLGLEnable cull(GL_CULL_FACE); LLGLDisable blend(GL_BLEND); @@ -4493,7 +4492,7 @@ void LLPipeline::renderDebug() gGL.flush(); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - glLineWidth(1.0f); + gGL.setLineWidth(1.0f); gGL.flush(); } //User designated path @@ -4608,11 +4607,11 @@ void LLPipeline::renderDebug() gPathfindingProgram.uniform1f(sTint, 1.f); gPathfindingProgram.uniform1f(sAlphaScale, 1.f); - glLineWidth(gSavedSettings.getF32("PathfindingLineWidth")); + gGL.setLineWidth(gSavedSettings.getF32("PathfindingLineWidth")); LLGLDisable blendOut(GL_BLEND); llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] ); gGL.flush(); - glLineWidth(1.f); + gGL.setLineWidth(1.f); } glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); @@ -4635,7 +4634,7 @@ void LLPipeline::renderDebug() LLGLEnable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER); gGL.flush(); - glLineWidth(2.0f); + gGL.setLineWidth(2.0f); LLGLEnable cull(GL_CULL_FACE); gPathfindingProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint")); @@ -4662,7 +4661,7 @@ void LLPipeline::renderDebug() gPathfindingProgram.bind(); gGL.flush(); - glLineWidth(1.0f); + gGL.setLineWidth(1.0f); } glPolygonOffset(0.f, 0.f); @@ -4955,7 +4954,7 @@ void LLPipeline::renderDebug() } /*gGL.flush(); - glLineWidth(16-i*2); + gGL.setLineWidth(16-i*2); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { @@ -4973,7 +4972,7 @@ void LLPipeline::renderDebug() } } gGL.flush(); - glLineWidth(1.f);*/ + gGL.setLineWidth(1.f);*/ } } |
