From 06bce2ddd0958cff3c2ee477a880e998dfc48be7 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Thu, 15 Feb 2018 21:55:24 +0000 Subject: 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/newview/app_settings/settings.xml | 14 ++++++++- indra/newview/llappviewer.cpp | 3 ++ indra/newview/llfasttimerview.cpp | 22 +++++++++------ indra/newview/llviewerwindow.cpp | 50 ++++++++++++++++++--------------- 4 files changed, 56 insertions(+), 33 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 3b518515cb..0cce614a1f 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8631,7 +8631,19 @@ Value 0 - + RenderNsightDebugSupport + + Comment + + Disable features which prevent nVidia nSight from being usable with SL + + Persist + 1 + Type + Boolean + Value + 0 + RenderLocalLights Comment diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index d9273dfcb5..2b0b8064bd 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -583,6 +583,7 @@ static void settings_to_globals() LLSurface::setTextureSize(gSavedSettings.getU32("RegionTextureSize")); LLRender::sGLCoreProfile = gSavedSettings.getBOOL("RenderGLCoreProfile"); + LLRender::sNsightDebugSupport = gSavedSettings.getBOOL("RenderNsightDebugSupport"); LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); LLImageGL::sGlobalUseAnisotropic = gSavedSettings.getBOOL("RenderAnisotropic"); LLImageGL::sCompressTextures = gSavedSettings.getBOOL("RenderCompressTextures"); @@ -1100,6 +1101,7 @@ bool LLAppViewer::init() } } +#if LL_RELEASE_FOR_DOWNLOAD char* PARENT = getenv("PARENT"); if (! (PARENT && std::string(PARENT) == "SL_Launcher")) { @@ -1112,6 +1114,7 @@ bool LLAppViewer::init() // him/herself in the foot. LLNotificationsUtil::add("RunLauncher"); } +#endif #if LL_WINDOWS if (gGLManager.mGLVersion < LLFeatureManager::getInstance()->getExpectedGLVersion()) diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 9219dd0279..34d0972d72 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -435,18 +435,22 @@ void LLFastTimerView::onClose(bool app_quitting) void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) { - //read result back into raw image - glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData()); + // disable use of glReadPixels which messes up nVidia nSight graphics debugging + if (!LLRender::sNsightDebugSupport) + { + //read result back into raw image + glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData()); - //write results to disk - LLPointer result = new LLImagePNG(); - result->encode(scratch, 0.f); + //write results to disk + LLPointer result = new LLImagePNG(); + result->encode(scratch, 0.f); - std::string ext = result->getExtension(); - std::string filename = llformat("%s_%s.%s", label.c_str(), suffix, ext.c_str()); + std::string ext = result->getExtension(); + std::string filename = llformat("%s_%s.%s", label.c_str(), suffix, ext.c_str()); - std::string out_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename); - result->save(out_file); + std::string out_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename); + result->save(out_file); + } } //static diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index c057954606..e0309a4546 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -731,7 +731,8 @@ public: addText(xpos, ypos, "View Matrix"); ypos += y_inc; } - if (gSavedSettings.getBOOL("DebugShowColor")) + // disable use of glReadPixels which messes up nVidia nSight graphics debugging + if (gSavedSettings.getBOOL("DebugShowColor") && !LLRender::sNsightDebugSupport) { U8 color[4]; LLCoordGL coord = gViewerWindow->getCurrentMouse(); @@ -4717,36 +4718,39 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei { LLAppViewer::instance()->pingMainloopTimeout("LLViewerWindow::rawSnapshot"); } - - if (type == LLSnapshotModel::SNAPSHOT_TYPE_COLOR) + // disable use of glReadPixels when doing nVidia nSight graphics debugging + if (!LLRender::sNsightDebugSupport) { - glReadPixels( + if (type == LLSnapshotModel::SNAPSHOT_TYPE_COLOR) + { + glReadPixels( subimage_x_offset, out_y + subimage_y_offset, read_width, 1, GL_RGB, GL_UNSIGNED_BYTE, raw->getData() + output_buffer_offset ); - } - else // LLSnapshotModel::SNAPSHOT_TYPE_DEPTH - { - LLPointer depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values - glReadPixels( - subimage_x_offset, out_y + subimage_y_offset, - read_width, 1, - GL_DEPTH_COMPONENT, GL_FLOAT, - depth_line_buffer->getData()// current output pixel is beginning of buffer... - ); - - for (S32 i = 0; i < (S32)read_width; i++) + } + else // LLSnapshotModel::SNAPSHOT_TYPE_DEPTH { - F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32))); - - F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2)); - U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar()); - // write converted scanline out to result image - for (S32 j = 0; j < raw->getComponents(); j++) + LLPointer depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values + glReadPixels( + subimage_x_offset, out_y + subimage_y_offset, + read_width, 1, + GL_DEPTH_COMPONENT, GL_FLOAT, + depth_line_buffer->getData()// current output pixel is beginning of buffer... + ); + + for (S32 i = 0; i < (S32)read_width; i++) { - *(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byte; + F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32))); + + F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2)); + U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar()); + // write converted scanline out to result image + for (S32 j = 0; j < raw->getComponents(); j++) + { + *(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byte; + } } } } -- cgit v1.2.3 From f6b770d062d4a1c88ada3ddded88bd60168751e7 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Thu, 15 Feb 2018 23:23:46 +0000 Subject: Mark RenderNsightDebugSupport as requiring restart (because it does). Remove nerfing of message to run SL_Launcher. --- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llappviewer.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 0cce614a1f..756e4b6616 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8635,7 +8635,7 @@ Comment - Disable features which prevent nVidia nSight from being usable with SL + Disable features which prevent nVidia nSight from being usable with SL. Requires restart. Persist 1 diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 2b0b8064bd..a0750214a8 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1101,7 +1101,6 @@ bool LLAppViewer::init() } } -#if LL_RELEASE_FOR_DOWNLOAD char* PARENT = getenv("PARENT"); if (! (PARENT && std::string(PARENT) == "SL_Launcher")) { @@ -1114,7 +1113,6 @@ bool LLAppViewer::init() // him/herself in the foot. LLNotificationsUtil::add("RunLauncher"); } -#endif #if LL_WINDOWS if (gGLManager.mGLVersion < LLFeatureManager::getInstance()->getExpectedGLVersion()) -- cgit v1.2.3 From caa60a57310a01041cca74be789935ae6135f4eb Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Thu, 15 Feb 2018 16:58:44 -0800 Subject: Fix batch display in avatar render info (%d is not for doubles). --- indra/newview/llviewerwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index e0309a4546..e90b4ac86c 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -614,7 +614,7 @@ public: if (last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize) > 0) { - 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))); + 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))); } ypos += y_inc; -- cgit v1.2.3