diff options
Diffstat (limited to 'indra/newview/lltexlayer.cpp')
-rw-r--r-- | indra/newview/lltexlayer.cpp | 162 |
1 files changed, 91 insertions, 71 deletions
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index 1d74a7be8c..5d51e32515 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -165,6 +165,7 @@ void LLTexLayerSetBuffer::dumpTotalByteCount() void LLTexLayerSetBuffer::requestUpdate() { + conditionalRestartUploadTimer(); mNeedsUpdate = TRUE; // 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. @@ -173,17 +174,26 @@ void LLTexLayerSetBuffer::requestUpdate() 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(); } - mNeedsUpload = TRUE; - mNumLowresUploads = 0; - mUploadPending = TRUE; - mNeedsUploadTimer.unpause(); } void LLTexLayerSetBuffer::cancelUpload() @@ -307,11 +317,26 @@ BOOL LLTexLayerSetBuffer::render() return success; } -bool LLTexLayerSetBuffer::isInitialized(void) const +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 (!mNeedsUpload) return FALSE; // Don't need to upload if we haven't requested one. @@ -353,40 +378,33 @@ BOOL LLTexLayerSetBuffer::updateImmediate() void LLTexLayerSetBuffer::readBackAndUpload() { - // pointers for storing data to upload - 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(); - - llinfos << "Baked " << mTexLayerSet->getBodyRegionName() << llendl; + llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl; LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES); - // We won't need our caches since we're baked now. (Techically, we won't - // really be baked until this image is sent to the server and the Avatar - // Appearance message is received.) + // 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(); - LLGLSUIDefault gls_ui; + // 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<LLImageRaw> baked_mask_image = new LLImageRaw(mFullWidth, mFullHeight, 1 ); U8* baked_mask_data = baked_mask_image->getData(); - mTexLayerSet->gatherMorphMaskAlpha(baked_mask_data, mFullWidth, mFullHeight); - // writes into baked_color_data - const char* comment_text = NULL; - S32 baked_image_components = 5; // red green blue [bump] clothing + // Create the baked image from our color and mask information + const S32 baked_image_components = 5; // red green blue [bump] clothing LLPointer<LLImageRaw> baked_image = new LLImageRaw( mFullWidth, mFullHeight, baked_image_components ); U8* baked_image_data = baked_image->getData(); - - comment_text = LINDEN_J2C_COMMENT_PREFIX "RGBHM"; // 5 channels: rgb, heightfield/alpha, mask - S32 i = 0; - for( S32 u = 0; u < mFullWidth; u++ ) + for (S32 u=0; u < mFullWidth; u++) { - for( S32 v = 0; v < mFullHeight; v++ ) + 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]; @@ -399,21 +417,19 @@ void LLTexLayerSetBuffer::readBackAndUpload() LLPointer<LLImageJ2C> compressedImage = new LLImageJ2C; compressedImage->setRate(0.f); - LLTransactionID tid; - LLAssetID asset_id; - tid.generate(); - asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - - BOOL res = false; - if( compressedImage->encode(baked_image, comment_text)) + 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)) { - res = LLVFile::writeFile(compressedImage->getData(), compressedImage->getDataSize(), - gVFS, asset_id, LLAssetType::AT_TEXTURE); - if (res) + 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)) { - LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C; + // Read back the file and validate. BOOL valid = FALSE; - S32 file_size; + LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C; + S32 file_size = 0; U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size); if (data) { @@ -424,31 +440,26 @@ void LLTexLayerSetBuffer::readBackAndUpload() integrity_test->setLastError("Unable to read entire file"); } - if( valid ) + if (valid) { - // baked_upload_data is owned by the responder and deleted after the request completes + // 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); mUploadID = asset_id; - const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal(); - - // upload the image - std::string url = gAgent.getRegion()->getCapability("UploadBakedTexture"); + // Upload the image + const std::string url = gAgent.getRegion()->getCapability("UploadBakedTexture"); if(!url.empty() - && !LLPipeline::sForceOldBakedUpload) // Toggle the debug setting UploadBakedTexOld to change between the new caps method and old method + && !LLPipeline::sForceOldBakedUpload) // toggle debug setting UploadBakedTexOld to change between the new caps method and old method { - llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl; - LLSD body = LLSD::emptyMap(); + // The responder will call LLTexLayerSetBuffer::onTextureUploadComplete() LLHTTPClient::post(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data)); - // Responder will call LLTexLayerSetBuffer::onTextureUploadComplete() + llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl; } else { - llinfos << "Baked texture upload via Asset Store." << llendl; - // gAssetStorage->storeAssetData(mTransactionID, LLAssetType::AT_IMAGE_JPEG, &uploadCallback, (void *)this, FALSE); gAssetStorage->storeAssetData(tid, LLAssetType::AT_TEXTURE, LLTexLayerSetBuffer::onTextureUploadComplete, @@ -456,49 +467,53 @@ void LLTexLayerSetBuffer::readBackAndUpload() TRUE, // temp_file TRUE, // is_priority TRUE); // store_local + llinfos << "Baked texture upload via Asset Store." << llendl; } - if (gSavedSettings.getBOOL("DebugAvatarRezTime")) - { - 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("AvatarRezSelfBakeNotification",args); - llinfos << "Uploading [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUploadTimer.getElapsedTimeF32() << " ]" << llendl; - } - + const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal(); if (highest_lod) { - // Sending the final LOD for the baked texture. - // All done, pause the upload timer so we know how long it took. + // 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. + // 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")) + { + 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("AvatarRezSelfBakeNotification",args); + llinfos << "Uploading [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUploadTimer.getElapsedTimeF32() << " ]" << llendl; + } } else { + // The read back and validate operation failed. Remove the uploaded file. mUploadPending = FALSE; - llinfos << "unable to create baked upload file: corrupted" << llendl; LLVFile file(gVFS, asset_id, LLAssetType::AT_TEXTURE, LLVFile::WRITE); file.remove(); + llinfos << "Unable to create baked upload file (reason: corrupted)." << llendl; } } } - if (!res) + else { + // The VFS write file operation failed. mUploadPending = FALSE; - llinfos << "unable to create baked upload file" << llendl; + llinfos << "Unable to create baked upload file (reason: failed to write file)" << llendl; } delete [] baked_color_data; @@ -2277,10 +2292,15 @@ const std::string LLTexLayerSetBuffer::dumpTextureInfo() const const BOOL is_high_res = !mNeedsUpload; const U32 num_low_res = mNumLowresUploads; const U32 upload_time = (U32)mNeedsUploadTimer.getElapsedTimeF32(); - const BOOL is_uploaded = !mUploadPending; const std::string local_texture_info = gAgentAvatarp->debugDumpLocalTextureDataInfo(mTexLayerSet); - std::string text = llformat("[ HiRes:%d LoRes:%d Uploaded:%d ] [ Timer:%d ] %s", - is_high_res, num_low_res, is_uploaded, + + 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; |