From c355fb98d3f4040196b7b8586dc9328fccb906d2 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Mon, 3 Sep 2012 06:12:50 +0000 Subject: Extracted texture baking system into llappearance library. --- indra/newview/llviewertexlayer.cpp | 791 +++++++++++++++++++++++++++++++++++++ 1 file changed, 791 insertions(+) create mode 100644 indra/newview/llviewertexlayer.cpp (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp new file mode 100644 index 0000000000..f805083aaa --- /dev/null +++ b/indra/newview/llviewertexlayer.cpp @@ -0,0 +1,791 @@ +/** + * @file llviewertexlayer.cpp + * @brief Viewer texture layer. Used for avatars. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llagent.h" +#include "llassetuploadresponders.h" +#include "llavatarappearance.h" +#include "llglslshader.h" +#include "llimagej2c.h" +#include "llnotificationsutil.h" +#include "llviewercontrol.h" +#include "llviewerregion.h" +#include "llviewertexlayer.h" +#include "llvfile.h" +#include "llvfs.h" +#include "llvoavatarself.h" +#include "pipeline.h" + +static const S32 BAKE_UPLOAD_ATTEMPTS = 7; +static const F32 BAKE_UPLOAD_RETRY_DELAY = 2.f; // actual delay grows by power of 2 each attempt + +// runway consolidate +extern std::string self_av_string(); + +LLViewerTexLayerSet::LLViewerTexLayerSet(LLAvatarAppearance* const appearance) : + LLTexLayerSet(appearance), + mComposite( NULL ), + mUpdatesEnabled( FALSE ) +{ +} + +// virtual +LLViewerTexLayerSet::~LLViewerTexLayerSet() +{ +} + +void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) +{ + memset(data, 255, width * height); + + for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + layer->gatherAlphaMasks(data, mComposite->getOriginX(),mComposite->getOriginY(), width, height); + } + + // Set alpha back to that of our alpha masks. + renderAlphaMaskTextures(mComposite->getOriginX(), mComposite->getOriginY(), width, height, true); +} + +LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() +{ + if (!mComposite) + { + createComposite(); + } + return mComposite; +} + +const LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() const +{ + return mComposite; +} + +// virtual +void LLViewerTexLayerSet::requestUpdate() +{ + if( mUpdatesEnabled ) + { + createComposite(); + mComposite->requestUpdate(); + } +} + +void LLViewerTexLayerSet::requestUpload() +{ + createComposite(); + mComposite->requestUpload(); +} + +void LLViewerTexLayerSet::cancelUpload() +{ + if(mComposite) + { + mComposite->cancelUpload(); + } +} + + +void LLViewerTexLayerSet::createComposite() +{ + if(!mComposite) + { + S32 width = mInfo->getWidth(); + S32 height = mInfo->getHeight(); + // Composite other avatars at reduced resolution + if( !mAvatarAppearance->isSelf() ) + { + llerrs << "composites should not be created for non-self avatars!" << llendl; + } + mComposite = new LLTexLayerSetBuffer( this, width, height ); + } +} + +void LLViewerTexLayerSet::updateComposite() +{ + createComposite(); + mComposite->requestUpdateImmediate(); +} + +// Returns TRUE if at least one packet of data has been received for each of the textures that this layerset depends on. +BOOL LLViewerTexLayerSet::isLocalTextureDataAvailable() const +{ + if (!mAvatarAppearance->isSelf()) return FALSE; + LLVOAvatarSelf* self = dynamic_cast(mAvatarAppearance); + return self->isLocalTextureDataAvailable(this); +} + + +// Returns TRUE if all of the data for the textures that this layerset depends on have arrived. +BOOL LLViewerTexLayerSet::isLocalTextureDataFinal() const +{ + if (!mAvatarAppearance->isSelf()) return FALSE; + LLVOAvatarSelf* self = dynamic_cast(mAvatarAppearance); + return self->isLocalTextureDataFinal(this); +} + +void LLViewerTexLayerSet::destroyComposite() +{ + if( mComposite ) + { + mComposite = NULL; + } +} + +void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b ) +{ + mUpdatesEnabled = b; +} + +LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() const +{ + return dynamic_cast (mAvatarAppearance); +} + +//----------------------------------------------------------------------------- +// LLBakedUploadData() +//----------------------------------------------------------------------------- +LLBakedUploadData::LLBakedUploadData(const LLVOAvatarSelf* avatar, + LLViewerTexLayerSet* layerset, + const LLUUID& id, + bool highest_res) : + mAvatar(avatar), + mTexLayerSet(layerset), + mID(id), + mStartTime(LLFrameTimer::getTotalTime()), // Record starting time + mIsHighestRes(highest_res) +{ +} + +//----------------------------------------------------------------------------- +// LLTexLayerSetBuffer +// The composite image that a LLViewerTexLayerSet writes to. Each LLViewerTexLayerSet has one. +//----------------------------------------------------------------------------- + +// static +S32 LLTexLayerSetBuffer::sGLByteCount = 0; + +LLTexLayerSetBuffer::LLTexLayerSetBuffer(LLViewerTexLayerSet* const owner, + S32 width, S32 height) : + // ORDER_LAST => must render these after the hints are created. + LLViewerDynamicTexture( width, height, 4, LLViewerDynamicTexture::ORDER_LAST, TRUE ), + mUploadPending(FALSE), // Not used for any logic here, just to sync sending of updates + mNeedsUpload(FALSE), + mNumLowresUploads(0), + mUploadFailCount(0), + mNeedsUpdate(TRUE), + mNumLowresUpdates(0), + mTexLayerSet(owner) +{ + LLTexLayerSetBuffer::sGLByteCount += getSize(); + mNeedsUploadTimer.start(); + mNeedsUpdateTimer.start(); +} + +LLTexLayerSetBuffer::~LLTexLayerSetBuffer() +{ + LLTexLayerSetBuffer::sGLByteCount -= getSize(); + destroyGLTexture(); + for( S32 order = 0; order < ORDER_COUNT; order++ ) + { + LLViewerDynamicTexture::sInstances[order].erase(this); // will fail in all but one case. + } +} + +//virtual +S8 LLTexLayerSetBuffer::getType() const +{ + return LLViewerDynamicTexture::LL_TEX_LAYER_SET_BUFFER ; +} + +//virtual +void LLTexLayerSetBuffer::restoreGLTexture() +{ + LLViewerDynamicTexture::restoreGLTexture() ; +} + +//virtual +void LLTexLayerSetBuffer::destroyGLTexture() +{ + LLViewerDynamicTexture::destroyGLTexture() ; +} + +// static +void LLTexLayerSetBuffer::dumpTotalByteCount() +{ + llinfos << "Composite System GL Buffers: " << (LLTexLayerSetBuffer::sGLByteCount/1024) << "KB" << llendl; +} + +void LLTexLayerSetBuffer::requestUpdate() +{ + restartUpdateTimer(); + mNeedsUpdate = TRUE; + mNumLowresUpdates = 0; + // If we're in the middle of uploading a baked texture, we don't care about it any more. + // When it's downloaded, ignore it. + mUploadID.setNull(); +} + +void LLTexLayerSetBuffer::requestUpload() +{ + conditionalRestartUploadTimer(); + mNeedsUpload = TRUE; + mNumLowresUploads = 0; + mUploadPending = TRUE; +} + +void LLTexLayerSetBuffer::conditionalRestartUploadTimer() +{ + // If we requested a new upload but haven't even uploaded + // a low res version of our last upload request, then + // keep the timer ticking instead of resetting it. + if (mNeedsUpload && (mNumLowresUploads == 0)) + { + mNeedsUploadTimer.unpause(); + } + else + { + mNeedsUploadTimer.reset(); + mNeedsUploadTimer.start(); + } +} + +void LLTexLayerSetBuffer::restartUpdateTimer() +{ + mNeedsUpdateTimer.reset(); + mNeedsUpdateTimer.start(); +} + +void LLTexLayerSetBuffer::cancelUpload() +{ + mNeedsUpload = FALSE; + mUploadPending = FALSE; + mNeedsUploadTimer.pause(); + mUploadRetryTimer.reset(); +} + +void LLTexLayerSetBuffer::pushProjection() const +{ + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); +} + +void LLTexLayerSetBuffer::popProjection() const +{ + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); +} + +// virtual +BOOL LLTexLayerSetBuffer::needsRender() +{ + llassert(mTexLayerSet->getAvatarAppearance() == gAgentAvatarp); + if (!isAgentAvatarValid()) return FALSE; + + const BOOL upload_now = mNeedsUpload && isReadyToUpload(); + const BOOL update_now = mNeedsUpdate && isReadyToUpdate(); + + // Don't render if we don't want to (or aren't ready to) upload or update. + if (!(update_now || upload_now)) + { + return FALSE; + } + + // Don't render if we're animating our appearance. + if (gAgentAvatarp->getIsAppearanceAnimating()) + { + return FALSE; + } + + // Don't render if we are trying to create a shirt texture but aren't wearing a skirt. + if (gAgentAvatarp->getBakedTE(mTexLayerSet) == LLVOAvatarDefines::TEX_SKIRT_BAKED && + !gAgentAvatarp->isWearingWearableType(LLWearableType::WT_SKIRT)) + { + cancelUpload(); + return FALSE; + } + + // Render if we have at least minimal level of detail for each local texture. + return mTexLayerSet->isLocalTextureDataAvailable(); +} + +void LLTexLayerSetBuffer::preRender(BOOL clear_depth) +{ + // Set up an ortho projection + pushProjection(); + + // keep depth buffer, we don't need to clear it + LLViewerDynamicTexture::preRender(FALSE); +} + +void LLTexLayerSetBuffer::postRender(BOOL success) +{ + popProjection(); + + LLViewerDynamicTexture::postRender(success); +} + +BOOL LLTexLayerSetBuffer::render() +{ + // Default color mask for tex layer render + gGL.setColorMask(true, true); + + // do we need to upload, and do we have sufficient data to create an uploadable composite? + // TODO: When do we upload the texture if gAgent.mNumPendingQueries is non-zero? + const BOOL upload_now = mNeedsUpload && isReadyToUpload(); + const BOOL update_now = mNeedsUpdate && isReadyToUpdate(); + + BOOL success = TRUE; + + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + if (use_shaders) + { + gAlphaMaskProgram.bind(); + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + + LLVertexBuffer::unbind(); + + // Composite the color data + LLGLSUIDefault gls_ui; + success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight ); + gGL.flush(); + + if(upload_now) + { + if (!success) + { + llinfos << "Failed attempt to bake " << mTexLayerSet->getBodyRegionName() << llendl; + mUploadPending = FALSE; + } + else + { + if (mTexLayerSet->isVisible()) + { + mTexLayerSet->getAvatar()->debugBakedTextureUpload(mTexLayerSet->getBakedTexIndex(), FALSE); // FALSE for start of upload, TRUE for finish. + doUpload(); + } + else + { + mUploadPending = FALSE; + mNeedsUpload = FALSE; + mNeedsUploadTimer.pause(); + mTexLayerSet->getAvatar()->setNewBakedTexture(mTexLayerSet->getBakedTexIndex(),IMG_INVISIBLE); + } + } + } + + if (update_now) + { + doUpdate(); + } + + if (use_shaders) + { + gAlphaMaskProgram.unbind(); + } + + LLVertexBuffer::unbind(); + + // reset GL state + gGL.setColorMask(true, true); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + // we have valid texture data now + mGLTexturep->setGLTextureCreated(true); + + return success; +} + +BOOL LLTexLayerSetBuffer::isInitialized(void) const +{ + return mGLTexturep.notNull() && mGLTexturep->isGLTextureCreated(); +} + +BOOL LLTexLayerSetBuffer::uploadPending() const +{ + return mUploadPending; +} + +BOOL LLTexLayerSetBuffer::uploadNeeded() const +{ + return mNeedsUpload; +} + +BOOL LLTexLayerSetBuffer::uploadInProgress() const +{ + return !mUploadID.isNull(); +} + +BOOL LLTexLayerSetBuffer::isReadyToUpload() const +{ + if (!gAgentQueryManager.hasNoPendingQueries()) return FALSE; // Can't upload if there are pending queries. + if (isAgentAvatarValid() && !gAgentAvatarp->isUsingBakedTextures()) return FALSE; // Don't upload if avatar is using composites. + + BOOL ready = FALSE; + if (mTexLayerSet->isLocalTextureDataFinal()) + { + // If we requested an upload and have the final LOD ready, upload (or wait a while if this is a retry) + if (mUploadFailCount == 0) + { + ready = TRUE; + } + else + { + ready = mUploadRetryTimer.getElapsedTimeF32() >= BAKE_UPLOAD_RETRY_DELAY * (1 << (mUploadFailCount - 1)); + } + } + else + { + // Upload if we've hit a timeout. Upload is a pretty expensive process so we need to make sure + // we aren't doing uploads too frequently. + const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedTextureUploadTimeout"); + if (texture_timeout != 0) + { + // The timeout period increases exponentially between every lowres upload in order to prevent + // spamming the server with frequent uploads. + const U32 texture_timeout_threshold = texture_timeout*(1 << mNumLowresUploads); + + // If we hit our timeout and have textures available at even lower resolution, then upload. + const BOOL is_upload_textures_timeout = mNeedsUploadTimer.getElapsedTimeF32() >= texture_timeout_threshold; + const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable(); + ready = has_lower_lod && is_upload_textures_timeout; + } + } + + return ready; +} + +BOOL LLTexLayerSetBuffer::isReadyToUpdate() const +{ + // If we requested an update and have the final LOD ready, then update. + if (mTexLayerSet->isLocalTextureDataFinal()) return TRUE; + + // If we haven't done an update yet, then just do one now regardless of state of textures. + if (mNumLowresUpdates == 0) return TRUE; + + // Update if we've hit a timeout. Unlike for uploads, we can make this timeout fairly small + // since render unnecessarily doesn't cost much. + const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedLocalTextureUpdateTimeout"); + if (texture_timeout != 0) + { + // If we hit our timeout and have textures available at even lower resolution, then update. + const BOOL is_update_textures_timeout = mNeedsUpdateTimer.getElapsedTimeF32() >= texture_timeout; + const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable(); + if (has_lower_lod && is_update_textures_timeout) return TRUE; + } + + return FALSE; +} + +BOOL LLTexLayerSetBuffer::requestUpdateImmediate() +{ + mNeedsUpdate = TRUE; + BOOL result = FALSE; + + if (needsRender()) + { + preRender(FALSE); + result = render(); + postRender(result); + } + + return result; +} + +// Create the baked texture, send it out to the server, then wait for it to come +// back so we can switch to using it. +void LLTexLayerSetBuffer::doUpload() +{ + llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl; + LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES); + + // Don't need caches since we're baked now. (note: we won't *really* be baked + // until this image is sent to the server and the Avatar Appearance message is received.) + mTexLayerSet->deleteCaches(); + + // Get the COLOR information from our texture + U8* baked_color_data = new U8[ mFullWidth * mFullHeight * 4 ]; + glReadPixels(mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, GL_RGBA, GL_UNSIGNED_BYTE, baked_color_data ); + stop_glerror(); + + // Get the MASK information from our texture + LLGLSUIDefault gls_ui; + LLPointer baked_mask_image = new LLImageRaw(mFullWidth, mFullHeight, 1 ); + U8* baked_mask_data = baked_mask_image->getData(); + mTexLayerSet->gatherMorphMaskAlpha(baked_mask_data, mFullWidth, mFullHeight); + + + // Create the baked image from our color and mask information + const S32 baked_image_components = 5; // red green blue [bump] clothing + LLPointer baked_image = new LLImageRaw( mFullWidth, mFullHeight, baked_image_components ); + U8* baked_image_data = baked_image->getData(); + S32 i = 0; + for (S32 u=0; u < mFullWidth; u++) + { + for (S32 v=0; v < mFullHeight; v++) + { + baked_image_data[5*i + 0] = baked_color_data[4*i + 0]; + baked_image_data[5*i + 1] = baked_color_data[4*i + 1]; + baked_image_data[5*i + 2] = baked_color_data[4*i + 2]; + baked_image_data[5*i + 3] = baked_color_data[4*i + 3]; // alpha should be correct for eyelashes. + baked_image_data[5*i + 4] = baked_mask_data[i]; + i++; + } + } + + LLPointer compressedImage = new LLImageJ2C; + const char* comment_text = LINDEN_J2C_COMMENT_PREFIX "RGBHM"; // writes into baked_color_data. 5 channels (rgb, heightfield/alpha, mask) + if (compressedImage->encode(baked_image, comment_text)) + { + LLTransactionID tid; + tid.generate(); + const LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); + if (LLVFile::writeFile(compressedImage->getData(), compressedImage->getDataSize(), + gVFS, asset_id, LLAssetType::AT_TEXTURE)) + { + // Read back the file and validate. + BOOL valid = FALSE; + LLPointer integrity_test = new LLImageJ2C; + S32 file_size = 0; + U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size); + if (data) + { + valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data' + } + else + { + integrity_test->setLastError("Unable to read entire file"); + } + + if (valid) + { + const bool highest_lod = mTexLayerSet->isLocalTextureDataFinal(); + // Baked_upload_data is owned by the responder and deleted after the request completes. + LLBakedUploadData* baked_upload_data = new LLBakedUploadData(gAgentAvatarp, + this->mTexLayerSet, + asset_id, + highest_lod); + // upload ID is used to avoid overlaps, e.g. when the user rapidly makes two changes outside of Face Edit. + mUploadID = asset_id; + + // Upload the image + const std::string url = gAgent.getRegion()->getCapability("UploadBakedTexture"); + if(!url.empty() + && !LLPipeline::sForceOldBakedUpload // toggle debug setting UploadBakedTexOld to change between the new caps method and old method + && (mUploadFailCount < (BAKE_UPLOAD_ATTEMPTS - 1))) // Try last ditch attempt via asset store if cap upload is failing. + { + LLSD body = LLSD::emptyMap(); + // The responder will call LLTexLayerSetBuffer::onTextureUploadComplete() + LLHTTPClient::post(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data)); + llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl; + } + else + { + gAssetStorage->storeAssetData(tid, + LLAssetType::AT_TEXTURE, + LLTexLayerSetBuffer::onTextureUploadComplete, + baked_upload_data, + TRUE, // temp_file + TRUE, // is_priority + TRUE); // store_local + llinfos << "Baked texture upload via Asset Store." << llendl; + } + + if (highest_lod) + { + // Sending the final LOD for the baked texture. All done, pause + // the upload timer so we know how long it took. + mNeedsUpload = FALSE; + mNeedsUploadTimer.pause(); + } + else + { + // Sending a lower level LOD for the baked texture. Restart the upload timer. + mNumLowresUploads++; + mNeedsUploadTimer.unpause(); + mNeedsUploadTimer.reset(); + } + + // Print out notification that we uploaded this texture. + if (gSavedSettings.getBOOL("DebugAvatarRezTime")) + { + const std::string lod_str = highest_lod ? "HighRes" : "LowRes"; + LLSD args; + args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatar()->debugGetExistenceTimeElapsedF32()); + args["TIME"] = llformat("%d",(U32)mNeedsUploadTimer.getElapsedTimeF32()); + args["BODYREGION"] = mTexLayerSet->getBodyRegionName(); + args["RESOLUTION"] = lod_str; + LLNotificationsUtil::add("AvatarRezSelfBakedTextureUploadNotification",args); + LL_DEBUGS("Avatar") << self_av_string() << "Uploading [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUploadTimer.getElapsedTimeF32() << " ]" << LL_ENDL; + } + } + else + { + // The read back and validate operation failed. Remove the uploaded file. + mUploadPending = FALSE; + LLVFile file(gVFS, asset_id, LLAssetType::AT_TEXTURE, LLVFile::WRITE); + file.remove(); + llinfos << "Unable to create baked upload file (reason: corrupted)." << llendl; + } + } + } + else + { + // The VFS write file operation failed. + mUploadPending = FALSE; + llinfos << "Unable to create baked upload file (reason: failed to write file)" << llendl; + } + + delete [] baked_color_data; +} + +// Mostly bookkeeping; don't need to actually "do" anything since +// render() will actually do the update. +void LLTexLayerSetBuffer::doUpdate() +{ + const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal(); + if (highest_lod) + { + mNeedsUpdate = FALSE; + } + else + { + mNumLowresUpdates++; + } + + restartUpdateTimer(); + + // need to switch to using this layerset if this is the first update + // after getting the lowest LOD + mTexLayerSet->getAvatarAppearance()->updateMeshTextures(); + + // Print out notification that we updated this texture. + if (gSavedSettings.getBOOL("DebugAvatarRezTime")) + { + const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal(); + const std::string lod_str = highest_lod ? "HighRes" : "LowRes"; + LLSD args; + args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatarAppearance()->debugGetExistenceTimeElapsedF32()); + args["TIME"] = llformat("%d",(U32)mNeedsUpdateTimer.getElapsedTimeF32()); + args["BODYREGION"] = mTexLayerSet->getBodyRegionName(); + args["RESOLUTION"] = lod_str; + LLNotificationsUtil::add("AvatarRezSelfBakedTextureUpdateNotification",args); + LL_DEBUGS("Avatar") << self_av_string() << "Locally updating [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUpdateTimer.getElapsedTimeF32() << " ]" << LL_ENDL; + } +} + +// static +void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, + void* userdata, + S32 result, + LLExtStat ext_status) // StoreAssetData callback (not fixed) +{ + LLBakedUploadData* baked_upload_data = (LLBakedUploadData*)userdata; + + if (isAgentAvatarValid() && + !gAgentAvatarp->isDead() && + (baked_upload_data->mAvatar == gAgentAvatarp) && // Sanity check: only the user's avatar should be uploading textures. + (baked_upload_data->mTexLayerSet->hasComposite())) + { + LLTexLayerSetBuffer* layerset_buffer = baked_upload_data->mTexLayerSet->getComposite(); + S32 failures = layerset_buffer->mUploadFailCount; + layerset_buffer->mUploadFailCount = 0; + + if (layerset_buffer->mUploadID.isNull()) + { + // The upload got canceled, we should be in the + // process of baking a new texture so request an + // upload with the new data + + // BAP: does this really belong in this callback, as + // opposed to where the cancellation takes place? + // suspect this does nothing. + layerset_buffer->requestUpload(); + } + else if (baked_upload_data->mID == layerset_buffer->mUploadID) + { + // This is the upload we're currently waiting for. + layerset_buffer->mUploadID.setNull(); + const std::string name(baked_upload_data->mTexLayerSet->getBodyRegionName()); + const std::string resolution = baked_upload_data->mIsHighestRes ? " full res " : " low res "; + if (result >= 0) + { + layerset_buffer->mUploadPending = FALSE; // Allows sending of AgentSetAppearance later + LLVOAvatarDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->mTexLayerSet); + // Update baked texture info with the new UUID + U64 now = LLFrameTimer::getTotalTime(); // Record starting time + llinfos << "Baked" << resolution << "texture upload for " << name << " took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << llendl; + gAgentAvatarp->setNewBakedTexture(baked_te, uuid); + } + else + { + ++failures; + S32 max_attempts = baked_upload_data->mIsHighestRes ? BAKE_UPLOAD_ATTEMPTS : 1; // only retry final bakes + llwarns << "Baked" << resolution << "texture upload for " << name << " failed (attempt " << failures << "/" << max_attempts << ")" << llendl; + if (failures < max_attempts) + { + layerset_buffer->mUploadFailCount = failures; + layerset_buffer->mUploadRetryTimer.start(); + layerset_buffer->requestUpload(); + } + } + } + else + { + llinfos << "Received baked texture out of date, ignored." << llendl; + } + + gAgentAvatarp->dirtyMesh(); + } + else + { + // Baked texture failed to upload (in which case since we + // didn't set the new baked texture, it means that they'll try + // and rebake it at some point in the future (after login?)), + // or this response to upload is out of date, in which case a + // current response should be on the way or already processed. + llwarns << "Baked upload failed" << llendl; + } + + delete baked_upload_data; +} + + + + -- cgit v1.2.3 From 0c7623f628cbba999860379a2f5c302d94c1d287 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Mon, 3 Sep 2012 08:37:58 +0000 Subject: Cleanup of llappearance refactor file definition order for easier diff'ing --- indra/newview/llviewertexlayer.cpp | 280 ++++++++++++++++++++----------------- 1 file changed, 152 insertions(+), 128 deletions(-) (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index f805083aaa..3a3cae4047 100644 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -26,19 +26,19 @@ #include "llviewerprecompiledheaders.h" +#include "llviewertexlayer.h" + #include "llagent.h" -#include "llassetuploadresponders.h" -#include "llavatarappearance.h" -#include "llglslshader.h" #include "llimagej2c.h" #include "llnotificationsutil.h" -#include "llviewercontrol.h" -#include "llviewerregion.h" -#include "llviewertexlayer.h" #include "llvfile.h" #include "llvfs.h" +#include "llviewerregion.h" +#include "llglslshader.h" #include "llvoavatarself.h" #include "pipeline.h" +#include "llassetuploadresponders.h" +#include "llviewercontrol.h" static const S32 BAKE_UPLOAD_ATTEMPTS = 7; static const F32 BAKE_UPLOAD_RETRY_DELAY = 2.f; // actual delay grows by power of 2 each attempt @@ -46,126 +46,6 @@ static const F32 BAKE_UPLOAD_RETRY_DELAY = 2.f; // actual delay grows by power o // runway consolidate extern std::string self_av_string(); -LLViewerTexLayerSet::LLViewerTexLayerSet(LLAvatarAppearance* const appearance) : - LLTexLayerSet(appearance), - mComposite( NULL ), - mUpdatesEnabled( FALSE ) -{ -} - -// virtual -LLViewerTexLayerSet::~LLViewerTexLayerSet() -{ -} - -void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) -{ - memset(data, 255, width * height); - - for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - LLTexLayerInterface* layer = *iter; - layer->gatherAlphaMasks(data, mComposite->getOriginX(),mComposite->getOriginY(), width, height); - } - - // Set alpha back to that of our alpha masks. - renderAlphaMaskTextures(mComposite->getOriginX(), mComposite->getOriginY(), width, height, true); -} - -LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() -{ - if (!mComposite) - { - createComposite(); - } - return mComposite; -} - -const LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() const -{ - return mComposite; -} - -// virtual -void LLViewerTexLayerSet::requestUpdate() -{ - if( mUpdatesEnabled ) - { - createComposite(); - mComposite->requestUpdate(); - } -} - -void LLViewerTexLayerSet::requestUpload() -{ - createComposite(); - mComposite->requestUpload(); -} - -void LLViewerTexLayerSet::cancelUpload() -{ - if(mComposite) - { - mComposite->cancelUpload(); - } -} - - -void LLViewerTexLayerSet::createComposite() -{ - if(!mComposite) - { - S32 width = mInfo->getWidth(); - S32 height = mInfo->getHeight(); - // Composite other avatars at reduced resolution - if( !mAvatarAppearance->isSelf() ) - { - llerrs << "composites should not be created for non-self avatars!" << llendl; - } - mComposite = new LLTexLayerSetBuffer( this, width, height ); - } -} - -void LLViewerTexLayerSet::updateComposite() -{ - createComposite(); - mComposite->requestUpdateImmediate(); -} - -// Returns TRUE if at least one packet of data has been received for each of the textures that this layerset depends on. -BOOL LLViewerTexLayerSet::isLocalTextureDataAvailable() const -{ - if (!mAvatarAppearance->isSelf()) return FALSE; - LLVOAvatarSelf* self = dynamic_cast(mAvatarAppearance); - return self->isLocalTextureDataAvailable(this); -} - - -// Returns TRUE if all of the data for the textures that this layerset depends on have arrived. -BOOL LLViewerTexLayerSet::isLocalTextureDataFinal() const -{ - if (!mAvatarAppearance->isSelf()) return FALSE; - LLVOAvatarSelf* self = dynamic_cast(mAvatarAppearance); - return self->isLocalTextureDataFinal(this); -} - -void LLViewerTexLayerSet::destroyComposite() -{ - if( mComposite ) - { - mComposite = NULL; - } -} - -void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b ) -{ - mUpdatesEnabled = b; -} - -LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() const -{ - return dynamic_cast (mAvatarAppearance); -} //----------------------------------------------------------------------------- // LLBakedUploadData() @@ -693,7 +573,7 @@ void LLTexLayerSetBuffer::doUpdate() // need to switch to using this layerset if this is the first update // after getting the lowest LOD - mTexLayerSet->getAvatarAppearance()->updateMeshTextures(); + mTexLayerSet->getAvatar()->updateMeshTextures(); // Print out notification that we updated this texture. if (gSavedSettings.getBOOL("DebugAvatarRezTime")) @@ -701,7 +581,7 @@ void LLTexLayerSetBuffer::doUpdate() const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal(); const std::string lod_str = highest_lod ? "HighRes" : "LowRes"; LLSD args; - args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatarAppearance()->debugGetExistenceTimeElapsedF32()); + args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatar()->debugGetExistenceTimeElapsedF32()); args["TIME"] = llformat("%d",(U32)mNeedsUpdateTimer.getElapsedTimeF32()); args["BODYREGION"] = mTexLayerSet->getBodyRegionName(); args["RESOLUTION"] = lod_str; @@ -786,6 +666,150 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, delete baked_upload_data; } +//----------------------------------------------------------------------------- +// LLViewerTexLayerSet +// An ordered set of texture layers that get composited into a single texture. +//----------------------------------------------------------------------------- + +LLViewerTexLayerSet::LLViewerTexLayerSet(LLAvatarAppearance* const appearance) : + LLTexLayerSet(appearance), + mComposite( NULL ), + mUpdatesEnabled( FALSE ) +{ +} + +// virtual +LLViewerTexLayerSet::~LLViewerTexLayerSet() +{ +} + +// Returns TRUE if at least one packet of data has been received for each of the textures that this layerset depends on. +BOOL LLViewerTexLayerSet::isLocalTextureDataAvailable() const +{ + if (!mAvatarAppearance->isSelf()) return FALSE; + return getAvatar()->isLocalTextureDataAvailable(this); +} + + +// Returns TRUE if all of the data for the textures that this layerset depends on have arrived. +BOOL LLViewerTexLayerSet::isLocalTextureDataFinal() const +{ + if (!mAvatarAppearance->isSelf()) return FALSE; + return getAvatar()->isLocalTextureDataFinal(this); +} + +// virtual +void LLViewerTexLayerSet::requestUpdate() +{ + if( mUpdatesEnabled ) + { + createComposite(); + mComposite->requestUpdate(); + } +} + +void LLViewerTexLayerSet::requestUpload() +{ + createComposite(); + mComposite->requestUpload(); +} + +void LLViewerTexLayerSet::cancelUpload() +{ + if(mComposite) + { + mComposite->cancelUpload(); + } +} + +void LLViewerTexLayerSet::createComposite() +{ + if(!mComposite) + { + S32 width = mInfo->getWidth(); + S32 height = mInfo->getHeight(); + // Composite other avatars at reduced resolution + if( !mAvatarAppearance->isSelf() ) + { + llerrs << "composites should not be created for non-self avatars!" << llendl; + } + mComposite = new LLTexLayerSetBuffer( this, width, height ); + } +} + +void LLViewerTexLayerSet::destroyComposite() +{ + if( mComposite ) + { + mComposite = NULL; + } +} + +void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b ) +{ + mUpdatesEnabled = b; +} + +void LLViewerTexLayerSet::updateComposite() +{ + createComposite(); + mComposite->requestUpdateImmediate(); +} +LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() +{ + if (!mComposite) + { + createComposite(); + } + return mComposite; +} +const LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() const +{ + return mComposite; +} + +void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) +{ + memset(data, 255, width * height); + + for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + layer->gatherAlphaMasks(data, mComposite->getOriginX(),mComposite->getOriginY(), width, height); + } + + // Set alpha back to that of our alpha masks. + renderAlphaMaskTextures(mComposite->getOriginX(), mComposite->getOriginY(), width, height, true); +} + + +LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() const +{ + return dynamic_cast (mAvatarAppearance); +} + + + +const std::string LLTexLayerSetBuffer::dumpTextureInfo() const +{ + if (!isAgentAvatarValid()) return ""; + + const BOOL is_high_res = !mNeedsUpload; + const U32 num_low_res = mNumLowresUploads; + const U32 upload_time = (U32)mNeedsUploadTimer.getElapsedTimeF32(); + const std::string local_texture_info = gAgentAvatarp->debugDumpLocalTextureDataInfo(mTexLayerSet); + + std::string status = "CREATING "; + if (!uploadNeeded()) status = "DONE "; + if (uploadInProgress()) status = "UPLOADING"; + + std::string text = llformat("[%s] [HiRes:%d LoRes:%d] [Elapsed:%d] %s", + status.c_str(), + is_high_res, num_low_res, + upload_time, + local_texture_info.c_str()); + return text; +} -- cgit v1.2.3 From 21c364c4d455cc05ec176032e8c090be0cc4ed50 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Mon, 3 Sep 2012 09:10:24 +0000 Subject: Renamed LLVOAvatarDefines to LLAvatarAppearanceDefines --- indra/newview/llviewertexlayer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index 3a3cae4047..051aa41ed1 100644 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -212,7 +212,7 @@ BOOL LLTexLayerSetBuffer::needsRender() } // Don't render if we are trying to create a shirt texture but aren't wearing a skirt. - if (gAgentAvatarp->getBakedTE(mTexLayerSet) == LLVOAvatarDefines::TEX_SKIRT_BAKED && + if (gAgentAvatarp->getBakedTE(mTexLayerSet) == LLAvatarAppearanceDefines::TEX_SKIRT_BAKED && !gAgentAvatarp->isWearingWearableType(LLWearableType::WT_SKIRT)) { cancelUpload(); @@ -627,7 +627,7 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, if (result >= 0) { layerset_buffer->mUploadPending = FALSE; // Allows sending of AgentSetAppearance later - LLVOAvatarDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->mTexLayerSet); + LLAvatarAppearanceDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->mTexLayerSet); // Update baked texture info with the new UUID U64 now = LLFrameTimer::getTotalTime(); // Record starting time llinfos << "Baked" << resolution << "texture upload for " << name << " took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << llendl; -- cgit v1.2.3 From 204be2ba5261d794f8264e004b65725450bf1be9 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Tue, 4 Sep 2012 15:18:15 +0000 Subject: Split LLTexLayerSetBuffer into llappearance portion, and viewer-specific LLViewerTexLayerSetBuffer --- indra/newview/llviewertexlayer.cpp | 260 +++++++++++++++---------------------- 1 file changed, 102 insertions(+), 158 deletions(-) (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index 051aa41ed1..69457ab1db 100644 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -63,33 +63,33 @@ LLBakedUploadData::LLBakedUploadData(const LLVOAvatarSelf* avatar, } //----------------------------------------------------------------------------- -// LLTexLayerSetBuffer +// LLViewerTexLayerSetBuffer // The composite image that a LLViewerTexLayerSet writes to. Each LLViewerTexLayerSet has one. //----------------------------------------------------------------------------- // static -S32 LLTexLayerSetBuffer::sGLByteCount = 0; +S32 LLViewerTexLayerSetBuffer::sGLByteCount = 0; -LLTexLayerSetBuffer::LLTexLayerSetBuffer(LLViewerTexLayerSet* const owner, +LLViewerTexLayerSetBuffer::LLViewerTexLayerSetBuffer(LLTexLayerSet* const owner, S32 width, S32 height) : // ORDER_LAST => must render these after the hints are created. + LLTexLayerSetBuffer(owner), LLViewerDynamicTexture( width, height, 4, LLViewerDynamicTexture::ORDER_LAST, TRUE ), mUploadPending(FALSE), // Not used for any logic here, just to sync sending of updates mNeedsUpload(FALSE), mNumLowresUploads(0), mUploadFailCount(0), mNeedsUpdate(TRUE), - mNumLowresUpdates(0), - mTexLayerSet(owner) + mNumLowresUpdates(0) { - LLTexLayerSetBuffer::sGLByteCount += getSize(); + LLViewerTexLayerSetBuffer::sGLByteCount += getSize(); mNeedsUploadTimer.start(); mNeedsUpdateTimer.start(); } -LLTexLayerSetBuffer::~LLTexLayerSetBuffer() +LLViewerTexLayerSetBuffer::~LLViewerTexLayerSetBuffer() { - LLTexLayerSetBuffer::sGLByteCount -= getSize(); + LLViewerTexLayerSetBuffer::sGLByteCount -= getSize(); destroyGLTexture(); for( S32 order = 0; order < ORDER_COUNT; order++ ) { @@ -98,30 +98,30 @@ LLTexLayerSetBuffer::~LLTexLayerSetBuffer() } //virtual -S8 LLTexLayerSetBuffer::getType() const +S8 LLViewerTexLayerSetBuffer::getType() const { return LLViewerDynamicTexture::LL_TEX_LAYER_SET_BUFFER ; } //virtual -void LLTexLayerSetBuffer::restoreGLTexture() +void LLViewerTexLayerSetBuffer::restoreGLTexture() { LLViewerDynamicTexture::restoreGLTexture() ; } //virtual -void LLTexLayerSetBuffer::destroyGLTexture() +void LLViewerTexLayerSetBuffer::destroyGLTexture() { LLViewerDynamicTexture::destroyGLTexture() ; } // static -void LLTexLayerSetBuffer::dumpTotalByteCount() +void LLViewerTexLayerSetBuffer::dumpTotalByteCount() { - llinfos << "Composite System GL Buffers: " << (LLTexLayerSetBuffer::sGLByteCount/1024) << "KB" << llendl; + llinfos << "Composite System GL Buffers: " << (LLViewerTexLayerSetBuffer::sGLByteCount/1024) << "KB" << llendl; } -void LLTexLayerSetBuffer::requestUpdate() +void LLViewerTexLayerSetBuffer::requestUpdate() { restartUpdateTimer(); mNeedsUpdate = TRUE; @@ -131,7 +131,7 @@ void LLTexLayerSetBuffer::requestUpdate() mUploadID.setNull(); } -void LLTexLayerSetBuffer::requestUpload() +void LLViewerTexLayerSetBuffer::requestUpload() { conditionalRestartUploadTimer(); mNeedsUpload = TRUE; @@ -139,7 +139,7 @@ void LLTexLayerSetBuffer::requestUpload() mUploadPending = TRUE; } -void LLTexLayerSetBuffer::conditionalRestartUploadTimer() +void LLViewerTexLayerSetBuffer::conditionalRestartUploadTimer() { // If we requested a new upload but haven't even uploaded // a low res version of our last upload request, then @@ -155,13 +155,13 @@ void LLTexLayerSetBuffer::conditionalRestartUploadTimer() } } -void LLTexLayerSetBuffer::restartUpdateTimer() +void LLViewerTexLayerSetBuffer::restartUpdateTimer() { mNeedsUpdateTimer.reset(); mNeedsUpdateTimer.start(); } -void LLTexLayerSetBuffer::cancelUpload() +void LLViewerTexLayerSetBuffer::cancelUpload() { mNeedsUpload = FALSE; mUploadPending = FALSE; @@ -169,29 +169,8 @@ void LLTexLayerSetBuffer::cancelUpload() mUploadRetryTimer.reset(); } -void LLTexLayerSetBuffer::pushProjection() const -{ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); -} - -void LLTexLayerSetBuffer::popProjection() const -{ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); -} - // virtual -BOOL LLTexLayerSetBuffer::needsRender() +BOOL LLViewerTexLayerSetBuffer::needsRender() { llassert(mTexLayerSet->getAvatarAppearance() == gAgentAvatarp); if (!isAgentAvatarValid()) return FALSE; @@ -212,7 +191,7 @@ BOOL LLTexLayerSetBuffer::needsRender() } // Don't render if we are trying to create a shirt texture but aren't wearing a skirt. - if (gAgentAvatarp->getBakedTE(mTexLayerSet) == LLAvatarAppearanceDefines::TEX_SKIRT_BAKED && + if (gAgentAvatarp->getBakedTE(getViewerTexLayerSet()) == LLAvatarAppearanceDefines::TEX_SKIRT_BAKED && !gAgentAvatarp->isWearingWearableType(LLWearableType::WT_SKIRT)) { cancelUpload(); @@ -220,51 +199,36 @@ BOOL LLTexLayerSetBuffer::needsRender() } // Render if we have at least minimal level of detail for each local texture. - return mTexLayerSet->isLocalTextureDataAvailable(); + return getViewerTexLayerSet()->isLocalTextureDataAvailable(); } -void LLTexLayerSetBuffer::preRender(BOOL clear_depth) +// virtual +void LLViewerTexLayerSetBuffer::preRenderTexLayerSet() { - // Set up an ortho projection - pushProjection(); + LLTexLayerSetBuffer::preRenderTexLayerSet(); // keep depth buffer, we don't need to clear it LLViewerDynamicTexture::preRender(FALSE); } -void LLTexLayerSetBuffer::postRender(BOOL success) +// virtual +void LLViewerTexLayerSetBuffer::postRenderTexLayerSet(BOOL success) { - popProjection(); + // *TODO: Old logic does not check success before setGLTextureCreated + // we have valid texture data now + mGLTexturep->setGLTextureCreated(true); + LLTexLayerSetBuffer::postRenderTexLayerSet(success); LLViewerDynamicTexture::postRender(success); } -BOOL LLTexLayerSetBuffer::render() +// virtual +void LLViewerTexLayerSetBuffer::midRenderTexLayerSet(BOOL success) { - // Default color mask for tex layer render - gGL.setColorMask(true, true); - // do we need to upload, and do we have sufficient data to create an uploadable composite? // TODO: When do we upload the texture if gAgent.mNumPendingQueries is non-zero? const BOOL upload_now = mNeedsUpload && isReadyToUpload(); const BOOL update_now = mNeedsUpdate && isReadyToUpdate(); - - BOOL success = TRUE; - - bool use_shaders = LLGLSLShader::sNoFixedFunction; - - if (use_shaders) - { - gAlphaMaskProgram.bind(); - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - - LLVertexBuffer::unbind(); - - // Composite the color data - LLGLSUIDefault gls_ui; - success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight ); - gGL.flush(); if(upload_now) { @@ -275,9 +239,10 @@ BOOL LLTexLayerSetBuffer::render() } else { - if (mTexLayerSet->isVisible()) + LLViewerTexLayerSet* layer_set = getViewerTexLayerSet(); + if (layer_set->isVisible()) { - mTexLayerSet->getAvatar()->debugBakedTextureUpload(mTexLayerSet->getBakedTexIndex(), FALSE); // FALSE for start of upload, TRUE for finish. + layer_set->getAvatar()->debugBakedTextureUpload(layer_set->getBakedTexIndex(), FALSE); // FALSE for start of upload, TRUE for finish. doUpload(); } else @@ -285,7 +250,7 @@ BOOL LLTexLayerSetBuffer::render() mUploadPending = FALSE; mNeedsUpload = FALSE; mNeedsUploadTimer.pause(); - mTexLayerSet->getAvatar()->setNewBakedTexture(mTexLayerSet->getBakedTexIndex(),IMG_INVISIBLE); + layer_set->getAvatar()->setNewBakedTexture(layer_set->getBakedTexIndex(),IMG_INVISIBLE); } } } @@ -294,51 +259,35 @@ BOOL LLTexLayerSetBuffer::render() { doUpdate(); } - - if (use_shaders) - { - gAlphaMaskProgram.unbind(); - } - - LLVertexBuffer::unbind(); - - // reset GL state - gGL.setColorMask(true, true); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - // we have valid texture data now - mGLTexturep->setGLTextureCreated(true); - - return success; } -BOOL LLTexLayerSetBuffer::isInitialized(void) const +BOOL LLViewerTexLayerSetBuffer::isInitialized(void) const { return mGLTexturep.notNull() && mGLTexturep->isGLTextureCreated(); } -BOOL LLTexLayerSetBuffer::uploadPending() const +BOOL LLViewerTexLayerSetBuffer::uploadPending() const { return mUploadPending; } -BOOL LLTexLayerSetBuffer::uploadNeeded() const +BOOL LLViewerTexLayerSetBuffer::uploadNeeded() const { return mNeedsUpload; } -BOOL LLTexLayerSetBuffer::uploadInProgress() const +BOOL LLViewerTexLayerSetBuffer::uploadInProgress() const { return !mUploadID.isNull(); } -BOOL LLTexLayerSetBuffer::isReadyToUpload() const +BOOL LLViewerTexLayerSetBuffer::isReadyToUpload() const { if (!gAgentQueryManager.hasNoPendingQueries()) return FALSE; // Can't upload if there are pending queries. if (isAgentAvatarValid() && !gAgentAvatarp->isUsingBakedTextures()) return FALSE; // Don't upload if avatar is using composites. BOOL ready = FALSE; - if (mTexLayerSet->isLocalTextureDataFinal()) + if (getViewerTexLayerSet()->isLocalTextureDataFinal()) { // If we requested an upload and have the final LOD ready, upload (or wait a while if this is a retry) if (mUploadFailCount == 0) @@ -363,7 +312,7 @@ BOOL LLTexLayerSetBuffer::isReadyToUpload() const // If we hit our timeout and have textures available at even lower resolution, then upload. const BOOL is_upload_textures_timeout = mNeedsUploadTimer.getElapsedTimeF32() >= texture_timeout_threshold; - const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable(); + const BOOL has_lower_lod = getViewerTexLayerSet()->isLocalTextureDataAvailable(); ready = has_lower_lod && is_upload_textures_timeout; } } @@ -371,10 +320,10 @@ BOOL LLTexLayerSetBuffer::isReadyToUpload() const return ready; } -BOOL LLTexLayerSetBuffer::isReadyToUpdate() const +BOOL LLViewerTexLayerSetBuffer::isReadyToUpdate() const { // If we requested an update and have the final LOD ready, then update. - if (mTexLayerSet->isLocalTextureDataFinal()) return TRUE; + if (getViewerTexLayerSet()->isLocalTextureDataFinal()) return TRUE; // If we haven't done an update yet, then just do one now regardless of state of textures. if (mNumLowresUpdates == 0) return TRUE; @@ -386,14 +335,14 @@ BOOL LLTexLayerSetBuffer::isReadyToUpdate() const { // If we hit our timeout and have textures available at even lower resolution, then update. const BOOL is_update_textures_timeout = mNeedsUpdateTimer.getElapsedTimeF32() >= texture_timeout; - const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable(); + const BOOL has_lower_lod = getViewerTexLayerSet()->isLocalTextureDataAvailable(); if (has_lower_lod && is_update_textures_timeout) return TRUE; } return FALSE; } -BOOL LLTexLayerSetBuffer::requestUpdateImmediate() +BOOL LLViewerTexLayerSetBuffer::requestUpdateImmediate() { mNeedsUpdate = TRUE; BOOL result = FALSE; @@ -410,14 +359,15 @@ BOOL LLTexLayerSetBuffer::requestUpdateImmediate() // Create the baked texture, send it out to the server, then wait for it to come // back so we can switch to using it. -void LLTexLayerSetBuffer::doUpload() +void LLViewerTexLayerSetBuffer::doUpload() { - llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl; + LLViewerTexLayerSet* layer_set = getViewerTexLayerSet(); + llinfos << "Uploading baked " << layer_set->getBodyRegionName() << llendl; LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES); // Don't need caches since we're baked now. (note: we won't *really* be baked // until this image is sent to the server and the Avatar Appearance message is received.) - mTexLayerSet->deleteCaches(); + layer_set->deleteCaches(); // Get the COLOR information from our texture U8* baked_color_data = new U8[ mFullWidth * mFullHeight * 4 ]; @@ -428,7 +378,7 @@ void LLTexLayerSetBuffer::doUpload() LLGLSUIDefault gls_ui; LLPointer baked_mask_image = new LLImageRaw(mFullWidth, mFullHeight, 1 ); U8* baked_mask_data = baked_mask_image->getData(); - mTexLayerSet->gatherMorphMaskAlpha(baked_mask_data, mFullWidth, mFullHeight); + layer_set->gatherMorphMaskAlpha(baked_mask_data, mFullWidth, mFullHeight); // Create the baked image from our color and mask information @@ -475,10 +425,10 @@ void LLTexLayerSetBuffer::doUpload() if (valid) { - const bool highest_lod = mTexLayerSet->isLocalTextureDataFinal(); + const bool highest_lod = layer_set->isLocalTextureDataFinal(); // Baked_upload_data is owned by the responder and deleted after the request completes. LLBakedUploadData* baked_upload_data = new LLBakedUploadData(gAgentAvatarp, - this->mTexLayerSet, + layer_set, asset_id, highest_lod); // upload ID is used to avoid overlaps, e.g. when the user rapidly makes two changes outside of Face Edit. @@ -491,7 +441,7 @@ void LLTexLayerSetBuffer::doUpload() && (mUploadFailCount < (BAKE_UPLOAD_ATTEMPTS - 1))) // Try last ditch attempt via asset store if cap upload is failing. { LLSD body = LLSD::emptyMap(); - // The responder will call LLTexLayerSetBuffer::onTextureUploadComplete() + // The responder will call LLViewerTexLayerSetBuffer::onTextureUploadComplete() LLHTTPClient::post(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data)); llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl; } @@ -499,7 +449,7 @@ void LLTexLayerSetBuffer::doUpload() { gAssetStorage->storeAssetData(tid, LLAssetType::AT_TEXTURE, - LLTexLayerSetBuffer::onTextureUploadComplete, + LLViewerTexLayerSetBuffer::onTextureUploadComplete, baked_upload_data, TRUE, // temp_file TRUE, // is_priority @@ -527,12 +477,12 @@ void LLTexLayerSetBuffer::doUpload() { const std::string lod_str = highest_lod ? "HighRes" : "LowRes"; LLSD args; - args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatar()->debugGetExistenceTimeElapsedF32()); + args["EXISTENCE"] = llformat("%d",(U32)layer_set->getAvatar()->debugGetExistenceTimeElapsedF32()); args["TIME"] = llformat("%d",(U32)mNeedsUploadTimer.getElapsedTimeF32()); - args["BODYREGION"] = mTexLayerSet->getBodyRegionName(); + args["BODYREGION"] = layer_set->getBodyRegionName(); args["RESOLUTION"] = lod_str; LLNotificationsUtil::add("AvatarRezSelfBakedTextureUploadNotification",args); - LL_DEBUGS("Avatar") << self_av_string() << "Uploading [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUploadTimer.getElapsedTimeF32() << " ]" << LL_ENDL; + LL_DEBUGS("Avatar") << self_av_string() << "Uploading [ name: " << layer_set->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUploadTimer.getElapsedTimeF32() << " ]" << LL_ENDL; } } else @@ -557,9 +507,10 @@ void LLTexLayerSetBuffer::doUpload() // Mostly bookkeeping; don't need to actually "do" anything since // render() will actually do the update. -void LLTexLayerSetBuffer::doUpdate() +void LLViewerTexLayerSetBuffer::doUpdate() { - const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal(); + LLViewerTexLayerSet* layer_set = getViewerTexLayerSet(); + const BOOL highest_lod = layer_set->isLocalTextureDataFinal(); if (highest_lod) { mNeedsUpdate = FALSE; @@ -573,25 +524,25 @@ void LLTexLayerSetBuffer::doUpdate() // need to switch to using this layerset if this is the first update // after getting the lowest LOD - mTexLayerSet->getAvatar()->updateMeshTextures(); + layer_set->getAvatar()->updateMeshTextures(); // Print out notification that we updated this texture. if (gSavedSettings.getBOOL("DebugAvatarRezTime")) { - const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal(); + const BOOL highest_lod = layer_set->isLocalTextureDataFinal(); const std::string lod_str = highest_lod ? "HighRes" : "LowRes"; LLSD args; - args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatar()->debugGetExistenceTimeElapsedF32()); + args["EXISTENCE"] = llformat("%d",(U32)layer_set->getAvatar()->debugGetExistenceTimeElapsedF32()); args["TIME"] = llformat("%d",(U32)mNeedsUpdateTimer.getElapsedTimeF32()); - args["BODYREGION"] = mTexLayerSet->getBodyRegionName(); + args["BODYREGION"] = layer_set->getBodyRegionName(); args["RESOLUTION"] = lod_str; LLNotificationsUtil::add("AvatarRezSelfBakedTextureUpdateNotification",args); - LL_DEBUGS("Avatar") << self_av_string() << "Locally updating [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUpdateTimer.getElapsedTimeF32() << " ]" << LL_ENDL; + LL_DEBUGS("Avatar") << self_av_string() << "Locally updating [ name: " << layer_set->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUpdateTimer.getElapsedTimeF32() << " ]" << LL_ENDL; } } // static -void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, +void LLViewerTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, void* userdata, S32 result, LLExtStat ext_status) // StoreAssetData callback (not fixed) @@ -603,7 +554,7 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, (baked_upload_data->mAvatar == gAgentAvatarp) && // Sanity check: only the user's avatar should be uploading textures. (baked_upload_data->mTexLayerSet->hasComposite())) { - LLTexLayerSetBuffer* layerset_buffer = baked_upload_data->mTexLayerSet->getComposite(); + LLViewerTexLayerSetBuffer* layerset_buffer = baked_upload_data->mTexLayerSet->getViewerComposite(); S32 failures = layerset_buffer->mUploadFailCount; layerset_buffer->mUploadFailCount = 0; @@ -627,7 +578,7 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, if (result >= 0) { layerset_buffer->mUploadPending = FALSE; // Allows sending of AgentSetAppearance later - LLAvatarAppearanceDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->mTexLayerSet); + LLAvatarAppearanceDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->getViewerTexLayerSet()); // Update baked texture info with the new UUID U64 now = LLFrameTimer::getTotalTime(); // Record starting time llinfos << "Baked" << resolution << "texture upload for " << name << " took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << llendl; @@ -673,7 +624,6 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, LLViewerTexLayerSet::LLViewerTexLayerSet(LLAvatarAppearance* const appearance) : LLTexLayerSet(appearance), - mComposite( NULL ), mUpdatesEnabled( FALSE ) { } @@ -704,24 +654,31 @@ void LLViewerTexLayerSet::requestUpdate() if( mUpdatesEnabled ) { createComposite(); - mComposite->requestUpdate(); + getViewerComposite()->requestUpdate(); } } void LLViewerTexLayerSet::requestUpload() { createComposite(); - mComposite->requestUpload(); + getViewerComposite()->requestUpload(); } void LLViewerTexLayerSet::cancelUpload() { if(mComposite) { - mComposite->cancelUpload(); + getViewerComposite()->cancelUpload(); } } +void LLViewerTexLayerSet::updateComposite() +{ + createComposite(); + getViewerComposite()->requestUpdateImmediate(); +} + +// virtual void LLViewerTexLayerSet::createComposite() { if(!mComposite) @@ -733,15 +690,7 @@ void LLViewerTexLayerSet::createComposite() { llerrs << "composites should not be created for non-self avatars!" << llendl; } - mComposite = new LLTexLayerSetBuffer( this, width, height ); - } -} - -void LLViewerTexLayerSet::destroyComposite() -{ - if( mComposite ) - { - mComposite = NULL; + mComposite = new LLViewerTexLayerSetBuffer( this, width, height ); } } @@ -751,26 +700,6 @@ void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b ) } -void LLViewerTexLayerSet::updateComposite() -{ - createComposite(); - mComposite->requestUpdateImmediate(); -} - -LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() -{ - if (!mComposite) - { - createComposite(); - } - return mComposite; -} - -const LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() const -{ - return mComposite; -} - void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) { memset(data, 255, width * height); @@ -778,29 +707,44 @@ void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) { LLTexLayerInterface* layer = *iter; - layer->gatherAlphaMasks(data, mComposite->getOriginX(),mComposite->getOriginY(), width, height); + layer->gatherAlphaMasks(data, getViewerComposite()->getOriginX(), + getViewerComposite()->getOriginY(), width, height); } // Set alpha back to that of our alpha masks. - renderAlphaMaskTextures(mComposite->getOriginX(), mComposite->getOriginY(), width, height, true); + renderAlphaMaskTextures(getViewerComposite()->getOriginX(), + getViewerComposite()->getOriginY(), width, height, true); } - -LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() const +LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() { return dynamic_cast (mAvatarAppearance); } +const LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() const +{ + return dynamic_cast (mAvatarAppearance); +} + +LLViewerTexLayerSetBuffer* LLViewerTexLayerSet::getViewerComposite() +{ + return dynamic_cast (getComposite()); +} + +const LLViewerTexLayerSetBuffer* LLViewerTexLayerSet::getViewerComposite() const +{ + return dynamic_cast (getComposite()); +} -const std::string LLTexLayerSetBuffer::dumpTextureInfo() const +const std::string LLViewerTexLayerSetBuffer::dumpTextureInfo() const { if (!isAgentAvatarValid()) return ""; const BOOL is_high_res = !mNeedsUpload; const U32 num_low_res = mNumLowresUploads; const U32 upload_time = (U32)mNeedsUploadTimer.getElapsedTimeF32(); - const std::string local_texture_info = gAgentAvatarp->debugDumpLocalTextureDataInfo(mTexLayerSet); + const std::string local_texture_info = gAgentAvatarp->debugDumpLocalTextureDataInfo(getViewerTexLayerSet()); std::string status = "CREATING "; if (!uploadNeeded()) status = "DONE "; -- cgit v1.2.3 From 41301004e13bec1c74f444f42372a3a6609cb305 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Tue, 4 Sep 2012 22:49:26 +0000 Subject: Cleanup actions from code review of llappearance with nyx --- indra/newview/llviewertexlayer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index 69457ab1db..f516562c2f 100644 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -214,9 +214,6 @@ void LLViewerTexLayerSetBuffer::preRenderTexLayerSet() // virtual void LLViewerTexLayerSetBuffer::postRenderTexLayerSet(BOOL success) { - // *TODO: Old logic does not check success before setGLTextureCreated - // we have valid texture data now - mGLTexturep->setGLTextureCreated(true); LLTexLayerSetBuffer::postRenderTexLayerSet(success); LLViewerDynamicTexture::postRender(success); @@ -259,6 +256,10 @@ void LLViewerTexLayerSetBuffer::midRenderTexLayerSet(BOOL success) { doUpdate(); } + + // *TODO: Old logic does not check success before setGLTextureCreated + // we have valid texture data now + mGLTexturep->setGLTextureCreated(true); } BOOL LLViewerTexLayerSetBuffer::isInitialized(void) const -- cgit v1.2.3 From ae0bb922909af95d96c140c1d74a4f39a264d4ec Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 26 Sep 2012 06:36:24 -0400 Subject: renamed isUsingBakedTextures to more accurate isUsingServerBakes. Commented some areas we are probably using the function incorrectly --- indra/newview/llviewertexlayer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index f516562c2f..463906d3ef 100644 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -285,7 +285,8 @@ BOOL LLViewerTexLayerSetBuffer::uploadInProgress() const BOOL LLViewerTexLayerSetBuffer::isReadyToUpload() const { if (!gAgentQueryManager.hasNoPendingQueries()) return FALSE; // Can't upload if there are pending queries. - if (isAgentAvatarValid() && !gAgentAvatarp->isUsingBakedTextures()) return FALSE; // Don't upload if avatar is using composites. + // FIXME DRANO + if (isAgentAvatarValid() && !gAgentAvatarp->isUsingServerBakes()) return FALSE; // Don't upload if avatar is using composites. BOOL ready = FALSE; if (getViewerTexLayerSet()->isLocalTextureDataFinal()) -- cgit v1.2.3 From ab83fab72c66e753917001a9030aa55e69a3c496 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 26 Sep 2012 11:52:19 -0400 Subject: error checking, comments for areas needing fix/check in appearance --- indra/newview/llviewertexlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 indra/newview/llviewertexlayer.cpp (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp old mode 100644 new mode 100755 index 463906d3ef..9477e89f1c --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -285,7 +285,7 @@ BOOL LLViewerTexLayerSetBuffer::uploadInProgress() const BOOL LLViewerTexLayerSetBuffer::isReadyToUpload() const { if (!gAgentQueryManager.hasNoPendingQueries()) return FALSE; // Can't upload if there are pending queries. - // FIXME DRANO + // FIXME DRANO - should be checking local appearance? if (isAgentAvatarValid() && !gAgentAvatarp->isUsingServerBakes()) return FALSE; // Don't upload if avatar is using composites. BOOL ready = FALSE; -- cgit v1.2.3 From 93e210d91f521b01deb10aa6aa25160364e6ae28 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 26 Sep 2012 15:45:58 -0400 Subject: more state management stuff, DRANO flags for problematic areas --- indra/newview/llviewertexlayer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index 9477e89f1c..b129c28e0d 100755 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -285,8 +285,7 @@ BOOL LLViewerTexLayerSetBuffer::uploadInProgress() const BOOL LLViewerTexLayerSetBuffer::isReadyToUpload() const { if (!gAgentQueryManager.hasNoPendingQueries()) return FALSE; // Can't upload if there are pending queries. - // FIXME DRANO - should be checking local appearance? - if (isAgentAvatarValid() && !gAgentAvatarp->isUsingServerBakes()) return FALSE; // Don't upload if avatar is using composites. + if (isAgentAvatarValid() && gAgentAvatarp->isEditingAppearance()) return FALSE; // Don't upload if avatar is being edited. BOOL ready = FALSE; if (getViewerTexLayerSet()->isLocalTextureDataFinal()) -- cgit v1.2.3 From 5483bc28ae6b33bf5b2371d46648ad20975daf8c Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Tue, 2 Oct 2012 01:02:34 +0000 Subject: Moved gatherMorphMaskAlpha into llappearance. --- indra/newview/llviewertexlayer.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index b129c28e0d..cd5e781d71 100755 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -379,7 +379,9 @@ void LLViewerTexLayerSetBuffer::doUpload() LLGLSUIDefault gls_ui; LLPointer baked_mask_image = new LLImageRaw(mFullWidth, mFullHeight, 1 ); U8* baked_mask_data = baked_mask_image->getData(); - layer_set->gatherMorphMaskAlpha(baked_mask_data, mFullWidth, mFullHeight); + layer_set->gatherMorphMaskAlpha(baked_mask_data, + mOrigin.mX, mOrigin.mY, + mFullWidth, mFullHeight); // Create the baked image from our color and mask information @@ -700,23 +702,6 @@ void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b ) mUpdatesEnabled = b; } - -void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) -{ - memset(data, 255, width * height); - - for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - LLTexLayerInterface* layer = *iter; - layer->gatherAlphaMasks(data, getViewerComposite()->getOriginX(), - getViewerComposite()->getOriginY(), width, height); - } - - // Set alpha back to that of our alpha masks. - renderAlphaMaskTextures(getViewerComposite()->getOriginX(), - getViewerComposite()->getOriginY(), width, height, true); -} - LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() { return dynamic_cast (mAvatarAppearance); -- cgit v1.2.3 From 07d05c2967fb1013a3f21c1c055ad068b2be9995 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Thu, 6 Dec 2012 22:54:50 +0000 Subject: Alpha rendering fixes for appearance utility. --- indra/newview/llviewertexlayer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index cd5e781d71..f3c9921819 100755 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -416,7 +416,10 @@ void LLViewerTexLayerSetBuffer::doUpload() BOOL valid = FALSE; LLPointer integrity_test = new LLImageJ2C; S32 file_size = 0; - U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size); + LLVFile file(gVFS, asset_id, LLAssetType::AT_TEXTURE); + file_size = file.getSize(); + U8* data = integrity_test->allocateData(file_size); + file.read(data, file_size); if (data) { valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data' -- cgit v1.2.3 From d1d0a2cf67e3ddd7bd187c63b9ce79e0c19988d6 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 3 Apr 2013 14:58:33 -0400 Subject: SH-4058 - log spam reduction initiative. --- indra/newview/llviewertexlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 indra/newview/llviewertexlayer.cpp (limited to 'indra/newview/llviewertexlayer.cpp') diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp old mode 100644 new mode 100755 index f3c9921819..777e1f9c76 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -363,7 +363,7 @@ BOOL LLViewerTexLayerSetBuffer::requestUpdateImmediate() void LLViewerTexLayerSetBuffer::doUpload() { LLViewerTexLayerSet* layer_set = getViewerTexLayerSet(); - llinfos << "Uploading baked " << layer_set->getBodyRegionName() << llendl; + LL_DEBUGS("Avatar") << "Uploading baked " << layer_set->getBodyRegionName() << llendl; LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES); // Don't need caches since we're baked now. (note: we won't *really* be baked -- cgit v1.2.3