[sldev] Texture Debug Display (Shift+Ctrl+3) VWR 779

Nicholaz Beresford nicholaz at blueflash.cc
Sat May 19 15:46:13 PDT 2007


I also did a patch today to address various layout and graphic issues of 
the texture debug display (missing background, bars overlapping text, 
bars over/undershooting) .  There were even two uninitialized variables 
there (texture packet counters).

Patch attached for review.
-------------- next part --------------

# XP [w:\sl1.15.1.3]c:/cygwin/bin/udiff -u linden-orig/indra/newview/lltextureview.cpp linden/indra/newview/lltextureview.cpp 
--- linden-orig/indra/newview/lltextureview.cpp	2007-05-14 16:47:26.000000000 +0200
+++ linden/indra/newview/lltextureview.cpp	2007-05-19 18:57:06.781250000 +0200
@@ -396,45 +396,59 @@
 	S32 max_total_mem = LLViewerImage::sMaxTotalTextureMem;
 	F32 discard_bias = LLViewerImage::sDesiredDiscardBias;
 	S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f);
+
+	LLGLEnable tex(GL_TEXTURE_2D);
 	
+
 	//----------------------------------------------------------------------------
 	LLGLSUIDefault gls_ui;
 	F32 text_color[] = {1.f, 1.f, 1.f, 0.75f};
 	
 	std::string text;
-	text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Discard Bias: %.2f",
+	text = llformat("Memory: Texures: %d/%d MB GL-Bound: %d/%d MB Discard Bias: %.2f",
 					total_mem/(1024*1024),
 					max_total_mem/(1024*1024),
 					bound_mem/(1024*1024),
 					max_bound_mem/(1024*1024),
 					discard_bias);
 
-	LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*3,
+	LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*4,
 									 text_color, LLFontGL::LEFT, LLFontGL::TOP);
 
 	//----------------------------------------------------------------------------
-	S32 bar_left = 380;
-	S32 bar_width = 200;
-	S32 top = line_height*3 - 2;
-	S32 bottom = top - 6;
+	F32 bar_total_scale = 1.5f;	// bar display up to 150% total
+	S32 bar_left = 440;
+	S32 bar_width = 100;
+	S32 bar_width_100 = llfloor((F32)bar_width / bar_total_scale);	// 100% fill indicator (bar scale scale goes to 150%)
+	S32 bar_top = line_height*4 - 2;
+	S32 bar_bottom = bar_top - line_height + 5;
+	S32 top = bar_top;
 	S32 left = bar_left;
-	S32 right = left + bar_width;
-
-	F32 bar_scale = (F32)bar_width / (max_bound_mem * 1.5f);
+	S32 fill = bar_left;
+	S32 bottom = bar_bottom;
+	F32 bar_scale = 0;
 	
 	LLGLSNoTexture gls_no_texture;
-	
-	glColor4f(0.5f, 0.5f, 0.5f, 0.75f);
-	gl_rect_2d(left, top, right, bottom);
 
+	//--------------------------------------
 	
-	left = bar_left;
-	right = left + llfloor(bound_mem * bar_scale);
-	if (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale))
+	// dimensions/values for total_memory bar
+	bar_scale = (F32)bar_width / (max_total_mem * bar_total_scale);
+	left += 20;
+	top = bar_top;
+	bottom = bar_bottom;
+	fill = left + llfloor(total_mem * bar_scale);
+
+	// draw total memroy bar container
+	glColor4f(0.25f, 0.25f, 0.25f, 0.75f);
+	gl_rect_2d(left, top, left+bar_width_100, bottom);
+
+	// draw bar fill
+	if (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale))
 	{
 		glColor4f(0.f, 1.f, 0.f, 0.75f);
 	}
-	else if (bound_mem < max_bound_mem)
+	else if (total_mem < max_total_mem)
 	{
 		glColor4f(1.f, 1.f, 0.f, 0.75f);
 	}
@@ -442,19 +456,30 @@
 	{
 		glColor4f(1.f, 0.f, 0.f, 0.75f);
 	}
