Add debug setting and code to allow nVidia nSight graphics debugging to capture SL frames.

Thu, 15 Feb 2018 21:55:24 +0000

author
Graham Linden graham@lindenlab.com
date
Thu, 15 Feb 2018 21:55:24 +0000
changeset 55287
09ebe35bb9fb
parent 55285
c8b6574c3f5b
child 55288
ef907fd4ba25

Add debug setting and code to allow nVidia nSight graphics debugging to capture SL frames.
These changes are only enabled if RenderNsightDebugSupport is true and eliminate use of
some OpenGL legacy functionality which is incompatible with nSight capture
(mostly glReadPixels and other fixed-function pipe rendering calls).

indra/llappearance/lltexlayer.cpp file | annotate | diff | revisions
indra/llrender/llgl.cpp file | annotate | diff | revisions
indra/llrender/llrender.cpp file | annotate | diff | revisions
indra/llrender/llrender.h file | annotate | diff | revisions
indra/llwindow/llwindowwin32.cpp file | annotate | diff | revisions
indra/newview/app_settings/settings.xml file | annotate | diff | revisions
indra/newview/llappviewer.cpp file | annotate | diff | revisions
indra/newview/llfasttimerview.cpp file | annotate | diff | revisions
indra/newview/llviewerwindow.cpp file | annotate | diff | revisions
     1.1 --- a/indra/llappearance/lltexlayer.cpp	Wed Feb 14 20:17:55 2018 +0200
     1.2 +++ b/indra/llappearance/lltexlayer.cpp	Thu Feb 15 21:55:24 2018 +0000
     1.3 @@ -1577,7 +1577,12 @@
     1.4  			}
     1.5  			alpha_data = new U8[width * height];
     1.6  			mAlphaCache[cache_index] = alpha_data;
     1.7 -			glReadPixels(x, y, width, height, GL_ALPHA, GL_UNSIGNED_BYTE, alpha_data);
     1.8 +    
     1.9 +			// nSight doesn't support use of glReadPixels
    1.10 +			if (!LLRender::sNsightDebugSupport)
    1.11 +			{
    1.12 +				glReadPixels(x, y, width, height, GL_ALPHA, GL_UNSIGNED_BYTE, alpha_data);
    1.13 +			}
    1.14  		}
    1.15  		
    1.16  		getTexLayerSet()->getAvatarAppearance()->dirtyMesh();
     2.1 --- a/indra/llrender/llgl.cpp	Wed Feb 14 20:17:55 2018 +0200
     2.2 +++ b/indra/llrender/llgl.cpp	Thu Feb 15 21:55:24 2018 +0000
     2.3 @@ -1348,8 +1348,19 @@
     2.4  	if (mHasVertexShader)
     2.5  	{
     2.6  		LL_INFOS() << "initExtensions() VertexShader-related procs..." << LL_ENDL;
     2.7 +
     2.8 +        // nSight doesn't support use of ARB funcs that have been normalized in the API
     2.9 +        if (!LLRender::sNsightDebugSupport)
    2.10 +        {
    2.11  		glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetAttribLocationARB");
    2.12  		glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) GLH_EXT_GET_PROC_ADDRESS("glBindAttribLocationARB");
    2.13 +        }
    2.14 +        else
    2.15 +        {
    2.16 +            glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetAttribLocation");
    2.17 +            glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBindAttribLocation");
    2.18 +        }
    2.19 +
    2.20  		glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetActiveAttribARB");
    2.21  		glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1dARB");
    2.22  		glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1dvARB");
     3.1 --- a/indra/llrender/llrender.cpp	Wed Feb 14 20:17:55 2018 +0200
     3.2 +++ b/indra/llrender/llrender.cpp	Thu Feb 15 21:55:24 2018 +0000
     3.3 @@ -49,6 +49,7 @@
     3.4  U32 LLRender::sUIVerts = 0;
     3.5  U32 LLTexUnit::sWhiteTexture = 0;
     3.6  bool LLRender::sGLCoreProfile = false;
     3.7 +bool LLRender::sNsightDebugSupport = false;
     3.8  
     3.9  static const U32 LL_NUM_TEXTURE_LAYERS = 32; 
    3.10  static const U32 LL_NUM_LIGHT_UNITS = 8;
     4.1 --- a/indra/llrender/llrender.h	Wed Feb 14 20:17:55 2018 +0200
     4.2 +++ b/indra/llrender/llrender.h	Thu Feb 15 21:55:24 2018 +0000
     4.3 @@ -438,7 +438,8 @@
     4.4  	static U32 sUICalls;
     4.5  	static U32 sUIVerts;
     4.6  	static bool sGLCoreProfile;
     4.7 -	
     4.8 +	static bool sNsightDebugSupport;
     4.9 +
    4.10  private:
    4.11  	friend class LLLightState;
    4.12  
     5.1 --- a/indra/llwindow/llwindowwin32.cpp	Wed Feb 14 20:17:55 2018 +0200
     5.2 +++ b/indra/llwindow/llwindowwin32.cpp	Thu Feb 15 21:55:24 2018 +0000
     5.3 @@ -1549,7 +1549,10 @@
     5.4  					(LLRender::sGLCoreProfile ? " core" : " compatibility") << " context." << LL_ENDL;
     5.5  				done = true;
     5.6  
     5.7 -				if (LLRender::sGLCoreProfile)
     5.8 +			// force sNoFixedFunction iff we're trying to use nsight debugging which does not support many legacy API uses
     5.9 +
    5.10 +				// nSight doesn't support use of legacy API funcs in the fixed function pipe
    5.11 +				if (LLRender::sGLCoreProfile || LLRender::sNsightDebugSupport)
    5.12  				{
    5.13  					LLGLSLShader::sNoFixedFunction = true;
    5.14  				}
     6.1 --- a/indra/newview/app_settings/settings.xml	Wed Feb 14 20:17:55 2018 +0200
     6.2 +++ b/indra/newview/app_settings/settings.xml	Thu Feb 15 21:55:24 2018 +0000
     6.3 @@ -8631,7 +8631,19 @@
     6.4        <key>Value</key>
     6.5        <integer>0</integer>
     6.6      </map>
     6.7 -
     6.8 +  <key>RenderNsightDebugSupport</key>
     6.9 +  <map>
    6.10 +    <key>Comment</key>
    6.11 +    <string>
    6.12 +      Disable features which prevent nVidia nSight from being usable with SL
    6.13 +    </string>
    6.14 +    <key>Persist</key>
    6.15 +    <integer>1</integer>
    6.16 +    <key>Type</key>
    6.17 +    <string>Boolean</string>
    6.18 +    <key>Value</key>
    6.19 +    <integer>0</integer>
    6.20 +  </map>
    6.21    <key>RenderLocalLights</key>
    6.22    <map>
    6.23      <key>Comment</key>
     7.1 --- a/indra/newview/llappviewer.cpp	Wed Feb 14 20:17:55 2018 +0200
     7.2 +++ b/indra/newview/llappviewer.cpp	Thu Feb 15 21:55:24 2018 +0000
     7.3 @@ -583,6 +583,7 @@
     7.4  	LLSurface::setTextureSize(gSavedSettings.getU32("RegionTextureSize"));
     7.5  	
     7.6  	LLRender::sGLCoreProfile = gSavedSettings.getBOOL("RenderGLCoreProfile");
     7.7 +	LLRender::sNsightDebugSupport = gSavedSettings.getBOOL("RenderNsightDebugSupport");
     7.8  	LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO");
     7.9  	LLImageGL::sGlobalUseAnisotropic	= gSavedSettings.getBOOL("RenderAnisotropic");
    7.10  	LLImageGL::sCompressTextures		= gSavedSettings.getBOOL("RenderCompressTextures");
    7.11 @@ -1100,6 +1101,7 @@
    7.12  		}
    7.13  	}
    7.14  
    7.15 +#if LL_RELEASE_FOR_DOWNLOAD
    7.16  	char* PARENT = getenv("PARENT");
    7.17  	if (! (PARENT && std::string(PARENT) == "SL_Launcher"))
    7.18  	{
    7.19 @@ -1112,6 +1114,7 @@
    7.20  		// him/herself in the foot.
    7.21  		LLNotificationsUtil::add("RunLauncher");
    7.22  	}
    7.23 +#endif
    7.24  
    7.25  #if LL_WINDOWS
    7.26  	if (gGLManager.mGLVersion < LLFeatureManager::getInstance()->getExpectedGLVersion())
     8.1 --- a/indra/newview/llfasttimerview.cpp	Wed Feb 14 20:17:55 2018 +0200
     8.2 +++ b/indra/newview/llfasttimerview.cpp	Thu Feb 15 21:55:24 2018 +0000
     8.3 @@ -435,18 +435,22 @@
     8.4  
     8.5  void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch)
     8.6  {
     8.7 -	//read result back into raw image
     8.8 -	glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData());
     8.9 +	// disable use of glReadPixels which messes up nVidia nSight graphics debugging
    8.10 +	if (!LLRender::sNsightDebugSupport)
    8.11 +	{
    8.12 +		//read result back into raw image
    8.13 +		glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData());
    8.14  
    8.15 -	//write results to disk
    8.16 -	LLPointer<LLImagePNG> result = new LLImagePNG();
    8.17 -	result->encode(scratch, 0.f);
    8.18 +		//write results to disk
    8.19 +		LLPointer<LLImagePNG> result = new LLImagePNG();
    8.20 +		result->encode(scratch, 0.f);
    8.21  
    8.22 -	std::string ext = result->getExtension();
    8.23 -	std::string filename = llformat("%s_%s.%s", label.c_str(), suffix, ext.c_str());
    8.24 +		std::string ext = result->getExtension();
    8.25 +		std::string filename = llformat("%s_%s.%s", label.c_str(), suffix, ext.c_str());
    8.26  	
    8.27 -	std::string out_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename);
    8.28 -	result->save(out_file);
    8.29 +		std::string out_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename);
    8.30 +		result->save(out_file);
    8.31 +	}
    8.32  }
    8.33  
    8.34  //static
     9.1 --- a/indra/newview/llviewerwindow.cpp	Wed Feb 14 20:17:55 2018 +0200
     9.2 +++ b/indra/newview/llviewerwindow.cpp	Thu Feb 15 21:55:24 2018 +0000
     9.3 @@ -731,7 +731,8 @@
     9.4  			addText(xpos, ypos, "View Matrix");
     9.5  			ypos += y_inc;
     9.6  		}
     9.7 -		if (gSavedSettings.getBOOL("DebugShowColor"))
     9.8 +		// disable use of glReadPixels which messes up nVidia nSight graphics debugging
     9.9 +		if (gSavedSettings.getBOOL("DebugShowColor") && !LLRender::sNsightDebugSupport)
    9.10  		{
    9.11  			U8 color[4];
    9.12  			LLCoordGL coord = gViewerWindow->getCurrentMouse();
    9.13 @@ -4717,36 +4718,39 @@
    9.14  					{
    9.15  						LLAppViewer::instance()->pingMainloopTimeout("LLViewerWindow::rawSnapshot");
    9.16  					}
    9.17 -				
    9.18 -					if (type == LLSnapshotModel::SNAPSHOT_TYPE_COLOR)
    9.19 +					// disable use of glReadPixels when doing nVidia nSight graphics debugging
    9.20 +					if (!LLRender::sNsightDebugSupport)
    9.21  					{
    9.22 -						glReadPixels(
    9.23 +						if (type == LLSnapshotModel::SNAPSHOT_TYPE_COLOR)
    9.24 +						{
    9.25 +							glReadPixels(
    9.26  									 subimage_x_offset, out_y + subimage_y_offset,
    9.27  									 read_width, 1,
    9.28  									 GL_RGB, GL_UNSIGNED_BYTE,
    9.29  									 raw->getData() + output_buffer_offset
    9.30  									 );
    9.31 -					}
    9.32 -					else // LLSnapshotModel::SNAPSHOT_TYPE_DEPTH
    9.33 -					{
    9.34 -						LLPointer<LLImageRaw> depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values
    9.35 -						glReadPixels(
    9.36 -									 subimage_x_offset, out_y + subimage_y_offset,
    9.37 -									 read_width, 1,
    9.38 -									 GL_DEPTH_COMPONENT, GL_FLOAT,
    9.39 -									 depth_line_buffer->getData()// current output pixel is beginning of buffer...
    9.40 -									 );
    9.41 -
    9.42 -						for (S32 i = 0; i < (S32)read_width; i++)
    9.43 +						}
    9.44 +						else // LLSnapshotModel::SNAPSHOT_TYPE_DEPTH
    9.45  						{
    9.46 -							F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32)));
    9.47 +							LLPointer<LLImageRaw> depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values
    9.48 +							glReadPixels(
    9.49 +										 subimage_x_offset, out_y + subimage_y_offset,
    9.50 +										 read_width, 1,
    9.51 +										 GL_DEPTH_COMPONENT, GL_FLOAT,
    9.52 +										 depth_line_buffer->getData()// current output pixel is beginning of buffer...
    9.53 +										 );
    9.54 +
    9.55 +							for (S32 i = 0; i < (S32)read_width; i++)
    9.56 +							{
    9.57 +								F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32)));
    9.58  					
    9.59 -							F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2));
    9.60 -							U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar());
    9.61 -							// write converted scanline out to result image
    9.62 -							for (S32 j = 0; j < raw->getComponents(); j++)
    9.63 -							{
    9.64 -								*(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byte;
    9.65 +								F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2));
    9.66 +								U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar());
    9.67 +								// write converted scanline out to result image
    9.68 +								for (S32 j = 0; j < raw->getComponents(); j++)
    9.69 +								{
    9.70 +									*(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byte;
    9.71 +								}
    9.72  							}
    9.73  						}
    9.74  					}

mercurial