From 456bec3e838b8dd3cd6f9d93b58978b6abced311 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 16 Feb 2011 18:19:22 -0600 Subject: [PATCH 1/4] Fixed snapshot floater failing to render overlay texture when full-screen preview is enabled Enabled bulk glReadPixels for snapshots if target-resolution matches render-resolution Snapshot thumbnail generated from downscaled render image, instead of requring an extra pass. --- indra/llrender/llpostprocess.cpp | 3 ++- indra/newview/llfloatersnapshot.cpp | 15 +++++++++++++-- indra/newview/llviewerwindow.cpp | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index c1c7f2132..ae367cee5 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -428,7 +428,8 @@ void LLPostProcess::doEffects(void) /// Clear the frame buffer. glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); - + LLGLDisable(GL_DEPTH_TEST); + /// Change to an orthogonal view viewOrthogonal(screenW, screenH); diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 99ab752f2..c7b37c1e0 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -243,6 +243,7 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ; mThumbnailUpdateLock = FALSE ; mThumbnailUpToDate = FALSE ; + updateSnapshot(TRUE,TRUE); //To initialize mImageRect to correct values } LLSnapshotLivePreview::~LLSnapshotLivePreview() @@ -880,7 +881,17 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) curr_preview_image->setAddressMode(LLTexUnit::TAM_CLAMP); previewp->mSnapshotUpToDate = TRUE; - previewp->generateThumbnailImage(TRUE) ; + //Resize to thumbnail. + { + previewp->mThumbnailUpToDate = TRUE ; + previewp->mThumbnailUpdateLock = TRUE ; + S32 w = get_lower_power_two(scaled->getWidth(), 512) * 2 ; + S32 h = get_lower_power_two(scaled->getHeight(), 512) * 2 ; + scaled->scale(w,h); + previewp->mThumbnailImage = new LLImageGL(scaled, FALSE); + previewp->mThumbnailUpdateLock = FALSE ; + previewp->setThumbnailImageSize(); + } previewp->mPosTakenGlobal = gAgent.getCameraPositionGlobal(); previewp->mShineCountdown = 4; // wait a few frames to avoid animation glitch due to readback this frame @@ -1236,7 +1247,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) { std::string fee = gHippoGridManager->getConnectedGrid()->getUploadFee(); floater->childSetLabelArg("upload_btn", "[UPLOADFEE]", fee); - + LLRadioGroup* snapshot_type_radio = floater->getChild("snapshot_type_radio"); snapshot_type_radio->setSelectedIndex(gSavedSettings.getS32("LastSnapshotType")); LLSnapshotLivePreview::ESnapshotType shot_type = getTypeIndex(floater); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 21eff8a44..5383a0917 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4422,8 +4422,8 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei render_ui(scale_factor, subfield); } -#if SHY_MOD // screenshot improvement - if(scale_factor <= 1.f) //faster. bulk copy opposed to line per line +#if 1//SHY_MOD // screenshot improvement + if(scale_factor <= 1.f && image_width == image_buffer_x && image_height == image_buffer_y) //faster. bulk copy opposed to line per line { if (type == SNAPSHOT_TYPE_OBJECT_ID || type == SNAPSHOT_TYPE_COLOR) { From 653053e30310d1719dbdfecf374adcc4df3066ea Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 16 Feb 2011 22:32:44 -0600 Subject: [PATCH 2/4] Fixed LLErrors killing the viewer when no username is provided on login. --- indra/newview/llpanellogin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index b16fea04f..be7dd209c 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -105,7 +105,7 @@ BOOL LLPanelLogin::sCapslockDidNotification = FALSE; static bool nameSplit(const std::string& full, std::string& first, std::string& last) { std::vector fragments; boost::algorithm::split(fragments, full, boost::is_any_of(" .")); - if (fragments.size() == 0) + if (!fragments.size() || !fragments[0].length()) return false; first = fragments[0]; if (fragments.size() == 1) From 835bc1775cf769e767ae888abfcd13ed4277a020 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 19 Feb 2011 02:27:39 -0600 Subject: [PATCH 3/4] Disabling bulk glReadPixels due to unpredictable behavior between drivers and internal image formats. Commented out document recent changes. Will remove later. --- indra/newview/llviewerwindow.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 5383a0917..d2b7f586c 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4422,21 +4422,35 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei render_ui(scale_factor, subfield); } -#if 1//SHY_MOD // screenshot improvement +#if 0//SHY_MOD // screenshot improvement + /* + //No longer doing this. glReadPixels can behave unpredictably between depth formats. May be the case for color formats as well. if(scale_factor <= 1.f && image_width == image_buffer_x && image_height == image_buffer_y) //faster. bulk copy opposed to line per line { if (type == SNAPSHOT_TYPE_OBJECT_ID || type == SNAPSHOT_TYPE_COLOR) { glReadPixels(0,0,image_width, image_height,GL_RGB, GL_UNSIGNED_BYTE,raw->getData()); + continue; } - else // SNAPSHOT_TYPE_DEPTH + //Buggered with GL_DEPTH_COMPONENT32_ARB, which flips the image upside down. + /*else // SNAPSHOT_TYPE_DEPTH { - LLPointer depth_line_buffer = new LLImageRaw(image_width, image_height, sizeof(GL_FLOAT)); - glReadPixels(0, 0,image_width,image_height, GL_DEPTH_COMPONENT, GL_FLOAT,depth_line_buffer->getData()); - raw->copy(depth_line_buffer); + //S32 desired_components = raw->getComponents(); + raw->resize(image_width,image_height,sizeof(FLOAT)); + glReadPixels(0, 0,image_width,image_height, GL_DEPTH_COMPONENT, GL_FLOAT,raw->getData()); + raw->setSize(image_width,image_height,desired_components);//Set components without reallocating + for(int i = 0;igetData() + (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()); + for(S32 j = 0; j < raw->getComponents(); j++) + raw->getData()[i*raw->getComponents()+j] = depth_byte; + } + raw->reallocateData(image_width*image_height*raw->getComponents()*sizeof(U8)); //Reallocate without erasing data + continue; } - continue; - } + }*/ #endif //shy_mod S32 subimage_x_offset = llclamp(buffer_x_offset - (subimage_x * window_width), 0, window_width); // handle fractional rows From 08ff53b2576d281152145146b229e5a82504b77c Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 19 Feb 2011 02:29:57 -0600 Subject: [PATCH 4/4] Clean state in prep for v2 selective merging. --- indra/newview/llviewerwindow.cpp | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index d2b7f586c..d6210df9f 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4422,36 +4422,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei render_ui(scale_factor, subfield); } -#if 0//SHY_MOD // screenshot improvement - /* - //No longer doing this. glReadPixels can behave unpredictably between depth formats. May be the case for color formats as well. - if(scale_factor <= 1.f && image_width == image_buffer_x && image_height == image_buffer_y) //faster. bulk copy opposed to line per line - { - if (type == SNAPSHOT_TYPE_OBJECT_ID || type == SNAPSHOT_TYPE_COLOR) - { - glReadPixels(0,0,image_width, image_height,GL_RGB, GL_UNSIGNED_BYTE,raw->getData()); - continue; - } - //Buggered with GL_DEPTH_COMPONENT32_ARB, which flips the image upside down. - /*else // SNAPSHOT_TYPE_DEPTH - { - //S32 desired_components = raw->getComponents(); - raw->resize(image_width,image_height,sizeof(FLOAT)); - glReadPixels(0, 0,image_width,image_height, GL_DEPTH_COMPONENT, GL_FLOAT,raw->getData()); - raw->setSize(image_width,image_height,desired_components);//Set components without reallocating - for(int i = 0;igetData() + (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()); - for(S32 j = 0; j < raw->getComponents(); j++) - raw->getData()[i*raw->getComponents()+j] = depth_byte; - } - raw->reallocateData(image_width*image_height*raw->getComponents()*sizeof(U8)); //Reallocate without erasing data - continue; - } - }*/ -#endif //shy_mod S32 subimage_x_offset = llclamp(buffer_x_offset - (subimage_x * window_width), 0, window_width); // handle fractional rows U32 read_width = llmax(0, (window_width - subimage_x_offset) -