-	gl_rect_2d(left, top, right, bottom);
+	gl_rect_2d(left, top, fill, bottom);
+	left = left + bar_width;
 
-	bar_scale = (F32)bar_width / (max_total_mem * 1.5f);
-	
-	top = bottom - 2;
-	bottom = top - 6;
-	left = bar_left;
-	right = left + llfloor(total_mem * bar_scale);
-	if (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale))
+
+	//--------------------------------------
+
+	// dimensions for bound-mem
+	bar_scale = (F32)bar_width / (max_bound_mem * bar_total_scale);
+	top = bar_top;
+	left += 20;
+	bottom = bar_bottom;
+	fill = left + llfloor(bound_mem * bar_scale);
+	fill = llclamp(fill, left, left + bar_width); // HACK: avoid bar overshooting for bogus bound_mem calculations
+
+	// draw bound-mem bar container 
+	glColor4f(0.25f, 0.25f, 0.25f, 0.75f);
+	gl_rect_2d(left, top, left+bar_width_100, bottom);
+
+	// draw bar fill
+	if (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale))
 	{
 		glColor4f(0.f, 1.f, 0.f, 0.75f);
 	}
-	else if (total_mem < max_total_mem)
+	else if (bound_mem < max_bound_mem)
 	{
 		glColor4f(1.f, 1.f, 0.f, 0.75f);
 	}
@@ -462,12 +487,11 @@
 	{
 		glColor4f(1.f, 0.f, 0.f, 0.75f);
 	}
-	gl_rect_2d(left, top, right, bottom);
+	gl_rect_2d(left, top, fill, bottom);
+	left = left + bar_width;
 
 	//----------------------------------------------------------------------------
 
-	LLGLEnable tex(GL_TEXTURE_2D);
-	
 	text = llformat("Textures: Count: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d(%d) RAW:%d",
 					gImageList.getNumImages(),
 					gTextureFetch->getNumRequests(), gTextureFetch->getNumDeletes(),
@@ -477,7 +501,7 @@
 					LLImageWorker::sCount, LLImageWorker::getWorkerThread()->getNumDeletes(),
 					LLImageRaw::sRawImageCount);
 
-	LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*2,
+	LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*3,
 									 text_color, LLFontGL::LEFT, LLFontGL::TOP);
 	
 	S32 dx1 = 0;
@@ -493,6 +517,7 @@
 										 text_color, LLFontGL::LEFT, LLFontGL::TOP);
 		dx1 += 8;
 	}
+
 	if (mTextureView->mOrderFetch)
 	{
 		LLFontGL::sMonospace->renderUTF8(title_string1b, 0, title_x1+dx1, line_height,
@@ -521,8 +546,9 @@
 
 LLRect LLGLTexMemBar::getRequiredRect()
 {
+	S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f);
 	LLRect rect;
-	rect.mTop = 8;
+	rect.mTop = line_height*3 - 4;
 	return rect;
 }
 
@@ -725,7 +751,7 @@
 		mGLTexMemBar = new LLGLTexMemBar("gl texmem bar", this);
 		addChild(mGLTexMemBar);
 	
-		reshape(mRect.getWidth(), mRect.getHeight(), TRUE);
+		reshape(mRect.getWidth(), mRect.getHeight()+100, TRUE);
 
 		/*
 		  count = gImageList.getNumImages();

# XP [w:\sl1.15.1.3]c:/cygwin/bin/udiff -u linden-orig/indra/newview/lltexturefetch.cpp linden/indra/newview/lltexturefetch.cpp 
--- linden-orig/indra/newview/lltexturefetch.cpp	2007-05-14 16:47:26.000000000 +0200
+++ linden/indra/newview/lltexturefetch.cpp	2007-05-19 18:34:25.937500000 +0200
@@ -1257,6 +1257,8 @@
 	: LLWorkerThread("TextureFetch", threaded),
 	  mDebugCount(0),
 	  mDebugPause(FALSE),
+	  mPacketCount(0),
+	  mBadPacketCount(0),
 	  mQueueMutex(getAPRPool()),
 	  mTextureCache(cache)
 {


More information about the SLDev mailing list