From c834bdd05a134d6b3442a31f351a94f21965d4e9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 6 Oct 2011 17:54:06 -0500
Subject: [PATCH] SH-2240 Better fix for beacon rendering -- let LLRender take
 care of optimization around joining chunks of line segments together into one
 draw call

---
 indra/newview/llglsandbox.cpp | 41 +++++------------------------------
 1 file changed, 6 insertions(+), 35 deletions(-)

diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index 3f773effcb1..ac87da2d71c 100644
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -788,9 +788,6 @@ void LLViewerObjectList::renderObjectBeacons()
 		S32 last_line_width = -1;
 		// gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width)
 		
-		BOOL flush = FALSE;
-		S32 flush_me = 128;
-
 		for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
 		{
 			const LLDebugBeacon &debug_beacon = *iter;
@@ -799,18 +796,14 @@ void LLViewerObjectList::renderObjectBeacons()
 			S32 line_width = debug_beacon.mLineWidth;
 			if (line_width != last_line_width)
 			{
-				if (flush)
-				{
-					gGL.end();
-				}
-				flush = TRUE;
 				gGL.flush();
 				glLineWidth( (F32)line_width );
 				last_line_width = line_width;
-				gGL.begin(LLRender::LINES);
 			}
 
 			const LLVector3 &thisline = debug_beacon.mPositionAgent;
+		
+			gGL.begin(LLRender::LINES);
 			gGL.color4fv(color.mV);
 			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 50.f);
 			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 50.f);
@@ -820,16 +813,9 @@ void LLViewerObjectList::renderObjectBeacons()
 			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] + 2.f,thisline.mV[VZ]);
 
 			draw_line_cube(0.10f, thisline);
-
-			if (--flush_me <= 0)
-			{
-				flush_me = 128;
-				gGL.end();
-				gGL.flush();
-				gGL.begin(LLRender::LINES);
-			}
+			
+			gGL.end();
 		}
-		gGL.end();
 	}
 
 	{
@@ -839,9 +825,6 @@ void LLViewerObjectList::renderObjectBeacons()
 		S32 last_line_width = -1;
 		// gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width)
 		
-		BOOL flush = FALSE;
-		S32 flush_me = 128;
-
 		for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
 		{
 			const LLDebugBeacon &debug_beacon = *iter;
@@ -849,18 +832,13 @@ void LLViewerObjectList::renderObjectBeacons()
 			S32 line_width = debug_beacon.mLineWidth;
 			if (line_width != last_line_width)
 			{
-				if (flush)
-				{
-					gGL.end();
-				}
-				flush = TRUE;
 				gGL.flush();
 				glLineWidth( (F32)line_width );
 				last_line_width = line_width;
-				gGL.begin(LLRender::LINES);
 			}
 
 			const LLVector3 &thisline = debug_beacon.mPositionAgent;
+			gGL.begin(LLRender::LINES);
 			gGL.color4fv(debug_beacon.mColor.mV);
 			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 0.5f);
 			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 0.5f);
@@ -871,16 +849,9 @@ void LLViewerObjectList::renderObjectBeacons()
 
 			draw_line_cube(0.10f, thisline);
 
-			if (--flush_me <= 0)
-			{
-				flush_me = 128;
-				gGL.end();
-				gGL.flush();
-				gGL.begin(LLRender::LINES);
-			}
+			gGL.end();
 		}
 		
-		gGL.end();
 		gGL.flush();
 		glLineWidth(1.f);
 
-- 
GitLab