Merged in graham_linden/viewer-neko (pull request #525)

Fri, 16 Feb 2018 20:52:10 +0000

author
Graham Madarasz <graham@lindenlab.com>
date
Fri, 16 Feb 2018 20:52:10 +0000
changeset 55290
74516ccad384
parent 55286
da06a005f97a
parent 55289
633897a9e4df
child 55291
f8fff11129d1

Merged in graham_linden/viewer-neko (pull request #525)

Fixes MAINT-8282 feature req (from me :) )

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

Approved-by: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Approved-by: Andrey Lihatskiy <andreylproductengine@lindenlab.com>
Approved-by: Ruslan Teliuk <ruslantproductengine@lindenlab.com>

     1.1 --- a/indra/llappearance/lltexlayer.cpp	Thu Feb 15 21:48:18 2018 +0200
     1.2 +++ b/indra/llappearance/lltexlayer.cpp	Fri Feb 16 20:52:10 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	Thu Feb 15 21:48:18 2018 +0200
     2.2 +++ b/indra/llrender/llgl.cpp	Fri Feb 16 20:52:10 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	Thu Feb 15 21:48:18 2018 +0200
     3.2 +++ b/indra/llrender/llrender.cpp	Fri Feb 16 20:52:10 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	Thu Feb 15 21:48:18 2018 +0200
     4.2 +++ b/indra/llrender/llrender.h	Fri Feb 16 20:52:10 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	Thu Feb 15 21:48:18 2018 +0200
     5.2 +++ b/indra/llwindow/llwindowwin32.cpp	Fri Feb 16 20:52:10 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	Thu Feb 15 21:48:18 2018 +0200
     6.2 +++ b/indra/newview/app_settings/settings.xml	Fri Feb 16 20:52:10 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. Requires restart.
    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	Thu Feb 15 21:48:18 2018 +0200
     7.2 +++ b/indra/newview/llappviewer.cpp	Fri Feb 16 20:52:10 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");
     8.1 --- a/indra/newview/llfasttimerview.cpp	Thu Feb 15 21:48:18 2018 +0200
     8.2 +++ b/indra/newview/llfasttimerview.cpp	Fri Feb 16 20:52:10 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	Thu Feb 15 21:48:18 2018 +0200
     9.2 +++ b/indra/newview/llviewerwindow.cpp	Fri Feb 16 20:52:10 2018 +0000
     9.3 @@ -614,7 +614,7 @@
     9.4  
     9.5   			if (last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize) > 0)
     9.6  			{
     9.7 - 				addText(xpos, ypos, llformat("Batch min/max/mean: %d/%d/%d", last_frame_recording.getMin(LLPipeline::sStatBatchSize), last_frame_recording.getMax(LLPipeline::sStatBatchSize), last_frame_recording.getMean(LLPipeline::sStatBatchSize)));
     9.8 +                addText(xpos, ypos, llformat("Batch min/max/mean: %d/%d/%d", (U32)last_frame_recording.getMin(LLPipeline::sStatBatchSize), (U32)last_frame_recording.getMax(LLPipeline::sStatBatchSize), (U32)last_frame_recording.getMean(LLPipeline::sStatBatchSize)));
     9.9  			}
    9.10              ypos += y_inc;
    9.11  
    9.12 @@ -731,7 +731,8 @@
    9.13  			addText(xpos, ypos, "View Matrix");
    9.14  			ypos += y_inc;
    9.15  		}
    9.16 -		if (gSavedSettings.getBOOL("DebugShowColor"))
    9.17 +		// disable use of glReadPixels which messes up nVidia nSight graphics debugging
    9.18 +		if (gSavedSettings.getBOOL("DebugShowColor") && !LLRender::sNsightDebugSupport)
    9.19  		{
    9.20  			U8 color[4];
    9.21  			LLCoordGL coord = gViewerWindow->getCurrentMouse();
    9.22 @@ -4717,36 +4718,39 @@
    9.23  					{
    9.24  						LLAppViewer::instance()->pingMainloopTimeout("LLViewerWindow::rawSnapshot");
    9.25  					}
    9.26 -				
    9.27 -					if (type == LLSnapshotModel::SNAPSHOT_TYPE_COLOR)
    9.28 +					// disable use of glReadPixels when doing nVidia nSight graphics debugging
    9.29 +					if (!LLRender::sNsightDebugSupport)
    9.30  					{
    9.31 -						glReadPixels(
    9.32 +						if (type == LLSnapshotModel::SNAPSHOT_TYPE_COLOR)
    9.33 +						{
    9.34 +							glReadPixels(
    9.35  									 subimage_x_offset, out_y + subimage_y_offset,
    9.36  									 read_width, 1,
    9.37  									 GL_RGB, GL_UNSIGNED_BYTE,
    9.38  									 raw->getData() + output_buffer_offset
    9.39  									 );
    9.40 -					}
    9.41 -					else // LLSnapshotModel::SNAPSHOT_TYPE_DEPTH
    9.42 -					{
    9.43 -						LLPointer<LLImageRaw> depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values
    9.44 -						glReadPixels(
    9.45 -									 subimage_x_offset, out_y + subimage_y_offset,
    9.46 -									 read_width, 1,
    9.47 -									 GL_DEPTH_COMPONENT, GL_FLOAT,
    9.48 -									 depth_line_buffer->getData()// current output pixel is beginning of buffer...
    9.49 -									 );
    9.50 -
    9.51 -						for (S32 i = 0; i < (S32)read_width; i++)
    9.52 +						}
    9.53 +						else // LLSnapshotModel::SNAPSHOT_TYPE_DEPTH
    9.54  						{
    9.55 -							F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32)));
    9.56 +							LLPointer<LLImageRaw> depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values
    9.57 +							glReadPixels(
    9.58 +										 subimage_x_offset, out_y + subimage_y_offset,
    9.59 +										 read_width, 1,
    9.60 +										 GL_DEPTH_COMPONENT, GL_FLOAT,
    9.61 +										 depth_line_buffer->getData()// current output pixel is beginning of buffer...
    9.62 +										 );
    9.63 +
    9.64 +							for (S32 i = 0; i < (S32)read_width; i++)
    9.65 +							{
    9.66 +								F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32)));
    9.67  					
    9.68 -							F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2));
    9.69 -							U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar());
    9.70 -							// write converted scanline out to result image
    9.71 -							for (S32 j = 0; j < raw->getComponents(); j++)
    9.72 -							{
    9.73 -								*(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byte;
    9.74 +								F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2));
    9.75 +								U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar());
    9.76 +								// write converted scanline out to result image
    9.77 +								for (S32 j = 0; j < raw->getComponents(); j++)
    9.78 +								{
    9.79 +									*(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byte;
    9.80 +								}
    9.81  							}
    9.82  						}
    9.83  					}

mercurial