From e2f3ea50d57ac530512e0ed77c537f0722198c18 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 14 Feb 2013 10:57:28 -0800 Subject: For MAINT-1291 Re-order cubemap disable and shader tex disable to avoid false alarm when using RenderDebugGL. Code Review: DaveP --- indra/newview/lldrawpoolbump.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 1b0b11298c..079cbe3a21 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -449,9 +449,6 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; if( cube_map ) { - cube_map->disable(); - cube_map->restoreMatrix(); - if (!invisible && shader_level > 1) { shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); @@ -464,6 +461,10 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& } } } + // Placed after shader->disableTex(ENV,TT_CUBE_MAP) above to avoid sequencing false alarm when using RenderDebugGL + // MAINT-1291 + cube_map->disable(); + cube_map->restoreMatrix(); } if (!LLGLSLShader::sNoFixedFunction) -- cgit v1.2.3 From f67087b87277dc63096fbf4c42cdc17f84d3fbb8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 20 Feb 2013 19:30:46 -0600 Subject: MAINT-2370 Add debug setting "RenderAutoMuteRenderCostLimit" that automatically visually mutes avatars above a certain threshold (adjusted by Avatar Mesh Detail Slider) --- indra/llrender/llrender.cpp | 16 ++ indra/llrender/llrender.h | 1 + indra/llrender/llrendertarget.cpp | 6 + indra/llrender/llrendertarget.h | 1 + indra/newview/app_settings/settings.xml | 11 + .../shaders/class1/deferred/avatarF.glsl | 4 +- indra/newview/lldrawpoolavatar.cpp | 182 +++++++-------- indra/newview/lldrawpoolavatar.h | 1 + indra/newview/llface.cpp | 7 + indra/newview/llmeshrepository.cpp | 3 +- indra/newview/llvoavatar.cpp | 258 +++++++++++---------- indra/newview/llvoavatar.h | 3 +- indra/newview/llvovolume.cpp | 6 + indra/newview/pipeline.cpp | 45 +++- .../newview/skins/default/xui/en/notifications.xml | 41 +++- 15 files changed, 343 insertions(+), 242 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 4597d06260..a12e9caf4c 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -2282,6 +2282,22 @@ void LLRender::diffuseColor4ubv(const U8* c) } } +void LLRender::diffuseColor4ub(U8 r, U8 g, U8 b, U8 a) +{ + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL); + + if (shader) + { + shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, r/255.f, g/255.f, b/255.f, a/255.f); + } + else + { + glColor4ub(r,g,b,a); + } +} + + void LLRender::debugTexUnits(void) { LL_INFOS("TextureUnit") << "Active TexUnit: " << mCurrTextureUnitIndex << LL_ENDL; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 78a310e525..90b1ec2f57 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -388,6 +388,7 @@ public: void diffuseColor4f(F32 r, F32 g, F32 b, F32 a); void diffuseColor4fv(const F32* c); void diffuseColor4ubv(const U8* c); + void diffuseColor4ub(U8 r, U8 g, U8 b, U8 a); void vertexBatchPreTransformed(LLVector3* verts, S32 vert_count); void vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count); diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index e35feda2d5..e501d0495b 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -458,6 +458,12 @@ U32 LLRenderTarget::getTexture(U32 attachment) const return mTex[attachment]; } +U32 LLRenderTarget::getNumTextures() const +{ + return mTex.size(); +} + + void LLRenderTarget::bindTexture(U32 index, S32 channel) { gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index)); diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index cf15f66d31..5cff0a0a21 100644 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h @@ -113,6 +113,7 @@ public: LLTexUnit::eTextureType getUsage(void) const { return mUsage; } U32 getTexture(U32 attachment = 0) const; + U32 getNumTextures() const; U32 getDepth(void) const { return mDepth; } bool hasStencil() const { return mStencil; } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index b302f5c9b9..e06b4bbe13 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9169,6 +9169,17 @@ Value 0 + RenderAutoMuteRenderCostLimit + + Comment + Maximum render cost before an avatar is automatically visually muted (0 for no limit). + Persist + 1 + Type + U32 + Value + 0 + RenderAutoMuteSurfaceAreaLimit Comment diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index bfd9b9b3eb..29a6d842d2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl @@ -31,6 +31,8 @@ out vec4 frag_data[3]; uniform sampler2D diffuseMap; +uniform float minimum_alpha; + VARYING vec3 vary_normal; VARYING vec2 vary_texcoord0; @@ -38,7 +40,7 @@ void main() { vec4 diff = texture2D(diffuseMap, vary_texcoord0.xy); - if (diff.a < 0.2) + if (diff.a < minimum_alpha) { discard; } diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 38268b102b..03641140dc 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -59,6 +59,7 @@ LLGLSLShader* LLDrawPoolAvatar::sVertexProgram = NULL; BOOL LLDrawPoolAvatar::sSkipOpaque = FALSE; BOOL LLDrawPoolAvatar::sSkipTransparent = FALSE; S32 LLDrawPoolAvatar::sDiffuseChannel = 0; +F32 LLDrawPoolAvatar::sMinimumAlpha = 0.2f; static bool is_deferred_render = false; @@ -272,7 +273,7 @@ void LLDrawPoolAvatar::beginPostDeferredAlpha() gPipeline.bindDeferredShader(*sVertexProgram); - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); } @@ -620,7 +621,7 @@ void LLDrawPoolAvatar::beginRigid() if (sVertexProgram != NULL) { //eyeballs render with the specular shader sVertexProgram->bind(); - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); } } else @@ -671,7 +672,7 @@ void LLDrawPoolAvatar::beginDeferredRigid() sVertexProgram = &gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram; sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); sVertexProgram->bind(); - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); } void LLDrawPoolAvatar::endDeferredRigid() @@ -729,7 +730,7 @@ void LLDrawPoolAvatar::beginSkinned() if (LLGLSLShader::sNoFixedFunction) { - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); } } @@ -1027,7 +1028,7 @@ void LLDrawPoolAvatar::beginDeferredSkinned() sRenderingSkinned = TRUE; sVertexProgram->bind(); - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gGL.getTexUnit(0)->activate(); @@ -1138,7 +1139,10 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) if (impostor) { - if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && avatarp->mImpostor.isComplete()) + if (LLPipeline::sRenderDeferred && //rendering a deferred impostor + !LLPipeline::sReflectionRender && + avatarp->mImpostor.isComplete() && //impostor has required data channels + avatarp->mImpostor.getNumTextures() >= 3) { if (normal_channel > -1) { @@ -1151,113 +1155,95 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) } avatarp->renderImpostor(LLColor4U(255,255,255,255), sDiffuseChannel); } - return; } - - llassert(LLPipeline::sImpostorRender || !avatarp->isVisuallyMuted()); - - /*if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview, 3=morph view - { - gPipeline.enableLightsAvatarEdit(LLColor4(.5f, .5f, .5f, 1.f)); - }*/ - - if (pass == 1) + else if (pass == 1) { // render rigid meshes (eyeballs) first avatarp->renderRigid(); - return; } - - if (pass == 3) - { - if (is_deferred_render) - { - renderDeferredRiggedSimple(avatarp); - } - else - { - renderRiggedSimple(avatarp); - } - return; - } - - if (pass == 4) - { - if (is_deferred_render) - { - renderDeferredRiggedBump(avatarp); - } - else + else if (pass >= 3 && pass <= 9) + { //render rigged attachments + if (!avatarp->isVisuallyMuted()) { - renderRiggedFullbright(avatarp); + if (pass == 3) + { + if (is_deferred_render) + { + renderDeferredRiggedSimple(avatarp); + } + else + { + renderRiggedSimple(avatarp); + } + } + else if (pass == 4) + { + if (is_deferred_render) + { + renderDeferredRiggedBump(avatarp); + } + else + { + renderRiggedFullbright(avatarp); + } + } + else if (pass == 5) + { + renderRiggedShinySimple(avatarp); + } + else if (pass == 6) + { + renderRiggedFullbrightShiny(avatarp); + } + else if (pass >= 7 && pass < 9) + { + if (pass == 7) + { + renderRiggedAlpha(avatarp); + } + else if (pass == 8) + { + renderRiggedFullbrightAlpha(avatarp); + } + } + else if (pass == 9) + { + renderRiggedGlow(avatarp); + } } - - return; } - - if (pass == 5) - { - renderRiggedShinySimple(avatarp); - return; - } - - if (pass == 6) - { - renderRiggedFullbrightShiny(avatarp); - return; - } - - if (pass >= 7 && pass < 9) + else { - if (pass == 7) + if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) { - renderRiggedAlpha(avatarp); - return; + LLMatrix4 rot_mat; + LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); + LLMatrix4 cfr(OGL_TO_CFR_ROTATION); + rot_mat *= cfr; + + LLVector4 wind; + wind.setVec(avatarp->mWindVec); + wind.mV[VW] = 0; + wind = wind * rot_mat; + wind.mV[VW] = avatarp->mWindVec.mV[VW]; + + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); + F32 phase = -1.f * (avatarp->mRipplePhase); + + F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); + LLVector4 sin_params(freq, freq, freq, phase); + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); + + LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); + gravity = gravity * rot_mat; + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); } - if (pass == 8) + if( !single_avatar || (avatarp == single_avatar) ) { - renderRiggedFullbrightAlpha(avatarp); - return; + avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); } } - - if (pass == 9) - { - renderRiggedGlow(avatarp); - - return; - } - - if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) - { - LLMatrix4 rot_mat; - LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); - LLMatrix4 cfr(OGL_TO_CFR_ROTATION); - rot_mat *= cfr; - - LLVector4 wind; - wind.setVec(avatarp->mWindVec); - wind.mV[VW] = 0; - wind = wind * rot_mat; - wind.mV[VW] = avatarp->mWindVec.mV[VW]; - - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); - F32 phase = -1.f * (avatarp->mRipplePhase); - - F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); - LLVector4 sin_params(freq, freq, freq, phase); - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); - - LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); - gravity = gravity * rot_mat; - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); - } - - if( !single_avatar || (avatarp == single_avatar) ) - { - avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); - } } void LLDrawPoolAvatar::getRiggedGeometry(LLFace* face, LLPointer& buffer, U32 data_mask, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face) diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h index 5551d8f6d8..544969001d 100644 --- a/indra/newview/lldrawpoolavatar.h +++ b/indra/newview/lldrawpoolavatar.h @@ -209,6 +209,7 @@ public: static BOOL sSkipOpaque; static BOOL sSkipTransparent; static S32 sDiffuseChannel; + static F32 sMinimumAlpha; static LLGLSLShader* sVertexProgram; }; diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 28e4b32793..a7e225843c 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -51,6 +51,7 @@ #include "llviewerregion.h" #include "llviewerwindow.h" #include "llviewershadermgr.h" +#include "llvoavatar.h" #define LL_MAX_INDICES_COUNT 1000000 @@ -325,6 +326,12 @@ void LLFace::dirtyTexture() if (vobj) { vobj->mLODChanged = TRUE; + + LLVOAvatar* avatar = vobj->getAvatar(); + if (avatar) + { //avatar render cost may have changed + avatar->updateVisualComplexity(); + } } gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME, FALSE); } diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 1223615079..5b65687090 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1200,8 +1200,7 @@ bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* dat LLMutexLock lock(mHeaderMutex); mMeshHeaderSize[mesh_id] = header_size; mMeshHeader[mesh_id] = header; - } - + } LLMutexLock lock(mMutex); // make sure only one thread access mPendingLOD at the same time. diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 62e93b7a53..4efd59685e 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -688,6 +688,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mFullyLoaded(FALSE), mPreviousFullyLoaded(FALSE), mFullyLoadedInitialized(FALSE), + mVisualComplexity(0), + mVisualComplexityStale(TRUE), mSupportsAlphaLayers(FALSE), mLoadedCallbacksPaused(FALSE), mHasPelvisOffset( FALSE ), @@ -3434,12 +3436,23 @@ void LLVOAvatar::slamPosition() bool LLVOAvatar::isVisuallyMuted() const { - static LLCachedControl max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit"); - static LLCachedControl max_attachment_area(gSavedSettings, "RenderAutoMuteSurfaceAreaLimit"); + bool ret = false; + + if (!isSelf()) + { + static LLCachedControl max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit"); + static LLCachedControl max_attachment_area(gSavedSettings, "RenderAutoMuteSurfaceAreaLimit"); + static LLCachedControl max_render_cost(gSavedSettings, "RenderAutoMuteRenderCostLimit"); - return LLMuteList::getInstance()->isMuted(getID()) || + U32 max_cost = (U32) (max_render_cost*(LLVOAvatar::sLODFactor+0.5)); + + ret = LLMuteList::getInstance()->isMuted(getID()) || (mAttachmentGeometryBytes > max_attachment_bytes && max_attachment_bytes > 0) || - (mAttachmentSurfaceArea > max_attachment_area && max_attachment_area > 0.f); + (mAttachmentSurfaceArea > max_attachment_area && max_attachment_area > 0.f) || + (mVisualComplexity > max_cost && max_render_cost > 0); + } + + return ret; } //------------------------------------------------------------------------ @@ -4139,46 +4152,6 @@ bool LLVOAvatar::shouldAlphaMask() } -U32 LLVOAvatar::renderSkinnedAttachments() -{ - /*U32 num_indices = 0; - - const U32 data_mask = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_NORMAL | - LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_COLOR | - LLVertexBuffer::MAP_WEIGHT4; - - for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); - iter != mAttachmentPoints.end(); - ++iter) - { - LLViewerJointAttachment* attachment = iter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) - { - const LLViewerObject* attached_object = (*attachment_iter); - if (attached_object && !attached_object->isHUDAttachment()) - { - const LLDrawable* drawable = attached_object->mDrawable; - if (drawable) - { - for (S32 i = 0; i < drawable->getNumFaces(); ++i) - { - LLFace* face = drawable->getFace(i); - if (face->isState(LLFace::RIGGED)) - { - - } - } - } - } - - return num_indices;*/ - return 0; -} - //----------------------------------------------------------------------------- // renderSkinned() //----------------------------------------------------------------------------- @@ -4336,21 +4309,23 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) BOOL first_pass = TRUE; if (!LLDrawPoolAvatar::sSkipOpaque) { + bool muted = isVisuallyMuted(); + if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender) { - if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy) + if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy || muted) { num_indices += mMeshLOD[MESH_ID_HEAD]->render(mAdjustedPixelArea, TRUE, mIsDummy); first_pass = FALSE; } } - if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy) + if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy || muted) { num_indices += mMeshLOD[MESH_ID_UPPER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); first_pass = FALSE; } - if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy) + if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy || muted) { num_indices += mMeshLOD[MESH_ID_LOWER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); first_pass = FALSE; @@ -6090,6 +6065,8 @@ const LLViewerJointAttachment *LLVOAvatar::attachObject(LLViewerObject *viewer_o return 0; } + mVisualComplexityStale = TRUE; + if (viewer_object->isSelected()) { LLSelectMgr::getInstance()->updateSelectionCenter(); @@ -6244,6 +6221,7 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object) if (attachment->isObjectAttached(viewer_object)) { + mVisualComplexityStale = TRUE; cleanupAttachedMesh( viewer_object ); attachment->removeObject(viewer_object); lldebugs << "Detaching object " << viewer_object->mID << " from " << attachment->getName() << llendl; @@ -8456,7 +8434,7 @@ void LLVOAvatar::updateImpostors() BOOL LLVOAvatar::isImpostor() const { - return (isVisuallyMuted() || (sUseImpostors && mUpdatePeriod >= IMPOSTOR_PERIOD)) ? TRUE : FALSE; + return sUseImpostors && (isVisuallyMuted() || (mUpdatePeriod >= IMPOSTOR_PERIOD)) ? TRUE : FALSE; } @@ -8501,6 +8479,8 @@ void LLVOAvatar::getImpostorValues(LLVector4a* extents, LLVector3& angle, F32& d void LLVOAvatar::idleUpdateRenderCost() { + static LLCachedControl max_render_cost(gSavedSettings, "RenderAutoMuteRenderCostLimit"); + static const U32 ARC_BODY_PART_COST = 200; static const U32 ARC_LIMIT = 20000; @@ -8511,123 +8491,147 @@ void LLVOAvatar::idleUpdateRenderCost() setDebugText(llformat("%.1f KB, %.2f m^2", mAttachmentGeometryBytes/1024.f, mAttachmentSurfaceArea)); } - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHAME)) + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHAME) && max_render_cost == 0) { return; } - U32 cost = 0; - LLVOVolume::texture_cost_t textures; - - for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++) + if (mVisualComplexityStale) { - const LLVOAvatarDictionary::BakedEntry *baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture((EBakedTextureIndex)baked_index); - ETextureIndex tex_index = baked_dict->mTextureIndex; - if ((tex_index != TEX_SKIRT_BAKED) || (isWearingWearableType(LLWearableType::WT_SKIRT))) + mVisualComplexityStale = FALSE; + U32 cost = 0; + LLVOVolume::texture_cost_t textures; + + for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++) { - if (isTextureVisible(tex_index)) + const LLVOAvatarDictionary::BakedEntry *baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture((EBakedTextureIndex)baked_index); + ETextureIndex tex_index = baked_dict->mTextureIndex; + if ((tex_index != TEX_SKIRT_BAKED) || (isWearingWearableType(LLWearableType::WT_SKIRT))) { - cost +=ARC_BODY_PART_COST; + if (isTextureVisible(tex_index)) + { + cost +=ARC_BODY_PART_COST; + } } } - } - for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); - iter != mAttachmentPoints.end(); - ++iter) - { - LLViewerJointAttachment* attachment = iter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) + for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); + iter != mAttachmentPoints.end(); + ++iter) { - const LLViewerObject* attached_object = (*attachment_iter); - if (attached_object && !attached_object->isHUDAttachment()) + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) { - textures.clear(); - const LLDrawable* drawable = attached_object->mDrawable; - if (drawable) + const LLViewerObject* attached_object = (*attachment_iter); + if (attached_object && !attached_object->isHUDAttachment()) { - const LLVOVolume* volume = drawable->getVOVolume(); - if (volume) + textures.clear(); + const LLDrawable* drawable = attached_object->mDrawable; + if (drawable) { - cost += volume->getRenderCost(textures); - - const_child_list_t children = volume->getChildren(); - for (const_child_list_t::const_iterator child_iter = children.begin(); - child_iter != children.end(); - ++child_iter) + const LLVOVolume* volume = drawable->getVOVolume(); + if (volume) { - LLViewerObject* child_obj = *child_iter; - LLVOVolume *child = dynamic_cast( child_obj ); - if (child) + cost += volume->getRenderCost(textures); + + const_child_list_t children = volume->getChildren(); + for (const_child_list_t::const_iterator child_iter = children.begin(); + child_iter != children.end(); + ++child_iter) { - cost += child->getRenderCost(textures); + LLViewerObject* child_obj = *child_iter; + LLVOVolume *child = dynamic_cast( child_obj ); + if (child) + { + cost += child->getRenderCost(textures); + } } - } - for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) - { - // add the cost of each individual texture in the linkset - cost += iter->second; + for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) + { + // add the cost of each individual texture in the linkset + cost += iter->second; + } } } } } - } - } + } - // Diagnostic output to identify all avatar-related textures. - // Does not affect rendering cost calculation. - // Could be wrapped in a debug option if output becomes problematic. - if (isSelf()) - { - // print any attachment textures we didn't already know about. - for (LLVOVolume::texture_cost_t::iterator it = textures.begin(); it != textures.end(); ++it) + // Diagnostic output to identify all avatar-related textures. + // Does not affect rendering cost calculation. + // Could be wrapped in a debug option if output becomes problematic. + if (isSelf()) { - LLUUID image_id = it->first; - if( image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR) - continue; - if (all_textures.find(image_id) == all_textures.end()) + // print any attachment textures we didn't already know about. + for (LLVOVolume::texture_cost_t::iterator it = textures.begin(); it != textures.end(); ++it) + { + LLUUID image_id = it->first; + if( image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR) + continue; + if (all_textures.find(image_id) == all_textures.end()) + { + // attachment texture not previously seen. + llinfos << "attachment_texture: " << image_id.asString() << llendl; + all_textures.insert(image_id); + } + } + + // print any avatar textures we didn't already know about + for (LLVOAvatarDictionary::Textures::const_iterator iter = LLVOAvatarDictionary::getInstance()->getTextures().begin(); + iter != LLVOAvatarDictionary::getInstance()->getTextures().end(); + ++iter) { - // attachment texture not previously seen. - llinfos << "attachment_texture: " << image_id.asString() << llendl; - all_textures.insert(image_id); + const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second; + // TODO: MULTI-WEARABLE: handle multiple textures for self + const LLViewerTexture* te_image = getImage(iter->first,0); + if (!te_image) + continue; + LLUUID image_id = te_image->getID(); + if( image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR) + continue; + if (all_textures.find(image_id) == all_textures.end()) + { + llinfos << "local_texture: " << texture_dict->mName << ": " << image_id << llendl; + all_textures.insert(image_id); + } } } - // print any avatar textures we didn't already know about - for (LLVOAvatarDictionary::Textures::const_iterator iter = LLVOAvatarDictionary::getInstance()->getTextures().begin(); - iter != LLVOAvatarDictionary::getInstance()->getTextures().end(); - ++iter) - { - const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second; - // TODO: MULTI-WEARABLE: handle multiple textures for self - const LLViewerTexture* te_image = getImage(iter->first,0); - if (!te_image) - continue; - LLUUID image_id = te_image->getID(); - if( image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR) - continue; - if (all_textures.find(image_id) == all_textures.end()) + if (isSelf() && max_render_cost > 0 && mVisualComplexity != cost) + { //pop up notification that you have exceeded a render cost limit + if (cost > max_render_cost+max_render_cost/2) + { + LLNotificationsUtil::add("ExceededHighDetailRenderCost"); + } + else if (cost > max_render_cost) { - llinfos << "local_texture: " << texture_dict->mName << ": " << image_id << llendl; - all_textures.insert(image_id); + LLNotificationsUtil::add("ExceededMidDetailRenderCost"); + } + else if (cost > max_render_cost/2) + { + LLNotificationsUtil::add("ExceededLowDetailRenderCost"); } } + + mVisualComplexity = cost; } - std::string viz_string = LLVOAvatar::rezStatusToString(getRezzedStatus()); - setDebugText(llformat("%s %d", viz_string.c_str(), cost)); - mVisualComplexity = cost; - F32 green = 1.f-llclamp(((F32) cost-(F32)ARC_LIMIT)/(F32)ARC_LIMIT, 0.f, 1.f); - F32 red = llmin((F32) cost/(F32)ARC_LIMIT, 1.f); - mText->setColor(LLColor4(red,green,0,1)); + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHAME)) + { + std::string viz_string = LLVOAvatar::rezStatusToString(getRezzedStatus()); + setDebugText(llformat("%s %d", viz_string.c_str(), mVisualComplexity)); + F32 green = 1.f-llclamp(((F32) mVisualComplexity-(F32)ARC_LIMIT)/(F32)ARC_LIMIT, 0.f, 1.f); + F32 red = llmin((F32) mVisualComplexity/(F32)ARC_LIMIT, 1.f); + mText->setColor(LLColor4(red,green,0,1)); + } } // static diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 1adb680962..e6569c557c 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -252,6 +252,7 @@ public: static void invalidateNameTags(); void addNameTagLine(const std::string& line, const LLColor4& color, S32 style, const LLFontGL* font); void idleUpdateRenderCost(); + void updateVisualComplexity() { mVisualComplexityStale = TRUE; } void idleUpdateBelowWater(); //-------------------------------------------------------------------- @@ -314,6 +315,7 @@ private: BOOL mFullyLoadedInitialized; S32 mFullyLoadedFrameCounter; S32 mVisualComplexity; + BOOL mVisualComplexityStale; LLFrameTimer mFullyLoadedTimer; LLFrameTimer mRuthTimer; @@ -437,7 +439,6 @@ public: U32 renderRigid(); U32 renderSkinned(EAvatarRenderPass pass); F32 getLastSkinTime() { return mLastSkinTime; } - U32 renderSkinnedAttachments(); U32 renderTransparent(BOOL first_pass); void renderCollisionVolumes(); static void deleteCachedImages(bool clearAll=true); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c0f80cf855..b853112f74 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1116,6 +1116,12 @@ void LLVOVolume::notifyMeshLoaded() { mSculptChanged = TRUE; gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE); + + LLVOAvatar* avatar = getAvatar(); + if (avatar) + { + avatar->updateVisualComplexity(); + } } // sculpt replaces generate() for sculpted surfaces diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4306b3da12..45d6d23b51 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10247,6 +10247,13 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) avatar->mImpostor.bindTarget(); } + F32 old_alpha = LLDrawPoolAvatar::sMinimumAlpha; + + if (muted) + { //disable alpha masking for muted avatars (get whole skin silhouette) + LLDrawPoolAvatar::sMinimumAlpha = 0.f; + } + if (LLPipeline::sRenderDeferred) { avatar->mImpostor.clear(); @@ -10260,7 +10267,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) avatar->mImpostor.clear(); renderGeom(camera); } - + + LLDrawPoolAvatar::sMinimumAlpha = old_alpha; + { //create alpha mask based on depth buffer (grey out if muted) LLFastTimer t(FTM_IMPOSTOR_BACKGROUND); if (LLPipeline::sRenderDeferred) @@ -10274,6 +10283,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) if (muted) { gGL.setColorMask(true, true); + } else { @@ -10292,25 +10302,36 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) gGL.pushMatrix(); gGL.loadIdentity(); - static const F32 clip_plane = 0.99999f; + static const F32 clip_plane = 0.999f; if (LLGLSLShader::sNoFixedFunction) { - gUIProgram.bind(); + gDebugProgram.bind(); } - gGL.color4ub(64,64,64,255); - gGL.begin(LLRender::QUADS); - gGL.vertex3f(-1, -1, clip_plane); - gGL.vertex3f(1, -1, clip_plane); - gGL.vertex3f(1, 1, clip_plane); - gGL.vertex3f(-1, 1, clip_plane); - gGL.end(); - gGL.flush(); + + if (LLMuteList::getInstance()->isMuted(avatar->getID())) + { //grey muted avatar + gGL.diffuseColor4ub(64,64,64,255); + } + else + { //blue visually muted avatar + gGL.diffuseColor4ub(72,61,139,255); + } + + { + gGL.begin(LLRender::QUADS); + gGL.vertex3f(-1, -1, clip_plane); + gGL.vertex3f(1, -1, clip_plane); + gGL.vertex3f(1, 1, clip_plane); + gGL.vertex3f(-1, 1, clip_plane); + gGL.end(); + gGL.flush(); + } if (LLGLSLShader::sNoFixedFunction) { - gUIProgram.unbind(); + gDebugProgram.unbind(); } gGL.popMatrix(); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 832e05a06f..fb530ef22d 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -202,6 +202,45 @@ Message Template [PATH] not found. yestext="OK"/> + + Your avatar has become too complex to be rendered by even high performance computers. Almost all Residents will see a low detail stand in instead of your actual avatar. + + + + + + Your avatar has become too complex to be rendered by most computers. Many Residents will see a low detail stand in instead of your actual avatar. + + + + + + Your avatar has become too complex to be rendered by some computers. Some Residents will see a low detail stand in instead of your actual avatar. + + + + fail Cannot create large prims that intersect other players. Please re-try when other players have moved. - + -- cgit v1.2.3 From 543500c58592e04ba1ef017abd49ef67cab0797e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 20 Feb 2013 20:06:40 -0600 Subject: MAINT-2390 Fix for texture animation corrupting face repeats on rigged attachments after switching off animation. --- indra/newview/lldrawpoolavatar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 03641140dc..6d02ad2b96 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1533,7 +1533,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) LLDrawPoolBump::bindBumpMap(face, normal_channel); } - if (face->mTextureMatrix) + if (face->mTextureMatrix && vobj->mTexAnimMode) { gGL.matrixMode(LLRender::MM_TEXTURE); gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix); -- cgit v1.2.3 From eb41cf7f767baeb9ceceaad1c6474be3555d926b Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 21 Feb 2013 16:26:16 -0800 Subject: For MAINT-755 Fix for unbinding cubemap causing false alarm in tex type checking code (OS X RenderDebugGL crash) Code review: Dav3p --- indra/newview/lldrawpoolbump.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 1b0b11298c..5a4f9591f7 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -449,9 +449,6 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; if( cube_map ) { - cube_map->disable(); - cube_map->restoreMatrix(); - if (!invisible && shader_level > 1) { shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); @@ -464,6 +461,10 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& } } } + // Moved below shader->disableTexture call to avoid false alarms from auto-re-enable of textures on stage 0 + // MAINT-755 + cube_map->disable(); + cube_map->restoreMatrix(); } if (!LLGLSLShader::sNoFixedFunction) -- cgit v1.2.3 From 2fd0e6e8f9cea68fbfe77282d623e70c64b52469 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 21 Feb 2013 16:50:04 -0800 Subject: Merge viewer-cat and resolve conflict with alternate self --- indra/llrender/llrender.cpp | 16 ++ indra/llrender/llrender.h | 1 + indra/llrender/llrendertarget.cpp | 6 + indra/llrender/llrendertarget.h | 1 + indra/newview/app_settings/settings.xml | 11 ++ .../shaders/class1/deferred/avatarF.glsl | 4 +- indra/newview/lldrawpoolavatar.cpp | 184 ++++++++++----------- indra/newview/lldrawpoolavatar.h | 1 + indra/newview/lldrawpoolbump.cpp | 4 +- 9 files changed, 126 insertions(+), 102 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 4597d06260..a12e9caf4c 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -2282,6 +2282,22 @@ void LLRender::diffuseColor4ubv(const U8* c) } } +void LLRender::diffuseColor4ub(U8 r, U8 g, U8 b, U8 a) +{ + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL); + + if (shader) + { + shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, r/255.f, g/255.f, b/255.f, a/255.f); + } + else + { + glColor4ub(r,g,b,a); + } +} + + void LLRender::debugTexUnits(void) { LL_INFOS("TextureUnit") << "Active TexUnit: " << mCurrTextureUnitIndex << LL_ENDL; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 78a310e525..90b1ec2f57 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -388,6 +388,7 @@ public: void diffuseColor4f(F32 r, F32 g, F32 b, F32 a); void diffuseColor4fv(const F32* c); void diffuseColor4ubv(const U8* c); + void diffuseColor4ub(U8 r, U8 g, U8 b, U8 a); void vertexBatchPreTransformed(LLVector3* verts, S32 vert_count); void vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count); diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index e35feda2d5..e501d0495b 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -458,6 +458,12 @@ U32 LLRenderTarget::getTexture(U32 attachment) const return mTex[attachment]; } +U32 LLRenderTarget::getNumTextures() const +{ + return mTex.size(); +} + + void LLRenderTarget::bindTexture(U32 index, S32 channel) { gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index)); diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index cf15f66d31..5cff0a0a21 100644 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h @@ -113,6 +113,7 @@ public: LLTexUnit::eTextureType getUsage(void) const { return mUsage; } U32 getTexture(U32 attachment = 0) const; + U32 getNumTextures() const; U32 getDepth(void) const { return mDepth; } bool hasStencil() const { return mStencil; } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index b302f5c9b9..e06b4bbe13 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9169,6 +9169,17 @@ Value 0 + RenderAutoMuteRenderCostLimit + + Comment + Maximum render cost before an avatar is automatically visually muted (0 for no limit). + Persist + 1 + Type + U32 + Value + 0 + RenderAutoMuteSurfaceAreaLimit Comment diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index bfd9b9b3eb..29a6d842d2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl @@ -31,6 +31,8 @@ out vec4 frag_data[3]; uniform sampler2D diffuseMap; +uniform float minimum_alpha; + VARYING vec3 vary_normal; VARYING vec2 vary_texcoord0; @@ -38,7 +40,7 @@ void main() { vec4 diff = texture2D(diffuseMap, vary_texcoord0.xy); - if (diff.a < 0.2) + if (diff.a < minimum_alpha) { discard; } diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 38268b102b..6d02ad2b96 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -59,6 +59,7 @@ LLGLSLShader* LLDrawPoolAvatar::sVertexProgram = NULL; BOOL LLDrawPoolAvatar::sSkipOpaque = FALSE; BOOL LLDrawPoolAvatar::sSkipTransparent = FALSE; S32 LLDrawPoolAvatar::sDiffuseChannel = 0; +F32 LLDrawPoolAvatar::sMinimumAlpha = 0.2f; static bool is_deferred_render = false; @@ -272,7 +273,7 @@ void LLDrawPoolAvatar::beginPostDeferredAlpha() gPipeline.bindDeferredShader(*sVertexProgram); - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); } @@ -620,7 +621,7 @@ void LLDrawPoolAvatar::beginRigid() if (sVertexProgram != NULL) { //eyeballs render with the specular shader sVertexProgram->bind(); - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); } } else @@ -671,7 +672,7 @@ void LLDrawPoolAvatar::beginDeferredRigid() sVertexProgram = &gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram; sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); sVertexProgram->bind(); - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); } void LLDrawPoolAvatar::endDeferredRigid() @@ -729,7 +730,7 @@ void LLDrawPoolAvatar::beginSkinned() if (LLGLSLShader::sNoFixedFunction) { - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); } } @@ -1027,7 +1028,7 @@ void LLDrawPoolAvatar::beginDeferredSkinned() sRenderingSkinned = TRUE; sVertexProgram->bind(); - sVertexProgram->setMinimumAlpha(0.2f); + sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gGL.getTexUnit(0)->activate(); @@ -1138,7 +1139,10 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) if (impostor) { - if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && avatarp->mImpostor.isComplete()) + if (LLPipeline::sRenderDeferred && //rendering a deferred impostor + !LLPipeline::sReflectionRender && + avatarp->mImpostor.isComplete() && //impostor has required data channels + avatarp->mImpostor.getNumTextures() >= 3) { if (normal_channel > -1) { @@ -1151,113 +1155,95 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) } avatarp->renderImpostor(LLColor4U(255,255,255,255), sDiffuseChannel); } - return; } - - llassert(LLPipeline::sImpostorRender || !avatarp->isVisuallyMuted()); - - /*if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview, 3=morph view - { - gPipeline.enableLightsAvatarEdit(LLColor4(.5f, .5f, .5f, 1.f)); - }*/ - - if (pass == 1) + else if (pass == 1) { // render rigid meshes (eyeballs) first avatarp->renderRigid(); - return; } - - if (pass == 3) - { - if (is_deferred_render) - { - renderDeferredRiggedSimple(avatarp); - } - else - { - renderRiggedSimple(avatarp); - } - return; - } - - if (pass == 4) - { - if (is_deferred_render) - { - renderDeferredRiggedBump(avatarp); - } - else + else if (pass >= 3 && pass <= 9) + { //render rigged attachments + if (!avatarp->isVisuallyMuted()) { - renderRiggedFullbright(avatarp); + if (pass == 3) + { + if (is_deferred_render) + { + renderDeferredRiggedSimple(avatarp); + } + else + { + renderRiggedSimple(avatarp); + } + } + else if (pass == 4) + { + if (is_deferred_render) + { + renderDeferredRiggedBump(avatarp); + } + else + { + renderRiggedFullbright(avatarp); + } + } + else if (pass == 5) + { + renderRiggedShinySimple(avatarp); + } + else if (pass == 6) + { + renderRiggedFullbrightShiny(avatarp); + } + else if (pass >= 7 && pass < 9) + { + if (pass == 7) + { + renderRiggedAlpha(avatarp); + } + else if (pass == 8) + { + renderRiggedFullbrightAlpha(avatarp); + } + } + else if (pass == 9) + { + renderRiggedGlow(avatarp); + } } - - return; } - - if (pass == 5) - { - renderRiggedShinySimple(avatarp); - return; - } - - if (pass == 6) - { - renderRiggedFullbrightShiny(avatarp); - return; - } - - if (pass >= 7 && pass < 9) + else { - if (pass == 7) + if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) { - renderRiggedAlpha(avatarp); - return; + LLMatrix4 rot_mat; + LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); + LLMatrix4 cfr(OGL_TO_CFR_ROTATION); + rot_mat *= cfr; + + LLVector4 wind; + wind.setVec(avatarp->mWindVec); + wind.mV[VW] = 0; + wind = wind * rot_mat; + wind.mV[VW] = avatarp->mWindVec.mV[VW]; + + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); + F32 phase = -1.f * (avatarp->mRipplePhase); + + F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); + LLVector4 sin_params(freq, freq, freq, phase); + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); + + LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); + gravity = gravity * rot_mat; + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); } - if (pass == 8) + if( !single_avatar || (avatarp == single_avatar) ) { - renderRiggedFullbrightAlpha(avatarp); - return; + avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); } } - - if (pass == 9) - { - renderRiggedGlow(avatarp); - - return; - } - - if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) - { - LLMatrix4 rot_mat; - LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); - LLMatrix4 cfr(OGL_TO_CFR_ROTATION); - rot_mat *= cfr; - - LLVector4 wind; - wind.setVec(avatarp->mWindVec); - wind.mV[VW] = 0; - wind = wind * rot_mat; - wind.mV[VW] = avatarp->mWindVec.mV[VW]; - - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); - F32 phase = -1.f * (avatarp->mRipplePhase); - - F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); - LLVector4 sin_params(freq, freq, freq, phase); - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); - - LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); - gravity = gravity * rot_mat; - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); - } - - if( !single_avatar || (avatarp == single_avatar) ) - { - avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); - } } void LLDrawPoolAvatar::getRiggedGeometry(LLFace* face, LLPointer& buffer, U32 data_mask, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face) @@ -1547,7 +1533,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) LLDrawPoolBump::bindBumpMap(face, normal_channel); } - if (face->mTextureMatrix) + if (face->mTextureMatrix && vobj->mTexAnimMode) { gGL.matrixMode(LLRender::MM_TEXTURE); gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix); diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h index 5551d8f6d8..544969001d 100644 --- a/indra/newview/lldrawpoolavatar.h +++ b/indra/newview/lldrawpoolavatar.h @@ -209,6 +209,7 @@ public: static BOOL sSkipOpaque; static BOOL sSkipTransparent; static S32 sDiffuseChannel; + static F32 sMinimumAlpha; static LLGLSLShader* sVertexProgram; }; diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 079cbe3a21..eacbf2d380 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -461,8 +461,8 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& } } } - // Placed after shader->disableTex(ENV,TT_CUBE_MAP) above to avoid sequencing false alarm when using RenderDebugGL - // MAINT-1291 + // Placed after shader->disableTex(ENV,TT_CUBE_MAP) to avoid sequencing false alarm when using RenderDebugGL + // MAINT-755 cube_map->disable(); cube_map->restoreMatrix(); } -- cgit v1.2.3 From 34158130b4e7a24011132230765d873ea36b8986 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 21 Feb 2013 16:54:36 -0800 Subject: Help the hg stop worrying about comment-only diffs --- indra/newview/lldrawpoolbump.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index eacbf2d380..8d1db7b9ad 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -461,8 +461,6 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& } } } - // Placed after shader->disableTex(ENV,TT_CUBE_MAP) to avoid sequencing false alarm when using RenderDebugGL - // MAINT-755 cube_map->disable(); cube_map->restoreMatrix(); } -- cgit v1.2.3 From e82667e3e879d33a2cc94a24cb258a5837c04357 Mon Sep 17 00:00:00 2001 From: Kelly Washington Date: Mon, 25 Feb 2013 14:06:38 -0800 Subject: MAINT-2407 'Stop animating me' spams server reviewed with Simon --- indra/newview/llagent.cpp | 33 ++++++++++++++++++++++++++++++++- indra/newview/llagent.h | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index b6fd7bc9c2..f0eee24fef 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -3062,6 +3062,30 @@ void LLAgent::sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request) sendReliableMessage(); } +// Send a message to the region to stop the NULL animation state +// This will reset animation state overrides for the agent. +void LLAgent::sendAnimationStateReset() +{ + if (gAgentID.isNull() || !mRegionp) + { + return; + } + + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_AgentAnimation); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, getID()); + msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); + + msg->nextBlockFast(_PREHASH_AnimationList); + msg->addUUIDFast(_PREHASH_AnimID, LLUUID::null ); + msg->addBOOLFast(_PREHASH_StartAnim, FALSE); + + msg->nextBlockFast(_PREHASH_PhysicalAvatarEventList); + msg->addBinaryDataFast(_PREHASH_TypeData, NULL, 0); + sendReliableMessage(); +} + void LLAgent::sendWalkRun(bool running) { LLMessageSystem* msgsys = gMessageSystem; @@ -4140,6 +4164,8 @@ void LLAgent::stopCurrentAnimations() // avatar, propagating this change back to the server. if (isAgentAvatarValid()) { + LLDynamicArray anim_ids; + for ( LLVOAvatar::AnimIterator anim_it = gAgentAvatarp->mPlayingAnimations.begin(); anim_it != gAgentAvatarp->mPlayingAnimations.end(); @@ -4157,10 +4183,15 @@ void LLAgent::stopCurrentAnimations() // stop this animation locally gAgentAvatarp->stopMotion(anim_it->first, TRUE); // ...and tell the server to tell everyone. - sendAnimationRequest(anim_it->first, ANIM_REQUEST_STOP); + anim_ids.push_back(anim_it->first); } } + sendAnimationRequests(anim_ids, ANIM_REQUEST_STOP); + + // Tell the region to clear any animation state overrides. + sendAnimationStateReset(); + // re-assert at least the default standing animation, because // viewers get confused by avs with no associated anims. sendAnimationRequest(ANIM_AGENT_STAND, diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 99904e118c..bec9352f5f 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -431,6 +431,8 @@ public: void onAnimStop(const LLUUID& id); void sendAnimationRequests(LLDynamicArray &anim_ids, EAnimRequest request); void sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request); + void sendAnimationStateReset(); + void endAnimationUpdateUI(); void unpauseAnimation() { mPauseRequest = NULL; } BOOL getCustomAnim() const { return mCustomAnim; } -- cgit v1.2.3 From f5e5396c3a17b6bcdc4eb49cda304a9047920fe1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 26 Feb 2013 15:15:08 -0600 Subject: MAINT-2371 First set of profile guided optimizations. Reviewed by Graham --- indra/llmath/llvolume.cpp | 97 +++++++++++++++++++++----------------- indra/llmath/llvolume.h | 3 ++ indra/llrender/llgl.cpp | 37 +++++++++------ indra/llrender/llglheaders.h | 2 + indra/llrender/llrender.cpp | 76 ++++++++++++++++------------- indra/llrender/llvertexbuffer.cpp | 47 ++++++++++-------- indra/llrender/llvertexbuffer.h | 3 +- indra/newview/llface.cpp | 28 +++++++---- indra/newview/llmeshrepository.cpp | 2 +- indra/newview/llvovolume.cpp | 29 ++++++++++++ 10 files changed, 203 insertions(+), 121 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 02c8d2b86f..77d89568df 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -5187,7 +5187,8 @@ LLVolumeFace::LLVolumeFace() : mTexCoords(NULL), mIndices(NULL), mWeights(NULL), - mOctree(NULL) + mOctree(NULL), + mOptimized(FALSE) { mExtents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*3); mExtents[0].splat(-0.5f); @@ -5517,14 +5518,14 @@ class LLVCacheVertexData public: S32 mIdx; S32 mCacheTag; - F32 mScore; + F64 mScore; U32 mActiveTriangles; std::vector mTriangles; LLVCacheVertexData() { mCacheTag = -1; - mScore = 0.f; + mScore = 0.0; mActiveTriangles = 0; mIdx = -1; } @@ -5534,13 +5535,13 @@ class LLVCacheTriangleData { public: bool mActive; - F32 mScore; + F64 mScore; LLVCacheVertexData* mVertex[3]; LLVCacheTriangleData() { mActive = true; - mScore = 0.f; + mScore = 0.0; mVertex[0] = mVertex[1] = mVertex[2] = NULL; } @@ -5551,7 +5552,7 @@ public: { if (mVertex[i]) { - llassert_always(mVertex[i]->mActiveTriangles > 0); + llassert(mVertex[i]->mActiveTriangles > 0); mVertex[i]->mActiveTriangles--; } } @@ -5563,44 +5564,44 @@ public: } }; -const F32 FindVertexScore_CacheDecayPower = 1.5f; -const F32 FindVertexScore_LastTriScore = 0.75f; -const F32 FindVertexScore_ValenceBoostScale = 2.0f; -const F32 FindVertexScore_ValenceBoostPower = 0.5f; +const F64 FindVertexScore_CacheDecayPower = 1.5; +const F64 FindVertexScore_LastTriScore = 0.75; +const F64 FindVertexScore_ValenceBoostScale = 2.0; +const F64 FindVertexScore_ValenceBoostPower = 0.5; const U32 MaxSizeVertexCache = 32; +const F64 FindVertexScore_Scaler = 1.0/(MaxSizeVertexCache-3); -F32 find_vertex_score(LLVCacheVertexData& data) +F64 find_vertex_score(LLVCacheVertexData& data) { - if (data.mActiveTriangles == 0) - { //no triangle references this vertex - return -1.f; - } - - F32 score = 0.f; + F64 score = -1.0; - S32 cache_idx = data.mCacheTag; + if (data.mActiveTriangles >= 0) + { + score = 0.0; + + S32 cache_idx = data.mCacheTag; - if (cache_idx < 0) - { - //not in cache - } - else - { - if (cache_idx < 3) - { //vertex was in the last triangle - score = FindVertexScore_LastTriScore; + if (cache_idx < 0) + { + //not in cache } else - { //more points for being higher in the cache - F32 scaler = 1.f/(MaxSizeVertexCache-3); - score = 1.f-((cache_idx-3)*scaler); - score = powf(score, FindVertexScore_CacheDecayPower); + { + if (cache_idx < 3) + { //vertex was in the last triangle + score = FindVertexScore_LastTriScore; + } + else + { //more points for being higher in the cache + score = 1.0-((cache_idx-3)*FindVertexScore_Scaler); + score = pow(score, FindVertexScore_CacheDecayPower); + } } - } - //bonus points for having low valence - F32 valence_boost = powf((F32)data.mActiveTriangles, -FindVertexScore_ValenceBoostPower); - score += FindVertexScore_ValenceBoostScale * valence_boost; + //bonus points for having low valence + F64 valence_boost = pow((F64)data.mActiveTriangles, -FindVertexScore_ValenceBoostPower); + score += FindVertexScore_ValenceBoostScale * valence_boost; + } return score; } @@ -5720,7 +5721,7 @@ public: if (mCache[i]) { mCache[i]->mScore = find_vertex_score(*(mCache[i])); - llassert_always(mCache[i]->mCacheTag == i); + llassert(mCache[i]->mCacheTag == i); } } @@ -5728,11 +5729,14 @@ public: //update triangle scores for (U32 i = 0; i < MaxSizeVertexCache+3; ++i) { - if (mCache[i]) + LLVCacheVertexData* data = mCache[i]; + if (data) { - for (U32 j = 0; j < mCache[i]->mTriangles.size(); ++j) + U32 count = data->mTriangles.size(); + + for (U32 j = 0; j < count; ++j) { - LLVCacheTriangleData* tri = mCache[i]->mTriangles[j]; + LLVCacheTriangleData* tri = data->mTriangles[j]; if (tri->mActive) { tri->mScore = tri->mVertex[0]->mScore; @@ -5753,7 +5757,7 @@ public: { if (mCache[i]) { - llassert_always(mCache[i]->mCacheTag == -1); + llassert(mCache[i]->mCacheTag == -1); mCache[i] = NULL; } } @@ -5765,6 +5769,9 @@ void LLVolumeFace::cacheOptimize() { //optimize for vertex cache according to Forsyth method: // http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html + llassert(!mOptimized); + mOptimized = TRUE; + LLVCacheLRU cache; if (mNumVertices < 3) @@ -5810,12 +5817,14 @@ void LLVolumeFace::cacheOptimize() for (U32 i = 0; i < mNumVertices; i++) { //initialize score values (no cache -- might try a fifo cache here) - vertex_data[i].mScore = find_vertex_score(vertex_data[i]); - vertex_data[i].mActiveTriangles = vertex_data[i].mTriangles.size(); + LLVCacheVertexData& data = vertex_data[i]; + + data.mScore = find_vertex_score(data); + data.mActiveTriangles = data.mTriangles.size(); - for (U32 j = 0; j < vertex_data[i].mTriangles.size(); ++j) + for (U32 j = 0; j < data.mActiveTriangles; ++j) { - vertex_data[i].mTriangles[j]->mScore += vertex_data[i].mScore; + data.mTriangles[j]->mScore += data.mScore; } } diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index c845556557..99158c1c44 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -933,6 +933,9 @@ public: LLOctreeNode* mOctree; + //whether or not face has been cache optimized + BOOL mOptimized; + private: BOOL createUnCutCubeCap(LLVolume* volume, BOOL partial_build = FALSE); BOOL createCap(LLVolume* volume, BOOL partial_build = FALSE); diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 9d06dd6904..89f1f36297 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -59,6 +59,7 @@ BOOL gDebugGL = FALSE; BOOL gClothRipple = FALSE; BOOL gHeadlessClient = FALSE; BOOL gGLActive = FALSE; +BOOL gGLDebugLoggingEnabled = TRUE; static const std::string HEADLESS_VENDOR_STRING("Linden Lab"); static const std::string HEADLESS_RENDERER_STRING("Headless"); @@ -72,6 +73,7 @@ std::ofstream gFailLog; #define APIENTRY #endif + void APIENTRY gl_debug_callback(GLenum source, GLenum type, GLuint id, @@ -80,22 +82,25 @@ void APIENTRY gl_debug_callback(GLenum source, const GLchar* message, GLvoid* userParam) { - if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) - { - llwarns << "----- GL ERROR --------" << llendl; - } - else + if (gGLDebugLoggingEnabled) { - llwarns << "----- GL WARNING -------" << llendl; - } - llwarns << "Type: " << std::hex << type << llendl; - llwarns << "ID: " << std::hex << id << llendl; - llwarns << "Severity: " << std::hex << severity << llendl; - llwarns << "Message: " << message << llendl; - llwarns << "-----------------------" << llendl; - if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) - { - llerrs << "Halting on GL Error" << llendl; + if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) + { + llwarns << "----- GL ERROR --------" << llendl; + } + else + { + llwarns << "----- GL WARNING -------" << llendl; + } + llwarns << "Type: " << std::hex << type << llendl; + llwarns << "ID: " << std::hex << id << llendl; + llwarns << "Severity: " << std::hex << severity << llendl; + llwarns << "Message: " << message << llendl; + llwarns << "-----------------------" << llendl; + if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) + { + llerrs << "Halting on GL Error" << llendl; + } } } #endif @@ -253,6 +258,7 @@ PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback = NULL; PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback = NULL; PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings = NULL; PFNGLBINDBUFFERRANGEPROC glBindBufferRange = NULL; +PFNGLBINDBUFFERBASEPROC glBindBufferBase = NULL; //GL_ARB_debug_output PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControlARB = NULL; @@ -1224,6 +1230,7 @@ void LLGLManager::initExtensions() glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) GLH_EXT_GET_PROC_ADDRESS("glEndTransformFeedback"); glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) GLH_EXT_GET_PROC_ADDRESS("glTransformFeedbackVaryings"); glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) GLH_EXT_GET_PROC_ADDRESS("glBindBufferRange"); + glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) GLH_EXT_GET_PROC_ADDRESS("glBindBufferBase"); } if (mHasDebugOutput) { diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 509de51f4d..a92ed428da 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -533,6 +533,7 @@ extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback; extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback; extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings; extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange; +extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; #elif LL_WINDOWS @@ -771,6 +772,7 @@ extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback; extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback; extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings; extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange; +extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; //GL_ARB_debug_output extern PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControlARB; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index a12e9caf4c..cb82cbfb74 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -225,46 +225,56 @@ void LLTexUnit::disable(void) bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) { stop_glerror(); - if (mIndex < 0) return false; - - gGL.flush(); - - LLImageGL* gl_tex = NULL ; - if (texture == NULL || !(gl_tex = texture->getGLTexture())) - { - llwarns << "NULL LLTexUnit::bind texture" << llendl; - return false; - } - - if (!gl_tex->getTexName()) //if texture does not exist + if (mIndex >= 0) { - //if deleted, will re-generate it immediately - texture->forceImmediateUpdate() ; - - gl_tex->forceUpdateBindStats() ; - return texture->bindDefaultImage(mIndex); - } + gGL.flush(); - //in audit, replace the selected texture by the default one. - if ((mCurrTexture != gl_tex->getTexName()) || forceBind) - { - activate(); - enable(gl_tex->getTarget()); - mCurrTexture = gl_tex->getTexName(); - glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); - if(gl_tex->updateBindStats(gl_tex->mTextureMemory)) + LLImageGL* gl_tex = NULL ; + if (texture != NULL && (gl_tex = texture->getGLTexture())) { - texture->setActive() ; - texture->updateBindStatsForTester() ; + if (gl_tex->getTexName()) //if texture exists + { + //in audit, replace the selected texture by the default one. + if ((mCurrTexture != gl_tex->getTexName()) || forceBind) + { + activate(); + enable(gl_tex->getTarget()); + mCurrTexture = gl_tex->getTexName(); + glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); + if(gl_tex->updateBindStats(gl_tex->mTextureMemory)) + { + texture->setActive() ; + texture->updateBindStatsForTester() ; + } + mHasMipMaps = gl_tex->mHasMipMaps; + if (gl_tex->mTexOptionsDirty) + { + gl_tex->mTexOptionsDirty = false; + setTextureAddressMode(gl_tex->mAddressMode); + setTextureFilteringOption(gl_tex->mFilterOption); + } + } + } + else + { + //if deleted, will re-generate it immediately + texture->forceImmediateUpdate() ; + + gl_tex->forceUpdateBindStats() ; + return texture->bindDefaultImage(mIndex); + } } - mHasMipMaps = gl_tex->mHasMipMaps; - if (gl_tex->mTexOptionsDirty) + else { - gl_tex->mTexOptionsDirty = false; - setTextureAddressMode(gl_tex->mAddressMode); - setTextureFilteringOption(gl_tex->mFilterOption); + llwarns << "NULL LLTexUnit::bind texture" << llendl; + return false; } } + else + { // mIndex < 0 + return false; + } + return true; } diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index dfbd8cd4ee..f152911b24 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -85,6 +85,7 @@ const U32 LL_VBO_POOL_SEED_COUNT = vbo_block_index(LL_VBO_POOL_MAX_SEED_SIZE); //static LLVBOPool LLVertexBuffer::sStreamVBOPool(GL_STREAM_DRAW_ARB, GL_ARRAY_BUFFER_ARB); LLVBOPool LLVertexBuffer::sDynamicVBOPool(GL_DYNAMIC_DRAW_ARB, GL_ARRAY_BUFFER_ARB); +LLVBOPool LLVertexBuffer::sDynamicCopyVBOPool(GL_DYNAMIC_COPY_ARB, GL_ARRAY_BUFFER_ARB); LLVBOPool LLVertexBuffer::sStreamIBOPool(GL_STREAM_DRAW_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB); LLVBOPool LLVertexBuffer::sDynamicIBOPool(GL_DYNAMIC_DRAW_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB); @@ -199,7 +200,10 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB) { glBufferDataARB(mType, size, 0, mUsage); - ret = (U8*) ll_aligned_malloc_16(size); + if (mUsage != GL_DYNAMIC_COPY_ARB) + { //data will be provided by application + ret = (U8*) ll_aligned_malloc_16(size); + } } else { //always use a true hint of static draw when allocating non-client-backed buffers @@ -393,6 +397,7 @@ void LLVertexBuffer::seedPools() { sStreamVBOPool.seedPool(); sDynamicVBOPool.seedPool(); + sDynamicCopyVBOPool.seedPool(); sStreamIBOPool.seedPool(); sDynamicIBOPool.seedPool(); } @@ -875,6 +880,7 @@ void LLVertexBuffer::cleanupClass() sDynamicIBOPool.cleanup(); sStreamVBOPool.cleanup(); sDynamicVBOPool.cleanup(); + sDynamicCopyVBOPool.cleanup(); if(sPrivatePoolp) { @@ -911,13 +917,16 @@ S32 LLVertexBuffer::determineUsage(S32 usage) if (ret_usage && ret_usage != GL_STREAM_DRAW_ARB) { //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default - if (sDisableVBOMapping) - { //always use stream draw if VBO mapping is disabled - ret_usage = GL_STREAM_DRAW_ARB; - } - else + if (ret_usage != GL_DYNAMIC_COPY_ARB) { - ret_usage = GL_DYNAMIC_DRAW_ARB; + if (sDisableVBOMapping) + { //always use stream draw if VBO mapping is disabled + ret_usage = GL_STREAM_DRAW_ARB; + } + else + { + ret_usage = GL_DYNAMIC_DRAW_ARB; + } } } @@ -1067,10 +1076,15 @@ void LLVertexBuffer::genBuffer(U32 size) { mMappedData = sStreamVBOPool.allocate(mGLBuffer, mSize); } - else + else if (mUsage == GL_DYNAMIC_DRAW_ARB) { mMappedData = sDynamicVBOPool.allocate(mGLBuffer, mSize); } + else + { + mMappedData = sDynamicCopyVBOPool.allocate(mGLBuffer, mSize); + } + sGLCount++; } @@ -1820,6 +1834,8 @@ void LLVertexBuffer::unmapBuffer() if (mMappedData && mVertexLocked) { + llassert(mUsage != GL_DYNAMIC_COPY_ARB); + LLFastTimer t(FTM_VBO_UNMAP); bindGLBuffer(true); updated_all = mIndexLocked; //both vertex and index buffers done updating @@ -2094,22 +2110,15 @@ bool LLVertexBuffer::bindGLBuffer(bool force_bind) if (useVBOs() && (force_bind || (mGLBuffer && (mGLBuffer != sGLRenderBuffer || !sVBOActive)))) { - LLFastTimer t(FTM_BIND_GL_BUFFER); - /*if (sMapped) - { - llerrs << "VBO bound while another VBO mapped!" << llendl; - }*/ + //LLFastTimer t(FTM_BIND_GL_BUFFER); <-- this timer is showing up as a hotspot (irony) + glBindBufferARB(GL_ARRAY_BUFFER_ARB, mGLBuffer); sGLRenderBuffer = mGLBuffer; sBindCount++; sVBOActive = true; - if (mGLArray) - { - llassert(sGLRenderArray == mGLArray); - //mCachedRenderBuffer = mGLBuffer; - } - + llassert(!mGLArray || sGLRenderArray == mGLArray); + ret = true; } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 11fa4ab6a0..a3400ae80c 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -125,9 +125,10 @@ public: static LLVBOPool sStreamVBOPool; static LLVBOPool sDynamicVBOPool; + static LLVBOPool sDynamicCopyVBOPool; static LLVBOPool sStreamIBOPool; static LLVBOPool sDynamicIBOPool; - + static std::list sAvailableVAOName; static U32 sCurVAOName; diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index a7e225843c..6b3127decf 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -53,6 +53,7 @@ #include "llviewershadermgr.h" #include "llvoavatar.h" +extern BOOL gGLDebugLoggingEnabled; #define LL_MAX_INDICES_COUNT 1000000 @@ -1166,6 +1167,15 @@ static LLFastTimer::DeclareTimer FTM_FACE_GEOM_COLOR("Color"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_EMISSIVE("Emissive"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_WEIGHTS("Weights"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_BINORMAL("Binormal"); + +static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK("Face Feedback"); +static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK_POSITION("Feedback Position"); +static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK_NORMAL("Feedback Normal"); +static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK_TEXTURE("Feedback Texture"); +static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK_COLOR("Feedback Color"); +static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK_EMISSIVE("Feedback Emissive"); +static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK_BINORMAL("Feedback Binormal"); + static LLFastTimer::DeclareTimer FTM_FACE_GEOM_INDEX("Index"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_INDEX_TAIL("Tail"); static LLFastTimer::DeclareTimer FTM_FACE_POSITION_STORE("Pos"); @@ -1389,12 +1399,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, #ifdef GL_TRANSFORM_FEEDBACK_BUFFER if (use_transform_feedback && + mVertexBuffer->getUsage() == GL_DYNAMIC_COPY_ARB && gTransformPositionProgram.mProgramObject && //transform shaders are loaded mVertexBuffer->useVBOs() && //target buffer is in VRAM !rebuild_weights && //TODO: add support for weights !volume.isUnique()) //source volume is NOT flexi { //use transform feedback to pack vertex buffer - + //gGLDebugLoggingEnabled = TRUE; + LLFastTimer t(FTM_FACE_GEOM_FEEDBACK); LLVertexBuffer* buff = (LLVertexBuffer*) vf.mVertexBuffer.get(); if (vf.mVertexBuffer.isNull() || buff->getNumVerts() != vf.mNumVertices) @@ -1411,7 +1423,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_pos) { - LLFastTimer t(FTM_FACE_GEOM_POSITION); + LLFastTimer t(FTM_FACE_GEOM_FEEDBACK_POSITION); gTransformPositionProgram.bind(); mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_VERTEX, mGeomIndex, mGeomCount); @@ -1436,7 +1448,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_color) { - LLFastTimer t(FTM_FACE_GEOM_COLOR); + LLFastTimer t(FTM_FACE_GEOM_FEEDBACK_COLOR); gTransformColorProgram.bind(); mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_COLOR, mGeomIndex, mGeomCount); @@ -1452,7 +1464,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_emissive) { - LLFastTimer t(FTM_FACE_GEOM_EMISSIVE); + LLFastTimer t(FTM_FACE_GEOM_FEEDBACK_EMISSIVE); gTransformColorProgram.bind(); mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_EMISSIVE, mGeomIndex, mGeomCount); @@ -1473,7 +1485,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_normal) { - LLFastTimer t(FTM_FACE_GEOM_NORMAL); + LLFastTimer t(FTM_FACE_GEOM_FEEDBACK_NORMAL); gTransformNormalProgram.bind(); mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_NORMAL, mGeomIndex, mGeomCount); @@ -1486,7 +1498,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_binormal) { - LLFastTimer t(FTM_FACE_GEOM_BINORMAL); + LLFastTimer t(FTM_FACE_GEOM_FEEDBACK_BINORMAL); gTransformBinormalProgram.bind(); mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_BINORMAL, mGeomIndex, mGeomCount); @@ -1499,7 +1511,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_tcoord) { - LLFastTimer t(FTM_FACE_GEOM_TEXTURE); + LLFastTimer t(FTM_FACE_GEOM_FEEDBACK_TEXTURE); gTransformTexCoordProgram.bind(); mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_TEXCOORD0, mGeomIndex, mGeomCount); @@ -1522,13 +1534,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } glBindBufferARB(GL_TRANSFORM_FEEDBACK_BUFFER, 0); - gGL.popMatrix(); if (cur_shader) { cur_shader->bind(); } + //gGLDebugLoggingEnabled = FALSE; } else #endif diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 5b65687090..ae48898e82 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -588,7 +588,7 @@ void LLMeshRepoThread::run() if (!fetchMeshLOD(req.mMeshParams, req.mLOD, count))//failed, resubmit { mMutex->lock(); - mLODReqQ.push(req) ; + mLODReqQ.push(req); mMutex->unlock(); } } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index b853112f74..6a18534484 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -99,6 +99,8 @@ static LLFastTimer::DeclareTimer FTM_GEN_TRIANGLES("Generate Triangles"); static LLFastTimer::DeclareTimer FTM_GEN_VOLUME("Generate Volumes"); static LLFastTimer::DeclareTimer FTM_VOLUME_TEXTURES("Volume Textures"); +extern BOOL gGLDebugLoggingEnabled; + // Implementation class of LLMediaDataClientObject. See llmediadataclient.h class LLMediaDataClientObjectImpl : public LLMediaDataClientObject { @@ -1067,7 +1069,9 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bo break; } volume->genBinormals(i); + //gGLDebugLoggingEnabled = TRUE; LLFace::cacheFaceInVRAM(face); + //gGLDebugLoggingEnabled = FALSE; } } @@ -4836,6 +4840,16 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: U32 buffer_usage = group->mBufferUsage; + static LLCachedControl use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback"); + + if (use_transform_feedback && + gTransformPositionProgram.mProgramObject && //transform shaders are loaded + buffer_usage == GL_DYNAMIC_DRAW_ARB && //target buffer is in VRAM + !(mask & LLVertexBuffer::MAP_WEIGHT4)) //TODO: add support for weights + { + buffer_usage = GL_DYNAMIC_COPY_ARB; + } + #if LL_DARWIN // HACK from Leslie: // Disable VBO usage for alpha on Mac OS X because it kills the framerate @@ -4895,6 +4909,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: //NEVER use more than 16 texture index channels (workaround for prevalent driver bug) texture_index_channels = llmin(texture_index_channels, 16); + bool flexi = false; + while (face_iter != faces.end()) { //pull off next face @@ -4921,6 +4937,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: U32 index_count = facep->getIndicesCount(); U32 geom_count = facep->getGeomCount(); + flexi = flexi || facep->getViewerObject()->getVolume()->isUnique(); + //sum up vertices needed for this render batch std::vector::iterator i = face_iter; ++i; @@ -4989,6 +5007,9 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } ++i; + + flexi = flexi || facep->getViewerObject()->getVolume()->isUnique(); + index_count += facep->getIndicesCount(); geom_count += facep->getGeomCount(); @@ -5018,10 +5039,18 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: ++i; index_count += facep->getIndicesCount(); geom_count += facep->getGeomCount(); + + flexi = flexi || facep->getViewerObject()->getVolume()->isUnique(); } } } + + if (flexi && buffer_usage && buffer_usage != GL_STREAM_DRAW_ARB) + { + buffer_usage = GL_STREAM_DRAW_ARB; + } + //create vertex buffer LLVertexBuffer* buffer = NULL; -- cgit v1.2.3 From 2c9636a9e5cb016d05741f214ac117dcae1ea317 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Wed, 27 Feb 2013 12:44:00 -0800 Subject: For MAINT-2003 Fix sequencing issue causing mem multiplier to be applied after clamping below actual mem available --- indra/newview/llfloaterhardwaresettings.cpp | 4 +++- indra/newview/llviewertexturelist.cpp | 14 +++++++------- indra/newview/llviewertexturelist.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp index 116bd241c4..664f7d4fd6 100644 --- a/indra/newview/llfloaterhardwaresettings.cpp +++ b/indra/newview/llfloaterhardwaresettings.cpp @@ -89,8 +89,10 @@ void LLFloaterHardwareSettings::refresh() void LLFloaterHardwareSettings::refreshEnabledState() { + F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); + S32 min_tex_mem = LLViewerTextureList::getMinVideoRamSetting(); - S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(); + S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier); getChild("GraphicsCardTextureMemory")->setMinValue(min_tex_mem); getChild("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem); diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index b9f5c432d0..82d990cf97 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1191,7 +1191,7 @@ S32 LLViewerTextureList::getMinVideoRamSetting() //static // Returns max setting for TextureMemory (in MB) -S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) +S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, float mem_multiplier) { S32 max_texmem; if (gGLManager.mVRAM != 0) @@ -1235,7 +1235,10 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) max_texmem = llmin(max_texmem, (S32)(system_ram/2)); else max_texmem = llmin(max_texmem, (S32)(system_ram)); - + + // limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise + max_texmem = llmin(max_texmem, (S32) (mem_multiplier * (F32) max_texmem)); + max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM_IN_MEGA_BYTES); return max_texmem; @@ -1248,7 +1251,7 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem) // Initialize the image pipeline VRAM settings S32 cur_mem = gSavedSettings.getS32("TextureMemory"); F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); - S32 default_mem = getMaxVideoRamSetting(true); // recommended default + S32 default_mem = getMaxVideoRamSetting(true, mem_multiplier); // recommended default if (mem == 0) { mem = cur_mem > 0 ? cur_mem : default_mem; @@ -1258,10 +1261,7 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem) mem = default_mem; } - // limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise - mem = llmin(mem, (S32) (mem_multiplier * (F32) default_mem)); - - mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting()); + mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting(false, mem_multiplier)); if (mem != cur_mem) { gSavedSettings.setS32("TextureMemory", mem); diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 3dda973d3f..88dea4448b 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -114,7 +114,7 @@ public: void setDebugFetching(LLViewerFetchedTexture* tex, S32 debug_level); static S32 getMinVideoRamSetting(); - static S32 getMaxVideoRamSetting(bool get_recommended = false); + static S32 getMaxVideoRamSetting(bool get_recommended, float mem_multiplier); private: void updateImagesDecodePriorities(); -- cgit v1.2.3 From da2caa46406d07b4b093bc17966ee23d87819f7c Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Wed, 27 Feb 2013 13:10:41 -0800 Subject: For MAINT-2003 and MAINT-1555 Fixes sequencing issue in determining max vram where mem multiplier was being done after already clamping to 512M, robbing people with >512M of 256M. Code review: DaveP --- indra/newview/llfloaterhardwaresettings.cpp | 4 +++- indra/newview/llviewertexturelist.cpp | 14 +++++++------- indra/newview/llviewertexturelist.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp index 116bd241c4..664f7d4fd6 100644 --- a/indra/newview/llfloaterhardwaresettings.cpp +++ b/indra/newview/llfloaterhardwaresettings.cpp @@ -89,8 +89,10 @@ void LLFloaterHardwareSettings::refresh() void LLFloaterHardwareSettings::refreshEnabledState() { + F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); + S32 min_tex_mem = LLViewerTextureList::getMinVideoRamSetting(); - S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(); + S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier); getChild("GraphicsCardTextureMemory")->setMinValue(min_tex_mem); getChild("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem); diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index b9f5c432d0..82d990cf97 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1191,7 +1191,7 @@ S32 LLViewerTextureList::getMinVideoRamSetting() //static // Returns max setting for TextureMemory (in MB) -S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) +S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, float mem_multiplier) { S32 max_texmem; if (gGLManager.mVRAM != 0) @@ -1235,7 +1235,10 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) max_texmem = llmin(max_texmem, (S32)(system_ram/2)); else max_texmem = llmin(max_texmem, (S32)(system_ram)); - + + // limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise + max_texmem = llmin(max_texmem, (S32) (mem_multiplier * (F32) max_texmem)); + max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM_IN_MEGA_BYTES); return max_texmem; @@ -1248,7 +1251,7 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem) // Initialize the image pipeline VRAM settings S32 cur_mem = gSavedSettings.getS32("TextureMemory"); F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); - S32 default_mem = getMaxVideoRamSetting(true); // recommended default + S32 default_mem = getMaxVideoRamSetting(true, mem_multiplier); // recommended default if (mem == 0) { mem = cur_mem > 0 ? cur_mem : default_mem; @@ -1258,10 +1261,7 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem) mem = default_mem; } - // limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise - mem = llmin(mem, (S32) (mem_multiplier * (F32) default_mem)); - - mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting()); + mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting(false, mem_multiplier)); if (mem != cur_mem) { gSavedSettings.setS32("TextureMemory", mem); diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 3dda973d3f..88dea4448b 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -114,7 +114,7 @@ public: void setDebugFetching(LLViewerFetchedTexture* tex, S32 debug_level); static S32 getMinVideoRamSetting(); - static S32 getMaxVideoRamSetting(bool get_recommended = false); + static S32 getMaxVideoRamSetting(bool get_recommended, float mem_multiplier); private: void updateImagesDecodePriorities(); -- cgit v1.2.3 From df08808640031bd27a11177ea49a08f797d2d570 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 28 Feb 2013 09:33:41 -0800 Subject: Improve perf of GLSL uniform lookups by name --- indra/llcommon/llstringtable.h | 480 ++++++----- indra/llrender/llglslshader.cpp | 92 +-- indra/llrender/llglslshader.h | 37 +- indra/llrender/llpostprocess.cpp | 59 +- indra/llrender/llpostprocess.h | 532 ++++++------ indra/newview/lldrawpoolavatar.cpp | 135 +-- indra/newview/lldrawpoolbump.cpp | 11 +- indra/newview/lldrawpoolterrain.cpp | 11 +- indra/newview/lldrawpoolwater.cpp | 1461 +++++++++++++++++---------------- indra/newview/lldrawpoolwlsky.cpp | 6 +- indra/newview/llface.cpp | 11 +- indra/newview/llmaniptranslate.cpp | 3 +- indra/newview/llviewershadermgr.cpp | 93 ++- indra/newview/llviewershadermgr.h | 16 +- indra/newview/llwaterparammanager.cpp | 22 +- indra/newview/llwlparammanager.cpp | 7 +- indra/newview/pipeline.cpp | 83 +- 17 files changed, 1570 insertions(+), 1489 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llstringtable.h b/indra/llcommon/llstringtable.h index 59d7372ed4..4f6417328c 100644 --- a/indra/llcommon/llstringtable.h +++ b/indra/llcommon/llstringtable.h @@ -1,217 +1,263 @@ -/** - * @file llstringtable.h - * @brief The LLStringTable class provides a _fast_ method for finding - * unique copies of strings. - * - * $LicenseInfo:firstyear=2001&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$ - */ - -#ifndef LL_STRING_TABLE_H -#define LL_STRING_TABLE_H - -#include "lldefs.h" -#include "llformat.h" -#include "llstl.h" -#include -#include - -#if LL_WINDOWS -# if (_MSC_VER >= 1300 && _MSC_VER < 1400) -# define STRING_TABLE_HASH_MAP 1 -# endif -#else -//# define STRING_TABLE_HASH_MAP 1 -#endif - -#if STRING_TABLE_HASH_MAP -# if LL_WINDOWS -# include -# else -# include -# endif -#endif - -const U32 MAX_STRINGS_LENGTH = 256; - -class LL_COMMON_API LLStringTableEntry -{ -public: - LLStringTableEntry(const char *str); - ~LLStringTableEntry(); - - void incCount() { mCount++; } - BOOL decCount() { return --mCount; } - - char *mString; - S32 mCount; -}; - -class LL_COMMON_API LLStringTable -{ -public: - LLStringTable(int tablesize); - ~LLStringTable(); - - char *checkString(const char *str); - char *checkString(const std::string& str); - LLStringTableEntry *checkStringEntry(const char *str); - LLStringTableEntry *checkStringEntry(const std::string& str); - - char *addString(const char *str); - char *addString(const std::string& str); - LLStringTableEntry *addStringEntry(const char *str); - LLStringTableEntry *addStringEntry(const std::string& str); - void removeString(const char *str); - - S32 mMaxEntries; - S32 mUniqueEntries; - -#if STRING_TABLE_HASH_MAP -#if LL_WINDOWS - typedef std::hash_multimap string_hash_t; -#else - typedef __gnu_cxx::hash_multimap string_hash_t; -#endif - string_hash_t mStringHash; -#else - typedef std::list string_list_t; - typedef string_list_t * string_list_ptr_t; - string_list_ptr_t *mStringList; -#endif -}; - -extern LL_COMMON_API LLStringTable gStringTable; - -//============================================================================ - -// This class is designed to be used locally, -// e.g. as a member of an LLXmlTree -// Strings can be inserted only, then quickly looked up - -typedef const std::string* LLStdStringHandle; - -class LL_COMMON_API LLStdStringTable -{ -public: - LLStdStringTable(S32 tablesize = 0) - { - if (tablesize == 0) - { - tablesize = 256; // default - } - // Make sure tablesize is power of 2 - for (S32 i = 31; i>0; i--) - { - if (tablesize & (1<= (3<<(i-1))) - tablesize = (1<<(i+1)); - else - tablesize = (1< > string_set_t; - string_set_t* mStringList; // [mTableSize] -}; - - -#endif +/** + * @file llstringtable.h + * @brief The LLStringTable class provides a _fast_ method for finding + * unique copies of strings. + * + * $LicenseInfo:firstyear=2001&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$ + */ + +#ifndef LL_STRING_TABLE_H +#define LL_STRING_TABLE_H + +#include "lldefs.h" +#include "llformat.h" +#include "llstl.h" +#include +#include +#include + +#if LL_WINDOWS +# if (_MSC_VER >= 1300 && _MSC_VER < 1400) +# define STRING_TABLE_HASH_MAP 1 +# endif +#else +//# define STRING_TABLE_HASH_MAP 1 +#endif + +#if STRING_TABLE_HASH_MAP +# if LL_WINDOWS +# include +# else +# include +# endif +#endif + +class LLStaticHashedString +{ +public: + + LLStaticHashedString(const std::string& s) + { + string_hash = makehash(s); + string = s; + } + + const std::string& String() const { return string; } + size_t Hash() const { return string_hash; } + +protected: + + size_t makehash(const std::string& s) + { + size_t len = s.size(); + const char* c = s.c_str(); + size_t hashval = 0; + for (size_t i=0; i +struct LLStaticStringHasher +{ + enum { bucket_size = 8 }; + size_t operator()(const T& key_value) const { return key_value.Hash(); } + bool operator()(const T& left, const T& right) const { return left.Hash() < right.Hash(); } +}; + +template< typename MappedObject > +class LL_COMMON_API LLStaticStringTable + : public std::hash_map< LLStaticHashedString , MappedObject, LLStaticStringHasher< LLStaticHashedString > > +{ +}; + +const U32 MAX_STRINGS_LENGTH = 256; + +class LL_COMMON_API LLStringTableEntry +{ +public: + LLStringTableEntry(const char *str); + ~LLStringTableEntry(); + + void incCount() { mCount++; } + BOOL decCount() { return --mCount; } + + char *mString; + S32 mCount; +}; + +class LL_COMMON_API LLStringTable +{ +public: + LLStringTable(int tablesize); + ~LLStringTable(); + + char *checkString(const char *str); + char *checkString(const std::string& str); + LLStringTableEntry *checkStringEntry(const char *str); + LLStringTableEntry *checkStringEntry(const std::string& str); + + char *addString(const char *str); + char *addString(const std::string& str); + LLStringTableEntry *addStringEntry(const char *str); + LLStringTableEntry *addStringEntry(const std::string& str); + void removeString(const char *str); + + S32 mMaxEntries; + S32 mUniqueEntries; + +#if STRING_TABLE_HASH_MAP +#if LL_WINDOWS + typedef std::hash_multimap string_hash_t; +#else + typedef __gnu_cxx::hash_multimap string_hash_t; +#endif + string_hash_t mStringHash; +#else + typedef std::list string_list_t; + typedef string_list_t * string_list_ptr_t; + string_list_ptr_t *mStringList; +#endif +}; + +extern LL_COMMON_API LLStringTable gStringTable; + +//============================================================================ + +// This class is designed to be used locally, +// e.g. as a member of an LLXmlTree +// Strings can be inserted only, then quickly looked up + +typedef const std::string* LLStdStringHandle; + +class LL_COMMON_API LLStdStringTable +{ +public: + LLStdStringTable(S32 tablesize = 0) + { + if (tablesize == 0) + { + tablesize = 256; // default + } + // Make sure tablesize is power of 2 + for (S32 i = 31; i>0; i--) + { + if (tablesize & (1<= (3<<(i-1))) + tablesize = (1<<(i+1)); + else + tablesize = (1< > string_set_t; + string_set_t* mStringList; // [mTableSize] +}; + + +#endif diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 7cbf39096e..298a03f32a 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -128,8 +128,8 @@ void LLGLSLShader::unload() stop_glerror(); } -BOOL LLGLSLShader::createShader(vector * attributes, - vector * uniforms, +BOOL LLGLSLShader::createShader(std::vector * attributes, + std::vector * uniforms, U32 varying_count, const char** varyings) { @@ -209,7 +209,8 @@ BOOL LLGLSLShader::createShader(vector * attributes, for (S32 i = 0; i < channel_count; i++) { - uniform1i(llformat("tex%d", i), i); + LLStaticHashedString uniName(llformat("tex%d", i)); + uniform1i(uniName, i); } S32 cur_tex = channel_count; //adjust any texture channels that might have been overwritten @@ -266,7 +267,7 @@ void LLGLSLShader::attachObjects(GLhandleARB* objects, S32 count) } } -BOOL LLGLSLShader::mapAttributes(const vector * attributes) +BOOL LLGLSLShader::mapAttributes(const std::vector * attributes) { //before linking, make sure reserved attributes always have consistent locations for (U32 i = 0; i < LLShaderMgr::instance()->mReservedAttribs.size(); i++) @@ -300,7 +301,7 @@ BOOL LLGLSLShader::mapAttributes(const vector * attributes) { for (U32 i = 0; i < numAttributes; i++) { - const char* name = (*attributes)[i].c_str(); + const char* name = (*attributes)[i].String().c_str(); S32 index = glGetAttribLocationARB(mProgramObject, name); if (index != -1) { @@ -316,7 +317,7 @@ BOOL LLGLSLShader::mapAttributes(const vector * attributes) return FALSE; } -void LLGLSLShader::mapUniform(GLint index, const vector * uniforms) +void LLGLSLShader::mapUniform(GLint index, const vector * uniforms) { if (index == -1) { @@ -341,7 +342,8 @@ void LLGLSLShader::mapUniform(GLint index, const vector * uniforms) is_array[0] = 0; } - mUniformMap[name] = location; + LLStaticHashedString hashedName(name); + mUniformMap[hashedName] = location; LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL; //find the index of this uniform @@ -362,7 +364,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector * uniforms) for (U32 i = 0; i < uniforms->size(); i++) { if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1) - && ((*uniforms)[i] == name)) + && ((*uniforms)[i].String() == name)) { //found it mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location; @@ -386,7 +388,7 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type) return -1; } -BOOL LLGLSLShader::mapUniforms(const vector * uniforms) +BOOL LLGLSLShader::mapUniforms(const vector * uniforms) { BOOL res = TRUE; @@ -793,18 +795,18 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c } } -GLint LLGLSLShader::getUniformLocation(const string& uniform) +GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform) { GLint ret = -1; if (mProgramObject > 0) { - std::map::iterator iter = mUniformMap.find(uniform); + LLStaticStringTable::iterator iter = mUniformMap.find(uniform); if (iter != mUniformMap.end()) { if (gDebugGL) { stop_glerror(); - if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.c_str())) + if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.String().c_str())) { llerrs << "Uniform does not match." << llendl; } @@ -841,10 +843,10 @@ GLint LLGLSLShader::getAttribLocation(U32 attrib) } } -void LLGLSLShader::uniform1i(const string& uniform, GLint v) +void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v) { GLint location = getUniformLocation(uniform); - + if (location >= 0) { std::map::iterator iter = mValue.find(location); @@ -857,10 +859,10 @@ void LLGLSLShader::uniform1i(const string& uniform, GLint v) } } -void LLGLSLShader::uniform1f(const string& uniform, GLfloat v) +void LLGLSLShader::uniform1f(const LLStaticHashedString& uniform, GLfloat v) { GLint location = getUniformLocation(uniform); - + if (location >= 0) { std::map::iterator iter = mValue.find(location); @@ -873,10 +875,10 @@ void LLGLSLShader::uniform1f(const string& uniform, GLfloat v) } } -void LLGLSLShader::uniform2f(const string& uniform, GLfloat x, GLfloat y) +void LLGLSLShader::uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y) { GLint location = getUniformLocation(uniform); - + if (location >= 0) { std::map::iterator iter = mValue.find(location); @@ -890,10 +892,10 @@ void LLGLSLShader::uniform2f(const string& uniform, GLfloat x, GLfloat y) } -void LLGLSLShader::uniform3f(const string& uniform, GLfloat x, GLfloat y, GLfloat z) +void LLGLSLShader::uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z) { GLint location = getUniformLocation(uniform); - + if (location >= 0) { std::map::iterator iter = mValue.find(location); @@ -906,23 +908,7 @@ void LLGLSLShader::uniform3f(const string& uniform, GLfloat x, GLfloat y, GLfloa } } -void LLGLSLShader::uniform4f(const string& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(x,y,z,w); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform4fARB(location, x,y,z,w); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniform1fv(const string& uniform, U32 count, const GLfloat* v) +void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) { GLint location = getUniformLocation(uniform); @@ -938,10 +924,10 @@ void LLGLSLShader::uniform1fv(const string& uniform, U32 count, const GLfloat* v } } -void LLGLSLShader::uniform2fv(const string& uniform, U32 count, const GLfloat* v) +void LLGLSLShader::uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) { GLint location = getUniformLocation(uniform); - + if (location >= 0) { std::map::iterator iter = mValue.find(location); @@ -954,10 +940,10 @@ void LLGLSLShader::uniform2fv(const string& uniform, U32 count, const GLfloat* v } } -void LLGLSLShader::uniform3fv(const string& uniform, U32 count, const GLfloat* v) +void LLGLSLShader::uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) { GLint location = getUniformLocation(uniform); - + if (location >= 0) { std::map::iterator iter = mValue.find(location); @@ -970,7 +956,7 @@ void LLGLSLShader::uniform3fv(const string& uniform, U32 count, const GLfloat* v } } -void LLGLSLShader::uniform4fv(const string& uniform, U32 count, const GLfloat* v) +void LLGLSLShader::uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) { GLint location = getUniformLocation(uniform); @@ -988,27 +974,7 @@ void LLGLSLShader::uniform4fv(const string& uniform, U32 count, const GLfloat* v } } -void LLGLSLShader::uniformMatrix2fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - glUniformMatrix2fvARB(location, count, transpose, v); - } -} - -void LLGLSLShader::uniformMatrix3fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - glUniformMatrix3fvARB(location, count, transpose, v); - } -} - -void LLGLSLShader::uniformMatrix4fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v) +void LLGLSLShader::uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v) { GLint location = getUniformLocation(uniform); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 5c68cb46eb..bac9af6959 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -75,16 +75,16 @@ public: static bool sNoFixedFunction; void unload(); - BOOL createShader(std::vector * attributes, - std::vector * uniforms, + BOOL createShader(std::vector * attributes, + std::vector * uniforms, U32 varying_count = 0, const char** varyings = NULL); BOOL attachObject(std::string object); void attachObject(GLhandleARB object); void attachObjects(GLhandleARB* objects = NULL, S32 count = 0); - BOOL mapAttributes(const std::vector * attributes); - BOOL mapUniforms(const std::vector * uniforms); - void mapUniform(GLint index, const std::vector * uniforms); + BOOL mapAttributes(const std::vector * attributes); + BOOL mapUniforms(const std::vector *); + void mapUniform(GLint index, const std::vector *); void uniform1i(U32 index, GLint i); void uniform1f(U32 index, GLfloat v); void uniform2f(U32 index, GLfloat x, GLfloat y); @@ -95,29 +95,26 @@ public: void uniform2fv(U32 index, U32 count, const GLfloat* v); void uniform3fv(U32 index, U32 count, const GLfloat* v); void uniform4fv(U32 index, U32 count, const GLfloat* v); - void uniform1i(const std::string& uniform, GLint i); - void uniform1f(const std::string& uniform, GLfloat v); - void uniform2f(const std::string& uniform, GLfloat x, GLfloat y); - void uniform3f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z); - void uniform4f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void uniform1iv(const std::string& uniform, U32 count, const GLint* i); - void uniform1fv(const std::string& uniform, U32 count, const GLfloat* v); - void uniform2fv(const std::string& uniform, U32 count, const GLfloat* v); - void uniform3fv(const std::string& uniform, U32 count, const GLfloat* v); - void uniform4fv(const std::string& uniform, U32 count, const GLfloat* v); void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); - void uniformMatrix2fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v); - void uniformMatrix3fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v); - void uniformMatrix4fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v); + void uniform1i(const LLStaticHashedString& uniform, GLint i); + void uniform1f(const LLStaticHashedString& uniform, GLfloat v); + void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y); + void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z); + void uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); + void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); + void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); + void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); + void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat *v); void setMinimumAlpha(F32 minimum); void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void vertexAttrib4fv(U32 index, GLfloat* v); - GLint getUniformLocation(const std::string& uniform); + //GLint getUniformLocation(const std::string& uniform); + GLint getUniformLocation(const LLStaticHashedString& uniform); GLint getUniformLocation(U32 index); GLint getAttribLocation(U32 attrib); @@ -143,7 +140,7 @@ public: GLhandleARB mProgramObject; std::vector mAttribute; //lookup table of attribute enum to attribute channel std::vector mUniform; //lookup table of uniform enum to uniform location - std::map mUniformMap; //lookup map of uniform name to uniform location + LLStaticStringTable mUniformMap; //lookup map of uniform name to uniform location std::map mValue; //lookup map of uniform location to last known value std::vector mTexture; S32 mActiveTextureChannels; diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index c0045c8044..21a28e386f 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -31,6 +31,21 @@ #include "llsdserialize.h" #include "llrender.h" +static LLStaticHashedString sRenderTexture("RenderTexture"); +static LLStaticHashedString sBrightness("brightness"); +static LLStaticHashedString sContrast("contrast"); +static LLStaticHashedString sContrastBase("contrastBase"); +static LLStaticHashedString sSaturation("saturation"); +static LLStaticHashedString sLumWeights("lumWeights"); +static LLStaticHashedString sNoiseTexture("NoiseTexture"); +static LLStaticHashedString sBrightMult("brightMult"); +static LLStaticHashedString sNoiseStrength("noiseStrength"); +static LLStaticHashedString sExtractLow("extractLow"); +static LLStaticHashedString sExtractHigh("extractHigh"); +static LLStaticHashedString sBloomStrength("bloomStrength"); +static LLStaticHashedString sTexelSize("texelSize"); +static LLStaticHashedString sBlurDirection("blurDirection"); +static LLStaticHashedString sBlurWidth("blurWidth"); LLPostProcess * gPostProcess = NULL; @@ -258,12 +273,12 @@ void LLPostProcess::applyColorFilterShader(void) void LLPostProcess::createColorFilterShader(void) { /// Define uniform names - colorFilterUniforms["RenderTexture"] = 0; - colorFilterUniforms["brightness"] = 0; - colorFilterUniforms["contrast"] = 0; - colorFilterUniforms["contrastBase"] = 0; - colorFilterUniforms["saturation"] = 0; - colorFilterUniforms["lumWeights"] = 0; + colorFilterUniforms[sRenderTexture] = 0; + colorFilterUniforms[sBrightness] = 0; + colorFilterUniforms[sContrast] = 0; + colorFilterUniforms[sContrastBase] = 0; + colorFilterUniforms[sSaturation] = 0; + colorFilterUniforms[sLumWeights] = 0; } void LLPostProcess::applyNightVisionShader(void) @@ -307,11 +322,11 @@ void LLPostProcess::applyNightVisionShader(void) void LLPostProcess::createNightVisionShader(void) { /// Define uniform names - nightVisionUniforms["RenderTexture"] = 0; - nightVisionUniforms["NoiseTexture"] = 0; - nightVisionUniforms["brightMult"] = 0; - nightVisionUniforms["noiseStrength"] = 0; - nightVisionUniforms["lumWeights"] = 0; + nightVisionUniforms[sRenderTexture] = 0; + nightVisionUniforms[sNoiseTexture] = 0; + nightVisionUniforms[sBrightMult] = 0; + nightVisionUniforms[sNoiseStrength] = 0; + nightVisionUniforms[sLumWeights] = 0; createNoiseTexture(mNoiseTexture); } @@ -326,25 +341,25 @@ void LLPostProcess::createBloomShader(void) createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); /// Create Bloom Extract Shader - bloomExtractUniforms["RenderTexture"] = 0; - bloomExtractUniforms["extractLow"] = 0; - bloomExtractUniforms["extractHigh"] = 0; - bloomExtractUniforms["lumWeights"] = 0; + bloomExtractUniforms[sRenderTexture] = 0; + bloomExtractUniforms[sExtractLow] = 0; + bloomExtractUniforms[sExtractHigh] = 0; + bloomExtractUniforms[sLumWeights] = 0; /// Create Bloom Blur Shader - bloomBlurUniforms["RenderTexture"] = 0; - bloomBlurUniforms["bloomStrength"] = 0; - bloomBlurUniforms["texelSize"] = 0; - bloomBlurUniforms["blurDirection"] = 0; - bloomBlurUniforms["blurWidth"] = 0; + bloomBlurUniforms[sRenderTexture] = 0; + bloomBlurUniforms[sBloomStrength] = 0; + bloomBlurUniforms[sTexelSize] = 0; + bloomBlurUniforms[sBlurDirection] = 0; + bloomBlurUniforms[sBlurWidth] = 0; } void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog) { /// Find uniform locations and insert into map - std::map::iterator i; + glslUniforms::iterator i; for (i = uniforms.begin(); i != uniforms.end(); ++i){ - i->second = glGetUniformLocationARB(prog, i->first); + i->second = glGetUniformLocationARB(prog, i->first.String().c_str()); } } diff --git a/indra/llrender/llpostprocess.h b/indra/llrender/llpostprocess.h index e19de44c60..c380413ec9 100644 --- a/indra/llrender/llpostprocess.h +++ b/indra/llrender/llpostprocess.h @@ -1,266 +1,266 @@ -/** - * @file llpostprocess.h - * @brief LLPostProcess class definition - * - * $LicenseInfo:firstyear=2007&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$ - */ - -#ifndef LL_POSTPROCESS_H -#define LL_POSTPROCESS_H - -#include -#include -#include "llgl.h" -#include "llglheaders.h" - -class LLPostProcess -{ -public: - - typedef enum _QuadType { - QUAD_NORMAL, - QUAD_NOISE, - QUAD_BLOOM_EXTRACT, - QUAD_BLOOM_COMBINE - } QuadType; - - /// GLSL Shader Encapsulation Struct - typedef std::map glslUniforms; - - struct PostProcessTweaks : public LLSD { - inline PostProcessTweaks() : LLSD(LLSD::emptyMap()) - { - } - - inline LLSD & brightMult() { - return (*this)["brightness_multiplier"]; - } - - inline LLSD & noiseStrength() { - return (*this)["noise_strength"]; - } - - inline LLSD & noiseSize() { - return (*this)["noise_size"]; - } - - inline LLSD & extractLow() { - return (*this)["extract_low"]; - } - - inline LLSD & extractHigh() { - return (*this)["extract_high"]; - } - - inline LLSD & bloomWidth() { - return (*this)["bloom_width"]; - } - - inline LLSD & bloomStrength() { - return (*this)["bloom_strength"]; - } - - inline LLSD & brightness() { - return (*this)["brightness"]; - } - - inline LLSD & contrast() { - return (*this)["contrast"]; - } - - inline LLSD & contrastBaseR() { - return (*this)["contrast_base"][0]; - } - - inline LLSD & contrastBaseG() { - return (*this)["contrast_base"][1]; - } - - inline LLSD & contrastBaseB() { - return (*this)["contrast_base"][2]; - } - - inline LLSD & contrastBaseIntensity() { - return (*this)["contrast_base"][3]; - } - - inline LLSD & saturation() { - return (*this)["saturation"]; - } - - inline LLSD & useNightVisionShader() { - return (*this)["enable_night_vision"]; - } - - inline LLSD & useBloomShader() { - return (*this)["enable_bloom"]; - } - - inline LLSD & useColorFilter() { - return (*this)["enable_color_filter"]; - } - - - inline F32 getBrightMult() const { - return F32((*this)["brightness_multiplier"].asReal()); - } - - inline F32 getNoiseStrength() const { - return F32((*this)["noise_strength"].asReal()); - } - - inline F32 getNoiseSize() const { - return F32((*this)["noise_size"].asReal()); - } - - inline F32 getExtractLow() const { - return F32((*this)["extract_low"].asReal()); - } - - inline F32 getExtractHigh() const { - return F32((*this)["extract_high"].asReal()); - } - - inline F32 getBloomWidth() const { - return F32((*this)["bloom_width"].asReal()); - } - - inline F32 getBloomStrength() const { - return F32((*this)["bloom_strength"].asReal()); - } - - inline F32 getBrightness() const { - return F32((*this)["brightness"].asReal()); - } - - inline F32 getContrast() const { - return F32((*this)["contrast"].asReal()); - } - - inline F32 getContrastBaseR() const { - return F32((*this)["contrast_base"][0].asReal()); - } - - inline F32 getContrastBaseG() const { - return F32((*this)["contrast_base"][1].asReal()); - } - - inline F32 getContrastBaseB() const { - return F32((*this)["contrast_base"][2].asReal()); - } - - inline F32 getContrastBaseIntensity() const { - return F32((*this)["contrast_base"][3].asReal()); - } - - inline F32 getSaturation() const { - return F32((*this)["saturation"].asReal()); - } - - }; - - bool initialized; - PostProcessTweaks tweaks; - - // the map of all availible effects - LLSD mAllEffects; - -private: - LLPointer mSceneRenderTexture ; - LLPointer mNoiseTexture ; - LLPointer mTempBloomTexture ; - -public: - LLPostProcess(void); - - ~LLPostProcess(void); - - void apply(unsigned int width, unsigned int height); - void invalidate() ; - - /// Perform global initialization for this class. - static void initClass(void); - - // Cleanup of global data that's only inited once per class. - static void cleanupClass(); - - void setSelectedEffect(std::string const & effectName); - - inline std::string const & getSelectedEffect(void) const { - return mSelectedEffectName; - } - - void saveEffect(std::string const & effectName); - -private: - /// read in from file - std::string mShaderErrorString; - unsigned int screenW; - unsigned int screenH; - - float noiseTextureScale; - - /// Shader Uniforms - glslUniforms nightVisionUniforms; - glslUniforms bloomExtractUniforms; - glslUniforms bloomBlurUniforms; - glslUniforms colorFilterUniforms; - - // the name of currently selected effect in mAllEffects - // invariant: tweaks == mAllEffects[mSelectedEffectName] - std::string mSelectedEffectName; - - /// General functions - void initialize(unsigned int width, unsigned int height); - void doEffects(void); - void applyShaders(void); - bool shadersEnabled(void); - - /// Night Vision Functions - void createNightVisionShader(void); - void applyNightVisionShader(void); - - /// Bloom Functions - void createBloomShader(void); - void applyBloomShader(void); - - /// Color Filter Functions - void createColorFilterShader(void); - void applyColorFilterShader(void); - - /// OpenGL Helper Functions - void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); - void createTexture(LLPointer& texture, unsigned int width, unsigned int height); - void copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height); - void createNoiseTexture(LLPointer& texture); - bool checkError(void); - void checkShaderError(GLhandleARB shader); - void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); - void viewOrthogonal(unsigned int width, unsigned int height); - void changeOrthogonal(unsigned int width, unsigned int height); - void viewPerspective(void); -}; - -extern LLPostProcess * gPostProcess; - - -#endif // LL_POSTPROCESS_H +/** + * @file llpostprocess.h + * @brief LLPostProcess class definition + * + * $LicenseInfo:firstyear=2007&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$ + */ + +#ifndef LL_POSTPROCESS_H +#define LL_POSTPROCESS_H + +#include +#include +#include "llgl.h" +#include "llglheaders.h" + +class LLPostProcess +{ +public: + + typedef enum _QuadType { + QUAD_NORMAL, + QUAD_NOISE, + QUAD_BLOOM_EXTRACT, + QUAD_BLOOM_COMBINE + } QuadType; + + /// GLSL Shader Encapsulation Struct + typedef LLStaticStringTable glslUniforms; + + struct PostProcessTweaks : public LLSD { + inline PostProcessTweaks() : LLSD(LLSD::emptyMap()) + { + } + + inline LLSD & brightMult() { + return (*this)["brightness_multiplier"]; + } + + inline LLSD & noiseStrength() { + return (*this)["noise_strength"]; + } + + inline LLSD & noiseSize() { + return (*this)["noise_size"]; + } + + inline LLSD & extractLow() { + return (*this)["extract_low"]; + } + + inline LLSD & extractHigh() { + return (*this)["extract_high"]; + } + + inline LLSD & bloomWidth() { + return (*this)["bloom_width"]; + } + + inline LLSD & bloomStrength() { + return (*this)["bloom_strength"]; + } + + inline LLSD & brightness() { + return (*this)["brightness"]; + } + + inline LLSD & contrast() { + return (*this)["contrast"]; + } + + inline LLSD & contrastBaseR() { + return (*this)["contrast_base"][0]; + } + + inline LLSD & contrastBaseG() { + return (*this)["contrast_base"][1]; + } + + inline LLSD & contrastBaseB() { + return (*this)["contrast_base"][2]; + } + + inline LLSD & contrastBaseIntensity() { + return (*this)["contrast_base"][3]; + } + + inline LLSD & saturation() { + return (*this)["saturation"]; + } + + inline LLSD & useNightVisionShader() { + return (*this)["enable_night_vision"]; + } + + inline LLSD & useBloomShader() { + return (*this)["enable_bloom"]; + } + + inline LLSD & useColorFilter() { + return (*this)["enable_color_filter"]; + } + + + inline F32 getBrightMult() const { + return F32((*this)["brightness_multiplier"].asReal()); + } + + inline F32 getNoiseStrength() const { + return F32((*this)["noise_strength"].asReal()); + } + + inline F32 getNoiseSize() const { + return F32((*this)["noise_size"].asReal()); + } + + inline F32 getExtractLow() const { + return F32((*this)["extract_low"].asReal()); + } + + inline F32 getExtractHigh() const { + return F32((*this)["extract_high"].asReal()); + } + + inline F32 getBloomWidth() const { + return F32((*this)["bloom_width"].asReal()); + } + + inline F32 getBloomStrength() const { + return F32((*this)["bloom_strength"].asReal()); + } + + inline F32 getBrightness() const { + return F32((*this)["brightness"].asReal()); + } + + inline F32 getContrast() const { + return F32((*this)["contrast"].asReal()); + } + + inline F32 getContrastBaseR() const { + return F32((*this)["contrast_base"][0].asReal()); + } + + inline F32 getContrastBaseG() const { + return F32((*this)["contrast_base"][1].asReal()); + } + + inline F32 getContrastBaseB() const { + return F32((*this)["contrast_base"][2].asReal()); + } + + inline F32 getContrastBaseIntensity() const { + return F32((*this)["contrast_base"][3].asReal()); + } + + inline F32 getSaturation() const { + return F32((*this)["saturation"].asReal()); + } + + }; + + bool initialized; + PostProcessTweaks tweaks; + + // the map of all availible effects + LLSD mAllEffects; + +private: + LLPointer mSceneRenderTexture ; + LLPointer mNoiseTexture ; + LLPointer mTempBloomTexture ; + +public: + LLPostProcess(void); + + ~LLPostProcess(void); + + void apply(unsigned int width, unsigned int height); + void invalidate() ; + + /// Perform global initialization for this class. + static void initClass(void); + + // Cleanup of global data that's only inited once per class. + static void cleanupClass(); + + void setSelectedEffect(std::string const & effectName); + + inline std::string const & getSelectedEffect(void) const { + return mSelectedEffectName; + } + + void saveEffect(std::string const & effectName); + +private: + /// read in from file + std::string mShaderErrorString; + unsigned int screenW; + unsigned int screenH; + + float noiseTextureScale; + + /// Shader Uniforms + glslUniforms nightVisionUniforms; + glslUniforms bloomExtractUniforms; + glslUniforms bloomBlurUniforms; + glslUniforms colorFilterUniforms; + + // the name of currently selected effect in mAllEffects + // invariant: tweaks == mAllEffects[mSelectedEffectName] + std::string mSelectedEffectName; + + /// General functions + void initialize(unsigned int width, unsigned int height); + void doEffects(void); + void applyShaders(void); + bool shadersEnabled(void); + + /// Night Vision Functions + void createNightVisionShader(void); + void applyNightVisionShader(void); + + /// Bloom Functions + void createBloomShader(void); + void applyBloomShader(void); + + /// Color Filter Functions + void createColorFilterShader(void); + void applyColorFilterShader(void); + + /// OpenGL Helper Functions + void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); + void createTexture(LLPointer& texture, unsigned int width, unsigned int height); + void copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height); + void createNoiseTexture(LLPointer& texture); + bool checkError(void); + void checkShaderError(GLhandleARB shader); + void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); + void viewOrthogonal(unsigned int width, unsigned int height); + void changeOrthogonal(unsigned int width, unsigned int height); + void viewPerspective(void); +}; + +extern LLPostProcess * gPostProcess; + + +#endif // LL_POSTPROCESS_H diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 6d02ad2b96..3cf96a9054 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1165,85 +1165,85 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) { //render rigged attachments if (!avatarp->isVisuallyMuted()) { - if (pass == 3) - { - if (is_deferred_render) - { - renderDeferredRiggedSimple(avatarp); - } - else - { - renderRiggedSimple(avatarp); - } - } + if (pass == 3) + { + if (is_deferred_render) + { + renderDeferredRiggedSimple(avatarp); + } + else + { + renderRiggedSimple(avatarp); + } + } else if (pass == 4) - { - if (is_deferred_render) - { - renderDeferredRiggedBump(avatarp); - } - else - { - renderRiggedFullbright(avatarp); - } - } + { + if (is_deferred_render) + { + renderDeferredRiggedBump(avatarp); + } + else + { + renderRiggedFullbright(avatarp); + } + } else if (pass == 5) - { - renderRiggedShinySimple(avatarp); - } + { + renderRiggedShinySimple(avatarp); + } else if (pass == 6) - { - renderRiggedFullbrightShiny(avatarp); - } + { + renderRiggedFullbrightShiny(avatarp); + } else if (pass >= 7 && pass < 9) - { - if (pass == 7) - { - renderRiggedAlpha(avatarp); - } + { + if (pass == 7) + { + renderRiggedAlpha(avatarp); + } else if (pass == 8) - { - renderRiggedFullbrightAlpha(avatarp); - } - } + { + renderRiggedFullbrightAlpha(avatarp); + } + } else if (pass == 9) - { - renderRiggedGlow(avatarp); - } + { + renderRiggedGlow(avatarp); + } } } else { - if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) - { - LLMatrix4 rot_mat; - LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); - LLMatrix4 cfr(OGL_TO_CFR_ROTATION); - rot_mat *= cfr; + if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) + { + LLMatrix4 rot_mat; + LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); + LLMatrix4 cfr(OGL_TO_CFR_ROTATION); + rot_mat *= cfr; - LLVector4 wind; - wind.setVec(avatarp->mWindVec); - wind.mV[VW] = 0; - wind = wind * rot_mat; - wind.mV[VW] = avatarp->mWindVec.mV[VW]; - - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); - F32 phase = -1.f * (avatarp->mRipplePhase); - - F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); - LLVector4 sin_params(freq, freq, freq, phase); - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); - - LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); - gravity = gravity * rot_mat; - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); - } + LLVector4 wind; + wind.setVec(avatarp->mWindVec); + wind.mV[VW] = 0; + wind = wind * rot_mat; + wind.mV[VW] = avatarp->mWindVec.mV[VW]; - if( !single_avatar || (avatarp == single_avatar) ) - { - avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); - } + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); + F32 phase = -1.f * (avatarp->mRipplePhase); + + F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); + LLVector4 sin_params(freq, freq, freq, phase); + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); + + LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); + gravity = gravity * rot_mat; + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); } + + if( !single_avatar || (avatarp == single_avatar) ) + { + avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); + } +} } void LLDrawPoolAvatar::getRiggedGeometry(LLFace* face, LLPointer& buffer, U32 data_mask, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face) @@ -1505,7 +1505,8 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) stop_glerror(); - LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", + static LLStaticHashedString sMatPalette("matrixPalette"); + LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv(sMatPalette, skin->mJointNames.size(), FALSE, (GLfloat*) mat[0].mMatrix); diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 8d1db7b9ad..4137084ebe 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -1368,9 +1368,14 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI LLGLDisable blend(GL_BLEND); gGL.setColorMask(TRUE, TRUE); gNormalMapGenProgram.bind(); - gNormalMapGenProgram.uniform1f("norm_scale", gSavedSettings.getF32("RenderNormalMapScale")); - gNormalMapGenProgram.uniform1f("stepX", 1.f/bump->getWidth()); - gNormalMapGenProgram.uniform1f("stepY", 1.f/bump->getHeight()); + + static LLStaticHashedString sNormScale("norm_scale"); + static LLStaticHashedString sStepX("stepX"); + static LLStaticHashedString sStepY("stepY"); + + gNormalMapGenProgram.uniform1f(sNormScale, gSavedSettings.getF32("RenderNormalMapScale")); + gNormalMapGenProgram.uniform1f(sStepX, 1.f/bump->getWidth()); + gNormalMapGenProgram.uniform1f(sStepY, 1.f/bump->getHeight()); LLVector2 v((F32) bump->getWidth()/gPipeline.mScreen.getWidth(), (F32) bump->getHeight()/gPipeline.mScreen.getHeight()); diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index 9bc32fddbd..3805348b6b 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -49,6 +49,9 @@ #include "llviewershadermgr.h" #include "llrender.h" +static LLStaticHashedString sObjectPlaneS("object_plane_s"); +static LLStaticHashedString sObjectPlaneT("object_plane_t"); + const F32 DETAIL_SCALE = 1.f/16.f; int DebugDetailMap = 0; @@ -352,8 +355,8 @@ void LLDrawPoolTerrain::renderFullShader() LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; llassert(shader); - shader->uniform4fv("object_plane_s", 1, tp0.mV); - shader->uniform4fv("object_plane_t", 1, tp1.mV); + shader->uniform4fv(sObjectPlaneS, 1, tp0.mV); + shader->uniform4fv(sObjectPlaneT, 1, tp1.mV); gGL.matrixMode(LLRender::MM_TEXTURE); gGL.loadIdentity(); @@ -862,8 +865,8 @@ void LLDrawPoolTerrain::renderSimple() if (LLGLSLShader::sNoFixedFunction) { - sShader->uniform4fv("object_plane_s", 1, tp0.mV); - sShader->uniform4fv("object_plane_t", 1, tp1.mV); + sShader->uniform4fv(sObjectPlaneS, 1, tp0.mV); + sShader->uniform4fv(sObjectPlaneT, 1, tp1.mV); } else { diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 4f6eaa5a5b..ffe438eb27 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -1,725 +1,736 @@ -/** - * @file lldrawpoolwater.cpp - * @brief LLDrawPoolWater class implementation - * - * $LicenseInfo:firstyear=2002&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 "llfeaturemanager.h" -#include "lldrawpoolwater.h" - -#include "llviewercontrol.h" -#include "lldir.h" -#include "llerror.h" -#include "m3math.h" -#include "llrender.h" - -#include "llagent.h" // for gAgent for getRegion for getWaterHeight -#include "llcubemap.h" -#include "lldrawable.h" -#include "llface.h" -#include "llsky.h" -#include "llviewertexturelist.h" -#include "llviewerregion.h" -#include "llvosky.h" -#include "llvowater.h" -#include "llworld.h" -#include "pipeline.h" -#include "llviewershadermgr.h" -#include "llwaterparammanager.h" - -const LLUUID TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004"); -const LLUUID OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055"); - -static float sTime; - -BOOL deferred_render = FALSE; - -BOOL LLDrawPoolWater::sSkipScreenCopy = FALSE; -BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE; -BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE; -LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f); -F32 LLDrawPoolWater::sWaterFogEnd = 0.f; - -LLVector3 LLDrawPoolWater::sLightDir; - -LLDrawPoolWater::LLDrawPoolWater() : - LLFacePool(POOL_WATER) -{ - mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, TRUE, LLViewerTexture::BOOST_UI); - gGL.getTexUnit(0)->bind(mHBTex[0]) ; - mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP); - - mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, TRUE, LLViewerTexture::BOOST_UI); - gGL.getTexUnit(0)->bind(mHBTex[1]); - mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP); - - - mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE); - llassert(mWaterImagep); - mWaterImagep->setNoDelete(); - mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE); - llassert(mOpaqueWaterImagep); - mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL); - mWaterNormp->setNoDelete(); - - restoreGL(); -} - -LLDrawPoolWater::~LLDrawPoolWater() -{ -} - -//static -void LLDrawPoolWater::restoreGL() -{ - -} - -LLDrawPool *LLDrawPoolWater::instancePool() -{ - llerrs << "Should never be calling instancePool on a water pool!" << llendl; - return NULL; -} - - -void LLDrawPoolWater::prerender() -{ - mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? - LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; - - // got rid of modulation by light color since it got a little too - // green at sunset and sl-57047 (underwater turns black at 8:00) - sWaterFogColor = LLWaterParamManager::instance().getFogColor(); - sWaterFogColor.mV[3] = 0; - -} - -S32 LLDrawPoolWater::getNumPasses() -{ - if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f) - { - return 1; - } - - return 0; -} - -void LLDrawPoolWater::beginPostDeferredPass(S32 pass) -{ - beginRenderPass(pass); - deferred_render = TRUE; -} - -void LLDrawPoolWater::endPostDeferredPass(S32 pass) -{ - endRenderPass(pass); - deferred_render = FALSE; -} - -//=============================== -//DEFERRED IMPLEMENTATION -//=============================== -void LLDrawPoolWater::renderDeferred(S32 pass) -{ - LLFastTimer t(FTM_RENDER_WATER); - deferred_render = TRUE; - shade(); - deferred_render = FALSE; -} - -//========================================= - -void LLDrawPoolWater::render(S32 pass) -{ - LLFastTimer ftm(FTM_RENDER_WATER); - if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1) - { - return; - } - - //do a quick 'n dirty depth sort - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace* facep = *iter; - facep->mDistance = -facep->mCenterLocal.mV[2]; - } - - std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater()); - - // See if we are rendering water as opaque or not - if (!gSavedSettings.getBOOL("RenderTransparentWater")) - { - // render water for low end hardware - renderOpaqueLegacyWater(); - return; - } - - LLGLEnable blend(GL_BLEND); - - if ((mVertexShaderLevel > 0) && !sSkipScreenCopy) - { - shade(); - return; - } - - LLVOSky *voskyp = gSky.mVOSkyp; - - stop_glerror(); - - if (!gGLManager.mHasMultitexture) - { - // Ack! No multitexture! Bail! - return; - } - - LLFace* refl_face = voskyp->getReflFace(); - - gPipeline.disableLights(); - - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - - LLGLDisable cullFace(GL_CULL_FACE); - - // Set up second pass first - mWaterImagep->addTextureStats(1024.f*1024.f); - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->bind(mWaterImagep) ; - - LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); - F32 up_dot = camera_up * LLVector3::z_axis; - - LLColor4 water_color; - if (LLViewerCamera::getInstance()->cameraUnderWater()) - { - water_color.setVec(1.f, 1.f, 1.f, 0.4f); - } - else - { - water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - } - - gGL.diffuseColor4fv(water_color.mV); - - // Automatically generate texture coords for detail map - glEnable(GL_TEXTURE_GEN_S); //texture unit 1 - glEnable(GL_TEXTURE_GEN_T); //texture unit 1 - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - - // Slowly move over time. - F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f); - F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f}; - F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f}; - glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); - glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); - - gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); - gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA); - - gGL.getTexUnit(0)->activate(); - - glClearStencil(1); - glClear(GL_STENCIL_BUFFER_BIT); - LLGLEnable gls_stencil(GL_STENCIL_TEST); - glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP); - glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - continue; - } - gGL.getTexUnit(0)->bind(face->getTexture()); - face->renderIndexed(); - } - - // Now, disable texture coord generation on texture state 1 - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->disable(); - glDisable(GL_TEXTURE_GEN_S); //texture unit 1 - glDisable(GL_TEXTURE_GEN_T); //texture unit 1 - - // Disable texture coordinate and color arrays - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - stop_glerror(); - - if (gSky.mVOSkyp->getCubeMap()) - { - gSky.mVOSkyp->getCubeMap()->enable(0); - gSky.mVOSkyp->getCubeMap()->bind(); - - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview(); - LLMatrix4 camera_rot(camera_mat.getMat3()); - camera_rot.invert(); - - gGL.loadMatrix((F32 *)camera_rot.mMatrix); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f, 0.5f*up_dot); - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - //refl_face = face; - continue; - } - - if (face->getGeomCount() > 0) - { - face->renderIndexed(); - } - } - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - - gSky.mVOSkyp->getCubeMap()->disable(); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - - } - - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - if (refl_face) - { - glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); - renderReflection(refl_face); - } - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); -} - -// for low end hardware -void LLDrawPoolWater::renderOpaqueLegacyWater() -{ - LLVOSky *voskyp = gSky.mVOSkyp; - - LLGLSLShader* shader = NULL; - if (LLGLSLShader::sNoFixedFunction) - { - if (LLPipeline::sUnderWaterRender) - { - shader = &gObjectSimpleNonIndexedTexGenWaterProgram; - } - else - { - shader = &gObjectSimpleNonIndexedTexGenProgram; - } - - shader->bind(); - } - - stop_glerror(); - - // Depth sorting and write to depth buffer - // since this is opaque, we should see nothing - // behind the water. No blending because - // of no transparency. And no face culling so - // that the underside of the water is also opaque. - LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); - LLGLDisable no_cull(GL_CULL_FACE); - LLGLDisable no_blend(GL_BLEND); - - gPipeline.disableLights(); - - mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); - - // Activate the texture binding and bind one - // texture since all images will have the same texture - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->bind(mOpaqueWaterImagep); - - // Automatically generate texture coords for water texture - if (!shader) - { - glEnable(GL_TEXTURE_GEN_S); //texture unit 0 - glEnable(GL_TEXTURE_GEN_T); //texture unit 0 - glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - } - - // Use the fact that we know all water faces are the same size - // to save some computation - - // Slowly move texture coordinates over time so the watter appears - // to be moving. - F32 movement_period_secs = 50.f; - - F32 offset = fmod(gFrameTimeSeconds, movement_period_secs); - - if (movement_period_secs != 0) - { - offset /= movement_period_secs; - } - else - { - offset = 0; - } - - F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset }; - F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset }; - - if (!shader) - { - glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); - glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); - } - else - { - shader->uniform4fv("object_plane_s", 1, tp0); - shader->uniform4fv("object_plane_t", 1, tp1); - } - - gGL.diffuseColor3f(1.f, 1.f, 1.f); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - if (voskyp->isReflFace(face)) - { - continue; - } - - face->renderIndexed(); - } - - stop_glerror(); - - if (!shader) - { - // Reset the settings back to expected values - glDisable(GL_TEXTURE_GEN_S); //texture unit 0 - glDisable(GL_TEXTURE_GEN_T); //texture unit 0 - } - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); -} - - -void LLDrawPoolWater::renderReflection(LLFace* face) -{ - LLVOSky *voskyp = gSky.mVOSkyp; - - if (!voskyp) - { - return; - } - - if (!face->getGeomCount()) - { - return; - } - - S8 dr = voskyp->getDrawRefl(); - if (dr < 0) - { - return; - } - - LLGLSNoFog noFog; - - gGL.getTexUnit(0)->bind(mHBTex[dr]); - - LLOverrideFaceColor override(this, face->getFaceColor().mV); - face->renderIndexed(); -} - -void LLDrawPoolWater::shade() -{ - if (!deferred_render) - { - gGL.setColorMask(true, true); - } - - LLVOSky *voskyp = gSky.mVOSkyp; - - if(voskyp == NULL) - { - return; - } - - LLGLDisable blend(GL_BLEND); - - LLColor3 light_diffuse(0,0,0); - F32 light_exp = 0.0f; - LLVector3 light_dir; - LLColor3 light_color; - - if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) - { - light_dir = gSky.getSunDirection(); - light_dir.normVec(); - light_color = gSky.getSunDiffuseColor(); - if(gSky.mVOSkyp) { - light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); - light_diffuse.normVec(); - } - light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); - light_diffuse *= light_exp + 0.25f; - } - else - { - light_dir = gSky.getMoonDirection(); - light_dir.normVec(); - light_color = gSky.getMoonDiffuseColor(); - light_diffuse = gSky.mVOSkyp->getMoon().getColorCached(); - light_diffuse.normVec(); - light_diffuse *= 0.5f; - light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); - } - - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= 256.f; - light_exp = light_exp > 32.f ? light_exp : 32.f; - - LLGLSLShader* shader; - - F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight(); - - if (deferred_render) - { - shader = &gDeferredWaterProgram; - } - else if (eyedepth < 0.f && LLPipeline::sWaterReflections) - { - shader = &gUnderWaterProgram; - } - else - { - shader = &gWaterProgram; - } - - if (deferred_render) - { - gPipeline.bindDeferredShader(*shader); - } - else - { - shader->bind(); - } - - sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; - - S32 reftex = shader->enableTexture(LLViewerShaderMgr::WATER_REFTEX); - - if (reftex > -1) - { - gGL.getTexUnit(reftex)->activate(); - gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef); - gGL.getTexUnit(0)->activate(); - } - - //bind normal map - S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); - - LLWaterParamManager * param_mgr = &LLWaterParamManager::instance(); - - // change mWaterNormp if needed - if (mWaterNormp->getID() != param_mgr->getNormalMapID()) - { - mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID()); - } - - mWaterNormp->addTextureStats(1024.f*1024.f); - gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ; - if (gSavedSettings.getBOOL("RenderWaterMipNormal")) - { - mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - } - else - { - mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT); - } - - S32 screentex = shader->enableTexture(LLViewerShaderMgr::WATER_SCREENTEX); - - if (screentex > -1) - { - shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); - shader->uniform1f(LLViewerShaderMgr::WATER_FOGDENSITY, - param_mgr->getFogDensity()); - gPipeline.mWaterDis.bindTexture(0, screentex); - } - - stop_glerror(); - - gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis); - - if (mVertexShaderLevel == 1) - { - sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue; - shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); - } - - F32 screenRes[] = - { - 1.f/gGLViewport[2], - 1.f/gGLViewport[3] - }; - shader->uniform2fv("screenRes", 1, screenRes); - stop_glerror(); - - S32 diffTex = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - stop_glerror(); - - light_dir.normVec(); - sLightDir = light_dir; - - light_diffuse *= 6.f; - - //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix); - shader->uniform1f(LLViewerShaderMgr::WATER_WATERHEIGHT, eyedepth); - shader->uniform1f(LLViewerShaderMgr::WATER_TIME, sTime); - shader->uniform3fv(LLViewerShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform3fv(LLViewerShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); - shader->uniform1f(LLViewerShaderMgr::WATER_SPECULAR_EXP, light_exp); - shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); - shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); - shader->uniform3fv(LLViewerShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); - - shader->uniform3fv("normScale", 1, param_mgr->getNormalScale().mV); - shader->uniform1f("fresnelScale", param_mgr->getFresnelScale()); - shader->uniform1f("fresnelOffset", param_mgr->getFresnelOffset()); - shader->uniform1f("blurMultiplier", param_mgr->getBlurMultiplier()); - - F32 sunAngle = llmax(0.f, light_dir.mV[2]); - F32 scaledAngle = 1.f - sunAngle; - - shader->uniform1f("sunAngle", sunAngle); - shader->uniform1f("scaledAngle", scaledAngle); - shader->uniform1f("sunAngle2", 0.1f + 0.2f*sunAngle); - - LLColor4 water_color; - LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); - F32 up_dot = camera_up * LLVector3::z_axis; - if (LLViewerCamera::getInstance()->cameraUnderWater()) - { - water_color.setVec(1.f, 1.f, 1.f, 0.4f); - shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); - } - else - { - water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); - } - - if (water_color.mV[3] > 0.9f) - { - water_color.mV[3] = 0.9f; - } - - { - LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0); - LLGLDisable cullface(GL_CULL_FACE); - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - - if (voskyp->isReflFace(face)) - { - continue; - } - - LLVOWater* water = (LLVOWater*) face->getViewerObject(); - gGL.getTexUnit(diffTex)->bind(face->getTexture()); - - sNeedsReflectionUpdate = TRUE; - - if (water->getUseTexture() || !water->getIsEdgePatch()) - { - sNeedsDistortionUpdate = TRUE; - face->renderIndexed(); - } - else if (gGLManager.mHasDepthClamp || deferred_render) - { - face->renderIndexed(); - } - else - { - LLGLSquashToFarClip far_clip(glh_get_current_projection()); - face->renderIndexed(); - } - } - } - - shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); - shader->disableTexture(LLViewerShaderMgr::WATER_SCREENTEX); - shader->disableTexture(LLViewerShaderMgr::BUMP_MAP); - shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - shader->disableTexture(LLViewerShaderMgr::WATER_REFTEX); - shader->disableTexture(LLViewerShaderMgr::WATER_SCREENDEPTH); - - if (deferred_render) - { - gPipeline.unbindDeferredShader(*shader); - } - else - { - shader->unbind(); - } - - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - if (!deferred_render) - { - gGL.setColorMask(true, false); - } - -} - -LLViewerTexture *LLDrawPoolWater::getDebugTexture() -{ - return LLViewerFetchedTexture::sSmokeImagep; -} - -LLColor3 LLDrawPoolWater::getDebugColor() const -{ - return LLColor3(0.f, 1.f, 1.f); -} +/** + * @file lldrawpoolwater.cpp + * @brief LLDrawPoolWater class implementation + * + * $LicenseInfo:firstyear=2002&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 "llfeaturemanager.h" +#include "lldrawpoolwater.h" + +#include "llviewercontrol.h" +#include "lldir.h" +#include "llerror.h" +#include "m3math.h" +#include "llrender.h" + +#include "llagent.h" // for gAgent for getRegion for getWaterHeight +#include "llcubemap.h" +#include "lldrawable.h" +#include "llface.h" +#include "llsky.h" +#include "llviewertexturelist.h" +#include "llviewerregion.h" +#include "llvosky.h" +#include "llvowater.h" +#include "llworld.h" +#include "pipeline.h" +#include "llviewershadermgr.h" +#include "llwaterparammanager.h" + +const LLUUID TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004"); +const LLUUID OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055"); + +static LLStaticHashedString sObjectPlaneS("object_plane_s"); +static LLStaticHashedString sObjectPlaneT("object_plane_t"); +static LLStaticHashedString sScreenRes("screenRes"); +static LLStaticHashedString sNormScale("normScale"); +static LLStaticHashedString sFresnelScale("fresnelScale"); +static LLStaticHashedString sFresnelOffset("fresnelOffset"); +static LLStaticHashedString sBlurMultiplier("blurMultiplier"); +static LLStaticHashedString sSunAngle("sunAngle"); +static LLStaticHashedString sScaledAngle("scaledAngle"); +static LLStaticHashedString sSunAngle2("sunAngle2"); + +static float sTime; + +BOOL deferred_render = FALSE; + +BOOL LLDrawPoolWater::sSkipScreenCopy = FALSE; +BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE; +BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE; +LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f); +F32 LLDrawPoolWater::sWaterFogEnd = 0.f; + +LLVector3 LLDrawPoolWater::sLightDir; + +LLDrawPoolWater::LLDrawPoolWater() : + LLFacePool(POOL_WATER) +{ + mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, TRUE, LLViewerTexture::BOOST_UI); + gGL.getTexUnit(0)->bind(mHBTex[0]) ; + mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP); + + mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, TRUE, LLViewerTexture::BOOST_UI); + gGL.getTexUnit(0)->bind(mHBTex[1]); + mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP); + + + mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE); + llassert(mWaterImagep); + mWaterImagep->setNoDelete(); + mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE); + llassert(mOpaqueWaterImagep); + mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL); + mWaterNormp->setNoDelete(); + + restoreGL(); +} + +LLDrawPoolWater::~LLDrawPoolWater() +{ +} + +//static +void LLDrawPoolWater::restoreGL() +{ + +} + +LLDrawPool *LLDrawPoolWater::instancePool() +{ + llerrs << "Should never be calling instancePool on a water pool!" << llendl; + return NULL; +} + + +void LLDrawPoolWater::prerender() +{ + mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? + LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; + + // got rid of modulation by light color since it got a little too + // green at sunset and sl-57047 (underwater turns black at 8:00) + sWaterFogColor = LLWaterParamManager::instance().getFogColor(); + sWaterFogColor.mV[3] = 0; + +} + +S32 LLDrawPoolWater::getNumPasses() +{ + if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f) + { + return 1; + } + + return 0; +} + +void LLDrawPoolWater::beginPostDeferredPass(S32 pass) +{ + beginRenderPass(pass); + deferred_render = TRUE; +} + +void LLDrawPoolWater::endPostDeferredPass(S32 pass) +{ + endRenderPass(pass); + deferred_render = FALSE; +} + +//=============================== +//DEFERRED IMPLEMENTATION +//=============================== +void LLDrawPoolWater::renderDeferred(S32 pass) +{ + LLFastTimer t(FTM_RENDER_WATER); + deferred_render = TRUE; + shade(); + deferred_render = FALSE; +} + +//========================================= + +void LLDrawPoolWater::render(S32 pass) +{ + LLFastTimer ftm(FTM_RENDER_WATER); + if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1) + { + return; + } + + //do a quick 'n dirty depth sort + for (std::vector::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace* facep = *iter; + facep->mDistance = -facep->mCenterLocal.mV[2]; + } + + std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater()); + + // See if we are rendering water as opaque or not + if (!gSavedSettings.getBOOL("RenderTransparentWater")) + { + // render water for low end hardware + renderOpaqueLegacyWater(); + return; + } + + LLGLEnable blend(GL_BLEND); + + if ((mVertexShaderLevel > 0) && !sSkipScreenCopy) + { + shade(); + return; + } + + LLVOSky *voskyp = gSky.mVOSkyp; + + stop_glerror(); + + if (!gGLManager.mHasMultitexture) + { + // Ack! No multitexture! Bail! + return; + } + + LLFace* refl_face = voskyp->getReflFace(); + + gPipeline.disableLights(); + + LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); + + LLGLDisable cullFace(GL_CULL_FACE); + + // Set up second pass first + mWaterImagep->addTextureStats(1024.f*1024.f); + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->bind(mWaterImagep) ; + + LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); + F32 up_dot = camera_up * LLVector3::z_axis; + + LLColor4 water_color; + if (LLViewerCamera::getInstance()->cameraUnderWater()) + { + water_color.setVec(1.f, 1.f, 1.f, 0.4f); + } + else + { + water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); + } + + gGL.diffuseColor4fv(water_color.mV); + + // Automatically generate texture coords for detail map + glEnable(GL_TEXTURE_GEN_S); //texture unit 1 + glEnable(GL_TEXTURE_GEN_T); //texture unit 1 + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + + // Slowly move over time. + F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f); + F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f}; + F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f}; + glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); + glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); + + gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); + gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA); + + gGL.getTexUnit(0)->activate(); + + glClearStencil(1); + glClear(GL_STENCIL_BUFFER_BIT); + LLGLEnable gls_stencil(GL_STENCIL_TEST); + glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP); + glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); + + for (std::vector::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + if (voskyp->isReflFace(face)) + { + continue; + } + gGL.getTexUnit(0)->bind(face->getTexture()); + face->renderIndexed(); + } + + // Now, disable texture coord generation on texture state 1 + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); + glDisable(GL_TEXTURE_GEN_S); //texture unit 1 + glDisable(GL_TEXTURE_GEN_T); //texture unit 1 + + // Disable texture coordinate and color arrays + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + stop_glerror(); + + if (gSky.mVOSkyp->getCubeMap()) + { + gSky.mVOSkyp->getCubeMap()->enable(0); + gSky.mVOSkyp->getCubeMap()->bind(); + + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadIdentity(); + LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview(); + LLMatrix4 camera_rot(camera_mat.getMat3()); + camera_rot.invert(); + + gGL.loadMatrix((F32 *)camera_rot.mMatrix); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f, 0.5f*up_dot); + + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + + for (std::vector::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + if (voskyp->isReflFace(face)) + { + //refl_face = face; + continue; + } + + if (face->getGeomCount() > 0) + { + face->renderIndexed(); + } + } + + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + + gSky.mVOSkyp->getCubeMap()->disable(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + + } + + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + + if (refl_face) + { + glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); + renderReflection(refl_face); + } + + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); +} + +// for low end hardware +void LLDrawPoolWater::renderOpaqueLegacyWater() +{ + LLVOSky *voskyp = gSky.mVOSkyp; + + LLGLSLShader* shader = NULL; + if (LLGLSLShader::sNoFixedFunction) + { + if (LLPipeline::sUnderWaterRender) + { + shader = &gObjectSimpleNonIndexedTexGenWaterProgram; + } + else + { + shader = &gObjectSimpleNonIndexedTexGenProgram; + } + + shader->bind(); + } + + stop_glerror(); + + // Depth sorting and write to depth buffer + // since this is opaque, we should see nothing + // behind the water. No blending because + // of no transparency. And no face culling so + // that the underside of the water is also opaque. + LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); + LLGLDisable no_cull(GL_CULL_FACE); + LLGLDisable no_blend(GL_BLEND); + + gPipeline.disableLights(); + + mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); + + // Activate the texture binding and bind one + // texture since all images will have the same texture + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->bind(mOpaqueWaterImagep); + + // Automatically generate texture coords for water texture + if (!shader) + { + glEnable(GL_TEXTURE_GEN_S); //texture unit 0 + glEnable(GL_TEXTURE_GEN_T); //texture unit 0 + glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + } + + // Use the fact that we know all water faces are the same size + // to save some computation + + // Slowly move texture coordinates over time so the watter appears + // to be moving. + F32 movement_period_secs = 50.f; + + F32 offset = fmod(gFrameTimeSeconds, movement_period_secs); + + if (movement_period_secs != 0) + { + offset /= movement_period_secs; + } + else + { + offset = 0; + } + + F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset }; + F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset }; + + if (!shader) + { + glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); + glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); + } + else + { + shader->uniform4fv(sObjectPlaneS, 1, tp0); + shader->uniform4fv(sObjectPlaneT, 1, tp1); + } + + gGL.diffuseColor3f(1.f, 1.f, 1.f); + + for (std::vector::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + if (voskyp->isReflFace(face)) + { + continue; + } + + face->renderIndexed(); + } + + stop_glerror(); + + if (!shader) + { + // Reset the settings back to expected values + glDisable(GL_TEXTURE_GEN_S); //texture unit 0 + glDisable(GL_TEXTURE_GEN_T); //texture unit 0 + } + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); +} + + +void LLDrawPoolWater::renderReflection(LLFace* face) +{ + LLVOSky *voskyp = gSky.mVOSkyp; + + if (!voskyp) + { + return; + } + + if (!face->getGeomCount()) + { + return; + } + + S8 dr = voskyp->getDrawRefl(); + if (dr < 0) + { + return; + } + + LLGLSNoFog noFog; + + gGL.getTexUnit(0)->bind(mHBTex[dr]); + + LLOverrideFaceColor override(this, face->getFaceColor().mV); + face->renderIndexed(); +} + +void LLDrawPoolWater::shade() +{ + if (!deferred_render) + { + gGL.setColorMask(true, true); + } + + LLVOSky *voskyp = gSky.mVOSkyp; + + if(voskyp == NULL) + { + return; + } + + LLGLDisable blend(GL_BLEND); + + LLColor3 light_diffuse(0,0,0); + F32 light_exp = 0.0f; + LLVector3 light_dir; + LLColor3 light_color; + + if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) + { + light_dir = gSky.getSunDirection(); + light_dir.normVec(); + light_color = gSky.getSunDiffuseColor(); + if(gSky.mVOSkyp) { + light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); + light_diffuse.normVec(); + } + light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); + light_diffuse *= light_exp + 0.25f; + } + else + { + light_dir = gSky.getMoonDirection(); + light_dir.normVec(); + light_color = gSky.getMoonDiffuseColor(); + light_diffuse = gSky.mVOSkyp->getMoon().getColorCached(); + light_diffuse.normVec(); + light_diffuse *= 0.5f; + light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); + } + + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= 256.f; + light_exp = light_exp > 32.f ? light_exp : 32.f; + + LLGLSLShader* shader; + + F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight(); + + if (deferred_render) + { + shader = &gDeferredWaterProgram; + } + else if (eyedepth < 0.f && LLPipeline::sWaterReflections) + { + shader = &gUnderWaterProgram; + } + else + { + shader = &gWaterProgram; + } + + if (deferred_render) + { + gPipeline.bindDeferredShader(*shader); + } + else + { + shader->bind(); + } + + sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; + + S32 reftex = shader->enableTexture(LLViewerShaderMgr::WATER_REFTEX); + + if (reftex > -1) + { + gGL.getTexUnit(reftex)->activate(); + gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef); + gGL.getTexUnit(0)->activate(); + } + + //bind normal map + S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); + + LLWaterParamManager * param_mgr = &LLWaterParamManager::instance(); + + // change mWaterNormp if needed + if (mWaterNormp->getID() != param_mgr->getNormalMapID()) + { + mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID()); + } + + mWaterNormp->addTextureStats(1024.f*1024.f); + gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ; + if (gSavedSettings.getBOOL("RenderWaterMipNormal")) + { + mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + } + else + { + mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT); + } + + S32 screentex = shader->enableTexture(LLViewerShaderMgr::WATER_SCREENTEX); + + if (screentex > -1) + { + shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); + shader->uniform1f(LLViewerShaderMgr::WATER_FOGDENSITY, + param_mgr->getFogDensity()); + gPipeline.mWaterDis.bindTexture(0, screentex); + } + + stop_glerror(); + + gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis); + + if (mVertexShaderLevel == 1) + { + sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue; + shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); + } + + F32 screenRes[] = + { + 1.f/gGLViewport[2], + 1.f/gGLViewport[3] + }; + shader->uniform2fv(sScreenRes, 1, screenRes); + stop_glerror(); + + S32 diffTex = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); + stop_glerror(); + + light_dir.normVec(); + sLightDir = light_dir; + + light_diffuse *= 6.f; + + //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix); + shader->uniform1f(LLViewerShaderMgr::WATER_WATERHEIGHT, eyedepth); + shader->uniform1f(LLViewerShaderMgr::WATER_TIME, sTime); + shader->uniform3fv(LLViewerShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform3fv(LLViewerShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); + shader->uniform1f(LLViewerShaderMgr::WATER_SPECULAR_EXP, light_exp); + shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); + shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); + shader->uniform3fv(LLViewerShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); + + shader->uniform3fv(sNormScale, 1, param_mgr->getNormalScale().mV); + shader->uniform1f(sFresnelScale, param_mgr->getFresnelScale()); + shader->uniform1f(sFresnelOffset, param_mgr->getFresnelOffset()); + shader->uniform1f(sBlurMultiplier, param_mgr->getBlurMultiplier()); + + F32 sunAngle = llmax(0.f, light_dir.mV[2]); + F32 scaledAngle = 1.f - sunAngle; + + shader->uniform1f(sSunAngle, sunAngle); + shader->uniform1f(sScaledAngle, scaledAngle); + shader->uniform1f(sSunAngle2, 0.1f + 0.2f*sunAngle); + + LLColor4 water_color; + LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); + F32 up_dot = camera_up * LLVector3::z_axis; + if (LLViewerCamera::getInstance()->cameraUnderWater()) + { + water_color.setVec(1.f, 1.f, 1.f, 0.4f); + shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); + } + else + { + water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); + shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); + } + + if (water_color.mV[3] > 0.9f) + { + water_color.mV[3] = 0.9f; + } + + { + LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0); + LLGLDisable cullface(GL_CULL_FACE); + for (std::vector::iterator iter = mDrawFace.begin(); + iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + + if (voskyp->isReflFace(face)) + { + continue; + } + + LLVOWater* water = (LLVOWater*) face->getViewerObject(); + gGL.getTexUnit(diffTex)->bind(face->getTexture()); + + sNeedsReflectionUpdate = TRUE; + + if (water->getUseTexture() || !water->getIsEdgePatch()) + { + sNeedsDistortionUpdate = TRUE; + face->renderIndexed(); + } + else if (gGLManager.mHasDepthClamp || deferred_render) + { + face->renderIndexed(); + } + else + { + LLGLSquashToFarClip far_clip(glh_get_current_projection()); + face->renderIndexed(); + } + } + } + + shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); + shader->disableTexture(LLViewerShaderMgr::WATER_SCREENTEX); + shader->disableTexture(LLViewerShaderMgr::BUMP_MAP); + shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); + shader->disableTexture(LLViewerShaderMgr::WATER_REFTEX); + shader->disableTexture(LLViewerShaderMgr::WATER_SCREENDEPTH); + + if (deferred_render) + { + gPipeline.unbindDeferredShader(*shader); + } + else + { + shader->unbind(); + } + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + if (!deferred_render) + { + gGL.setColorMask(true, false); + } + +} + +LLViewerTexture *LLDrawPoolWater::getDebugTexture() +{ + return LLViewerFetchedTexture::sSmokeImagep; +} + +LLColor3 LLDrawPoolWater::getDebugColor() const +{ + return LLColor3(0.f, 1.f, 1.f); +} diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index b5faff7968..b0e69aa9b5 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -152,7 +152,8 @@ void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) cons gGL.translatef(0.f,-camHeightLocal, 0.f); // Draw WL Sky - shader->uniform3f("camPosLocal", 0.f, camHeightLocal, 0.f); + static LLStaticHashedString sCamPosLocal("camPosLocal"); + shader->uniform3f(sCamPosLocal, 0.f, camHeightLocal, 0.f); gSky.mVOWLSkyp->drawDome(); @@ -207,7 +208,8 @@ void LLDrawPoolWLSky::renderStars(void) const if (LLGLSLShader::sNoFixedFunction) { gCustomAlphaProgram.bind(); - gCustomAlphaProgram.uniform1f("custom_alpha", star_alpha.mV[3]); + static LLStaticHashedString sCustomAlpha("custom_alpha"); + gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); } else { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 28e4b32793..3c7a49d5ce 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -55,6 +55,9 @@ #define LL_MAX_INDICES_COUNT 1000000 +static LLStaticHashedString sTextureIndexIn("texture_index_in"); +static LLStaticHashedString sColorIn("color_in"); + BOOL LLFace::sSafeRenderSelect = TRUE; // FALSE #define DOTVEC(a,b) (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1] + a.mV[2]*b.mV[2]) @@ -1417,8 +1420,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, vp[1] = 0; vp[2] = 0; vp[3] = 0; - - gTransformPositionProgram.uniform1i("texture_index_in", val); + + gTransformPositionProgram.uniform1i(sTextureIndexIn, val); glBeginTransformFeedback(GL_POINTS); buff->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -1436,7 +1439,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, S32 val = *((S32*) color.mV); - gTransformColorProgram.uniform1i("color_in", val); + gTransformColorProgram.uniform1i(sColorIn, val); glBeginTransformFeedback(GL_POINTS); buff->setBuffer(LLVertexBuffer::MAP_VERTEX); push_for_transform(buff, vf.mNumVertices, mGeomCount); @@ -1457,7 +1460,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, (glow << 16) | (glow << 24); - gTransformColorProgram.uniform1i("color_in", glow32); + gTransformColorProgram.uniform1i(sColorIn, glow32); glBeginTransformFeedback(GL_POINTS); buff->setBuffer(LLVertexBuffer::MAP_VERTEX); push_for_transform(buff, vf.mNumVertices, mGeomCount); diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index 362308c176..0228807dc8 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -1698,7 +1698,8 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal, gGL.getModelviewMatrix().inverse().mult_vec_matrix(plane); - gClipProgram.uniform4fv("clip_plane", 1, plane.v); + static LLStaticHashedString sClipPlane("clip_plane"); + gClipProgram.uniform4fv(sClipPlane, 1, plane.v); BOOL particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES); BOOL clouds = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ba9818946c..fc7e51d06c 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -52,6 +52,13 @@ #define UNIFORM_ERRS LL_ERRS("Shader") #endif +static LLStaticHashedString sTexture0("texture0"); +static LLStaticHashedString sTexture1("texture1"); +static LLStaticHashedString sTex0("tex0"); +static LLStaticHashedString sTex1("tex1"); +static LLStaticHashedString sGlowMap("glowMap"); +static LLStaticHashedString sScreenMap("screenMap"); + // Lots of STL stuff in here, using namespace std to keep things more readable using std::vector; using std::pair; @@ -305,46 +312,46 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void) { LLShaderMgr::initAttribsAndUniforms(); - mAvatarUniforms.push_back("matrixPalette"); - mAvatarUniforms.push_back("gWindDir"); - mAvatarUniforms.push_back("gSinWaveParams"); - mAvatarUniforms.push_back("gGravity"); + mAvatarUniforms.push_back(LLStaticHashedString("matrixPalette")); + mAvatarUniforms.push_back(LLStaticHashedString("gWindDir")); + mAvatarUniforms.push_back(LLStaticHashedString("gSinWaveParams")); + mAvatarUniforms.push_back(LLStaticHashedString("gGravity")); - mWLUniforms.push_back("camPosLocal"); + mWLUniforms.push_back(LLStaticHashedString("camPosLocal")); mTerrainUniforms.reserve(5); - mTerrainUniforms.push_back("detail_0"); - mTerrainUniforms.push_back("detail_1"); - mTerrainUniforms.push_back("detail_2"); - mTerrainUniforms.push_back("detail_3"); - mTerrainUniforms.push_back("alpha_ramp"); + mTerrainUniforms.push_back(LLStaticHashedString("detail_0")); + mTerrainUniforms.push_back(LLStaticHashedString("detail_1")); + mTerrainUniforms.push_back(LLStaticHashedString("detail_2")); + mTerrainUniforms.push_back(LLStaticHashedString("detail_3")); + mTerrainUniforms.push_back(LLStaticHashedString("alpha_ramp")); - mGlowUniforms.push_back("glowDelta"); - mGlowUniforms.push_back("glowStrength"); + mGlowUniforms.push_back(LLStaticHashedString("glowDelta")); + mGlowUniforms.push_back(LLStaticHashedString("glowStrength")); - mGlowExtractUniforms.push_back("minLuminance"); - mGlowExtractUniforms.push_back("maxExtractAlpha"); - mGlowExtractUniforms.push_back("lumWeights"); - mGlowExtractUniforms.push_back("warmthWeights"); - mGlowExtractUniforms.push_back("warmthAmount"); + mGlowExtractUniforms.push_back(LLStaticHashedString("minLuminance")); + mGlowExtractUniforms.push_back(LLStaticHashedString("maxExtractAlpha")); + mGlowExtractUniforms.push_back(LLStaticHashedString("lumWeights")); + mGlowExtractUniforms.push_back(LLStaticHashedString("warmthWeights")); + mGlowExtractUniforms.push_back(LLStaticHashedString("warmthAmount")); - mShinyUniforms.push_back("origin"); + mShinyUniforms.push_back(LLStaticHashedString("origin")); mWaterUniforms.reserve(12); - mWaterUniforms.push_back("screenTex"); - mWaterUniforms.push_back("screenDepth"); - mWaterUniforms.push_back("refTex"); - mWaterUniforms.push_back("eyeVec"); - mWaterUniforms.push_back("time"); - mWaterUniforms.push_back("d1"); - mWaterUniforms.push_back("d2"); - mWaterUniforms.push_back("lightDir"); - mWaterUniforms.push_back("specular"); - mWaterUniforms.push_back("lightExp"); - mWaterUniforms.push_back("fogCol"); - mWaterUniforms.push_back("kd"); - mWaterUniforms.push_back("refScale"); - mWaterUniforms.push_back("waterHeight"); + mWaterUniforms.push_back(LLStaticHashedString("screenTex")); + mWaterUniforms.push_back(LLStaticHashedString("screenDepth")); + mWaterUniforms.push_back(LLStaticHashedString("refTex")); + mWaterUniforms.push_back(LLStaticHashedString("eyeVec")); + mWaterUniforms.push_back(LLStaticHashedString("time")); + mWaterUniforms.push_back(LLStaticHashedString("d1")); + mWaterUniforms.push_back(LLStaticHashedString("d2")); + mWaterUniforms.push_back(LLStaticHashedString("lightDir")); + mWaterUniforms.push_back(LLStaticHashedString("specular")); + mWaterUniforms.push_back(LLStaticHashedString("lightExp")); + mWaterUniforms.push_back(LLStaticHashedString("fogCol")); + mWaterUniforms.push_back(LLStaticHashedString("kd")); + mWaterUniforms.push_back(LLStaticHashedString("refScale")); + mWaterUniforms.push_back(LLStaticHashedString("waterHeight")); } } @@ -2091,8 +2098,8 @@ BOOL LLViewerShaderMgr::loadShadersObject() if (success) { //lldrawpoolbump assumes "texture0" has channel 0 and "texture1" has channel 1 gObjectBumpProgram.bind(); - gObjectBumpProgram.uniform1i("texture0", 0); - gObjectBumpProgram.uniform1i("texture1", 1); + gObjectBumpProgram.uniform1i(sTexture0, 0); + gObjectBumpProgram.uniform1i(sTexture1, 1); gObjectBumpProgram.unbind(); } } @@ -2651,7 +2658,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() if (success) { gSplatTextureRectProgram.bind(); - gSplatTextureRectProgram.uniform1i("screenMap", 0); + gSplatTextureRectProgram.uniform1i(sScreenMap, 0); gSplatTextureRectProgram.unbind(); } } @@ -2667,8 +2674,8 @@ BOOL LLViewerShaderMgr::loadShadersInterface() if (success) { gGlowCombineProgram.bind(); - gGlowCombineProgram.uniform1i("glowMap", 0); - gGlowCombineProgram.uniform1i("screenMap", 1); + gGlowCombineProgram.uniform1i(sGlowMap, 0); + gGlowCombineProgram.uniform1i(sScreenMap, 1); gGlowCombineProgram.unbind(); } } @@ -2684,8 +2691,8 @@ BOOL LLViewerShaderMgr::loadShadersInterface() if (success) { gGlowCombineFXAAProgram.bind(); - gGlowCombineFXAAProgram.uniform1i("glowMap", 0); - gGlowCombineFXAAProgram.uniform1i("screenMap", 1); + gGlowCombineFXAAProgram.uniform1i(sGlowMap, 0); + gGlowCombineFXAAProgram.uniform1i(sScreenMap, 1); gGlowCombineFXAAProgram.unbind(); } } @@ -2702,8 +2709,8 @@ BOOL LLViewerShaderMgr::loadShadersInterface() if (success) { gTwoTextureAddProgram.bind(); - gTwoTextureAddProgram.uniform1i("tex0", 0); - gTwoTextureAddProgram.uniform1i("tex1", 1); + gTwoTextureAddProgram.uniform1i(sTex0, 0); + gTwoTextureAddProgram.uniform1i(sTex1, 1); } } @@ -2718,7 +2725,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() if (success) { gOneTextureNoColorProgram.bind(); - gOneTextureNoColorProgram.uniform1i("tex0", 0); + gOneTextureNoColorProgram.uniform1i(sTex0, 0); } } @@ -2733,7 +2740,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() if (success) { gSolidColorProgram.bind(); - gSolidColorProgram.uniform1i("tex0", 0); + gSolidColorProgram.uniform1i(sTex0, 0); gSolidColorProgram.unbind(); } } diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index d6dd645e8c..999baa0ad0 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -177,22 +177,24 @@ public: private: - std::vector mShinyUniforms; + typedef std::vector< LLStaticHashedString > UniformVec; + + UniformVec mShinyUniforms; //water parameters - std::vector mWaterUniforms; + UniformVec mWaterUniforms; - std::vector mWLUniforms; + UniformVec mWLUniforms; //terrain parameters - std::vector mTerrainUniforms; + UniformVec mTerrainUniforms; //glow parameters - std::vector mGlowUniforms; + UniformVec mGlowUniforms; - std::vector mGlowExtractUniforms; + UniformVec mGlowExtractUniforms; - std::vector mAvatarUniforms; + UniformVec mAvatarUniforms; // the list of shaders we need to propagate parameters to. std::vector mShaderList; diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 4f52ff9778..376715a2d6 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -57,6 +57,14 @@ #include "curl/curl.h" +static LLStaticHashedString sCamPosLocal("camPosLocal"); +static LLStaticHashedString sWaterFogColor("waterFogColor"); +static LLStaticHashedString sWaterFogEnd("waterFogEnd"); +static LLStaticHashedString sWaterPlane("waterPlane"); +static LLStaticHashedString sWaterFogDensity("waterFogDensity"); +static LLStaticHashedString sWaterFogKS("waterFogKS"); +static LLStaticHashedString sDistanceMultiplier("distance_multiplier"); + LLWaterParamManager::LLWaterParamManager() : mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), mFogDensity(4, "waterFogDensity", 2), @@ -188,13 +196,13 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::getInstance()->getRotatedLightDir().mV); - shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform4fv("waterFogColor", 1, LLDrawPoolWater::sWaterFogColor.mV); - shader->uniform1f("waterFogEnd", LLDrawPoolWater::sWaterFogEnd); - shader->uniform4fv("waterPlane", 1, mWaterPlane.mV); - shader->uniform1f("waterFogDensity", getFogDensity()); - shader->uniform1f("waterFogKS", mWaterFogKS); - shader->uniform1f("distance_multiplier", 0); + shader->uniform3fv(sCamPosLocal, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform4fv(sWaterFogColor, 1, LLDrawPoolWater::sWaterFogColor.mV); + shader->uniform1f(sWaterFogEnd, LLDrawPoolWater::sWaterFogEnd); + shader->uniform4fv(sWaterPlane, 1, mWaterPlane.mV); + shader->uniform1f(sWaterFogDensity, getFogDensity()); + shader->uniform1f(sWaterFogKS, mWaterFogKS); + shader->uniform1f(sDistanceMultiplier, 0); } } diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 6077208799..65cb80c3e7 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -61,6 +61,9 @@ #include "curl/curl.h" #include "llstreamtools.h" +static LLStaticHashedString sCamPosLocal("camPosLocal"); +static LLStaticHashedString sSceneLightStrength("scene_light_strength"); + LLWLParamManager::LLWLParamManager() : //set the defaults for the controls @@ -352,7 +355,7 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) { shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV); - shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform3fv(sCamPosLocal, 1, LLViewerCamera::getInstance()->getOrigin().mV); } else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) @@ -360,7 +363,7 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDir.mV); } - shader->uniform1f("scene_light_strength", mSceneLightStrength); + shader->uniform1f(sSceneLightStrength, mSceneLightStrength); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4306b3da12..92c5ac8583 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -253,6 +253,17 @@ LLFastTimer::DeclareTimer FTM_RENDER_DEFERRED("Deferred Shading"); static LLFastTimer::DeclareTimer FTM_STATESORT_DRAWABLE("Sort Drawables"); static LLFastTimer::DeclareTimer FTM_STATESORT_POSTSORT("Post Sort"); +static LLStaticHashedString sTint("tint"); +static LLStaticHashedString sAmbiance("ambiance"); +static LLStaticHashedString sAlphaScale("alpha_scale"); +static LLStaticHashedString sNormMat("norm_mat"); +static LLStaticHashedString sOffset("offset"); +static LLStaticHashedString sScreenRes("screenRes"); +static LLStaticHashedString sDelta("delta"); +static LLStaticHashedString sDistFactor("dist_factor"); +static LLStaticHashedString sKern("kern"); +static LLStaticHashedString sKernScale("kern_scale"); + //---------------------------------------- std::string gPoolNames[] = { @@ -4621,9 +4632,9 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { gPathfindingProgram.bind(); - gPathfindingProgram.uniform1f("tint", 1.f); - gPathfindingProgram.uniform1f("ambiance", 1.f); - gPathfindingProgram.uniform1f("alpha_scale", 1.f); + gPathfindingProgram.uniform1f(sTint, 1.f); + gPathfindingProgram.uniform1f(sAmbiance, 1.f); + gPathfindingProgram.uniform1f(sAlphaScale, 1.f); } //Requried character physics capsule render parameters @@ -4640,7 +4651,7 @@ void LLPipeline::renderDebug() llPathingLibInstance->renderSimpleShapeCapsuleID( gGL, id, pos, rot ); gGL.setColorMask(true, false); LLGLEnable blend(GL_BLEND); - gPathfindingProgram.uniform1f("alpha_scale", 0.90f); + gPathfindingProgram.uniform1f(sAlphaScale, 0.90f); llPathingLibInstance->renderSimpleShapeCapsuleID( gGL, id, pos, rot ); gPathfindingProgram.bind(); } @@ -4667,9 +4678,9 @@ void LLPipeline::renderDebug() { gPathfindingProgram.bind(); - gPathfindingProgram.uniform1f("tint", 1.f); - gPathfindingProgram.uniform1f("ambiance", ambiance); - gPathfindingProgram.uniform1f("alpha_scale", 1.f); + gPathfindingProgram.uniform1f(sTint, 1.f); + gPathfindingProgram.uniform1f(sAmbiance, ambiance); + gPathfindingProgram.uniform1f(sAlphaScale, 1.f); } if ( !pathfindingConsole->isRenderWorld() ) @@ -4693,7 +4704,7 @@ void LLPipeline::renderDebug() if ( pathfindingConsole->isRenderWorld() ) { LLGLEnable blend(GL_BLEND); - gPathfindingProgram.uniform1f("alpha_scale", 0.66f); + gPathfindingProgram.uniform1f(sAlphaScale, 0.66f); llPathingLibInstance->renderNavMesh(); } else @@ -4705,8 +4716,8 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { gPathfindingNoNormalsProgram.bind(); - gPathfindingNoNormalsProgram.uniform1f("tint", 1.f); - gPathfindingNoNormalsProgram.uniform1f("alpha_scale", 1.f); + gPathfindingNoNormalsProgram.uniform1f(sTint, 1.f); + gPathfindingNoNormalsProgram.uniform1f(sAlphaScale, 1.f); llPathingLibInstance->renderNavMeshEdges(); gPathfindingProgram.bind(); } @@ -4746,7 +4757,7 @@ void LLPipeline::renderDebug() gGL.setColorMask(true, false); //render the bookends LLGLEnable blend(GL_BLEND); - gPathfindingProgram.uniform1f("alpha_scale", 0.90f); + gPathfindingProgram.uniform1f(sAlphaScale, 0.90f); llPathingLibInstance->renderPathBookend( gGL, LLPathingLib::LLPL_START ); llPathingLibInstance->renderPathBookend( gGL, LLPathingLib::LLPL_END ); gPathfindingProgram.bind(); @@ -4764,7 +4775,7 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { LLGLEnable blend(GL_BLEND); - gPathfindingProgram.uniform1f("alpha_scale", 0.90f); + gPathfindingProgram.uniform1f(sAlphaScale, 0.90f); llPathingLibInstance->renderSimpleShapes( gGL, gAgent.getRegion()->getWaterHeight() ); } else @@ -4812,7 +4823,7 @@ void LLPipeline::renderDebug() LLGLEnable blend(GL_BLEND); { - gPathfindingProgram.uniform1f("ambiance", ambiance); + gPathfindingProgram.uniform1f(sAmbiance, ambiance); { //draw solid overlay LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_LEQUAL); @@ -4827,8 +4838,8 @@ void LLPipeline::renderDebug() if (pathfindingConsole->isRenderXRay()) { - gPathfindingProgram.uniform1f("tint", gSavedSettings.getF32("PathfindingXRayTint")); - gPathfindingProgram.uniform1f("alpha_scale", gSavedSettings.getF32("PathfindingXRayOpacity")); + gPathfindingProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint")); + gPathfindingProgram.uniform1f(sAlphaScale, gSavedSettings.getF32("PathfindingXRayOpacity")); LLGLEnable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER); @@ -4836,13 +4847,13 @@ void LLPipeline::renderDebug() if (gSavedSettings.getBOOL("PathfindingXRayWireframe")) { //draw hidden wireframe as darker and less opaque - gPathfindingProgram.uniform1f("ambiance", 1.f); + gPathfindingProgram.uniform1f(sAmbiance, 1.f); llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] ); } else { glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - gPathfindingProgram.uniform1f("ambiance", ambiance); + gPathfindingProgram.uniform1f(sAmbiance, ambiance); llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] ); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } @@ -4850,9 +4861,9 @@ void LLPipeline::renderDebug() { //draw visible wireframe as brighter, thicker and more opaque glPolygonOffset(offset, offset); - gPathfindingProgram.uniform1f("ambiance", 1.f); - gPathfindingProgram.uniform1f("tint", 1.f); - gPathfindingProgram.uniform1f("alpha_scale", 1.f); + gPathfindingProgram.uniform1f(sAmbiance, 1.f); + gPathfindingProgram.uniform1f(sTint, 1.f); + gPathfindingProgram.uniform1f(sAlphaScale, 1.f); glLineWidth(gSavedSettings.getF32("PathfindingLineWidth")); LLGLDisable blendOut(GL_BLEND); @@ -4884,19 +4895,19 @@ void LLPipeline::renderDebug() glLineWidth(2.0f); LLGLEnable cull(GL_CULL_FACE); - gPathfindingProgram.uniform1f("tint", gSavedSettings.getF32("PathfindingXRayTint")); - gPathfindingProgram.uniform1f("alpha_scale", gSavedSettings.getF32("PathfindingXRayOpacity")); + gPathfindingProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint")); + gPathfindingProgram.uniform1f(sAlphaScale, gSavedSettings.getF32("PathfindingXRayOpacity")); if (gSavedSettings.getBOOL("PathfindingXRayWireframe")) { //draw hidden wireframe as darker and less opaque glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - gPathfindingProgram.uniform1f("ambiance", 1.f); + gPathfindingProgram.uniform1f(sAmbiance, 1.f); llPathingLibInstance->renderNavMesh(); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } else { - gPathfindingProgram.uniform1f("ambiance", ambiance); + gPathfindingProgram.uniform1f(sAmbiance, ambiance); llPathingLibInstance->renderNavMesh(); } @@ -4904,8 +4915,8 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { gPathfindingNoNormalsProgram.bind(); - gPathfindingNoNormalsProgram.uniform1f("tint", gSavedSettings.getF32("PathfindingXRayTint")); - gPathfindingNoNormalsProgram.uniform1f("alpha_scale", gSavedSettings.getF32("PathfindingXRayOpacity")); + gPathfindingNoNormalsProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint")); + gPathfindingNoNormalsProgram.uniform1f(sAlphaScale, gSavedSettings.getF32("PathfindingXRayOpacity")); llPathingLibInstance->renderNavMeshEdges(); gPathfindingProgram.bind(); } @@ -7858,11 +7869,11 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); - - if (shader.getUniformLocation("norm_mat") >= 0) + static LLStaticHashedString sNormMat("norm_mat"); + if (shader.getUniformLocation(sNormMat) >= 0) { glh::matrix4f norm_mat = glh_get_current_modelview().inverse().transpose(); - shader.uniformMatrix4fv("norm_mat", 1, FALSE, norm_mat.m); + shader.uniformMatrix4fv(sNormMat, 1, FALSE, norm_mat.m); } } @@ -7972,8 +7983,8 @@ void LLPipeline::renderDeferredLighting() } } - gDeferredSunProgram.uniform3fv("offset", slice, offset); - gDeferredSunProgram.uniform2f("screenRes", mDeferredLight.getWidth(), mDeferredLight.getHeight()); + gDeferredSunProgram.uniform3fv(sOffset, slice, offset); + gDeferredSunProgram.uniform2f(sScreenRes, mDeferredLight.getWidth(), mDeferredLight.getHeight()); { LLGLDisable blend(GL_BLEND); @@ -8017,10 +8028,10 @@ void LLPipeline::renderDeferredLighting() x += 1.f; } - gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f); - gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor); - gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV); - gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f)); + gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); + gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor); + gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV); + gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length/2.f - 0.5f)); { LLGLDisable blend(GL_BLEND); @@ -8037,7 +8048,7 @@ void LLPipeline::renderDeferredLighting() mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredLight.bindTarget(); - gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f); + gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); { LLGLDisable blend(GL_BLEND); -- cgit v1.2.3 From 2dcbbf04c9375e2de877956476e0a58219a169cf Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 28 Feb 2013 09:45:43 -0800 Subject: Improve curl/ares init behavior by duping handles instead of calling easy_init --- indra/llcorehttp/_httpoprequest.cpp | 30 +++++++----------------------- indra/llcorehttp/_httpoprequest.h | 4 +++- indra/llmessage/llcurl.cpp | 25 +++++++++++++++++++++++-- indra/llmessage/llcurl.h | 10 +++++++++- 4 files changed, 42 insertions(+), 27 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 51a8eaf998..469ce75434 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -339,7 +339,6 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, } } - // Sets all libcurl options and data for a request. // // Used both for initial requests and to 'reload' for @@ -381,13 +380,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) // Get policy options HttpPolicyGlobal & policy(service->getPolicy().getGlobalOptions()); - mCurlHandle = curl_easy_init(); - curl_easy_setopt(mCurlHandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); - curl_easy_setopt(mCurlHandle, CURLOPT_NOSIGNAL, 1); - curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1); - curl_easy_setopt(mCurlHandle, CURLOPT_URL, mReqURL.c_str()); - curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, this); - curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, ""); + mCurlHandle = LLCurlHandleHandler::getInstance()->CreateCurlHandle(); if (HTTP_ENABLE_LINKSYS_WRT54G_V5_DNS_FIX) { @@ -399,23 +392,14 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) // seconds and no RSTs. curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, 15); } - else - { - // *TODO: Revisit this old DNS timeout setting - may no longer be valid - // I don't think this is valid anymore, the Multi shared DNS - // cache is working well. For the case of naked easy handles, - // consider using a shared DNS object. - curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, 0); - } - curl_easy_setopt(mCurlHandle, CURLOPT_AUTOREFERER, 1); - curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(mCurlHandle, CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT); + curl_easy_setopt(mCurlHandle, CURLOPT_WRITEFUNCTION, writeCallback); - curl_easy_setopt(mCurlHandle, CURLOPT_WRITEDATA, this); - curl_easy_setopt(mCurlHandle, CURLOPT_READFUNCTION, readCallback); + curl_easy_setopt(mCurlHandle, CURLOPT_READFUNCTION, readCallback); curl_easy_setopt(mCurlHandle, CURLOPT_READDATA, this); - curl_easy_setopt(mCurlHandle, CURLOPT_SSL_VERIFYPEER, 1); - curl_easy_setopt(mCurlHandle, CURLOPT_SSL_VERIFYHOST, 0); + curl_easy_setopt(mCurlHandle, CURLOPT_WRITEDATA, this); + curl_easy_setopt(mCurlHandle, CURLOPT_URL, mReqURL.c_str()); + curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, this); + curl_easy_setopt(mCurlHandle, CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT); const std::string * opt_value(NULL); long opt_long(0L); diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 7b65d17783..e819f74079 100644 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -29,6 +29,7 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces +#include "llsingleton.h" #include #include @@ -60,12 +61,13 @@ class HttpOptions; /// the information needed to make a working request which can /// then be enqueued to a request queue. /// - class HttpOpRequest : public HttpOperation { public: HttpOpRequest(); + friend class CurlHandleHandler; + protected: virtual ~HttpOpRequest(); // Use release() diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 6da153279c..5b9965680d 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -1813,10 +1813,10 @@ CURL* LLCurl::newEasyHandle() } sTotalHandles++; - CURL* ret = curl_easy_init() ; + CURL* ret = LLCurlHandleHandler::getInstance()->CreateCurlHandle(); if(!ret) { - llwarns << "curl_easy_init failed." << llendl ; + llwarns << "failed to create curl handle." << llendl ; } return ret ; @@ -1846,3 +1846,24 @@ void LLCurlFF::check_multi_code(CURLMcode code) { check_curl_multi_code(code); } + +CURL* LLCurlHandleHandler::the_one_true_curl_handle; + +LLCurlHandleHandler::LLCurlHandleHandler() +{ + the_one_true_curl_handle = curl_easy_init(); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_NOSIGNAL, 1); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_NOPROGRESS, 1); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_ENCODING, ""); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_AUTOREFERER, 1); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_SSL_VERIFYPEER, 1); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_SSL_VERIFYHOST, 0); + curl_easy_setopt(the_one_true_curl_handle, CURLOPT_DNS_CACHE_TIMEOUT, 0); +} + +CURL* LLCurlHandleHandler::CreateCurlHandle() +{ + return curl_easy_duphandle(the_one_true_curl_handle); +} diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index 7bcf61e233..a03333157c 100644 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -45,7 +45,7 @@ #include "llqueuedthread.h" #include "llframetimer.h" #include "llpointer.h" - +#include "llsingleton.h" class LLMutex; class LLCurlThread; @@ -53,6 +53,14 @@ class LLCurlThread; // For whatever reason, this is not typedef'd in curl.h typedef size_t (*curl_header_callback)(void *ptr, size_t size, size_t nmemb, void *stream); +class LLCurlHandleHandler : public LLSingleton +{ +public: + static CURL* the_one_true_curl_handle; + LLCurlHandleHandler(); + static CURL* CreateCurlHandle(); +}; + class LLCurl { LOG_CLASS(LLCurl); -- cgit v1.2.3 From 93eaccae6fe6e8442a3c6e5a2d40a408aa44df77 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 28 Feb 2013 15:35:14 -0800 Subject: Modify LLInstanceTracker to avoid using a map of strings to find a map of foo to find some pointers --- indra/llcommon/lleventapi.h | 5 ++-- indra/llcommon/lleventtimer.h | 3 ++- indra/llcommon/llfasttimer.h | 5 ++-- indra/llcommon/llinstancetracker.cpp | 14 ++++------- indra/llcommon/llinstancetracker.h | 46 +++++++++++++++++++++++++++-------- indra/llcommon/llleap.h | 3 ++- indra/llrender/llgl.h | 4 +-- indra/llui/llconsole.h | 3 ++- indra/llui/llfloater.h | 5 +++- indra/llui/lllayoutstack.h | 3 ++- indra/llui/llnotifications.h | 5 ++-- indra/llwindow/llwindow.h | 3 ++- indra/llxml/llcontrol.cpp | 2 +- indra/llxml/llcontrol.h | 10 ++++---- indra/newview/lldrawable.cpp | 6 +++++ indra/newview/llfloaterwebcontent.cpp | 2 +- indra/newview/llfloaterwebcontent.h | 5 ++-- indra/newview/llmediactrl.cpp | 2 +- indra/newview/llmediactrl.h | 3 ++- indra/newview/llnamelistctrl.h | 3 ++- indra/newview/lltoast.cpp | 2 +- indra/newview/lltoast.h | 3 ++- 22 files changed, 90 insertions(+), 47 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h index 1a37d780b6..10c7e7a23f 100644 --- a/indra/llcommon/lleventapi.h +++ b/indra/llcommon/lleventapi.h @@ -41,12 +41,13 @@ * Deriving from LLInstanceTracker lets us enumerate instances. */ class LL_COMMON_API LLEventAPI: public LLDispatchListener, - public LLInstanceTracker + public INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) { typedef LLDispatchListener lbase; - typedef LLInstanceTracker ibase; + typedef INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) ibase; public: + /** * @param name LLEventPump name on which this LLEventAPI will listen. This * also serves as the LLInstanceTracker instance key. diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h index 7f42623d01..e55f851758 100644 --- a/indra/llcommon/lleventtimer.h +++ b/indra/llcommon/lleventtimer.h @@ -33,9 +33,10 @@ #include "lltimer.h" // class for scheduling a function to be called at a given frequency (approximate, inprecise) -class LL_COMMON_API LLEventTimer : public LLInstanceTracker +class LL_COMMON_API LLEventTimer : public INSTANCE_TRACKER(LLEventTimer) { public: + LLEventTimer(F32 period); // period is the amount of time between each call to tick() in seconds LLEventTimer(const LLDate& time); virtual ~LLEventTimer(); diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e42e549df5..440d42ab5a 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -63,7 +63,7 @@ public: // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances class LL_COMMON_API NamedTimer - : public LLInstanceTracker + : public LLInstanceTracker { friend class DeclareTimer; public: @@ -137,10 +137,11 @@ public: // used to statically declare a new named timer class LL_COMMON_API DeclareTimer - : public LLInstanceTracker + : public LLInstanceTracker< DeclareTimer, InstanceTrackType_DeclareTimer > { friend class LLFastTimer; public: + DeclareTimer(const std::string& name, bool open); DeclareTimer(const std::string& name); diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 5dc3ea5d7b..0804be358f 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -32,18 +32,14 @@ // external library headers // other Linden headers -//static -void * & LLInstanceTrackerBase::getInstances(std::type_info const & info) -{ - typedef std::map InstancesMap; - static InstancesMap instances; +static void* sInstanceTrackerData[ kInstanceTrackTypeCount ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t) +{ // std::map::insert() is just what we want here. You attempt to insert a // (key, value) pair. If the specified key doesn't yet exist, it inserts // the pair and returns a std::pair of (iterator, true). If the specified // key DOES exist, insert() simply returns (iterator, false). One lookup // handles both cases. - return instances.insert(InstancesMap::value_type(info.name(), - InstancesMap::mapped_type())) - .first->second; -} + return sInstanceTrackerData[t]; +} \ No newline at end of file diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 403df08990..70bccde992 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -38,6 +38,31 @@ #include #include +enum InstanceTrackType +{ + InstanceTrackType_LLEventAPI, + InstanceTrackType_LLEventTimer, + InstanceTrackType_NamedTimer, + InstanceTrackType_DeclareTimer, + InstanceTrackType_LLLeap, + InstanceTrackType_LLGLNamePool, + InstanceTrackType_LLConsole, + InstanceTrackType_LLFloater, + InstanceTrackType_LLFloaterWebContent, + InstanceTrackType_LLLayoutStack, + InstanceTrackType_LLNotificationContext, + InstanceTrackType_LLWindow, + InstanceTrackType_LLControlGroup, + InstanceTrackType_LLControlCache, + InstanceTrackType_LLMediaCtrl, + InstanceTrackType_LLNameListCtrl, + InstanceTrackType_LLToast, + kInstanceTrackTypeCount +}; + +#define INSTANCE_TRACKER(T) LLInstanceTracker< T, InstanceTrackType_##T > +#define INSTANCE_TRACKER_KEYED(T,K) LLInstanceTracker< T, InstanceTrackType_##T, K > + /** * Base class manages "class-static" data that must actually have singleton * semantics: one instance per process, rather than one instance per module as @@ -47,14 +72,15 @@ class LL_COMMON_API LLInstanceTrackerBase : public boost::noncopyable { protected: /// Get a process-unique void* pointer slot for the specified type_info - static void * & getInstances(std::type_info const & info); + //static void * & getInstances(std::type_info const & info); + static void * & getInstances(InstanceTrackType t); /// Find or create a STATICDATA instance for the specified TRACKED class. /// STATICDATA must be default-constructible. - template + template static STATICDATA& getStatic() { - void *& instances = getInstances(typeid(TRACKED)); + void *& instances = getInstances(TRACKEDTYPE); if (! instances) { instances = new STATICDATA; @@ -78,16 +104,16 @@ protected: /// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup /// If KEY is not provided, then instances are stored in a simple set /// @NOTE: see explicit specialization below for default KEY==T* case -template +template class LLInstanceTracker : public LLInstanceTrackerBase { - typedef LLInstanceTracker MyT; + typedef LLInstanceTracker MyT; typedef typename std::map InstanceMap; struct StaticData: public StaticBase { InstanceMap sMap; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } + static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } static InstanceMap& getMap_() { return getStatic().sMap; } public: @@ -226,16 +252,16 @@ private: /// explicit specialization for default case where KEY is T* /// use a simple std::set -template -class LLInstanceTracker : public LLInstanceTrackerBase +template +class LLInstanceTracker : public LLInstanceTrackerBase { - typedef LLInstanceTracker MyT; + typedef LLInstanceTracker MyT; typedef typename std::set InstanceSet; struct StaticData: public StaticBase { InstanceSet sSet; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } + static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } static InstanceSet& getSet_() { return getStatic().sSet; } public: diff --git a/indra/llcommon/llleap.h b/indra/llcommon/llleap.h index 1a1ad23d39..d4e138f4be 100644 --- a/indra/llcommon/llleap.h +++ b/indra/llcommon/llleap.h @@ -29,9 +29,10 @@ * LLLeap* pointer should be validated before use by * LLLeap::getInstance(LLLeap*) (see LLInstanceTracker). */ -class LL_COMMON_API LLLeap: public LLInstanceTracker +class LL_COMMON_API LLLeap: public INSTANCE_TRACKER(LLLeap) { public: + /** * Pass a brief string description, mostly for logging purposes. The desc * need not be unique, but obviously the clearer we can make it, the diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 823de9d361..133c2de1f5 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -350,10 +350,10 @@ public: Generic pooling scheme for things which use GL names (used for occlusion queries and vertex buffer objects). Prevents thrashing of GL name caches by avoiding calls to glGenFoo and glDeleteFoo. */ -class LLGLNamePool : public LLInstanceTracker +class LLGLNamePool : public INSTANCE_TRACKER(LLGLNamePool) { public: - typedef LLInstanceTracker tracker_t; + typedef INSTANCE_TRACKER(LLGLNamePool) tracker_t; struct NameEntry { diff --git a/indra/llui/llconsole.h b/indra/llui/llconsole.h index f32f1dd74c..b264aeb7eb 100644 --- a/indra/llui/llconsole.h +++ b/indra/llui/llconsole.h @@ -34,9 +34,10 @@ class LLSD; -class LLConsole : public LLFixedBuffer, public LLUICtrl, public LLInstanceTracker +class LLConsole : public LLFixedBuffer, public LLUICtrl, public INSTANCE_TRACKER(LLConsole) { public: + typedef enum e_font_size { MONOSPACE = -1, diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index aef63bcf93..113fdf10e4 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -112,15 +112,18 @@ struct LLCoordFloater : LLCoord bool operator!=(const LLCoordFloater& other) const { return !(*this == other); } void setFloater(LLFloater& floater); + + }; -class LLFloater : public LLPanel, public LLInstanceTracker +class LLFloater : public LLPanel, public INSTANCE_TRACKER(LLFloater) { friend class LLFloaterView; friend class LLFloaterReg; friend class LLMultiFloater; public: + struct KeyCompare { // static bool compare(const LLSD& a, const LLSD& b); diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 648cd5fdce..26b8a7f973 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -34,9 +34,10 @@ class LLLayoutPanel; -class LLLayoutStack : public LLView, public LLInstanceTracker +class LLLayoutStack : public LLView, public INSTANCE_TRACKER(LLLayoutStack) { public: + typedef enum e_layout_orientation { HORIZONTAL, diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index d7534c416d..faeba8f6eb 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -136,10 +136,11 @@ typedef LLFunctorRegistration LLNotificationFunctorRegi // context data that can be looked up via a notification's payload by the display logic // derive from this class to implement specific contexts -class LLNotificationContext : public LLInstanceTracker +class LLNotificationContext : public INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID) { public: - LLNotificationContext() : LLInstanceTracker(LLUUID::generateNewID()) + + LLNotificationContext() : INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID)(LLUUID::generateNewID()) { } diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index e9147d552e..06d7e4907a 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -39,9 +39,10 @@ class LLWindowCallbacks; // Refer to llwindow_test in test/common/llwindow for usage example -class LLWindow : public LLInstanceTracker +class LLWindow : public INSTANCE_TRACKER(LLWindow) { public: + struct LLWindowResolution { S32 mWidth; diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 53d9380f4f..561f4fdc73 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -316,7 +316,7 @@ LLPointer LLControlGroup::getControl(const std::string& name) //////////////////////////////////////////////////////////////////////////// LLControlGroup::LLControlGroup(const std::string& name) -: LLInstanceTracker(name) +: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { mTypeString[TYPE_U32] = "U32"; mTypeString[TYPE_S32] = "S32"; diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index ee7d1d50b7..6ea010f4f9 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -180,7 +180,7 @@ T convert_from_llsd(const LLSD& sd, eControlType type, const std::string& contro } //const U32 STRING_CACHE_SIZE = 10000; -class LLControlGroup : public LLInstanceTracker +class LLControlGroup : public INSTANCE_TRACKER_KEYED(LLControlGroup, std::string) { LOG_CLASS(LLControlGroup); @@ -197,7 +197,7 @@ public: ~LLControlGroup(); void cleanup(); - typedef LLInstanceTracker::instance_iter instance_iter; + typedef INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)::instance_iter instance_iter; LLControlVariablePtr getControl(const std::string& name); @@ -306,7 +306,7 @@ public: //! without have to manually create and bind a listener to a local //! object. template -class LLControlCache : public LLRefCount, public LLInstanceTracker, std::string> +class LLControlCache : public LLRefCount, public LLInstanceTracker, InstanceTrackType_LLControlCache, std::string> { public: // This constructor will declare a control if it doesn't exist in the contol group @@ -314,7 +314,7 @@ public: const std::string& name, const T& default_value, const std::string& comment) - : LLInstanceTracker, std::string >(name) + : LLInstanceTracker, InstanceTrackType_LLControlCache, std::string >(name) { if(!group.controlExists(name)) { @@ -329,7 +329,7 @@ public: LLControlCache(LLControlGroup& group, const std::string& name) - : LLInstanceTracker, std::string >(name) + : LLInstanceTracker, InstanceTrackType_LLControlCache, std::string >(name) { if(!group.controlExists(name)) { diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index d041baea90..119b8d24d0 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -577,6 +577,12 @@ F32 LLDrawable::updateXform(BOOL undamped) mVObjp->dirtySpatialGroup(); } } + else if (!isRoot() + && ( dist_vec_squared(old_pos, target_pos) > 0.f + || (1.f - dot(old_rot, target_rot)) > 0.f)) + { // update child prims moved from LSL + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } else if (!getVOVolume() && !isAvatar()) { movePartition(); diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index 3fe2518de6..94c3f4149c 100644 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -54,7 +54,7 @@ LLFloaterWebContent::_Params::_Params() LLFloaterWebContent::LLFloaterWebContent( const Params& params ) : LLFloater( params ), - LLInstanceTracker(params.id()), + INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string)(params.id()), mWebBrowser(NULL), mAddressCombo(NULL), mSecureLockIcon(NULL), diff --git a/indra/newview/llfloaterwebcontent.h b/indra/newview/llfloaterwebcontent.h index cfc87e9015..409c15fb0b 100644 --- a/indra/newview/llfloaterwebcontent.h +++ b/indra/newview/llfloaterwebcontent.h @@ -40,10 +40,11 @@ class LLIconCtrl; class LLFloaterWebContent : public LLFloater, public LLViewerMediaObserver, - public LLInstanceTracker + public INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string) { public: - typedef LLInstanceTracker instance_tracker_t; + + typedef INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string) instance_tracker_t; LOG_CLASS(LLFloaterWebContent); struct _Params : public LLInitParam::Block<_Params> diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 99b4707158..48730f0f20 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -81,7 +81,7 @@ LLMediaCtrl::Params::Params() LLMediaCtrl::LLMediaCtrl( const Params& p) : LLPanel( p ), - LLInstanceTracker(LLUUID::generateNewID()), + INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID)(LLUUID::generateNewID()), mTextureDepthBytes( 4 ), mBorder(NULL), mFrequentUpdates( true ), diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index 7f2a5e1642..4fed21bf22 100644 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -42,10 +42,11 @@ class LLMediaCtrl : public LLPanel, public LLViewerMediaObserver, public LLViewerMediaEventEmitter, - public LLInstanceTracker + public INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID) { LOG_CLASS(LLMediaCtrl); public: + struct Params : public LLInitParam::Block { Optional start_url; diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h index 09c3d49fe7..103806a1bd 100644 --- a/indra/newview/llnamelistctrl.h +++ b/indra/newview/llnamelistctrl.h @@ -64,9 +64,10 @@ private: class LLNameListCtrl -: public LLScrollListCtrl, public LLInstanceTracker +: public LLScrollListCtrl, public INSTANCE_TRACKER(LLNameListCtrl) { public: + typedef enum e_name_type { INDIVIDUAL, diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index 9dfb29b905..49debe67f6 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -572,7 +572,7 @@ S32 LLToast::notifyParent(const LLSD& info) //static void LLToast::updateClass() { - for (LLInstanceTracker::instance_iter iter = LLInstanceTracker::beginInstances(); iter != LLInstanceTracker::endInstances(); ) + for (INSTANCE_TRACKER(LLToast)::instance_iter iter = INSTANCE_TRACKER(LLToast)::beginInstances(); iter != INSTANCE_TRACKER(LLToast)::endInstances(); ) { LLToast& toast = *iter++; diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index e1d99b1bcb..8f77e7b78b 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -69,10 +69,11 @@ private : * Represents toast pop-up. * This is a parent view for all toast panels. */ -class LLToast : public LLModalDialog, public LLInstanceTracker +class LLToast : public LLModalDialog, public INSTANCE_TRACKER(LLToast) { friend class LLToastLifeTimer; public: + typedef boost::function toast_callback_t; typedef boost::signals2::signal toast_signal_t; typedef boost::signals2::signal toast_hover_check_signal_t; -- cgit v1.2.3 From ae1aa461ea3f96c092e2a50ae40f290b03b25356 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 28 Feb 2013 16:37:09 -0800 Subject: Attempt at a faster ThreadSafeRefCount class --- indra/llcommon/llapr.h | 8 +++++++- indra/llcommon/llthread.cpp | 8 -------- indra/llcommon/llthread.h | 40 ++++++++++++++++++---------------------- 3 files changed, 25 insertions(+), 31 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 034546c3f3..8042fe2502 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -164,14 +164,20 @@ public: ~LLAtomic32() {}; operator const Type() { apr_uint32_t data = apr_atomic_read32(&mData); return Type(data); } + + Type CurrentValue() const { apr_uint32_t data = apr_atomic_read32(const_cast< volatile apr_uint32_t* >(&mData)); return Type(data); } + Type operator =(const Type& x) { apr_atomic_set32(&mData, apr_uint32_t(x)); return Type(mData); } void operator -=(Type x) { apr_atomic_sub32(&mData, apr_uint32_t(x)); } void operator +=(Type x) { apr_atomic_add32(&mData, apr_uint32_t(x)); } Type operator ++(int) { return apr_atomic_inc32(&mData); } // Type++ Type operator --(int) { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise) + + Type operator ++() { return apr_atomic_inc32(&mData); } // Type++ + Type operator --() { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise) private: - apr_uint32_t mData; + volatile apr_uint32_t mData; }; typedef LLAtomic32 LLAtomicU32; diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 1d56a52c32..6c117f7daf 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -495,15 +495,7 @@ LLThreadSafeRefCount::LLThreadSafeRefCount() : LLThreadSafeRefCount::LLThreadSafeRefCount(const LLThreadSafeRefCount& src) { - if (sMutex) - { - sMutex->lock(); - } mRef = 0; - if (sMutex) - { - sMutex->unlock(); - } } LLThreadSafeRefCount::~LLThreadSafeRefCount() diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 5c8bbca2ca..c2f4184a8a 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -241,47 +241,43 @@ public: LLThreadSafeRefCount(const LLThreadSafeRefCount&); LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) { - if (sMutex) - { - sMutex->lock(); - } mRef = 0; - if (sMutex) - { - sMutex->unlock(); - } return *this; } - - void ref() { - if (sMutex) sMutex->lock(); mRef++; - if (sMutex) sMutex->unlock(); } S32 unref() { - llassert(mRef >= 1); - if (sMutex) sMutex->lock(); - S32 res = --mRef; - if (sMutex) sMutex->unlock(); - if (0 == res) + llassert(mRef >= 1); + bool time_to_die = (mRef == 1); + if (time_to_die) { - delete this; + if (sMutex) sMutex->lock(); + // Looks redundant, but is very much not + // We need to check again once we've acquired the lock + // so that two threads who get into the if in parallel + // don't both attempt to the delete. + // + if (mRef == 1) + delete this; + mRef--; + if (sMutex) sMutex->unlock(); return 0; } - return res; - } + return --mRef; + } S32 getNumRefs() const { - return mRef; + const S32 currentVal = mRef.CurrentValue(); + return currentVal; } private: - S32 mRef; + LLAtomic32< S32 > mRef; }; //============================================================================ -- cgit v1.2.3 From dfda8826eb4654845430520dac48c011e058e1c0 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Fri, 1 Mar 2013 11:21:35 -0800 Subject: Make WL updates use pre-hashed strings for uniform sets --- indra/llcommon/CMakeLists.txt | 1 + indra/llcommon/llstringtable.h | 54 -- indra/llcommon/llthread.h | 4 +- indra/llrender/llglslshader.h | 1 + indra/llrender/llpostprocess.cpp | 1162 +++++++++++++++++++------------------- indra/llrender/llpostprocess.h | 1 + indra/newview/llwaterparamset.h | 15 + indra/newview/llwlparamset.cpp | 55 +- indra/newview/llwlparamset.h | 9 +- 9 files changed, 651 insertions(+), 651 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 5cce8ff2c4..e019c17280 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -236,6 +236,7 @@ set(llcommon_HEADER_FILES llstrider.h llstring.h llstringtable.h + llstaticstringtable.h llsys.h llthread.h llthreadsafequeue.h diff --git a/indra/llcommon/llstringtable.h b/indra/llcommon/llstringtable.h index 4f6417328c..787a046741 100644 --- a/indra/llcommon/llstringtable.h +++ b/indra/llcommon/llstringtable.h @@ -33,7 +33,6 @@ #include "llstl.h" #include #include -#include #if LL_WINDOWS # if (_MSC_VER >= 1300 && _MSC_VER < 1400) @@ -43,59 +42,6 @@ //# define STRING_TABLE_HASH_MAP 1 #endif -#if STRING_TABLE_HASH_MAP -# if LL_WINDOWS -# include -# else -# include -# endif -#endif - -class LLStaticHashedString -{ -public: - - LLStaticHashedString(const std::string& s) - { - string_hash = makehash(s); - string = s; - } - - const std::string& String() const { return string; } - size_t Hash() const { return string_hash; } - -protected: - - size_t makehash(const std::string& s) - { - size_t len = s.size(); - const char* c = s.c_str(); - size_t hashval = 0; - for (size_t i=0; i -struct LLStaticStringHasher -{ - enum { bucket_size = 8 }; - size_t operator()(const T& key_value) const { return key_value.Hash(); } - bool operator()(const T& left, const T& right) const { return left.Hash() < right.Hash(); } -}; - -template< typename MappedObject > -class LL_COMMON_API LLStaticStringTable - : public std::hash_map< LLStaticHashedString , MappedObject, LLStaticStringHasher< LLStaticHashedString > > -{ -}; - const U32 MAX_STRINGS_LENGTH = 256; class LL_COMMON_API LLStringTableEntry diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index c2f4184a8a..0d22bc863d 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -262,9 +262,9 @@ public: // so that two threads who get into the if in parallel // don't both attempt to the delete. // - if (mRef == 1) - delete this; mRef--; + if (mRef == 0) + delete this; if (sMutex) sMutex->unlock(); return 0; } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index bac9af6959..619c3559ea 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -29,6 +29,7 @@ #include "llgl.h" #include "llrender.h" +#include "llstaticstringtable.h" class LLShaderFeatures { diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 21a28e386f..c51f85ab71 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -1,36 +1,36 @@ -/** - * @file llpostprocess.cpp - * @brief LLPostProcess class implementation - * - * $LicenseInfo:firstyear=2007&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 "linden_common.h" - -#include "llpostprocess.h" -#include "llglslshader.h" -#include "llsdserialize.h" -#include "llrender.h" - +/** + * @file llpostprocess.cpp + * @brief LLPostProcess class implementation + * + * $LicenseInfo:firstyear=2007&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 "linden_common.h" + +#include "llpostprocess.h" +#include "llglslshader.h" +#include "llsdserialize.h" +#include "llrender.h" + static LLStaticHashedString sRenderTexture("RenderTexture"); static LLStaticHashedString sBrightness("brightness"); static LLStaticHashedString sContrast("contrast"); @@ -45,551 +45,551 @@ static LLStaticHashedString sExtractHigh("extractHigh"); static LLStaticHashedString sBloomStrength("bloomStrength"); static LLStaticHashedString sTexelSize("texelSize"); static LLStaticHashedString sBlurDirection("blurDirection"); -static LLStaticHashedString sBlurWidth("blurWidth"); - -LLPostProcess * gPostProcess = NULL; - - -static const unsigned int NOISE_SIZE = 512; - -/// CALCULATING LUMINANCE (Using NTSC lum weights) -/// http://en.wikipedia.org/wiki/Luma_%28video%29 -static const float LUMINANCE_R = 0.299f; -static const float LUMINANCE_G = 0.587f; -static const float LUMINANCE_B = 0.114f; - -static const char * const XML_FILENAME = "postprocesseffects.xml"; - -LLPostProcess::LLPostProcess(void) : - initialized(false), - mAllEffects(LLSD::emptyMap()), - screenW(1), screenH(1) -{ - mSceneRenderTexture = NULL ; - mNoiseTexture = NULL ; - mTempBloomTexture = NULL ; - - noiseTextureScale = 1.0f; - - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); - LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; - - llifstream effectsXML(pathName); - - if (effectsXML) - { - LLPointer parser = new LLSDXMLParser(); - - parser->parse(effectsXML, mAllEffects, LLSDSerialize::SIZE_UNLIMITED); - } - - if (!mAllEffects.has("default")) - { - LLSD & defaultEffect = (mAllEffects["default"] = LLSD::emptyMap()); - - defaultEffect["enable_night_vision"] = LLSD::Boolean(false); - defaultEffect["enable_bloom"] = LLSD::Boolean(false); - defaultEffect["enable_color_filter"] = LLSD::Boolean(false); - - /// NVG Defaults - defaultEffect["brightness_multiplier"] = 3.0; - defaultEffect["noise_size"] = 25.0; - defaultEffect["noise_strength"] = 0.4; - - // TODO BTest potentially add this to tweaks? - noiseTextureScale = 1.0f; - - /// Bloom Defaults - defaultEffect["extract_low"] = 0.95; - defaultEffect["extract_high"] = 1.0; - defaultEffect["bloom_width"] = 2.25; - defaultEffect["bloom_strength"] = 1.5; - - /// Color Filter Defaults - defaultEffect["brightness"] = 1.0; - defaultEffect["contrast"] = 1.0; - defaultEffect["saturation"] = 1.0; - - LLSD& contrastBase = (defaultEffect["contrast_base"] = LLSD::emptyArray()); - contrastBase.append(1.0); - contrastBase.append(1.0); - contrastBase.append(1.0); - contrastBase.append(0.5); - } - - setSelectedEffect("default"); - */ -} - -LLPostProcess::~LLPostProcess(void) -{ - invalidate() ; -} - -// static -void LLPostProcess::initClass(void) -{ - //this will cause system to crash at second time login - //if first time login fails due to network connection --- bao - //***llassert_always(gPostProcess == NULL); - //replaced by the following line: - if(gPostProcess) - return ; - - - gPostProcess = new LLPostProcess(); -} - -// static -void LLPostProcess::cleanupClass() -{ - delete gPostProcess; - gPostProcess = NULL; -} - -void LLPostProcess::setSelectedEffect(std::string const & effectName) -{ - mSelectedEffectName = effectName; - static_cast(tweaks) = mAllEffects[effectName]; -} - -void LLPostProcess::saveEffect(std::string const & effectName) -{ - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. - mAllEffects[effectName] = tweaks; - - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); - //llinfos << "Saving PostProcess Effects settings to " << pathName << llendl; - - llofstream effectsXML(pathName); - - LLPointer formatter = new LLSDXMLFormatter(); - - formatter->format(mAllEffects, effectsXML); - */ -} -void LLPostProcess::invalidate() -{ - mSceneRenderTexture = NULL ; - mNoiseTexture = NULL ; - mTempBloomTexture = NULL ; - initialized = FALSE ; -} - -void LLPostProcess::apply(unsigned int width, unsigned int height) -{ - if (!initialized || width != screenW || height != screenH){ - initialize(width, height); - } - if (shadersEnabled()){ - doEffects(); - } -} - -void LLPostProcess::initialize(unsigned int width, unsigned int height) -{ - screenW = width; - screenH = height; - createTexture(mSceneRenderTexture, screenW, screenH); - initialized = true; - - checkError(); - createNightVisionShader(); - createBloomShader(); - createColorFilterShader(); - checkError(); -} - -inline bool LLPostProcess::shadersEnabled(void) -{ - return (tweaks.useColorFilter().asBoolean() || - tweaks.useNightVisionShader().asBoolean() || - tweaks.useBloomShader().asBoolean() ); - -} - -void LLPostProcess::applyShaders(void) -{ - if (tweaks.useColorFilter()){ - applyColorFilterShader(); - checkError(); - } - if (tweaks.useNightVisionShader()){ - /// If any of the above shaders have been called update the frame buffer; - if (tweaks.useColorFilter()) - { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); - } - applyNightVisionShader(); - checkError(); - } - if (tweaks.useBloomShader()){ - /// If any of the above shaders have been called update the frame buffer; - if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()) - { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); - } - applyBloomShader(); - checkError(); - } -} - -void LLPostProcess::applyColorFilterShader(void) -{ - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. - gPostColorFilterProgram.bind(); - - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); - - getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); - glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); - glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness()); - glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast()); - float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f; - baseI = tweaks.getContrastBaseIntensity() / ((baseI < 0.001f) ? 0.001f : baseI); - float baseR = tweaks.getContrastBaseR() * baseI; - float baseG = tweaks.getContrastBaseG() * baseI; - float baseB = tweaks.getContrastBaseB() * baseI; - glUniform3fARB(colorFilterUniforms["contrastBase"], baseR, baseG, baseB); - glUniform1fARB(colorFilterUniforms["saturation"], tweaks.getSaturation()); - glUniform3fARB(colorFilterUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); - - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_REPLACE); - LLGLDepthTest depth(GL_FALSE); - - /// Draw a screen space quad - drawOrthoQuad(screenW, screenH, QUAD_NORMAL); - gPostColorFilterProgram.unbind(); - */ -} - -void LLPostProcess::createColorFilterShader(void) -{ - /// Define uniform names - colorFilterUniforms[sRenderTexture] = 0; - colorFilterUniforms[sBrightness] = 0; - colorFilterUniforms[sContrast] = 0; - colorFilterUniforms[sContrastBase] = 0; - colorFilterUniforms[sSaturation] = 0; - colorFilterUniforms[sLumWeights] = 0; -} - -void LLPostProcess::applyNightVisionShader(void) -{ - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. - gPostNightVisionProgram.bind(); - - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - - getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); - glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); - - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - - gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture); - glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); - - - glUniform1fARB(nightVisionUniforms["brightMult"], tweaks.getBrightMult()); - glUniform1fARB(nightVisionUniforms["noiseStrength"], tweaks.getNoiseStrength()); - noiseTextureScale = 0.01f + ((101.f - tweaks.getNoiseSize()) / 100.f); - noiseTextureScale *= (screenH / NOISE_SIZE); - - - glUniform3fARB(nightVisionUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); - - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_REPLACE); - LLGLDepthTest depth(GL_FALSE); - - /// Draw a screen space quad - drawOrthoQuad(screenW, screenH, QUAD_NOISE); - gPostNightVisionProgram.unbind(); - gGL.getTexUnit(0)->activate(); - */ -} - -void LLPostProcess::createNightVisionShader(void) -{ - /// Define uniform names - nightVisionUniforms[sRenderTexture] = 0; - nightVisionUniforms[sNoiseTexture] = 0; - nightVisionUniforms[sBrightMult] = 0; - nightVisionUniforms[sNoiseStrength] = 0; - nightVisionUniforms[sLumWeights] = 0; - - createNoiseTexture(mNoiseTexture); -} - -void LLPostProcess::applyBloomShader(void) -{ - -} - -void LLPostProcess::createBloomShader(void) -{ - createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); - - /// Create Bloom Extract Shader - bloomExtractUniforms[sRenderTexture] = 0; - bloomExtractUniforms[sExtractLow] = 0; - bloomExtractUniforms[sExtractHigh] = 0; - bloomExtractUniforms[sLumWeights] = 0; - - /// Create Bloom Blur Shader - bloomBlurUniforms[sRenderTexture] = 0; - bloomBlurUniforms[sBloomStrength] = 0; - bloomBlurUniforms[sTexelSize] = 0; - bloomBlurUniforms[sBlurDirection] = 0; - bloomBlurUniforms[sBlurWidth] = 0; -} - -void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog) -{ - /// Find uniform locations and insert into map - glslUniforms::iterator i; - for (i = uniforms.begin(); i != uniforms.end(); ++i){ - i->second = glGetUniformLocationARB(prog, i->first.String().c_str()); - } -} - -void LLPostProcess::doEffects(void) -{ - /// Save GL State - glPushAttrib(GL_ALL_ATTRIB_BITS); - glPushClientAttrib(GL_ALL_ATTRIB_BITS); - - /// Copy the screen buffer to the render texture - { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); - } - - /// Clear the frame buffer. - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - /// Change to an orthogonal view - viewOrthogonal(screenW, screenH); - - checkError(); - applyShaders(); - - LLGLSLShader::bindNoShader(); - checkError(); - - /// Change to a perspective view - viewPerspective(); - - /// Reset GL State - glPopClientAttrib(); - glPopAttrib(); - checkError(); -} - -void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height) -{ - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); - glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); -} - -void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type) -{ -#if 0 - float noiseX = 0.f; - float noiseY = 0.f; - float screenRatio = 1.0f; - - if (type == QUAD_NOISE){ - noiseX = ((float) rand() / (float) RAND_MAX); - noiseY = ((float) rand() / (float) RAND_MAX); - screenRatio = (float) width / (float) height; - } - - - glBegin(GL_QUADS); - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - noiseX, - noiseTextureScale + noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f); - } - glVertex2f(0.f, (GLfloat) screenH - height); - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - noiseX, - noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f); - } - glVertex2f(0.f, (GLfloat) height + (screenH - height)); - - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - screenRatio * noiseTextureScale + noiseX, - noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f); - } - glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height)); - - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - screenRatio * noiseTextureScale + noiseX, - noiseTextureScale + noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f); - } - glVertex2f((GLfloat) width, (GLfloat) screenH - height); - glEnd(); -#endif -} - -void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) -{ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.ortho( 0.f, (GLdouble) width , (GLdouble) height , 0.f, -1.f, 1.f ); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); -} - -void LLPostProcess::viewPerspective(void) -{ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); -} - -void LLPostProcess::changeOrthogonal(unsigned int width, unsigned int height) -{ - viewPerspective(); - viewOrthogonal(width, height); -} - -void LLPostProcess::createTexture(LLPointer& texture, unsigned int width, unsigned int height) -{ - std::vector data(width * height * 4, 0) ; - - texture = new LLImageGL(FALSE) ; - if(texture->createGLTexture()) - { - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName()); - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - } -} - -void LLPostProcess::createNoiseTexture(LLPointer& texture) -{ - std::vector buffer(NOISE_SIZE * NOISE_SIZE); - for (unsigned int i = 0; i < NOISE_SIZE; i++){ - for (unsigned int k = 0; k < NOISE_SIZE; k++){ - buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); - } - } - - texture = new LLImageGL(FALSE) ; - if(texture->createGLTexture()) - { - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName()); - LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP); - } -} - -bool LLPostProcess::checkError(void) -{ - GLenum glErr; - bool retCode = false; - - glErr = glGetError(); - while (glErr != GL_NO_ERROR) - { - // shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl; - char const * err_str_raw = (const char *) gluErrorString(glErr); - - if(err_str_raw == NULL) - { - std::ostringstream err_builder; - err_builder << "unknown error number " << glErr; - mShaderErrorString = err_builder.str(); - } - else - { - mShaderErrorString = err_str_raw; - } - - retCode = true; - glErr = glGetError(); - } - return retCode; -} - -void LLPostProcess::checkShaderError(GLhandleARB shader) -{ - GLint infologLength = 0; - GLint charsWritten = 0; - GLchar *infoLog; - - checkError(); // Check for OpenGL errors - - glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength); - - checkError(); // Check for OpenGL errors - - if (infologLength > 0) - { - infoLog = (GLchar *)malloc(infologLength); - if (infoLog == NULL) - { - /// Could not allocate infolog buffer - return; - } - glGetInfoLogARB(shader, infologLength, &charsWritten, infoLog); - // shaderErrorLog << (char *) infoLog << std::endl; - mShaderErrorString = (char *) infoLog; - free(infoLog); - } - checkError(); // Check for OpenGL errors -} +static LLStaticHashedString sBlurWidth("blurWidth"); + +LLPostProcess * gPostProcess = NULL; + + +static const unsigned int NOISE_SIZE = 512; + +/// CALCULATING LUMINANCE (Using NTSC lum weights) +/// http://en.wikipedia.org/wiki/Luma_%28video%29 +static const float LUMINANCE_R = 0.299f; +static const float LUMINANCE_G = 0.587f; +static const float LUMINANCE_B = 0.114f; + +static const char * const XML_FILENAME = "postprocesseffects.xml"; + +LLPostProcess::LLPostProcess(void) : + initialized(false), + mAllEffects(LLSD::emptyMap()), + screenW(1), screenH(1) +{ + mSceneRenderTexture = NULL ; + mNoiseTexture = NULL ; + mTempBloomTexture = NULL ; + + noiseTextureScale = 1.0f; + + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); + LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; + + llifstream effectsXML(pathName); + + if (effectsXML) + { + LLPointer parser = new LLSDXMLParser(); + + parser->parse(effectsXML, mAllEffects, LLSDSerialize::SIZE_UNLIMITED); + } + + if (!mAllEffects.has("default")) + { + LLSD & defaultEffect = (mAllEffects["default"] = LLSD::emptyMap()); + + defaultEffect["enable_night_vision"] = LLSD::Boolean(false); + defaultEffect["enable_bloom"] = LLSD::Boolean(false); + defaultEffect["enable_color_filter"] = LLSD::Boolean(false); + + /// NVG Defaults + defaultEffect["brightness_multiplier"] = 3.0; + defaultEffect["noise_size"] = 25.0; + defaultEffect["noise_strength"] = 0.4; + + // TODO BTest potentially add this to tweaks? + noiseTextureScale = 1.0f; + + /// Bloom Defaults + defaultEffect["extract_low"] = 0.95; + defaultEffect["extract_high"] = 1.0; + defaultEffect["bloom_width"] = 2.25; + defaultEffect["bloom_strength"] = 1.5; + + /// Color Filter Defaults + defaultEffect["brightness"] = 1.0; + defaultEffect["contrast"] = 1.0; + defaultEffect["saturation"] = 1.0; + + LLSD& contrastBase = (defaultEffect["contrast_base"] = LLSD::emptyArray()); + contrastBase.append(1.0); + contrastBase.append(1.0); + contrastBase.append(1.0); + contrastBase.append(0.5); + } + + setSelectedEffect("default"); + */ +} + +LLPostProcess::~LLPostProcess(void) +{ + invalidate() ; +} + +// static +void LLPostProcess::initClass(void) +{ + //this will cause system to crash at second time login + //if first time login fails due to network connection --- bao + //***llassert_always(gPostProcess == NULL); + //replaced by the following line: + if(gPostProcess) + return ; + + + gPostProcess = new LLPostProcess(); +} + +// static +void LLPostProcess::cleanupClass() +{ + delete gPostProcess; + gPostProcess = NULL; +} + +void LLPostProcess::setSelectedEffect(std::string const & effectName) +{ + mSelectedEffectName = effectName; + static_cast(tweaks) = mAllEffects[effectName]; +} + +void LLPostProcess::saveEffect(std::string const & effectName) +{ + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + mAllEffects[effectName] = tweaks; + + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); + //llinfos << "Saving PostProcess Effects settings to " << pathName << llendl; + + llofstream effectsXML(pathName); + + LLPointer formatter = new LLSDXMLFormatter(); + + formatter->format(mAllEffects, effectsXML); + */ +} +void LLPostProcess::invalidate() +{ + mSceneRenderTexture = NULL ; + mNoiseTexture = NULL ; + mTempBloomTexture = NULL ; + initialized = FALSE ; +} + +void LLPostProcess::apply(unsigned int width, unsigned int height) +{ + if (!initialized || width != screenW || height != screenH){ + initialize(width, height); + } + if (shadersEnabled()){ + doEffects(); + } +} + +void LLPostProcess::initialize(unsigned int width, unsigned int height) +{ + screenW = width; + screenH = height; + createTexture(mSceneRenderTexture, screenW, screenH); + initialized = true; + + checkError(); + createNightVisionShader(); + createBloomShader(); + createColorFilterShader(); + checkError(); +} + +inline bool LLPostProcess::shadersEnabled(void) +{ + return (tweaks.useColorFilter().asBoolean() || + tweaks.useNightVisionShader().asBoolean() || + tweaks.useBloomShader().asBoolean() ); + +} + +void LLPostProcess::applyShaders(void) +{ + if (tweaks.useColorFilter()){ + applyColorFilterShader(); + checkError(); + } + if (tweaks.useNightVisionShader()){ + /// If any of the above shaders have been called update the frame buffer; + if (tweaks.useColorFilter()) + { + U32 tex = mSceneRenderTexture->getTexName() ; + copyFrameBuffer(tex, screenW, screenH); + } + applyNightVisionShader(); + checkError(); + } + if (tweaks.useBloomShader()){ + /// If any of the above shaders have been called update the frame buffer; + if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()) + { + U32 tex = mSceneRenderTexture->getTexName() ; + copyFrameBuffer(tex, screenW, screenH); + } + applyBloomShader(); + checkError(); + } +} + +void LLPostProcess::applyColorFilterShader(void) +{ + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + gPostColorFilterProgram.bind(); + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); + + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); + + getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); + glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); + glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness()); + glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast()); + float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f; + baseI = tweaks.getContrastBaseIntensity() / ((baseI < 0.001f) ? 0.001f : baseI); + float baseR = tweaks.getContrastBaseR() * baseI; + float baseG = tweaks.getContrastBaseG() * baseI; + float baseB = tweaks.getContrastBaseB() * baseI; + glUniform3fARB(colorFilterUniforms["contrastBase"], baseR, baseG, baseB); + glUniform1fARB(colorFilterUniforms["saturation"], tweaks.getSaturation()); + glUniform3fARB(colorFilterUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); + + LLGLEnable blend(GL_BLEND); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + LLGLDepthTest depth(GL_FALSE); + + /// Draw a screen space quad + drawOrthoQuad(screenW, screenH, QUAD_NORMAL); + gPostColorFilterProgram.unbind(); + */ +} + +void LLPostProcess::createColorFilterShader(void) +{ + /// Define uniform names + colorFilterUniforms[sRenderTexture] = 0; + colorFilterUniforms[sBrightness] = 0; + colorFilterUniforms[sContrast] = 0; + colorFilterUniforms[sContrastBase] = 0; + colorFilterUniforms[sSaturation] = 0; + colorFilterUniforms[sLumWeights] = 0; +} + +void LLPostProcess::applyNightVisionShader(void) +{ + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + gPostNightVisionProgram.bind(); + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); + + getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); + glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); + + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + + gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture); + glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); + + + glUniform1fARB(nightVisionUniforms["brightMult"], tweaks.getBrightMult()); + glUniform1fARB(nightVisionUniforms["noiseStrength"], tweaks.getNoiseStrength()); + noiseTextureScale = 0.01f + ((101.f - tweaks.getNoiseSize()) / 100.f); + noiseTextureScale *= (screenH / NOISE_SIZE); + + + glUniform3fARB(nightVisionUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); + + LLGLEnable blend(GL_BLEND); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + LLGLDepthTest depth(GL_FALSE); + + /// Draw a screen space quad + drawOrthoQuad(screenW, screenH, QUAD_NOISE); + gPostNightVisionProgram.unbind(); + gGL.getTexUnit(0)->activate(); + */ +} + +void LLPostProcess::createNightVisionShader(void) +{ + /// Define uniform names + nightVisionUniforms[sRenderTexture] = 0; + nightVisionUniforms[sNoiseTexture] = 0; + nightVisionUniforms[sBrightMult] = 0; + nightVisionUniforms[sNoiseStrength] = 0; + nightVisionUniforms[sLumWeights] = 0; + + createNoiseTexture(mNoiseTexture); +} + +void LLPostProcess::applyBloomShader(void) +{ + +} + +void LLPostProcess::createBloomShader(void) +{ + createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); + + /// Create Bloom Extract Shader + bloomExtractUniforms[sRenderTexture] = 0; + bloomExtractUniforms[sExtractLow] = 0; + bloomExtractUniforms[sExtractHigh] = 0; + bloomExtractUniforms[sLumWeights] = 0; + + /// Create Bloom Blur Shader + bloomBlurUniforms[sRenderTexture] = 0; + bloomBlurUniforms[sBloomStrength] = 0; + bloomBlurUniforms[sTexelSize] = 0; + bloomBlurUniforms[sBlurDirection] = 0; + bloomBlurUniforms[sBlurWidth] = 0; +} + +void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog) +{ + /// Find uniform locations and insert into map + glslUniforms::iterator i; + for (i = uniforms.begin(); i != uniforms.end(); ++i){ + i->second = glGetUniformLocationARB(prog, i->first.String().c_str()); + } +} + +void LLPostProcess::doEffects(void) +{ + /// Save GL State + glPushAttrib(GL_ALL_ATTRIB_BITS); + glPushClientAttrib(GL_ALL_ATTRIB_BITS); + + /// Copy the screen buffer to the render texture + { + U32 tex = mSceneRenderTexture->getTexName() ; + copyFrameBuffer(tex, screenW, screenH); + } + + /// Clear the frame buffer. + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + /// Change to an orthogonal view + viewOrthogonal(screenW, screenH); + + checkError(); + applyShaders(); + + LLGLSLShader::bindNoShader(); + checkError(); + + /// Change to a perspective view + viewPerspective(); + + /// Reset GL State + glPopClientAttrib(); + glPopAttrib(); + checkError(); +} + +void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height) +{ + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); + glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); +} + +void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type) +{ +#if 0 + float noiseX = 0.f; + float noiseY = 0.f; + float screenRatio = 1.0f; + + if (type == QUAD_NOISE){ + noiseX = ((float) rand() / (float) RAND_MAX); + noiseY = ((float) rand() / (float) RAND_MAX); + screenRatio = (float) width / (float) height; + } + + + glBegin(GL_QUADS); + if (type != QUAD_BLOOM_EXTRACT){ + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height); + } else { + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f); + } + if (type == QUAD_NOISE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, + noiseX, + noiseTextureScale + noiseY); + } else if (type == QUAD_BLOOM_COMBINE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f); + } + glVertex2f(0.f, (GLfloat) screenH - height); + + if (type != QUAD_BLOOM_EXTRACT){ + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); + } else { + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); + } + if (type == QUAD_NOISE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, + noiseX, + noiseY); + } else if (type == QUAD_BLOOM_COMBINE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f); + } + glVertex2f(0.f, (GLfloat) height + (screenH - height)); + + + if (type != QUAD_BLOOM_EXTRACT){ + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f); + } else { + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f); + } + if (type == QUAD_NOISE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, + screenRatio * noiseTextureScale + noiseX, + noiseY); + } else if (type == QUAD_BLOOM_COMBINE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f); + } + glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height)); + + + if (type != QUAD_BLOOM_EXTRACT){ + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height); + } else { + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f); + } + if (type == QUAD_NOISE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, + screenRatio * noiseTextureScale + noiseX, + noiseTextureScale + noiseY); + } else if (type == QUAD_BLOOM_COMBINE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f); + } + glVertex2f((GLfloat) width, (GLfloat) screenH - height); + glEnd(); +#endif +} + +void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) +{ + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.ortho( 0.f, (GLdouble) width , (GLdouble) height , 0.f, -1.f, 1.f ); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); +} + +void LLPostProcess::viewPerspective(void) +{ + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); +} + +void LLPostProcess::changeOrthogonal(unsigned int width, unsigned int height) +{ + viewPerspective(); + viewOrthogonal(width, height); +} + +void LLPostProcess::createTexture(LLPointer& texture, unsigned int width, unsigned int height) +{ + std::vector data(width * height * 4, 0) ; + + texture = new LLImageGL(FALSE) ; + if(texture->createGLTexture()) + { + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName()); + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, + GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + } +} + +void LLPostProcess::createNoiseTexture(LLPointer& texture) +{ + std::vector buffer(NOISE_SIZE * NOISE_SIZE); + for (unsigned int i = 0; i < NOISE_SIZE; i++){ + for (unsigned int k = 0; k < NOISE_SIZE; k++){ + buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); + } + } + + texture = new LLImageGL(FALSE) ; + if(texture->createGLTexture()) + { + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName()); + LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP); + } +} + +bool LLPostProcess::checkError(void) +{ + GLenum glErr; + bool retCode = false; + + glErr = glGetError(); + while (glErr != GL_NO_ERROR) + { + // shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl; + char const * err_str_raw = (const char *) gluErrorString(glErr); + + if(err_str_raw == NULL) + { + std::ostringstream err_builder; + err_builder << "unknown error number " << glErr; + mShaderErrorString = err_builder.str(); + } + else + { + mShaderErrorString = err_str_raw; + } + + retCode = true; + glErr = glGetError(); + } + return retCode; +} + +void LLPostProcess::checkShaderError(GLhandleARB shader) +{ + GLint infologLength = 0; + GLint charsWritten = 0; + GLchar *infoLog; + + checkError(); // Check for OpenGL errors + + glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength); + + checkError(); // Check for OpenGL errors + + if (infologLength > 0) + { + infoLog = (GLchar *)malloc(infologLength); + if (infoLog == NULL) + { + /// Could not allocate infolog buffer + return; + } + glGetInfoLogARB(shader, infologLength, &charsWritten, infoLog); + // shaderErrorLog << (char *) infoLog << std::endl; + mShaderErrorString = (char *) infoLog; + free(infoLog); + } + checkError(); // Check for OpenGL errors +} diff --git a/indra/llrender/llpostprocess.h b/indra/llrender/llpostprocess.h index c380413ec9..6894505753 100644 --- a/indra/llrender/llpostprocess.h +++ b/indra/llrender/llpostprocess.h @@ -31,6 +31,7 @@ #include #include "llgl.h" #include "llglheaders.h" +#include "llstaticstringtable.h" class LLPostProcess { diff --git a/indra/newview/llwaterparamset.h b/indra/newview/llwaterparamset.h index b28585af59..368cb0ccba 100644 --- a/indra/newview/llwaterparamset.h +++ b/indra/newview/llwaterparamset.h @@ -33,6 +33,7 @@ #include "v4math.h" #include "v4color.h" #include "llviewershadermgr.h" +#include "llstringtable.h" class LLWaterParamSet; @@ -47,6 +48,9 @@ public: private: LLSD mParamValues; + std::vector mParamHashedNames; + + void updateHashedNames(); public: @@ -140,6 +144,17 @@ inline void LLWaterParamSet::setAll(const LLSD& val) mParamValues[mIt->first] = mIt->second; } } + updateHashedNames(); +} + +inline void LLWaterParamSet::updateHashedNames() +{ + mParamHashedNames.clear(); + // Iterate through values + for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) + { + mParamHashedNames.push_back(LLStaticHashedString(iter->first)); + } } inline const LLSD& LLWaterParamSet::getAll() diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index b04d30db55..745cdae441 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -38,6 +38,22 @@ #include +static LLStaticHashedString sStarBrightness("star_brightness"); +static LLStaticHashedString sPresetNum("preset_num"); +static LLStaticHashedString sSunAngle("sun_angle"); +static LLStaticHashedString sEastAngle("east_angle"); +static LLStaticHashedString sEnableCloudScroll("enable_cloud_scroll"); +static LLStaticHashedString sCloudScrollRate("cloud_scroll_rate"); +static LLStaticHashedString sLightNorm("lightnorm"); +static LLStaticHashedString sCloudDensity("cloud_pos_density1"); +static LLStaticHashedString sCloudScale("cloud_scale"); +static LLStaticHashedString sCloudShadow("cloud_shadow"); +static LLStaticHashedString sDensityMultiplier("density_multiplier"); +static LLStaticHashedString sDistanceMultiplier("distance_multiplier"); +static LLStaticHashedString sHazeDensity("haze_density"); +static LLStaticHashedString sHazeHorizon("haze_horizon"); +static LLStaticHashedString sMaxY("max_y"); + LLWLParamSet::LLWLParamSet(void) : mName("Unnamed Preset"), mCloudScrollXOffset(0.f), mCloudScrollYOffset(0.f) @@ -48,21 +64,24 @@ static LLFastTimer::DeclareTimer FTM_WL_PARAM_UPDATE("WL Param Update"); void LLWLParamSet::update(LLGLSLShader * shader) const { LLFastTimer t(FTM_WL_PARAM_UPDATE); - - for(LLSD::map_const_iterator i = mParamValues.beginMap(); - i != mParamValues.endMap(); - ++i) + LLSD::map_const_iterator i = mParamValues.beginMap(); + std::vector::const_iterator n = mParamHashedNames.begin(); + for(;(i != mParamValues.endMap()) && (n != mParamHashedNames.end());++i, n++) { - const std::string& param = i->first; + const LLStaticHashedString& param = *n; - if (param == "star_brightness" || param == "preset_num" || param == "sun_angle" || - param == "east_angle" || param == "enable_cloud_scroll" || - param == "cloud_scroll_rate" || param == "lightnorm" ) + // check that our pre-hashed names are still tracking the mParamValues map correctly + // + llassert(param.String() == i->first); + + if (param == sStarBrightness || param == sPresetNum || param == sSunAngle || + param == sEastAngle || param == sEnableCloudScroll || + param == sCloudScrollRate || param == sLightNorm ) { continue; } - if (param == "cloud_pos_density1") + if (param == sCloudDensity) { LLVector4 val; val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; @@ -74,10 +93,10 @@ void LLWLParamSet::update(LLGLSLShader * shader) const shader->uniform4fv(param, 1, val.mV); stop_glerror(); } - else if (param == "cloud_scale" || param == "cloud_shadow" || - param == "density_multiplier" || param == "distance_multiplier" || - param == "haze_density" || param == "haze_horizon" || - param == "max_y" ) + else if (param == sCloudScale || param == sCloudShadow || + param == sDensityMultiplier || param == sDistanceMultiplier || + param == sHazeDensity || param == sHazeHorizon || + param == sMaxY ) { F32 val = (F32) i->second[0].asReal(); @@ -378,3 +397,13 @@ void LLWLParamSet::updateCloudScrolling(void) mCloudScrollYOffset += F32(delta_t * (getCloudScrollY() - 10.f) / 100.f); } } + +void LLWLParamSet::updateHashedNames() +{ + mParamHashedNames.clear(); + // Iterate through values + for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) + { + mParamHashedNames.push_back(LLStaticHashedString(iter->first)); + } +} \ No newline at end of file diff --git a/indra/newview/llwlparamset.h b/indra/newview/llwlparamset.h index b087119dd5..3e9f77ba6c 100644 --- a/indra/newview/llwlparamset.h +++ b/indra/newview/llwlparamset.h @@ -29,9 +29,11 @@ #include #include +#include #include "v4math.h" #include "v4color.h" +#include "llstaticstringtable.h" class LLWLParamSet; class LLGLSLShader; @@ -47,9 +49,12 @@ public: private: LLSD mParamValues; - + std::vector mParamHashedNames; + float mCloudScrollXOffset, mCloudScrollYOffset; + void updateHashedNames(); + public: LLWLParamSet(); @@ -177,6 +182,8 @@ inline void LLWLParamSet::setAll(const LLSD& val) if(val.isMap()) { mParamValues = val; } + + updateHashedNames(); } inline const LLSD& LLWLParamSet::getAll() -- cgit v1.2.3 From 7f66555ed6ce46ac85a10a349e9f40b73c136950 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Fri, 1 Mar 2013 11:23:46 -0800 Subject: Add llstaticstringtable.h --- indra/llcommon/llstaticstringtable.h | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 indra/llcommon/llstaticstringtable.h (limited to 'indra') diff --git a/indra/llcommon/llstaticstringtable.h b/indra/llcommon/llstaticstringtable.h new file mode 100644 index 0000000000..05b0848e30 --- /dev/null +++ b/indra/llcommon/llstaticstringtable.h @@ -0,0 +1,81 @@ +/** + * @file llstringtable.h + * @brief The LLStringTable class provides a _fast_ method for finding + * unique copies of strings. + * + * $LicenseInfo:firstyear=2001&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$ + */ + +#ifndef LL_STATIC_STRING_TABLE_H +#define LL_STATIC_STRING_TABLE_H + +#include "lldefs.h" +#include +#include "llstl.h" + +class LLStaticHashedString +{ +public: + + LLStaticHashedString(const std::string& s) + { + string_hash = makehash(s); + string = s; + } + + const std::string& String() const { return string; } + size_t Hash() const { return string_hash; } + + bool operator==(const LLStaticHashedString& b) const { return Hash() == b.Hash(); } + +protected: + + size_t makehash(const std::string& s) + { + size_t len = s.size(); + const char* c = s.c_str(); + size_t hashval = 0; + for (size_t i=0; i +class LL_COMMON_API LLStaticStringTable + : public boost::unordered_map< LLStaticHashedString, MappedObject, LLStaticStringHasher > +{ +}; + +#endif \ No newline at end of file -- cgit v1.2.3 From 59a0c687807e2a4293708f263f1c8eca2dd86b8f Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Fri, 1 Mar 2013 11:34:33 -0800 Subject: Fix windoze line-endings from missing commit hook fiasco --- indra/llrender/llpostprocess.cpp | 1190 +++++++++++++++++++------------------- 1 file changed, 595 insertions(+), 595 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index c51f85ab71..4c36185b08 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -1,595 +1,595 @@ -/** - * @file llpostprocess.cpp - * @brief LLPostProcess class implementation - * - * $LicenseInfo:firstyear=2007&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 "linden_common.h" - -#include "llpostprocess.h" -#include "llglslshader.h" -#include "llsdserialize.h" -#include "llrender.h" - -static LLStaticHashedString sRenderTexture("RenderTexture"); -static LLStaticHashedString sBrightness("brightness"); -static LLStaticHashedString sContrast("contrast"); -static LLStaticHashedString sContrastBase("contrastBase"); -static LLStaticHashedString sSaturation("saturation"); -static LLStaticHashedString sLumWeights("lumWeights"); -static LLStaticHashedString sNoiseTexture("NoiseTexture"); -static LLStaticHashedString sBrightMult("brightMult"); -static LLStaticHashedString sNoiseStrength("noiseStrength"); -static LLStaticHashedString sExtractLow("extractLow"); -static LLStaticHashedString sExtractHigh("extractHigh"); -static LLStaticHashedString sBloomStrength("bloomStrength"); -static LLStaticHashedString sTexelSize("texelSize"); -static LLStaticHashedString sBlurDirection("blurDirection"); -static LLStaticHashedString sBlurWidth("blurWidth"); - -LLPostProcess * gPostProcess = NULL; - - -static const unsigned int NOISE_SIZE = 512; - -/// CALCULATING LUMINANCE (Using NTSC lum weights) -/// http://en.wikipedia.org/wiki/Luma_%28video%29 -static const float LUMINANCE_R = 0.299f; -static const float LUMINANCE_G = 0.587f; -static const float LUMINANCE_B = 0.114f; - -static const char * const XML_FILENAME = "postprocesseffects.xml"; - -LLPostProcess::LLPostProcess(void) : - initialized(false), - mAllEffects(LLSD::emptyMap()), - screenW(1), screenH(1) -{ - mSceneRenderTexture = NULL ; - mNoiseTexture = NULL ; - mTempBloomTexture = NULL ; - - noiseTextureScale = 1.0f; - - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); - LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; - - llifstream effectsXML(pathName); - - if (effectsXML) - { - LLPointer parser = new LLSDXMLParser(); - - parser->parse(effectsXML, mAllEffects, LLSDSerialize::SIZE_UNLIMITED); - } - - if (!mAllEffects.has("default")) - { - LLSD & defaultEffect = (mAllEffects["default"] = LLSD::emptyMap()); - - defaultEffect["enable_night_vision"] = LLSD::Boolean(false); - defaultEffect["enable_bloom"] = LLSD::Boolean(false); - defaultEffect["enable_color_filter"] = LLSD::Boolean(false); - - /// NVG Defaults - defaultEffect["brightness_multiplier"] = 3.0; - defaultEffect["noise_size"] = 25.0; - defaultEffect["noise_strength"] = 0.4; - - // TODO BTest potentially add this to tweaks? - noiseTextureScale = 1.0f; - - /// Bloom Defaults - defaultEffect["extract_low"] = 0.95; - defaultEffect["extract_high"] = 1.0; - defaultEffect["bloom_width"] = 2.25; - defaultEffect["bloom_strength"] = 1.5; - - /// Color Filter Defaults - defaultEffect["brightness"] = 1.0; - defaultEffect["contrast"] = 1.0; - defaultEffect["saturation"] = 1.0; - - LLSD& contrastBase = (defaultEffect["contrast_base"] = LLSD::emptyArray()); - contrastBase.append(1.0); - contrastBase.append(1.0); - contrastBase.append(1.0); - contrastBase.append(0.5); - } - - setSelectedEffect("default"); - */ -} - -LLPostProcess::~LLPostProcess(void) -{ - invalidate() ; -} - -// static -void LLPostProcess::initClass(void) -{ - //this will cause system to crash at second time login - //if first time login fails due to network connection --- bao - //***llassert_always(gPostProcess == NULL); - //replaced by the following line: - if(gPostProcess) - return ; - - - gPostProcess = new LLPostProcess(); -} - -// static -void LLPostProcess::cleanupClass() -{ - delete gPostProcess; - gPostProcess = NULL; -} - -void LLPostProcess::setSelectedEffect(std::string const & effectName) -{ - mSelectedEffectName = effectName; - static_cast(tweaks) = mAllEffects[effectName]; -} - -void LLPostProcess::saveEffect(std::string const & effectName) -{ - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. - mAllEffects[effectName] = tweaks; - - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); - //llinfos << "Saving PostProcess Effects settings to " << pathName << llendl; - - llofstream effectsXML(pathName); - - LLPointer formatter = new LLSDXMLFormatter(); - - formatter->format(mAllEffects, effectsXML); - */ -} -void LLPostProcess::invalidate() -{ - mSceneRenderTexture = NULL ; - mNoiseTexture = NULL ; - mTempBloomTexture = NULL ; - initialized = FALSE ; -} - -void LLPostProcess::apply(unsigned int width, unsigned int height) -{ - if (!initialized || width != screenW || height != screenH){ - initialize(width, height); - } - if (shadersEnabled()){ - doEffects(); - } -} - -void LLPostProcess::initialize(unsigned int width, unsigned int height) -{ - screenW = width; - screenH = height; - createTexture(mSceneRenderTexture, screenW, screenH); - initialized = true; - - checkError(); - createNightVisionShader(); - createBloomShader(); - createColorFilterShader(); - checkError(); -} - -inline bool LLPostProcess::shadersEnabled(void) -{ - return (tweaks.useColorFilter().asBoolean() || - tweaks.useNightVisionShader().asBoolean() || - tweaks.useBloomShader().asBoolean() ); - -} - -void LLPostProcess::applyShaders(void) -{ - if (tweaks.useColorFilter()){ - applyColorFilterShader(); - checkError(); - } - if (tweaks.useNightVisionShader()){ - /// If any of the above shaders have been called update the frame buffer; - if (tweaks.useColorFilter()) - { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); - } - applyNightVisionShader(); - checkError(); - } - if (tweaks.useBloomShader()){ - /// If any of the above shaders have been called update the frame buffer; - if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()) - { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); - } - applyBloomShader(); - checkError(); - } -} - -void LLPostProcess::applyColorFilterShader(void) -{ - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. - gPostColorFilterProgram.bind(); - - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); - - getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); - glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); - glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness()); - glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast()); - float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f; - baseI = tweaks.getContrastBaseIntensity() / ((baseI < 0.001f) ? 0.001f : baseI); - float baseR = tweaks.getContrastBaseR() * baseI; - float baseG = tweaks.getContrastBaseG() * baseI; - float baseB = tweaks.getContrastBaseB() * baseI; - glUniform3fARB(colorFilterUniforms["contrastBase"], baseR, baseG, baseB); - glUniform1fARB(colorFilterUniforms["saturation"], tweaks.getSaturation()); - glUniform3fARB(colorFilterUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); - - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_REPLACE); - LLGLDepthTest depth(GL_FALSE); - - /// Draw a screen space quad - drawOrthoQuad(screenW, screenH, QUAD_NORMAL); - gPostColorFilterProgram.unbind(); - */ -} - -void LLPostProcess::createColorFilterShader(void) -{ - /// Define uniform names - colorFilterUniforms[sRenderTexture] = 0; - colorFilterUniforms[sBrightness] = 0; - colorFilterUniforms[sContrast] = 0; - colorFilterUniforms[sContrastBase] = 0; - colorFilterUniforms[sSaturation] = 0; - colorFilterUniforms[sLumWeights] = 0; -} - -void LLPostProcess::applyNightVisionShader(void) -{ - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. - gPostNightVisionProgram.bind(); - - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - - getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); - glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); - - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - - gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture); - glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); - - - glUniform1fARB(nightVisionUniforms["brightMult"], tweaks.getBrightMult()); - glUniform1fARB(nightVisionUniforms["noiseStrength"], tweaks.getNoiseStrength()); - noiseTextureScale = 0.01f + ((101.f - tweaks.getNoiseSize()) / 100.f); - noiseTextureScale *= (screenH / NOISE_SIZE); - - - glUniform3fARB(nightVisionUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); - - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_REPLACE); - LLGLDepthTest depth(GL_FALSE); - - /// Draw a screen space quad - drawOrthoQuad(screenW, screenH, QUAD_NOISE); - gPostNightVisionProgram.unbind(); - gGL.getTexUnit(0)->activate(); - */ -} - -void LLPostProcess::createNightVisionShader(void) -{ - /// Define uniform names - nightVisionUniforms[sRenderTexture] = 0; - nightVisionUniforms[sNoiseTexture] = 0; - nightVisionUniforms[sBrightMult] = 0; - nightVisionUniforms[sNoiseStrength] = 0; - nightVisionUniforms[sLumWeights] = 0; - - createNoiseTexture(mNoiseTexture); -} - -void LLPostProcess::applyBloomShader(void) -{ - -} - -void LLPostProcess::createBloomShader(void) -{ - createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); - - /// Create Bloom Extract Shader - bloomExtractUniforms[sRenderTexture] = 0; - bloomExtractUniforms[sExtractLow] = 0; - bloomExtractUniforms[sExtractHigh] = 0; - bloomExtractUniforms[sLumWeights] = 0; - - /// Create Bloom Blur Shader - bloomBlurUniforms[sRenderTexture] = 0; - bloomBlurUniforms[sBloomStrength] = 0; - bloomBlurUniforms[sTexelSize] = 0; - bloomBlurUniforms[sBlurDirection] = 0; - bloomBlurUniforms[sBlurWidth] = 0; -} - -void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog) -{ - /// Find uniform locations and insert into map - glslUniforms::iterator i; - for (i = uniforms.begin(); i != uniforms.end(); ++i){ - i->second = glGetUniformLocationARB(prog, i->first.String().c_str()); - } -} - -void LLPostProcess::doEffects(void) -{ - /// Save GL State - glPushAttrib(GL_ALL_ATTRIB_BITS); - glPushClientAttrib(GL_ALL_ATTRIB_BITS); - - /// Copy the screen buffer to the render texture - { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); - } - - /// Clear the frame buffer. - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - /// Change to an orthogonal view - viewOrthogonal(screenW, screenH); - - checkError(); - applyShaders(); - - LLGLSLShader::bindNoShader(); - checkError(); - - /// Change to a perspective view - viewPerspective(); - - /// Reset GL State - glPopClientAttrib(); - glPopAttrib(); - checkError(); -} - -void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height) -{ - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); - glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); -} - -void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type) -{ -#if 0 - float noiseX = 0.f; - float noiseY = 0.f; - float screenRatio = 1.0f; - - if (type == QUAD_NOISE){ - noiseX = ((float) rand() / (float) RAND_MAX); - noiseY = ((float) rand() / (float) RAND_MAX); - screenRatio = (float) width / (float) height; - } - - - glBegin(GL_QUADS); - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - noiseX, - noiseTextureScale + noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f); - } - glVertex2f(0.f, (GLfloat) screenH - height); - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - noiseX, - noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f); - } - glVertex2f(0.f, (GLfloat) height + (screenH - height)); - - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - screenRatio * noiseTextureScale + noiseX, - noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f); - } - glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height)); - - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - screenRatio * noiseTextureScale + noiseX, - noiseTextureScale + noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f); - } - glVertex2f((GLfloat) width, (GLfloat) screenH - height); - glEnd(); -#endif -} - -void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) -{ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.ortho( 0.f, (GLdouble) width , (GLdouble) height , 0.f, -1.f, 1.f ); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); -} - -void LLPostProcess::viewPerspective(void) -{ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); -} - -void LLPostProcess::changeOrthogonal(unsigned int width, unsigned int height) -{ - viewPerspective(); - viewOrthogonal(width, height); -} - -void LLPostProcess::createTexture(LLPointer& texture, unsigned int width, unsigned int height) -{ - std::vector data(width * height * 4, 0) ; - - texture = new LLImageGL(FALSE) ; - if(texture->createGLTexture()) - { - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName()); - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - } -} - -void LLPostProcess::createNoiseTexture(LLPointer& texture) -{ - std::vector buffer(NOISE_SIZE * NOISE_SIZE); - for (unsigned int i = 0; i < NOISE_SIZE; i++){ - for (unsigned int k = 0; k < NOISE_SIZE; k++){ - buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); - } - } - - texture = new LLImageGL(FALSE) ; - if(texture->createGLTexture()) - { - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName()); - LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP); - } -} - -bool LLPostProcess::checkError(void) -{ - GLenum glErr; - bool retCode = false; - - glErr = glGetError(); - while (glErr != GL_NO_ERROR) - { - // shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl; - char const * err_str_raw = (const char *) gluErrorString(glErr); - - if(err_str_raw == NULL) - { - std::ostringstream err_builder; - err_builder << "unknown error number " << glErr; - mShaderErrorString = err_builder.str(); - } - else - { - mShaderErrorString = err_str_raw; - } - - retCode = true; - glErr = glGetError(); - } - return retCode; -} - -void LLPostProcess::checkShaderError(GLhandleARB shader) -{ - GLint infologLength = 0; - GLint charsWritten = 0; - GLchar *infoLog; - - checkError(); // Check for OpenGL errors - - glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength); - - checkError(); // Check for OpenGL errors - - if (infologLength > 0) - { - infoLog = (GLchar *)malloc(infologLength); - if (infoLog == NULL) - { - /// Could not allocate infolog buffer - return; - } - glGetInfoLogARB(shader, infologLength, &charsWritten, infoLog); - // shaderErrorLog << (char *) infoLog << std::endl; - mShaderErrorString = (char *) infoLog; - free(infoLog); - } - checkError(); // Check for OpenGL errors -} +/** + * @file llpostprocess.cpp + * @brief LLPostProcess class implementation + * + * $LicenseInfo:firstyear=2007&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 "linden_common.h" + +#include "llpostprocess.h" +#include "llglslshader.h" +#include "llsdserialize.h" +#include "llrender.h" + +static LLStaticHashedString sRenderTexture("RenderTexture"); +static LLStaticHashedString sBrightness("brightness"); +static LLStaticHashedString sContrast("contrast"); +static LLStaticHashedString sContrastBase("contrastBase"); +static LLStaticHashedString sSaturation("saturation"); +static LLStaticHashedString sLumWeights("lumWeights"); +static LLStaticHashedString sNoiseTexture("NoiseTexture"); +static LLStaticHashedString sBrightMult("brightMult"); +static LLStaticHashedString sNoiseStrength("noiseStrength"); +static LLStaticHashedString sExtractLow("extractLow"); +static LLStaticHashedString sExtractHigh("extractHigh"); +static LLStaticHashedString sBloomStrength("bloomStrength"); +static LLStaticHashedString sTexelSize("texelSize"); +static LLStaticHashedString sBlurDirection("blurDirection"); +static LLStaticHashedString sBlurWidth("blurWidth"); + +LLPostProcess * gPostProcess = NULL; + + +static const unsigned int NOISE_SIZE = 512; + +/// CALCULATING LUMINANCE (Using NTSC lum weights) +/// http://en.wikipedia.org/wiki/Luma_%28video%29 +static const float LUMINANCE_R = 0.299f; +static const float LUMINANCE_G = 0.587f; +static const float LUMINANCE_B = 0.114f; + +static const char * const XML_FILENAME = "postprocesseffects.xml"; + +LLPostProcess::LLPostProcess(void) : + initialized(false), + mAllEffects(LLSD::emptyMap()), + screenW(1), screenH(1) +{ + mSceneRenderTexture = NULL ; + mNoiseTexture = NULL ; + mTempBloomTexture = NULL ; + + noiseTextureScale = 1.0f; + + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); + LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; + + llifstream effectsXML(pathName); + + if (effectsXML) + { + LLPointer parser = new LLSDXMLParser(); + + parser->parse(effectsXML, mAllEffects, LLSDSerialize::SIZE_UNLIMITED); + } + + if (!mAllEffects.has("default")) + { + LLSD & defaultEffect = (mAllEffects["default"] = LLSD::emptyMap()); + + defaultEffect["enable_night_vision"] = LLSD::Boolean(false); + defaultEffect["enable_bloom"] = LLSD::Boolean(false); + defaultEffect["enable_color_filter"] = LLSD::Boolean(false); + + /// NVG Defaults + defaultEffect["brightness_multiplier"] = 3.0; + defaultEffect["noise_size"] = 25.0; + defaultEffect["noise_strength"] = 0.4; + + // TODO BTest potentially add this to tweaks? + noiseTextureScale = 1.0f; + + /// Bloom Defaults + defaultEffect["extract_low"] = 0.95; + defaultEffect["extract_high"] = 1.0; + defaultEffect["bloom_width"] = 2.25; + defaultEffect["bloom_strength"] = 1.5; + + /// Color Filter Defaults + defaultEffect["brightness"] = 1.0; + defaultEffect["contrast"] = 1.0; + defaultEffect["saturation"] = 1.0; + + LLSD& contrastBase = (defaultEffect["contrast_base"] = LLSD::emptyArray()); + contrastBase.append(1.0); + contrastBase.append(1.0); + contrastBase.append(1.0); + contrastBase.append(0.5); + } + + setSelectedEffect("default"); + */ +} + +LLPostProcess::~LLPostProcess(void) +{ + invalidate() ; +} + +// static +void LLPostProcess::initClass(void) +{ + //this will cause system to crash at second time login + //if first time login fails due to network connection --- bao + //***llassert_always(gPostProcess == NULL); + //replaced by the following line: + if(gPostProcess) + return ; + + + gPostProcess = new LLPostProcess(); +} + +// static +void LLPostProcess::cleanupClass() +{ + delete gPostProcess; + gPostProcess = NULL; +} + +void LLPostProcess::setSelectedEffect(std::string const & effectName) +{ + mSelectedEffectName = effectName; + static_cast(tweaks) = mAllEffects[effectName]; +} + +void LLPostProcess::saveEffect(std::string const & effectName) +{ + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + mAllEffects[effectName] = tweaks; + + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); + //llinfos << "Saving PostProcess Effects settings to " << pathName << llendl; + + llofstream effectsXML(pathName); + + LLPointer formatter = new LLSDXMLFormatter(); + + formatter->format(mAllEffects, effectsXML); + */ +} +void LLPostProcess::invalidate() +{ + mSceneRenderTexture = NULL ; + mNoiseTexture = NULL ; + mTempBloomTexture = NULL ; + initialized = FALSE ; +} + +void LLPostProcess::apply(unsigned int width, unsigned int height) +{ + if (!initialized || width != screenW || height != screenH){ + initialize(width, height); + } + if (shadersEnabled()){ + doEffects(); + } +} + +void LLPostProcess::initialize(unsigned int width, unsigned int height) +{ + screenW = width; + screenH = height; + createTexture(mSceneRenderTexture, screenW, screenH); + initialized = true; + + checkError(); + createNightVisionShader(); + createBloomShader(); + createColorFilterShader(); + checkError(); +} + +inline bool LLPostProcess::shadersEnabled(void) +{ + return (tweaks.useColorFilter().asBoolean() || + tweaks.useNightVisionShader().asBoolean() || + tweaks.useBloomShader().asBoolean() ); + +} + +void LLPostProcess::applyShaders(void) +{ + if (tweaks.useColorFilter()){ + applyColorFilterShader(); + checkError(); + } + if (tweaks.useNightVisionShader()){ + /// If any of the above shaders have been called update the frame buffer; + if (tweaks.useColorFilter()) + { + U32 tex = mSceneRenderTexture->getTexName() ; + copyFrameBuffer(tex, screenW, screenH); + } + applyNightVisionShader(); + checkError(); + } + if (tweaks.useBloomShader()){ + /// If any of the above shaders have been called update the frame buffer; + if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()) + { + U32 tex = mSceneRenderTexture->getTexName() ; + copyFrameBuffer(tex, screenW, screenH); + } + applyBloomShader(); + checkError(); + } +} + +void LLPostProcess::applyColorFilterShader(void) +{ + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + gPostColorFilterProgram.bind(); + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); + + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); + + getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); + glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); + glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness()); + glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast()); + float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f; + baseI = tweaks.getContrastBaseIntensity() / ((baseI < 0.001f) ? 0.001f : baseI); + float baseR = tweaks.getContrastBaseR() * baseI; + float baseG = tweaks.getContrastBaseG() * baseI; + float baseB = tweaks.getContrastBaseB() * baseI; + glUniform3fARB(colorFilterUniforms["contrastBase"], baseR, baseG, baseB); + glUniform1fARB(colorFilterUniforms["saturation"], tweaks.getSaturation()); + glUniform3fARB(colorFilterUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); + + LLGLEnable blend(GL_BLEND); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + LLGLDepthTest depth(GL_FALSE); + + /// Draw a screen space quad + drawOrthoQuad(screenW, screenH, QUAD_NORMAL); + gPostColorFilterProgram.unbind(); + */ +} + +void LLPostProcess::createColorFilterShader(void) +{ + /// Define uniform names + colorFilterUniforms[sRenderTexture] = 0; + colorFilterUniforms[sBrightness] = 0; + colorFilterUniforms[sContrast] = 0; + colorFilterUniforms[sContrastBase] = 0; + colorFilterUniforms[sSaturation] = 0; + colorFilterUniforms[sLumWeights] = 0; +} + +void LLPostProcess::applyNightVisionShader(void) +{ + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + gPostNightVisionProgram.bind(); + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); + + getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); + glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); + + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + + gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture); + glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); + + + glUniform1fARB(nightVisionUniforms["brightMult"], tweaks.getBrightMult()); + glUniform1fARB(nightVisionUniforms["noiseStrength"], tweaks.getNoiseStrength()); + noiseTextureScale = 0.01f + ((101.f - tweaks.getNoiseSize()) / 100.f); + noiseTextureScale *= (screenH / NOISE_SIZE); + + + glUniform3fARB(nightVisionUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); + + LLGLEnable blend(GL_BLEND); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + LLGLDepthTest depth(GL_FALSE); + + /// Draw a screen space quad + drawOrthoQuad(screenW, screenH, QUAD_NOISE); + gPostNightVisionProgram.unbind(); + gGL.getTexUnit(0)->activate(); + */ +} + +void LLPostProcess::createNightVisionShader(void) +{ + /// Define uniform names + nightVisionUniforms[sRenderTexture] = 0; + nightVisionUniforms[sNoiseTexture] = 0; + nightVisionUniforms[sBrightMult] = 0; + nightVisionUniforms[sNoiseStrength] = 0; + nightVisionUniforms[sLumWeights] = 0; + + createNoiseTexture(mNoiseTexture); +} + +void LLPostProcess::applyBloomShader(void) +{ + +} + +void LLPostProcess::createBloomShader(void) +{ + createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); + + /// Create Bloom Extract Shader + bloomExtractUniforms[sRenderTexture] = 0; + bloomExtractUniforms[sExtractLow] = 0; + bloomExtractUniforms[sExtractHigh] = 0; + bloomExtractUniforms[sLumWeights] = 0; + + /// Create Bloom Blur Shader + bloomBlurUniforms[sRenderTexture] = 0; + bloomBlurUniforms[sBloomStrength] = 0; + bloomBlurUniforms[sTexelSize] = 0; + bloomBlurUniforms[sBlurDirection] = 0; + bloomBlurUniforms[sBlurWidth] = 0; +} + +void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog) +{ + /// Find uniform locations and insert into map + glslUniforms::iterator i; + for (i = uniforms.begin(); i != uniforms.end(); ++i){ + i->second = glGetUniformLocationARB(prog, i->first.String().c_str()); + } +} + +void LLPostProcess::doEffects(void) +{ + /// Save GL State + glPushAttrib(GL_ALL_ATTRIB_BITS); + glPushClientAttrib(GL_ALL_ATTRIB_BITS); + + /// Copy the screen buffer to the render texture + { + U32 tex = mSceneRenderTexture->getTexName() ; + copyFrameBuffer(tex, screenW, screenH); + } + + /// Clear the frame buffer. + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + /// Change to an orthogonal view + viewOrthogonal(screenW, screenH); + + checkError(); + applyShaders(); + + LLGLSLShader::bindNoShader(); + checkError(); + + /// Change to a perspective view + viewPerspective(); + + /// Reset GL State + glPopClientAttrib(); + glPopAttrib(); + checkError(); +} + +void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height) +{ + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); + glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); +} + +void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type) +{ +#if 0 + float noiseX = 0.f; + float noiseY = 0.f; + float screenRatio = 1.0f; + + if (type == QUAD_NOISE){ + noiseX = ((float) rand() / (float) RAND_MAX); + noiseY = ((float) rand() / (float) RAND_MAX); + screenRatio = (float) width / (float) height; + } + + + glBegin(GL_QUADS); + if (type != QUAD_BLOOM_EXTRACT){ + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height); + } else { + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f); + } + if (type == QUAD_NOISE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, + noiseX, + noiseTextureScale + noiseY); + } else if (type == QUAD_BLOOM_COMBINE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f); + } + glVertex2f(0.f, (GLfloat) screenH - height); + + if (type != QUAD_BLOOM_EXTRACT){ + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); + } else { + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); + } + if (type == QUAD_NOISE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, + noiseX, + noiseY); + } else if (type == QUAD_BLOOM_COMBINE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f); + } + glVertex2f(0.f, (GLfloat) height + (screenH - height)); + + + if (type != QUAD_BLOOM_EXTRACT){ + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f); + } else { + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f); + } + if (type == QUAD_NOISE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, + screenRatio * noiseTextureScale + noiseX, + noiseY); + } else if (type == QUAD_BLOOM_COMBINE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f); + } + glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height)); + + + if (type != QUAD_BLOOM_EXTRACT){ + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height); + } else { + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f); + } + if (type == QUAD_NOISE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, + screenRatio * noiseTextureScale + noiseX, + noiseTextureScale + noiseY); + } else if (type == QUAD_BLOOM_COMBINE){ + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f); + } + glVertex2f((GLfloat) width, (GLfloat) screenH - height); + glEnd(); +#endif +} + +void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) +{ + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.ortho( 0.f, (GLdouble) width , (GLdouble) height , 0.f, -1.f, 1.f ); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); +} + +void LLPostProcess::viewPerspective(void) +{ + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); +} + +void LLPostProcess::changeOrthogonal(unsigned int width, unsigned int height) +{ + viewPerspective(); + viewOrthogonal(width, height); +} + +void LLPostProcess::createTexture(LLPointer& texture, unsigned int width, unsigned int height) +{ + std::vector data(width * height * 4, 0) ; + + texture = new LLImageGL(FALSE) ; + if(texture->createGLTexture()) + { + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName()); + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, + GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + } +} + +void LLPostProcess::createNoiseTexture(LLPointer& texture) +{ + std::vector buffer(NOISE_SIZE * NOISE_SIZE); + for (unsigned int i = 0; i < NOISE_SIZE; i++){ + for (unsigned int k = 0; k < NOISE_SIZE; k++){ + buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); + } + } + + texture = new LLImageGL(FALSE) ; + if(texture->createGLTexture()) + { + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName()); + LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP); + } +} + +bool LLPostProcess::checkError(void) +{ + GLenum glErr; + bool retCode = false; + + glErr = glGetError(); + while (glErr != GL_NO_ERROR) + { + // shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl; + char const * err_str_raw = (const char *) gluErrorString(glErr); + + if(err_str_raw == NULL) + { + std::ostringstream err_builder; + err_builder << "unknown error number " << glErr; + mShaderErrorString = err_builder.str(); + } + else + { + mShaderErrorString = err_str_raw; + } + + retCode = true; + glErr = glGetError(); + } + return retCode; +} + +void LLPostProcess::checkShaderError(GLhandleARB shader) +{ + GLint infologLength = 0; + GLint charsWritten = 0; + GLchar *infoLog; + + checkError(); // Check for OpenGL errors + + glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength); + + checkError(); // Check for OpenGL errors + + if (infologLength > 0) + { + infoLog = (GLchar *)malloc(infologLength); + if (infoLog == NULL) + { + /// Could not allocate infolog buffer + return; + } + glGetInfoLogARB(shader, infologLength, &charsWritten, infoLog); + // shaderErrorLog << (char *) infoLog << std::endl; + mShaderErrorString = (char *) infoLog; + free(infoLog); + } + checkError(); // Check for OpenGL errors +} -- cgit v1.2.3 From 88de325b36b92aafc1b12aed4617c73c01218b43 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Fri, 1 Mar 2013 14:07:55 -0800 Subject: Fix integration tests broken by instancetracker changes --- indra/llcommon/tests/llinstancetracker_test.cpp | 6 +++--- indra/newview/tests/llagentaccess_test.cpp | 2 +- indra/newview/tests/lllogininstance_test.cpp | 2 +- indra/newview/tests/llremoteparcelrequest_test.cpp | 2 +- indra/newview/tests/llsecapi_test.cpp | 2 +- indra/newview/tests/llsechandler_basic_test.cpp | 2 +- indra/newview/tests/llslurl_test.cpp | 2 +- indra/newview/tests/lltranslate_test.cpp | 2 +- indra/newview/tests/llviewerhelputil_test.cpp | 2 +- indra/newview/tests/llviewernetwork_test.cpp | 2 +- indra/newview/tests/llworldmipmap_test.cpp | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp index 454695ff9f..9d5db4b1d9 100644 --- a/indra/llcommon/tests/llinstancetracker_test.cpp +++ b/indra/llcommon/tests/llinstancetracker_test.cpp @@ -48,16 +48,16 @@ struct Badness: public std::runtime_error Badness(const std::string& what): std::runtime_error(what) {} }; -struct Keyed: public LLInstanceTracker +struct Keyed: public INSTANCE_TRACKER_KEYED(Keyed, std::string) { Keyed(const std::string& name): - LLInstanceTracker(name), + INSTANCE_TRACKER_KEYED(Keyed, std::string)(name), mName(name) {} std::string mName; }; -struct Unkeyed: public LLInstanceTracker +struct Unkeyed: public INSTANCE_TRACKER(Unkeyed) { Unkeyed(const std::string& thrw="") { diff --git a/indra/newview/tests/llagentaccess_test.cpp b/indra/newview/tests/llagentaccess_test.cpp index 3ba25f3c10..426ad40342 100644 --- a/indra/newview/tests/llagentaccess_test.cpp +++ b/indra/newview/tests/llagentaccess_test.cpp @@ -40,7 +40,7 @@ static U32 test_preferred_maturity = SIM_ACCESS_PG; LLControlGroup::LLControlGroup(const std::string& name) - : LLInstanceTracker(name) + : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { } diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp index 7705b4c567..25da5939f1 100644 --- a/indra/newview/tests/lllogininstance_test.cpp +++ b/indra/newview/tests/lllogininstance_test.cpp @@ -167,7 +167,7 @@ std::string LLGridManager::getAppSLURLBase(const std::string& grid_name) LLControlGroup gSavedSettings("Global"); LLControlGroup::LLControlGroup(const std::string& name) : - LLInstanceTracker(name){} + INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name){} LLControlGroup::~LLControlGroup() {} void LLControlGroup::setBOOL(const std::string& name, BOOL val) {} BOOL LLControlGroup::getBOOL(const std::string& name) { return FALSE; } diff --git a/indra/newview/tests/llremoteparcelrequest_test.cpp b/indra/newview/tests/llremoteparcelrequest_test.cpp index ed66066b0a..da273132db 100644 --- a/indra/newview/tests/llremoteparcelrequest_test.cpp +++ b/indra/newview/tests/llremoteparcelrequest_test.cpp @@ -69,7 +69,7 @@ void LLAgent::sendReliableMessage(void) { } LLUUID gAgentSessionID; LLUUID gAgentID; LLUIColor::LLUIColor(void) { } -LLControlGroup::LLControlGroup(std::string const & name) : LLInstanceTracker(name) { } +LLControlGroup::LLControlGroup(std::string const & name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { } LLControlGroup::~LLControlGroup(void) { } void LLUrlEntryParcel::processParcelInfo(const LLUrlEntryParcel::LLParcelData& parcel_data) { } diff --git a/indra/newview/tests/llsecapi_test.cpp b/indra/newview/tests/llsecapi_test.cpp index 703603e2db..83a4149971 100644 --- a/indra/newview/tests/llsecapi_test.cpp +++ b/indra/newview/tests/llsecapi_test.cpp @@ -37,7 +37,7 @@ // Mock objects for the dependencies of the code we're testing LLControlGroup::LLControlGroup(const std::string& name) -: LLInstanceTracker(name) {} +: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/llsechandler_basic_test.cpp b/indra/newview/tests/llsechandler_basic_test.cpp index 0235400976..814010028f 100644 --- a/indra/newview/tests/llsechandler_basic_test.cpp +++ b/indra/newview/tests/llsechandler_basic_test.cpp @@ -69,7 +69,7 @@ extern bool _cert_hostname_wildcard_match(const std::string& hostname, const std std::string gFirstName; std::string gLastName; LLControlGroup::LLControlGroup(const std::string& name) -: LLInstanceTracker(name) {} +: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp index 09343ef227..d7debd6c67 100644 --- a/indra/newview/tests/llslurl_test.cpp +++ b/indra/newview/tests/llslurl_test.cpp @@ -35,7 +35,7 @@ // Mock objects for the dependencies of the code we're testing LLControlGroup::LLControlGroup(const std::string& name) -: LLInstanceTracker(name) {} +: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/lltranslate_test.cpp b/indra/newview/tests/lltranslate_test.cpp index fd9527d631..c13660332d 100644 --- a/indra/newview/tests/lltranslate_test.cpp +++ b/indra/newview/tests/lltranslate_test.cpp @@ -295,7 +295,7 @@ LLControlGroup gSavedSettings("test"); std::string LLUI::getLanguage() { return "en"; } std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { return "dummy"; } -LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker(name) {} +LLControlGroup::LLControlGroup(const std::string& name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} std::string LLControlGroup::getString(const std::string& name) { return "dummy"; } LLControlGroup::~LLControlGroup() {} diff --git a/indra/newview/tests/llviewerhelputil_test.cpp b/indra/newview/tests/llviewerhelputil_test.cpp index 710881d811..102cad8852 100644 --- a/indra/newview/tests/llviewerhelputil_test.cpp +++ b/indra/newview/tests/llviewerhelputil_test.cpp @@ -47,7 +47,7 @@ static std::string gOS; // Mock objects for the dependencies of the code we're testing LLControlGroup::LLControlGroup(const std::string& name) - : LLInstanceTracker(name) {} + : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index a1e97ea17e..725b5122fb 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -35,7 +35,7 @@ // Mock objects for the dependencies of the code we're testing LLControlGroup::LLControlGroup(const std::string& name) -: LLInstanceTracker(name) {} +: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/llworldmipmap_test.cpp b/indra/newview/tests/llworldmipmap_test.cpp index e7ef017760..47453a1b1a 100644 --- a/indra/newview/tests/llworldmipmap_test.cpp +++ b/indra/newview/tests/llworldmipmap_test.cpp @@ -46,7 +46,7 @@ void LLViewerTexture::setBoostLevel(S32 ) { } LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const std::string&, BOOL, LLViewerTexture::EBoostLevel, S8, LLGLint, LLGLenum, const LLUUID& ) { return NULL; } -LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker(name) { } +LLControlGroup::LLControlGroup(const std::string& name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { } LLControlGroup::~LLControlGroup() { } std::string LLControlGroup::getString(const std::string& ) { return std::string("test_url"); } LLControlGroup gSavedSettings("test_settings"); -- cgit v1.2.3 From 3849ee79c3810226d1129bcbeb6bd69144aba243 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Fri, 1 Mar 2013 14:28:48 -0800 Subject: Added missing enums for integ test usage --- indra/llcommon/llinstancetracker.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 70bccde992..c31f579f30 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -57,6 +57,8 @@ enum InstanceTrackType InstanceTrackType_LLMediaCtrl, InstanceTrackType_LLNameListCtrl, InstanceTrackType_LLToast, + InstanceTrackType_Keyed, // for integ tests + InstanceTrackType_Unkeyed, // for integ tests kInstanceTrackTypeCount }; -- cgit v1.2.3 From e7e617f42351876e3d003f885e89d19a02ab6f48 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 4 Mar 2013 11:10:10 -0800 Subject: For MAINT-2303 Fix potential stack smash from well-crafted meshes --- indra/newview/llvovolume.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c0f80cf855..c7d317c526 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3839,7 +3839,8 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons LLMatrix4a mp[64]; LLMatrix4* mat = (LLMatrix4*) mp; - for (U32 j = 0; j < skin->mJointNames.size(); ++j) + U32 maxJoints = llmin(skin->mJointNames.size(), 64); + for (U32 j = 0; j < maxJoints; ++j) { LLJoint* joint = avatar->getJoint(skin->mJointNames[j]); if (joint) @@ -3894,8 +3895,11 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons F32 w = wght[k]; LLMatrix4a src; - src.setMul(mp[idx[k]], w); - + // Insure ref'd bone is in our clamped array of mats + llassert(idx[k] < 64); + // don't read garbage off the stack in release + if (idx[k] < 64) + src.setMul(mp[idx[k]], w); final_mat.add(src); } -- cgit v1.2.3 From 8c5c877d304d1173d2be2e6dcaa8982a4a16c6c0 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 4 Mar 2013 13:04:08 -0800 Subject: Make fix for MAINT-2303 work on TC and not just my install of VS 2010 --- indra/newview/llvovolume.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 895808d225..246c84e3cb 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3846,10 +3846,12 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons } //build matrix palette - LLMatrix4a mp[64]; + static const size_t kMaxJoints = 64; + + LLMatrix4a mp[kMaxJoints]; LLMatrix4* mat = (LLMatrix4*) mp; - U32 maxJoints = llmin(skin->mJointNames.size(), 64); + U32 maxJoints = llmin(skin->mJointNames.size(), kMaxJoints); for (U32 j = 0; j < maxJoints; ++j) { LLJoint* joint = avatar->getJoint(skin->mJointNames[j]); @@ -3906,10 +3908,9 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons LLMatrix4a src; // Insure ref'd bone is in our clamped array of mats - llassert(idx[k] < 64); - // don't read garbage off the stack in release - if (idx[k] < 64) - src.setMul(mp[idx[k]], w); + llassert(idx[k] < kMaxJoints); + // clamp k to kMaxJoints to avoid reading garbage off stack in release + src.setMul(mp[idx[(k < kMaxJoints) ? k : 0]], w); final_mat.add(src); } -- cgit v1.2.3 From 3ee3c3ced32bd1e67a6bea51341734c8764df018 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 4 Mar 2013 14:26:16 -0800 Subject: MAINT-2422 : Clean up mesh http status code usage --- indra/newview/llmeshrepository.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index ae48898e82..306f29f703 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1918,7 +1918,7 @@ void LLMeshLODResponder::completedRaw(U32 status, const std::string& reason, if (data_size < mRequestedBytes) { - if (status == 499 || status == 503) + if (status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE) { //timeout or service unavailable, try again llwarns << "Timeout or service unavailable, retrying." << llendl; LLMeshRepository::sHTTPRetryCount++; @@ -1926,7 +1926,7 @@ void LLMeshLODResponder::completedRaw(U32 status, const std::string& reason, } else { - llassert(status == 499 || status == 503); //intentionally trigger a breakpoint + llassert(status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE); //intentionally trigger a breakpoint llwarns << "Unhandled status " << status << llendl; } return; @@ -1982,7 +1982,7 @@ void LLMeshSkinInfoResponder::completedRaw(U32 status, const std::string& reason if (data_size < mRequestedBytes) { - if (status == 499 || status == 503) + if (status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE) { //timeout or service unavailable, try again llwarns << "Timeout or service unavailable, retrying." << llendl; LLMeshRepository::sHTTPRetryCount++; @@ -1990,7 +1990,7 @@ void LLMeshSkinInfoResponder::completedRaw(U32 status, const std::string& reason } else { - llassert(status == 499 || status == 503); //intentionally trigger a breakpoint + llassert(status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE); //intentionally trigger a breakpoint llwarns << "Unhandled status " << status << llendl; } return; @@ -2045,7 +2045,7 @@ void LLMeshDecompositionResponder::completedRaw(U32 status, const std::string& r if (data_size < mRequestedBytes) { - if (status == 499 || status == 503) + if (status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE) { //timeout or service unavailable, try again llwarns << "Timeout or service unavailable, retrying." << llendl; LLMeshRepository::sHTTPRetryCount++; @@ -2053,7 +2053,7 @@ void LLMeshDecompositionResponder::completedRaw(U32 status, const std::string& r } else { - llassert(status == 499 || status == 503); //intentionally trigger a breakpoint + llassert(status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE); //intentionally trigger a breakpoint llwarns << "Unhandled status " << status << llendl; } return; @@ -2109,7 +2109,7 @@ void LLMeshPhysicsShapeResponder::completedRaw(U32 status, const std::string& re if (data_size < mRequestedBytes) { - if (status == 499 || status == 503) + if (status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE) { //timeout or service unavailable, try again llwarns << "Timeout or service unavailable, retrying." << llendl; LLMeshRepository::sHTTPRetryCount++; @@ -2117,7 +2117,7 @@ void LLMeshPhysicsShapeResponder::completedRaw(U32 status, const std::string& re } else { - llassert(status == 499 || status == 503); //intentionally trigger a breakpoint + llassert(status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE); //intentionally trigger a breakpoint llwarns << "Unhandled status " << status << llendl; } return; @@ -2170,16 +2170,16 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason, // << "Header responder failed with status: " // << status << ": " << reason << llendl; - // 503 (service unavailable) or 499 (timeout) + // 503 (service unavailable) or 499 (internal Linden-generated error) // can be due to server load and can be retried // TODO*: Add maximum retry logic, exponential backoff // and (somewhat more optional than the others) retries // again after some set period of time - llassert(status == 503 || status == 499); + llassert(status == HTTP_SERVICE_UNAVAILABLE || status == HTTP_REQUEST_TIME_OUT || status == HTTP_INTERNAL_ERROR); - if (status == 503 || status == 499) + if (status == HTTP_SERVICE_UNAVAILABLE || status == HTTP_REQUEST_TIME_OUT || status == HTTP_INTERNAL_ERROR) { //retry llwarns << "Timeout or service unavailable, retrying." << llendl; LLMeshRepository::sHTTPRetryCount++; @@ -2191,7 +2191,7 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason, } else { - llwarns << "Unhandled status." << llendl; + llwarns << "Unhandled status: " << status << llendl; } } -- cgit v1.2.3 From f3aa1aa31e75c88ea0b5402dc1948bfd44523419 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 4 Mar 2013 14:27:41 -0800 Subject: For MAINT-1930 add checks to unprotected volume pointer deref --- indra/newview/llvovolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 246c84e3cb..db52b1bd1e 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1268,7 +1268,7 @@ BOOL LLVOVolume::calcLOD() else { distance = mDrawable->mDistanceWRTCamera; - radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length(); + radius = getVolume() ? getVolume()->mLODScaleBias.scaledVec(getScale()).length() : getScale().length(); } //hold onto unmodified distance for debugging -- cgit v1.2.3 From 609ed855e1160505238378a1be49e2b92e8496f5 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 4 Mar 2013 18:01:42 -0600 Subject: MAINT-2371 More optimizations. Reviewed by Graham --- indra/llcommon/llmemory.h | 13 +- indra/llmath/llvolume.cpp | 220 ++++++++++++--------- indra/llmath/llvolume.h | 1 + indra/llrender/llgl.cpp | 11 +- indra/llrender/llimagegl.cpp | 34 +++- indra/llrender/llrender.cpp | 10 + indra/llrender/llshadermgr.cpp | 46 ++++- indra/llrender/llshadermgr.h | 44 +++++ indra/llrender/llvertexbuffer.cpp | 88 ++++----- indra/llrender/llvertexbuffer.h | 4 +- .../app_settings/shaders/class1/deferred/giF.glsl | 190 ------------------ .../shaders/class1/deferred/waterF.glsl | 6 +- .../shaders/class1/environment/underWaterF.glsl | 2 - .../shaders/class1/environment/waterF.glsl | 2 - indra/newview/llappviewer.cpp | 2 +- indra/newview/lldrawable.cpp | 2 +- indra/newview/lldrawpool.cpp | 1 + indra/newview/lldrawpoolavatar.cpp | 4 +- indra/newview/lldrawpoolterrain.cpp | 8 +- indra/newview/lldrawpoolwater.cpp | 62 +++--- indra/newview/llface.cpp | 99 +++++++--- indra/newview/llfasttimerview.cpp | 2 +- indra/newview/llviewerdisplay.cpp | 4 +- indra/newview/llviewershadermgr.cpp | 104 +++------- indra/newview/llviewershadermgr.h | 69 +------ indra/newview/llvovolume.cpp | 2 +- indra/newview/llwaterparammanager.cpp | 12 +- indra/newview/llwlparammanager.cpp | 4 +- indra/newview/pipeline.cpp | 10 +- 29 files changed, 474 insertions(+), 582 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/giF.glsl (limited to 'indra') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index e725bdd9fa..46cabfadcd 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -38,17 +38,28 @@ class LLMutex ; inline void* ll_aligned_malloc( size_t size, int align ) { +#if defined(LL_WINDOWS) + return _aligned_malloc(size, align); +#else void* mem = malloc( size + (align - 1) + sizeof(void*) ); char* aligned = ((char*)mem) + sizeof(void*); aligned += align - ((uintptr_t)aligned & (align - 1)); ((void**)aligned)[-1] = mem; return aligned; +#endif } inline void ll_aligned_free( void* ptr ) { - free( ((void**)ptr)[-1] ); +#if defined(LL_WINDOWS) + _aligned_free(ptr); +#else + if (ptr) + { + free( ((void**)ptr)[-1] ); + } +#endif } #if !LL_USE_TCMALLOC diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 77d89568df..d614695efb 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -5180,6 +5180,7 @@ LLVolumeFace::LLVolumeFace() : mNumS(0), mNumT(0), mNumVertices(0), + mNumAllocatedVertices(0), mNumIndices(0), mPositions(NULL), mNormals(NULL), @@ -5204,6 +5205,7 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src) mNumS(0), mNumT(0), mNumVertices(0), + mNumAllocatedVertices(0), mNumIndices(0), mPositions(NULL), mNormals(NULL), @@ -5258,12 +5260,6 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) { LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) src.mTexCoords, tc_size); } - else - { - ll_aligned_free_16(mTexCoords) ; - mTexCoords = NULL ; - } - if (src.mBinormals) { @@ -5311,10 +5307,11 @@ void LLVolumeFace::freeData() { ll_aligned_free_16(mPositions); mPositions = NULL; - ll_aligned_free_16( mNormals); + + //normals and texture coordinates are part of the same buffer as mPositions, do not free them separately mNormals = NULL; - ll_aligned_free_16(mTexCoords); mTexCoords = NULL; + ll_aligned_free_16(mIndices); mIndices = NULL; ll_aligned_free_16(mBinormals); @@ -5496,18 +5493,6 @@ void LLVolumeFace::optimize(F32 angle_cutoff) llassert(new_face.mNumIndices == mNumIndices); llassert(new_face.mNumVertices <= mNumVertices); - if (angle_cutoff > 1.f && !mNormals) - { - ll_aligned_free_16(new_face.mNormals); - new_face.mNormals = NULL; - } - - if (!mTexCoords) - { - ll_aligned_free_16(new_face.mTexCoords); - new_face.mTexCoords = NULL; - } - swapData(new_face); } @@ -5708,35 +5693,44 @@ public: void updateScores() { - for (U32 i = MaxSizeVertexCache; i < MaxSizeVertexCache+3; ++i) - { //trailing 3 vertices aren't actually in the cache for scoring purposes - if (mCache[i]) + LLVCacheVertexData** data_iter = mCache+MaxSizeVertexCache; + LLVCacheVertexData** end_data = mCache+MaxSizeVertexCache+3; + + while(data_iter != end_data) + { + LLVCacheVertexData* data = *data_iter++; + //trailing 3 vertices aren't actually in the cache for scoring purposes + if (data) { - mCache[i]->mCacheTag = -1; + data->mCacheTag = -1; } } - for (U32 i = 0; i < MaxSizeVertexCache; ++i) + data_iter = mCache; + end_data = mCache+MaxSizeVertexCache; + + while (data_iter != end_data) { //update scores of vertices in cache - if (mCache[i]) + LLVCacheVertexData* data = *data_iter++; + if (data) { - mCache[i]->mScore = find_vertex_score(*(mCache[i])); - llassert(mCache[i]->mCacheTag == i); + data->mScore = find_vertex_score(*data); } } mBestTriangle = NULL; //update triangle scores - for (U32 i = 0; i < MaxSizeVertexCache+3; ++i) + data_iter = mCache; + end_data = mCache+MaxSizeVertexCache+3; + + while (data_iter != end_data) { - LLVCacheVertexData* data = mCache[i]; + LLVCacheVertexData* data = *data_iter++; if (data) { - U32 count = data->mTriangles.size(); - - for (U32 j = 0; j < count; ++j) + for (std::vector::iterator iter = data->mTriangles.begin(), end_iter = data->mTriangles.end(); iter != end_iter; ++iter) { - LLVCacheTriangleData* tri = data->mTriangles[j]; + LLVCacheTriangleData* tri = *iter; if (tri->mActive) { tri->mScore = tri->mVertex[0]->mScore; @@ -5753,13 +5747,17 @@ public: } //knock trailing 3 vertices off the cache - for (U32 i = MaxSizeVertexCache; i < MaxSizeVertexCache+3; ++i) + data_iter = mCache+MaxSizeVertexCache; + end_data = mCache+MaxSizeVertexCache+3; + while (data_iter != end_data) { - if (mCache[i]) + LLVCacheVertexData* data = *data_iter; + if (data) { - llassert(mCache[i]->mCacheTag == -1); - mCache[i] = NULL; + llassert(data->mCacheTag == -1); + *data_iter = NULL; } + ++data_iter; } } }; @@ -5894,10 +5892,10 @@ void LLVolumeFace::cacheOptimize() //allocate space for new buffer S32 num_verts = mNumVertices; - LLVector4a* pos = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); - LLVector4a* norm = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); S32 size = ((num_verts*sizeof(LLVector2)) + 0xF) & ~0xF; - LLVector2* tc = (LLVector2*) ll_aligned_malloc_16(size); + LLVector4a* pos = (LLVector4a*) ll_aligned_malloc(sizeof(LLVector4a)*2*num_verts+size, 64); + LLVector4a* norm = pos + num_verts; + LLVector2* tc = (LLVector2*) (norm + num_verts); LLVector4a* wght = NULL; if (mWeights) @@ -5945,9 +5943,8 @@ void LLVolumeFace::cacheOptimize() mIndices[i] = new_idx[mIndices[i]]; } - ll_aligned_free_16(mPositions); - ll_aligned_free_16(mNormals); - ll_aligned_free_16(mTexCoords); + ll_aligned_free(mPositions); + // DO NOT free mNormals and mTexCoords as they are part of mPositions buffer ll_aligned_free_16(mWeights); ll_aligned_free_16(mBinormals); @@ -6664,24 +6661,22 @@ void LLVolumeFace::createBinormals() void LLVolumeFace::resizeVertices(S32 num_verts) { - ll_aligned_free_16(mPositions); - ll_aligned_free_16(mNormals); + ll_aligned_free(mPositions); + //DO NOT free mNormals and mTexCoords as they are part of mPositions buffer ll_aligned_free_16(mBinormals); - ll_aligned_free_16(mTexCoords); - + mBinormals = NULL; if (num_verts) { - mPositions = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); - ll_assert_aligned(mPositions, 16); - mNormals = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); - ll_assert_aligned(mNormals, 16); - //pad texture coordinate block end to allow for QWORD reads S32 size = ((num_verts*sizeof(LLVector2)) + 0xF) & ~0xF; - mTexCoords = (LLVector2*) ll_aligned_malloc_16(size); - ll_assert_aligned(mTexCoords, 16); + + mPositions = (LLVector4a*) ll_aligned_malloc(sizeof(LLVector4a)*2*num_verts+size, 64); + mNormals = mPositions+num_verts; + mTexCoords = (LLVector2*) (mNormals+num_verts); + + ll_assert_aligned(mPositions, 64); } else { @@ -6691,6 +6686,7 @@ void LLVolumeFace::resizeVertices(S32 num_verts) } mNumVertices = num_verts; + mNumAllocatedVertices = num_verts; } void LLVolumeFace::pushVertex(const LLVolumeFace::VertexData& cv) @@ -6701,27 +6697,43 @@ void LLVolumeFace::pushVertex(const LLVolumeFace::VertexData& cv) void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, const LLVector2& tc) { S32 new_verts = mNumVertices+1; - S32 new_size = new_verts*16; - S32 old_size = mNumVertices*16; - //positions - mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_size, old_size); - ll_assert_aligned(mPositions,16); + if (new_verts > mNumAllocatedVertices) + { + //double buffer size on expansion + new_verts *= 2; + + S32 new_tc_size = ((new_verts*8)+0xF) & ~0xF; + S32 old_tc_size = ((mNumVertices*8)+0xF) & ~0xF; + + S32 old_vsize = mNumVertices*16; + + S32 new_size = new_verts*16*2+new_tc_size; + + LLVector4a* old_buf = mPositions; + + mPositions = (LLVector4a*) ll_aligned_malloc(new_size, 64); + mNormals = mPositions+new_verts; + mTexCoords = (LLVector2*) (mNormals+new_verts); + + //positions + LLVector4a::memcpyNonAliased16((F32*) mPositions, (F32*) old_buf, old_vsize); + + //normals + LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) (old_buf+mNumVertices), old_vsize); - //normals - mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_size, old_size); - ll_assert_aligned(mNormals,16); - - //tex coords - new_size = ((new_verts*8)+0xF) & ~0xF; - old_size = ((mNumVertices*8)+0xF) & ~0xF; - mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, new_size, old_size); - ll_assert_aligned(mTexCoords,16); + //tex coords + LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) (old_buf+mNumVertices*2), old_tc_size); + //just clear binormals + ll_aligned_free_16(mBinormals); - //just clear binormals - ll_aligned_free_16(mBinormals); - mBinormals = NULL; + ll_aligned_free(old_buf); + + mNumAllocatedVertices = new_verts; + + mBinormals = NULL; + } mPositions[mNumVertices] = pos; mNormals[mNumVertices] = norm; @@ -6810,13 +6822,23 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat llerrs << "Cannot append empty face." << llendl; } + U32 old_vsize = mNumVertices*16; + U32 new_vsize = new_count * 16; + U32 old_tcsize = (mNumVertices*sizeof(LLVector2)+0xF) & ~0xF; + U32 new_tcsize = (new_count*sizeof(LLVector2)+0xF) & ~0xF; + U32 new_size = new_vsize * 2 + new_tcsize; + //allocate new buffer space - mPositions = (LLVector4a*) ll_aligned_realloc_16(mPositions, new_count*sizeof(LLVector4a), mNumVertices*sizeof(LLVector4a)); - ll_assert_aligned(mPositions, 16); - mNormals = (LLVector4a*) ll_aligned_realloc_16(mNormals, new_count*sizeof(LLVector4a), mNumVertices*sizeof(LLVector4a)); - ll_assert_aligned(mNormals, 16); - mTexCoords = (LLVector2*) ll_aligned_realloc_16(mTexCoords, (new_count*sizeof(LLVector2)+0xF) & ~0xF, (mNumVertices*sizeof(LLVector2)+0xF) & ~0xF); - ll_assert_aligned(mTexCoords, 16); + LLVector4a* old_buf = mPositions; + mPositions = (LLVector4a*) ll_aligned_malloc(new_size, 64); + mNormals = mPositions + new_count; + mTexCoords = (LLVector2*) (mNormals+new_count); + + mNumAllocatedVertices = new_count; + + LLVector4a::memcpyNonAliased16((F32*) mPositions, (F32*) old_buf, old_vsize); + LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) (old_buf+mNumVertices), old_vsize); + LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) (old_buf+mNumVertices*2), old_tcsize); mNumVertices = new_count; @@ -6912,12 +6934,15 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) LLVector4a* pos = (LLVector4a*) mPositions; LLVector4a* norm = (LLVector4a*) mNormals; LLVector2* tc = (LLVector2*) mTexCoords; - S32 begin_stex = llfloor( profile[mBeginS].mV[2] ); + F32 begin_stex = floorf(profile[mBeginS].mV[2]); S32 num_s = ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2) ? mNumS/2 : mNumS; S32 cur_vertex = 0; + S32 end_t = mBeginT+mNumT; + bool test = (mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2; + // Copy the vertices into the array - for (t = mBeginT; t < mBeginT + mNumT; t++) + for (t = mBeginT; t < end_t; t++) { tt = path_data[t].mTexT; for (s = 0; s < num_s; s++) @@ -6968,9 +6993,8 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) norm[cur_vertex].clear(); cur_vertex++; - if ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2 && s > 0) + if (test && s > 0) { - pos[cur_vertex].load3(mesh[i].mPos.mV); tc[cur_vertex] = LLVector2(ss,tt); @@ -7085,30 +7109,38 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } //generate normals - for (U32 i = 0; i < mNumIndices/3; i++) //for each triangle + U32 count = mNumIndices/3; + + for (U32 i = 0; i < count; i++) //for each triangle { const U16* idx = &(mIndices[i*3]); - - LLVector4a* v[] = - { pos+idx[0], pos+idx[1], pos+idx[2] }; + LLVector4a& v0 = *(pos+idx[0]); + LLVector4a& v1 = *(pos+idx[1]); + LLVector4a& v2 = *(pos+idx[2]); - LLVector4a* n[] = - { norm+idx[0], norm+idx[1], norm+idx[2] }; + LLVector4a& n0 = *(norm+idx[0]); + LLVector4a& n1 = *(norm+idx[1]); + LLVector4a& n2 = *(norm+idx[2]); //calculate triangle normal LLVector4a a, b, c; - a.setSub(*v[0], *v[1]); - b.setSub(*v[0], *v[2]); + a.setSub(v0, v1); + b.setSub(v0, v2); c.setCross3(a,b); - n[0]->add(c); - n[1]->add(c); - n[2]->add(c); + n0.add(c); + n1.add(c); + n2.add(c); //even out quad contributions - n[i%2+1]->add(c); + switch (i%2+1) + { + case 0: n0.add(c); break; + case 1: n1.add(c); break; + case 2: n2.add(c); break; + }; } // adjust normals based on wrapping and stitching diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 99158c1c44..1d3b0fe52f 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -912,6 +912,7 @@ public: LLVector2 mTexCoordExtents[2]; //minimum and maximum of texture coordinates of the face. S32 mNumVertices; + S32 mNumAllocatedVertices; S32 mNumIndices; LLVector4a* mPositions; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 89f1f36297..58bd346c15 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -741,7 +741,7 @@ bool LLGLManager::initGL() #if LL_WINDOWS if (mHasDebugOutput && gDebugGL) { //setup debug output callback - //glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE); + glDebugMessageControlARB(GL_DONT_CARE, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE); glDebugMessageCallbackARB((GLDEBUGPROCARB) gl_debug_callback, NULL); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); } @@ -1478,7 +1478,7 @@ void do_assert_glerror() void assert_glerror() { - if (!gGLActive) +/* if (!gGLActive) { //llwarns << "GL used while not active!" << llendl; @@ -1487,8 +1487,13 @@ void assert_glerror() //ll_fail("GL used while not active"); } } +*/ - if (gDebugGL) + if (!gDebugGL) + { + //funny looking if for branch prediction -- gDebugGL is almost always false and assert_glerror is called often + } + else { do_assert_glerror(); } diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index a4d7872ec2..ef2648ae98 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -709,9 +709,12 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) mMipLevels = wpo2(llmax(w, h)); - //use legacy mipmap generation mode - glTexParameteri(mTarget, GL_GENERATE_MIPMAP, GL_TRUE); - + if (!gGLManager.mHasFramebufferObject) + { + //use legacy mipmap generation mode + glTexParameteri(mTarget, GL_GENERATE_MIPMAP, GL_TRUE); + } + LLImageGL::setManualImage(mTarget, 0, mFormatInternal, w, h, mFormatPrimary, mFormatType, @@ -726,6 +729,11 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); stop_glerror(); } + + if (gGLManager.mHasFramebufferObject) + { + glGenerateMipmap(mTarget); + } } } else @@ -1057,6 +1065,16 @@ void LLImageGL::generateTextures(LLTexUnit::eTextureType type, U32 format, S32 n { bool empty = true; + if (LLRender::sGLCoreProfile) + { + switch (format) + { + case GL_LUMINANCE8: format = GL_RGB8; break; + case GL_LUMINANCE8_ALPHA8: + case GL_ALPHA8: format = GL_RGBA8; break; + } + } + dead_texturelist_t::iterator iter = sDeadTextureList[type].find(format); if (iter != sDeadTextureList[type].end()) @@ -1084,6 +1102,16 @@ void LLImageGL::deleteTextures(LLTexUnit::eTextureType type, U32 format, S32 mip { if (gGLManager.mInited) { + if (LLRender::sGLCoreProfile) + { + switch (format) + { + case GL_LUMINANCE8: format = GL_RGB8; break; + case GL_LUMINANCE8_ALPHA8: + case GL_ALPHA8: format = GL_RGBA8; break; + } + } + if (format == 0 || type == LLTexUnit::TT_CUBE_MAP || mip_levels == -1) { //unknown internal format or unknown number of mip levels, not safe to reuse glDeleteTextures(numTextures, textures); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index cb82cbfb74..dada27557e 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1070,6 +1070,16 @@ LLRender::~LLRender() void LLRender::init() { + if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) + { //bind a dummy vertex array object so we're core profile compliant +#ifdef GL_ARB_vertex_array_object + U32 ret; + glGenVertexArrays(1, &ret); + glBindVertexArray(ret); +#endif + } + + llassert_always(mBuffer.isNull()) ; stop_glerror(); mBuffer = new LLVertexBuffer(immediate_mask, 0); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index b6a9a6b653..825f80a6dc 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -974,7 +974,9 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("texture_matrix1"); mReservedUniforms.push_back("texture_matrix2"); mReservedUniforms.push_back("texture_matrix3"); - llassert(mReservedUniforms.size() == LLShaderMgr::TEXTURE_MATRIX3+1); + mReservedUniforms.push_back("object_plane_s"); + mReservedUniforms.push_back("object_plane_t"); + llassert(mReservedUniforms.size() == LLShaderMgr::OBJECT_PLANE_T+1); mReservedUniforms.push_back("viewport"); @@ -1116,6 +1118,48 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("bloomMap"); mReservedUniforms.push_back("projectionMap"); + mReservedUniforms.push_back("matrixPalette"); + + + mReservedUniforms.reserve(12); + mReservedUniforms.push_back("screenTex"); + mReservedUniforms.push_back("screenDepth"); + mReservedUniforms.push_back("refTex"); + mReservedUniforms.push_back("eyeVec"); + mReservedUniforms.push_back("time"); + mReservedUniforms.push_back("d1"); + mReservedUniforms.push_back("d2"); + mReservedUniforms.push_back("lightDir"); + mReservedUniforms.push_back("specular"); + mReservedUniforms.push_back("lightExp"); + mReservedUniforms.push_back("waterFogColor"); + mReservedUniforms.push_back("waterFogDensity"); + mReservedUniforms.push_back("waterFogKS"); + mReservedUniforms.push_back("refScale"); + mReservedUniforms.push_back("waterHeight"); + mReservedUniforms.push_back("waterPlane"); + mReservedUniforms.push_back("normScale"); + mReservedUniforms.push_back("fresnelScale"); + mReservedUniforms.push_back("fresnelOffset"); + mReservedUniforms.push_back("blurMultiplier"); + mReservedUniforms.push_back("sunAngle"); + mReservedUniforms.push_back("scaledAngle"); + mReservedUniforms.push_back("sunAngle2"); + + mReservedUniforms.push_back("camPosLocal"); + + mReservedUniforms.push_back("gWindDir"); + mReservedUniforms.push_back("gSinWaveParams"); + mReservedUniforms.push_back("gGravity"); + + mReservedUniforms.push_back("detail_0"); + mReservedUniforms.push_back("detail_1"); + mReservedUniforms.push_back("detail_2"); + mReservedUniforms.push_back("detail_3"); + mReservedUniforms.push_back("alpha_ramp"); + + mReservedUniforms.push_back("origin"); + llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); std::set dupe_check; diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 7a16b7c20f..77e90372e0 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -47,6 +47,8 @@ public: TEXTURE_MATRIX1, TEXTURE_MATRIX2, TEXTURE_MATRIX3, + OBJECT_PLANE_S, + OBJECT_PLANE_T, VIEWPORT, LIGHT_POSITION, LIGHT_DIRECTION, @@ -164,7 +166,49 @@ public: DEFERRED_LIGHT, DEFERRED_BLOOM, DEFERRED_PROJECTION, + + AVATAR_MATRIX, + + WATER_SCREENTEX, + WATER_SCREENDEPTH, + WATER_REFTEX, + WATER_EYEVEC, + WATER_TIME, + WATER_WAVE_DIR1, + WATER_WAVE_DIR2, + WATER_LIGHT_DIR, + WATER_SPECULAR, + WATER_SPECULAR_EXP, + WATER_FOGCOLOR, + WATER_FOGDENSITY, + WATER_FOGKS, + WATER_REFSCALE, + WATER_WATERHEIGHT, + WATER_WATERPLANE, + WATER_NORM_SCALE, + WATER_FRESNEL_SCALE, + WATER_FRESNEL_OFFSET, + WATER_BLUR_MULTIPLIER, + WATER_SUN_ANGLE, + WATER_SCALED_ANGLE, + WATER_SUN_ANGLE2, + + WL_CAMPOSLOCAL, + + AVATAR_WIND, + AVATAR_SINWAVE, + AVATAR_GRAVITY, + + TERRAIN_DETAIL0, + TERRAIN_DETAIL1, + TERRAIN_DETAIL2, + TERRAIN_DETAIL3, + TERRAIN_ALPHARAMP, + + SHINY_ORIGIN, + END_RESERVED_UNIFORMS + } eGLSLReservedUniforms; // singleton pattern implementation diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index f152911b24..1d257d8415 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -202,7 +202,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) glBufferDataARB(mType, size, 0, mUsage); if (mUsage != GL_DYNAMIC_COPY_ARB) { //data will be provided by application - ret = (U8*) ll_aligned_malloc_16(size); + ret = (U8*) ll_aligned_malloc(size, 64); } } else @@ -256,7 +256,7 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) llassert(vbo_block_size(size) == size); deleteBuffer(name); - ll_aligned_free_16((U8*) buffer); + ll_aligned_free((U8*) buffer); if (mType == GL_ARRAY_BUFFER_ARB) { @@ -1298,7 +1298,7 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) //actually allocate space for the vertex buffer if using VBO mapping flush(); - if (gGLManager.mHasVertexArrayObject && useVBOs() && (LLRender::sGLCoreProfile || sUseVAO)) + if (gGLManager.mHasVertexArrayObject && useVBOs() && (sUseVAO)) { #if GL_ARB_vertex_array_object mGLArray = getVAOName(); @@ -1454,21 +1454,18 @@ bool LLVertexBuffer::useVBOs() const //---------------------------------------------------------------------------- -bool expand_region(LLVertexBuffer::MappedRegion& region, S32 index, S32 count) +bool expand_region(LLVertexBuffer::MappedRegion& region, S32 start, S32 end) { - S32 end = index+count; - S32 region_end = region.mIndex+region.mCount; - if (end < region.mIndex || - index > region_end) + start > region.mEnd) { //gap exists, do not merge return false; } - S32 new_end = llmax(end, region_end); - S32 new_index = llmin(index, region.mIndex); - region.mIndex = new_index; - region.mCount = new_end-new_index; + region.mEnd = llmax(end, region.mEnd); + region.mIndex = llmin(start, region.mIndex); + region.mCount = region.mEnd-region.mIndex; + return true; } @@ -1478,7 +1475,6 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER("VBO Map"); // Map for data access volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range) { - bindGLBuffer(true); if (mFinal) { llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl; @@ -1499,23 +1495,23 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo bool mapped = false; //see if range is already mapped - for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) + S32 start_index = mOffsets[type]+index*sTypeSize[type]; + S32 end_index = start_index+count*sTypeSize[type]; + + for (std::vector::iterator iter = mMappedVertexRegions.begin(), end = mMappedVertexRegions.end(); iter != end; ++iter) { - MappedRegion& region = mMappedVertexRegions[i]; - if (region.mType == type) + MappedRegion& region = *iter; + if (expand_region(region, index, end_index)) { - if (expand_region(region, index, count)) - { - mapped = true; - break; - } + mapped = true; + break; } } if (!mapped) { //not already mapped, map new region - MappedRegion region(type, mMappable && map_range ? -1 : index, count); + MappedRegion region(mMappable && map_range ? -1 : start_index, end_index-start_index); mMappedVertexRegions.push_back(region); } } @@ -1539,6 +1535,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo { volatile U8* src = NULL; waitFence(); + bindGLBuffer(); if (gGLManager.mHasMapBufferRange) { if (map_range) @@ -1657,7 +1654,6 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_INDEX("IBO Map"); volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) { - bindGLIndices(true); if (mFinal) { llerrs << "LLVertexBuffer::mapIndexBuffer() called on a finalized buffer." << llendl; @@ -1676,12 +1672,14 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range count = mNumIndices-index; } + S32 end = index+count; + bool mapped = false; //see if range is already mapped for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) { MappedRegion& region = mMappedIndexRegions[i]; - if (expand_region(region, index, count)) + if (expand_region(region, index, end)) { mapped = true; break; @@ -1691,7 +1689,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range if (!mapped) { //not already mapped, map new region - MappedRegion region(TYPE_INDEX, mMappable && map_range ? -1 : index, count); + MappedRegion region(mMappable && map_range ? -1 : index, count); mMappedIndexRegions.push_back(region); } } @@ -1707,23 +1705,23 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range sMappedCount++; stop_glerror(); - if (gDebugGL && useVBOs()) - { - GLint elem = 0; - glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &elem); - - if (elem != mGLIndices) - { - llerrs << "Wrong index buffer bound!" << llendl; - } - } - if(!mMappable) { map_range = false; } else { + bindGLIndices(); + if (gDebugGL && useVBOs()) + { + GLint elem = 0; + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &elem); + + if (elem != mGLIndices) + { + llerrs << "Wrong index buffer bound!" << llendl; + } + } volatile U8* src = NULL; waitFence(); if (gGLManager.mHasMapBufferRange) @@ -1837,7 +1835,7 @@ void LLVertexBuffer::unmapBuffer() llassert(mUsage != GL_DYNAMIC_COPY_ARB); LLFastTimer t(FTM_VBO_UNMAP); - bindGLBuffer(true); + bindGLBuffer(); updated_all = mIndexLocked; //both vertex and index buffers done updating if(!mMappable) @@ -1848,8 +1846,8 @@ void LLVertexBuffer::unmapBuffer() for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) { const MappedRegion& region = mMappedVertexRegions[i]; - S32 offset = region.mIndex >= 0 ? mOffsets[region.mType]+sTypeSize[region.mType]*region.mIndex : 0; - S32 length = sTypeSize[region.mType]*region.mCount; + S32 offset = region.mIndex; + S32 length = region.mCount; glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedData+offset); stop_glerror(); } @@ -1873,8 +1871,8 @@ void LLVertexBuffer::unmapBuffer() for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) { const MappedRegion& region = mMappedVertexRegions[i]; - S32 offset = region.mIndex >= 0 ? mOffsets[region.mType]+sTypeSize[region.mType]*region.mIndex : 0; - S32 length = sTypeSize[region.mType]*region.mCount; + S32 offset = region.mIndex; + S32 length = region.mCount; if (gGLManager.mHasMapBufferRange) { LLFastTimer t(FTM_VBO_FLUSH_RANGE); @@ -2083,7 +2081,6 @@ bool LLVertexBuffer::bindGLArray() if (mGLArray && sGLRenderArray != mGLArray) { { - LLFastTimer t(FTM_BIND_GL_ARRAY); #if GL_ARB_vertex_array_object glBindVertexArray(mGLArray); #endif @@ -2453,11 +2450,10 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) llglassertok(); } -LLVertexBuffer::MappedRegion::MappedRegion(S32 type, S32 index, S32 count) -: mType(type), mIndex(index), mCount(count) +LLVertexBuffer::MappedRegion::MappedRegion(S32 index, S32 count) +: mIndex(index), mCount(count) { - llassert(mType == LLVertexBuffer::TYPE_INDEX || - mType < LLVertexBuffer::TYPE_TEXTURE_INDEX); + mEnd = mIndex+mCount; } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index a3400ae80c..52559d3505 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -104,11 +104,11 @@ public: class MappedRegion { public: - S32 mType; S32 mIndex; S32 mCount; + S32 mEnd; - MappedRegion(S32 type, S32 index, S32 count); + MappedRegion(S32 index, S32 count); }; LLVertexBuffer(const LLVertexBuffer& rhs) diff --git a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl deleted file mode 100644 index da1b234240..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl +++ /dev/null @@ -1,190 +0,0 @@ -/** - * @file giF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2DRect depthMap; -uniform sampler2DRect normalMap; -uniform sampler2D noiseMap; - -uniform sampler2D diffuseGIMap; -uniform sampler2D normalGIMap; -uniform sampler2D depthGIMap; - -uniform sampler2D lightFunc; - -// Inputs -VARYING vec2 vary_fragcoord; - -uniform vec2 screen_res; - -uniform mat4 inv_proj; -uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space -uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space -uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix -uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space -uniform float gi_radius; -uniform float gi_intensity; -uniform int gi_samples; -uniform vec2 gi_kern[25]; -uniform vec2 gi_scale; -uniform vec3 gi_quad; -uniform vec3 gi_spec; -uniform float gi_direction_weight; -uniform float gi_light_offset; - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -vec4 getGIPosition(vec2 gi_tc) -{ - float depth = texture2D(depthGIMap, gi_tc).a; - vec2 sc = gi_tc*2.0; - sc -= vec2(1.0, 1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = gi_inv_proj*ndc; - pos.xyz /= pos.w; - pos.w = 1.0; - return pos; -} - -vec3 giAmbient(vec3 pos, vec3 norm) -{ - vec4 gi_c = gi_mat_proj * vec4(pos, 1.0); - gi_c.xyz /= gi_c.w; - - vec4 gi_pos = gi_mat*vec4(pos,1.0); - vec3 gi_norm = (gi_norm_mat*vec4(norm,1.0)).xyz; - gi_norm = normalize(gi_norm); - - vec2 tcx = gi_norm.xy; - vec2 tcy = gi_norm.yx; - - vec4 eye_pos = gi_mat*vec4(0,0,0,1.0); - - vec3 eye_dir = normalize(gi_pos.xyz-eye_pos.xyz/eye_pos.w); - - //vec3 eye_dir = vec3(0,0,-1); - //eye_dir = (gi_norm_mat*vec4(eye_dir, 1.0)).xyz; - //eye_dir = normalize(eye_dir); - - //float round_x = gi_scale.x; - //float round_y = gi_scale.y; - - vec3 debug = texture2D(normalGIMap, gi_c.xy).rgb*0.5+0.5; - debug.xz = vec2(0.0,0.0); - //debug = fract(debug); - - float round_x = 1.0/64.0; - float round_y = 1.0/64.0; - - //gi_c.x = floor(gi_c.x/round_x+0.5)*round_x; - //gi_c.y = floor(gi_c.y/round_y+0.5)*round_y; - - float fda = 0.0; - vec3 fdiff = vec3(0,0,0); - - vec3 rcol = vec3(0,0,0); - - float fsa = 0.0; - - for (int i = -1; i < 2; i+=2 ) - { - for (int j = -1; j < 2; j+=2) - { - vec2 tc = vec2(i, j)*0.75; - vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0+tc*0.5).xyz; - //tc += gi_norm.xy*nz.z; - tc += nz.xy*2.0; - tc /= gi_samples; - tc += gi_c.xy; - - vec3 lnorm = -normalize(texture2D(normalGIMap, tc.xy).xyz*2.0-1.0); - vec3 lpos = getGIPosition(tc.xy).xyz; - - vec3 at = lpos-gi_pos.xyz; - float dist = dot(at,at); - float da = clamp(1.0/(gi_spec.x*dist), 0.0, 1.0); - - if (da > 0.0) - { - //add angular attenuation - vec3 ldir = at; - float ang_atten = clamp(dot(ldir, gi_norm), 0.0, 1.0); - - float ld = -dot(ldir, lnorm); - - if (ang_atten > 0.0 && ld < 0.0) - { - vec3 diff = texture2D(diffuseGIMap, tc.xy).xyz; - da = da*ang_atten; - fda += da; - fdiff += diff*da; - } - } - } - } - - fdiff /= max(gi_spec.y*fda, gi_quad.z); - fdiff = clamp(fdiff, vec3(0), vec3(1)); - - vec3 ret = fda*fdiff; - //ret = ret*ret*gi_quad.x+ret*gi_quad.y+gi_quad.z; - - //fda *= nz.z; - - //rcol.rgb *= gi_intensity; - //return rcol.rgb+vary_AmblitColor.rgb*0.25; - //return vec4(debug, 0.0); - //return vec4(fda*fdiff, 0.0); - return clamp(ret,vec3(0.0), vec3(1.0)); - //return debug.xyz; -} - -void main() -{ - vec2 pos_screen = vary_fragcoord.xy; - vec4 pos = getPosition(pos_screen); - vec3 norm = texture2DRect(normalMap, pos_screen).xyz; - norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm - - frag_color.xyz = giAmbient(pos, norm); -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 3427d6db57..1149aec30b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -53,13 +53,11 @@ uniform vec3 specular; uniform float lightExp; uniform float refScale; uniform float kd; -uniform vec2 screenRes; uniform vec3 normScale; uniform float fresnelScale; uniform float fresnelOffset; uniform float blurMultiplier; -uniform vec2 screen_res; -uniform mat4 norm_mat; //region space to screen space +uniform mat3 normal_matrix; //bigWave is (refCoord.w, view.w); VARYING vec4 refCoord; @@ -157,7 +155,7 @@ void main() //wavef.z *= 0.1f; //wavef = normalize(wavef); - vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz; + vec3 screenspacewavef = normal_matrix*wavef; frag_data[0] = vec4(color.rgb, 0.5); // diffuse frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec diff --git a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl index 0d8dab0a41..485e48537c 100644 --- a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl @@ -43,13 +43,11 @@ uniform vec2 fbScale; uniform float refScale; uniform float znear; uniform float zfar; -uniform float kd; uniform vec4 waterPlane; uniform vec3 eyeVec; uniform vec4 waterFogColor; uniform float waterFogDensity; uniform float waterFogKS; -uniform vec2 screenRes; //bigWave is (refCoord.w, view.w); VARYING vec4 refCoord; diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 79bffab745..1fd7bdaa5c 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -42,8 +42,6 @@ uniform vec3 lightDir; uniform vec3 specular; uniform float lightExp; uniform float refScale; -uniform float kd; -uniform vec2 screenRes; uniform vec3 normScale; uniform float fresnelScale; uniform float fresnelOffset; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 7331b93810..9bbaede68d 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -537,7 +537,7 @@ static void settings_to_globals() LLSurface::setTextureSize(gSavedSettings.getU32("RegionTextureSize")); LLRender::sGLCoreProfile = gSavedSettings.getBOOL("RenderGLCoreProfile"); - + LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); LLImageGL::sGlobalUseAnisotropic = gSavedSettings.getBOOL("RenderAnisotropic"); LLImageGL::sCompressTextures = gSavedSettings.getBOOL("RenderCompressTextures"); LLVOVolume::sLODFactor = gSavedSettings.getF32("RenderVolumeLODFactor"); diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index d041baea90..d046b22133 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -254,7 +254,7 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep) return count; } -static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face", true); +static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face"); LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) { diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 94dd927d26..d8f293cc62 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -472,6 +472,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba { params.mGroup->rebuildMesh(); } + params.mVertexBuffer->setBuffer(mask); params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 6d02ad2b96..c3cf744222 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1505,7 +1505,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) stop_glerror(); - LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", + LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv(LLViewerShaderMgr::AVATAR_MATRIX, skin->mJointNames.size(), FALSE, (GLfloat*) mat[0].mMatrix); @@ -1547,6 +1547,8 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) buff->setBuffer(data_mask); buff->drawRange(LLRender::TRIANGLES, start, end, count, offset); } + + gPipeline.addTrianglesDrawn(count, LLRender::TRIANGLES); } } } diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index 9bc32fddbd..cac862a107 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -352,8 +352,8 @@ void LLDrawPoolTerrain::renderFullShader() LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; llassert(shader); - shader->uniform4fv("object_plane_s", 1, tp0.mV); - shader->uniform4fv("object_plane_t", 1, tp1.mV); + shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0.mV); + shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1.mV); gGL.matrixMode(LLRender::MM_TEXTURE); gGL.loadIdentity(); @@ -862,8 +862,8 @@ void LLDrawPoolTerrain::renderSimple() if (LLGLSLShader::sNoFixedFunction) { - sShader->uniform4fv("object_plane_s", 1, tp0.mV); - sShader->uniform4fv("object_plane_t", 1, tp1.mV); + sShader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0.mV); + sShader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1.mV); } else { diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 4f6eaa5a5b..b6a4b0194c 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -407,8 +407,8 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() } else { - shader->uniform4fv("object_plane_s", 1, tp0); - shader->uniform4fv("object_plane_t", 1, tp1); + shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0); + shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1); } gGL.diffuseColor3f(1.f, 1.f, 1.f); @@ -546,7 +546,7 @@ void LLDrawPoolWater::shade() sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; - S32 reftex = shader->enableTexture(LLViewerShaderMgr::WATER_REFTEX); + S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX); if (reftex > -1) { @@ -577,12 +577,12 @@ void LLDrawPoolWater::shade() mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT); } - S32 screentex = shader->enableTexture(LLViewerShaderMgr::WATER_SCREENTEX); + S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX); if (screentex > -1) { - shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); - shader->uniform1f(LLViewerShaderMgr::WATER_FOGDENSITY, + shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); + shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, param_mgr->getFogDensity()); gPipeline.mWaterDis.bindTexture(0, screentex); } @@ -594,15 +594,9 @@ void LLDrawPoolWater::shade() if (mVertexShaderLevel == 1) { sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue; - shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); + shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); } - F32 screenRes[] = - { - 1.f/gGLViewport[2], - 1.f/gGLViewport[3] - }; - shader->uniform2fv("screenRes", 1, screenRes); stop_glerror(); S32 diffTex = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -614,26 +608,26 @@ void LLDrawPoolWater::shade() light_diffuse *= 6.f; //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix); - shader->uniform1f(LLViewerShaderMgr::WATER_WATERHEIGHT, eyedepth); - shader->uniform1f(LLViewerShaderMgr::WATER_TIME, sTime); - shader->uniform3fv(LLViewerShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform3fv(LLViewerShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); - shader->uniform1f(LLViewerShaderMgr::WATER_SPECULAR_EXP, light_exp); - shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); - shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); - shader->uniform3fv(LLViewerShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); - - shader->uniform3fv("normScale", 1, param_mgr->getNormalScale().mV); - shader->uniform1f("fresnelScale", param_mgr->getFresnelScale()); - shader->uniform1f("fresnelOffset", param_mgr->getFresnelOffset()); - shader->uniform1f("blurMultiplier", param_mgr->getBlurMultiplier()); + shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth); + shader->uniform1f(LLShaderMgr::WATER_TIME, sTime); + shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); + shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp); + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); + shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); + + shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV); + shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale()); + shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset()); + shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier()); F32 sunAngle = llmax(0.f, light_dir.mV[2]); F32 scaledAngle = 1.f - sunAngle; - shader->uniform1f("sunAngle", sunAngle); - shader->uniform1f("scaledAngle", scaledAngle); - shader->uniform1f("sunAngle2", 0.1f + 0.2f*sunAngle); + shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle); + shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle); + shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle); LLColor4 water_color; LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); @@ -641,12 +635,12 @@ void LLDrawPoolWater::shade() if (LLViewerCamera::getInstance()->cameraUnderWater()) { water_color.setVec(1.f, 1.f, 1.f, 0.4f); - shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); + shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); } else { water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); + shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); } if (water_color.mV[3] > 0.9f) @@ -690,11 +684,11 @@ void LLDrawPoolWater::shade() } shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); - shader->disableTexture(LLViewerShaderMgr::WATER_SCREENTEX); + shader->disableTexture(LLShaderMgr::WATER_SCREENTEX); shader->disableTexture(LLViewerShaderMgr::BUMP_MAP); shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - shader->disableTexture(LLViewerShaderMgr::WATER_REFTEX); - shader->disableTexture(LLViewerShaderMgr::WATER_SCREENDEPTH); + shader->disableTexture(LLShaderMgr::WATER_REFTEX); + shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH); if (deferred_render) { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 6b3127decf..ef91a459e7 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1407,6 +1407,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { //use transform feedback to pack vertex buffer //gGLDebugLoggingEnabled = TRUE; LLFastTimer t(FTM_FACE_GEOM_FEEDBACK); + LLGLEnable discard(GL_RASTERIZER_DISCARD); LLVertexBuffer* buff = (LLVertexBuffer*) vf.mVertexBuffer.get(); if (vf.mVertexBuffer.isNull() || buff->getNumVerts() != vf.mNumVertices) @@ -1955,21 +1956,31 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_pos) { - LLFastTimer t(FTM_FACE_GEOM_POSITION); + LLVector4a* src = vf.mPositions; + + //_mm_prefetch((char*)src, _MM_HINT_T0); + + LLVector4a* end = src+num_vertices; + //LLVector4a* end_64 = end-4; + + //LLFastTimer t(FTM_FACE_GEOM_POSITION); llassert(num_vertices > 0); mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount, map_range); - LLMatrix4a mat_vert; mat_vert.loadu(mat_vert_in); + + F32* dst = (F32*) vert.get(); + F32* end_f32 = dst+mGeomCount*4; - LLVector4a* src = vf.mPositions; - volatile F32* dst = (volatile F32*) vert.get(); - - volatile F32* end = dst+num_vertices*4; - LLVector4a res; + //_mm_prefetch((char*)dst, _MM_HINT_NTA); + //_mm_prefetch((char*)src, _MM_HINT_NTA); + + //_mm_prefetch((char*)dst, _MM_HINT_NTA); + LLVector4a res0; //,res1,res2,res3; + LLVector4a texIdx; S32 index = mTextureIndex < 255 ? mTextureIndex : 0; @@ -1986,29 +1997,53 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, texIdx.set(0,0,0,val); + LLVector4a tmp; + { - LLFastTimer t(FTM_FACE_POSITION_STORE); - LLVector4a tmp; + //LLFastTimer t2(FTM_FACE_POSITION_STORE); - do - { - mat_vert.affineTransform(*src++, res); - tmp.setSelectWithMask(mask, texIdx, res); + /*if (num_vertices > 4) + { //more than 64 bytes + while (src < end_64) + { + _mm_prefetch((char*)src + 64, _MM_HINT_T0); + _mm_prefetch((char*)dst + 64, _MM_HINT_T0); + + mat_vert.affineTransform(*src, res0); + tmp.setSelectWithMask(mask, texIdx, res0); + tmp.store4a((F32*) dst); + + mat_vert.affineTransform(*(src+1), res1); + tmp.setSelectWithMask(mask, texIdx, res1); + tmp.store4a((F32*) dst+4); + + mat_vert.affineTransform(*(src+2), res2); + tmp.setSelectWithMask(mask, texIdx, res2); + tmp.store4a((F32*) dst+8); + + mat_vert.affineTransform(*(src+3), res3); + tmp.setSelectWithMask(mask, texIdx, res3); + tmp.store4a((F32*) dst+12); + + dst += 16; + src += 4; + } + }*/ + + while (src < end) + { + mat_vert.affineTransform(*src++, res0); + tmp.setSelectWithMask(mask, texIdx, res0); tmp.store4a((F32*) dst); dst += 4; } - while(dst < end); } - + { - LLFastTimer t(FTM_FACE_POSITION_PAD); - S32 aligned_pad_vertices = mGeomCount - num_vertices; - res.set(res[0], res[1], res[2], 0.f); - - while (aligned_pad_vertices > 0) + //LLFastTimer t(FTM_FACE_POSITION_PAD); + while (dst < end_f32) { - --aligned_pad_vertices; - res.store4a((F32*) dst); + res0.store4a((F32*) dst); dst += 4; } } @@ -2022,15 +2057,17 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (rebuild_normal) { - LLFastTimer t(FTM_FACE_GEOM_NORMAL); + //LLFastTimer t(FTM_FACE_GEOM_NORMAL); mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, map_range); F32* normals = (F32*) norm.get(); - for (S32 i = 0; i < num_vertices; i++) - { + LLVector4a* src = vf.mNormals; + LLVector4a* end = src+num_vertices; + + while (src < end) + { LLVector4a normal; - mat_normal.rotate(vf.mNormals[i], normal); - normal.normalize3fast(); + mat_normal.rotate(*src++, normal); normal.store4a(normals); normals += 4; } @@ -2047,11 +2084,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, mVertexBuffer->getBinormalStrider(binorm, mGeomIndex, mGeomCount, map_range); F32* binormals = (F32*) binorm.get(); - for (S32 i = 0; i < num_vertices; i++) + LLVector4a* src = vf.mBinormals; + LLVector4a* end = vf.mBinormals+num_vertices; + + while (src < end) { LLVector4a binormal; - mat_normal.rotate(vf.mBinormals[i], binormal); - binormal.normalize3fast(); + mat_normal.rotate(*src++, binormal); binormal.store4a(binormals); binormals += 4; } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 4dfb93f1bc..e7a3f9b390 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -345,7 +345,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) return TRUE; } -static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true); +static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers"); static std::map sTimerColors; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index ffeea2f4df..9ffc64312d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -212,13 +212,13 @@ void display_stats() } static LLFastTimer::DeclareTimer FTM_PICK("Picking"); -static LLFastTimer::DeclareTimer FTM_RENDER("Render", true); +static LLFastTimer::DeclareTimer FTM_RENDER("Render"); static LLFastTimer::DeclareTimer FTM_UPDATE_SKY("Update Sky"); static LLFastTimer::DeclareTimer FTM_UPDATE_TEXTURES("Update Textures"); static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE("Update Images"); static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_CLASS("Class"); static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_BUMP("Image Update Bump"); -static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_LIST("List"); +static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_LIST("List", true); static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_DELETE("Delete"); static LLFastTimer::DeclareTimer FTM_RESIZE_WINDOW("Resize Window"); static LLFastTimer::DeclareTimer FTM_HUD_UPDATE("HUD Update"); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ba9818946c..c7677759af 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -304,47 +304,6 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void) if (mReservedAttribs.empty()) { LLShaderMgr::initAttribsAndUniforms(); - - mAvatarUniforms.push_back("matrixPalette"); - mAvatarUniforms.push_back("gWindDir"); - mAvatarUniforms.push_back("gSinWaveParams"); - mAvatarUniforms.push_back("gGravity"); - - mWLUniforms.push_back("camPosLocal"); - - mTerrainUniforms.reserve(5); - mTerrainUniforms.push_back("detail_0"); - mTerrainUniforms.push_back("detail_1"); - mTerrainUniforms.push_back("detail_2"); - mTerrainUniforms.push_back("detail_3"); - mTerrainUniforms.push_back("alpha_ramp"); - - mGlowUniforms.push_back("glowDelta"); - mGlowUniforms.push_back("glowStrength"); - - mGlowExtractUniforms.push_back("minLuminance"); - mGlowExtractUniforms.push_back("maxExtractAlpha"); - mGlowExtractUniforms.push_back("lumWeights"); - mGlowExtractUniforms.push_back("warmthWeights"); - mGlowExtractUniforms.push_back("warmthAmount"); - - mShinyUniforms.push_back("origin"); - - mWaterUniforms.reserve(12); - mWaterUniforms.push_back("screenTex"); - mWaterUniforms.push_back("screenDepth"); - mWaterUniforms.push_back("refTex"); - mWaterUniforms.push_back("eyeVec"); - mWaterUniforms.push_back("time"); - mWaterUniforms.push_back("d1"); - mWaterUniforms.push_back("d2"); - mWaterUniforms.push_back("lightDir"); - mWaterUniforms.push_back("specular"); - mWaterUniforms.push_back("lightExp"); - mWaterUniforms.push_back("fogCol"); - mWaterUniforms.push_back("kd"); - mWaterUniforms.push_back("refScale"); - mWaterUniforms.push_back("waterHeight"); } } @@ -915,7 +874,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gTerrainProgram.mShaderFiles.push_back(make_pair("environment/terrainV.glsl", GL_VERTEX_SHADER_ARB)); gTerrainProgram.mShaderFiles.push_back(make_pair("environment/terrainF.glsl", GL_FRAGMENT_SHADER_ARB)); gTerrainProgram.mShaderLevel = mVertexShaderLevel[SHADER_ENVIRONMENT]; - success = gTerrainProgram.createShader(NULL, &mTerrainUniforms); + success = gTerrainProgram.createShader(NULL, NULL); } if (!success) @@ -953,7 +912,7 @@ BOOL LLViewerShaderMgr::loadShadersWater() gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER_ARB)); gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER_ARB)); gWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER]; - success = gWaterProgram.createShader(NULL, &mWaterUniforms); + success = gWaterProgram.createShader(NULL, NULL); } if (success) @@ -967,7 +926,7 @@ BOOL LLViewerShaderMgr::loadShadersWater() gUnderWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER]; gUnderWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - success = gUnderWaterProgram.createShader(NULL, &mWaterUniforms); + success = gUnderWaterProgram.createShader(NULL, NULL); } if (success) @@ -985,7 +944,7 @@ BOOL LLViewerShaderMgr::loadShadersWater() gTerrainWaterProgram.mShaderFiles.push_back(make_pair("environment/terrainWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); gTerrainWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_ENVIRONMENT]; gTerrainWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - terrainWaterSuccess = gTerrainWaterProgram.createShader(NULL, &mTerrainUniforms); + terrainWaterSuccess = gTerrainWaterProgram.createShader(NULL, NULL); } /// Keep track of water shader levels @@ -1034,7 +993,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowV.glsl", GL_VERTEX_SHADER_ARB)); gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowF.glsl", GL_FRAGMENT_SHADER_ARB)); gGlowProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; - success = gGlowProgram.createShader(NULL, &mGlowUniforms); + success = gGlowProgram.createShader(NULL, NULL); if (!success) { LLPipeline::sRenderGlow = FALSE; @@ -1048,7 +1007,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractV.glsl", GL_VERTEX_SHADER_ARB)); gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractF.glsl", GL_FRAGMENT_SHADER_ARB)); gGlowExtractProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; - success = gGlowExtractProgram.createShader(NULL, &mGlowExtractUniforms); + success = gGlowExtractProgram.createShader(NULL, NULL); if (!success) { LLPipeline::sRenderGlow = FALSE; @@ -1408,7 +1367,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredWaterProgram.createShader(NULL, &mWaterUniforms); + success = gDeferredWaterProgram.createShader(NULL, NULL); } if (success) @@ -1467,7 +1426,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAvatarShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredAvatarShadowProgram.createShader(NULL, &mAvatarUniforms); + success = gDeferredAvatarShadowProgram.createShader(NULL, NULL); } if (success) @@ -1488,7 +1447,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredTerrainProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredTerrainProgram.createShader(NULL, &mTerrainUniforms); + success = gDeferredTerrainProgram.createShader(NULL, NULL); } if (success) @@ -1499,7 +1458,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAvatarProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredAvatarProgram.createShader(NULL, &mAvatarUniforms); + success = gDeferredAvatarProgram.createShader(NULL, NULL); } if (success) @@ -1519,7 +1478,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedNoColorF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredAvatarAlphaProgram.createShader(NULL, &mAvatarUniforms); + success = gDeferredAvatarAlphaProgram.createShader(NULL, NULL); gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = true; gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true; @@ -1584,7 +1543,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; - success = gDeferredWLSkyProgram.createShader(NULL, &mWLUniforms); + success = gDeferredWLSkyProgram.createShader(NULL, NULL); } if (success) @@ -1595,7 +1554,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - success = gDeferredWLCloudProgram.createShader(NULL, &mWLUniforms); + success = gDeferredWLCloudProgram.createShader(NULL, NULL); } if (success) @@ -1606,7 +1565,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredStarProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY; - success = gDeferredStarProgram.createShader(NULL, &mWLUniforms); + success = gDeferredStarProgram.createShader(NULL, NULL); } if (success) @@ -1957,7 +1916,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectShinyNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gObjectShinyNonIndexedProgram.createShader(NULL, &mShinyUniforms); + success = gObjectShinyNonIndexedProgram.createShader(NULL, NULL); } if (success) @@ -1974,7 +1933,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectShinyNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; gObjectShinyNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - success = gObjectShinyNonIndexedWaterProgram.createShader(NULL, &mShinyUniforms); + success = gObjectShinyNonIndexedWaterProgram.createShader(NULL, NULL); } if (success) @@ -1990,7 +1949,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectFullbrightShinyNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gObjectFullbrightShinyNonIndexedProgram.createShader(NULL, &mShinyUniforms); + success = gObjectFullbrightShinyNonIndexedProgram.createShader(NULL, NULL); } if (success) @@ -2008,7 +1967,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectFullbrightShinyNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; gObjectFullbrightShinyNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - success = gObjectFullbrightShinyNonIndexedWaterProgram.createShader(NULL, &mShinyUniforms); + success = gObjectFullbrightShinyNonIndexedWaterProgram.createShader(NULL, NULL); } if (success) @@ -2087,7 +2046,6 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; success = gObjectBumpProgram.createShader(NULL, NULL); - if (success) { //lldrawpoolbump assumes "texture0" has channel 0 and "texture1" has channel 1 gObjectBumpProgram.bind(); @@ -2241,7 +2199,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectShinyProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gObjectShinyProgram.createShader(NULL, &mShinyUniforms); + success = gObjectShinyProgram.createShader(NULL, NULL); } if (success) @@ -2258,7 +2216,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; gObjectShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - success = gObjectShinyWaterProgram.createShader(NULL, &mShinyUniforms); + success = gObjectShinyWaterProgram.createShader(NULL, NULL); } if (success) @@ -2274,7 +2232,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gObjectFullbrightShinyProgram.createShader(NULL, &mShinyUniforms); + success = gObjectFullbrightShinyProgram.createShader(NULL, NULL); } if (success) @@ -2292,7 +2250,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; gObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - success = gObjectFullbrightShinyWaterProgram.createShader(NULL, &mShinyUniforms); + success = gObjectFullbrightShinyWaterProgram.createShader(NULL, NULL); } if (mVertexShaderLevel[SHADER_AVATAR] > 0) @@ -2377,7 +2335,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); gSkinnedObjectFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gSkinnedObjectFullbrightShinyProgram.createShader(NULL, &mShinyUniforms); + success = gSkinnedObjectFullbrightShinyProgram.createShader(NULL, NULL); } if (success) @@ -2394,7 +2352,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); gSkinnedObjectShinySimpleProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gSkinnedObjectShinySimpleProgram.createShader(NULL, &mShinyUniforms); + success = gSkinnedObjectShinySimpleProgram.createShader(NULL, NULL); } if (success) @@ -2451,7 +2409,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); gSkinnedObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gSkinnedObjectFullbrightShinyWaterProgram.createShader(NULL, &mShinyUniforms); + success = gSkinnedObjectFullbrightShinyWaterProgram.createShader(NULL, NULL); } if (success) @@ -2470,7 +2428,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); gSkinnedObjectShinySimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gSkinnedObjectShinySimpleWaterProgram.createShader(NULL, &mShinyUniforms); + success = gSkinnedObjectShinySimpleWaterProgram.createShader(NULL, NULL); } } @@ -2511,7 +2469,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarProgram.mShaderFiles.push_back(make_pair("avatar/avatarV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarProgram.mShaderFiles.push_back(make_pair("avatar/avatarF.glsl", GL_FRAGMENT_SHADER_ARB)); gAvatarProgram.mShaderLevel = mVertexShaderLevel[SHADER_AVATAR]; - success = gAvatarProgram.createShader(NULL, &mAvatarUniforms); + success = gAvatarProgram.createShader(NULL, NULL); if (success) { @@ -2530,7 +2488,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() // Note: no cloth under water: gAvatarWaterProgram.mShaderLevel = llmin(mVertexShaderLevel[SHADER_AVATAR], 1); gAvatarWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - success = gAvatarWaterProgram.createShader(NULL, &mAvatarUniforms); + success = gAvatarWaterProgram.createShader(NULL, NULL); } /// Keep track of avatar levels @@ -2549,7 +2507,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarPickProgram.mShaderFiles.push_back(make_pair("avatar/pickAvatarV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarPickProgram.mShaderFiles.push_back(make_pair("avatar/pickAvatarF.glsl", GL_FRAGMENT_SHADER_ARB)); gAvatarPickProgram.mShaderLevel = mVertexShaderLevel[SHADER_AVATAR]; - success = gAvatarPickProgram.createShader(NULL, &mAvatarUniforms); + success = gAvatarPickProgram.createShader(NULL, NULL); } if (success) @@ -2817,7 +2775,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; gWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; - success = gWLSkyProgram.createShader(NULL, &mWLUniforms); + success = gWLSkyProgram.createShader(NULL, NULL); } if (success) @@ -2829,7 +2787,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - success = gWLCloudProgram.createShader(NULL, &mWLUniforms); + success = gWLCloudProgram.createShader(NULL, NULL); } return success; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index d6dd645e8c..b8552d2d95 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -74,56 +74,7 @@ public: SHADER_COUNT }; - typedef enum - { - SHINY_ORIGIN = END_RESERVED_UNIFORMS - } eShinyUniforms; - - typedef enum - { - WATER_SCREENTEX = END_RESERVED_UNIFORMS, - WATER_SCREENDEPTH, - WATER_REFTEX, - WATER_EYEVEC, - WATER_TIME, - WATER_WAVE_DIR1, - WATER_WAVE_DIR2, - WATER_LIGHT_DIR, - WATER_SPECULAR, - WATER_SPECULAR_EXP, - WATER_FOGCOLOR, - WATER_FOGDENSITY, - WATER_REFSCALE, - WATER_WATERHEIGHT, - } eWaterUniforms; - - typedef enum - { - WL_CAMPOSLOCAL = END_RESERVED_UNIFORMS, - WL_WATERHEIGHT - } eWLUniforms; - - typedef enum - { - TERRAIN_DETAIL0 = END_RESERVED_UNIFORMS, - TERRAIN_DETAIL1, - TERRAIN_DETAIL2, - TERRAIN_DETAIL3, - TERRAIN_ALPHARAMP - } eTerrainUniforms; - - typedef enum - { - GLOW_DELTA = END_RESERVED_UNIFORMS - } eGlowUniforms; - - typedef enum - { - AVATAR_MATRIX = END_RESERVED_UNIFORMS, - AVATAR_WIND, - AVATAR_SINWAVE, - AVATAR_GRAVITY, - } eAvatarUniforms; + // simple model of forward iterator // http://www.sgi.com/tech/stl/ForwardIterator.html @@ -176,24 +127,6 @@ public: /* virtual */ void updateShaderUniforms(LLGLSLShader * shader); private: - - std::vector mShinyUniforms; - - //water parameters - std::vector mWaterUniforms; - - std::vector mWLUniforms; - - //terrain parameters - std::vector mTerrainUniforms; - - //glow parameters - std::vector mGlowUniforms; - - std::vector mGlowExtractUniforms; - - std::vector mAvatarUniforms; - // the list of shaders we need to propagate parameters to. std::vector mShaderList; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 6a18534484..b0f23fca42 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4654,7 +4654,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bump_mask |= LLVertexBuffer::MAP_BINORMAL; genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, TRUE); genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, FALSE, TRUE); - genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, TRUE); + genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, FALSE); genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, TRUE, TRUE); } else diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 4f52ff9778..548890b5b5 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -188,13 +188,11 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::getInstance()->getRotatedLightDir().mV); - shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform4fv("waterFogColor", 1, LLDrawPoolWater::sWaterFogColor.mV); - shader->uniform1f("waterFogEnd", LLDrawPoolWater::sWaterFogEnd); - shader->uniform4fv("waterPlane", 1, mWaterPlane.mV); - shader->uniform1f("waterFogDensity", getFogDensity()); - shader->uniform1f("waterFogKS", mWaterFogKS); - shader->uniform1f("distance_multiplier", 0); + shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV); + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV); + shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, getFogDensity()); + shader->uniform1f(LLShaderMgr::WATER_FOGKS, mWaterFogKS); + shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); } } diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 6077208799..04d41a2512 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -352,7 +352,7 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) { shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV); - shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); } else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) @@ -360,7 +360,7 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDir.mV); } - shader->uniform1f("scene_light_strength", mSceneLightStrength); + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 45d6d23b51..d9771af254 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7857,13 +7857,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mShadow[4].getWidth(), mShadow[4].getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); - - - if (shader.getUniformLocation("norm_mat") >= 0) - { - glh::matrix4f norm_mat = glh_get_current_modelview().inverse().transpose(); - shader.uniformMatrix4fv("norm_mat", 1, FALSE, norm_mat.m); - } } static LLFastTimer::DeclareTimer FTM_GI_TRACE("Trace"); @@ -7973,8 +7966,7 @@ void LLPipeline::renderDeferredLighting() } gDeferredSunProgram.uniform3fv("offset", slice, offset); - gDeferredSunProgram.uniform2f("screenRes", mDeferredLight.getWidth(), mDeferredLight.getHeight()); - + { LLGLDisable blend(GL_BLEND); LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); -- cgit v1.2.3 From b19eeabd54afcfb56e864899c166b64db1ac6790 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 4 Mar 2013 16:05:12 -0800 Subject: Include signal.h instead of replicating typedef to avoid errors from redefining it...provides better compat with non-Ubuntu distros --- indra/llcommon/llapp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index a536a06ea5..afa06df23e 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -38,7 +38,7 @@ typedef LLAtomic32 LLAtomicU32; class LLErrorThread; class LLLiveFile; #if LL_LINUX -typedef struct siginfo siginfo_t; +#include #endif typedef void (*LLAppErrorHandler)(); -- cgit v1.2.3 From a65c275865f1cc9bf53237e4b8c99a7bee3731ee Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 5 Mar 2013 01:38:49 -0600 Subject: Merge cleanup. --- indra/newview/llviewershadermgr.h | 1 - 1 file changed, 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index dd1325277c..6cd52dc736 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -128,7 +128,6 @@ public: private: - UniformVec mShinyUniforms; // the list of shaders we need to propagate parameters to. std::vector mShaderList; -- cgit v1.2.3 From eda81f68ca1b337164a94e89f42e53fe76c0e381 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 6 Mar 2013 09:07:33 -0800 Subject: For MAINT-1842 fix model validation to check for NaNs --- indra/newview/llfloatermodelpreview.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index ea839e6f5a..8ea0b43b36 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -305,8 +305,34 @@ bool validate_face(const LLVolumeFace& face) return false; } + for (U32 i = 0; i < face.mNumIndices; i+=3) + { + U16 idx1 = face.mIndices[i]; + U16 idx2 = face.mIndices[i+1]; + U16 idx3 = face.mIndices[i+2]; + + if (face.mPositions + && (!face.mPositions[idx1].isFinite3() + || !face.mPositions[idx2].isFinite3() + || !face.mPositions[idx3].isFinite3())) + { + llwarns << "NaN position data in face found!" << llendl; + return false; + } + + if (face.mNormals + && (!face.mNormals[idx1].isFinite3() + || !face.mNormals[idx2].isFinite3() + || !face.mNormals[idx3].isFinite3())) + { + llwarns << "NaN normal data in face found!" << llendl; + return false; + } + } + /*const LLVector4a scale(0.5f); + for (U32 i = 0; i < face.mNumIndices; i+=3) { U16 idx1 = face.mIndices[i]; @@ -323,7 +349,6 @@ bool validate_face(const LLVolumeFace& face) return false; } }*/ - return true; } -- cgit v1.2.3 From 1816582b929737f92ee68a1422e3be4e7c02f542 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 6 Mar 2013 09:09:07 -0800 Subject: Fix crashes from using single alloc for pos/norm/tc in volume face data fighting with old free call in model loading code --- indra/llmath/llvolume.cpp | 11 ++++++----- indra/llprimitive/llmodel.cpp | 31 ++++++++++++++++++------------- 2 files changed, 24 insertions(+), 18 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index f989e8ed17..f503eea107 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -5307,7 +5307,7 @@ LLVolumeFace::~LLVolumeFace() void LLVolumeFace::freeData() { - ll_aligned_free_16(mPositions); + ll_aligned_free(mPositions); mPositions = NULL; //normals and texture coordinates are part of the same buffer as mPositions, do not free them separately @@ -5492,10 +5492,11 @@ void LLVolumeFace::optimize(F32 angle_cutoff) } } - llassert(new_face.mNumIndices == mNumIndices); - llassert(new_face.mNumVertices <= mNumVertices); - - swapData(new_face); + if (new_face.mNumVertices) + { + llassert(new_face.mNumIndices == mNumIndices); + swapData(new_face); + } } class LLVCacheTriangleData; diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 5ed05e2201..8f0120b064 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -194,6 +194,9 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa cv.setPosition(LLVector4a(v[idx[i+pos_offset]*3+0], v[idx[i+pos_offset]*3+1], v[idx[i+pos_offset]*3+2])); + + if (!cv.getPosition().isFinite3()) + return LLModel::BAD_ELEMENT; } if (tc_source) @@ -207,6 +210,8 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa cv.setNormal(LLVector4a(n[idx[i+norm_offset]*3+0], n[idx[i+norm_offset]*3+1], n[idx[i+norm_offset]*3+2])); + if (!cv.getNormal().isFinite3()) + return LLModel::BAD_ELEMENT; } BOOL found = FALSE; @@ -261,13 +266,13 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa LLVolumeFace& new_face = *face_list.rbegin(); if (!norm_source) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!tc_source) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } @@ -292,13 +297,13 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa LLVolumeFace& new_face = *face_list.rbegin(); if (!norm_source) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!tc_source) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } } @@ -480,13 +485,13 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac LLVolumeFace& new_face = *face_list.rbegin(); if (!norm_source) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!tc_source) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } @@ -514,13 +519,13 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac LLVolumeFace& new_face = *face_list.rbegin(); if (!norm_source) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!tc_source) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } } @@ -730,13 +735,13 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac LLVolumeFace& new_face = *face_list.rbegin(); if (!n) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!t) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } } @@ -1036,7 +1041,7 @@ void LLModel::setVolumeFaceData( } else { - ll_aligned_free_16(face.mNormals); + //ll_aligned_free_16(face.mNormals); face.mNormals = NULL; } @@ -1047,7 +1052,7 @@ void LLModel::setVolumeFaceData( } else { - ll_aligned_free_16(face.mTexCoords); + //ll_aligned_free_16(face.mTexCoords); face.mTexCoords = NULL; } @@ -1246,7 +1251,7 @@ void LLModel::generateNormals(F32 angle_cutoff) } else { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } -- cgit v1.2.3 From 1b3dec4c11e76f5c5ab6ab8bd2464d07177009c4 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 7 Mar 2013 09:00:26 -0800 Subject: Put newline at end of file to appease gcc's OCD --- indra/llcommon/llinstancetracker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 0804be358f..65ef4322f6 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -42,4 +42,5 @@ void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t) // key DOES exist, insert() simply returns (iterator, false). One lookup // handles both cases. return sInstanceTrackerData[t]; -} \ No newline at end of file +} + -- cgit v1.2.3 From de4414260d1a898299a8081d85c4a12363eed17f Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 7 Mar 2013 14:11:35 -0800 Subject: Fix missing eol at eof --- indra/llcommon/llstaticstringtable.h | 163 ++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 81 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llstaticstringtable.h b/indra/llcommon/llstaticstringtable.h index 05b0848e30..d7e0e8a08d 100644 --- a/indra/llcommon/llstaticstringtable.h +++ b/indra/llcommon/llstaticstringtable.h @@ -1,81 +1,82 @@ -/** - * @file llstringtable.h - * @brief The LLStringTable class provides a _fast_ method for finding - * unique copies of strings. - * - * $LicenseInfo:firstyear=2001&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$ - */ - -#ifndef LL_STATIC_STRING_TABLE_H -#define LL_STATIC_STRING_TABLE_H - -#include "lldefs.h" -#include -#include "llstl.h" - -class LLStaticHashedString -{ -public: - - LLStaticHashedString(const std::string& s) - { - string_hash = makehash(s); - string = s; - } - - const std::string& String() const { return string; } - size_t Hash() const { return string_hash; } - - bool operator==(const LLStaticHashedString& b) const { return Hash() == b.Hash(); } - -protected: - - size_t makehash(const std::string& s) - { - size_t len = s.size(); - const char* c = s.c_str(); - size_t hashval = 0; - for (size_t i=0; i -class LL_COMMON_API LLStaticStringTable - : public boost::unordered_map< LLStaticHashedString, MappedObject, LLStaticStringHasher > -{ -}; - -#endif \ No newline at end of file +/** + * @file llstringtable.h + * @brief The LLStringTable class provides a _fast_ method for finding + * unique copies of strings. + * + * $LicenseInfo:firstyear=2001&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$ + */ + +#ifndef LL_STATIC_STRING_TABLE_H +#define LL_STATIC_STRING_TABLE_H + +#include "lldefs.h" +#include +#include "llstl.h" + +class LLStaticHashedString +{ +public: + + LLStaticHashedString(const std::string& s) + { + string_hash = makehash(s); + string = s; + } + + const std::string& String() const { return string; } + size_t Hash() const { return string_hash; } + + bool operator==(const LLStaticHashedString& b) const { return Hash() == b.Hash(); } + +protected: + + size_t makehash(const std::string& s) + { + size_t len = s.size(); + const char* c = s.c_str(); + size_t hashval = 0; + for (size_t i=0; i +class LL_COMMON_API LLStaticStringTable + : public boost::unordered_map< LLStaticHashedString, MappedObject, LLStaticStringHasher > +{ +}; + +#endif + -- cgit v1.2.3 From 2e8b2558b4b86b97dafec539792d14b66b2724d1 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 7 Mar 2013 14:13:14 -0800 Subject: For MAINT-2436 and MAINT-2388 contribs from STORM-1935 and STORM-1936 --- indra/llprimitive/llmodel.cpp | 114 +++++++++++++++++++++++++++++++- indra/newview/llfloatermodelpreview.cpp | 42 +++++------- 2 files changed, 131 insertions(+), 25 deletions(-) (limited to 'indra') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 8f0120b064..4ef4744981 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -186,32 +186,78 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa LLVolumeFace::VertexMapData::PointMap point_map; - for (U32 i = 0; i < idx.getCount(); i += idx_stride) + U32 index_count = idx.getCount(); + U32 vertex_count = pos_source ? v.getCount() : 0; + U32 tc_count = tc_source ? tc.getCount() : 0; + U32 norm_count = norm_source ? n.getCount() : 0; + + for (U32 i = 0; i < index_count; i += idx_stride) { LLVolumeFace::VertexData cv; if (pos_source) { + // guard against model data specifiying out of range indices or verts + // + if (((i + pos_offset) > index_count) + || ((idx[i+pos_offset]*3+2) > vertex_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.setPosition(LLVector4a(v[idx[i+pos_offset]*3+0], v[idx[i+pos_offset]*3+1], v[idx[i+pos_offset]*3+2])); if (!cv.getPosition().isFinite3()) + { return LLModel::BAD_ELEMENT; + } } if (tc_source) { + // guard against model data specifiying out of range indices or tcs + // + if (((i + tc_offset) > index_count) + || ((idx[i+pos_offset]*2+1) > tc_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.mTexCoord.setVec(tc[idx[i+tc_offset]*2+0], tc[idx[i+tc_offset]*2+1]); + + if (!cv.mTexCoord.isFinite()) + { + llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } if (norm_source) { + // guard against model data specifiying out of range indices or norms + // + if (((i + pos_offset) > index_count) + || ((idx[i+pos_offset]*3+2) > vertex_count)) + { + return LLModel::BAD_ELEMENT; + } + if (((i + norm_offset) > index_count) + || ((idx[i+norm_offset]*3+2) > norm_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.setNormal(LLVector4a(n[idx[i+norm_offset]*3+0], n[idx[i+norm_offset]*3+1], n[idx[i+norm_offset]*3+2])); + if (!cv.getNormal().isFinite3()) + { + llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl; return LLModel::BAD_ELEMENT; + } } BOOL found = FALSE; @@ -369,6 +415,11 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac LLVolumeFace::VertexMapData::PointMap point_map; + U32 index_count = idx.getCount(); + U32 vertex_count = pos_source ? v.getCount() : 0; + U32 tc_count = tc_source ? tc.getCount() : 0; + U32 norm_count = norm_source ? n.getCount() : 0; + U32 cur_idx = 0; for (U32 i = 0; i < vcount.getCount(); ++i) { //for each polygon @@ -381,22 +432,65 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac if (pos_source) { + // guard against model data specifiying out of range indices or verts + // + if (((i + pos_offset) > index_count) + || ((idx[i+pos_offset]*3+2) > vertex_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.getPosition().set(v[idx[cur_idx+pos_offset]*3+0], v[idx[cur_idx+pos_offset]*3+1], v[idx[cur_idx+pos_offset]*3+2]); + + if (!cv.getPosition().isFinite3()) + { + llwarns << "Found NaN while loading positions from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } + } if (tc_source) { + // guard against model data specifiying out of range indices or tcs + // + if (((i + pos_offset) > index_count) + || ((idx[cur_idx+tc_offset]*2+1) > tc_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.mTexCoord.setVec(tc[idx[cur_idx+tc_offset]*2+0], tc[idx[cur_idx+tc_offset]*2+1]); + + if (!cv.mTexCoord.isFinite()) + { + llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } if (norm_source) { + // guard against model data specifiying out of range indices or norms + // + if (((i + pos_offset) > index_count) + || ((idx[cur_idx+norm_offset]*3+2) > norm_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.getNormal().set(n[idx[cur_idx+norm_offset]*3+0], n[idx[cur_idx+norm_offset]*3+1], n[idx[cur_idx+norm_offset]*3+2]); + + if (!cv.getNormal().isFinite3()) + { + llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } cur_idx += idx_stride; @@ -637,6 +731,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac vert.getPosition().set(v->get(v_idx), v->get(v_idx+1), v->get(v_idx+2)); + + if (!vert.getPosition().isFinite3()) + { + llwarns << "Found NaN while loading position data from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } //bounds check n and t lookups because some FBX to DAE converters @@ -649,6 +749,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac vert.getNormal().set(n->get(n_idx), n->get(n_idx+1), n->get(n_idx+2)); + + if (!vert.getNormal().isFinite3()) + { + llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } else { @@ -662,6 +768,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac t_idx = llclamp(t_idx, (U32) 0, (U32) t->getCount()); vert.mTexCoord.setVec(t->get(t_idx), t->get(t_idx+1)); + + if (!vert.mTexCoord.isFinite()) + { + llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } else { diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 8ea0b43b36..07c36b9f1b 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -290,6 +290,22 @@ bool ll_is_degenerate(const LLVector4a& a, const LLVector4a& b, const LLVector4a bool validate_face(const LLVolumeFace& face) { + + for (U32 v = 0; v < face.mNumVertices; v++) + { + if(face.mPositions && !face.mPositions[v].isFinite3()) + { + llwarns << "NaN position data in face found!" << llendl; + return false; + } + + if(face.mNormals && !face.mNormals[v].isFinite3()) + { + llwarns << "NaN normal data in face found!" << llendl; + return false; + } + } + for (U32 i = 0; i < face.mNumIndices; ++i) { if (face.mIndices[i] >= face.mNumVertices) @@ -305,30 +321,6 @@ bool validate_face(const LLVolumeFace& face) return false; } - for (U32 i = 0; i < face.mNumIndices; i+=3) - { - U16 idx1 = face.mIndices[i]; - U16 idx2 = face.mIndices[i+1]; - U16 idx3 = face.mIndices[i+2]; - - if (face.mPositions - && (!face.mPositions[idx1].isFinite3() - || !face.mPositions[idx2].isFinite3() - || !face.mPositions[idx3].isFinite3())) - { - llwarns << "NaN position data in face found!" << llendl; - return false; - } - - if (face.mNormals - && (!face.mNormals[idx1].isFinite3() - || !face.mNormals[idx2].isFinite3() - || !face.mNormals[idx3].isFinite3())) - { - llwarns << "NaN normal data in face found!" << llendl; - return false; - } - } /*const LLVector4a scale(0.5f); @@ -5959,3 +5951,5 @@ void LLFloaterModelPreview::setPermissonsErrorStatus(U32 status, const std::stri LLNotificationsUtil::add("MeshUploadPermError"); } + + -- cgit v1.2.3 From 4b67d34c7e31e7dcc8185061e4a0b02c5da6560a Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 7 Mar 2013 15:45:29 -0800 Subject: Remove redundant data validation copy-pasted into normals loop --- indra/llprimitive/llmodel.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 4ef4744981..ef6eb75a6b 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -238,11 +238,6 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa { // guard against model data specifiying out of range indices or norms // - if (((i + pos_offset) > index_count) - || ((idx[i+pos_offset]*3+2) > vertex_count)) - { - return LLModel::BAD_ELEMENT; - } if (((i + norm_offset) > index_count) || ((idx[i+norm_offset]*3+2) > norm_count)) { -- cgit v1.2.3 From f8e059deee28500b88c8c172eaa8c4d7ca657748 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 8 Mar 2013 17:11:30 -0600 Subject: MAINT-2371 Lat round of optimizations. Reviewed by Graham --- indra/llmath/llmatrix4a.h | 11 +- indra/llmath/llvector4a.inl | 13 +- indra/llmath/llvolume.cpp | 1791 +++++++++++++----------------------- indra/llmath/llvolume.h | 79 +- indra/newview/llflexibleobject.cpp | 18 +- indra/newview/llspatialpartition.h | 2 +- indra/newview/llvovolume.cpp | 157 ++-- 7 files changed, 824 insertions(+), 1247 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h index c4cefdb4fa..d141298f69 100644 --- a/indra/llmath/llmatrix4a.h +++ b/indra/llmath/llmatrix4a.h @@ -107,15 +107,14 @@ public: inline void rotate(const LLVector4a& v, LLVector4a& res) { + LLVector4a y,z; + res = _mm_shuffle_ps(v, v, _MM_SHUFFLE(0, 0, 0, 0)); - res.mul(mMatrix[0]); - - LLVector4a y; y = _mm_shuffle_ps(v, v, _MM_SHUFFLE(1, 1, 1, 1)); - y.mul(mMatrix[1]); - - LLVector4a z; z = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 2, 2, 2)); + + res.mul(mMatrix[0]); + y.mul(mMatrix[1]); z.mul(mMatrix[2]); res.add(y); diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 7c52ffef21..35a67204ec 100644 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -460,16 +460,13 @@ inline void LLVector4a::setMax(const LLVector4a& lhs, const LLVector4a& rhs) mQ = _mm_max_ps(lhs.mQ, rhs.mQ); } -// Set this to (c * lhs) + rhs * ( 1 - c) +// Set this to lhs + (rhs-lhs)*c inline void LLVector4a::setLerp(const LLVector4a& lhs, const LLVector4a& rhs, F32 c) { - LLVector4a a = lhs; - a.mul(c); - - LLVector4a b = rhs; - b.mul(1.f-c); - - setAdd(a, b); + LLVector4a t; + t.setSub(rhs,lhs); + t.mul(c); + setAdd(lhs, t); } inline LLBool32 LLVector4a::isFinite3() const diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index f989e8ed17..9fc72fd801 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -94,6 +94,95 @@ const S32 SCULPT_MIN_AREA_DETAIL = 1; extern BOOL gDebugGL; +bool less_than_max_mag(const LLVector4a& vec); + +template +LLAlignedArray::LLAlignedArray() +{ + mArray = NULL; + mElementCount = 0; + mCapacity = 0; +} + +template +LLAlignedArray::~LLAlignedArray() +{ + ll_aligned_free(mArray); + mArray = NULL; + mElementCount = 0; + mCapacity = 0; +} + +template +void LLAlignedArray::push_back(const T& elem) +{ + T* old_buf = NULL; + if (mCapacity <= mElementCount) + { + mCapacity++; + mCapacity *= 2; + T* new_buf = (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment); + if (mArray) + { + LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); + } + old_buf = mArray; + mArray = new_buf; + } + + mArray[mElementCount++] = elem; + + //delete old array here to prevent error on a.push_back(a[0]) + ll_aligned_free(old_buf); +} + +template +void LLAlignedArray::resize(U32 size) +{ + if (mCapacity < size) + { + mCapacity = size+mCapacity*2; + T* new_buf = mCapacity > 0 ? (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment) : NULL; + if (mArray) + { + LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); + ll_aligned_free(mArray); + } + + /*for (U32 i = mElementCount; i < mCapacity; ++i) + { + new(new_buf+i) T(); + }*/ + mArray = new_buf; + } + + mElementCount = size; +} + + +template +T& LLAlignedArray::operator[](int idx) +{ + llassert(idx < mElementCount); + return mArray[idx]; +} + +template +const T& LLAlignedArray::operator[](int idx) const +{ + llassert(idx < mElementCount); + return mArray[idx]; +} + +template +T* LLAlignedArray::append(S32 N) +{ + U32 sz = size(); + resize(sz+N); + return &((*this)[sz]); +} + + BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm) { LLVector3 test = (pt2-pt1)%(pt3-pt2); @@ -474,7 +563,7 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 const F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f }; F32 scale = 0.5f; F32 t, t_step, t_first, t_fraction, ang, ang_step; - LLVector3 pt1,pt2; + LLVector4a pt1,pt2; F32 begin = params.getBegin(); F32 end = params.getEnd(); @@ -497,20 +586,21 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 // Starting t and ang values for the first face t = t_first; ang = 2.0f*F_PI*(t*ang_scale + offset); - pt1.setVec(cos(ang)*scale,sin(ang)*scale, t); + pt1.set(cos(ang)*scale,sin(ang)*scale, t); // Increment to the next point. // pt2 is the end point on the fractional face t += t_step; ang += ang_step; - pt2.setVec(cos(ang)*scale,sin(ang)*scale,t); + pt2.set(cos(ang)*scale,sin(ang)*scale,t); t_fraction = (begin - t_first)*sides; // Only use if it's not almost exactly on an edge. if (t_fraction < 0.9999f) { - LLVector3 new_pt = lerp(pt1, pt2, t_fraction); + LLVector4a new_pt; + new_pt.setLerp(pt1, pt2, t_fraction); mProfile.push_back(new_pt); } @@ -518,12 +608,17 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 while (t < end) { // Iterate through all the integer steps of t. - pt1.setVec(cos(ang)*scale,sin(ang)*scale,t); + pt1.set(cos(ang)*scale,sin(ang)*scale,t); if (mProfile.size() > 0) { - LLVector3 p = mProfile[mProfile.size()-1]; + LLVector4a p = mProfile[mProfile.size()-1]; for (S32 i = 0; i < split && mProfile.size() > 0; i++) { - mProfile.push_back(p+(pt1-p) * 1.0f/(float)(split+1) * (float)(i+1)); + //mProfile.push_back(p+(pt1-p) * 1.0f/(float)(split+1) * (float)(i+1)); + LLVector4a new_pt; + new_pt.setSub(pt1, p); + new_pt.mul(1.0f/(float)(split+1) * (float)(i+1)); + new_pt.add(p); + mProfile.push_back(new_pt); } } mProfile.push_back(pt1); @@ -536,18 +631,25 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 // pt1 is the first point on the fractional face // pt2 is the end point on the fractional face - pt2.setVec(cos(ang)*scale,sin(ang)*scale,t); + pt2.set(cos(ang)*scale,sin(ang)*scale,t); // Find the fraction that we need to add to the end point. t_fraction = (end - (t - t_step))*sides; if (t_fraction > 0.0001f) { - LLVector3 new_pt = lerp(pt1, pt2, t_fraction); + LLVector4a new_pt; + new_pt.setLerp(pt1, pt2, t_fraction); if (mProfile.size() > 0) { - LLVector3 p = mProfile[mProfile.size()-1]; + LLVector4a p = mProfile[mProfile.size()-1]; for (S32 i = 0; i < split && mProfile.size() > 0; i++) { - mProfile.push_back(p+(new_pt-p) * 1.0f/(float)(split+1) * (float)(i+1)); + //mProfile.push_back(p+(new_pt-p) * 1.0f/(float)(split+1) * (float)(i+1)); + + LLVector4a pt1; + pt1.setSub(new_pt, p); + pt1.mul(1.0f/(float)(split+1) * (float)(i+1)); + pt1.add(p); + mProfile.push_back(pt1); } } mProfile.push_back(new_pt); @@ -568,7 +670,7 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 if (params.getHollow() <= 0) { // put center point if not hollow. - mProfile.push_back(LLVector3(0,0,0)); + mProfile.push_back(LLVector4a(0,0,0)); } } else @@ -581,103 +683,6 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 mTotal = mProfile.size(); } -void LLProfile::genNormals(const LLProfileParams& params) -{ - S32 count = mProfile.size(); - - S32 outer_count; - if (mTotalOut) - { - outer_count = mTotalOut; - } - else - { - outer_count = mTotal / 2; - } - - mEdgeNormals.resize(count * 2); - mEdgeCenters.resize(count * 2); - mNormals.resize(count); - - LLVector2 pt0,pt1; - - BOOL hollow = (params.getHollow() > 0); - - S32 i0, i1, i2, i3, i4; - - // Parametrically generate normal - for (i2 = 0; i2 < count; i2++) - { - mNormals[i2].mV[0] = mProfile[i2].mV[0]; - mNormals[i2].mV[1] = mProfile[i2].mV[1]; - if (hollow && (i2 >= outer_count)) - { - mNormals[i2] *= -1.f; - } - if (mNormals[i2].magVec() < 0.001) - { - // Special case for point at center, get adjacent points. - i1 = (i2 - 1) >= 0 ? i2 - 1 : count - 1; - i0 = (i1 - 1) >= 0 ? i1 - 1 : count - 1; - i3 = (i2 + 1) < count ? i2 + 1 : 0; - i4 = (i3 + 1) < count ? i3 + 1 : 0; - - pt0.setVec(mProfile[i1].mV[VX] + mProfile[i1].mV[VX] - mProfile[i0].mV[VX], - mProfile[i1].mV[VY] + mProfile[i1].mV[VY] - mProfile[i0].mV[VY]); - pt1.setVec(mProfile[i3].mV[VX] + mProfile[i3].mV[VX] - mProfile[i4].mV[VX], - mProfile[i3].mV[VY] + mProfile[i3].mV[VY] - mProfile[i4].mV[VY]); - - mNormals[i2] = pt0 + pt1; - mNormals[i2] *= 0.5f; - } - mNormals[i2].normVec(); - } - - S32 num_normal_sets = isConcave() ? 2 : 1; - for (S32 normal_set = 0; normal_set < num_normal_sets; normal_set++) - { - S32 point_num; - for (point_num = 0; point_num < mTotal; point_num++) - { - LLVector3 point_1 = mProfile[point_num]; - point_1.mV[VZ] = 0.f; - - LLVector3 point_2; - - if (isConcave() && normal_set == 0 && point_num == (mTotal - 1) / 2) - { - point_2 = mProfile[mTotal - 1]; - } - else if (isConcave() && normal_set == 1 && point_num == mTotal - 1) - { - point_2 = mProfile[(mTotal - 1) / 2]; - } - else - { - LLVector3 delta_pos; - S32 neighbor_point = (point_num + 1) % mTotal; - while(delta_pos.magVecSquared() < 0.01f * 0.01f) - { - point_2 = mProfile[neighbor_point]; - delta_pos = point_2 - point_1; - neighbor_point = (neighbor_point + 1) % mTotal; - if (neighbor_point == point_num) - { - break; - } - } - } - - point_2.mV[VZ] = 0.f; - LLVector3 face_normal = (point_2 - point_1) % LLVector3::z_axis; - face_normal.normVec(); - mEdgeNormals[normal_set * count + point_num] = face_normal; - mEdgeCenters[normal_set * count + point_num] = lerp(point_1, point_2, 0.5f); - } - } -} - - // Hollow is percent of the original bounding box, not of this particular // profile's geometry. Thus, a swept triangle needs lower hollow values than // a swept square. @@ -693,12 +698,13 @@ LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, BOOL flat, F3 Face *face = addFace(mTotalOut, mTotal-mTotalOut,0,LL_FACE_INNER_SIDE, flat); - std::vector pt; + static LLAlignedArray pt; pt.resize(mTotal) ; for (S32 i=mTotalOut;imPos.setVec(0 + lerp(0,params.getShear().mV[0],s) + pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s) + lerp(-skew ,skew, t) * 0.5f, c + lerp(0,params.getShear().mV[1],s), s); - pt->mScale.mV[VX] = hole_x * lerp(taper_x_begin, taper_x_end, t); - pt->mScale.mV[VY] = hole_y * lerp(taper_y_begin, taper_y_end, t); + pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t), + hole_y * lerp(taper_y_begin, taper_y_end, t), + 0,1); pt->mTexT = t; // Twist rotates the path along the x,y plane (I think) - DJS 04/05/02 twist.setQuat (lerp(twist_begin,twist_end,t) * 2.f * F_PI - F_PI,0,0,1); // Rotate the point around the circle's center. qang.setQuat (ang,path_axis); - pt->mRot = twist * qang; + + LLMatrix3 rot(twist * qang); + + pt->mRot.loadu(rot); t+=step; @@ -1408,51 +1419,55 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en // Run through the non-cut dependent points. while (t < params.getEnd()) { - pt = vector_append(mPath, 1); + pt = mPath.append(1); ang = 2.0f*F_PI*revolutions * t; c = cos(ang)*lerp(radius_start, radius_end, t); s = sin(ang)*lerp(radius_start, radius_end, t); - pt->mPos.setVec(0 + lerp(0,params.getShear().mV[0],s) + pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s) + lerp(-skew ,skew, t) * 0.5f, c + lerp(0,params.getShear().mV[1],s), s); - pt->mScale.mV[VX] = hole_x * lerp(taper_x_begin, taper_x_end, t); - pt->mScale.mV[VY] = hole_y * lerp(taper_y_begin, taper_y_end, t); + pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t), + hole_y * lerp(taper_y_begin, taper_y_end, t), + 0,1); pt->mTexT = t; // Twist rotates the path along the x,y plane (I think) - DJS 04/05/02 twist.setQuat (lerp(twist_begin,twist_end,t) * 2.f * F_PI - F_PI,0,0,1); // Rotate the point around the circle's center. qang.setQuat (ang,path_axis); - pt->mRot = twist * qang; - + LLMatrix3 tmp(twist*qang); + pt->mRot.loadu(tmp); + t+=step; } // Make one final pass for the end cut. t = params.getEnd(); - pt = vector_append(mPath, 1); + pt = mPath.append(1); ang = 2.0f*F_PI*revolutions * t; c = cos(ang)*lerp(radius_start, radius_end, t); s = sin(ang)*lerp(radius_start, radius_end, t); - pt->mPos.setVec(0 + lerp(0,params.getShear().mV[0],s) + pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s) + lerp(-skew ,skew, t) * 0.5f, c + lerp(0,params.getShear().mV[1],s), s); - pt->mScale.mV[VX] = hole_x * lerp(taper_x_begin, taper_x_end, t); - pt->mScale.mV[VY] = hole_y * lerp(taper_y_begin, taper_y_end, t); + pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t), + hole_y * lerp(taper_y_begin, taper_y_end, t), + 0,1); pt->mTexT = t; // Twist rotates the path along the x,y plane (I think) - DJS 04/05/02 twist.setQuat (lerp(twist_begin,twist_end,t) * 2.f * F_PI - F_PI,0,0,1); // Rotate the point around the circle's center. qang.setQuat (ang,path_axis); - pt->mRot = twist * qang; - + LLMatrix3 tmp(twist*qang); + pt->mRot.loadu(tmp); + mTotal = mPath.size(); } @@ -1549,7 +1564,7 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, mDirty = FALSE; S32 np = 2; // hardcode for line - mPath.clear(); + mPath.resize(0); mOpen = TRUE; // Is this 0xf0 mask really necessary? DK 03/02/05 @@ -1575,12 +1590,16 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, for (S32 i=0;imPath.size() * mProfilep->mProfile.size()) > (1u << 20)) - { - llinfos << "sizeS: " << mPathp->mPath.size() << " sizeT: " << mProfilep->mProfile.size() << llendl ; - llinfos << "path_detail : " << path_detail << " split: " << split << " profile_detail: " << profile_detail << llendl ; - llinfos << mParams << llendl ; - llinfos << "more info to check if mProfilep is deleted or not." << llendl ; - llinfos << mProfilep->mNormals.size() << " : " << mProfilep->mFaces.size() << " : " << mProfilep->mEdgeNormals.size() << " : " << mProfilep->mEdgeCenters.size() << llendl ; - - llerrs << "LLVolume corrupted!" << llendl ; - } - //******************************************************************** - BOOL regenPath = mPathp->generate(mParams.getPathParams(), path_detail, split); BOOL regenProf = mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(),profile_detail, split); @@ -2163,21 +2176,6 @@ BOOL LLVolume::generate() S32 sizeS = mPathp->mPath.size(); S32 sizeT = mProfilep->mProfile.size(); - //******************************************************************** - //debug info, to be removed - if((U32)(sizeS * sizeT) > (1u << 20)) - { - llinfos << "regenPath: " << (S32)regenPath << " regenProf: " << (S32)regenProf << llendl ; - llinfos << "sizeS: " << sizeS << " sizeT: " << sizeT << llendl ; - llinfos << "path_detail : " << path_detail << " split: " << split << " profile_detail: " << profile_detail << llendl ; - llinfos << mParams << llendl ; - llinfos << "more info to check if mProfilep is deleted or not." << llendl ; - llinfos << mProfilep->mNormals.size() << " : " << mProfilep->mFaces.size() << " : " << mProfilep->mEdgeNormals.size() << " : " << mProfilep->mEdgeCenters.size() << llendl ; - - llerrs << "LLVolume corrupted!" << llendl ; - } - //******************************************************************** - sNumMeshPoints -= mMesh.size(); mMesh.resize(sizeT * sizeS); sNumMeshPoints += mMesh.size(); @@ -2185,22 +2183,39 @@ BOOL LLVolume::generate() //generate vertex positions // Run along the path. + LLVector4a* dst = mMesh.mArray; + for (S32 s = 0; s < sizeS; ++s) { - LLVector2 scale = mPathp->mPath[s].mScale; - LLQuaternion rot = mPathp->mPath[s].mRot; + F32* scale = mPathp->mPath[s].mScale.getF32ptr(); + + F32 sc [] = + { scale[0], 0, 0, 0, + 0, scale[1], 0, 0, + 0, 0, scale[2], 0, + 0, 0, 0, 1 }; + + LLMatrix4 rot((F32*) mPathp->mPath[s].mRot.mMatrix); + LLMatrix4 scale_mat(sc); + + scale_mat *= rot; + + LLMatrix4a rot_mat; + rot_mat.loadu(scale_mat); + + LLVector4a* profile = mProfilep->mProfile.mArray; + LLVector4a* end_profile = profile+sizeT; + LLVector4a offset = mPathp->mPath[s].mPos; + + LLVector4a tmp; // Run along the profile. - for (S32 t = 0; t < sizeT; ++t) + while (profile < end_profile) { - S32 m = s*sizeT + t; - Point& pt = mMesh[m]; - - pt.mPos.mV[0] = mProfilep->mProfile[t].mV[0] * scale.mV[0]; - pt.mPos.mV[1] = mProfilep->mProfile[t].mV[1] * scale.mV[1]; - pt.mPos.mV[2] = 0.0f; - pt.mPos = pt.mPos * rot; - pt.mPos += mPathp->mPath[s].mPos; + rot_mat.rotate(*profile++, tmp); + dst->setAdd(tmp,offset); + llassert(less_than_max_mag(*dst)); + ++dst; } } @@ -2210,9 +2225,11 @@ BOOL LLVolume::generate() LLFaceID id = iter->mFaceID; mFaceMask |= id; } - + LL_CHECK_MEMORY return TRUE; } + + LL_CHECK_MEMORY return FALSE; } @@ -2790,14 +2807,16 @@ void LLVolume::createVolumeFaces() } -inline LLVector3 sculpt_rgb_to_vector(U8 r, U8 g, U8 b) +inline LLVector4a sculpt_rgb_to_vector(U8 r, U8 g, U8 b) { // maps RGB values to vector values [0..255] -> [-0.5..0.5] - LLVector3 value; - value.mV[VX] = r / 255.f - 0.5f; - value.mV[VY] = g / 255.f - 0.5f; - value.mV[VZ] = b / 255.f - 0.5f; + LLVector4a value; + LLVector4a sub(0.5f, 0.5f, 0.5f); + value.set(r,g,b); + value.mul(1.f/255.f); + value.sub(sub); + return value; } @@ -2817,21 +2836,21 @@ inline U32 sculpt_st_to_index(S32 s, S32 t, S32 size_s, S32 size_t, U16 sculpt_w } -inline LLVector3 sculpt_index_to_vector(U32 index, const U8* sculpt_data) +inline LLVector4a sculpt_index_to_vector(U32 index, const U8* sculpt_data) { - LLVector3 v = sculpt_rgb_to_vector(sculpt_data[index], sculpt_data[index+1], sculpt_data[index+2]); + LLVector4a v = sculpt_rgb_to_vector(sculpt_data[index], sculpt_data[index+1], sculpt_data[index+2]); return v; } -inline LLVector3 sculpt_st_to_vector(S32 s, S32 t, S32 size_s, S32 size_t, U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data) +inline LLVector4a sculpt_st_to_vector(S32 s, S32 t, S32 size_s, S32 size_t, U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data) { U32 index = sculpt_st_to_index(s, t, size_s, size_t, sculpt_width, sculpt_height, sculpt_components); return sculpt_index_to_vector(index, sculpt_data); } -inline LLVector3 sculpt_xy_to_vector(U32 x, U32 y, U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data) +inline LLVector4a sculpt_xy_to_vector(U32 x, U32 y, U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data) { U32 index = sculpt_xy_to_index(x, y, sculpt_width, sculpt_height, sculpt_components); @@ -2853,15 +2872,26 @@ F32 LLVolume::sculptGetSurfaceArea() for (S32 t = 0; t < sizeT-1; t++) { // get four corners of quad - LLVector3 p1 = mMesh[(s )*sizeT + (t )].mPos; - LLVector3 p2 = mMesh[(s+1)*sizeT + (t )].mPos; - LLVector3 p3 = mMesh[(s )*sizeT + (t+1)].mPos; - LLVector3 p4 = mMesh[(s+1)*sizeT + (t+1)].mPos; + LLVector4a& p1 = mMesh[(s )*sizeT + (t )]; + LLVector4a& p2 = mMesh[(s+1)*sizeT + (t )]; + LLVector4a& p3 = mMesh[(s )*sizeT + (t+1)]; + LLVector4a& p4 = mMesh[(s+1)*sizeT + (t+1)]; // compute the area of the quad by taking the length of the cross product of the two triangles - LLVector3 cross1 = (p1 - p2) % (p1 - p3); - LLVector3 cross2 = (p4 - p2) % (p4 - p3); - area += (cross1.magVec() + cross2.magVec()) / 2.f; + LLVector4a v0,v1,v2,v3; + v0.setSub(p1,p2); + v1.setSub(p1,p3); + v2.setSub(p4,p2); + v3.setSub(p4,p3); + + LLVector4a cross1, cross2; + cross1.setCross3(v0,v1); + cross2.setCross3(v2,v3); + + //LLVector3 cross1 = (p1 - p2) % (p1 - p3); + //LLVector3 cross2 = (p4 - p2) % (p4 - p3); + + area += (cross1.getLength3() + cross2.getLength3()).getF32() / 2.f; } } @@ -2882,17 +2912,19 @@ void LLVolume::sculptGeneratePlaceholder() for (S32 t = 0; t < sizeT; t++) { S32 i = t + line; - Point& pt = mMesh[i]; + LLVector4a& pt = mMesh[i]; F32 u = (F32)s/(sizeS-1); F32 v = (F32)t/(sizeT-1); const F32 RADIUS = (F32) 0.3; - - pt.mPos.mV[0] = (F32)(sin(F_PI * v) * cos(2.0 * F_PI * u) * RADIUS); - pt.mPos.mV[1] = (F32)(sin(F_PI * v) * sin(2.0 * F_PI * u) * RADIUS); - pt.mPos.mV[2] = (F32)(cos(F_PI * v) * RADIUS); + + F32* p = pt.getF32ptr(); + + p[0] = (F32)(sin(F_PI * v) * cos(2.0 * F_PI * u) * RADIUS); + p[1] = (F32)(sin(F_PI * v) * sin(2.0 * F_PI * u) * RADIUS); + p[2] = (F32)(cos(F_PI * v) * RADIUS); } line += sizeT; @@ -2917,7 +2949,7 @@ void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 for (S32 t = 0; t < sizeT; t++) { S32 i = t + line; - Point& pt = mMesh[i]; + LLVector4a& pt = mMesh[i]; S32 reversed_t = t; @@ -2974,11 +3006,12 @@ void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 } } - pt.mPos = sculpt_xy_to_vector(x, y, sculpt_width, sculpt_height, sculpt_components, sculpt_data); + pt = sculpt_xy_to_vector(x, y, sculpt_width, sculpt_height, sculpt_components, sculpt_data); if (sculpt_mirror) { - pt.mPos.mV[VX] *= -1.f; + LLVector4a scale(-1.f,1,1,1); + pt.mul(scale); } } @@ -3560,803 +3593,125 @@ bool LLVolumeParams::validate(U8 prof_curve, F32 prof_begin, F32 prof_end, F32 h return true; } -S32 *LLVolume::getTriangleIndices(U32 &num_indices) const +void LLVolume::getLoDTriangleCounts(const LLVolumeParams& params, S32* counts) +{ //attempt to approximate the number of triangles that will result from generating a volume LoD set for the + //supplied LLVolumeParams -- inaccurate, but a close enough approximation for determining streaming cost + F32 detail[] = {1.f, 1.5f, 2.5f, 4.f}; + for (S32 i = 0; i < 4; i++) + { + S32 count = 0; + S32 path_points = LLPath::getNumPoints(params.getPathParams(), detail[i]); + S32 profile_points = LLProfile::getNumPoints(params.getProfileParams(), false, detail[i]); + + count = (profile_points-1)*2*(path_points-1); + count += profile_points*2; + + counts[i] = count; + } +} + + +S32 LLVolume::getNumTriangles(S32* vcount) const { - S32 expected_num_triangle_indices = getNumTriangleIndices(); - if (expected_num_triangle_indices > MAX_VOLUME_TRIANGLE_INDICES) + U32 triangle_count = 0; + U32 vertex_count = 0; + + for (S32 i = 0; i < getNumVolumeFaces(); ++i) { - // we don't allow LLVolumes with this many vertices - llwarns << "Couldn't allocate triangle indices" << llendl; - num_indices = 0; - return NULL; + const LLVolumeFace& face = getVolumeFace(i); + triangle_count += face.mNumIndices/3; + + vertex_count += face.mNumVertices; } - S32* index = new S32[expected_num_triangle_indices]; - S32 count = 0; - // Let's do this totally diffently, as we don't care about faces... - // Counter-clockwise triangles are forward facing... + if (vcount) + { + *vcount = vertex_count; + } + + return triangle_count; +} + - BOOL open = getProfile().isOpen(); - BOOL hollow = (mParams.getProfileParams().getHollow() > 0); - BOOL path_open = getPath().isOpen(); - S32 size_s, size_s_out, size_t; - S32 s, t, i; - size_s = getProfile().getTotal(); - size_s_out = getProfile().getTotalOut(); - size_t = getPath().mPath.size(); +//----------------------------------------------------------------------------- +// generateSilhouetteVertices() +//----------------------------------------------------------------------------- +void LLVolume::generateSilhouetteVertices(std::vector &vertices, + std::vector &normals, + const LLVector3& obj_cam_vec_in, + const LLMatrix4& mat_in, + const LLMatrix3& norm_mat_in, + S32 face_mask) +{ + LLMatrix4a mat; + mat.loadu(mat_in); + + LLMatrix4a norm_mat; + norm_mat.loadu(norm_mat_in); + + LLVector4a obj_cam_vec; + obj_cam_vec.load3(obj_cam_vec_in.mV); - // NOTE -- if the construction of the triangles below ever changes - // then getNumTriangleIndices() method may also have to be updated. + vertices.clear(); + normals.clear(); - if (open) /* Flawfinder: ignore */ + if ((mParams.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH) { - if (hollow) + return; + } + + S32 cur_index = 0; + //for each face + for (face_list_t::iterator iter = mVolumeFaces.begin(); + iter != mVolumeFaces.end(); ++iter) + { + LLVolumeFace& face = *iter; + + if (!(face_mask & (0x1 << cur_index++)) || + face.mNumIndices == 0 || face.mEdge.empty()) { - // Open hollow -- much like the closed solid, except we - // we need to stitch up the gap between s=0 and s=size_s-1 + continue; + } - for (t = 0; t < size_t - 1; t++) - { - // The outer face, first cut, and inner face - for (s = 0; s < size_s - 1; s++) - { - i = s + t*size_s; - index[count++] = i; // x,y - index[count++] = i + 1; // x+1,y - index[count++] = i + size_s; // x,y+1 + if (face.mTypeMask & (LLVolumeFace::CAP_MASK)) { - index[count++] = i + size_s; // x,y+1 - index[count++] = i + 1; // x+1,y - index[count++] = i + size_s + 1; // x+1,y+1 - } + } + else { - // The other cut face - index[count++] = s + t*size_s; // x,y - index[count++] = 0 + t*size_s; // x+1,y - index[count++] = s + (t+1)*size_s; // x,y+1 - - index[count++] = s + (t+1)*size_s; // x,y+1 - index[count++] = 0 + t*size_s; // x+1,y - index[count++] = 0 + (t+1)*size_s; // x+1,y+1 - } + //============================================== + //DEBUG draw edge map instead of silhouette edge + //============================================== - // Do the top and bottom caps, if necessary - if (path_open) - { - // Top cap - S32 pt1 = 0; - S32 pt2 = size_s-1; - S32 i = (size_t - 1)*size_s; +#if DEBUG_SILHOUETTE_EDGE_MAP - while (pt2 - pt1 > 1) - { - // Use the profile points instead of the mesh, since you want - // the un-transformed profile distances. - LLVector3 p1 = getProfile().mProfile[pt1]; - LLVector3 p2 = getProfile().mProfile[pt2]; - LLVector3 pa = getProfile().mProfile[pt1+1]; - LLVector3 pb = getProfile().mProfile[pt2-1]; - - p1.mV[VZ] = 0.f; - p2.mV[VZ] = 0.f; - pa.mV[VZ] = 0.f; - pb.mV[VZ] = 0.f; - - // Use area of triangle to determine backfacing - F32 area_1a2, area_1ba, area_21b, area_2ab; - area_1a2 = (p1.mV[0]*pa.mV[1] - pa.mV[0]*p1.mV[1]) + - (pa.mV[0]*p2.mV[1] - p2.mV[0]*pa.mV[1]) + - (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]); - - area_1ba = (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*pa.mV[1] - pa.mV[0]*pb.mV[1]) + - (pa.mV[0]*p1.mV[1] - p1.mV[0]*pa.mV[1]); - - area_21b = (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]) + - (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); - - area_2ab = (p2.mV[0]*pa.mV[1] - pa.mV[0]*p2.mV[1]) + - (pa.mV[0]*pb.mV[1] - pb.mV[0]*pa.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); - - BOOL use_tri1a2 = TRUE; - BOOL tri_1a2 = TRUE; - BOOL tri_21b = TRUE; - - if (area_1a2 < 0) - { - tri_1a2 = FALSE; - } - if (area_2ab < 0) - { - // Can't use, because it contains point b - tri_1a2 = FALSE; - } - if (area_21b < 0) - { - tri_21b = FALSE; - } - if (area_1ba < 0) - { - // Can't use, because it contains point b - tri_21b = FALSE; - } + //for each triangle + U32 count = face.mNumIndices; + for (U32 j = 0; j < count/3; j++) { + //get vertices + S32 v1 = face.mIndices[j*3+0]; + S32 v2 = face.mIndices[j*3+1]; + S32 v3 = face.mIndices[j*3+2]; - if (!tri_1a2) - { - use_tri1a2 = FALSE; - } - else if (!tri_21b) - { - use_tri1a2 = TRUE; - } - else - { - LLVector3 d1 = p1 - pa; - LLVector3 d2 = p2 - pb; + //get current face center + LLVector3 cCenter = (face.mVertices[v1].getPosition() + + face.mVertices[v2].getPosition() + + face.mVertices[v3].getPosition()) / 3.0f; - if (d1.magVecSquared() < d2.magVecSquared()) - { - use_tri1a2 = TRUE; - } - else - { - use_tri1a2 = FALSE; - } + //for each edge + for (S32 k = 0; k < 3; k++) { + S32 nIndex = face.mEdge[j*3+k]; + if (nIndex <= -1) { + continue; } - if (use_tri1a2) - { - index[count++] = pt1 + i; - index[count++] = pt1 + 1 + i; - index[count++] = pt2 + i; - pt1++; - } - else - { - index[count++] = pt1 + i; - index[count++] = pt2 - 1 + i; - index[count++] = pt2 + i; - pt2--; + if (nIndex >= (S32) count/3) { + continue; } - } - - // Bottom cap - pt1 = 0; - pt2 = size_s-1; - while (pt2 - pt1 > 1) - { - // Use the profile points instead of the mesh, since you want - // the un-transformed profile distances. - LLVector3 p1 = getProfile().mProfile[pt1]; - LLVector3 p2 = getProfile().mProfile[pt2]; - LLVector3 pa = getProfile().mProfile[pt1+1]; - LLVector3 pb = getProfile().mProfile[pt2-1]; - - p1.mV[VZ] = 0.f; - p2.mV[VZ] = 0.f; - pa.mV[VZ] = 0.f; - pb.mV[VZ] = 0.f; - - // Use area of triangle to determine backfacing - F32 area_1a2, area_1ba, area_21b, area_2ab; - area_1a2 = (p1.mV[0]*pa.mV[1] - pa.mV[0]*p1.mV[1]) + - (pa.mV[0]*p2.mV[1] - p2.mV[0]*pa.mV[1]) + - (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]); - - area_1ba = (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*pa.mV[1] - pa.mV[0]*pb.mV[1]) + - (pa.mV[0]*p1.mV[1] - p1.mV[0]*pa.mV[1]); - - area_21b = (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]) + - (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); - - area_2ab = (p2.mV[0]*pa.mV[1] - pa.mV[0]*p2.mV[1]) + - (pa.mV[0]*pb.mV[1] - pb.mV[0]*pa.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); - - BOOL use_tri1a2 = TRUE; - BOOL tri_1a2 = TRUE; - BOOL tri_21b = TRUE; - - if (area_1a2 < 0) - { - tri_1a2 = FALSE; - } - if (area_2ab < 0) - { - // Can't use, because it contains point b - tri_1a2 = FALSE; - } - if (area_21b < 0) - { - tri_21b = FALSE; - } - if (area_1ba < 0) - { - // Can't use, because it contains point b - tri_21b = FALSE; - } - - if (!tri_1a2) - { - use_tri1a2 = FALSE; - } - else if (!tri_21b) - { - use_tri1a2 = TRUE; - } - else - { - LLVector3 d1 = p1 - pa; - LLVector3 d2 = p2 - pb; - - if (d1.magVecSquared() < d2.magVecSquared()) - { - use_tri1a2 = TRUE; - } - else - { - use_tri1a2 = FALSE; - } - } - - if (use_tri1a2) - { - index[count++] = pt1; - index[count++] = pt2; - index[count++] = pt1 + 1; - pt1++; - } - else - { - index[count++] = pt1; - index[count++] = pt2; - index[count++] = pt2 - 1; - pt2--; - } - } - } - } - else - { - // Open solid - - for (t = 0; t < size_t - 1; t++) - { - // Outer face + 1 cut face - for (s = 0; s < size_s - 1; s++) - { - i = s + t*size_s; - - index[count++] = i; // x,y - index[count++] = i + 1; // x+1,y - index[count++] = i + size_s; // x,y+1 - - index[count++] = i + size_s; // x,y+1 - index[count++] = i + 1; // x+1,y - index[count++] = i + size_s + 1; // x+1,y+1 - } - - // The other cut face - index[count++] = (size_s - 1) + (t*size_s); // x,y - index[count++] = 0 + t*size_s; // x+1,y - index[count++] = (size_s - 1) + (t+1)*size_s; // x,y+1 - - index[count++] = (size_s - 1) + (t+1)*size_s; // x,y+1 - index[count++] = 0 + (t*size_s); // x+1,y - index[count++] = 0 + (t+1)*size_s; // x+1,y+1 - } - - // Do the top and bottom caps, if necessary - if (path_open) - { - for (s = 0; s < size_s - 2; s++) - { - index[count++] = s+1; - index[count++] = s; - index[count++] = size_s - 1; - } - - // We've got a top cap - S32 offset = (size_t - 1)*size_s; - for (s = 0; s < size_s - 2; s++) - { - // Inverted ordering from bottom cap. - index[count++] = offset + size_s - 1; - index[count++] = offset + s; - index[count++] = offset + s + 1; - } - } - } - } - else if (hollow) - { - // Closed hollow - // Outer face - - for (t = 0; t < size_t - 1; t++) - { - for (s = 0; s < size_s_out - 1; s++) - { - i = s + t*size_s; - - index[count++] = i; // x,y - index[count++] = i + 1; // x+1,y - index[count++] = i + size_s; // x,y+1 - - index[count++] = i + size_s; // x,y+1 - index[count++] = i + 1; // x+1,y - index[count++] = i + 1 + size_s; // x+1,y+1 - } - } - - // Inner face - // Invert facing from outer face - for (t = 0; t < size_t - 1; t++) - { - for (s = size_s_out; s < size_s - 1; s++) - { - i = s + t*size_s; - - index[count++] = i; // x,y - index[count++] = i + 1; // x+1,y - index[count++] = i + size_s; // x,y+1 - - index[count++] = i + size_s; // x,y+1 - index[count++] = i + 1; // x+1,y - index[count++] = i + 1 + size_s; // x+1,y+1 - } - } - - // Do the top and bottom caps, if necessary - if (path_open) - { - // Top cap - S32 pt1 = 0; - S32 pt2 = size_s-1; - S32 i = (size_t - 1)*size_s; - - while (pt2 - pt1 > 1) - { - // Use the profile points instead of the mesh, since you want - // the un-transformed profile distances. - LLVector3 p1 = getProfile().mProfile[pt1]; - LLVector3 p2 = getProfile().mProfile[pt2]; - LLVector3 pa = getProfile().mProfile[pt1+1]; - LLVector3 pb = getProfile().mProfile[pt2-1]; - - p1.mV[VZ] = 0.f; - p2.mV[VZ] = 0.f; - pa.mV[VZ] = 0.f; - pb.mV[VZ] = 0.f; - - // Use area of triangle to determine backfacing - F32 area_1a2, area_1ba, area_21b, area_2ab; - area_1a2 = (p1.mV[0]*pa.mV[1] - pa.mV[0]*p1.mV[1]) + - (pa.mV[0]*p2.mV[1] - p2.mV[0]*pa.mV[1]) + - (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]); - - area_1ba = (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*pa.mV[1] - pa.mV[0]*pb.mV[1]) + - (pa.mV[0]*p1.mV[1] - p1.mV[0]*pa.mV[1]); - - area_21b = (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]) + - (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); - - area_2ab = (p2.mV[0]*pa.mV[1] - pa.mV[0]*p2.mV[1]) + - (pa.mV[0]*pb.mV[1] - pb.mV[0]*pa.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); - - BOOL use_tri1a2 = TRUE; - BOOL tri_1a2 = TRUE; - BOOL tri_21b = TRUE; - - if (area_1a2 < 0) - { - tri_1a2 = FALSE; - } - if (area_2ab < 0) - { - // Can't use, because it contains point b - tri_1a2 = FALSE; - } - if (area_21b < 0) - { - tri_21b = FALSE; - } - if (area_1ba < 0) - { - // Can't use, because it contains point b - tri_21b = FALSE; - } - - if (!tri_1a2) - { - use_tri1a2 = FALSE; - } - else if (!tri_21b) - { - use_tri1a2 = TRUE; - } - else - { - LLVector3 d1 = p1 - pa; - LLVector3 d2 = p2 - pb; - - if (d1.magVecSquared() < d2.magVecSquared()) - { - use_tri1a2 = TRUE; - } - else - { - use_tri1a2 = FALSE; - } - } - - if (use_tri1a2) - { - index[count++] = pt1 + i; - index[count++] = pt1 + 1 + i; - index[count++] = pt2 + i; - pt1++; - } - else - { - index[count++] = pt1 + i; - index[count++] = pt2 - 1 + i; - index[count++] = pt2 + i; - pt2--; - } - } - - // Bottom cap - pt1 = 0; - pt2 = size_s-1; - while (pt2 - pt1 > 1) - { - // Use the profile points instead of the mesh, since you want - // the un-transformed profile distances. - LLVector3 p1 = getProfile().mProfile[pt1]; - LLVector3 p2 = getProfile().mProfile[pt2]; - LLVector3 pa = getProfile().mProfile[pt1+1]; - LLVector3 pb = getProfile().mProfile[pt2-1]; - - p1.mV[VZ] = 0.f; - p2.mV[VZ] = 0.f; - pa.mV[VZ] = 0.f; - pb.mV[VZ] = 0.f; - - // Use area of triangle to determine backfacing - F32 area_1a2, area_1ba, area_21b, area_2ab; - area_1a2 = (p1.mV[0]*pa.mV[1] - pa.mV[0]*p1.mV[1]) + - (pa.mV[0]*p2.mV[1] - p2.mV[0]*pa.mV[1]) + - (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]); - - area_1ba = (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*pa.mV[1] - pa.mV[0]*pb.mV[1]) + - (pa.mV[0]*p1.mV[1] - p1.mV[0]*pa.mV[1]); - - area_21b = (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]) + - (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); - - area_2ab = (p2.mV[0]*pa.mV[1] - pa.mV[0]*p2.mV[1]) + - (pa.mV[0]*pb.mV[1] - pb.mV[0]*pa.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); - - BOOL use_tri1a2 = TRUE; - BOOL tri_1a2 = TRUE; - BOOL tri_21b = TRUE; - - if (area_1a2 < 0) - { - tri_1a2 = FALSE; - } - if (area_2ab < 0) - { - // Can't use, because it contains point b - tri_1a2 = FALSE; - } - if (area_21b < 0) - { - tri_21b = FALSE; - } - if (area_1ba < 0) - { - // Can't use, because it contains point b - tri_21b = FALSE; - } - - if (!tri_1a2) - { - use_tri1a2 = FALSE; - } - else if (!tri_21b) - { - use_tri1a2 = TRUE; - } - else - { - LLVector3 d1 = p1 - pa; - LLVector3 d2 = p2 - pb; - - if (d1.magVecSquared() < d2.magVecSquared()) - { - use_tri1a2 = TRUE; - } - else - { - use_tri1a2 = FALSE; - } - } - - if (use_tri1a2) - { - index[count++] = pt1; - index[count++] = pt2; - index[count++] = pt1 + 1; - pt1++; - } - else - { - index[count++] = pt1; - index[count++] = pt2; - index[count++] = pt2 - 1; - pt2--; - } - } - } - } - else - { - // Closed solid. Easy case. - for (t = 0; t < size_t - 1; t++) - { - for (s = 0; s < size_s - 1; s++) - { - // Should wrap properly, but for now... - i = s + t*size_s; - - index[count++] = i; // x,y - index[count++] = i + 1; // x+1,y - index[count++] = i + size_s; // x,y+1 - - index[count++] = i + size_s; // x,y+1 - index[count++] = i + 1; // x+1,y - index[count++] = i + size_s + 1; // x+1,y+1 - } - } - - // Do the top and bottom caps, if necessary - if (path_open) - { - // bottom cap - for (s = 1; s < size_s - 2; s++) - { - index[count++] = s+1; - index[count++] = s; - index[count++] = 0; - } - - // top cap - S32 offset = (size_t - 1)*size_s; - for (s = 1; s < size_s - 2; s++) - { - // Inverted ordering from bottom cap. - index[count++] = offset; - index[count++] = offset + s; - index[count++] = offset + s + 1; - } - } - } - -#ifdef LL_DEBUG - // assert that we computed the correct number of indices - if (count != expected_num_triangle_indices ) - { - llerrs << "bad index count prediciton:" - << " expected=" << expected_num_triangle_indices - << " actual=" << count << llendl; - } -#endif - -#if 0 - // verify that each index does not point beyond the size of the mesh - S32 num_vertices = mMesh.size(); - for (i = 0; i < count; i+=3) - { - llinfos << index[i] << ":" << index[i+1] << ":" << index[i+2] << llendl; - llassert(index[i] < num_vertices); - llassert(index[i+1] < num_vertices); - llassert(index[i+2] < num_vertices); - } -#endif - - num_indices = count; - return index; -} - -void LLVolume::getLoDTriangleCounts(const LLVolumeParams& params, S32* counts) -{ //attempt to approximate the number of triangles that will result from generating a volume LoD set for the - //supplied LLVolumeParams -- inaccurate, but a close enough approximation for determining streaming cost - F32 detail[] = {1.f, 1.5f, 2.5f, 4.f}; - for (S32 i = 0; i < 4; i++) - { - S32 count = 0; - S32 path_points = LLPath::getNumPoints(params.getPathParams(), detail[i]); - S32 profile_points = LLProfile::getNumPoints(params.getProfileParams(), false, detail[i]); - - count = (profile_points-1)*2*(path_points-1); - count += profile_points*2; - - counts[i] = count; - } -} - -S32 LLVolume::getNumTriangleIndices() const -{ - BOOL profile_open = getProfile().isOpen(); - BOOL hollow = (mParams.getProfileParams().getHollow() > 0); - BOOL path_open = getPath().isOpen(); - - S32 size_s, size_s_out, size_t; - size_s = getProfile().getTotal(); - size_s_out = getProfile().getTotalOut(); - size_t = getPath().mPath.size(); - - S32 count = 0; - if (profile_open) /* Flawfinder: ignore */ - { - if (hollow) - { - // Open hollow -- much like the closed solid, except we - // we need to stitch up the gap between s=0 and s=size_s-1 - count = (size_t - 1) * (((size_s -1) * 6) + 6); - } - else - { - count = (size_t - 1) * (((size_s -1) * 6) + 6); - } - } - else if (hollow) - { - // Closed hollow - // Outer face - count = (size_t - 1) * (size_s_out - 1) * 6; - - // Inner face - count += (size_t - 1) * ((size_s - 1) - size_s_out) * 6; - } - else - { - // Closed solid. Easy case. - count = (size_t - 1) * (size_s - 1) * 6; - } - - if (path_open) - { - S32 cap_triangle_count = size_s - 3; - if ( profile_open - || hollow ) - { - cap_triangle_count = size_s - 2; - } - if ( cap_triangle_count > 0 ) - { - // top and bottom caps - count += cap_triangle_count * 2 * 3; - } - } - return count; -} - - -S32 LLVolume::getNumTriangles(S32* vcount) const -{ - U32 triangle_count = 0; - U32 vertex_count = 0; - - for (S32 i = 0; i < getNumVolumeFaces(); ++i) - { - const LLVolumeFace& face = getVolumeFace(i); - triangle_count += face.mNumIndices/3; - - vertex_count += face.mNumVertices; - } - - - if (vcount) - { - *vcount = vertex_count; - } - - return triangle_count; -} - - -//----------------------------------------------------------------------------- -// generateSilhouetteVertices() -//----------------------------------------------------------------------------- -void LLVolume::generateSilhouetteVertices(std::vector &vertices, - std::vector &normals, - const LLVector3& obj_cam_vec_in, - const LLMatrix4& mat_in, - const LLMatrix3& norm_mat_in, - S32 face_mask) -{ - LLMatrix4a mat; - mat.loadu(mat_in); - - LLMatrix4a norm_mat; - norm_mat.loadu(norm_mat_in); - - LLVector4a obj_cam_vec; - obj_cam_vec.load3(obj_cam_vec_in.mV); - - vertices.clear(); - normals.clear(); - - if ((mParams.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH) - { - return; - } - - S32 cur_index = 0; - //for each face - for (face_list_t::iterator iter = mVolumeFaces.begin(); - iter != mVolumeFaces.end(); ++iter) - { - LLVolumeFace& face = *iter; - - if (!(face_mask & (0x1 << cur_index++)) || - face.mNumIndices == 0 || face.mEdge.empty()) - { - continue; - } - - if (face.mTypeMask & (LLVolumeFace::CAP_MASK)) { - - } - else { - - //============================================== - //DEBUG draw edge map instead of silhouette edge - //============================================== - -#if DEBUG_SILHOUETTE_EDGE_MAP - - //for each triangle - U32 count = face.mNumIndices; - for (U32 j = 0; j < count/3; j++) { - //get vertices - S32 v1 = face.mIndices[j*3+0]; - S32 v2 = face.mIndices[j*3+1]; - S32 v3 = face.mIndices[j*3+2]; - - //get current face center - LLVector3 cCenter = (face.mVertices[v1].getPosition() + - face.mVertices[v2].getPosition() + - face.mVertices[v3].getPosition()) / 3.0f; - - //for each edge - for (S32 k = 0; k < 3; k++) { - S32 nIndex = face.mEdge[j*3+k]; - if (nIndex <= -1) { - continue; - } - - if (nIndex >= (S32) count/3) { - continue; - } - //get neighbor vertices - v1 = face.mIndices[nIndex*3+0]; - v2 = face.mIndices[nIndex*3+1]; - v3 = face.mIndices[nIndex*3+2]; + //get neighbor vertices + v1 = face.mIndices[nIndex*3+0]; + v2 = face.mIndices[nIndex*3+1]; + v3 = face.mIndices[nIndex*3+2]; //get neighbor face center LLVector3 nCenter = (face.mVertices[v1].getPosition() + @@ -5243,8 +4598,6 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) freeData(); - LLVector4a::memcpyNonAliased16((F32*) mExtents, (F32*) src.mExtents, 3*sizeof(LLVector4a)); - resizeVertices(src.mNumVertices); resizeIndices(src.mNumIndices); @@ -5307,7 +4660,7 @@ LLVolumeFace::~LLVolumeFace() void LLVolumeFace::freeData() { - ll_aligned_free_16(mPositions); + ll_aligned_free(mPositions); mPositions = NULL; //normals and texture coordinates are part of the same buffer as mPositions, do not free them separately @@ -5331,52 +4684,23 @@ BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build) delete mOctree; mOctree = NULL; + LL_CHECK_MEMORY BOOL ret = FALSE ; if (mTypeMask & CAP_MASK) { ret = createCap(volume, partial_build); + LL_CHECK_MEMORY } else if ((mTypeMask & END_MASK) || (mTypeMask & SIDE_MASK)) { ret = createSide(volume, partial_build); + LL_CHECK_MEMORY } else { llerrs << "Unknown/uninitialized face type!" << llendl; } - //update the range of the texture coordinates - if(ret) - { - mTexCoordExtents[0].setVec(1.f, 1.f) ; - mTexCoordExtents[1].setVec(0.f, 0.f) ; - - for(U32 i = 0 ; i < mNumVertices ; i++) - { - if(mTexCoordExtents[0].mV[0] > mTexCoords[i].mV[0]) - { - mTexCoordExtents[0].mV[0] = mTexCoords[i].mV[0] ; - } - if(mTexCoordExtents[1].mV[0] < mTexCoords[i].mV[0]) - { - mTexCoordExtents[1].mV[0] = mTexCoords[i].mV[0] ; - } - - if(mTexCoordExtents[0].mV[1] > mTexCoords[i].mV[1]) - { - mTexCoordExtents[0].mV[1] = mTexCoords[i].mV[1] ; - } - if(mTexCoordExtents[1].mV[1] < mTexCoords[i].mV[1]) - { - mTexCoordExtents[1].mV[1] = mTexCoords[i].mV[1] ; - } - } - mTexCoordExtents[0].mV[0] = llmax(0.f, mTexCoordExtents[0].mV[0]) ; - mTexCoordExtents[0].mV[1] = llmax(0.f, mTexCoordExtents[0].mV[1]) ; - mTexCoordExtents[1].mV[0] = llmin(1.f, mTexCoordExtents[1].mV[0]) ; - mTexCoordExtents[1].mV[1] = llmin(1.f, mTexCoordExtents[1].mV[1]) ; - } - return ret ; } @@ -6068,8 +5392,10 @@ void LerpPlanarVertex(LLVolumeFace::VertexData& v0, BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) { - const std::vector& mesh = volume->getMesh(); - const std::vector& profile = volume->getProfile().mProfile; + LL_CHECK_MEMORY + + const LLAlignedArray& mesh = volume->getMesh(); + const LLAlignedArray& profile = volume->getProfile().mProfile; S32 max_s = volume->getProfile().getTotal(); S32 max_t = volume->getPath().mPath.size(); @@ -6099,9 +5425,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) VertexData baseVert; for(S32 t = 0; t < 4; t++) { - corners[t].getPosition().load3( mesh[offset + (grid_size*t)].mPos.mV); - corners[t].mTexCoord.mV[0] = profile[grid_size*t].mV[0]+0.5f; - corners[t].mTexCoord.mV[1] = 0.5f - profile[grid_size*t].mV[1]; + corners[t].getPosition().load4a(mesh[offset + (grid_size*t)].getF32ptr()); + corners[t].mTexCoord.mV[0] = profile[grid_size*t][0]+0.5f; + corners[t].mTexCoord.mV[1] = 0.5f - profile[grid_size*t][1]; } { @@ -6182,6 +5508,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) mCenter->mul(0.5f); } + llassert(less_than_max_mag(mExtents[0])); + llassert(less_than_max_mag(mExtents[1])); + if (!partial_build) { resizeIndices(grid_size*grid_size*6); @@ -6212,6 +5541,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) } } + LL_CHECK_MEMORY return TRUE; } @@ -6230,8 +5560,8 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) S32 num_vertices = 0, num_indices = 0; - const std::vector& mesh = volume->getMesh(); - const std::vector& profile = volume->getProfile().mProfile; + const LLAlignedArray& mesh = volume->getMesh(); + const LLAlignedArray& profile = volume->getProfile().mProfile; // All types of caps have the same number of vertices and indices num_vertices = profile.size(); @@ -6251,13 +5581,14 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) { resizeVertices(num_vertices); allocateBinormals(num_vertices); - if (!partial_build) { resizeIndices(num_indices); } } + LL_CHECK_MEMORY; + S32 max_s = volume->getProfile().getTotal(); S32 max_t = volume->getPath().mPath.size(); @@ -6288,35 +5619,68 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) LLVector4a* binorm = (LLVector4a*) mBinormals; // Copy the vertices into the array - for (S32 i = 0; i < num_vertices; i++) + + const LLVector4a* src = mesh.mArray+offset; + const LLVector4a* end = src+num_vertices; + + min = *src; + max = min; + + + const LLVector4a* p = profile.mArray; + + if (mTypeMask & TOP_MASK) { - if (mTypeMask & TOP_MASK) - { - tc[i].mV[0] = profile[i].mV[0]+0.5f; - tc[i].mV[1] = profile[i].mV[1]+0.5f; - } - else + min_uv.set((*p)[0]+0.5f, + (*p)[1]+0.5f); + + max_uv = min_uv; + + while(src < end) { - // Mirror for underside. - tc[i].mV[0] = profile[i].mV[0]+0.5f; - tc[i].mV[1] = 0.5f - profile[i].mV[1]; - } + tc->mV[0] = (*p)[0]+0.5f; + tc->mV[1] = (*p)[1]+0.5f; - pos[i].load3(mesh[i + offset].mPos.mV); + llassert(less_than_max_mag(*src)); + update_min_max(min,max,*src); + update_min_max(min_uv, max_uv, *tc); - if (i == 0) - { - max = pos[i]; - min = max; - min_uv = max_uv = tc[i]; + *pos = *src; + + ++p; + ++tc; + ++src; + ++pos; } - else + } + else + { + + min_uv.set((*p)[0]+0.5f, + 0.5f - (*p)[1]); + max_uv = min_uv; + + while(src < end) { - update_min_max(min,max,pos[i]); - update_min_max(min_uv, max_uv, tc[i]); + // Mirror for underside. + tc->mV[0] = (*p)[0]+0.5f; + tc->mV[1] = 0.5f - (*p)[1]; + + llassert(less_than_max_mag(*src)); + update_min_max(min,max,*src); + update_min_max(min_uv, max_uv, *tc); + + *pos = *src; + + ++p; + ++tc; + ++src; + ++pos; } } + LL_CHECK_MEMORY + mCenter->setAdd(min, max); mCenter->mul(0.5f); @@ -6353,15 +5717,25 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) if (!(mTypeMask & HOLLOW_MASK) && !(mTypeMask & OPEN_MASK)) { - pos[num_vertices] = *mCenter; - tc[num_vertices] = cuv; + *pos++ = *mCenter; + *tc++ = cuv; num_vertices++; } - - for (S32 i = 0; i < num_vertices; i++) + + LL_CHECK_MEMORY + + F32* dst_binorm = (F32*) binorm; + F32* end_binorm = (F32*) (binorm+num_vertices); + + F32* dst_norm = (F32*) norm; + + while (dst_binorm < end_binorm) { - binorm[i].load4a(binormal.getF32ptr()); - norm[i].load4a(normal.getF32ptr()); + binormal.store4a(dst_binorm); + normal.store4a(dst_norm); + + dst_binorm += 4; + dst_norm += 4; } if (partial_build) @@ -6382,33 +5756,38 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) { // Use the profile points instead of the mesh, since you want // the un-transformed profile distances. - LLVector3 p1 = profile[pt1]; - LLVector3 p2 = profile[pt2]; - LLVector3 pa = profile[pt1+1]; - LLVector3 pb = profile[pt2-1]; + const LLVector4a& p1 = profile[pt1]; + const LLVector4a& p2 = profile[pt2]; + const LLVector4a& pa = profile[pt1+1]; + const LLVector4a& pb = profile[pt2-1]; + + const F32* p1V = p1.getF32ptr(); + const F32* p2V = p2.getF32ptr(); + const F32* paV = pa.getF32ptr(); + const F32* pbV = pb.getF32ptr(); - p1.mV[VZ] = 0.f; - p2.mV[VZ] = 0.f; - pa.mV[VZ] = 0.f; - pb.mV[VZ] = 0.f; + //p1.mV[VZ] = 0.f; + //p2.mV[VZ] = 0.f; + //pa.mV[VZ] = 0.f; + //pb.mV[VZ] = 0.f; // Use area of triangle to determine backfacing F32 area_1a2, area_1ba, area_21b, area_2ab; - area_1a2 = (p1.mV[0]*pa.mV[1] - pa.mV[0]*p1.mV[1]) + - (pa.mV[0]*p2.mV[1] - p2.mV[0]*pa.mV[1]) + - (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]); + area_1a2 = (p1V[0]*paV[1] - paV[0]*p1V[1]) + + (paV[0]*p2V[1] - p2V[0]*paV[1]) + + (p2V[0]*p1V[1] - p1V[0]*p2V[1]); - area_1ba = (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*pa.mV[1] - pa.mV[0]*pb.mV[1]) + - (pa.mV[0]*p1.mV[1] - p1.mV[0]*pa.mV[1]); + area_1ba = (p1V[0]*pbV[1] - pbV[0]*p1V[1]) + + (pbV[0]*paV[1] - paV[0]*pbV[1]) + + (paV[0]*p1V[1] - p1V[0]*paV[1]); - area_21b = (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]) + - (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); + area_21b = (p2V[0]*p1V[1] - p1V[0]*p2V[1]) + + (p1V[0]*pbV[1] - pbV[0]*p1V[1]) + + (pbV[0]*p2V[1] - p2V[0]*pbV[1]); - area_2ab = (p2.mV[0]*pa.mV[1] - pa.mV[0]*p2.mV[1]) + - (pa.mV[0]*pb.mV[1] - pb.mV[0]*pa.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); + area_2ab = (p2V[0]*paV[1] - paV[0]*p2V[1]) + + (paV[0]*pbV[1] - pbV[0]*paV[1]) + + (pbV[0]*p2V[1] - p2V[0]*pbV[1]); BOOL use_tri1a2 = TRUE; BOOL tri_1a2 = TRUE; @@ -6443,10 +5822,13 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) } else { - LLVector3 d1 = p1 - pa; - LLVector3 d2 = p2 - pb; + LLVector4a d1; + d1.setSub(p1, pa); + + LLVector4a d2; + d2.setSub(p2, pb); - if (d1.magVecSquared() < d2.magVecSquared()) + if (d1.dot3(d1) < d2.dot3(d2)) { use_tri1a2 = TRUE; } @@ -6485,33 +5867,33 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) { // Use the profile points instead of the mesh, since you want // the un-transformed profile distances. - LLVector3 p1 = profile[pt1]; - LLVector3 p2 = profile[pt2]; - LLVector3 pa = profile[pt1+1]; - LLVector3 pb = profile[pt2-1]; - - p1.mV[VZ] = 0.f; - p2.mV[VZ] = 0.f; - pa.mV[VZ] = 0.f; - pb.mV[VZ] = 0.f; - + const LLVector4a& p1 = profile[pt1]; + const LLVector4a& p2 = profile[pt2]; + const LLVector4a& pa = profile[pt1+1]; + const LLVector4a& pb = profile[pt2-1]; + + const F32* p1V = p1.getF32ptr(); + const F32* p2V = p2.getF32ptr(); + const F32* paV = pa.getF32ptr(); + const F32* pbV = pb.getF32ptr(); + // Use area of triangle to determine backfacing F32 area_1a2, area_1ba, area_21b, area_2ab; - area_1a2 = (p1.mV[0]*pa.mV[1] - pa.mV[0]*p1.mV[1]) + - (pa.mV[0]*p2.mV[1] - p2.mV[0]*pa.mV[1]) + - (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]); + area_1a2 = (p1V[0]*paV[1] - paV[0]*p1V[1]) + + (paV[0]*p2V[1] - p2V[0]*paV[1]) + + (p2V[0]*p1V[1] - p1V[0]*p2V[1]); - area_1ba = (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*pa.mV[1] - pa.mV[0]*pb.mV[1]) + - (pa.mV[0]*p1.mV[1] - p1.mV[0]*pa.mV[1]); + area_1ba = (p1V[0]*pbV[1] - pbV[0]*p1V[1]) + + (pbV[0]*paV[1] - paV[0]*pbV[1]) + + (paV[0]*p1V[1] - p1V[0]*paV[1]); - area_21b = (p2.mV[0]*p1.mV[1] - p1.mV[0]*p2.mV[1]) + - (p1.mV[0]*pb.mV[1] - pb.mV[0]*p1.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); + area_21b = (p2V[0]*p1V[1] - p1V[0]*p2V[1]) + + (p1V[0]*pbV[1] - pbV[0]*p1V[1]) + + (pbV[0]*p2V[1] - p2V[0]*pbV[1]); - area_2ab = (p2.mV[0]*pa.mV[1] - pa.mV[0]*p2.mV[1]) + - (pa.mV[0]*pb.mV[1] - pb.mV[0]*pa.mV[1]) + - (pb.mV[0]*p2.mV[1] - p2.mV[0]*pb.mV[1]); + area_2ab = (p2V[0]*paV[1] - paV[0]*p2V[1]) + + (paV[0]*pbV[1] - pbV[0]*paV[1]) + + (pbV[0]*p2V[1] - p2V[0]*pbV[1]); BOOL use_tri1a2 = TRUE; BOOL tri_1a2 = TRUE; @@ -6546,10 +5928,12 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) } else { - LLVector3 d1 = p1 - pa; - LLVector3 d2 = p2 - pb; + LLVector4a d1; + d1.setSub(p1,pa); + LLVector4a d2; + d2.setSub(p2,pb); - if (d1.magVecSquared() < d2.magVecSquared()) + if (d1.dot3(d1) < d2.dot3(d2)) { use_tri1a2 = TRUE; } @@ -6598,6 +5982,8 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) } + + LL_CHECK_MEMORY return TRUE; } @@ -6900,6 +6286,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) { + LL_CHECK_MEMORY BOOL flat = mTypeMask & FLAT_MASK; U8 sculpt_type = volume->getParams().getSculptType(); @@ -6910,9 +6297,9 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) S32 num_vertices, num_indices; - const std::vector& mesh = volume->getMesh(); - const std::vector& profile = volume->getProfile().mProfile; - const std::vector& path_data = volume->getPath().mPath; + const LLAlignedArray& mesh = volume->getMesh(); + const LLAlignedArray& profile = volume->getProfile().mProfile; + const LLAlignedArray& path_data = volume->getPath().mPath; S32 max_s = volume->getProfile().getTotal(); @@ -6933,10 +6320,11 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } } + LL_CHECK_MEMORY + LLVector4a* pos = (LLVector4a*) mPositions; - LLVector4a* norm = (LLVector4a*) mNormals; LLVector2* tc = (LLVector2*) mTexCoords; - F32 begin_stex = floorf(profile[mBeginS].mV[2]); + F32 begin_stex = floorf(profile[mBeginS][2]); S32 num_s = ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2) ? mNumS/2 : mNumS; S32 cur_vertex = 0; @@ -6965,11 +6353,11 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) // Get s value for tex-coord. if (!flat) { - ss = profile[mBeginS + s].mV[2]; + ss = profile[mBeginS + s][2]; } else { - ss = profile[mBeginS + s].mV[2] - begin_stex; + ss = profile[mBeginS + s][2] - begin_stex; } } @@ -6989,19 +6377,17 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) i = mBeginS + s + max_s*t; } - pos[cur_vertex].load3(mesh[i].mPos.mV); - tc[cur_vertex] = LLVector2(ss,tt); + llassert(less_than_max_mag(mesh[i])); + mesh[i].store4a((F32*)(pos+cur_vertex)); + tc[cur_vertex].set(ss,tt); - norm[cur_vertex].clear(); cur_vertex++; if (test && s > 0) { - pos[cur_vertex].load3(mesh[i].mPos.mV); - tc[cur_vertex] = LLVector2(ss,tt); - - norm[cur_vertex].clear(); - + llassert(less_than_max_mag(mesh[i])); + mesh[i].store4a((F32*)(pos+cur_vertex)); + tc[cur_vertex].set(ss,tt); cur_vertex++; } } @@ -7018,28 +6404,66 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } i = mBeginS + s + max_s*t; - ss = profile[mBeginS + s].mV[2] - begin_stex; - pos[cur_vertex].load3(mesh[i].mPos.mV); - tc[cur_vertex] = LLVector2(ss,tt); - norm[cur_vertex].clear(); - + ss = profile[mBeginS + s][2] - begin_stex; + + llassert(less_than_max_mag(mesh[i])); + mesh[i].store4a((F32*)(pos+cur_vertex)); + tc[cur_vertex].set(ss,tt); + cur_vertex++; } } + LL_CHECK_MEMORY - //get bounding box for this side - LLVector4a& face_min = mExtents[0]; - LLVector4a& face_max = mExtents[1]; + mCenter->clear(); - face_min = face_max = pos[0]; + LLVector4a* cur_pos = pos; + LLVector4a* end_pos = pos + mNumVertices; + + //get bounding box for this side + LLVector4a face_min; + LLVector4a face_max; + + face_min = face_max = *cur_pos++; + + while (cur_pos < end_pos) + { + update_min_max(face_min, face_max, *cur_pos++); + } + + mExtents[0] = face_min; + mExtents[1] = face_max; + + U32 tc_count = mNumVertices; + if (tc_count%2 == 1) + { //odd number of texture coordinates, duplicate last entry to padded end of array + tc_count++; + mTexCoords[mNumVertices] = mTexCoords[mNumVertices-1]; + } + + LLVector4a* cur_tc = (LLVector4a*) mTexCoords; + LLVector4a* end_tc = (LLVector4a*) (mTexCoords+tc_count); + + LLVector4a tc_min; + LLVector4a tc_max; + + tc_min = tc_max = *cur_tc++; - for (U32 i = 1; i < mNumVertices; ++i) + while (cur_tc < end_tc) { - update_min_max(face_min, face_max, pos[i]); + update_min_max(tc_min, tc_max, *cur_tc++); } + F32* minp = tc_min.getF32ptr(); + F32* maxp = tc_max.getF32ptr(); + + mTexCoordExtents[0].mV[0] = llmin(minp[0], minp[2]); + mTexCoordExtents[0].mV[1] = llmin(minp[1], minp[3]); + mTexCoordExtents[1].mV[0] = llmax(maxp[0], maxp[2]); + mTexCoordExtents[1].mV[1] = llmax(maxp[1], maxp[3]); + mCenter->setAdd(face_min, face_max); mCenter->mul(0.5f); @@ -7104,33 +6528,94 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } } + LL_CHECK_MEMORY + //clear normals - for (U32 i = 0; i < mNumVertices; i++) + F32* dst = (F32*) mNormals; + F32* end = (F32*) (mNormals+mNumVertices); + LLVector4a zero = LLVector4a::getZero(); + + while (dst < end) { - mNormals[i].clear(); + zero.store4a(dst); + dst += 4; } + LL_CHECK_MEMORY + //generate normals U32 count = mNumIndices/3; - for (U32 i = 0; i < count; i++) //for each triangle + LLVector4a* norm = mNormals; + + static LLAlignedArray triangle_normals; + triangle_normals.resize(count); + LLVector4a* output = triangle_normals.mArray; + LLVector4a* end_output = output+count; + + U16* idx = mIndices; + + while (output < end_output) { - const U16* idx = &(mIndices[i*3]); - - LLVector4a& v0 = *(pos+idx[0]); - LLVector4a& v1 = *(pos+idx[1]); - LLVector4a& v2 = *(pos+idx[2]); - - LLVector4a& n0 = *(norm+idx[0]); - LLVector4a& n1 = *(norm+idx[1]); - LLVector4a& n2 = *(norm+idx[2]); + LLVector4a b,v1,v2; + b.load4a((F32*) (pos+idx[0])); + v1.load4a((F32*) (pos+idx[1])); + v2.load4a((F32*) (pos+idx[2])); //calculate triangle normal - LLVector4a a, b, c; + LLVector4a a; - a.setSub(v0, v1); - b.setSub(v0, v2); - c.setCross3(a,b); + a.setSub(b, v1); + b.sub(v2); + + + LLQuad& vector1 = *((LLQuad*) &v1); + LLQuad& vector2 = *((LLQuad*) &v2); + + LLQuad& amQ = *((LLQuad*) &a); + LLQuad& bmQ = *((LLQuad*) &b); + + //v1.setCross3(t,v0); + //setCross3(const LLVector4a& a, const LLVector4a& b) + // Vectors are stored in memory in w, z, y, x order from high to low + // Set vector1 = { a[W], a[X], a[Z], a[Y] } + vector1 = _mm_shuffle_ps( amQ, amQ, _MM_SHUFFLE( 3, 0, 2, 1 )); + // Set vector2 = { b[W], b[Y], b[X], b[Z] } + vector2 = _mm_shuffle_ps( bmQ, bmQ, _MM_SHUFFLE( 3, 1, 0, 2 )); + // mQ = { a[W]*b[W], a[X]*b[Y], a[Z]*b[X], a[Y]*b[Z] } + vector2 = _mm_mul_ps( vector1, vector2 ); + // vector3 = { a[W], a[Y], a[X], a[Z] } + amQ = _mm_shuffle_ps( amQ, amQ, _MM_SHUFFLE( 3, 1, 0, 2 )); + // vector4 = { b[W], b[X], b[Z], b[Y] } + bmQ = _mm_shuffle_ps( bmQ, bmQ, _MM_SHUFFLE( 3, 0, 2, 1 )); + // mQ = { 0, a[X]*b[Y] - a[Y]*b[X], a[Z]*b[X] - a[X]*b[Z], a[Y]*b[Z] - a[Z]*b[Y] } + vector1 = _mm_sub_ps( vector2, _mm_mul_ps( amQ, bmQ )); + + v1.store4a((F32*) output); + + output++; + idx += 3; + } + + idx = mIndices; + + LLVector4a* src = triangle_normals.mArray; + + for (U32 i = 0; i < count; i++) //for each triangle + { + LLVector4a c; + c.load4a((F32*) (src++)); + + LLVector4a* n0p = norm+idx[0]; + LLVector4a* n1p = norm+idx[1]; + LLVector4a* n2p = norm+idx[2]; + + idx += 3; + + LLVector4a n0,n1,n2; + n0.load4a((F32*) n0p); + n1.load4a((F32*) n1p); + n2.load4a((F32*) n2p); n0.add(c); n1.add(c); @@ -7143,8 +6628,14 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) case 1: n1.add(c); break; case 2: n2.add(c); break; }; + + n0.store4a((F32*) n0p); + n1.store4a((F32*) n1p); + n2.store4a((F32*) n2p); } + LL_CHECK_MEMORY + // adjust normals based on wrapping and stitching LLVector4a top; @@ -7276,6 +6767,8 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } + LL_CHECK_MEMORY + return TRUE; } diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 1d3b0fe52f..5e43af92ec 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -37,7 +37,6 @@ class LLPath; template class LLOctreeNode; -class LLVector4a; class LLVolumeFace; class LLVolume; class LLVolumeTriangle; @@ -50,6 +49,8 @@ class LLVolumeTriangle; #include "v3math.h" #include "v3dmath.h" #include "v4math.h" +#include "llvector4a.h" +#include "llmatrix4a.h" #include "llquaternion.h" #include "llstrider.h" #include "v4coloru.h" @@ -194,6 +195,26 @@ const U8 LL_SCULPT_FLAG_MIRROR = 128; const S32 LL_SCULPT_MESH_MAX_FACES = 8; +template +class LLAlignedArray +{ +public: + T* mArray; + U32 mElementCount; + U32 mCapacity; + + LLAlignedArray(); + ~LLAlignedArray(); + + void push_back(const T& elem); + U32 size() const { return mElementCount; } + void resize(U32 size); + T* append(S32 N); + T& operator[](int idx); + const T& operator[](int idx) const; +}; + + class LLProfileParams { public: @@ -708,16 +729,16 @@ public: LLFaceID mFaceID; }; - std::vector mProfile; - std::vector mNormals; + LLAlignedArray mProfile; + //LLAlignedArray mNormals; std::vector mFaces; - std::vector mEdgeNormals; - std::vector mEdgeCenters; + + //LLAlignedArray mEdgeNormals; + //LLAlignedArray mEdgeCenters; friend std::ostream& operator<<(std::ostream &s, const LLProfile &profile); protected: - void genNormals(const LLProfileParams& params); static S32 getNumNGonPoints(const LLProfileParams& params, S32 sides, F32 offset=0.0f, F32 bevel = 0.0f, F32 ang_scale = 1.f, S32 split = 0); void genNGon(const LLProfileParams& params, S32 sides, F32 offset=0.0f, F32 bevel = 0.0f, F32 ang_scale = 1.f, S32 split = 0); @@ -741,13 +762,29 @@ protected: class LLPath { public: - struct PathPt + class PathPt { - LLVector3 mPos; - LLVector2 mScale; - LLQuaternion mRot; + public: + LLMatrix4a mRot; + LLVector4a mPos; + + LLVector4a mScale; F32 mTexT; - PathPt() { mPos.setVec(0,0,0); mTexT = 0; mScale.setVec(0,0); mRot.loadIdentity(); } + F32 pad[3]; //for alignment + PathPt() + { + mPos.clear(); + mTexT = 0; + mScale.clear(); + mRot.setRows(LLVector4a(1,0,0,0), + LLVector4a(0,1,0,0), + LLVector4a(0,0,1,0)); + + //distinguished data in the pad for debugging + pad[0] = 3.14159f; + pad[1] = -3.14159f; + pad[2] = 0.585f; + } }; public: @@ -779,7 +816,7 @@ public: friend std::ostream& operator<<(std::ostream &s, const LLPath &path); public: - std::vector mPath; + LLAlignedArray mPath; protected: BOOL mOpen; @@ -951,11 +988,7 @@ protected: ~LLVolume(); // use unref public: - struct Point - { - LLVector3 mPos; - }; - + struct FaceParams { LLFaceID mFaceID; @@ -978,8 +1011,8 @@ public: const LLProfile& getProfile() const { return *mProfilep; } LLPath& getPath() const { return *mPathp; } void resizePath(S32 length); - const std::vector& getMesh() const { return mMesh; } - const LLVector3& getMeshPt(const U32 i) const { return mMesh[i].mPos; } + const LLAlignedArray& getMesh() const { return mMesh; } + const LLVector4a& getMeshPt(const U32 i) const { return mMesh[i]; } void setDirty() { mPathp->setDirty(); mProfilep->setDirty(); } @@ -994,10 +1027,7 @@ public: S32 getSculptLevel() const { return mSculptLevel; } void setSculptLevel(S32 level) { mSculptLevel = level; } - S32 *getTriangleIndices(U32 &num_indices) const; - - // returns number of triangle indeces required for path/profile mesh - S32 getNumTriangleIndices() const; + static void getLoDTriangleCounts(const LLVolumeParams& params, S32* counts); S32 getNumTriangles(S32* vcount = NULL) const; @@ -1070,7 +1100,8 @@ public: LLVolumeParams mParams; LLPath *mPathp; LLProfile *mProfilep; - std::vector mMesh; + LLAlignedArray mMesh; + BOOL mGenerateSingleFace; typedef std::vector face_list_t; diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index 77a0cdffce..cd4718381b 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -683,30 +683,36 @@ void LLVolumeImplFlexible::doFlexibleUpdate() LLVector4(z_axis, 0.f), LLVector4(delta_pos, 1.f)); + LL_CHECK_MEMORY for (i=0; i<=num_render_sections; ++i) { new_point = &path->mPath[i]; LLVector3 pos = newSection[i].mPosition * rel_xform; LLQuaternion rot = mSection[i].mAxisRotation * newSection[i].mRotation * delta_rot; - - if (!mUpdated || (new_point->mPos-pos).magVec()/mVO->mDrawable->mDistanceWRTCamera > 0.001f) + + LLVector3 np(new_point->mPos.getF32ptr()); + + if (!mUpdated || (np-pos).magVec()/mVO->mDrawable->mDistanceWRTCamera > 0.001f) { - new_point->mPos = newSection[i].mPosition * rel_xform; + new_point->mPos.load3((newSection[i].mPosition * rel_xform).mV); mUpdated = FALSE; } - new_point->mRot = rot; - new_point->mScale = newSection[i].mScale; + new_point->mRot.loadu(LLMatrix3(rot)); + new_point->mScale.set(newSection[i].mScale.mV[0], newSection[i].mScale.mV[1], 0,1); new_point->mTexT = ((F32)i)/(num_render_sections); } - + LL_CHECK_MEMORY mLastSegmentRotation = parentSegmentRotation; } +static LLFastTimer::DeclareTimer FTM_FLEXI_PREBUILD("Flexi Prebuild"); + void LLVolumeImplFlexible::preRebuild() { if (!mUpdated) { + LLFastTimer t(FTM_FLEXI_PREBUILD); doFlexibleRebuild(); } } diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index b1706d9d35..b5543c4a37 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -739,7 +739,7 @@ class LLVolumeGeometryManager: public LLGeometryManager virtual void rebuildGeom(LLSpatialGroup* group); virtual void rebuildMesh(LLSpatialGroup* group); virtual void getGeometry(LLSpatialGroup* group); - void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector& faces, BOOL distance_sort = FALSE, BOOL batch_textures = FALSE); + void genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace** faces, U32 face_count, BOOL distance_sort = FALSE, BOOL batch_textures = FALSE); void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type); }; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 7adf18b6d0..597fb03526 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1051,8 +1051,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bo } } } - - + static LLCachedControl use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback"); bool cache_in_vram = use_transform_feedback && gTransformPositionProgram.mProgramObject && @@ -4242,11 +4241,20 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) mFaceList.clear(); - std::vector fullbright_faces; - std::vector bump_faces; - std::vector simple_faces; + const U32 MAX_FACE_COUNT = 4096; + + static LLFace** fullbright_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64); + static LLFace** bump_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64); + static LLFace** simple_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64); + static LLFace** alpha_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64); + + U32 fullbright_count = 0; + U32 bump_count = 0; + U32 simple_count = 0; + U32 alpha_count = 0; + - std::vector alpha_faces; + U32 useage = group->mSpatialPartition->mBufferUsage; U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcVertexSize(group->mSpatialPartition->mVertexDataMask); @@ -4257,6 +4265,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool emissive = false; + + { LLFastTimer t(FTM_REBUILD_VOLUME_FACE_LIST); @@ -4558,7 +4568,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { if (facep->canRenderAsMask()) { //can be treated as alpha mask - simple_faces.push_back(facep); + if (simple_count < MAX_FACE_COUNT) + { + simple_faces[simple_count++] = facep; + } } else { @@ -4566,7 +4579,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { //only treat as alpha in the pipeline if < 100% transparent drawablep->setState(LLDrawable::HAS_ALPHA); } - alpha_faces.push_back(facep); + if (alpha_count < MAX_FACE_COUNT) + { + alpha_faces[alpha_count++] = facep; + } } } else @@ -4581,33 +4597,51 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { if (te->getBumpmap()) { //needs normal + binormal - bump_faces.push_back(facep); + if (bump_count < MAX_FACE_COUNT) + { + bump_faces[bump_count++] = facep; + } } else if (te->getShiny() || !te->getFullbright()) { //needs normal - simple_faces.push_back(facep); + if (simple_count < MAX_FACE_COUNT) + { + simple_faces[simple_count++] = facep; + } } else { //doesn't need normal facep->setState(LLFace::FULLBRIGHT); - fullbright_faces.push_back(facep); + if (fullbright_count < MAX_FACE_COUNT) + { + fullbright_faces[fullbright_count++] = facep; + } } } else { if (te->getBumpmap() && LLPipeline::sRenderBump) { //needs normal + binormal - bump_faces.push_back(facep); + if (bump_count < MAX_FACE_COUNT) + { + bump_faces[bump_count++] = facep; + } } else if ((te->getShiny() && LLPipeline::sRenderBump) || !(te->getFullbright() || bake_sunlight)) { //needs normal - simple_faces.push_back(facep); + if (simple_count < MAX_FACE_COUNT) + { + simple_faces[simple_count++] = facep; + } } else { //doesn't need normal facep->setState(LLFace::FULLBRIGHT); - fullbright_faces.push_back(facep); + if (fullbright_count < MAX_FACE_COUNT) + { + fullbright_faces[fullbright_count++] = facep; + } } } } @@ -4657,17 +4691,17 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (batch_textures) { bump_mask |= LLVertexBuffer::MAP_BINORMAL; - genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, TRUE); - genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, FALSE, TRUE); - genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, FALSE); - genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, TRUE, TRUE); + genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, simple_count, FALSE, TRUE); + genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, fullbright_count, FALSE, TRUE); + genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, bump_count, FALSE, FALSE); + genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, alpha_count, TRUE, TRUE); } else { - genDrawInfo(group, simple_mask, simple_faces); - genDrawInfo(group, fullbright_mask, fullbright_faces); - genDrawInfo(group, bump_mask, bump_faces, FALSE, TRUE); - genDrawInfo(group, alpha_mask, alpha_faces, TRUE); + genDrawInfo(group, simple_mask, simple_faces, simple_count); + genDrawInfo(group, fullbright_mask, fullbright_faces, fullbright_count); + genDrawInfo(group, bump_mask, bump_faces, bump_count, FALSE, FALSE); + genDrawInfo(group, alpha_mask, alpha_faces, alpha_count, TRUE); } @@ -4699,6 +4733,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } } +static LLFastTimer::DeclareTimer FTM_REBUILD_MESH_FLUSH("Flush Mesh"); void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) { @@ -4708,11 +4743,14 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) LLFastTimer ftm(FTM_REBUILD_VOLUME_VB); LLFastTimer t(FTM_REBUILD_VOLUME_GEN_DRAW_INFO); //make sure getgeometryvolume shows up in the right place in timers - S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ; - group->mBuilt = 1.f; - std::set mapped_buffers; + S32 num_mapped_vertex_buffer = LLVertexBuffer::sMappedCount ; + + const U32 MAX_BUFFER_COUNT = 4096; + LLVertexBuffer* locked_buffer[MAX_BUFFER_COUNT]; + + U32 buffer_count = 0; for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) { @@ -4722,7 +4760,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) { LLVOVolume* vobj = drawablep->getVOVolume(); vobj->preRebuild(); - + if (drawablep->isState(LLDrawable::ANIMATED_CHILD)) { vobj->updateRelativeXform(true); @@ -4747,9 +4785,9 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) } - if (buff->isLocked()) + if (buff->isLocked() && buffer_count < MAX_BUFFER_COUNT) { - mapped_buffers.insert(buff); + locked_buffer[buffer_count++] = buff; } } } @@ -4765,21 +4803,24 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) } } - for (std::set::iterator iter = mapped_buffers.begin(); iter != mapped_buffers.end(); ++iter) { - (*iter)->flush(); - } - - // don't forget alpha - if(group != NULL && - !group->mVertexBuffer.isNull() && - group->mVertexBuffer->isLocked()) - { - group->mVertexBuffer->flush(); + LLFastTimer t(FTM_REBUILD_MESH_FLUSH); + for (LLVertexBuffer** iter = locked_buffer, ** end_iter = locked_buffer+buffer_count; iter != end_iter; ++iter) + { + (*iter)->flush(); + } + + // don't forget alpha + if(group != NULL && + !group->mVertexBuffer.isNull() && + group->mVertexBuffer->isLocked()) + { + group->mVertexBuffer->flush(); + } } //if not all buffers are unmapped - if(num_mapped_veretx_buffer != LLVertexBuffer::sMappedCount) + if(num_mapped_vertex_buffer != LLVertexBuffer::sMappedCount) { llwarns << "Not all mapped vertex buffers are unmapped!" << llendl ; for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) @@ -4839,7 +4880,7 @@ static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_RESIZE_VB("Resize VB"); -void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector& faces, BOOL distance_sort, BOOL batch_textures) +void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace** faces, U32 face_count, BOOL distance_sort, BOOL batch_textures) { LLFastTimer t(FTM_REBUILD_VOLUME_GEN_DRAW_INFO); @@ -4875,17 +4916,18 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: if (!distance_sort) { //sort faces by things that break batches - std::sort(faces.begin(), faces.end(), CompareBatchBreakerModified()); + std::sort(faces, faces+face_count, CompareBatchBreakerModified()); } else { //sort faces by distance - std::sort(faces.begin(), faces.end(), LLFace::CompareDistanceGreater()); + std::sort(faces, faces+face_count, LLFace::CompareDistanceGreater()); } } bool hud_group = group->isHUDGroup() ; - std::vector::iterator face_iter = faces.begin(); + LLFace** face_iter = faces; + LLFace** end_faces = faces+face_count; LLSpatialGroup::buffer_map_t buffer_map; @@ -4916,7 +4958,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: bool flexi = false; - while (face_iter != faces.end()) + while (face_iter != end_faces) { //pull off next face LLFace* facep = *face_iter; @@ -4945,10 +4987,13 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: flexi = flexi || facep->getViewerObject()->getVolume()->isUnique(); //sum up vertices needed for this render batch - std::vector::iterator i = face_iter; + LLFace** i = face_iter; ++i; - std::vector texture_list; + const U32 MAX_TEXTURE_COUNT = 32; + LLViewerTexture* texture_list[MAX_TEXTURE_COUNT]; + + U32 texture_count = 0; { LLFastTimer t(FTM_GEN_DRAW_INFO_FACE_SIZE); @@ -4956,12 +5001,15 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: { U8 cur_tex = 0; facep->setTextureIndex(cur_tex); - texture_list.push_back(tex); - + if (texture_count < MAX_TEXTURE_COUNT) + { + texture_list[texture_count++] = tex; + } + if (can_batch_texture(facep)) { //populate texture_list with any textures that can be batched //move i to the next unbatchable face - while (i != faces.end()) + while (i != end_faces) { facep = *i; @@ -4976,7 +5024,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: if (distance_sort) { //textures might be out of order, see if texture exists in current batch bool found = false; - for (U32 tex_idx = 0; tex_idx < texture_list.size(); ++tex_idx) + for (U32 tex_idx = 0; tex_idx < texture_count; ++tex_idx) { if (facep->getTexture() == texture_list[tex_idx]) { @@ -4988,7 +5036,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: if (!found) { - cur_tex = texture_list.size(); + cur_tex = texture_count; } } else @@ -5003,7 +5051,10 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: tex = facep->getTexture(); - texture_list.push_back(tex); + if (texture_count < MAX_TEXTURE_COUNT) + { + texture_list[texture_count++] = tex; + } } if (geom_count + facep->getGeomCount() > max_vertices) @@ -5026,7 +5077,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } else { - while (i != faces.end() && + while (i != end_faces && (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getTexture() == tex))) { facep = *i; -- cgit v1.2.3 From f061b2b90e34d74b9c6db3606babb0402473a24d Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Fri, 8 Mar 2013 15:31:37 -0800 Subject: Optimize interp code to elim hundreds of divides per frame and fix jitter bugs. --- indra/llcharacter/lleditingmotion.cpp | 5 +- indra/llcharacter/llheadrotmotion.cpp | 5 +- indra/llcharacter/llkeyframemotion.cpp | 7 +- indra/llcharacter/llkeyframewalkmotion.cpp | 9 +-- indra/llcharacter/llmotion.cpp | 5 +- indra/llcharacter/lltargetingmotion.cpp | 3 +- indra/llcommon/llcriticaldamp.cpp | 51 +++++--------- indra/llcommon/llcriticaldamp.h | 82 +++++++++++++++++++++- indra/llui/llbutton.cpp | 5 +- indra/llui/lllayoutstack.cpp | 12 ++-- indra/llui/llmenugl.cpp | 2 +- indra/llui/llscrollbar.cpp | 5 +- indra/llui/lltabcontainer.cpp | 3 +- indra/newview/llagentcamera.cpp | 23 ++++--- indra/newview/lldrawable.cpp | 106 +++++++++++++---------------- indra/newview/llfasttimerview.cpp | 4 +- indra/newview/llfloatercolorpicker.cpp | 5 +- indra/newview/llfloatersnapshot.cpp | 5 +- indra/newview/llfolderviewitem.cpp | 7 +- indra/newview/llfollowcam.cpp | 17 +++-- indra/newview/llhudnametag.cpp | 3 +- indra/newview/llmaniprotate.cpp | 18 ++--- indra/newview/llmanipscale.cpp | 5 +- indra/newview/llmaniptranslate.cpp | 13 ++-- indra/newview/llnetmap.cpp | 3 +- indra/newview/llselectmgr.cpp | 9 +++ indra/newview/lltexturectrl.cpp | 4 +- indra/newview/llviewerdisplay.cpp | 3 +- indra/newview/llvoavatar.cpp | 12 ++-- indra/newview/llvovolume.cpp | 5 +- indra/newview/llworldmapview.cpp | 6 +- 31 files changed, 259 insertions(+), 183 deletions(-) (limited to 'indra') diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp index 0d0b85ba60..35508e0a87 100644 --- a/indra/llcharacter/lleditingmotion.cpp +++ b/indra/llcharacter/lleditingmotion.cpp @@ -38,8 +38,6 @@ // Constants //----------------------------------------------------------------------------- const LLQuaternion EDIT_MOTION_WRIST_ROTATION(F_PI_BY_TWO * 0.7f, LLVector3(1.0f, 0.0f, 0.0f)); -const F32 TARGET_LAG_HALF_LIFE = 0.1f; // half-life of IK targeting -const F32 TORSO_LAG_HALF_LIFE = 0.2f; const F32 MAX_TIME_DELTA = 2.f; //max two seconds a frame for calculating interpolation S32 LLEditingMotion::sHandPose = LLHandMotion::HAND_POSE_RELAXED_R; @@ -232,7 +230,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) mIKSolver.solve(); // use blending... - F32 slerp_amt = LLCriticalDamp::getInterpolant(TARGET_LAG_HALF_LIFE); + F32 slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTargetLagHalfLife); shoulderRot = slerp(slerp_amt, mShoulderJoint.getRotation(), shoulderRot); elbowRot = slerp(slerp_amt, mElbowJoint.getRotation(), elbowRot); @@ -258,3 +256,4 @@ void LLEditingMotion::onDeactivate() // End + diff --git a/indra/llcharacter/llheadrotmotion.cpp b/indra/llcharacter/llheadrotmotion.cpp index 15a58a8389..1eddd0f449 100644 --- a/indra/llcharacter/llheadrotmotion.cpp +++ b/indra/llcharacter/llheadrotmotion.cpp @@ -182,8 +182,8 @@ BOOL LLHeadRotMotion::onUpdate(F32 time, U8* joint_mask) LLQuaternion currentRootRotWorld = mRootJoint->getWorldRotation(); LLQuaternion currentInvRootRotWorld = ~currentRootRotWorld; - F32 head_slerp_amt = LLCriticalDamp::getInterpolant(HEAD_LOOKAT_LAG_HALF_LIFE); - F32 torso_slerp_amt = LLCriticalDamp::getInterpolant(TORSO_LOOKAT_LAG_HALF_LIFE); + F32 head_slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaHeadLookAtLagHalfLife); + F32 torso_slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTorsoLookAtLagHalfLife); LLVector3* targetPos = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); @@ -530,3 +530,4 @@ void LLEyeMotion::onDeactivate() } // End + diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index c6f45bffa2..f394cf2635 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -1031,11 +1031,11 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 if (constraint->mSharedData->mChainLength != 0 && dist_vec_squared(root_pos, target_pos) * 0.95f > constraint->mTotalLength * constraint->mTotalLength) { - constraint->mWeight = lerp(constraint->mWeight, 0.f, LLCriticalDamp::getInterpolant(0.1f)); + constraint->mWeight = lerp(constraint->mWeight, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); } else { - constraint->mWeight = lerp(constraint->mWeight, 1.f, LLCriticalDamp::getInterpolant(0.3f)); + constraint->mWeight = lerp(constraint->mWeight, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaSmallish)); } F32 weight = constraint->mWeight * ((shared_data->mEaseOutStopTime == 0.f) ? 1.f : @@ -1084,7 +1084,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 F32 time_constant = 1.f / clamp_rescale(constraint->mFixupDistanceRMS, 0.f, 0.5f, 0.2f, 8.f); // llinfos << "Interpolant " << LLCriticalDamp::getInterpolant(time_constant, FALSE) << " and fixup distance " << constraint->mFixupDistanceRMS << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << llendl; positions[joint_num] = lerp(positions[joint_num], kinematic_position, - LLCriticalDamp::getInterpolant(time_constant, FALSE)); + LLCriticalDamp::getInterpolant(time_constant)); } S32 iteration_count; @@ -2304,3 +2304,4 @@ LLKeyframeMotion::JointConstraint::~JointConstraint() } // End + diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp index d52eb89a5c..d17c123e54 100644 --- a/indra/llcharacter/llkeyframewalkmotion.cpp +++ b/indra/llcharacter/llkeyframewalkmotion.cpp @@ -287,7 +287,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) F32 desired_speed_multiplier = llclamp(speed / foot_speed, min_speed_multiplier, ANIM_SPEED_MAX); // blend towards new speed adjustment value - F32 new_speed_adjust = lerp(mAdjustedSpeed, desired_speed_multiplier, LLCriticalDamp::getInterpolant(SPEED_ADJUST_TIME_CONSTANT)); + F32 new_speed_adjust = lerp(mAdjustedSpeed, desired_speed_multiplier, LLCriticalDamp::getInterpolant(InterpDeltaSpeedAdjustTime)); // limit that rate at which the speed adjustment changes F32 speedDelta = llclamp(new_speed_adjust - mAdjustedSpeed, -SPEED_ADJUST_MAX_SEC * delta_time, SPEED_ADJUST_MAX_SEC * delta_time); @@ -305,8 +305,8 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) { // standing/turning // damp out speed adjustment to 0 - mAnimSpeed = lerp(mAnimSpeed, 1.f, LLCriticalDamp::getInterpolant(0.2f)); - //mPelvisOffset = lerp(mPelvisOffset, LLVector3::zero, LLCriticalDamp::getInterpolant(0.2f)); + mAnimSpeed = lerp(mAnimSpeed, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaSmall)); + //mPelvisOffset = lerp(mPelvisOffset, LLVector3::zero, LLCriticalDamp::getInterpolant(InterpDeltaSmall)); } // broadcast walk speed change @@ -383,10 +383,11 @@ BOOL LLFlyAdjustMotion::onUpdate(F32 time, U8* joint_mask) F32 target_roll = llclamp(ang_vel.mV[VZ], -4.f, 4.f) * roll_factor; // roll is critically damped interpolation between current roll and angular velocity-derived target roll - mRoll = lerp(mRoll, target_roll, LLCriticalDamp::getInterpolant(0.1f)); + mRoll = lerp(mRoll, target_roll, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); LLQuaternion roll(mRoll, LLVector3(0.f, 0.f, 1.f)); mPelvisState->setRotation(roll); return TRUE; } + diff --git a/indra/llcharacter/llmotion.cpp b/indra/llcharacter/llmotion.cpp index 2551f125d0..d4db0d84c9 100644 --- a/indra/llcharacter/llmotion.cpp +++ b/indra/llcharacter/llmotion.cpp @@ -73,7 +73,7 @@ void LLMotion::fadeOut() { if (mFadeWeight > 0.01f) { - mFadeWeight = lerp(mFadeWeight, 0.f, LLCriticalDamp::getInterpolant(0.15f)); + mFadeWeight = lerp(mFadeWeight, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaFadeWeight)); } else { @@ -88,7 +88,7 @@ void LLMotion::fadeIn() { if (mFadeWeight < 0.99f) { - mFadeWeight = lerp(mFadeWeight, 1.f, LLCriticalDamp::getInterpolant(0.15f)); + mFadeWeight = lerp(mFadeWeight, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaFadeWeight)); } else { @@ -169,3 +169,4 @@ BOOL LLMotion::canDeprecate() } // End + diff --git a/indra/llcharacter/lltargetingmotion.cpp b/indra/llcharacter/lltargetingmotion.cpp index 489aef923c..6ce6ce31d6 100644 --- a/indra/llcharacter/lltargetingmotion.cpp +++ b/indra/llcharacter/lltargetingmotion.cpp @@ -106,7 +106,7 @@ BOOL LLTargetingMotion::onActivate() //----------------------------------------------------------------------------- BOOL LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) { - F32 slerp_amt = LLCriticalDamp::getInterpolant(TORSO_TARGET_HALF_LIFE); + F32 slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTorsoTargetLagHalfLife); LLVector3 target; LLVector3* lookAtPoint = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); @@ -169,3 +169,4 @@ void LLTargetingMotion::onDeactivate() // End + diff --git a/indra/llcommon/llcriticaldamp.cpp b/indra/llcommon/llcriticaldamp.cpp index 87d79b1ee0..27fef0e6dc 100644 --- a/indra/llcommon/llcriticaldamp.cpp +++ b/indra/llcommon/llcriticaldamp.cpp @@ -32,8 +32,9 @@ // static members //----------------------------------------------------------------------------- LLFrameTimer LLCriticalDamp::sInternalTimer; -std::map LLCriticalDamp::sInterpolants; F32 LLCriticalDamp::sTimeDelta; +F32 LLCriticalDamp::sInterpolants[kNumCachedInterpolants]; +F32 LLCriticalDamp::sInterpolatedValues[kNumCachedInterpolants]; //----------------------------------------------------------------------------- // LLCriticalDamp() @@ -41,6 +42,17 @@ F32 LLCriticalDamp::sTimeDelta; LLCriticalDamp::LLCriticalDamp() { sTimeDelta = 0.f; + + // Init the core interpolant values (to which many, many enums map) + // + setInterpolantConstant(InterpDelta_0_025, 0.025f); + setInterpolantConstant(InterpDelta_0_05, 0.05f ); + setInterpolantConstant(InterpDelta_0_06, 0.06f); + setInterpolantConstant(InterpDelta_0_10, 0.10f); + setInterpolantConstant(InterpDelta_0_15, 0.15f); + setInterpolantConstant(InterpDelta_0_20, 0.20f); + setInterpolantConstant(InterpDelta_0_25, 0.25f); + setInterpolantConstant(InterpDelta_0_30, 0.30f); } // static @@ -51,39 +63,10 @@ void LLCriticalDamp::updateInterpolants() { sTimeDelta = sInternalTimer.getElapsedTimeAndResetF32(); - F32 time_constant; - - for (std::map::iterator iter = sInterpolants.begin(); - iter != sInterpolants.end(); iter++) - { - time_constant = iter->first; - F32 new_interpolant = 1.f - pow(2.f, -sTimeDelta / time_constant); - new_interpolant = llclamp(new_interpolant, 0.f, 1.f); - sInterpolants[time_constant] = new_interpolant; - } -} - -//----------------------------------------------------------------------------- -// getInterpolant() -//----------------------------------------------------------------------------- -F32 LLCriticalDamp::getInterpolant(const F32 time_constant, BOOL use_cache) -{ - if (time_constant == 0.f) + U32 i; + for (i = 0; i < kNumCachedInterpolants; i++) { - return 1.f; + sInterpolatedValues[i] = llclamp(sTimeDelta / sInterpolants[ i], 0.0f, 1.0f); } - - if (use_cache && sInterpolants.count(time_constant)) - { - return sInterpolants[time_constant]; - } - - F32 interpolant = 1.f - pow(2.f, -sTimeDelta / time_constant); - interpolant = llclamp(interpolant, 0.f, 1.f); - if (use_cache) - { - sInterpolants[time_constant] = interpolant; - } - - return interpolant; } + diff --git a/indra/llcommon/llcriticaldamp.h b/indra/llcommon/llcriticaldamp.h index 52f052ae25..19a2ddb77a 100644 --- a/indra/llcommon/llcriticaldamp.h +++ b/indra/llcommon/llcriticaldamp.h @@ -32,22 +32,98 @@ #include "llframetimer.h" +// These enums each represent one fixed-time delta value +// that we interpolate once given the actual sTimeDelta time +// that has passed. This allows us to calculate the interp portion +// of those values once and then look them up repeatedly per frame. +// +enum InterpDelta +{ + InterpDelta_0_025, // 0.025 + InterpDeltaTeenier = InterpDelta_0_025, + InterpDeltaFolderOpenTime = InterpDelta_0_025, + InterpDeltaFolderCloseTime = InterpDelta_0_025, + InterpDeltaCameraFocusHalfLife = InterpDelta_0_025, // USED TO BE ZERO.... + + InterpDelta_0_05, // 0.05 + InterpDeltaTeeny = InterpDelta_0_05, + + InterpDelta_0_06, // 0.06 + InterpDeltaObjectDampingConstant = InterpDelta_0_06, + InterpDeltaCameraZoomHalfLife = InterpDelta_0_06, + InterpDeltaFovZoomHalfLife = InterpDelta_0_06, + InterpDeltaManipulatorScaleHalfLife = InterpDelta_0_06, + InterpDeltaContextFadeTime = InterpDelta_0_06, + + InterpDelta_0_10, // 0.10 + InterpDeltaSmaller = InterpDelta_0_10, + InterpDeltaTargetLagHalfLife = InterpDelta_0_10, + InterpDeltaSpeedAdjustTime = InterpDelta_0_10, + + InterpDelta_0_15, // 0.15 + InterpDeltaFadeWeight = InterpDelta_0_15, + InterpDeltaHeadLookAtLagHalfLife = InterpDelta_0_15, + + InterpDelta_0_20, // 0.20 + InterpDeltaSmall = InterpDelta_0_20, + InterpDeltaTorsoLagHalfLife = InterpDelta_0_20, + InterpDeltaPositionDampingTC = InterpDelta_0_20, + + InterpDelta_0_25, // 0.25 + InterpDeltaCameraLagHalfLife = InterpDelta_0_25, + InterpDeltaTorsoTargetLagHalfLife = InterpDelta_0_25, + InterpDeltaTorsoLookAtLagHalfLife = InterpDelta_0_25, + + InterpDelta_0_30, // 0.3 + InterpDeltaSmallish = InterpDelta_0_30, + + // Dynamically set interpolants which use setInterpolantConstant + // + InterpDeltaCameraSmoothingHalfLife, + InterpDeltaBehindnessLag, + InterpDeltaFocusLag, + InterpDeltaPositionLag, + InterpDeltaOpenTime, + InterpDeltaCloseTime, + + kNumCachedInterpolants +}; + class LL_COMMON_API LLCriticalDamp { public: LLCriticalDamp(); - // MANIPULATORS + // Updates all the known interp delta values for fast lookup in calls to getInterpolant(InterpDelta) + // static void updateInterpolants(); + static inline void setInterpolantConstant(InterpDelta whichDelta, const F32 time_constant) + { + llassert(whichDelta < kNumCachedInterpolants); + sInterpolants[whichDelta] = time_constant; + } + // ACCESSORS - static F32 getInterpolant(const F32 time_constant, BOOL use_cache = TRUE); + static inline F32 getInterpolant(InterpDelta whichDelta) + { + llassert(whichDelta < kNumCachedInterpolants); + return sInterpolatedValues[whichDelta]; + } + + static inline F32 getInterpolant(const F32 time_constant) + { + return llclamp((sTimeDelta / time_constant), 0.0f, 1.0f); + } protected: static LLFrameTimer sInternalTimer; // frame timer for calculating deltas - static std::map sInterpolants; + //static std::map sInterpolants; + static F32 sInterpolants[kNumCachedInterpolants]; + static F32 sInterpolatedValues[kNumCachedInterpolants]; static F32 sTimeDelta; }; #endif // LL_LLCRITICALDAMP_H + diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 705fe16559..3dfcb3ffa1 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -758,11 +758,11 @@ void LLButton::draw() mCurGlowStrength = lerp(mCurGlowStrength, mFlashing ? (flash? 1.0 : 0.0) : mHoverGlowStrength, - LLCriticalDamp::getInterpolant(0.05f)); + LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); } else { - mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f)); + mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); } // Draw button image, if available. @@ -1247,3 +1247,4 @@ BOOL LLButton::handleDoubleClick(S32 x, S32 y, MASK mask) // just treat a double click as a second click return handleMouseDown(x, y, mask); } + diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 4c730286da..c93f538570 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -229,7 +229,10 @@ LLLayoutStack::LLLayoutStack(const LLLayoutStack::Params& p) mOpenTimeConstant(p.open_time_constant), mCloseTimeConstant(p.close_time_constant), mResizeBarOverlap(p.resize_bar_overlap) -{} +{ + LLCriticalDamp::setInterpolantConstant(InterpDeltaCloseTime, mCloseTimeConstant); + LLCriticalDamp::setInterpolantConstant(InterpDeltaOpenTime, mOpenTimeConstant); +} LLLayoutStack::~LLLayoutStack() { @@ -592,7 +595,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(mOpenTimeConstant)); + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaOpenTime)); if (panelp->mVisibleAmt > 0.99f) { panelp->mVisibleAmt = 1.f; @@ -617,7 +620,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaCloseTime)); if (panelp->mVisibleAmt < 0.001f) { panelp->mVisibleAmt = 0.f; @@ -644,7 +647,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); + panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLCriticalDamp::getInterpolant(InterpDeltaCloseTime)); } if (llabs(panelp->mCollapseAmt - collapse_state) < 0.001f) @@ -855,3 +858,4 @@ void LLLayoutStack::updateResizeBarLimits() previous_visible_panelp = visible_panelp; } } + diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index cd6cc6a75e..f142be885d 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -3673,7 +3673,7 @@ void LLTearOffMenu::draw() if (getRect().getHeight() != mTargetHeight) { // animate towards target height - reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(0.05f)))); + reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)))); } LLFloater::draw(); } diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index 5d3bf7a670..d65b4431a8 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -493,11 +493,11 @@ void LLScrollbar::draw() BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y)); if (hovered) { - mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f)); + mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); } else { - mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f)); + mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); } // Draw background and thumb. @@ -642,3 +642,4 @@ void LLScrollbar::onLineDownBtnPressed( const LLSD& data ) { changeLine( mStepSize, TRUE ); } + diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 5fc2cc350d..1e64cd0df8 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -406,7 +406,7 @@ void LLTabContainer::draw() } } - setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(0.08f))); + setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(InterpDeltaTeeny))); BOOL has_scroll_arrows = !getTabsHidden() && ((mMaxScrollPos > 0) || (mScrollPosPixels > 0)); if (!mIsVertical) @@ -2046,3 +2046,4 @@ void LLTabContainer::commitHoveredButton(S32 x, S32 y) } } } + diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 9025c7af8b..a40d9cd318 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -179,7 +179,7 @@ LLAgentCamera::LLAgentCamera() : clearGeneralKeys(); clearOrbitKeys(); - clearPanKeys(); + clearPanKeys(); } // Requires gSavedSettings to be initialized. @@ -192,6 +192,9 @@ void LLAgentCamera::init() mDrawDistance = gSavedSettings.getF32("RenderFarClip"); + const F32 SMOOTHING_HALF_LIFE = 0.02f; + LLCriticalDamp::setInterpolantConstant(InterpDeltaCameraSmoothingHalfLife, gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE); + LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW); // Leave at 0.1 meters until we have real near clip management LLViewerCamera::getInstance()->setNear(0.1f); @@ -337,7 +340,7 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) LLVector3 agent_at_axis = gAgent.getAtAxis(); agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector()); agent_at_axis.normalize(); - gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); + gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(InterpDeltaSmall))); } setFocusOnAvatar(TRUE, ANIMATE); @@ -1246,7 +1249,7 @@ void LLAgentCamera::updateCamera() gAgentCamera.clearPanKeys(); // lerp camera focus offset - mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(CAMERA_FOCUS_HALF_LIFE)); + mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(InterpDeltaCameraFocusHalfLife)); if ( mCameraMode == CAMERA_MODE_FOLLOW ) { @@ -1361,10 +1364,8 @@ void LLAgentCamera::updateCamera() mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode; if (cameraThirdPerson() && !mCameraSmoothingStop) - { - const F32 SMOOTHING_HALF_LIFE = 0.02f; - - F32 smoothing = LLCriticalDamp::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE); + { + F32 smoothing = LLCriticalDamp::getInterpolant(InterpDeltaCameraSmoothingHalfLife); if (!mFocusObject) // we differentiate on avatar mode { @@ -1394,7 +1395,7 @@ void LLAgentCamera::updateCamera() } - mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(FOV_ZOOM_HALF_LIFE)); + mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(InterpDeltaFovZoomHalfLife)); // llinfos << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << llendl; @@ -1809,7 +1810,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) if (mTargetCameraDistance != mCurrentCameraDistance) { - F32 camera_lerp_amt = LLCriticalDamp::getInterpolant(CAMERA_ZOOM_HALF_LIFE); + F32 camera_lerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaCameraZoomHalfLife); mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt); } @@ -1827,7 +1828,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) if (isAgentAvatarValid()) { LLVector3d camera_lag_d; - F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); + F32 lag_interp = LLCriticalDamp::getInterpolant(InterpDeltaCameraLagHalfLife); LLVector3 target_lag; LLVector3 vel = gAgent.getVelocity(); @@ -1872,7 +1873,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) } else { - mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(0.15f)); + mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(InterpDeltaCameraLagHalfLife)); } camera_lag_d.setVec(mCameraLag); diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index d29181a3ce..dc0e256ebb 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -492,97 +492,83 @@ F32 LLDrawable::updateXform(BOOL undamped) BOOL damped = !undamped; // Position - LLVector3 old_pos(mXform.getPosition()); - LLVector3 target_pos; - if (mXform.isRoot()) - { - // get root position in your agent's region - target_pos = mVObjp->getPositionAgent(); - } - else - { - // parent-relative position - target_pos = mVObjp->getPosition(); - } - + LLVector3 old_pos = mXform.getPosition(); + + // get agent position or parent-relative position as appropriate + // + LLVector3 target_pos = mXform.isRoot() ? mVObjp->getPositionAgent() : mVObjp->getPosition(); + // Rotation LLQuaternion old_rot(mXform.getRotation()); LLQuaternion target_rot = mVObjp->getRotation(); + //scaling LLVector3 target_scale = mVObjp->getScale(); LLVector3 old_scale = mCurrentScale; LLVector3 dest_scale = target_scale; - - // Damping - F32 dist_squared = 0.f; - F32 camdist2 = (mDistanceWRTCamera * mDistanceWRTCamera); + LLVector3 scale_vec = old_scale-target_scale; + + static const F32 dot_threshold = 1.0f - FLT_EPSILON; + + F32 dist_squared = dist_vec_squared(old_pos, target_pos); + bool translated = dist_squared > 0.0f; + bool rotated = !mVObjp->getAngularVelocity().isExactlyZero() || (dot(old_rot, target_rot) < dot_threshold); + bool scaled = (scale_vec * scale_vec) > MIN_INTERPOLATE_DISTANCE_SQUARED; + + // Damping if (damped && isVisible()) { - F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); + F32 lerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaObjectDampingConstant); LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); - dist_squared = dist_vec_squared(new_pos, target_pos); + dist_squared = dist_vec_squared(new_pos, old_pos); LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); - // FIXME: This can be negative! It is be possible for some rots to 'cancel out' pos or size changes. - dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; + dist_squared += fabs(1.f - dot(new_rot, old_rot)) * 10.f; LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); - dist_squared += dist_vec_squared(new_scale, target_scale); + dist_squared += dist_vec_squared(new_scale, old_scale); - if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && - (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) + // If our lerp isn't moving too far, substitue the lerp'd pos for our target for this frame + // + if (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED) { // interpolate target_pos = new_pos; target_rot = new_rot; target_scale = new_scale; } - else if (mVObjp->getAngularVelocity().isExactlyZero()) + else { - // snap to final position (only if no target omega is applied) - dist_squared = 0.0f; - if (getVOVolume() && !isRoot()) - { //child prim snapping to some position, needs a rebuild - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); - } + llinfos << "skipping update due to overly large lerp" << llendl; } } - else - { - // The following fixes MAINT-1742 but breaks vehicles similar to MAINT-2275 - // dist_squared = dist_vec_squared(old_pos, target_pos); - // The following fixes MAINT-2247 but causes MAINT-2275 - //dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; - //dist_squared += dist_vec_squared(old_scale, target_scale); - } + if (translated || rotated || scaled) + { + if (scaled) + { + mCurrentScale = target_scale; + } - LLVector3 vec = mCurrentScale-target_scale; - - if (vec*vec > MIN_INTERPOLATE_DISTANCE_SQUARED) - { //scale change requires immediate rebuild - mCurrentScale = target_scale; - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); - } - else if (!isRoot() && - (!mVObjp->getAngularVelocity().isExactlyZero() || - dist_squared > 0.f)) - { //child prim moving relative to parent, tag as needing to be rendered atomically and rebuild dist_squared = 1.f; //keep this object on the move list - if (!isState(LLDrawable::ANIMATED_CHILD)) + + //child prim moving relative to parent, tag as needing to be rendered atomically + // + if (!isRoot() && !isState(LLDrawable::ANIMATED_CHILD)) { setState(LLDrawable::ANIMATED_CHILD); - gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); - mVObjp->dirtySpatialGroup(); } + + // Mark any components that need to be rebuilt based on what change transpired + // + if (!rotated && !scaled) + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + else + gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); + + mVObjp->dirtySpatialGroup(); } - else if (!isRoot() - && ( dist_vec_squared(old_pos, target_pos) > 0.f - || (1.f - dot(old_rot, target_rot)) > 0.f)) - { // update child prims moved from LSL - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); - } else if (!getVOVolume() && !isAvatar()) { movePartition(); @@ -781,7 +767,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) } pos -= camera.getOrigin(); - mDistanceWRTCamera = llround(pos.magVec(), 0.01f); + mDistanceWRTCamera = 20.0f;//llround(pos.magVec(), 0.01f); mVObjp->updateLOD(); } } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index e7a3f9b390..643ce63f29 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -940,7 +940,7 @@ void LLFastTimerView::draw() } //interpolate towards new maximum - last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); + last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); if (last_max - cur_max <= 1 || cur_max - last_max <= 1) { last_max = cur_max; @@ -948,7 +948,7 @@ void LLFastTimerView::draw() F32 alpha_target = last_max > cur_max ? llmin((F32) last_max/ (F32) cur_max - 1.f,1.f) : llmin((F32) cur_max/ (F32) last_max - 1.f,1.f); - alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); + alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); if (mHoverID != NULL) { diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index d6ebe44daa..10d31df22c 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -525,11 +525,11 @@ void LLFloaterColorPicker::draw() if (gFocusMgr.childHasMouseCapture(getDragHandle())) { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); + mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); } else { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); + mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); } mPipetteBtn->setToggleState(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); @@ -1113,3 +1113,4 @@ void LLFloaterColorPicker::stopUsingPipette() LLToolMgr::getInstance()->clearTransientTool(); } } + diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index d8d62e5bbb..103eaace88 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -478,7 +478,7 @@ void LLSnapshotLivePreview::draw() { if (mFlashAlpha < 1.f) { - mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(0.02f)); + mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); } else { @@ -487,7 +487,7 @@ void LLSnapshotLivePreview::draw() } else { - mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(0.15f)); + mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaSmallish) * 0.5f); } // Draw shining animation if appropriate. @@ -2500,3 +2500,4 @@ BOOL LLSnapshotFloaterView::handleHover(S32 x, S32 y, MASK mask) } return TRUE; } + diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 3aa16b4413..23241b57c4 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -1293,7 +1293,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) // animate current height towards target height if (llabs(mCurHeight - mTargetHeight) > 1.f) { - mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(mIsOpen ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT)); + mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(mIsOpen ? InterpDeltaFolderOpenTime : InterpDeltaFolderCloseTime)); requestArrange(); @@ -2538,11 +2538,11 @@ void LLFolderViewFolder::draw() } else if (mIsOpen) { - mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(0.04f)); + mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); } else { - mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(0.025f)); + mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); } bool possibly_has_children = false; @@ -2899,3 +2899,4 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde } } } + diff --git a/indra/newview/llfollowcam.cpp b/indra/newview/llfollowcam.cpp index b670af1782..a3c1996512 100644 --- a/indra/newview/llfollowcam.cpp +++ b/indra/newview/llfollowcam.cpp @@ -148,14 +148,16 @@ LLFollowCamParams::~LLFollowCamParams() { } //--------------------------------------------------------- void LLFollowCamParams::setPositionLag( F32 p ) { - mPositionLag = llclamp(p, FOLLOW_CAM_MIN_POSITION_LAG, FOLLOW_CAM_MAX_POSITION_LAG); + mPositionLag = llclamp(p, FOLLOW_CAM_MIN_POSITION_LAG, FOLLOW_CAM_MAX_POSITION_LAG); + LLCriticalDamp::setInterpolantConstant(InterpDeltaPositionLag, mPositionLag); } //--------------------------------------------------------- void LLFollowCamParams::setFocusLag( F32 f ) { - mFocusLag = llclamp(f, FOLLOW_CAM_MIN_FOCUS_LAG, FOLLOW_CAM_MAX_FOCUS_LAG); + mFocusLag = llclamp(f, FOLLOW_CAM_MIN_FOCUS_LAG, FOLLOW_CAM_MAX_FOCUS_LAG); + LLCriticalDamp::setInterpolantConstant(InterpDeltaFocusLag, mFocusLag); } @@ -184,6 +186,7 @@ void LLFollowCamParams::setPitch( F32 p ) void LLFollowCamParams::setBehindnessLag( F32 b ) { mBehindnessLag = llclamp(b, FOLLOW_CAM_MIN_BEHINDNESS_LAG, FOLLOW_CAM_MAX_BEHINDNESS_LAG); + LLCriticalDamp::setInterpolantConstant(InterpDeltaBehindnessLag, mBehindnessLag); } //--------------------------------------------------------- @@ -328,11 +331,11 @@ void LLFollowCam::update() F32 force = focusOffsetDistance - focusThresholdNormalizedByDistance; */ - F32 focusLagLerp = LLCriticalDamp::getInterpolant( mFocusLag ); + F32 focusLagLerp = LLCriticalDamp::getInterpolant(InterpDeltaFocusLag); focus_pt_agent = lerp( focus_pt_agent, whereFocusWantsToBe, focusLagLerp ); mSimulatedFocusGlobal = gAgent.getPosGlobalFromAgent(focus_pt_agent); } - mRelativeFocus = lerp(mRelativeFocus, (focus_pt_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(0.05f)); + mRelativeFocus = lerp(mRelativeFocus, (focus_pt_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); }// if focus is not locked --------------------------------------------- @@ -415,7 +418,7 @@ void LLFollowCam::update() //------------------------------------------------------------------------------------------------- if ( distanceFromPositionToIdealPosition > mPositionThreshold ) { - F32 positionPullLerp = LLCriticalDamp::getInterpolant( mPositionLag ); + F32 positionPullLerp = LLCriticalDamp::getInterpolant(InterpDeltaPositionLag); simulated_pos_agent = lerp( simulated_pos_agent, whereCameraPositionWantsToBe, positionPullLerp ); } @@ -435,7 +438,7 @@ void LLFollowCam::update() updateBehindnessConstraint(gAgent.getPosAgentFromGlobal(mSimulatedFocusGlobal), simulated_pos_agent); mSimulatedPositionGlobal = gAgent.getPosGlobalFromAgent(simulated_pos_agent); - mRelativePos = lerp(mRelativePos, (simulated_pos_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(0.05f)); + mRelativePos = lerp(mRelativePos, (simulated_pos_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); } // if position is not locked ----------------------------------------------------------- @@ -490,7 +493,7 @@ BOOL LLFollowCam::updateBehindnessConstraint(LLVector3 focus, LLVector3& cam_pos if ( cameraOffsetAngle > mBehindnessMaxAngle ) { - F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLCriticalDamp::getInterpolant(mBehindnessLag); + F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLCriticalDamp::getInterpolant(InterpDeltaBehindnessLag); cam_position = focus + horizontalSubjectBack * (slerp(fraction, camera_offset_rotation, LLQuaternion::DEFAULT)); cam_position.mV[VZ] = cameraZ; // clamp z value back to what it was before we started messing with it constraint_active = TRUE; diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index 482294c8a6..b94681b340 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -980,7 +980,7 @@ void LLHUDNameTag::updateAll() // { // continue; // } - (*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(POSITION_DAMPING_TC)); + (*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(InterpDeltaPositionDampingTC)); } } @@ -1083,3 +1083,4 @@ F32 LLHUDNameTag::LLHUDTextSegment::getWidth(const LLFontGL* font) return width; } } + diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp index 826e8d560a..748ac7a16e 100644 --- a/indra/newview/llmaniprotate.cpp +++ b/indra/newview/llmaniprotate.cpp @@ -240,7 +240,7 @@ void LLManipRotate::render() if (mManipPart == LL_ROT_Z) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); gGL.pushMatrix(); { // selected part @@ -251,7 +251,7 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_Y) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); gGL.pushMatrix(); { gGL.rotatef( 90.f, 1.f, 0.f, 0.f ); @@ -262,7 +262,7 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_X) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); gGL.pushMatrix(); { gGL.rotatef( 90.f, 0.f, 1.f, 0.f ); @@ -273,13 +273,13 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_ROLL) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); } else if (mManipPart == LL_NO_PART) { if (mHighlightedPart == LL_NO_PART) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); } LLGLEnable cull_face(GL_CULL_FACE); @@ -294,7 +294,7 @@ void LLManipRotate::render() { if (mHighlightedPart == LL_ROT_Z) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); gGL.scalef(mManipulatorScales.mV[VZ], mManipulatorScales.mV[VZ], mManipulatorScales.mV[VZ]); // hovering over part gl_ring( mRadiusMeters, width_meters, LLColor4( 0.f, 0.f, 1.f, 1.f ), LLColor4( 0.f, 0.f, 1.f, 0.5f ), CIRCLE_STEPS, i); @@ -312,7 +312,7 @@ void LLManipRotate::render() gGL.rotatef( 90.f, 1.f, 0.f, 0.f ); if (mHighlightedPart == LL_ROT_Y) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); gGL.scalef(mManipulatorScales.mV[VY], mManipulatorScales.mV[VY], mManipulatorScales.mV[VY]); // hovering over part gl_ring( mRadiusMeters, width_meters, LLColor4( 0.f, 1.f, 0.f, 1.f ), LLColor4( 0.f, 1.f, 0.f, 0.5f ), CIRCLE_STEPS, i); @@ -330,7 +330,7 @@ void LLManipRotate::render() gGL.rotatef( 90.f, 0.f, 1.f, 0.f ); if (mHighlightedPart == LL_ROT_X) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); gGL.scalef(mManipulatorScales.mV[VX], mManipulatorScales.mV[VX], mManipulatorScales.mV[VX]); // hovering over part @@ -346,7 +346,7 @@ void LLManipRotate::render() if (mHighlightedPart == LL_ROT_ROLL) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); } } diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 00a0bf8894..9802d5503e 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -535,11 +535,11 @@ void LLManipScale::highlightManipulators(S32 x, S32 y) { if (mHighlightedPart == MANIPULATOR_IDS[i]) { - mManipulatorScales[i] = lerp(mManipulatorScales[i], SELECTED_MANIPULATOR_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales[i] = lerp(mManipulatorScales[i], SELECTED_MANIPULATOR_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); } else { - mManipulatorScales[i] = lerp(mManipulatorScales[i], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); + mManipulatorScales[i] = lerp(mManipulatorScales[i], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); } } @@ -2082,3 +2082,4 @@ BOOL LLManipScale::canAffectSelection() } return can_scale; } + diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index 0228807dc8..9d287e7a03 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -1922,18 +1922,18 @@ void LLManipTranslate::renderTranslationHandles() { if (index == mManipPart - LL_X_ARROW || index == mHighlightedPart - LL_X_ARROW) { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); } else if (index == mManipPart - LL_YZ_PLANE || index == mHighlightedPart - LL_YZ_PLANE) { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); } else { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); } } @@ -2323,3 +2323,4 @@ BOOL LLManipTranslate::canAffectSelection() } return can_move; } + diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 1bda7640bd..274497f2b5 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -162,7 +162,7 @@ void LLNetMap::draw() static LLUICachedControl auto_center("MiniMapAutoCenter", true); if (auto_center) { - mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(0.1f)); + mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); } // Prepare a scissor region @@ -987,3 +987,4 @@ void LLNetMap::handleStopTracking (const LLSD& userdata) LLTracker::stopTracking ((void*)LLTracker::isTracking(NULL)); } } + diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 343316d30a..cf9d95455e 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6108,6 +6108,14 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); gGL.begin(LLRender::LINES); { + // Lines require an even number of verts so repeat the first + // vert if we don't meet that requirement + // + if (mSilhouetteVertices.size() & 0x1) + { + mSilhouetteVertices.push_back(mSilhouetteVertices[0]); + } + for(S32 i = 0; i < mSilhouetteVertices.size(); i += 2) { u_coord += u_divisor * LLSelectMgr::sHighlightUScale; @@ -7547,3 +7555,4 @@ void LLSelectMgr::sendSelectionMove() //saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); } + diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index ec36cf48c2..8c5844eca7 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -549,11 +549,11 @@ void LLFloaterTexturePicker::draw() if (gFocusMgr.childHasMouseCapture(getDragHandle())) { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); + mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); } else { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); + mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); } updateImageStats(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 9ffc64312d..3f97659c66 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1033,7 +1033,7 @@ void render_hud_attachments() // clamp target zoom level to reasonable values gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); // smoothly interpolate current zoom level - gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f)); + gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices()) { @@ -1593,3 +1593,4 @@ void display_cleanup() { gDisconnectedImagep = NULL; } + diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 4efd59685e..d28da507ea 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2913,7 +2913,7 @@ void LLVOAvatar::idleUpdateWindEffect() LLVector3 velocity = getVelocity(); F32 speed = velocity.length(); //RN: velocity varies too much frame to frame for this to work - mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLCriticalDamp::getInterpolant(0.02f)); + mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); mLastVel = velocity; LLVector4 wind; wind.setVec(getRegion()->mWind.getVelocityNoisy(getPositionAgent(), 4.f) - velocity); @@ -2934,13 +2934,10 @@ void LLVOAvatar::idleUpdateWindEffect() wind.mV[VW] = llmin(0.025f + (speed * 0.015f) + hover_strength, 0.5f); F32 interp; - if (wind.mV[VW] > mWindVec.mV[VW]) + interp = LLCriticalDamp::getInterpolant(InterpDeltaSmall); + if (wind.mV[VW] <= mWindVec.mV[VW]) { - interp = LLCriticalDamp::getInterpolant(0.2f); - } - else - { - interp = LLCriticalDamp::getInterpolant(0.4f); + interp *= 2.0f; } mWindVec = lerp(mWindVec, wind, interp); @@ -3801,7 +3798,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) // Set the root rotation, but do so incrementally so that it // lags in time by some fixed amount. - //F32 u = LLCriticalDamp::getInterpolant(PELVIS_LAG); F32 pelvis_lag_time = 0.f; if (self_in_mouselook) { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 7adf18b6d0..3c831bafa0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1268,7 +1268,7 @@ BOOL LLVOVolume::calcLOD() else { distance = mDrawable->mDistanceWRTCamera; - radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length(); + radius = getVolume() ? getVolume()->mLODScaleBias.scaledVec(getScale()).length() : getScale().length(); } //hold onto unmodified distance for debugging @@ -2990,7 +2990,8 @@ void LLVOVolume::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_p //transform view vector into volume space view_vector -= getRenderPosition(); - mDrawable->mDistanceWRTCamera = view_vector.length(); + // WTF...why is silhouette generation touching a variable used all over the place?! + //mDrawable->mDistanceWRTCamera = view_vector.length(); LLQuaternion worldRot = getRenderRotation(); view_vector = view_vector * ~worldRot; if (!isVolumeGlobal()) diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index ccc513b80d..7c3bc5988c 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -302,8 +302,8 @@ void LLWorldMapView::draw() mVisibleRegions.clear(); // animate pan if necessary - sPanX = lerp(sPanX, sTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); - sPanY = lerp(sPanY, sTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); + sPanX = lerp(sPanX, sTargetPanX, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + sPanY = lerp(sPanY, sTargetPanY, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); const S32 width = getRect().getWidth(); const S32 height = getRect().getHeight(); @@ -1795,3 +1795,5 @@ BOOL LLWorldMapView::handleDoubleClick( S32 x, S32 y, MASK mask ) } return FALSE; } + + -- cgit v1.2.3 From b628518fd7c2ee6432dd2f49ecf192bd26455dba Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 8 Mar 2013 17:42:22 -0600 Subject: MAINT-2461 Potential fix for crash in LLPipeline::renderBloom --- indra/newview/pipeline.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 54a62a858a..e9cd74406d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7261,7 +7261,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) else { //focus on alt-zoom target - focus_point = LLVector3(gAgentCamera.getFocusGlobal()-gAgent.getRegion()->getOriginGlobal()); + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + focus_point = LLVector3(gAgentCamera.getFocusGlobal()-region->getOriginGlobal()); + } } } -- cgit v1.2.3 From 7a71c094b95bbc6b821b93e2be7e18d19c3cff11 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 8 Mar 2013 18:12:19 -0600 Subject: MAINT-2410 Extra Particle Parameters -- port of Kelly's simulator changeset --- indra/llmessage/llpartdata.cpp | 78 ++++++++++++++++++++++++++++++----- indra/llmessage/llpartdata.h | 36 +++++++++++++++- indra/lscript/lscript_compile/indra.l | 14 +++++++ 3 files changed, 117 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llpartdata.cpp b/indra/llmessage/llpartdata.cpp index 26cafa025f..c0fd3c9542 100644 --- a/indra/llmessage/llpartdata.cpp +++ b/indra/llmessage/llpartdata.cpp @@ -37,12 +37,18 @@ +const S32 PS_PART_DATA_GLOW_BLEND_SIZE = 4; const S32 PS_PART_DATA_BLOCK_SIZE = 4 + 2 + 4 + 4 + 2 + 2; // 18 -const S32 PS_DATA_BLOCK_SIZE = 68 + PS_PART_DATA_BLOCK_SIZE; // 68 + 18 = 86 +const S32 PS_DATA_BLOCK_SIZE = 68 + PS_PART_DATA_BLOCK_SIZE + PS_PART_DATA_GLOW_BLEND_SIZE; // 68 + 18 + 4 = 90 const F32 MAX_PART_SCALE = 4.f; +bool LLPartData::hasGlow() const +{ + return mStartGlow > 0.f || mEndGlow > 0.f; +} + BOOL LLPartData::pack(LLDataPacker &dp) { LLColor4U coloru; @@ -56,6 +62,14 @@ BOOL LLPartData::pack(LLDataPacker &dp) dp.packFixed(mStartScale.mV[1], "pdstartscaley", FALSE, 3, 5); dp.packFixed(mEndScale.mV[0], "pdendscalex", FALSE, 3, 5); dp.packFixed(mEndScale.mV[1], "pdendscaley", FALSE, 3, 5); + + if (hasGlow() || hasBlendFunc()) + { + dp.packU8(mStartGlow * 255,"pdstartglow"); + dp.packU8(mEndGlow * 255,"pdendglow"); + dp.packU8(mBlendFuncSource,"pdblendsource"); + dp.packU8(mBlendFuncDest,"pdblenddest"); + } return TRUE; } @@ -68,6 +82,11 @@ LLSD LLPartData::asLLSD() const sd["pdendcolor"] = ll_sd_from_color4(mEndColor); sd["pdstartscale"] = ll_sd_from_vector2(mStartScale); sd["pdendscale"] = ll_sd_from_vector2(mEndScale); + sd["pdstartglow"] = mStartGlow; + sd["pdendglow"] = mEndGlow; + sd["pdblendsource"] = (S32)mBlendFuncSource; + sd["pdblenddest"] = (S32)mBlendFuncDest; + return sd; } @@ -79,6 +98,12 @@ bool LLPartData::fromLLSD(LLSD& sd) mEndColor = ll_color4_from_sd(sd["pdendcolor"]); mStartScale = ll_vector2_from_sd(sd["pdstartscale"]); mEndScale = ll_vector2_from_sd(sd["pdendscale"]); + + mStartGlow = sd.has("pdstartglow") ? sd["pdstartglow"].asReal() : 0.f; + mEndGlow = sd.has("pdendglow") ? sd["pdendglow"].asReal() : 0.f; + mBlendFuncSource = sd.has("pdblendsource") ? (U8)sd["pdblendsource"].asInteger() : LL_PART_BF_SOURCE_ALPHA; + mBlendFuncDest = sd.has("pdblenddest") ? (U8)sd["pdblenddest"].asInteger() : LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; + return true; } @@ -98,6 +123,18 @@ BOOL LLPartData::unpack(LLDataPacker &dp) dp.unpackFixed(mStartScale.mV[1], "pdstartscaley", FALSE, 3, 5); dp.unpackFixed(mEndScale.mV[0], "pdendscalex", FALSE, 3, 5); dp.unpackFixed(mEndScale.mV[1], "pdendscaley", FALSE, 3, 5); + + if (dp.hasNext()) + { + U8 tmp_glow = 0; + dp.unpackU8(tmp_glow,"pdstartglow"); + mStartGlow = tmp_glow / 255.f; + dp.unpackU8(tmp_glow,"pdendglow"); + mEndGlow = tmp_glow / 255.f; + dp.unpackU8(mBlendFuncSource,"pdblendsource"); + dp.unpackU8(mBlendFuncDest,"pdblenddest"); + } + return TRUE; } @@ -148,6 +185,18 @@ void LLPartData::setEndAlpha(const F32 alpha) mEndColor.mV[3] = alpha; } +// static +bool LLPartData::validBlendFunc(S32 func) +{ + if (func >= 0 + && func < LL_PART_BF_COUNT + && func != UNSUPPORTED_DEST_ALPHA + && func != UNSUPPORTED_ONE_MINUS_DEST_ALPHA) + { + return true; + } + return false; +} LLPartSysData::LLPartSysData() { @@ -160,6 +209,10 @@ LLPartSysData::LLPartSysData() mPartData.mStartScale = LLVector2(1.f, 1.f); mPartData.mEndScale = LLVector2(1.f, 1.f); mPartData.mMaxAge = 10.0; + mPartData.mBlendFuncSource = LLPartData::LL_PART_BF_SOURCE_ALPHA; + mPartData.mBlendFuncDest = LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; + mPartData.mStartGlow = 0.f; + mPartData.mEndGlow = 0.f; mMaxAge = 0.0; mStartAge = 0.0; @@ -264,14 +317,16 @@ BOOL LLPartSysData::isNullPS(const S32 block_num) { return TRUE; } - else if (size != PS_DATA_BLOCK_SIZE) + + gMessageSystem->getBinaryData("ObjectData", "PSBlock", ps_data_block, PS_DATA_BLOCK_SIZE, block_num, PS_DATA_BLOCK_SIZE); + + if (size > PS_DATA_BLOCK_SIZE) { - llwarns << "PSBlock is wrong size for particle system data - got " << size << ", expecting " << PS_DATA_BLOCK_SIZE << llendl; + //size is too big, newer particle version unsupported return TRUE; } - gMessageSystem->getBinaryData("ObjectData", "PSBlock", ps_data_block, PS_DATA_BLOCK_SIZE, block_num, PS_DATA_BLOCK_SIZE); - LLDataPackerBinaryBuffer dp(ps_data_block, PS_DATA_BLOCK_SIZE); + LLDataPackerBinaryBuffer dp(ps_data_block, size); dp.unpackU32(crc, "crc"); if (crc == 0) @@ -296,10 +351,13 @@ BOOL LLPartSysData::packBlock() U8 ps_data_block[PS_DATA_BLOCK_SIZE]; LLDataPackerBinaryBuffer dp(ps_data_block, PS_DATA_BLOCK_SIZE); + pack(dp); + S32 size = dp.getCurrentSize(); + // Add to message - gMessageSystem->addBinaryData("PSBlock", ps_data_block, PS_DATA_BLOCK_SIZE); + gMessageSystem->addBinaryData("PSBlock", ps_data_block, size); return TRUE; } @@ -312,16 +370,16 @@ BOOL LLPartSysData::unpackBlock(const S32 block_num) // Check size of block S32 size = gMessageSystem->getSize("ObjectData", block_num, "PSBlock"); - if (size != PS_DATA_BLOCK_SIZE) + if (size > PS_DATA_BLOCK_SIZE) { - llwarns << "PSBlock is wrong size for particle system data - got " << size << ", expecting " << PS_DATA_BLOCK_SIZE << llendl; + // Larger packets are newer and unsupported return FALSE; } // Get from message - gMessageSystem->getBinaryData("ObjectData", "PSBlock", ps_data_block, PS_DATA_BLOCK_SIZE, block_num, PS_DATA_BLOCK_SIZE); + gMessageSystem->getBinaryData("ObjectData", "PSBlock", ps_data_block, size, block_num, PS_DATA_BLOCK_SIZE); - LLDataPackerBinaryBuffer dp(ps_data_block, PS_DATA_BLOCK_SIZE); + LLDataPackerBinaryBuffer dp(ps_data_block, size); unpack(dp); return TRUE; diff --git a/indra/llmessage/llpartdata.h b/indra/llmessage/llpartdata.h index a4ef058b30..19207d994d 100644 --- a/indra/llmessage/llpartdata.h +++ b/indra/llmessage/llpartdata.h @@ -70,7 +70,12 @@ enum LLPSScriptFlags LLPS_SRC_TARGET_UUID, LLPS_SRC_OMEGA, LLPS_SRC_ANGLE_BEGIN, - LLPS_SRC_ANGLE_END + LLPS_SRC_ANGLE_END, + + LLPS_PART_BLEND_FUNC_SOURCE, + LLPS_PART_BLEND_FUNC_DEST, + LLPS_PART_START_GLOW, + LLPS_PART_END_GLOW }; @@ -89,6 +94,9 @@ public: operator LLSD() const {return asLLSD(); } bool fromLLSD(LLSD& sd); + bool hasGlow() const; + bool hasBlendFunc() const; + // Masks for the different particle flags enum { @@ -102,6 +110,7 @@ public: LL_PART_TARGET_LINEAR_MASK = 0x80, // Particle uses a direct linear interpolation LL_PART_EMISSIVE_MASK = 0x100, // Particle is "emissive", instead of being lit LL_PART_BEAM_MASK = 0x200, // Particle is a "beam" connecting source and target + LL_PART_RIBBON_MASK = 0x400, // Particles are joined together into one continuous triangle strip // Not implemented yet! //LL_PART_RANDOM_ACCEL_MASK = 0x100, // Particles have random acceleration @@ -113,6 +122,23 @@ public: LL_PART_DEAD_MASK = 0x80000000, }; + enum + { + LL_PART_BF_ONE = 0, + LL_PART_BF_ZERO = 1, + LL_PART_BF_DEST_COLOR = 2, + LL_PART_BF_SOURCE_COLOR = 3, + LL_PART_BF_ONE_MINUS_DEST_COLOR = 4, + LL_PART_BF_ONE_MINUS_SOURCE_COLOR = 5, + UNSUPPORTED_DEST_ALPHA = 6, + LL_PART_BF_SOURCE_ALPHA = 7, + UNSUPPORTED_ONE_MINUS_DEST_ALPHA = 8, + LL_PART_BF_ONE_MINUS_SOURCE_ALPHA = 9, + LL_PART_BF_COUNT = 10 + }; + + static bool validBlendFunc(S32 func); + void setFlags(const U32 flags); void setMaxAge(const F32 max_age); void setStartScale(const F32 xs, F32 ys); @@ -137,6 +163,12 @@ public: LLVector3 mPosOffset; // Offset from source if using FOLLOW_SOURCE F32 mParameter; // A single floating point parameter + + F32 mStartGlow; + F32 mEndGlow; + + U8 mBlendFuncSource; + U8 mBlendFuncDest; }; @@ -187,6 +219,8 @@ public: void clampSourceParticleRate(); friend std::ostream& operator<<(std::ostream& s, const LLPartSysData &data); // Stream a + + S32 getdataBlockSize() const; public: // Public because I'm lazy.... diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index 307a5561a0..3f844d0fd1 100644 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -355,6 +355,10 @@ extern "C" { int yyerror(const char *fmt, ...); } "PSYS_PART_END_SCALE" { count(); yylval.ival = LLPS_PART_END_SCALE; return (INTEGER_CONSTANT); } "PSYS_PART_MAX_AGE" { count(); yylval.ival = LLPS_PART_MAX_AGE; return (INTEGER_CONSTANT); } +"PSYS_PART_BLEND_FUNC_SOURCE" { count(); yylval.ival = LLPS_PART_BLEND_FUNC_SOURCE; return (INTEGER_CONSTANT); } +"PSYS_PART_BLEND_FUNC_DEST" { count(); yylval.ival = LLPS_PART_BLEND_FUNC_DEST; return (INTEGER_CONSTANT); } +"PSYS_PART_START_GLOW" { count(); yylval.ival = LLPS_PART_START_GLOW; return (INTEGER_CONSTANT); } +"PSYS_PART_END_GLOW" { count(); yylval.ival = LLPS_PART_END_GLOW; return (INTEGER_CONSTANT); } "PSYS_PART_WIND_MASK" { count(); yylval.ival = LLPartData::LL_PART_WIND_MASK; return(INTEGER_CONSTANT); } "PSYS_PART_INTERP_COLOR_MASK" { count(); yylval.ival = LLPartData::LL_PART_INTERP_COLOR_MASK; return(INTEGER_CONSTANT); } @@ -365,6 +369,16 @@ extern "C" { int yyerror(const char *fmt, ...); } "PSYS_PART_TARGET_POS_MASK" { count(); yylval.ival = LLPartData::LL_PART_TARGET_POS_MASK; return(INTEGER_CONSTANT); } "PSYS_PART_EMISSIVE_MASK" { count(); yylval.ival = LLPartData::LL_PART_EMISSIVE_MASK; return(INTEGER_CONSTANT); } "PSYS_PART_TARGET_LINEAR_MASK" { count(); yylval.ival = LLPartData::LL_PART_TARGET_LINEAR_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_RIBBON_MASK" { count(); yylval.ival = LLPartData::LL_PART_RIBBON_MASK; return(INTEGER_CONSTANT); } + +"PSYS_PART_BF_ONE" { count(); yylval.ival = LLPartData::LL_PART_BF_ONE; return(INTEGER_CONSTANT); } +"PSYS_PART_BF_ZERO" { count(); yylval.ival = LLPartData::LL_PART_BF_ZERO; return(INTEGER_CONSTANT); } +"PSYS_PART_BF_DEST_COLOR" { count(); yylval.ival = LLPartData::LL_PART_BF_DEST_COLOR; return(INTEGER_CONSTANT); } +"PSYS_PART_BF_SOURCE_COLOR" { count(); yylval.ival = LLPartData::LL_PART_BF_SOURCE_COLOR; return(INTEGER_CONSTANT); } +"PSYS_PART_BF_ONE_MINUS_DEST_COLOR" { count(); yylval.ival = LLPartData::LL_PART_BF_ONE_MINUS_DEST_COLOR; return(INTEGER_CONSTANT); } +"PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR" { count(); yylval.ival = LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_COLOR; return(INTEGER_CONSTANT); } +"PSYS_PART_BF_SOURCE_ALPHA" { count(); yylval.ival = LLPartData::LL_PART_BF_SOURCE_ALPHA; return(INTEGER_CONSTANT); } +"PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA" { count(); yylval.ival = LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; return(INTEGER_CONSTANT); } "PSYS_SRC_MAX_AGE" { count(); yylval.ival = LLPS_SRC_MAX_AGE; return(INTEGER_CONSTANT); } -- cgit v1.2.3 From 5616d198bdace981c0d284d000eddd815d4c7491 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 11 Mar 2013 09:55:33 -0700 Subject: Fix missing eol at eof in llinstancetracker.cpp tripping up linux build --- indra/llcommon/llinstancetracker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 0804be358f..65ef4322f6 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -42,4 +42,5 @@ void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t) // key DOES exist, insert() simply returns (iterator, false). One lookup // handles both cases. return sInstanceTrackerData[t]; -} \ No newline at end of file +} + -- cgit v1.2.3 From 8c1e635317caebbb5532bc0a4dadf0f4a30f737b Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 11 Mar 2013 10:12:10 -0700 Subject: Fix missing eol at eof in llstaticstringtable.h breaking linux build --- indra/llcommon/llstaticstringtable.h | 163 ++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 81 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llstaticstringtable.h b/indra/llcommon/llstaticstringtable.h index 05b0848e30..52049b0921 100644 --- a/indra/llcommon/llstaticstringtable.h +++ b/indra/llcommon/llstaticstringtable.h @@ -1,81 +1,82 @@ -/** - * @file llstringtable.h - * @brief The LLStringTable class provides a _fast_ method for finding - * unique copies of strings. - * - * $LicenseInfo:firstyear=2001&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$ - */ - -#ifndef LL_STATIC_STRING_TABLE_H -#define LL_STATIC_STRING_TABLE_H - -#include "lldefs.h" -#include -#include "llstl.h" - -class LLStaticHashedString -{ -public: - - LLStaticHashedString(const std::string& s) - { - string_hash = makehash(s); - string = s; - } - - const std::string& String() const { return string; } - size_t Hash() const { return string_hash; } - - bool operator==(const LLStaticHashedString& b) const { return Hash() == b.Hash(); } - -protected: - - size_t makehash(const std::string& s) - { - size_t len = s.size(); - const char* c = s.c_str(); - size_t hashval = 0; - for (size_t i=0; i -class LL_COMMON_API LLStaticStringTable - : public boost::unordered_map< LLStaticHashedString, MappedObject, LLStaticStringHasher > -{ -}; - -#endif \ No newline at end of file +/** + * @file llstringtable.h + * @brief The LLStringTable class provides a _fast_ method for finding + * unique copies of strings. + * + * $LicenseInfo:firstyear=2001&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$ + */ + +#ifndef LL_STATIC_STRING_TABLE_H +#define LL_STATIC_STRING_TABLE_H + +#include "lldefs.h" +#include +#include "llstl.h" + +class LLStaticHashedString +{ +public: + + LLStaticHashedString(const std::string& s) + { + string_hash = makehash(s); + string = s; + } + + const std::string& String() const { return string; } + size_t Hash() const { return string_hash; } + + bool operator==(const LLStaticHashedString& b) const { return Hash() == b.Hash(); } + +protected: + + size_t makehash(const std::string& s) + { + size_t len = s.size(); + const char* c = s.c_str(); + size_t hashval = 0; + for (size_t i=0; i +class LL_COMMON_API LLStaticStringTable + : public boost::unordered_map< LLStaticHashedString, MappedObject, LLStaticStringHasher > +{ +}; + +#endif + -- cgit v1.2.3 From c04f4f66c813181eb378b00045aec969dc2c4aae Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 11 Mar 2013 12:30:16 -0700 Subject: Moved LLAlignedArray from llmath to llcommon and put template func impls in header to work around Mac 4.3.3 link issue. --- indra/llcommon/CMakeLists.txt | 1 + indra/llmath/llvolume.cpp | 87 ------------------------------------------- indra/llmath/llvolume.h | 21 +---------- 3 files changed, 2 insertions(+), 107 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index e019c17280..0c2ceebb52 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -121,6 +121,7 @@ set(llcommon_HEADER_FILES linden_common.h linked_lists.h llaccountingcost.h + llalignedarray.h llallocator.h llallocator_heap_profile.h llagentconstants.h diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 9fc72fd801..4f3e753276 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -96,93 +96,6 @@ extern BOOL gDebugGL; bool less_than_max_mag(const LLVector4a& vec); -template -LLAlignedArray::LLAlignedArray() -{ - mArray = NULL; - mElementCount = 0; - mCapacity = 0; -} - -template -LLAlignedArray::~LLAlignedArray() -{ - ll_aligned_free(mArray); - mArray = NULL; - mElementCount = 0; - mCapacity = 0; -} - -template -void LLAlignedArray::push_back(const T& elem) -{ - T* old_buf = NULL; - if (mCapacity <= mElementCount) - { - mCapacity++; - mCapacity *= 2; - T* new_buf = (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment); - if (mArray) - { - LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); - } - old_buf = mArray; - mArray = new_buf; - } - - mArray[mElementCount++] = elem; - - //delete old array here to prevent error on a.push_back(a[0]) - ll_aligned_free(old_buf); -} - -template -void LLAlignedArray::resize(U32 size) -{ - if (mCapacity < size) - { - mCapacity = size+mCapacity*2; - T* new_buf = mCapacity > 0 ? (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment) : NULL; - if (mArray) - { - LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); - ll_aligned_free(mArray); - } - - /*for (U32 i = mElementCount; i < mCapacity; ++i) - { - new(new_buf+i) T(); - }*/ - mArray = new_buf; - } - - mElementCount = size; -} - - -template -T& LLAlignedArray::operator[](int idx) -{ - llassert(idx < mElementCount); - return mArray[idx]; -} - -template -const T& LLAlignedArray::operator[](int idx) const -{ - llassert(idx < mElementCount); - return mArray[idx]; -} - -template -T* LLAlignedArray::append(S32 N) -{ - U32 sz = size(); - resize(sz+N); - return &((*this)[sz]); -} - - BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm) { LLVector3 test = (pt2-pt1)%(pt3-pt2); diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 5e43af92ec..1ff53590cf 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -41,6 +41,7 @@ class LLVolumeFace; class LLVolume; class LLVolumeTriangle; +#include "llalignedarray.h" #include "lldarray.h" #include "lluuid.h" #include "v4color.h" @@ -195,26 +196,6 @@ const U8 LL_SCULPT_FLAG_MIRROR = 128; const S32 LL_SCULPT_MESH_MAX_FACES = 8; -template -class LLAlignedArray -{ -public: - T* mArray; - U32 mElementCount; - U32 mCapacity; - - LLAlignedArray(); - ~LLAlignedArray(); - - void push_back(const T& elem); - U32 size() const { return mElementCount; } - void resize(U32 size); - T* append(S32 N); - T& operator[](int idx); - const T& operator[](int idx) const; -}; - - class LLProfileParams { public: -- cgit v1.2.3 From 356d10e6a6cfea279228f371aed88aba73ed70dd Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 11 Mar 2013 13:12:03 -0700 Subject: Work around 'interesting' forced include order in vmath stuff on Windows --- indra/llmath/llvolume.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 1ff53590cf..6b599a4126 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -41,7 +41,6 @@ class LLVolumeFace; class LLVolume; class LLVolumeTriangle; -#include "llalignedarray.h" #include "lldarray.h" #include "lluuid.h" #include "v4color.h" @@ -58,6 +57,7 @@ class LLVolumeTriangle; #include "llrefcount.h" #include "llpointer.h" #include "llfile.h" +#include "llalignedarray.h" //============================================================================ -- cgit v1.2.3 From 9a0f913e7089c9b2120856936bf47dcb8de9c6b1 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 11 Mar 2013 13:55:40 -0700 Subject: Work around bogus gcc 4.3.4 warning from alignment assert --- indra/llmath/llvector4a.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra') diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h index 0526793d3a..1a478bc8de 100644 --- a/indra/llmath/llvector4a.h +++ b/indra/llmath/llvector4a.h @@ -93,7 +93,11 @@ public: LLVector4a() { //DO NOT INITIALIZE -- The overhead is completely unnecessary +// This assert is causing spurious referenced before set warnings on GCC 4.3.4 +// +#if !LL_LINUX ll_assert_aligned(this,16); +#endif } LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f) -- cgit v1.2.3 From 6ac6736994240d9789a81bf585468bef50805fd8 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 11 Mar 2013 16:00:25 -0700 Subject: Move 16b aligned memcpy and alignment utilities to llmem in llcommon for easier use elsewhere --- indra/llcommon/llalignedarray.h | 16 +------ indra/llcommon/llmemory.h | 102 +++++++++++++++++++++++++++++++++++++--- indra/llmath/llsimdmath.h | 28 ----------- indra/llmath/llvector4a.cpp | 50 +------------------- 4 files changed, 99 insertions(+), 97 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llalignedarray.h b/indra/llcommon/llalignedarray.h index 5e04e8050f..ed8fd31205 100644 --- a/indra/llcommon/llalignedarray.h +++ b/indra/llcommon/llalignedarray.h @@ -29,10 +29,6 @@ #include "llmemory.h" -#if LL_WINDOWS -#include "llvector4a.h" // for 16b fast copy -#endif - template class LLAlignedArray { @@ -81,11 +77,7 @@ void LLAlignedArray::push_back(const T& elem) T* new_buf = (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment); if (mArray) { -#if LL_WINDOWS - LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); -#else - memcpy((F32*)new_buf, (F32*)mArray, sizeof(T)*mElementCount); -#endif + ll_memcpy_nonaliased_aligned_16((char*)new_buf, (char*)mArray, sizeof(T)*mElementCount); } old_buf = mArray; mArray = new_buf; @@ -106,11 +98,7 @@ void LLAlignedArray::resize(U32 size) T* new_buf = mCapacity > 0 ? (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment) : NULL; if (mArray) { -#if LL_WINDOWS - LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); -#else - memcpy((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); -#endif + ll_memcpy_nonaliased_aligned_16((char*) new_buf, (char*) mArray, sizeof(T)*mElementCount); ll_aligned_free(mArray); } diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 46cabfadcd..4938775e2b 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -36,6 +36,44 @@ class LLMutex ; #define LL_CHECK_MEMORY #endif +LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment); + +#ifdef SHOW_ASSERT +#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast(ptr),((U32)alignment)) +#else +#define ll_assert_aligned(ptr,alignment) +#endif + +#include + +template T* LL_NEXT_ALIGNED_ADDRESS(T* address) +{ + return reinterpret_cast( + (reinterpret_cast(address) + 0xF) & ~0xF); +} + +template T* LL_NEXT_ALIGNED_ADDRESS_64(T* address) +{ + return reinterpret_cast( + (reinterpret_cast(address) + 0x3F) & ~0x3F); +} + +#if LL_LINUX || LL_DARWIN + +#define LL_ALIGN_PREFIX(x) +#define LL_ALIGN_POSTFIX(x) __attribute__((aligned(x))) + +#elif LL_WINDOWS + +#define LL_ALIGN_PREFIX(x) __declspec(align(x)) +#define LL_ALIGN_POSTFIX(x) + +#else +#error "LL_ALIGN_PREFIX and LL_ALIGN_POSTFIX undefined" +#endif + +#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16) + inline void* ll_aligned_malloc( size_t size, int align ) { #if defined(LL_WINDOWS) @@ -144,6 +182,64 @@ inline void ll_aligned_free_32(void *p) #endif } + +// Copy words 16-byte blocks from src to dst. Source and destination MUST NOT OVERLAP. +// Source and dest must be 16-byte aligned and size must be multiple of 16. +// +inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __restrict src, size_t bytes) +{ + assert(src != NULL); + assert(dst != NULL); + assert(bytes > 0); + assert((bytes % sizeof(F32))== 0); + ll_assert_aligned(src,16); + ll_assert_aligned(dst,16); + assert((src < dst) ? ((src + bytes) < dst) : ((dst + bytes) < src)); + assert(bytes%16==0); + + char* end = dst + bytes; + + if (bytes > 64) + { + void* begin_64 = LL_NEXT_ALIGNED_ADDRESS_64(dst); + + //at least 64 bytes before the end of the destination, switch to 16 byte copies + void* end_64 = end-64; + + _mm_prefetch((char*)begin_64, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 64, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 128, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 192, _MM_HINT_NTA); + + while (dst < begin_64) + { + + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + dst += 4; + src += 4; + } + + while (dst < end_64) + { + _mm_prefetch((char*)src + 512, _MM_HINT_NTA); + _mm_prefetch((char*)dst + 512, _MM_HINT_NTA); + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + _mm_store_ps((F32*)(dst + 16), _mm_load_ps((F32*)(src + 16))); + _mm_store_ps((F32*)(dst + 32), _mm_load_ps((F32*)(src + 32))); + _mm_store_ps((F32*)(dst + 48), _mm_load_ps((F32*)(src + 48))); + dst += 64; + src += 64; + } + } + + while (dst < end) + { + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + dst += 16; + src += 16; + } +} + #ifndef __DEBUG_PRIVATE_MEM__ #define __DEBUG_PRIVATE_MEM__ 0 #endif @@ -552,13 +648,7 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr) // LLSingleton moved to llsingleton.h -LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment); -#ifdef SHOW_ASSERT -#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast(ptr),((U32)alignment)) -#else -#define ll_assert_aligned(ptr,alignment) -#endif #endif diff --git a/indra/llmath/llsimdmath.h b/indra/llmath/llsimdmath.h index 01458521ec..cebd2ace7d 100644 --- a/indra/llmath/llsimdmath.h +++ b/indra/llmath/llsimdmath.h @@ -39,34 +39,6 @@ #include #endif -template T* LL_NEXT_ALIGNED_ADDRESS(T* address) -{ - return reinterpret_cast( - (reinterpret_cast(address) + 0xF) & ~0xF); -} - -template T* LL_NEXT_ALIGNED_ADDRESS_64(T* address) -{ - return reinterpret_cast( - (reinterpret_cast(address) + 0x3F) & ~0x3F); -} - -#if LL_LINUX || LL_DARWIN - -#define LL_ALIGN_PREFIX(x) -#define LL_ALIGN_POSTFIX(x) __attribute__((aligned(x))) - -#elif LL_WINDOWS - -#define LL_ALIGN_PREFIX(x) __declspec(align(x)) -#define LL_ALIGN_POSTFIX(x) - -#else -#error "LL_ALIGN_PREFIX and LL_ALIGN_POSTFIX undefined" -#endif - -#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16) - #include #include diff --git a/indra/llmath/llvector4a.cpp b/indra/llmath/llvector4a.cpp index 6edeb0fefe..570fa41a43 100644 --- a/indra/llmath/llvector4a.cpp +++ b/indra/llmath/llvector4a.cpp @@ -41,55 +41,7 @@ extern const LLVector4a LL_V4A_EPSILON = reinterpret_cast ( F /*static */void LLVector4a::memcpyNonAliased16(F32* __restrict dst, const F32* __restrict src, size_t bytes) { - assert(src != NULL); - assert(dst != NULL); - assert(bytes > 0); - assert((bytes % sizeof(F32))== 0); - ll_assert_aligned(src,16); - ll_assert_aligned(dst,16); - assert(bytes%16==0); - - F32* end = dst + (bytes / sizeof(F32) ); - - if (bytes > 64) - { - F32* begin_64 = LL_NEXT_ALIGNED_ADDRESS_64(dst); - - //at least 64 (16*4) bytes before the end of the destination, switch to 16 byte copies - F32* end_64 = end-16; - - _mm_prefetch((char*)begin_64, _MM_HINT_NTA); - _mm_prefetch((char*)begin_64 + 64, _MM_HINT_NTA); - _mm_prefetch((char*)begin_64 + 128, _MM_HINT_NTA); - _mm_prefetch((char*)begin_64 + 192, _MM_HINT_NTA); - - while (dst < begin_64) - { - copy4a(dst, src); - dst += 4; - src += 4; - } - - while (dst < end_64) - { - _mm_prefetch((char*)src + 512, _MM_HINT_NTA); - _mm_prefetch((char*)dst + 512, _MM_HINT_NTA); - copy4a(dst, src); - copy4a(dst+4, src+4); - copy4a(dst+8, src+8); - copy4a(dst+12, src+12); - - dst += 16; - src += 16; - } - } - - while (dst < end) - { - copy4a(dst, src); - dst += 4; - src += 4; - } + ll_memcpy_nonaliased_aligned_16((char*)dst, (char*)src, bytes); } void LLVector4a::setRotated( const LLRotation& rot, const LLVector4a& vec ) -- cgit v1.2.3 From 6613d80d72931b13cc008c3dcc8ee90a39bec8f5 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 11 Mar 2013 14:19:05 -0700 Subject: Clean up moving llalignedarray and fast memcpy to llcommon --- indra/llcommon/llmemory.h | 24 +++++++++++++++++++----- indra/newview/llface.cpp | 3 +++ indra/newview/llpolymesh.cpp | 26 ++++++++++++++++++++------ 3 files changed, 42 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 4938775e2b..61e30f11cc 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -201,24 +201,36 @@ inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __ if (bytes > 64) { + + // Find start of 64b aligned area within block + // void* begin_64 = LL_NEXT_ALIGNED_ADDRESS_64(dst); //at least 64 bytes before the end of the destination, switch to 16 byte copies void* end_64 = end-64; - + + // Prefetch the head of the 64b area now + // _mm_prefetch((char*)begin_64, _MM_HINT_NTA); _mm_prefetch((char*)begin_64 + 64, _MM_HINT_NTA); _mm_prefetch((char*)begin_64 + 128, _MM_HINT_NTA); _mm_prefetch((char*)begin_64 + 192, _MM_HINT_NTA); - + + // Copy 16b chunks until we're 64b aligned + // while (dst < begin_64) { _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); - dst += 4; - src += 4; + dst += 16; + src += 16; } - + + // Copy 64b chunks up to your tail + // + // might be good to shmoo the 512b prefetch offset + // (characterize performance for various values) + // while (dst < end_64) { _mm_prefetch((char*)src + 512, _MM_HINT_NTA); @@ -232,6 +244,8 @@ inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __ } } + // Copy remainder 16b tail chunks (or ALL 16b chunks for sub-64b copies) + // while (dst < end) { _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 86e5f20812..5f86205175 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -64,6 +64,8 @@ BOOL LLFace::sSafeRenderSelect = TRUE; // FALSE #define DOTVEC(a,b) (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1] + a.mV[2]*b.mV[2]) +//#pragma GCC diagnostic ignored "-Wuninitialized" + /* For each vertex, given: B - binormal @@ -1982,6 +1984,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, //_mm_prefetch((char*)dst, _MM_HINT_NTA); + LLVector4a res0; //,res1,res2,res3; LLVector4a texIdx; diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp index 5f5258bbce..916f3d8e06 100644 --- a/indra/newview/llpolymesh.cpp +++ b/indra/newview/llpolymesh.cpp @@ -983,12 +983,26 @@ LLVector4a *LLPolyMesh::getScaledBinormals() //----------------------------------------------------------------------------- void LLPolyMesh::initializeForMorph() { - LLVector4a::memcpyNonAliased16((F32*) mCoords, (F32*) mSharedData->mBaseCoords, sizeof(LLVector4a) * mSharedData->mNumVertices); - LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices); - LLVector4a::memcpyNonAliased16((F32*) mScaledNormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices); - LLVector4a::memcpyNonAliased16((F32*) mBinormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices); - LLVector4a::memcpyNonAliased16((F32*) mScaledBinormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices); - LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) mSharedData->mTexCoords, sizeof(LLVector2) * (mSharedData->mNumVertices + mSharedData->mNumVertices%2)); + // Must insure that src and dst of copies below + // are actually 16b aligned...the 16b mod 0 size + // is assumed from the data being LLVector4a + // + ll_assert_aligned(mCoords,16); + ll_assert_aligned(mNormals,16); + ll_assert_aligned(mScaledNormals,16); + ll_assert_aligned(mBinormals,16); + ll_assert_aligned(mScaledBinormals,16); + ll_assert_aligned(mTexCoords,16); + ll_assert_aligned(mSharedData->mBaseCoords,16); + ll_assert_aligned(mSharedData->mBaseNormals,16); + ll_assert_aligned(mSharedData->mTexCoords,16); + + ll_memcpy_nonaliased_aligned_16((char*)mCoords, (char*)mSharedData->mBaseCoords, sizeof(LLVector4a) * mSharedData->mNumVertices); + ll_memcpy_nonaliased_aligned_16((char*)mNormals, (char*)mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices); + ll_memcpy_nonaliased_aligned_16((char*)mScaledNormals, (char*)mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices); + ll_memcpy_nonaliased_aligned_16((char*)mBinormals, (char*)mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices); + ll_memcpy_nonaliased_aligned_16((char*)mScaledBinormals, (char*)mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices); + ll_memcpy_nonaliased_aligned_16((char*)mTexCoords, (char*)mSharedData->mTexCoords, sizeof(LLVector2) * (mSharedData->mNumVertices + mSharedData->mNumVertices%2)); for (U32 i = 0; i < mSharedData->mNumVertices; ++i) { -- cgit v1.2.3 From 117ca53f099b6b2a3b22cf22065625c3fa26a1b1 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 12 Mar 2013 04:51:52 -0700 Subject: Add pragma warning disable for linux only to work-around spurious used before set warnings from GCC 4.3.4 on Vector4a with empty ctor --- indra/newview/llface.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 86e5f20812..73ae3743fc 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -53,6 +53,12 @@ #include "llviewershadermgr.h" #include "llvoavatar.h" +#if LL_LINUX +// Work-around spurious used before init warning on Vector4a +// +#pragma GCC diagnostic ignored "-Wuninitialized" +#endif + extern BOOL gGLDebugLoggingEnabled; #define LL_MAX_INDICES_COUNT 1000000 -- cgit v1.2.3 From 8af4974a02f1ad0c34c7e9cd17d0c2487231468e Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 12 Mar 2013 06:19:26 -0700 Subject: Disable more warnings to try to get llface.cpp to compile in the TC linux farm --- indra/newview/llface.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 73ae3743fc..f0393dcc5c 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -57,6 +57,8 @@ // Work-around spurious used before init warning on Vector4a // #pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wunused-function" #endif extern BOOL gGLDebugLoggingEnabled; -- cgit v1.2.3 From a7203a79088618552d890945b0bdc56c952f0a5a Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 12 Mar 2013 07:22:11 -0700 Subject: CMake hack to work around gcc-4.1 lack of pragma warning disable processing. --- indra/cmake/00-Common.cmake | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra') diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 452fd5f356..9ad17b64b9 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -128,6 +128,13 @@ if (LINUX) # Let's actually get a numerical version of gxx's version STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.([0-9]).*" "\\1\\2\\3" CXX_VERSION_NUMBER ${CXX_VERSION}) + # Hacks to work around gcc 4.1 TC build pool machines which can't process pragma warning disables + # This is pure rubbish; I wish there was another way. + # + if(${CXX_VERSION_NUMBER} LESS 420) + set(CMAKE_CXX_FLAGS "-Wno-deprecated -Wno-unitialized -Wno-unused-variable -Wno-unused-function ${CMAKE_CXX_FLAGS}") + endif (${CXX_VERSION_NUMBER} LESS 420) + # gcc 4.3 and above don't like the LL boost and also # cause warnings due to our use of deprecated headers if(${CXX_VERSION_NUMBER} GREATER 429) -- cgit v1.2.3 From 2874ecea4d59b2db87c764ba5fae0b662992c121 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 12 Mar 2013 07:47:36 -0700 Subject: Fix -Wno-uninitialized disable --- indra/cmake/00-Common.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 9ad17b64b9..28ace35fd3 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -132,7 +132,7 @@ if (LINUX) # This is pure rubbish; I wish there was another way. # if(${CXX_VERSION_NUMBER} LESS 420) - set(CMAKE_CXX_FLAGS "-Wno-deprecated -Wno-unitialized -Wno-unused-variable -Wno-unused-function ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wno-deprecated -Wno-uninitialized -Wno-unused-variable -Wno-unused-function ${CMAKE_CXX_FLAGS}") endif (${CXX_VERSION_NUMBER} LESS 420) # gcc 4.3 and above don't like the LL boost and also -- cgit v1.2.3 From d66aa0974abddbaa56be5d1535de4e09576324bc Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 12 Mar 2013 08:14:19 -0700 Subject: Remove pragma diags which ALSO cause gcc-4.1 to warning and thus error out. *sigh* --- indra/newview/llface.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index f0393dcc5c..86e5f20812 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -53,14 +53,6 @@ #include "llviewershadermgr.h" #include "llvoavatar.h" -#if LL_LINUX -// Work-around spurious used before init warning on Vector4a -// -#pragma GCC diagnostic ignored "-Wuninitialized" -#pragma GCC diagnostic ignored "-Wunused-variable" -#pragma GCC diagnostic ignored "-Wunused-function" -#endif - extern BOOL gGLDebugLoggingEnabled; #define LL_MAX_INDICES_COUNT 1000000 -- cgit v1.2.3 From 5a51a43f23f89b88e7f9b3e16d019a23196131f6 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 12 Mar 2013 08:45:10 -0700 Subject: Fix eol at eof on wl param files. --- indra/newview/llwlanimator.h | 1 + indra/newview/llwlparammanager.h | 1 + indra/newview/llwlparamset.cpp | 3 ++- indra/newview/llwlparamset.h | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llwlanimator.h b/indra/newview/llwlanimator.h index 5223b45343..810f4cf7e5 100644 --- a/indra/newview/llwlanimator.h +++ b/indra/newview/llwlanimator.h @@ -137,3 +137,4 @@ private: }; #endif // LL_WL_ANIMATOR_H + diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 72422500fc..e13aed98ed 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -412,3 +412,4 @@ inline LLVector4 LLWLParamManager::getRotatedLightDir(void) const } #endif + diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index 745cdae441..b307f19e8a 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -406,4 +406,5 @@ void LLWLParamSet::updateHashedNames() { mParamHashedNames.push_back(LLStaticHashedString(iter->first)); } -} \ No newline at end of file +} + diff --git a/indra/newview/llwlparamset.h b/indra/newview/llwlparamset.h index 3e9f77ba6c..6e5f1d3a4b 100644 --- a/indra/newview/llwlparamset.h +++ b/indra/newview/llwlparamset.h @@ -243,3 +243,4 @@ inline F32 LLWLParamSet::getCloudScrollY() { #endif // LL_WLPARAM_SET_H + -- cgit v1.2.3 From 067a9cdfa903f3657ffd20008ae2933fb82718c8 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 12 Mar 2013 01:05:06 -0700 Subject: Better compat with non-Ubuntu distros (bare typedef sometimes conflicts with OS decl of same). --- indra/llcommon/llapp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index a536a06ea5..afa06df23e 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -38,7 +38,7 @@ typedef LLAtomic32 LLAtomicU32; class LLErrorThread; class LLLiveFile; #if LL_LINUX -typedef struct siginfo siginfo_t; +#include #endif typedef void (*LLAppErrorHandler)(); -- cgit v1.2.3 From ab60c46a917366574fa7292b6e7142ece858bec5 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 12 Mar 2013 03:27:24 -0700 Subject: Fix for linux (and likely other platform) shutdown crash from mismatched alloc/free in VBOPool client data --- indra/llrender/llvertexbuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 1d257d8415..c6f1d76653 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -310,7 +310,7 @@ void LLVBOPool::cleanup() if (r.mClientData) { - ll_aligned_free_16((void*) r.mClientData); + ll_aligned_free((void*) r.mClientData); } l.pop_front(); -- cgit v1.2.3 From 35383790fb250532fa7701638d39a8f1c6a0cf76 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 12 Mar 2013 04:40:51 -0700 Subject: Merge pragma warning hack to fix linux build --- indra/cmake/00-Common.cmake | 2 +- indra/cmake/Variables.cmake | 9 ++------- indra/llrender/llvertexbuffer.cpp | 2 +- indra/newview/llface.cpp | 8 ++++++-- 4 files changed, 10 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 452fd5f356..81296965c2 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -218,7 +218,7 @@ if (LINUX OR DARWIN) set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs") if (NOT GCC_DISABLE_FATAL_WARNINGS) - set(GCC_WARNINGS "${GCC_WARNINGS} -Werror") +# set(GCC_WARNINGS "${GCC_WARNINGS} -Werror") endif (NOT GCC_DISABLE_FATAL_WARNINGS) set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor") diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake index 4b459f1a48..6297ee822e 100644 --- a/indra/cmake/Variables.cmake +++ b/indra/cmake/Variables.cmake @@ -104,13 +104,8 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OUTPUT_VARIABLE XCODE_VERSION ) # To support a different SDK update these Xcode settings: - if (XCODE_VERSION GREATER 4.2) - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6) - else (XCODE_VERSION GREATER 4.2) - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5) - endif (XCODE_VERSION GREATER 4.2) - - set(CMAKE_OSX_SYSROOT macosx10.6) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.8) + set(CMAKE_OSX_SYSROOT macosx10.8) set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf-with-dsym) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 1d257d8415..c6f1d76653 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -310,7 +310,7 @@ void LLVBOPool::cleanup() if (r.mClientData) { - ll_aligned_free_16((void*) r.mClientData); + ll_aligned_free((void*) r.mClientData); } l.pop_front(); diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 5f86205175..c3cb914120 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -53,6 +53,12 @@ #include "llviewershadermgr.h" #include "llvoavatar.h" +#if LL_LINUX +// Work-around spurious used before init warning on Vector4a +// +#pragma GCC diagnostic ignored "-Wuninitialized" +#endif + extern BOOL gGLDebugLoggingEnabled; #define LL_MAX_INDICES_COUNT 1000000 @@ -64,8 +70,6 @@ BOOL LLFace::sSafeRenderSelect = TRUE; // FALSE #define DOTVEC(a,b) (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1] + a.mV[2]*b.mV[2]) -//#pragma GCC diagnostic ignored "-Wuninitialized" - /* For each vertex, given: B - binormal -- cgit v1.2.3 From 45e46cf4c163a7af6544645b5216834d4598b85d Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 12 Mar 2013 06:59:12 -0700 Subject: Restore cmake to use 10.6 hacked locally to 10.8 of which TC does not approve --- indra/cmake/Variables.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake index 6297ee822e..4b459f1a48 100644 --- a/indra/cmake/Variables.cmake +++ b/indra/cmake/Variables.cmake @@ -104,8 +104,13 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OUTPUT_VARIABLE XCODE_VERSION ) # To support a different SDK update these Xcode settings: - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.8) - set(CMAKE_OSX_SYSROOT macosx10.8) + if (XCODE_VERSION GREATER 4.2) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6) + else (XCODE_VERSION GREATER 4.2) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5) + endif (XCODE_VERSION GREATER 4.2) + + set(CMAKE_OSX_SYSROOT macosx10.6) set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf-with-dsym) -- cgit v1.2.3 From e08de2f60989658315784f6cc605373e464102a5 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 12 Mar 2013 07:27:31 -0700 Subject: Fix linux_crash_logger freetype fail (now finds prebuilts as it should) --- indra/cmake/Copy3rdPartyLibs.cmake | 1 + indra/cmake/FreeType.cmake | 8 +------- indra/linux_crash_logger/CMakeLists.txt | 2 ++ 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake index c32e357da3..1551b0e3f7 100644 --- a/indra/cmake/Copy3rdPartyLibs.cmake +++ b/indra/cmake/Copy3rdPartyLibs.cmake @@ -266,6 +266,7 @@ elseif(LINUX) libdb-5.1.so libexpat.so libexpat.so.1 + libfreetype.so.6 libglod.so libgmock_main.so libgmock.so.0 diff --git a/indra/cmake/FreeType.cmake b/indra/cmake/FreeType.cmake index 43a9d282d0..c9a90a9a8d 100644 --- a/indra/cmake/FreeType.cmake +++ b/indra/cmake/FreeType.cmake @@ -7,13 +7,7 @@ if (STANDALONE) pkg_check_modules(FREETYPE REQUIRED freetype2) else (STANDALONE) use_prebuilt_binary(freetype) - if (LINUX) - set(FREETYPE_INCLUDE_DIRS - ${LIBS_PREBUILT_DIR}/include) - else (LINUX) - set(FREETYPE_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include) - endif (LINUX) - + set(FREETYPE_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include) set(FREETYPE_LIBRARIES freetype) endif (STANDALONE) diff --git a/indra/linux_crash_logger/CMakeLists.txt b/indra/linux_crash_logger/CMakeLists.txt index 98ebdc7487..5263b59584 100644 --- a/indra/linux_crash_logger/CMakeLists.txt +++ b/indra/linux_crash_logger/CMakeLists.txt @@ -12,6 +12,7 @@ include(LLVFS) include(LLXML) include(Linking) include(UI) +include(FreeType) include_directories( ${LLCOMMON_INCLUDE_DIRS} @@ -53,6 +54,7 @@ target_link_libraries(linux-crash-logger ${LLCOMMON_LIBRARIES} ${UI_LIBRARIES} ${DB_LIBRARIES} + ${FREETYPE_LIBRARIES} ) add_custom_target(linux-crash-logger-target ALL -- cgit v1.2.3 From e8b8a12b7365c17cf0326be365b78bcb1da1bfac Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 12 Mar 2013 10:48:05 -0700 Subject: Mods to make compile on gcc 4.6.3 work mo betta --- indra/cmake/00-Common.cmake | 4 ++++ indra/llmath/llvolume.cpp | 5 ----- indra/llmessage/lliosocket.cpp | 1 + indra/llui/llconsole.cpp | 2 -- indra/llui/llkeywords.cpp | 2 +- indra/llui/lllayoutstack.cpp | 2 +- indra/llui/lltextbase.cpp | 3 ++- indra/llui/lltexteditor.cpp | 1 - indra/llui/lltoolbar.cpp | 4 +--- indra/lscript/lscript_execute/lscript_readlso.cpp | 6 +++--- indra/test/io.cpp | 1 + indra/test/llstreamtools_tut.cpp | 8 +++++++- indra/test/lltemplatemessagebuilder_tut.cpp | 2 ++ 13 files changed, 23 insertions(+), 18 deletions(-) (limited to 'indra') diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 6bfd8c14d6..aa1d50b993 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -135,6 +135,10 @@ if (LINUX) set(CMAKE_CXX_FLAGS "-Wno-deprecated -Wno-uninitialized -Wno-unused-variable -Wno-unused-function ${CMAKE_CXX_FLAGS}") endif (${CXX_VERSION_NUMBER} LESS 420) + if(${CXX_VERSION_NUMBER} GREATER 459) + set(CMAKE_CXX_FLAGS "-Wno-deprecated -Wno-unused-but-set-variable -Wno-unused-variable ${CMAKE_CXX_FLAGS}") + endif (${CXX_VERSION_NUMBER} GREATER 459) + # gcc 4.3 and above don't like the LL boost and also # cause warnings due to our use of deprecated headers if(${CXX_VERSION_NUMBER} GREATER 429) diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index eff224743b..cb5633c1bb 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -5314,12 +5314,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) S32 max_t = volume->getPath().mPath.size(); // S32 i; - S32 num_vertices = 0, num_indices = 0; S32 grid_size = (profile.size()-1)/4; - S32 quad_count = (grid_size * grid_size); - - num_vertices = (grid_size+1)*(grid_size+1); - num_indices = quad_count * 4; LLVector4a& min = mExtents[0]; LLVector4a& max = mExtents[1]; diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index 0287026659..7713e553ef 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -592,6 +592,7 @@ LLIOPipe::EStatus LLIOServerSocket::process_impl( PUMP_DEBUG; apr_pool_t* new_pool = NULL; apr_status_t status = apr_pool_create(&new_pool, mPool); + (void)status; apr_socket_t* socket = NULL; status = apr_socket_accept( &socket, diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index 161496b1f5..fdfaf284de 100644 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -243,8 +243,6 @@ void LLConsole::draw() void LLConsole::Paragraph::makeParagraphColorSegments (const LLColor4 &color) { LLSD paragraph_color_segments; - LLColor4 lcolor=color; - paragraph_color_segments[0]["text"] =wstring_to_utf8str(mParagraphText); LLSD color_sd = color.getValue(); paragraph_color_segments[0]["color"]=color_sd; diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index c1cd04186b..537cc82302 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -368,7 +368,7 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW const llwchar* base = wtext.c_str(); const llwchar* cur = base; const llwchar* line = NULL; - + (void)line; while( *cur ) { if( *cur == '\n' || cur == base ) diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index c93f538570..32383b1f1d 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -481,7 +481,7 @@ void LLLayoutStack::createResizeBar(LLLayoutPanel* panelp) { LLResizeBar::Side side = (mOrientation == HORIZONTAL) ? LLResizeBar::RIGHT : LLResizeBar::BOTTOM; LLRect resize_bar_rect = getRect(); - + (void)resize_bar_rect; LLResizeBar::Params resize_params; resize_params.name("resize"); resize_params.resizing_view(lp); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 3815eec447..ec66b6df56 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -351,7 +351,6 @@ void LLTextBase::drawSelectionBackground() S32 selection_left = llmin( mSelectionStart, mSelectionEnd ); S32 selection_right = llmax( mSelectionStart, mSelectionEnd ); - LLRect selection_rect = mVisibleTextRect; // Skip through the lines we aren't drawing. LLRect content_display_rect = getVisibleDocumentRect(); @@ -2241,6 +2240,8 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, // Figure out which line we're nearest to. LLRect visible_region = getVisibleDocumentRect(); LLRect doc_rect = mDocumentView->getRect(); + (void)visible_region; + (void)doc_rect; S32 doc_y = local_y - doc_rect.mBottom; diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 46fbd1e6a0..e4bd51c8ce 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -2490,7 +2490,6 @@ void LLTextEditor::updateSegments() mKeywords.findSegments(&segment_list, getWText(), mDefaultColor.get(), *this); clearSegments(); - segment_set_t::iterator insert_it = mSegments.begin(); for (segment_vec_t::iterator list_it = segment_list.begin(); list_it != segment_list.end(); ++list_it) { insertSegment(*list_it); diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 63b7e452d2..62b6a0cd2f 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -653,7 +653,6 @@ void LLToolBar::updateLayoutAsNeeded() S32 max_row_length = 0; S32 max_length; - S32 max_total_girth; S32 cur_start; S32 cur_row ; S32 row_pad_start; @@ -664,7 +663,6 @@ void LLToolBar::updateLayoutAsNeeded() if (orientation == LLLayoutStack::HORIZONTAL) { max_length = getRect().getWidth() - mPadLeft - mPadRight; - max_total_girth = getRect().getHeight() - mPadTop - mPadBottom; row_pad_start = mPadLeft; row_pad_end = mPadRight; cur_row = mPadTop; @@ -673,7 +671,6 @@ void LLToolBar::updateLayoutAsNeeded() else // VERTICAL { max_length = getRect().getHeight() - mPadTop - mPadBottom; - max_total_girth = getRect().getWidth() - mPadLeft - mPadRight; row_pad_start = mPadTop; row_pad_end = mPadBottom; cur_row = mPadLeft; @@ -842,6 +839,7 @@ void LLToolBar::draw() { LLRect caret_rect = caret->getRect(); LLRect toolbar_rect = getRect(); + (void)toolbar_rect; if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { caret->setRect(LLRect(mDragx-caret_rect.getWidth()/2+1, diff --git a/indra/lscript/lscript_execute/lscript_readlso.cpp b/indra/lscript/lscript_execute/lscript_readlso.cpp index 35caa41ae1..3cdb41ac17 100644 --- a/indra/lscript/lscript_execute/lscript_readlso.cpp +++ b/indra/lscript/lscript_execute/lscript_readlso.cpp @@ -145,7 +145,7 @@ void LLScriptLSOParse::printGlobals(LLFILE *fp) // get offset to skip past name varoffset = global_v_offset; offset = bytestream2integer(mRawData, global_v_offset); - + (void)offset; //hush little compiler // get typeexport type = *(mRawData + global_v_offset++); @@ -262,8 +262,6 @@ void LLScriptLSOParse::printGlobalFunctions(LLFILE *fp) fprintf(fp, "[Function #%d] [0x%X] %s\n", function_number, orig_function_offset, name); fprintf(fp, "\tReturn Type: %s\n", LSCRIPTTypeNames[type]); type = *(mRawData + function_offset++); - S32 params; - params = 0; S32 pcount = 0; while (type) { @@ -350,6 +348,7 @@ void LLScriptLSOParse::printStates(LLFILE *fp) S32 dummy; opcode_end = worst_case_opcode_end; + (void)opcode_end; for (k = LSTT_STATE_BEGIN; k < LSTT_STATE_END; k++) { @@ -357,6 +356,7 @@ void LLScriptLSOParse::printStates(LLFILE *fp) { temp_end = bytestream2integer(mRawData, read_ahead); dummy = bytestream2integer(mRawData, read_ahead); + (void)dummy; if ( (temp_end < opcode_end) &&(temp_end > event_offset)) { diff --git a/indra/test/io.cpp b/indra/test/io.cpp index ce747f667d..7f26ac6724 100644 --- a/indra/test/io.cpp +++ b/indra/test/io.cpp @@ -1141,6 +1141,7 @@ namespace tut ensure("Connected to server", connected); lldebugs << "connected" << llendl; F32 elapsed = pump_loop(mPump,0.1f); + (void)elapsed; count = mPump->runningChains(); ensure_equals("server chain onboard", count, 2); lldebugs << "** Client is connected." << llendl; diff --git a/indra/test/llstreamtools_tut.cpp b/indra/test/llstreamtools_tut.cpp index a93f2e8f65..68e56b5ee2 100644 --- a/indra/test/llstreamtools_tut.cpp +++ b/indra/test/llstreamtools_tut.cpp @@ -386,15 +386,17 @@ namespace tut std::string actual_result; std::istringstream is; bool ret; - is.clear(); is.str(str = " First Second \t \r \n Third Fourth-ShouldThisBePartOfFourth Fifth\n"); actual_result = ""; ret = get_word(actual_result, is); // First + (void)ret; actual_result = ""; ret = get_word(actual_result, is); // Second + (void)ret; actual_result = ""; ret = get_word(actual_result, is); // Third + (void)ret; // the current implementation of get_word seems inconsistent with // skip_to_next_word. skip_to_next_word treats any character other @@ -486,6 +488,7 @@ namespace tut is.str(str = "First Second \t \r\n Third Fourth-ShouldThisBePartOfFourth IsThisFifth\n"); actual_result = ""; ret = get_line(actual_result, is); + (void)ret; expected_result = "First Second \t \r\n"; ensure_equals("get_line: 1", actual_result, expected_result); @@ -551,6 +554,7 @@ namespace tut is.str(str = "Should not skip lone \r.\r\n"); actual_result = ""; ret = get_line(actual_result, is); + (void)ret; expected_result = "Should not skip lone \r.\r\n"; ensure_equals("get_line: carriage return skipped even though not followed by newline", actual_result, expected_result); } @@ -569,6 +573,7 @@ namespace tut is.str(str = "\n"); actual_result = ""; ret = get_line(actual_result, is); + (void)ret; expected_result = "\n"; ensure_equals("get_line: Just newline", actual_result, expected_result); } @@ -588,6 +593,7 @@ namespace tut is.str(str = "First Line.\nSecond Line.\n"); actual_result = ""; ret = get_line(actual_result, is, 255); + (void)ret; expected_result = "First Line.\n"; ensure_equals("get_line: Basic Operation", actual_result, expected_result); diff --git a/indra/test/lltemplatemessagebuilder_tut.cpp b/indra/test/lltemplatemessagebuilder_tut.cpp index 6e1c82bb24..0aad3cbc15 100644 --- a/indra/test/lltemplatemessagebuilder_tut.cpp +++ b/indra/test/lltemplatemessagebuilder_tut.cpp @@ -958,11 +958,13 @@ namespace tut reader->validateMessage(buffer, builtSize, LLHost()); reader->readMessage(buffer, LLHost()); reader->getU32(_PREHASH_Test0, _PREHASH_Test0, outValue); + (void)outValue; char outBuffer[bufferSize]; memset(buffer, 0xcc, bufferSize); reader->getString(_PREHASH_Test1, _PREHASH_Test0, bufferSize, outBuffer); outValue2 = reader->getNumberOfBlocks(_PREHASH_Test1); + (void)outValue2; ensure_equals("Ensure present value ", outValue, inValue); ensure_equals("Ensure unchanged buffer ", strlen(outBuffer), 0); delete reader; -- cgit v1.2.3 From 5d2fea6262d91eb8d3c06d97a160ca9373b96889 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Wed, 13 Mar 2013 10:42:40 -0700 Subject: Move fast memcpy to llcommon and use it in llalignedarray pushback on all platforms. Code Review: DaveP --- indra/llcommon/llalignedarray.h | 16 +----- indra/llcommon/llmemory.h | 116 +++++++++++++++++++++++++++++++++++++--- indra/llmath/llsimdmath.h | 28 ---------- indra/llmath/llvector4a.cpp | 50 +---------------- indra/llmath/llvector4a.h | 4 -- indra/llmath/llvolume.cpp | 11 ++-- 6 files changed, 120 insertions(+), 105 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llalignedarray.h b/indra/llcommon/llalignedarray.h index 5e04e8050f..ed8fd31205 100644 --- a/indra/llcommon/llalignedarray.h +++ b/indra/llcommon/llalignedarray.h @@ -29,10 +29,6 @@ #include "llmemory.h" -#if LL_WINDOWS -#include "llvector4a.h" // for 16b fast copy -#endif - template class LLAlignedArray { @@ -81,11 +77,7 @@ void LLAlignedArray::push_back(const T& elem) T* new_buf = (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment); if (mArray) { -#if LL_WINDOWS - LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); -#else - memcpy((F32*)new_buf, (F32*)mArray, sizeof(T)*mElementCount); -#endif + ll_memcpy_nonaliased_aligned_16((char*)new_buf, (char*)mArray, sizeof(T)*mElementCount); } old_buf = mArray; mArray = new_buf; @@ -106,11 +98,7 @@ void LLAlignedArray::resize(U32 size) T* new_buf = mCapacity > 0 ? (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment) : NULL; if (mArray) { -#if LL_WINDOWS - LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); -#else - memcpy((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount); -#endif + ll_memcpy_nonaliased_aligned_16((char*) new_buf, (char*) mArray, sizeof(T)*mElementCount); ll_aligned_free(mArray); } diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 46cabfadcd..61e30f11cc 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -36,6 +36,44 @@ class LLMutex ; #define LL_CHECK_MEMORY #endif +LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment); + +#ifdef SHOW_ASSERT +#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast(ptr),((U32)alignment)) +#else +#define ll_assert_aligned(ptr,alignment) +#endif + +#include + +template T* LL_NEXT_ALIGNED_ADDRESS(T* address) +{ + return reinterpret_cast( + (reinterpret_cast(address) + 0xF) & ~0xF); +} + +template T* LL_NEXT_ALIGNED_ADDRESS_64(T* address) +{ + return reinterpret_cast( + (reinterpret_cast(address) + 0x3F) & ~0x3F); +} + +#if LL_LINUX || LL_DARWIN + +#define LL_ALIGN_PREFIX(x) +#define LL_ALIGN_POSTFIX(x) __attribute__((aligned(x))) + +#elif LL_WINDOWS + +#define LL_ALIGN_PREFIX(x) __declspec(align(x)) +#define LL_ALIGN_POSTFIX(x) + +#else +#error "LL_ALIGN_PREFIX and LL_ALIGN_POSTFIX undefined" +#endif + +#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16) + inline void* ll_aligned_malloc( size_t size, int align ) { #if defined(LL_WINDOWS) @@ -144,6 +182,78 @@ inline void ll_aligned_free_32(void *p) #endif } + +// Copy words 16-byte blocks from src to dst. Source and destination MUST NOT OVERLAP. +// Source and dest must be 16-byte aligned and size must be multiple of 16. +// +inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __restrict src, size_t bytes) +{ + assert(src != NULL); + assert(dst != NULL); + assert(bytes > 0); + assert((bytes % sizeof(F32))== 0); + ll_assert_aligned(src,16); + ll_assert_aligned(dst,16); + assert((src < dst) ? ((src + bytes) < dst) : ((dst + bytes) < src)); + assert(bytes%16==0); + + char* end = dst + bytes; + + if (bytes > 64) + { + + // Find start of 64b aligned area within block + // + void* begin_64 = LL_NEXT_ALIGNED_ADDRESS_64(dst); + + //at least 64 bytes before the end of the destination, switch to 16 byte copies + void* end_64 = end-64; + + // Prefetch the head of the 64b area now + // + _mm_prefetch((char*)begin_64, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 64, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 128, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 192, _MM_HINT_NTA); + + // Copy 16b chunks until we're 64b aligned + // + while (dst < begin_64) + { + + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + dst += 16; + src += 16; + } + + // Copy 64b chunks up to your tail + // + // might be good to shmoo the 512b prefetch offset + // (characterize performance for various values) + // + while (dst < end_64) + { + _mm_prefetch((char*)src + 512, _MM_HINT_NTA); + _mm_prefetch((char*)dst + 512, _MM_HINT_NTA); + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + _mm_store_ps((F32*)(dst + 16), _mm_load_ps((F32*)(src + 16))); + _mm_store_ps((F32*)(dst + 32), _mm_load_ps((F32*)(src + 32))); + _mm_store_ps((F32*)(dst + 48), _mm_load_ps((F32*)(src + 48))); + dst += 64; + src += 64; + } + } + + // Copy remainder 16b tail chunks (or ALL 16b chunks for sub-64b copies) + // + while (dst < end) + { + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + dst += 16; + src += 16; + } +} + #ifndef __DEBUG_PRIVATE_MEM__ #define __DEBUG_PRIVATE_MEM__ 0 #endif @@ -552,13 +662,7 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr) // LLSingleton moved to llsingleton.h -LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment); -#ifdef SHOW_ASSERT -#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast(ptr),((U32)alignment)) -#else -#define ll_assert_aligned(ptr,alignment) -#endif #endif diff --git a/indra/llmath/llsimdmath.h b/indra/llmath/llsimdmath.h index 01458521ec..cebd2ace7d 100644 --- a/indra/llmath/llsimdmath.h +++ b/indra/llmath/llsimdmath.h @@ -39,34 +39,6 @@ #include #endif -template T* LL_NEXT_ALIGNED_ADDRESS(T* address) -{ - return reinterpret_cast( - (reinterpret_cast(address) + 0xF) & ~0xF); -} - -template T* LL_NEXT_ALIGNED_ADDRESS_64(T* address) -{ - return reinterpret_cast( - (reinterpret_cast(address) + 0x3F) & ~0x3F); -} - -#if LL_LINUX || LL_DARWIN - -#define LL_ALIGN_PREFIX(x) -#define LL_ALIGN_POSTFIX(x) __attribute__((aligned(x))) - -#elif LL_WINDOWS - -#define LL_ALIGN_PREFIX(x) __declspec(align(x)) -#define LL_ALIGN_POSTFIX(x) - -#else -#error "LL_ALIGN_PREFIX and LL_ALIGN_POSTFIX undefined" -#endif - -#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16) - #include #include diff --git a/indra/llmath/llvector4a.cpp b/indra/llmath/llvector4a.cpp index 6edeb0fefe..570fa41a43 100644 --- a/indra/llmath/llvector4a.cpp +++ b/indra/llmath/llvector4a.cpp @@ -41,55 +41,7 @@ extern const LLVector4a LL_V4A_EPSILON = reinterpret_cast ( F /*static */void LLVector4a::memcpyNonAliased16(F32* __restrict dst, const F32* __restrict src, size_t bytes) { - assert(src != NULL); - assert(dst != NULL); - assert(bytes > 0); - assert((bytes % sizeof(F32))== 0); - ll_assert_aligned(src,16); - ll_assert_aligned(dst,16); - assert(bytes%16==0); - - F32* end = dst + (bytes / sizeof(F32) ); - - if (bytes > 64) - { - F32* begin_64 = LL_NEXT_ALIGNED_ADDRESS_64(dst); - - //at least 64 (16*4) bytes before the end of the destination, switch to 16 byte copies - F32* end_64 = end-16; - - _mm_prefetch((char*)begin_64, _MM_HINT_NTA); - _mm_prefetch((char*)begin_64 + 64, _MM_HINT_NTA); - _mm_prefetch((char*)begin_64 + 128, _MM_HINT_NTA); - _mm_prefetch((char*)begin_64 + 192, _MM_HINT_NTA); - - while (dst < begin_64) - { - copy4a(dst, src); - dst += 4; - src += 4; - } - - while (dst < end_64) - { - _mm_prefetch((char*)src + 512, _MM_HINT_NTA); - _mm_prefetch((char*)dst + 512, _MM_HINT_NTA); - copy4a(dst, src); - copy4a(dst+4, src+4); - copy4a(dst+8, src+8); - copy4a(dst+12, src+12); - - dst += 16; - src += 16; - } - } - - while (dst < end) - { - copy4a(dst, src); - dst += 4; - src += 4; - } + ll_memcpy_nonaliased_aligned_16((char*)dst, (char*)src, bytes); } void LLVector4a::setRotated( const LLRotation& rot, const LLVector4a& vec ) diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h index 1a478bc8de..0526793d3a 100644 --- a/indra/llmath/llvector4a.h +++ b/indra/llmath/llvector4a.h @@ -93,11 +93,7 @@ public: LLVector4a() { //DO NOT INITIALIZE -- The overhead is completely unnecessary -// This assert is causing spurious referenced before set warnings on GCC 4.3.4 -// -#if !LL_LINUX ll_assert_aligned(this,16); -#endif } LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f) diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 4f3e753276..e7a0bc7df7 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4729,10 +4729,13 @@ void LLVolumeFace::optimize(F32 angle_cutoff) } } - llassert(new_face.mNumIndices == mNumIndices); - llassert(new_face.mNumVertices <= mNumVertices); - - swapData(new_face); + // Only swap data if we've actually optimized the mesh + // + if (new_face.mNumVertices < mNumVertices) + { + llassert(new_face.mNumIndices == mNumIndices); + swapData(new_face); + } } class LLVCacheTriangleData; -- cgit v1.2.3 From bba84a3fa9a1af87f6a8080f9093f9277feb1292 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Wed, 13 Mar 2013 13:38:30 -0700 Subject: Cleanup per code review of prev change with DaveP --- indra/llcommon/llmemory.h | 12 ++++++------ indra/llmath/llvolume.cpp | 11 +++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 61e30f11cc..d0e4bc9e25 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -188,14 +188,14 @@ inline void ll_aligned_free_32(void *p) // inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __restrict src, size_t bytes) { - assert(src != NULL); - assert(dst != NULL); - assert(bytes > 0); - assert((bytes % sizeof(F32))== 0); + llassert(src != NULL); + llassert(dst != NULL); + llassert(bytes >= 16); + llassert((bytes % sizeof(F32))== 0); + llassert((src < dst) ? ((src + bytes) < dst) : ((dst + bytes) < src)); + llassert(bytes%16==0); ll_assert_aligned(src,16); ll_assert_aligned(dst,16); - assert((src < dst) ? ((src + bytes) < dst) : ((dst + bytes) < src)); - assert(bytes%16==0); char* end = dst + bytes; diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index cb5633c1bb..edd16b5688 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4729,11 +4729,13 @@ void LLVolumeFace::optimize(F32 angle_cutoff) } } - if (new_face.mNumVertices) + // disallow data amplification + // + if (new_face.mNumVertices <= mNumVertices) { - llassert(new_face.mNumIndices == mNumIndices); - swapData(new_face); - } + llassert(new_face.mNumIndices == mNumIndices); + swapData(new_face); + } } class LLVCacheTriangleData; @@ -6731,3 +6733,4 @@ void calc_binormal_from_triangle(LLVector4a& binormal, binormal.set( 0, 1 , 0 ); } } + -- cgit v1.2.3 From 08ae21f52dbbe6245ac8deee0fdfd5df4d3dba53 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 13 Mar 2013 17:07:22 -0500 Subject: MAINT-2410 Extra Particle Parameters -- viewer implementation Reviewed by Kelly and Graham --- indra/llmessage/llpartdata.cpp | 257 ++++++++++++++++++----------- indra/llmessage/llpartdata.h | 22 ++- indra/llrender/llvertexbuffer.cpp | 9 +- indra/newview/lldrawpoolalpha.cpp | 38 +++-- indra/newview/llspatialpartition.cpp | 4 +- indra/newview/llspatialpartition.h | 2 + indra/newview/llviewerobject.cpp | 21 ++- indra/newview/llviewerobject.h | 8 +- indra/newview/llviewerpartsim.cpp | 27 +++- indra/newview/llviewerpartsim.h | 9 +- indra/newview/llviewerpartsource.cpp | 75 ++++++++- indra/newview/llviewerpartsource.h | 4 +- indra/newview/llvograss.cpp | 7 +- indra/newview/llvograss.h | 1 + indra/newview/llvopartgroup.cpp | 305 +++++++++++++++++++++++++---------- indra/newview/llvopartgroup.h | 6 +- indra/newview/llvovolume.cpp | 6 +- 17 files changed, 573 insertions(+), 228 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llpartdata.cpp b/indra/llmessage/llpartdata.cpp index c0fd3c9542..0f33a94295 100644 --- a/indra/llmessage/llpartdata.cpp +++ b/indra/llmessage/llpartdata.cpp @@ -37,9 +37,21 @@ -const S32 PS_PART_DATA_GLOW_BLEND_SIZE = 4; -const S32 PS_PART_DATA_BLOCK_SIZE = 4 + 2 + 4 + 4 + 2 + 2; // 18 -const S32 PS_DATA_BLOCK_SIZE = 68 + PS_PART_DATA_BLOCK_SIZE + PS_PART_DATA_GLOW_BLEND_SIZE; // 68 + 18 + 4 = 90 +const S32 PS_PART_DATA_GLOW_SIZE = 2; +const S32 PS_PART_DATA_BLEND_SIZE = 2; +const S32 PS_LEGACY_PART_DATA_BLOCK_SIZE = 4 + 2 + 4 + 4 + 2 + 2; //18 +const S32 PS_SYS_DATA_BLOCK_SIZE = 68; +const S32 PS_MAX_DATA_BLOCK_SIZE = PS_SYS_DATA_BLOCK_SIZE+ + PS_LEGACY_PART_DATA_BLOCK_SIZE + + PS_PART_DATA_BLEND_SIZE + + PS_PART_DATA_GLOW_SIZE+ + 8; //two S32 size fields + +const S32 PS_LEGACY_DATA_BLOCK_SIZE = PS_SYS_DATA_BLOCK_SIZE + PS_LEGACY_PART_DATA_BLOCK_SIZE; + + +const U32 PART_DATA_MASK = LLPartData::LL_PART_DATA_GLOW | LLPartData::LL_PART_DATA_BLEND; + const F32 MAX_PART_SCALE = 4.f; @@ -49,28 +61,9 @@ bool LLPartData::hasGlow() const return mStartGlow > 0.f || mEndGlow > 0.f; } -BOOL LLPartData::pack(LLDataPacker &dp) +bool LLPartData::hasBlendFunc() const { - LLColor4U coloru; - dp.packU32(mFlags, "pdflags"); - dp.packFixed(mMaxAge, "pdmaxage", FALSE, 8, 8); - coloru.setVec(mStartColor); - dp.packColor4U(coloru, "pdstartcolor"); - coloru.setVec(mEndColor); - dp.packColor4U(coloru, "pdendcolor"); - dp.packFixed(mStartScale.mV[0], "pdstartscalex", FALSE, 3, 5); - dp.packFixed(mStartScale.mV[1], "pdstartscaley", FALSE, 3, 5); - dp.packFixed(mEndScale.mV[0], "pdendscalex", FALSE, 3, 5); - dp.packFixed(mEndScale.mV[1], "pdendscaley", FALSE, 3, 5); - - if (hasGlow() || hasBlendFunc()) - { - dp.packU8(mStartGlow * 255,"pdstartglow"); - dp.packU8(mEndGlow * 255,"pdendglow"); - dp.packU8(mBlendFuncSource,"pdblendsource"); - dp.packU8(mBlendFuncDest,"pdblenddest"); - } - return TRUE; + return mBlendFuncSource != LLPartData::LL_PART_BF_SOURCE_ALPHA || mBlendFuncDest != LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; } LLSD LLPartData::asLLSD() const @@ -107,8 +100,17 @@ bool LLPartData::fromLLSD(LLSD& sd) return true; } +S32 LLPartData::getSize() const +{ + S32 size = PS_LEGACY_PART_DATA_BLOCK_SIZE; + if (hasGlow()) size += PS_PART_DATA_GLOW_SIZE; + if (hasBlendFunc()) size += PS_PART_DATA_BLEND_SIZE; + + return size; +} -BOOL LLPartData::unpack(LLDataPacker &dp) + +BOOL LLPartData::unpackLegacy(LLDataPacker &dp) { LLColor4U coloru; @@ -124,7 +126,7 @@ BOOL LLPartData::unpack(LLDataPacker &dp) dp.unpackFixed(mEndScale.mV[0], "pdendscalex", FALSE, 3, 5); dp.unpackFixed(mEndScale.mV[1], "pdendscaley", FALSE, 3, 5); - if (dp.hasNext()) + /*if (dp.hasNext()) { U8 tmp_glow = 0; dp.unpackU8(tmp_glow,"pdstartglow"); @@ -133,11 +135,71 @@ BOOL LLPartData::unpack(LLDataPacker &dp) mEndGlow = tmp_glow / 255.f; dp.unpackU8(mBlendFuncSource,"pdblendsource"); dp.unpackU8(mBlendFuncDest,"pdblenddest"); - } + }*/ + + mStartGlow = 0.f; + mEndGlow = 0.f; + mBlendFuncSource = LLPartData::LL_PART_BF_SOURCE_ALPHA; + mBlendFuncDest = LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; return TRUE; } +BOOL LLPartData::unpack(LLDataPacker &dp) +{ + S32 size = 0; + dp.unpackS32(size, "partsize"); + + unpackLegacy(dp); + size -= PS_LEGACY_PART_DATA_BLOCK_SIZE; + + if (mFlags & LL_PART_DATA_GLOW) + { + if (size < PS_PART_DATA_GLOW_SIZE) return FALSE; + + U8 tmp_glow = 0; + dp.unpackU8(tmp_glow,"pdstartglow"); + mStartGlow = tmp_glow / 255.f; + dp.unpackU8(tmp_glow,"pdendglow"); + mEndGlow = tmp_glow / 255.f; + + size -= PS_PART_DATA_GLOW_SIZE; + } + else + { + mStartGlow = 0.f; + mEndGlow = 0.f; + } + + if (mFlags & LL_PART_DATA_BLEND) + { + if (size < PS_PART_DATA_BLEND_SIZE) return FALSE; + dp.unpackU8(mBlendFuncSource,"pdblendsource"); + dp.unpackU8(mBlendFuncDest,"pdblenddest"); + size -= PS_PART_DATA_BLEND_SIZE; + } + else + { + mBlendFuncSource = LLPartData::LL_PART_BF_SOURCE_ALPHA; + mBlendFuncDest = LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; + } + + if (size > 0) + { //leftover bytes, unrecognized parameters + U8 feh = 0; + while (size > 0) + { //read remaining bytes in block + dp.unpackU8(feh, "whippang"); + size--; + } + + //this particle system won't display properly, better to not show anything + return FALSE; + } + + + return TRUE; +} void LLPartData::setFlags(const U32 flags) { @@ -228,38 +290,7 @@ LLPartSysData::LLPartSysData() mNumParticles = 0; } - -BOOL LLPartSysData::pack(LLDataPacker &dp) -{ - dp.packU32(mCRC, "pscrc"); - dp.packU32(mFlags, "psflags"); - dp.packU8(mPattern, "pspattern"); - dp.packFixed(mMaxAge, "psmaxage", FALSE, 8, 8); - dp.packFixed(mStartAge, "psstartage", FALSE, 8, 8); - dp.packFixed(mInnerAngle, "psinnerangle", FALSE, 3, 5); - dp.packFixed(mOuterAngle, "psouterangle", FALSE, 3, 5); - dp.packFixed(mBurstRate, "psburstrate", FALSE, 8, 8); - dp.packFixed(mBurstRadius, "psburstradius", FALSE, 8, 8); - dp.packFixed(mBurstSpeedMin, "psburstspeedmin", FALSE, 8, 8); - dp.packFixed(mBurstSpeedMax, "psburstspeedmax", FALSE, 8, 8); - dp.packU8(mBurstPartCount, "psburstpartcount"); - - dp.packFixed(mAngularVelocity.mV[0], "psangvelx", TRUE, 8, 7); - dp.packFixed(mAngularVelocity.mV[1], "psangvely", TRUE, 8, 7); - dp.packFixed(mAngularVelocity.mV[2], "psangvelz", TRUE, 8, 7); - - dp.packFixed(mPartAccel.mV[0], "psaccelx", TRUE, 8, 7); - dp.packFixed(mPartAccel.mV[1], "psaccely", TRUE, 8, 7); - dp.packFixed(mPartAccel.mV[2], "psaccelz", TRUE, 8, 7); - - dp.packUUID(mPartImageID, "psuuid"); - dp.packUUID(mTargetUUID, "pstargetuuid"); - mPartData.pack(dp); - return TRUE; -} - - -BOOL LLPartSysData::unpack(LLDataPacker &dp) +BOOL LLPartSysData::unpackSystem(LLDataPacker &dp) { dp.unpackU32(mCRC, "pscrc"); dp.unpackU32(mFlags, "psflags"); @@ -285,10 +316,48 @@ BOOL LLPartSysData::unpack(LLDataPacker &dp) dp.unpackUUID(mPartImageID, "psuuid"); dp.unpackUUID(mTargetUUID, "pstargetuuid"); - mPartData.unpack(dp); return TRUE; } +BOOL LLPartSysData::unpackLegacy(LLDataPacker &dp) +{ + unpackSystem(dp); + mPartData.unpackLegacy(dp); + + return TRUE; +} + +BOOL LLPartSysData::unpack(LLDataPacker &dp) +{ + // syssize is currently unused. Adding now when modifying the 'version to make extensible in the future + S32 size = 0; + dp.unpackS32(size, "syssize"); + + if (size != PS_SYS_DATA_BLOCK_SIZE) + { //unexpected size, this viewer doesn't know how to parse this particle system + + //skip to LLPartData block + U8 feh = 0; + + for (U32 i = 0; i < size; ++i) + { + dp.unpackU8(feh, "whippang"); + } + + dp.unpackS32(size, "partsize"); + //skip LLPartData block + for (U32 i = 0; i < size; ++i) + { + dp.unpackU8(feh, "whippang"); + } + return FALSE; + } + + unpackSystem(dp); + + return mPartData.unpack(dp); +} + std::ostream& operator<<(std::ostream& s, const LLPartSysData &data) { s << "Flags: " << std::hex << data.mFlags; @@ -306,7 +375,7 @@ std::ostream& operator<<(std::ostream& s, const LLPartSysData &data) BOOL LLPartSysData::isNullPS(const S32 block_num) { - U8 ps_data_block[PS_DATA_BLOCK_SIZE]; + U8 ps_data_block[PS_MAX_DATA_BLOCK_SIZE]; U32 crc; S32 size; @@ -318,15 +387,27 @@ BOOL LLPartSysData::isNullPS(const S32 block_num) return TRUE; } - gMessageSystem->getBinaryData("ObjectData", "PSBlock", ps_data_block, PS_DATA_BLOCK_SIZE, block_num, PS_DATA_BLOCK_SIZE); - - if (size > PS_DATA_BLOCK_SIZE) + if (size > PS_MAX_DATA_BLOCK_SIZE) { //size is too big, newer particle version unsupported return TRUE; } + gMessageSystem->getBinaryData("ObjectData", "PSBlock", ps_data_block, size, block_num, PS_MAX_DATA_BLOCK_SIZE); + LLDataPackerBinaryBuffer dp(ps_data_block, size); + if (size > PS_LEGACY_DATA_BLOCK_SIZE) + { + // non legacy systems pack a size before the CRC + S32 tmp = 0; + dp.unpackS32(tmp, "syssize"); + + if (tmp > PS_SYS_DATA_BLOCK_SIZE) + { //unknown system data block size, don't know how to parse it, treat as NULL + return TRUE; + } + } + dp.unpackU32(crc, "crc"); if (crc == 0) @@ -336,53 +417,37 @@ BOOL LLPartSysData::isNullPS(const S32 block_num) return FALSE; } - -//static -BOOL LLPartSysData::packNull() -{ - U8 ps_data_block[PS_DATA_BLOCK_SIZE]; - gMessageSystem->addBinaryData("PSBlock", ps_data_block, 0); - return TRUE; -} - - -BOOL LLPartSysData::packBlock() -{ - U8 ps_data_block[PS_DATA_BLOCK_SIZE]; - - LLDataPackerBinaryBuffer dp(ps_data_block, PS_DATA_BLOCK_SIZE); - - pack(dp); - - S32 size = dp.getCurrentSize(); - - // Add to message - gMessageSystem->addBinaryData("PSBlock", ps_data_block, size); - - return TRUE; -} - - BOOL LLPartSysData::unpackBlock(const S32 block_num) { - U8 ps_data_block[PS_DATA_BLOCK_SIZE]; + U8 ps_data_block[PS_MAX_DATA_BLOCK_SIZE]; // Check size of block S32 size = gMessageSystem->getSize("ObjectData", block_num, "PSBlock"); - if (size > PS_DATA_BLOCK_SIZE) + if (size > PS_MAX_DATA_BLOCK_SIZE) { // Larger packets are newer and unsupported return FALSE; } // Get from message - gMessageSystem->getBinaryData("ObjectData", "PSBlock", ps_data_block, size, block_num, PS_DATA_BLOCK_SIZE); + gMessageSystem->getBinaryData("ObjectData", "PSBlock", ps_data_block, size, block_num, PS_MAX_DATA_BLOCK_SIZE); LLDataPackerBinaryBuffer dp(ps_data_block, size); - unpack(dp); - return TRUE; + if (size == PS_LEGACY_DATA_BLOCK_SIZE) + { + return unpackLegacy(dp); + } + else + { + return unpack(dp); + } +} + +bool LLPartSysData::isLegacyCompatible() const +{ + return !mPartData.hasGlow() && !mPartData.hasBlendFunc(); } void LLPartSysData::clampSourceParticleRate() diff --git a/indra/llmessage/llpartdata.h b/indra/llmessage/llpartdata.h index 19207d994d..80a52b79dd 100644 --- a/indra/llmessage/llpartdata.h +++ b/indra/llmessage/llpartdata.h @@ -88,7 +88,9 @@ public: mParameter(0.f) { } + BOOL unpackLegacy(LLDataPacker &dp); BOOL unpack(LLDataPacker &dp); + BOOL pack(LLDataPacker &dp); LLSD asLLSD() const; operator LLSD() const {return asLLSD(); } @@ -117,6 +119,10 @@ public: //LL_PART_RANDOM_VEL_MASK = 0x200, // Particles have random velocity shifts" //LL_PART_TRAIL_MASK = 0x400, // Particles have historical "trails" + //sYSTEM SET FLAGS + LL_PART_DATA_GLOW = 0x10000, + LL_PART_DATA_BLEND = 0x20000, + // Viewer side use only! LL_PART_HUD = 0x40000000, LL_PART_DEAD_MASK = 0x80000000, @@ -152,6 +158,9 @@ public: friend class LLPartSysData; friend class LLViewerPartSourceScript; +private: + S32 getSize() const; + // These are public because I'm really lazy... public: U32 mFlags; // Particle state/interpolators in effect @@ -178,15 +187,13 @@ public: LLPartSysData(); BOOL unpack(LLDataPacker &dp); - BOOL pack(LLDataPacker &dp); - - + BOOL unpackLegacy(LLDataPacker &dp); BOOL unpackBlock(const S32 block_num); - BOOL packBlock(); - - static BOOL packNull(); + static BOOL isNullPS(const S32 block_num); // Returns FALSE if this is a "NULL" particle system (i.e. no system) + bool isLegacyCompatible() const; + // Different masks for effects on the source enum { @@ -222,6 +229,9 @@ public: S32 getdataBlockSize() const; +private: + BOOL unpackSystem(LLDataPacker &dp); + public: // Public because I'm lazy.... diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 1d257d8415..4460461e12 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -2360,7 +2360,8 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) if (data_mask & MAP_COLOR) { S32 loc = TYPE_COLOR; - void* ptr = (void*)(base + mOffsets[TYPE_COLOR]); + //bind emissive instead of color pointer if emissive is present + void* ptr = (data_mask & MAP_EMISSIVE) ? (void*)(base + mOffsets[TYPE_EMISSIVE]) : (void*)(base + mOffsets[TYPE_COLOR]); glVertexAttribPointerARB(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_COLOR], ptr); } if (data_mask & MAP_EMISSIVE) @@ -2368,6 +2369,12 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) S32 loc = TYPE_EMISSIVE; void* ptr = (void*)(base + mOffsets[TYPE_EMISSIVE]); glVertexAttribPointerARB(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], ptr); + + if (!(data_mask & MAP_COLOR)) + { //map emissive to color channel when color is not also being bound to avoid unnecessary shader swaps + loc = TYPE_COLOR; + glVertexAttribPointerARB(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], ptr); + } } if (data_mask & MAP_WEIGHT) { diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 313b310e1e..6fa16825df 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -394,10 +394,15 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) if (group->mSpatialPartition->mRenderByGroup && !group->isDead()) { - bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow. - // All particle systems seem to come off the wire with texture entries which claim that they glow. This is probably a bug in the data. Suppress. - group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_PARTICLE && - group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD_PARTICLE; + static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_GROUP_LOOP("Alpha Group"); + LLFastTimer t(FTM_RENDER_ALPHA_GROUP_LOOP); + + bool draw_glow_for_this_partition = mVertexShaderLevel > 0; // no shaders = no glow. + + bool disable_cull = group->mSpatialPartition->mPartitionType == LLViewerRegion::PARTITION_PARTICLE || + group->mSpatialPartition->mPartitionType == LLViewerRegion::PARTITION_HUD_PARTICLE; + + LLGLDisable cull(disable_cull ? GL_CULL_FACE : 0); LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA]; @@ -498,32 +503,31 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) } } - params.mVertexBuffer->setBuffer(mask); - params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); - gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); + static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_PUSH("Alpha Push Verts"); + { + LLFastTimer t(FTM_RENDER_ALPHA_PUSH); + gGL.blendFunc((LLRender::eBlendFactor) params.mBlendFuncSrc, (LLRender::eBlendFactor) params.mBlendFuncDst, mAlphaSFactor, mAlphaDFactor); + params.mVertexBuffer->setBuffer(mask); + params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); + gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); + } // If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha. if (current_shader && draw_glow_for_this_partition && params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE)) { + static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_GLOW("Alpha Glow"); + LLFastTimer t(FTM_RENDER_ALPHA_GLOW); // install glow-accumulating blend mode gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE, // don't touch color LLRender::BF_ONE, LLRender::BF_ONE); // add to alpha (glow) - emissive_shader->bind(); - - // glow doesn't use vertex colors from the mesh data - params.mVertexBuffer->setBuffer((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); + params.mVertexBuffer->setBuffer(mask | LLVertexBuffer::MAP_EMISSIVE); // do the actual drawing, again params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); - - // restore our alpha blend mode - gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); - - current_shader->bind(); } if (tex_setup) @@ -536,6 +540,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) } } + gGL.setSceneBlendType(LLRender::BT_ALPHA); + LLVertexBuffer::unbind(); if (!light_enabled) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index dd69172184..1ec56eb5f8 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -4654,7 +4654,9 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, mGroup(NULL), mFace(NULL), mDistance(0.f), - mDrawMode(LLRender::TRIANGLES) + mDrawMode(LLRender::TRIANGLES), + mBlendFuncSrc(LLRender::BF_SOURCE_ALPHA), + mBlendFuncDst(LLRender::BF_ONE_MINUS_SOURCE_ALPHA) { mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset); diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index b5543c4a37..08e77855c4 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -119,6 +119,8 @@ public: LL_ALIGN_16(LLFace* mFace); //associated face F32 mDistance; U32 mDrawMode; + U32 mBlendFuncSrc; + U32 mBlendFuncDst; struct CompareTexture { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index b1a60197a2..09cc4a1121 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -1553,6 +1553,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, dp->setPassFlags(value); dp->unpackUUID(owner_id, "Owner"); + mOwnerID = owner_id; + if (value & 0x80) { dp->unpackVector3(new_angv, "Omega"); @@ -1626,13 +1628,13 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, retval |= checkMediaURL(media_url); // - // Unpack particle system data + // Unpack particle system data (legacy) // if (value & 0x8) { - unpackParticleSource(*dp, owner_id); + unpackParticleSource(*dp, owner_id, true); } - else + else if (!(value & 0x400)) { deleteParticleSource(); } @@ -1697,7 +1699,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, // keep local flags and overwrite remote-controlled flags mFlags = (mFlags & FLAGS_LOCAL) | flags; - // ...new objects that should come in selected need to be added to the selected list + // ...new objects that should come in selected need to be added to the selected list mCreateSelected = ((flags & FLAGS_CREATE_SELECTED) != 0); } break; @@ -4604,7 +4606,7 @@ void LLViewerObject::unpackParticleSource(const S32 block_num, const LLUUID& own } } -void LLViewerObject::unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_id) +void LLViewerObject::unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_id, bool legacy) { if (!mPartSourcep.isNull() && mPartSourcep->isDead()) { @@ -4613,7 +4615,7 @@ void LLViewerObject::unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_ if (mPartSourcep) { // If we've got one already, just update the existing source (or remove it) - if (!LLViewerPartSourceScript::unpackPSS(this, mPartSourcep, dp)) + if (!LLViewerPartSourceScript::unpackPSS(this, mPartSourcep, dp, legacy)) { mPartSourcep->setDead(); mPartSourcep = NULL; @@ -4621,7 +4623,7 @@ void LLViewerObject::unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_ } else { - LLPointer pss = LLViewerPartSourceScript::unpackPSS(this, NULL, dp); + LLPointer pss = LLViewerPartSourceScript::unpackPSS(this, NULL, dp, legacy); //If the owner is muted, don't create the system if(LLMuteList::getInstance()->isMuted(owner_id, LLMute::flagParticles)) return; // We need to be able to deal with a particle source that hasn't changed, but still got an update! @@ -5467,6 +5469,11 @@ F32 LLAlphaObject::getPartSize(S32 idx) return 0.f; } +void LLAlphaObject::getBlendFunc(S32 face, U32& src, U32& dst) +{ + +} + // virtual void LLStaticViewerObject::updateDrawable(BOOL force_damped) { diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 97cf0a4850..cab617b745 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -584,6 +584,7 @@ public: } EPhysicsShapeType; LLUUID mID; + LLUUID mOwnerID; //null if unknown // unique within region, not unique across regions // Local ID = 0 is not used @@ -662,7 +663,7 @@ protected: BOOL isOnMap(); void unpackParticleSource(const S32 block_num, const LLUUID& owner_id); - void unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_id); + void unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_id, bool legacy); void deleteParticleSource(); void setParticleSource(const LLPartSysData& particle_parameters, const LLUUID& owner_id); @@ -826,9 +827,12 @@ public: LLStrider& verticesp, LLStrider& normalsp, LLStrider& texcoordsp, - LLStrider& colorsp, + LLStrider& colorsp, + LLStrider& emissivep, LLStrider& indicesp) = 0; + virtual void getBlendFunc(S32 face, U32& src, U32& dst); + F32 mDepth; }; diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 61cdfd7818..21f1d2619c 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -80,12 +80,31 @@ LLViewerPart::LLViewerPart() : mImagep(NULL) { mPartSourcep = NULL; - + mParent = NULL; + mChild = NULL; ++LLViewerPartSim::sParticleCount2 ; } LLViewerPart::~LLViewerPart() { + if (mPartSourcep.notNull() && mPartSourcep->mLastPart == this) + { + mPartSourcep->mLastPart = NULL; + } + + //patch up holes in the ribbon + if (mParent) + { + llassert(mParent->mChild == this); + mParent->mChild = mChild; + } + + if (mChild) + { + llassert (mChild->mParent == this); + mChild->mParent = mParent; + } + mPartSourcep = NULL; --LLViewerPartSim::sParticleCount2 ; @@ -367,6 +386,9 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt) part->mScale += frac*part->mEndScale; } + // Do glow interpolation + part->mGlow.mV[3] = (U8) (lerp(part->mStartGlow, part->mEndGlow, frac)*255.f); + // Set the last update time to now. part->mLastUpdateTime = cur_time; @@ -623,6 +645,9 @@ void LLViewerPartSim::updateSimulation() { static LLFrameTimer update_timer; + //reset VBO cursor + LLVOPartGroup::sVBSlotCursor = 0; + const F32 dt = llmin(update_timer.getElapsedTimeAndResetF32(), 0.1f); if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES))) diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h index c91fcf0691..095de2060c 100644 --- a/indra/newview/llviewerpartsim.h +++ b/indra/newview/llviewerpartsim.h @@ -65,15 +65,22 @@ public: LLVPCallback mVPCallback; // Callback function for more complicated behaviors LLPointer mPartSourcep; // Particle source used for this object - + + LLViewerPart* mParent; // particle to connect to if this is part of a particle ribbon + LLViewerPart* mChild; // child particle for clean reference destruction // Current particle state (possibly used for rendering) LLPointer mImagep; LLVector3 mPosAgent; LLVector3 mVelocity; LLVector3 mAccel; + LLVector3 mAxis; LLColor4 mColor; LLVector2 mScale; + F32 mStartGlow; + F32 mEndGlow; + LLColor4U mGlow; + static U32 sNextPartID; }; diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp index b311f659fb..8c49ce646d 100644 --- a/indra/newview/llviewerpartsource.cpp +++ b/indra/newview/llviewerpartsource.cpp @@ -52,6 +52,8 @@ LLViewerPartSource::LLViewerPartSource(const U32 type) : static U32 id_seed = 0; mID = ++id_seed; + mLastPart = NULL; + mDelay = 0 ; } @@ -279,6 +281,22 @@ void LLViewerPartSourceScript::update(const F32 dt) { part->mFlags |= LLPartData::LL_PART_HUD; } + + if (part->mFlags & LLPartData::LL_PART_RIBBON_MASK && mLastPart) + { //set previous particle's parent to this particle to chain ribbon together + mLastPart->mParent = part; + part->mChild = mLastPart; + part->mAxis = LLVector3(0,0,1); + + if (mSourceObjectp.notNull()) + { + LLQuaternion rot = mSourceObjectp->getRenderRotation(); + part->mAxis *= rot; + } + } + + mLastPart = part; + part->mMaxAge = mPartSysData.mPartData.mMaxAge; part->mStartColor = mPartSysData.mPartData.mStartColor; part->mEndColor = mPartSysData.mPartData.mEndColor; @@ -290,6 +308,13 @@ void LLViewerPartSourceScript::update(const F32 dt) part->mAccel = mPartSysData.mPartAccel; + part->mBlendFuncDest = mPartSysData.mPartData.mBlendFuncDest; + part->mBlendFuncSource = mPartSysData.mPartData.mBlendFuncSource; + + part->mStartGlow = mPartSysData.mPartData.mStartGlow; + part->mEndGlow = mPartSysData.mPartData.mEndGlow; + part->mGlow = LLColor4U(0, 0, 0, (U8) (part->mStartGlow*255.f)); + if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_DROP) { part->mPosAgent = mPosAgent; @@ -430,28 +455,51 @@ LLPointer LLViewerPartSourceScript::unpackPSS(LLViewer } -LLPointer LLViewerPartSourceScript::unpackPSS(LLViewerObject *source_objp, LLPointer pssp, LLDataPacker &dp) +LLPointer LLViewerPartSourceScript::unpackPSS(LLViewerObject *source_objp, LLPointer pssp, LLDataPacker &dp, bool legacy) { if (!pssp) { LLPointer new_pssp = new LLViewerPartSourceScript(source_objp); - if (!new_pssp->mPartSysData.unpack(dp)) + if (legacy) { - return NULL; + if (!new_pssp->mPartSysData.unpackLegacy(dp)) + { + return NULL; + } + } + else + { + if (!new_pssp->mPartSysData.unpack(dp)) + { + return NULL; + } } + if (new_pssp->mPartSysData.mTargetUUID.notNull()) { LLViewerObject *target_objp = gObjectList.findObject(new_pssp->mPartSysData.mTargetUUID); new_pssp->setTargetObject(target_objp); } + return new_pssp; } else { - if (!pssp->mPartSysData.unpack(dp)) + if (legacy) { - return NULL; + if (!pssp->mPartSysData.unpackLegacy(dp)) + { + return NULL; + } } + else + { + if (!pssp->mPartSysData.unpack(dp)) + { + return NULL; + } + } + if (pssp->mPartSysData.mTargetUUID.notNull()) { LLViewerObject *target_objp = gObjectList.findObject(pssp->mPartSysData.mTargetUUID); @@ -569,6 +617,11 @@ void LLViewerPartSourceSpiral::update(const F32 dt) part->mScale.mV[0] = 0.25f; part->mScale.mV[1] = 0.25f; part->mParameter = ll_frand(F_TWO_PI); + part->mBlendFuncDest = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; + part->mBlendFuncSource = LLRender::BF_SOURCE_ALPHA; + part->mStartGlow = 0.f; + part->mEndGlow = 0.f; + part->mGlow = LLColor4U(0, 0, 0, 0); LLViewerPartSim::getInstance()->addPart(part); } @@ -721,6 +774,12 @@ void LLViewerPartSourceBeam::update(const F32 dt) part->mPosAgent = mPosAgent; part->mVelocity = mTargetPosAgent - mPosAgent; + part->mBlendFuncDest = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; + part->mBlendFuncSource = LLRender::BF_SOURCE_ALPHA; + part->mStartGlow = 0.f; + part->mEndGlow = 0.f; + part->mGlow = LLColor4U(0, 0, 0, 0); + LLViewerPartSim::getInstance()->addPart(part); } } @@ -825,6 +884,12 @@ void LLViewerPartSourceChat::update(const F32 dt) part->mScale.mV[0] = 0.25f; part->mScale.mV[1] = 0.25f; part->mParameter = ll_frand(F_TWO_PI); + part->mBlendFuncDest = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; + part->mBlendFuncSource = LLRender::BF_SOURCE_ALPHA; + part->mStartGlow = 0.f; + part->mEndGlow = 0.f; + part->mGlow = LLColor4U(0, 0, 0, 0); + LLViewerPartSim::getInstance()->addPart(part); } diff --git a/indra/newview/llviewerpartsource.h b/indra/newview/llviewerpartsource.h index 28702d36a2..12e926173b 100644 --- a/indra/newview/llviewerpartsource.h +++ b/indra/newview/llviewerpartsource.h @@ -76,6 +76,7 @@ public: LLVector3 mLastUpdatePosAgent; LLPointer mSourceObjectp; U32 mID; + LLViewerPart* mLastPart; //last particle emitted (for making particle ribbons) protected: U32 mType; @@ -85,7 +86,6 @@ protected: F32 mLastPartTime; LLUUID mOwnerUUID; LLPointer mImagep; - // Particle information U32 mPartFlags; // Flags for the particle U32 mDelay ; //delay to start particles @@ -114,7 +114,7 @@ public: // Returns a new particle source to attach to an object... static LLPointer unpackPSS(LLViewerObject *source_objp, LLPointer pssp, const S32 block_num); - static LLPointer unpackPSS(LLViewerObject *source_objp, LLPointer pssp, LLDataPacker &dp); + static LLPointer unpackPSS(LLViewerObject *source_objp, LLPointer pssp, LLDataPacker &dp, bool legacy); static LLPointer createPSS(LLViewerObject *source_objp, const LLPartSysData& particle_parameters); LLViewerTexture *getImage() const { return mImagep; } diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 4dca87652d..ed62abe4ef 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -476,6 +476,7 @@ void LLVOGrass::getGeometry(S32 idx, LLStrider& normalsp, LLStrider& texcoordsp, LLStrider& colorsp, + LLStrider& emissivep, LLStrider& indicesp) { if(!mNumBlades)//stop rendering grass @@ -708,7 +709,11 @@ void LLGrassPartition::getGeometry(LLSpatialGroup* group) facep->setIndicesIndex(index_count); facep->setVertexBuffer(buffer); facep->setPoolType(LLDrawPool::POOL_ALPHA); - object->getGeometry(facep->getTEOffset(), verticesp, normalsp, texcoordsp, colorsp, indicesp); + + //dummy parameter (unused by this implementation) + LLStrider emissivep; + + object->getGeometry(facep->getTEOffset(), verticesp, normalsp, texcoordsp, colorsp, emissivep, indicesp); vertex_count += facep->getGeomCount(); index_count += facep->getIndicesCount(); diff --git a/indra/newview/llvograss.h b/indra/newview/llvograss.h index b9835b8802..1fe9990cea 100644 --- a/indra/newview/llvograss.h +++ b/indra/newview/llvograss.h @@ -63,6 +63,7 @@ public: LLStrider& normalsp, LLStrider& texcoordsp, LLStrider& colorsp, + LLStrider& emissivep, LLStrider& indicesp); void updateFaceSize(S32 idx) { } diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 1a9769f09d..53d67347d1 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -49,17 +49,11 @@ const F32 MAX_PART_LIFETIME = 120.f; extern U64 gFrameTime; LLPointer LLVOPartGroup::sVB = NULL; -S32 LLVOPartGroup::sVBSlotFree[]; -S32* LLVOPartGroup::sVBSlotCursor = NULL; +S32 LLVOPartGroup::sVBSlotCursor = 0; void LLVOPartGroup::initClass() { - for (S32 i = 0; i < LL_MAX_PARTICLE_COUNT; ++i) - { - sVBSlotFree[i] = i; - } - - sVBSlotCursor = sVBSlotFree; + } //static @@ -122,36 +116,33 @@ void LLVOPartGroup::destroyGL() //static S32 LLVOPartGroup::findAvailableVBSlot() { - if (sVBSlotCursor >= sVBSlotFree+LL_MAX_PARTICLE_COUNT) + if (sVBSlotCursor >= LL_MAX_PARTICLE_COUNT) { //no more available slots return -1; } - S32 ret = *sVBSlotCursor; - sVBSlotCursor++; - - return ret; + return sVBSlotCursor++; } bool ll_is_part_idx_allocated(S32 idx, S32* start, S32* end) { - while (start < end) + /*while (start < end) { if (*start == idx) { //not allocated (in free list) return false; } ++start; - } + }*/ //allocated (not in free list) - return true; + return false; } //static void LLVOPartGroup::freeVBSlot(S32 idx) { - llassert(idx < LL_MAX_PARTICLE_COUNT && idx >= 0); + /*llassert(idx < LL_MAX_PARTICLE_COUNT && idx >= 0); llassert(sVBSlotCursor > sVBSlotFree); llassert(ll_is_part_idx_allocated(idx, sVBSlotCursor, sVBSlotFree+LL_MAX_PARTICLE_COUNT)); @@ -159,7 +150,7 @@ void LLVOPartGroup::freeVBSlot(S32 idx) { sVBSlotCursor--; *sVBSlotCursor = idx; - } + }*/ } LLVOPartGroup::LLVOPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) @@ -189,6 +180,7 @@ F32 LLVOPartGroup::getBinRadius() void LLVOPartGroup::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) { const LLVector3& pos_agent = getPositionAgent(); + newMin.load3( (pos_agent - mScale).mV); newMax.load3( (pos_agent + mScale).mV); LLVector4a pos; @@ -273,6 +265,16 @@ F32 LLVOPartGroup::getPartSize(S32 idx) return 0.f; } +void LLVOPartGroup::getBlendFunc(S32 idx, U32& src, U32& dst) +{ + if (idx < (S32) mViewerPartGroupp->mParticles.size()) + { + LLViewerPart* part = mViewerPartGroupp->mParticles[idx]; + src = part->mBlendFuncSource; + dst = part->mBlendFuncDest; + } +} + LLVector3 LLVOPartGroup::getCameraPosition() const { return gAgentCamera.getCameraPositionAgent(); @@ -332,13 +334,42 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) mDepth = 0.f; S32 i = 0 ; LLVector3 camera_agent = getCameraPosition(); + + F32 max_scale = 0.f; + + for (i = 0 ; i < (S32)mViewerPartGroupp->mParticles.size(); i++) { const LLViewerPart *part = mViewerPartGroupp->mParticles[i]; + + //remember the largest particle + max_scale = llmax(max_scale, part->mScale.mV[0], part->mScale.mV[1]); + + if (part->mFlags & LLPartData::LL_PART_RIBBON_MASK) + { //include ribbon segment length in scale + const LLVector3* pos_agent = NULL; + if (part->mParent) + { + pos_agent = &(part->mParent->mPosAgent); + } + else if (part->mPartSourcep.notNull()) + { + pos_agent = &(part->mPartSourcep->mPosAgent); + } + + if (pos_agent) + { + F32 dist = (*pos_agent-part->mPosAgent).length(); + + max_scale = llmax(max_scale, dist); + } + } + LLVector3 part_pos_agent(part->mPosAgent); LLVector3 at(part_pos_agent - camera_agent); + F32 camera_dist_squared = at.lengthSquared(); F32 inv_camera_dist_squared; if (camera_dist_squared > 1.f) @@ -411,6 +442,9 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) facep->setSize(0, 0); } + //record max scale (used to stretch bounding box for visibility culling) + mScale.set(max_scale, max_scale, max_scale); + mDrawable->movePartition(); LLPipeline::sCompiles++; return TRUE; @@ -478,74 +512,129 @@ BOOL LLVOPartGroup::lineSegmentIntersect(const LLVector3& start, const LLVector3 void LLVOPartGroup::getGeometry(const LLViewerPart& part, LLStrider& verticesp) { - LLVector4a part_pos_agent; - part_pos_agent.load3(part.mPosAgent.mV); - LLVector4a camera_agent; - camera_agent.load3(getCameraPosition().mV); - LLVector4a at; - at.setSub(part_pos_agent, camera_agent); - LLVector4a up(0, 0, 1); - LLVector4a right; - - right.setCross3(at, up); - right.normalize3fast(); - up.setCross3(right, at); - up.normalize3fast(); - - if (part.mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK) + if (part.mFlags & LLPartData::LL_PART_RIBBON_MASK) { - LLVector4a normvel; - normvel.load3(part.mVelocity.mV); - normvel.normalize3fast(); - LLVector2 up_fracs; - up_fracs.mV[0] = normvel.dot3(right).getF32(); - up_fracs.mV[1] = normvel.dot3(up).getF32(); - up_fracs.normalize(); - LLVector4a new_up; - LLVector4a new_right; - - //new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up; - LLVector4a t = right; - t.mul(up_fracs.mV[0]); - new_up = up; - new_up.mul(up_fracs.mV[1]); - new_up.add(t); - - //new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up; - t = right; - t.mul(up_fracs.mV[1]); - new_right = up; - new_right.mul(up_fracs.mV[0]); - t.sub(new_right); - - up = new_up; - right = t; - up.normalize3fast(); - right.normalize3fast(); + LLVector4a axis, pos, paxis, ppos; + F32 scale, pscale; + + pos.load3(part.mPosAgent.mV); + axis.load3(part.mAxis.mV); + scale = part.mScale.mV[0]; + + if (part.mParent) + { + ppos.load3(part.mParent->mPosAgent.mV); + paxis.load3(part.mParent->mAxis.mV); + pscale = part.mParent->mScale.mV[0]; + } + else + { //use source object as position + + if (part.mPartSourcep->mSourceObjectp.notNull()) + { + LLVector3 v = LLVector3(0,0,1); + v *= part.mPartSourcep->mSourceObjectp->getRenderRotation(); + paxis.load3(v.mV); + ppos.load3(part.mPartSourcep->mPosAgent.mV); + pscale = part.mStartScale.mV[0]; + } + else + { //no source object, no parent, nothing to draw + ppos = pos; + pscale = scale; + paxis = axis; + } + } + + LLVector4a p0, p1, p2, p3; + + scale *= 0.5f; + pscale *= 0.5f; + + axis.mul(scale); + paxis.mul(pscale); + + p0.setAdd(pos, axis); + p1.setSub(pos,axis); + p2.setAdd(ppos, paxis); + p3.setSub(ppos, paxis); + + (*verticesp++) = p2; + (*verticesp++) = p3; + (*verticesp++) = p0; + (*verticesp++) = p1; } + else + { + LLVector4a part_pos_agent; + part_pos_agent.load3(part.mPosAgent.mV); + LLVector4a camera_agent; + camera_agent.load3(getCameraPosition().mV); + LLVector4a at; + at.setSub(part_pos_agent, camera_agent); + LLVector4a up(0, 0, 1); + LLVector4a right; + + right.setCross3(at, up); + right.normalize3fast(); + up.setCross3(right, at); + up.normalize3fast(); - right.mul(0.5f*part.mScale.mV[0]); - up.mul(0.5f*part.mScale.mV[1]); + if (part.mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK) + { + LLVector4a normvel; + normvel.load3(part.mVelocity.mV); + normvel.normalize3fast(); + LLVector2 up_fracs; + up_fracs.mV[0] = normvel.dot3(right).getF32(); + up_fracs.mV[1] = normvel.dot3(up).getF32(); + up_fracs.normalize(); + LLVector4a new_up; + LLVector4a new_right; + + //new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up; + LLVector4a t = right; + t.mul(up_fracs.mV[0]); + new_up = up; + new_up.mul(up_fracs.mV[1]); + new_up.add(t); + + //new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up; + t = right; + t.mul(up_fracs.mV[1]); + new_right = up; + new_right.mul(up_fracs.mV[0]); + t.sub(new_right); + + up = new_up; + right = t; + up.normalize3fast(); + right.normalize3fast(); + } + right.mul(0.5f*part.mScale.mV[0]); + up.mul(0.5f*part.mScale.mV[1]); - //HACK -- the verticesp->mV[3] = 0.f here are to set the texture index to 0 (particles don't use texture batching, maybe they should) - // this works because there is actually a 4th float stored after the vertex position which is used as a texture index - // also, somebody please VECTORIZE THIS - LLVector4a ppapu; - LLVector4a ppamu; + //HACK -- the verticesp->mV[3] = 0.f here are to set the texture index to 0 (particles don't use texture batching, maybe they should) + // this works because there is actually a 4th float stored after the vertex position which is used as a texture index + // also, somebody please VECTORIZE THIS - ppapu.setAdd(part_pos_agent, up); - ppamu.setSub(part_pos_agent, up); + LLVector4a ppapu; + LLVector4a ppamu; - verticesp->setSub(ppapu, right); - (*verticesp++).getF32ptr()[3] = 0.f; - verticesp->setSub(ppamu, right); - (*verticesp++).getF32ptr()[3] = 0.f; - verticesp->setAdd(ppapu, right); - (*verticesp++).getF32ptr()[3] = 0.f; - verticesp->setAdd(ppamu, right); - (*verticesp++).getF32ptr()[3] = 0.f; + ppapu.setAdd(part_pos_agent, up); + ppamu.setSub(part_pos_agent, up); + + verticesp->setSub(ppapu, right); + (*verticesp++).getF32ptr()[3] = 0.f; + verticesp->setSub(ppamu, right); + (*verticesp++).getF32ptr()[3] = 0.f; + verticesp->setAdd(ppapu, right); + (*verticesp++).getF32ptr()[3] = 0.f; + verticesp->setAdd(ppamu, right); + (*verticesp++).getF32ptr()[3] = 0.f; + } } @@ -555,6 +644,7 @@ void LLVOPartGroup::getGeometry(S32 idx, LLStrider& normalsp, LLStrider& texcoordsp, LLStrider& colorsp, + LLStrider& emissivep, LLStrider& indicesp) { if (idx >= (S32) mViewerPartGroupp->mParticles.size()) @@ -566,10 +656,40 @@ void LLVOPartGroup::getGeometry(S32 idx, getGeometry(part, verticesp); - *colorsp++ = part.mColor; - *colorsp++ = part.mColor; - *colorsp++ = part.mColor; - *colorsp++ = part.mColor; + LLColor4U pcolor; + LLColor4U color = part.mColor; + + LLColor4U pglow; + + if (part.mFlags & LLPartData::LL_PART_RIBBON_MASK) + { //make sure color blends properly + if (part.mParent) + { + pglow = part.mParent->mGlow; + pcolor = part.mParent->mColor; + } + else + { + pglow = LLColor4U(0, 0, 0, (U8) (255.f*part.mStartGlow)); + pcolor = part.mStartColor; + } + } + else + { + pglow = part.mGlow; + pcolor = color; + } + + *colorsp++ = pcolor; + *colorsp++ = pcolor; + *colorsp++ = color; + *colorsp++ = color; + + *emissivep++ = pglow; + *emissivep++ = pglow; + *emissivep++ = part.mGlow; + *emissivep++ = part.mGlow; + if (!(part.mFlags & LLPartData::LL_PART_EMISSIVE_MASK)) { //not fullbright, needs normal @@ -712,10 +832,13 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) LLStrider normalsp; LLStrider texcoordsp; LLStrider colorsp; + LLStrider emissivep; buffer->getVertexStrider(verticesp); buffer->getNormalStrider(normalsp); buffer->getColorStrider(colorsp); + buffer->getEmissiveStrider(emissivep); + LLSpatialGroup::drawmap_elem_t& draw_vec = group->mDrawMap[mRenderPass]; @@ -724,7 +847,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) LLFace* facep = *i; LLAlphaObject* object = (LLAlphaObject*) facep->getViewerObject(); - if (!facep->isState(LLFace::PARTICLE)) + //if (!facep->isState(LLFace::PARTICLE)) { //set the indices of this face S32 idx = LLVOPartGroup::findAvailableVBSlot(); if (idx >= 0) @@ -733,7 +856,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) facep->setIndicesIndex(idx*6); facep->setVertexBuffer(LLVOPartGroup::sVB); facep->setPoolType(LLDrawPool::POOL_ALPHA); - facep->setState(LLFace::PARTICLE); + //facep->setState(LLFace::PARTICLE); } else { @@ -748,8 +871,9 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) LLStrider cur_norm = normalsp + geom_idx; LLStrider cur_tc = texcoordsp + geom_idx; LLStrider cur_col = colorsp + geom_idx; + LLStrider cur_glow = emissivep + geom_idx; - object->getGeometry(facep->getTEOffset(), cur_vert, cur_norm, cur_tc, cur_col, cur_idx); + object->getGeometry(facep->getTEOffset(), cur_vert, cur_norm, cur_tc, cur_col, cur_glow, cur_idx); llassert(facep->getGeomCount() == 4); llassert(facep->getIndicesCount() == 6); @@ -765,9 +889,16 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) bool batched = false; + U32 bf_src = LLRender::BF_SOURCE_ALPHA; + U32 bf_dst = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; + + object->getBlendFunc(facep->getTEOffset(), bf_src, bf_dst); + if (idx >= 0 && draw_vec[idx]->mTexture == facep->getTexture() && - draw_vec[idx]->mFullbright == fullbright) + draw_vec[idx]->mFullbright == fullbright && + draw_vec[idx]->mBlendFuncDst == bf_dst && + draw_vec[idx]->mBlendFuncSrc == bf_src) { if (draw_vec[idx]->mEnd == facep->getGeomIndex()-1) { @@ -799,6 +930,8 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) info->mExtents[0] = group->mObjectExtents[0]; info->mExtents[1] = group->mObjectExtents[1]; info->mVSize = vsize; + info->mBlendFuncDst = bf_dst; + info->mBlendFuncSrc = bf_src; draw_vec.push_back(info); //for alpha sorting facep->setDrawInfo(info); diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h index ce05a0282e..3c2e0344a2 100644 --- a/indra/newview/llvopartgroup.h +++ b/indra/newview/llvopartgroup.h @@ -42,8 +42,7 @@ public: //vertex buffer for holding all particles static LLPointer sVB; - static S32 sVBSlotFree[LL_MAX_PARTICLE_COUNT]; - static S32* sVBSlotCursor; + static S32 sVBSlotCursor; static void initClass(); static void restoreGL(); @@ -57,6 +56,7 @@ public: LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | + LLVertexBuffer::MAP_EMISSIVE | LLVertexBuffer::MAP_TEXTURE_INDEX }; @@ -91,10 +91,12 @@ public: LLStrider& normalsp, LLStrider& texcoordsp, LLStrider& colorsp, + LLStrider& emissivep, LLStrider& indicesp); void updateFaceSize(S32 idx) { } F32 getPartSize(S32 idx); + void getBlendFunc(S32 idx, U32& src, U32& dst); LLUUID getPartOwner(S32 idx); LLUUID getPartSource(S32 idx); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 597fb03526..0df0e653ae 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -384,7 +384,6 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, } else { - // CORY TO DO: Figure out how to get the value here if (update_type != OUT_TERSE_IMPROVED) { LLVolumeParams volume_params; @@ -453,6 +452,11 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, mFaceMappingChanged = TRUE; mTexAnimMode = 0; } + + if (value & 0x400) + { //particle system (new) + unpackParticleSource(*dp, mOwnerID, false); + } } else { -- cgit v1.2.3 From ebb57d28ef2ce37e0803f346610e5dff4d65eb85 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Wed, 13 Mar 2013 16:40:06 -0700 Subject: Resurrect merge victim...restoring ll_memcpy_nonaliased_aligned_16 definition --- indra/llcommon/llmemory.h | 78 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 528af83b8f..61e30f11cc 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -182,6 +182,78 @@ inline void ll_aligned_free_32(void *p) #endif } + +// Copy words 16-byte blocks from src to dst. Source and destination MUST NOT OVERLAP. +// Source and dest must be 16-byte aligned and size must be multiple of 16. +// +inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __restrict src, size_t bytes) +{ + assert(src != NULL); + assert(dst != NULL); + assert(bytes > 0); + assert((bytes % sizeof(F32))== 0); + ll_assert_aligned(src,16); + ll_assert_aligned(dst,16); + assert((src < dst) ? ((src + bytes) < dst) : ((dst + bytes) < src)); + assert(bytes%16==0); + + char* end = dst + bytes; + + if (bytes > 64) + { + + // Find start of 64b aligned area within block + // + void* begin_64 = LL_NEXT_ALIGNED_ADDRESS_64(dst); + + //at least 64 bytes before the end of the destination, switch to 16 byte copies + void* end_64 = end-64; + + // Prefetch the head of the 64b area now + // + _mm_prefetch((char*)begin_64, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 64, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 128, _MM_HINT_NTA); + _mm_prefetch((char*)begin_64 + 192, _MM_HINT_NTA); + + // Copy 16b chunks until we're 64b aligned + // + while (dst < begin_64) + { + + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + dst += 16; + src += 16; + } + + // Copy 64b chunks up to your tail + // + // might be good to shmoo the 512b prefetch offset + // (characterize performance for various values) + // + while (dst < end_64) + { + _mm_prefetch((char*)src + 512, _MM_HINT_NTA); + _mm_prefetch((char*)dst + 512, _MM_HINT_NTA); + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + _mm_store_ps((F32*)(dst + 16), _mm_load_ps((F32*)(src + 16))); + _mm_store_ps((F32*)(dst + 32), _mm_load_ps((F32*)(src + 32))); + _mm_store_ps((F32*)(dst + 48), _mm_load_ps((F32*)(src + 48))); + dst += 64; + src += 64; + } + } + + // Copy remainder 16b tail chunks (or ALL 16b chunks for sub-64b copies) + // + while (dst < end) + { + _mm_store_ps((F32*)dst, _mm_load_ps((F32*)src)); + dst += 16; + src += 16; + } +} + #ifndef __DEBUG_PRIVATE_MEM__ #define __DEBUG_PRIVATE_MEM__ 0 #endif @@ -590,13 +662,7 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr) // LLSingleton moved to llsingleton.h -LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment); -#ifdef SHOW_ASSERT -#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast(ptr),((U32)alignment)) -#else -#define ll_assert_aligned(ptr,alignment) -#endif #endif -- cgit v1.2.3 From e95563e10d8c906cf4a09a1e2ff773f345a17c44 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 13 Mar 2013 21:08:17 -0500 Subject: MAINT-2410 Remove unused particle packing code and fix integration test to work without a packer. --- indra/llmessage/llpartdata.cpp | 45 ------ indra/llmessage/llpartdata.h | 5 +- indra/llmessage/tests/llpartdata_test.cpp | 256 +++++++++++------------------- 3 files changed, 98 insertions(+), 208 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llpartdata.cpp b/indra/llmessage/llpartdata.cpp index 0f33a94295..41a0310ce0 100644 --- a/indra/llmessage/llpartdata.cpp +++ b/indra/llmessage/llpartdata.cpp @@ -66,40 +66,6 @@ bool LLPartData::hasBlendFunc() const return mBlendFuncSource != LLPartData::LL_PART_BF_SOURCE_ALPHA || mBlendFuncDest != LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; } -LLSD LLPartData::asLLSD() const -{ - LLSD sd = LLSD(); - sd["pdflags"] = ll_sd_from_U32(mFlags); - sd["pdmaxage"] = mMaxAge; - sd["pdstartcolor"] = ll_sd_from_color4(mStartColor); - sd["pdendcolor"] = ll_sd_from_color4(mEndColor); - sd["pdstartscale"] = ll_sd_from_vector2(mStartScale); - sd["pdendscale"] = ll_sd_from_vector2(mEndScale); - sd["pdstartglow"] = mStartGlow; - sd["pdendglow"] = mEndGlow; - sd["pdblendsource"] = (S32)mBlendFuncSource; - sd["pdblenddest"] = (S32)mBlendFuncDest; - - return sd; -} - -bool LLPartData::fromLLSD(LLSD& sd) -{ - mFlags = ll_U32_from_sd(sd["pdflags"]); - mMaxAge = (F32)sd["pdmaxage"].asReal(); - mStartColor = ll_color4_from_sd(sd["pdstartcolor"]); - mEndColor = ll_color4_from_sd(sd["pdendcolor"]); - mStartScale = ll_vector2_from_sd(sd["pdstartscale"]); - mEndScale = ll_vector2_from_sd(sd["pdendscale"]); - - mStartGlow = sd.has("pdstartglow") ? sd["pdstartglow"].asReal() : 0.f; - mEndGlow = sd.has("pdendglow") ? sd["pdendglow"].asReal() : 0.f; - mBlendFuncSource = sd.has("pdblendsource") ? (U8)sd["pdblendsource"].asInteger() : LL_PART_BF_SOURCE_ALPHA; - mBlendFuncDest = sd.has("pdblenddest") ? (U8)sd["pdblenddest"].asInteger() : LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; - - return true; -} - S32 LLPartData::getSize() const { S32 size = PS_LEGACY_PART_DATA_BLOCK_SIZE; @@ -126,17 +92,6 @@ BOOL LLPartData::unpackLegacy(LLDataPacker &dp) dp.unpackFixed(mEndScale.mV[0], "pdendscalex", FALSE, 3, 5); dp.unpackFixed(mEndScale.mV[1], "pdendscaley", FALSE, 3, 5); - /*if (dp.hasNext()) - { - U8 tmp_glow = 0; - dp.unpackU8(tmp_glow,"pdstartglow"); - mStartGlow = tmp_glow / 255.f; - dp.unpackU8(tmp_glow,"pdendglow"); - mEndGlow = tmp_glow / 255.f; - dp.unpackU8(mBlendFuncSource,"pdblendsource"); - dp.unpackU8(mBlendFuncDest,"pdblenddest"); - }*/ - mStartGlow = 0.f; mEndGlow = 0.f; mBlendFuncSource = LLPartData::LL_PART_BF_SOURCE_ALPHA; diff --git a/indra/llmessage/llpartdata.h b/indra/llmessage/llpartdata.h index 80a52b79dd..ed5c1a6ac7 100644 --- a/indra/llmessage/llpartdata.h +++ b/indra/llmessage/llpartdata.h @@ -92,10 +92,7 @@ public: BOOL unpack(LLDataPacker &dp); BOOL pack(LLDataPacker &dp); - LLSD asLLSD() const; - operator LLSD() const {return asLLSD(); } - bool fromLLSD(LLSD& sd); - + bool hasGlow() const; bool hasBlendFunc() const; diff --git a/indra/llmessage/tests/llpartdata_test.cpp b/indra/llmessage/tests/llpartdata_test.cpp index 9123bd06c7..de81e0bbb2 100644 --- a/indra/llmessage/tests/llpartdata_test.cpp +++ b/indra/llmessage/tests/llpartdata_test.cpp @@ -38,10 +38,34 @@ namespace tut { + + //bunch of sniffed data that *should* be a valid particle system + static U8 msg[] = { + 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x80, 0x00, 0x80, + 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x5e, 0x12, 0x0b, 0xa1, 0x58, 0x05, 0xdc, 0x57, 0x66, + 0xb7, 0xf5, 0xac, 0x4b, 0xd1, 0x8f, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x02, 0x05, 0x02, 0x00, 0x00, 0x0a, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7e, 0xc6, 0x81, 0xdc, 0x7e, 0xc6, 0x81, 0xdc, 0x77, 0xcf, 0xef, 0xd4, 0xce, 0x64, 0x1a, 0x7e, + 0x26, 0x87, 0x55, 0x7f, 0xdd, 0x65, 0x22, 0x7f, 0xdd, 0x65, 0x22, 0x7f, 0x77, 0xcf, 0x98, 0xa3, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xf2, + 0xf1, 0x65, 0x32, 0x1b, 0xef, 0x18, 0x70, 0x66, 0xba, 0x30, 0xa0, 0x11, 0xaa, 0x2f, 0xb0, 0xab, 0xd0, + 0x30, 0x7d, 0xbd, 0x01, 0x00, 0xf8, 0x0d, 0xb8, 0x30, 0x01, 0x00, 0x00, 0x00, 0xce, 0xc6, 0x81, 0xdc, + 0xce, 0xc6, 0x81, 0xdc, 0xc7, 0xcf, 0xef, 0xd4, 0x75, 0x65, 0x1a, 0x7f, 0x62, 0x6f, 0x55, 0x7f, 0x6d, + 0x65, 0x22, 0x7f, 0x6d, 0x65, 0x22, 0x7f, 0xc7, 0xcf, 0x98, 0xa3, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xf2, 0xf1, 0x62, 0x12, 0x1b, 0xef, + 0x18, 0x7e, 0xbd, 0x01, 0x00, 0x16, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7c, 0xac, 0x28, 0x03, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, + 0xe0, 0xb9, 0x30, 0x03, 0xe1, 0xb9, 0x30, 0xbb, 0x00, 0x00, 0x00, 0x48, 0xe0, 0xb9, 0x30, 0x36, 0xd9, + 0x81, 0xdc, 0x36, 0xd9, 0x81, 0xdc, 0x3f, 0xd0, 0xef, 0xd4, 0xa5, 0x7a, 0x72, 0x7f, 0x26, 0x30, 0x55, + 0x7f, 0x95, 0x7a, 0x22, 0x7f, 0x95, 0x7a, 0x22, 0x7f, 0x3f, 0xd0, 0x98, 0xa3, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00 }; struct partdata_test { }; + typedef test_group partdata_test_t; typedef partdata_test_t::object partdata_test_object_t; tut::partdata_test_t tut_partdata_test("LLPartData"); @@ -49,168 +73,82 @@ namespace tut template<> template<> void partdata_test_object_t::test<1>() { - LLPartData llpdata,llpdata1; - U8 pkbuf[128]; - - llpdata.setFlags(LLPartData::LL_PART_INTERP_COLOR_MASK | LLPartData::LL_PART_INTERP_SCALE_MASK | - LLPartData::LL_PART_BOUNCE_MASK | LLPartData::LL_PART_WIND_MASK | LLPartData::LL_PART_FOLLOW_SRC_MASK | - LLPartData::LL_PART_FOLLOW_VELOCITY_MASK | LLPartData::LL_PART_TARGET_POS_MASK | LLPartData::LL_PART_TARGET_LINEAR_MASK | - LLPartData::LL_PART_EMISSIVE_MASK | LLPartData::LL_PART_BEAM_MASK | LLPartData::LL_PART_DEAD_MASK); - - llpdata.setMaxAge(29.3f); - - LLVector3 llvec1(1.0f, .5f, .25f); - llpdata.setStartColor(llvec1); - llpdata.setStartAlpha(.7f); - - LLVector3 llvec2(.2f, .3f, 1.0f); - llpdata.setEndColor(llvec2); - llpdata.setEndAlpha(1.0f); + LLPartSysData llpsysdata; + LLDataPackerBinaryBuffer dp1(msg, sizeof(msg)); - llpdata.setStartScale(3.23f, 4.0f); - llpdata.setEndScale(2.4678f, 1.0f); + ensure("LLPartSysData::unpack failed.", llpsysdata.unpack(dp1)); - LLDataPackerBinaryBuffer dp((U8*)pkbuf, 128); - llpdata.pack(dp); - S32 cur_size = dp.getCurrentSize(); - - LLDataPackerBinaryBuffer dp1((U8*)pkbuf, cur_size); - llpdata1.unpack(dp1); - - ensure("1.mFlags values are different after unpacking", llpdata1.mFlags == llpdata.mFlags); - ensure_approximately_equals("2.mMaxAge values are different after unpacking", llpdata1.mMaxAge, llpdata.mMaxAge, 8); - - ensure_approximately_equals("3.mStartColor[0] values are different after unpacking", llpdata1.mStartColor.mV[0], llpdata.mStartColor.mV[0], 8); - ensure_approximately_equals("4.mStartColor[1] values are different after unpacking", llpdata1.mStartColor.mV[1], llpdata.mStartColor.mV[1], 8); - ensure_approximately_equals("5.mStartColor[2] values are different after unpacking", llpdata1.mStartColor.mV[2], llpdata.mStartColor.mV[2], 8); - ensure_approximately_equals("6.mStartColor[3] values are different after unpacking", llpdata1.mStartColor.mV[3], llpdata.mStartColor.mV[3], 8); - - ensure_approximately_equals("7.mEndColor[0] values are different after unpacking", llpdata1.mEndColor.mV[0], llpdata.mEndColor.mV[0], 8); - ensure_approximately_equals("8.mEndColor[1] values are different after unpacking", llpdata1.mEndColor.mV[1], llpdata.mEndColor.mV[1], 8); - ensure_approximately_equals("9.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[2], llpdata.mEndColor.mV[2], 8); - ensure_approximately_equals("10.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[3], llpdata.mEndColor.mV[3], 8); - - ensure_approximately_equals("11.mStartScale[0] values are different after unpacking", llpdata1.mStartScale.mV[0], llpdata.mStartScale.mV[0], 5); - ensure_approximately_equals("12.mStartScale[1] values are different after unpacking", llpdata1.mStartScale.mV[1], llpdata.mStartScale.mV[1], 5); - - ensure_approximately_equals("13.mEndScale[0] values are different after unpacking", llpdata1.mEndScale.mV[0], llpdata.mEndScale.mV[0], 5); - ensure_approximately_equals("14.mEndScale[1] values are different after unpacking", llpdata1.mEndScale.mV[1], llpdata.mEndScale.mV[1], 5); - } - - - template<> template<> - void partdata_test_object_t::test<2>() - { - LLPartData llpdata,llpdata1; - - llpdata.setFlags(LLPartData::LL_PART_INTERP_COLOR_MASK | LLPartData::LL_PART_INTERP_SCALE_MASK | - LLPartData::LL_PART_BOUNCE_MASK | LLPartData::LL_PART_WIND_MASK | LLPartData::LL_PART_FOLLOW_SRC_MASK | - LLPartData::LL_PART_FOLLOW_VELOCITY_MASK | LLPartData::LL_PART_TARGET_POS_MASK | LLPartData::LL_PART_TARGET_LINEAR_MASK | - LLPartData::LL_PART_EMISSIVE_MASK | LLPartData::LL_PART_BEAM_MASK | LLPartData::LL_PART_DEAD_MASK); - - llpdata.setMaxAge(29.3f); - - LLVector3 llvec1(1.0f, .5f, .25f); - llpdata.setStartColor(llvec1); - llpdata.setStartAlpha(.7f); - - LLVector3 llvec2(.2f, .3f, 1.0f); - llpdata.setEndColor(llvec2); - llpdata.setEndAlpha(1.0f); - - llpdata.setStartScale(3.23f, 4.0f); - llpdata.setEndScale(2.4678f, 1.0f); - - LLSD llsd = llpdata.asLLSD(); - - llpdata1.fromLLSD(llsd); - - ensure("1.mFlags values are different after unpacking", llpdata1.mFlags == llpdata.mFlags); - ensure_approximately_equals("2.mMaxAge values are different after unpacking", llpdata1.mMaxAge, llpdata.mMaxAge, 8); - - ensure_approximately_equals("3.mStartColor[0] values are different after unpacking", llpdata1.mStartColor.mV[0], llpdata.mStartColor.mV[0], 8); - ensure_approximately_equals("4.mStartColor[1] values are different after unpacking", llpdata1.mStartColor.mV[1], llpdata.mStartColor.mV[1], 8); - ensure_approximately_equals("5.mStartColor[2] values are different after unpacking", llpdata1.mStartColor.mV[2], llpdata.mStartColor.mV[2], 8); - ensure_approximately_equals("6.mStartColor[3] values are different after unpacking", llpdata1.mStartColor.mV[3], llpdata.mStartColor.mV[3], 8); - - ensure_approximately_equals("7.mEndColor[0] values are different after unpacking", llpdata1.mEndColor.mV[0], llpdata.mEndColor.mV[0], 8); - ensure_approximately_equals("8.mEndColor[1] values are different after unpacking", llpdata1.mEndColor.mV[1], llpdata.mEndColor.mV[1], 8); - ensure_approximately_equals("9.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[2], llpdata.mEndColor.mV[2], 8); - ensure_approximately_equals("10.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[3], llpdata.mEndColor.mV[3], 8); - - ensure_approximately_equals("11.mStartScale[0] values are different after unpacking", llpdata1.mStartScale.mV[0], llpdata.mStartScale.mV[0], 5); - ensure_approximately_equals("12.mStartScale[1] values are different after unpacking", llpdata1.mStartScale.mV[1], llpdata.mStartScale.mV[1], 5); - - ensure_approximately_equals("13.mEndScale[0] values are different after unpacking", llpdata1.mEndScale.mV[0], llpdata.mEndScale.mV[0], 5); - ensure_approximately_equals("14.mEndScale[1] values are different after unpacking", llpdata1.mEndScale.mV[1], llpdata.mEndScale.mV[1], 5); - } - - -//*********llpartsysdata*********** - - template<> template<> - void partdata_test_object_t::test<3>() - { - LLPartSysData llpsysdata, llpsysdata1; - U8 pkbuf[256]; - llpsysdata.setBurstSpeedMin(33.33f); - ensure("1.mBurstSpeedMin coudnt be set", 33.33f == llpsysdata.mBurstSpeedMin); - - llpsysdata.setBurstSpeedMax(44.44f); - ensure("2.mBurstSpeedMax coudnt be set", 44.44f == llpsysdata.mBurstSpeedMax); - - llpsysdata.setBurstRadius(45.55f); - ensure("3.mBurstRadius coudnt be set", 45.55f == llpsysdata.mBurstRadius); - - LLVector3 llvec(44.44f, 111.11f, -40.4f); - llpsysdata.setPartAccel(llvec); - - llpsysdata.mCRC = 0xFFFFFFFF; - llpsysdata.mFlags = 0x20; - - llpsysdata.mPattern = LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE_EMPTY; - - llpsysdata.mMaxAge = 99.99f; - llpsysdata.mStartAge = 18.5f; - llpsysdata.mInnerAngle = 4.234f; - llpsysdata.mOuterAngle = 7.123f; - llpsysdata.mBurstRate = 245.53f; - llpsysdata.mBurstPartCount = 0xFF; - llpsysdata.mAngularVelocity = llvec; - - llpsysdata.mPartImageID.generate(); - llpsysdata.mTargetUUID.generate(); + //mCRC 1 unsigned int + ensure("mCRC different after unpacking", llpsysdata.mCRC == (U32) 1); + //mFlags 0 unsigned int + ensure ("mFlags different after unpacking", llpsysdata.mFlags == (U32) 0); + //mPattern 1 '' unsigned char + ensure ("mPattern different after unpacking", llpsysdata.mPattern == (U8) 1); + //mInnerAngle 0.00000000 float + ensure_approximately_equals("mInnerAngle different after unpacking", llpsysdata.mInnerAngle, 0.f, 8); + //mOuterAngle 0.00000000 float + ensure_approximately_equals("mOuterAngle different after unpacking", llpsysdata.mOuterAngle, 0.f, 8); + //mAngularVelocity 0,0,0 + ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[0], 0.f, 8); + ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[1], 0.f, 8); + ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[2], 0.f, 8); + //mBurstRate 0.097656250 float + ensure_approximately_equals("mBurstRate different after unpacking", llpsysdata.mBurstRate, 0.097656250f, 8); + //mBurstPartCount 1 '' unsigned char + ensure("mBurstPartCount different after unpacking", llpsysdata.mBurstPartCount == (U8) 1); + //mBurstRadius 0.00000000 float + ensure_approximately_equals("mBurstRadius different after unpacking", llpsysdata.mBurstRadius, 0.f, 8); + //mBurstSpeedMin 1.0000000 float + ensure_approximately_equals("mBurstSpeedMin different after unpacking", llpsysdata.mBurstSpeedMin, 1.f, 8); + //mBurstSpeedMax 1.0000000 float + ensure_approximately_equals("mBurstSpeedMax different after unpacking", llpsysdata.mBurstSpeedMax, 1.f, 8); + //mMaxAge 0.00000000 float + ensure_approximately_equals("mMaxAge different after unpacking", llpsysdata.mMaxAge, 0.f, 8); + //mStartAge 0.00000000 float + ensure_approximately_equals("mStartAge different after unpacking", llpsysdata.mStartAge, 0.f, 8); + //mPartAccel <0,0,0> + ensure_approximately_equals("mPartAccel.mV[0] different after unpacking", llpsysdata.mPartAccel.mV[0], 0.f, 7); + ensure_approximately_equals("mPartAccel.mV[1] different after unpacking", llpsysdata.mPartAccel.mV[1], 0.f, 7); + ensure_approximately_equals("mPartAccel.mV[2] different after unpacking", llpsysdata.mPartAccel.mV[2], 0.f, 7); + + //mPartData + LLPartData& data = llpsysdata.mPartData; + + //mFlags 132354 unsigned int + ensure ("mPartData.mFlags different after unpacking", data.mFlags == (U32) 132354); + //mMaxAge 10.000000 float + ensure_approximately_equals("mPartData.mMaxAge different after unpacking", data.mMaxAge, 10.f, 8); + //mStartColor <1,1,1,1> + ensure_approximately_equals("mPartData.mStartColor.mV[0] different after unpacking", data.mStartColor.mV[0], 1.f, 8); + ensure_approximately_equals("mPartData.mStartColor.mV[1] different after unpacking", data.mStartColor.mV[1], 1.f, 8); + ensure_approximately_equals("mPartData.mStartColor.mV[2] different after unpacking", data.mStartColor.mV[2], 1.f, 8); + ensure_approximately_equals("mPartData.mStartColor.mV[3] different after unpacking", data.mStartColor.mV[3], 1.f, 8); + //mEndColor <1,1,0,0> + ensure_approximately_equals("mPartData.mEndColor.mV[0] different after unpacking", data.mEndColor.mV[0], 1.f, 8); + ensure_approximately_equals("mPartData.mEndColor.mV[1] different after unpacking", data.mEndColor.mV[1], 1.f, 8); + ensure_approximately_equals("mPartData.mEndColor.mV[2] different after unpacking", data.mEndColor.mV[2], 0.f, 8); + ensure_approximately_equals("mPartData.mEndColor.mV[3] different after unpacking", data.mEndColor.mV[3], 0.f, 8); + //mStartScale <1,1> + ensure_approximately_equals("mPartData.mStartScale.mV[0] different after unpacking", data.mStartScale.mV[0], 1.f, 8); + ensure_approximately_equals("mPartData.mStartScale.mV[1] different after unpacking", data.mStartScale.mV[1], 1.f, 8); + //mEndScale <0,0> + ensure_approximately_equals("mPartData.mEndScale.mV[0] different after unpacking", data.mEndScale.mV[0], 0.f, 8); + ensure_approximately_equals("mPartData.mEndScale.mV[1] different after unpacking", data.mEndScale.mV[1], 0.f, 8); + //mPosOffset <0,0,0> + ensure_approximately_equals("mPartData.mPosOffset.mV[0] different after unpacking", data.mPosOffset.mV[0], 0.f, 8); + ensure_approximately_equals("mPartData.mPosOffset.mV[1] different after unpacking", data.mPosOffset.mV[1], 0.f, 8); + ensure_approximately_equals("mPartData.mPosOffset.mV[2] different after unpacking", data.mPosOffset.mV[2], 0.f, 8); + //mParameter 0.00000000 float + ensure_approximately_equals("mPartData.mParameter different after unpacking", data.mParameter, 0.f, 8); - LLDataPackerBinaryBuffer dp((U8*)pkbuf, 256); - llpsysdata.pack(dp); - S32 cur_size = dp.getCurrentSize(); - LLDataPackerBinaryBuffer dp1((U8*)pkbuf, cur_size); - llpsysdata1.unpack(dp1); - - ensure("1.mCRC's not equal", llpsysdata.mCRC == llpsysdata1.mCRC); - ensure("2.mFlags's not equal", llpsysdata.mFlags == llpsysdata1.mFlags); - ensure("3.mPattern's not equal", llpsysdata.mPattern == llpsysdata1.mPattern); - ensure_approximately_equals("4.mMaxAge's not equal", llpsysdata.mMaxAge , llpsysdata1.mMaxAge, 8); - ensure_approximately_equals("5.mStartAge's not equal", llpsysdata.mStartAge, llpsysdata1.mStartAge, 8); - ensure_approximately_equals("6.mOuterAngle's not equal", llpsysdata.mOuterAngle, llpsysdata1.mOuterAngle, 5); - ensure_approximately_equals("7.mInnerAngles's not equal", llpsysdata.mInnerAngle, llpsysdata1.mInnerAngle, 5); - ensure_approximately_equals("8.mBurstRate's not equal", llpsysdata.mBurstRate, llpsysdata1.mBurstRate, 8); - ensure("9.mBurstPartCount's not equal", llpsysdata.mBurstPartCount == llpsysdata1.mBurstPartCount); - - ensure_approximately_equals("10.mBurstSpeedMin's not equal", llpsysdata.mBurstSpeedMin, llpsysdata1.mBurstSpeedMin, 8); - ensure_approximately_equals("11.mBurstSpeedMax's not equal", llpsysdata.mBurstSpeedMax, llpsysdata1.mBurstSpeedMax, 8); - - ensure_approximately_equals("12.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[0], llpsysdata1.mAngularVelocity.mV[0], 7); - ensure_approximately_equals("13.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[1], llpsysdata1.mAngularVelocity.mV[1], 7); - ensure_approximately_equals("14.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[2], llpsysdata1.mAngularVelocity.mV[2], 7); - - ensure_approximately_equals("15.mPartAccel's not equal", llpsysdata.mPartAccel.mV[0], llpsysdata1.mPartAccel.mV[0], 7); - ensure_approximately_equals("16.mPartAccel's not equal", llpsysdata.mPartAccel.mV[1], llpsysdata1.mPartAccel.mV[1], 7); - ensure_approximately_equals("17.mPartAccel's not equal", llpsysdata.mPartAccel.mV[2], llpsysdata1.mPartAccel.mV[2], 7); - - ensure("18.mPartImageID's not equal", llpsysdata.mPartImageID == llpsysdata1.mPartImageID); - ensure("19.mTargetUUID's not equal", llpsysdata.mTargetUUID == llpsysdata1.mTargetUUID); - ensure_approximately_equals("20.mBurstRadius's not equal", llpsysdata.mBurstRadius, llpsysdata1.mBurstRadius, 8); + //mStartGlow 0.00000000 float + ensure_approximately_equals("mPartData.mStartGlow different after unpacking", data.mStartGlow, 0.f, 8); + //mEndGlow 0.00000000 float + ensure_approximately_equals("mPartData.mEndGlow different after unpacking", data.mEndGlow, 0.f, 8); + //mBlendFuncSource 2 '' unsigned char + ensure("mPartData.mBlendFuncSource different after unpacking", data.mBlendFuncSource == (U8) 2); + //mBlendFuncDest 1 '' unsigned char + ensure("mPartData.mBlendFuncDest different after unpacking", data.mBlendFuncDest == (U8) 1); } } -- cgit v1.2.3 From 85257154a3ba001ecadacf4d81baa6f9c187a041 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 14 Mar 2013 14:01:39 -0700 Subject: Rollback fix for Maestro 'Jitter Bug' which is causing issues elsewhere --- indra/llcharacter/lleditingmotion.cpp | 4 +- indra/llcharacter/llheadrotmotion.cpp | 4 +- indra/llcharacter/llkeyframemotion.cpp | 6 +- indra/llcharacter/llkeyframewalkmotion.cpp | 6 +- indra/llcharacter/llmotion.cpp | 4 +- indra/llcharacter/lltargetingmotion.cpp | 2 +- indra/llcommon/llcriticaldamp.cpp | 50 +++++++++----- indra/llcommon/llcriticaldamp.h | 82 +--------------------- indra/llui/llbutton.cpp | 5 +- indra/llui/lllayoutstack.cpp | 12 ++-- indra/llui/llmenugl.cpp | 2 +- indra/llui/llscrollbar.cpp | 5 +- indra/llui/lltabcontainer.cpp | 3 +- indra/newview/llagentcamera.cpp | 23 +++---- indra/newview/lldrawable.cpp | 106 ++++++++++++++++------------- indra/newview/llfasttimerview.cpp | 4 +- indra/newview/llfloatercolorpicker.cpp | 5 +- indra/newview/llfloatersnapshot.cpp | 5 +- indra/newview/llfolderviewitem.cpp | 7 +- indra/newview/llfollowcam.cpp | 17 ++--- indra/newview/llhudnametag.cpp | 3 +- indra/newview/llmaniprotate.cpp | 18 ++--- indra/newview/llmanipscale.cpp | 5 +- indra/newview/llmaniptranslate.cpp | 13 ++-- indra/newview/llnetmap.cpp | 3 +- indra/newview/llselectmgr.cpp | 9 --- indra/newview/lltexturectrl.cpp | 4 +- indra/newview/llviewerdisplay.cpp | 3 +- indra/newview/llvoavatar.cpp | 12 ++-- indra/newview/llvovolume.cpp | 5 +- indra/newview/llworldmapview.cpp | 4 +- 31 files changed, 182 insertions(+), 249 deletions(-) (limited to 'indra') diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp index 35508e0a87..4e8c3268c5 100644 --- a/indra/llcharacter/lleditingmotion.cpp +++ b/indra/llcharacter/lleditingmotion.cpp @@ -38,6 +38,8 @@ // Constants //----------------------------------------------------------------------------- const LLQuaternion EDIT_MOTION_WRIST_ROTATION(F_PI_BY_TWO * 0.7f, LLVector3(1.0f, 0.0f, 0.0f)); +const F32 TARGET_LAG_HALF_LIFE = 0.1f; // half-life of IK targeting +const F32 TORSO_LAG_HALF_LIFE = 0.2f; const F32 MAX_TIME_DELTA = 2.f; //max two seconds a frame for calculating interpolation S32 LLEditingMotion::sHandPose = LLHandMotion::HAND_POSE_RELAXED_R; @@ -230,7 +232,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) mIKSolver.solve(); // use blending... - F32 slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTargetLagHalfLife); + F32 slerp_amt = LLCriticalDamp::getInterpolant(TARGET_LAG_HALF_LIFE); shoulderRot = slerp(slerp_amt, mShoulderJoint.getRotation(), shoulderRot); elbowRot = slerp(slerp_amt, mElbowJoint.getRotation(), elbowRot); diff --git a/indra/llcharacter/llheadrotmotion.cpp b/indra/llcharacter/llheadrotmotion.cpp index 1eddd0f449..2b1aa194a9 100644 --- a/indra/llcharacter/llheadrotmotion.cpp +++ b/indra/llcharacter/llheadrotmotion.cpp @@ -182,8 +182,8 @@ BOOL LLHeadRotMotion::onUpdate(F32 time, U8* joint_mask) LLQuaternion currentRootRotWorld = mRootJoint->getWorldRotation(); LLQuaternion currentInvRootRotWorld = ~currentRootRotWorld; - F32 head_slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaHeadLookAtLagHalfLife); - F32 torso_slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTorsoLookAtLagHalfLife); + F32 head_slerp_amt = LLCriticalDamp::getInterpolant(HEAD_LOOKAT_LAG_HALF_LIFE); + F32 torso_slerp_amt = LLCriticalDamp::getInterpolant(TORSO_LOOKAT_LAG_HALF_LIFE); LLVector3* targetPos = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index f394cf2635..905d1c2d26 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -1031,11 +1031,11 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 if (constraint->mSharedData->mChainLength != 0 && dist_vec_squared(root_pos, target_pos) * 0.95f > constraint->mTotalLength * constraint->mTotalLength) { - constraint->mWeight = lerp(constraint->mWeight, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + constraint->mWeight = lerp(constraint->mWeight, 0.f, LLCriticalDamp::getInterpolant(0.1f)); } else { - constraint->mWeight = lerp(constraint->mWeight, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaSmallish)); + constraint->mWeight = lerp(constraint->mWeight, 1.f, LLCriticalDamp::getInterpolant(0.3f)); } F32 weight = constraint->mWeight * ((shared_data->mEaseOutStopTime == 0.f) ? 1.f : @@ -1084,7 +1084,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 F32 time_constant = 1.f / clamp_rescale(constraint->mFixupDistanceRMS, 0.f, 0.5f, 0.2f, 8.f); // llinfos << "Interpolant " << LLCriticalDamp::getInterpolant(time_constant, FALSE) << " and fixup distance " << constraint->mFixupDistanceRMS << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << llendl; positions[joint_num] = lerp(positions[joint_num], kinematic_position, - LLCriticalDamp::getInterpolant(time_constant)); + LLCriticalDamp::getInterpolant(time_constant, FALSE)); } S32 iteration_count; diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp index d17c123e54..8422553beb 100644 --- a/indra/llcharacter/llkeyframewalkmotion.cpp +++ b/indra/llcharacter/llkeyframewalkmotion.cpp @@ -287,7 +287,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) F32 desired_speed_multiplier = llclamp(speed / foot_speed, min_speed_multiplier, ANIM_SPEED_MAX); // blend towards new speed adjustment value - F32 new_speed_adjust = lerp(mAdjustedSpeed, desired_speed_multiplier, LLCriticalDamp::getInterpolant(InterpDeltaSpeedAdjustTime)); + F32 new_speed_adjust = lerp(mAdjustedSpeed, desired_speed_multiplier, LLCriticalDamp::getInterpolant(SPEED_ADJUST_TIME_CONSTANT)); // limit that rate at which the speed adjustment changes F32 speedDelta = llclamp(new_speed_adjust - mAdjustedSpeed, -SPEED_ADJUST_MAX_SEC * delta_time, SPEED_ADJUST_MAX_SEC * delta_time); @@ -305,8 +305,8 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) { // standing/turning // damp out speed adjustment to 0 - mAnimSpeed = lerp(mAnimSpeed, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaSmall)); - //mPelvisOffset = lerp(mPelvisOffset, LLVector3::zero, LLCriticalDamp::getInterpolant(InterpDeltaSmall)); + mAnimSpeed = lerp(mAnimSpeed, 1.f, LLCriticalDamp::getInterpolant(0.2f)); + //mPelvisOffset = lerp(mPelvisOffset, LLVector3::zero, LLCriticalDamp::getInterpolant(0.2f)); } // broadcast walk speed change diff --git a/indra/llcharacter/llmotion.cpp b/indra/llcharacter/llmotion.cpp index d4db0d84c9..a07f9f4d2e 100644 --- a/indra/llcharacter/llmotion.cpp +++ b/indra/llcharacter/llmotion.cpp @@ -73,7 +73,7 @@ void LLMotion::fadeOut() { if (mFadeWeight > 0.01f) { - mFadeWeight = lerp(mFadeWeight, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaFadeWeight)); + mFadeWeight = lerp(mFadeWeight, 0.f, LLCriticalDamp::getInterpolant(0.15f)); } else { @@ -88,7 +88,7 @@ void LLMotion::fadeIn() { if (mFadeWeight < 0.99f) { - mFadeWeight = lerp(mFadeWeight, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaFadeWeight)); + mFadeWeight = lerp(mFadeWeight, 1.f, LLCriticalDamp::getInterpolant(0.15f)); } else { diff --git a/indra/llcharacter/lltargetingmotion.cpp b/indra/llcharacter/lltargetingmotion.cpp index 6ce6ce31d6..fa5f06328e 100644 --- a/indra/llcharacter/lltargetingmotion.cpp +++ b/indra/llcharacter/lltargetingmotion.cpp @@ -106,7 +106,7 @@ BOOL LLTargetingMotion::onActivate() //----------------------------------------------------------------------------- BOOL LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) { - F32 slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTorsoTargetLagHalfLife); + F32 slerp_amt = LLCriticalDamp::getInterpolant(TORSO_TARGET_HALF_LIFE); LLVector3 target; LLVector3* lookAtPoint = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); diff --git a/indra/llcommon/llcriticaldamp.cpp b/indra/llcommon/llcriticaldamp.cpp index 27fef0e6dc..49aac9ce75 100644 --- a/indra/llcommon/llcriticaldamp.cpp +++ b/indra/llcommon/llcriticaldamp.cpp @@ -32,9 +32,8 @@ // static members //----------------------------------------------------------------------------- LLFrameTimer LLCriticalDamp::sInternalTimer; +std::map LLCriticalDamp::sInterpolants; F32 LLCriticalDamp::sTimeDelta; -F32 LLCriticalDamp::sInterpolants[kNumCachedInterpolants]; -F32 LLCriticalDamp::sInterpolatedValues[kNumCachedInterpolants]; //----------------------------------------------------------------------------- // LLCriticalDamp() @@ -42,17 +41,6 @@ F32 LLCriticalDamp::sInterpolatedValues[kNumCachedInterpolants]; LLCriticalDamp::LLCriticalDamp() { sTimeDelta = 0.f; - - // Init the core interpolant values (to which many, many enums map) - // - setInterpolantConstant(InterpDelta_0_025, 0.025f); - setInterpolantConstant(InterpDelta_0_05, 0.05f ); - setInterpolantConstant(InterpDelta_0_06, 0.06f); - setInterpolantConstant(InterpDelta_0_10, 0.10f); - setInterpolantConstant(InterpDelta_0_15, 0.15f); - setInterpolantConstant(InterpDelta_0_20, 0.20f); - setInterpolantConstant(InterpDelta_0_25, 0.25f); - setInterpolantConstant(InterpDelta_0_30, 0.30f); } // static @@ -63,10 +51,40 @@ void LLCriticalDamp::updateInterpolants() { sTimeDelta = sInternalTimer.getElapsedTimeAndResetF32(); - U32 i; - for (i = 0; i < kNumCachedInterpolants; i++) + F32 time_constant; + + for (std::map::iterator iter = sInterpolants.begin(); + iter != sInterpolants.end(); iter++) + { + time_constant = iter->first; + F32 new_interpolant = 1.f - pow(2.f, -sTimeDelta / time_constant); + new_interpolant = llclamp(new_interpolant, 0.f, 1.f); + sInterpolants[time_constant] = new_interpolant; + } +} + +//----------------------------------------------------------------------------- +// getInterpolant() +//----------------------------------------------------------------------------- +F32 LLCriticalDamp::getInterpolant(const F32 time_constant, BOOL use_cache) +{ + if (time_constant == 0.f) + { + return 1.f; + } + + if (use_cache && sInterpolants.count(time_constant)) { - sInterpolatedValues[i] = llclamp(sTimeDelta / sInterpolants[ i], 0.0f, 1.0f); + return sInterpolants[time_constant]; } + + F32 interpolant = 1.f - pow(2.f, -sTimeDelta / time_constant); + interpolant = llclamp(interpolant, 0.f, 1.f); + if (use_cache) + { + sInterpolants[time_constant] = interpolant; + } + + return interpolant; } diff --git a/indra/llcommon/llcriticaldamp.h b/indra/llcommon/llcriticaldamp.h index 19a2ddb77a..52f052ae25 100644 --- a/indra/llcommon/llcriticaldamp.h +++ b/indra/llcommon/llcriticaldamp.h @@ -32,98 +32,22 @@ #include "llframetimer.h" -// These enums each represent one fixed-time delta value -// that we interpolate once given the actual sTimeDelta time -// that has passed. This allows us to calculate the interp portion -// of those values once and then look them up repeatedly per frame. -// -enum InterpDelta -{ - InterpDelta_0_025, // 0.025 - InterpDeltaTeenier = InterpDelta_0_025, - InterpDeltaFolderOpenTime = InterpDelta_0_025, - InterpDeltaFolderCloseTime = InterpDelta_0_025, - InterpDeltaCameraFocusHalfLife = InterpDelta_0_025, // USED TO BE ZERO.... - - InterpDelta_0_05, // 0.05 - InterpDeltaTeeny = InterpDelta_0_05, - - InterpDelta_0_06, // 0.06 - InterpDeltaObjectDampingConstant = InterpDelta_0_06, - InterpDeltaCameraZoomHalfLife = InterpDelta_0_06, - InterpDeltaFovZoomHalfLife = InterpDelta_0_06, - InterpDeltaManipulatorScaleHalfLife = InterpDelta_0_06, - InterpDeltaContextFadeTime = InterpDelta_0_06, - - InterpDelta_0_10, // 0.10 - InterpDeltaSmaller = InterpDelta_0_10, - InterpDeltaTargetLagHalfLife = InterpDelta_0_10, - InterpDeltaSpeedAdjustTime = InterpDelta_0_10, - - InterpDelta_0_15, // 0.15 - InterpDeltaFadeWeight = InterpDelta_0_15, - InterpDeltaHeadLookAtLagHalfLife = InterpDelta_0_15, - - InterpDelta_0_20, // 0.20 - InterpDeltaSmall = InterpDelta_0_20, - InterpDeltaTorsoLagHalfLife = InterpDelta_0_20, - InterpDeltaPositionDampingTC = InterpDelta_0_20, - - InterpDelta_0_25, // 0.25 - InterpDeltaCameraLagHalfLife = InterpDelta_0_25, - InterpDeltaTorsoTargetLagHalfLife = InterpDelta_0_25, - InterpDeltaTorsoLookAtLagHalfLife = InterpDelta_0_25, - - InterpDelta_0_30, // 0.3 - InterpDeltaSmallish = InterpDelta_0_30, - - // Dynamically set interpolants which use setInterpolantConstant - // - InterpDeltaCameraSmoothingHalfLife, - InterpDeltaBehindnessLag, - InterpDeltaFocusLag, - InterpDeltaPositionLag, - InterpDeltaOpenTime, - InterpDeltaCloseTime, - - kNumCachedInterpolants -}; - class LL_COMMON_API LLCriticalDamp { public: LLCriticalDamp(); - // Updates all the known interp delta values for fast lookup in calls to getInterpolant(InterpDelta) - // + // MANIPULATORS static void updateInterpolants(); - static inline void setInterpolantConstant(InterpDelta whichDelta, const F32 time_constant) - { - llassert(whichDelta < kNumCachedInterpolants); - sInterpolants[whichDelta] = time_constant; - } - // ACCESSORS - static inline F32 getInterpolant(InterpDelta whichDelta) - { - llassert(whichDelta < kNumCachedInterpolants); - return sInterpolatedValues[whichDelta]; - } - - static inline F32 getInterpolant(const F32 time_constant) - { - return llclamp((sTimeDelta / time_constant), 0.0f, 1.0f); - } + static F32 getInterpolant(const F32 time_constant, BOOL use_cache = TRUE); protected: static LLFrameTimer sInternalTimer; // frame timer for calculating deltas - //static std::map sInterpolants; - static F32 sInterpolants[kNumCachedInterpolants]; - static F32 sInterpolatedValues[kNumCachedInterpolants]; + static std::map sInterpolants; static F32 sTimeDelta; }; #endif // LL_LLCRITICALDAMP_H - diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 3dfcb3ffa1..705fe16559 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -758,11 +758,11 @@ void LLButton::draw() mCurGlowStrength = lerp(mCurGlowStrength, mFlashing ? (flash? 1.0 : 0.0) : mHoverGlowStrength, - LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + LLCriticalDamp::getInterpolant(0.05f)); } else { - mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f)); } // Draw button image, if available. @@ -1247,4 +1247,3 @@ BOOL LLButton::handleDoubleClick(S32 x, S32 y, MASK mask) // just treat a double click as a second click return handleMouseDown(x, y, mask); } - diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index c93f538570..4c730286da 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -229,10 +229,7 @@ LLLayoutStack::LLLayoutStack(const LLLayoutStack::Params& p) mOpenTimeConstant(p.open_time_constant), mCloseTimeConstant(p.close_time_constant), mResizeBarOverlap(p.resize_bar_overlap) -{ - LLCriticalDamp::setInterpolantConstant(InterpDeltaCloseTime, mCloseTimeConstant); - LLCriticalDamp::setInterpolantConstant(InterpDeltaOpenTime, mOpenTimeConstant); -} +{} LLLayoutStack::~LLLayoutStack() { @@ -595,7 +592,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaOpenTime)); + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(mOpenTimeConstant)); if (panelp->mVisibleAmt > 0.99f) { panelp->mVisibleAmt = 1.f; @@ -620,7 +617,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaCloseTime)); + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); if (panelp->mVisibleAmt < 0.001f) { panelp->mVisibleAmt = 0.f; @@ -647,7 +644,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLCriticalDamp::getInterpolant(InterpDeltaCloseTime)); + panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); } if (llabs(panelp->mCollapseAmt - collapse_state) < 0.001f) @@ -858,4 +855,3 @@ void LLLayoutStack::updateResizeBarLimits() previous_visible_panelp = visible_panelp; } } - diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index f142be885d..cd6cc6a75e 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -3673,7 +3673,7 @@ void LLTearOffMenu::draw() if (getRect().getHeight() != mTargetHeight) { // animate towards target height - reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)))); + reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(0.05f)))); } LLFloater::draw(); } diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index d65b4431a8..5d3bf7a670 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -493,11 +493,11 @@ void LLScrollbar::draw() BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y)); if (hovered) { - mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f)); } else { - mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f)); } // Draw background and thumb. @@ -642,4 +642,3 @@ void LLScrollbar::onLineDownBtnPressed( const LLSD& data ) { changeLine( mStepSize, TRUE ); } - diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 1e64cd0df8..5fc2cc350d 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -406,7 +406,7 @@ void LLTabContainer::draw() } } - setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(InterpDeltaTeeny))); + setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(0.08f))); BOOL has_scroll_arrows = !getTabsHidden() && ((mMaxScrollPos > 0) || (mScrollPosPixels > 0)); if (!mIsVertical) @@ -2046,4 +2046,3 @@ void LLTabContainer::commitHoveredButton(S32 x, S32 y) } } } - diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index a40d9cd318..9025c7af8b 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -179,7 +179,7 @@ LLAgentCamera::LLAgentCamera() : clearGeneralKeys(); clearOrbitKeys(); - clearPanKeys(); + clearPanKeys(); } // Requires gSavedSettings to be initialized. @@ -192,9 +192,6 @@ void LLAgentCamera::init() mDrawDistance = gSavedSettings.getF32("RenderFarClip"); - const F32 SMOOTHING_HALF_LIFE = 0.02f; - LLCriticalDamp::setInterpolantConstant(InterpDeltaCameraSmoothingHalfLife, gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE); - LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW); // Leave at 0.1 meters until we have real near clip management LLViewerCamera::getInstance()->setNear(0.1f); @@ -340,7 +337,7 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) LLVector3 agent_at_axis = gAgent.getAtAxis(); agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector()); agent_at_axis.normalize(); - gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(InterpDeltaSmall))); + gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); } setFocusOnAvatar(TRUE, ANIMATE); @@ -1249,7 +1246,7 @@ void LLAgentCamera::updateCamera() gAgentCamera.clearPanKeys(); // lerp camera focus offset - mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(InterpDeltaCameraFocusHalfLife)); + mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(CAMERA_FOCUS_HALF_LIFE)); if ( mCameraMode == CAMERA_MODE_FOLLOW ) { @@ -1364,8 +1361,10 @@ void LLAgentCamera::updateCamera() mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode; if (cameraThirdPerson() && !mCameraSmoothingStop) - { - F32 smoothing = LLCriticalDamp::getInterpolant(InterpDeltaCameraSmoothingHalfLife); + { + const F32 SMOOTHING_HALF_LIFE = 0.02f; + + F32 smoothing = LLCriticalDamp::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE); if (!mFocusObject) // we differentiate on avatar mode { @@ -1395,7 +1394,7 @@ void LLAgentCamera::updateCamera() } - mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(InterpDeltaFovZoomHalfLife)); + mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(FOV_ZOOM_HALF_LIFE)); // llinfos << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << llendl; @@ -1810,7 +1809,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) if (mTargetCameraDistance != mCurrentCameraDistance) { - F32 camera_lerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaCameraZoomHalfLife); + F32 camera_lerp_amt = LLCriticalDamp::getInterpolant(CAMERA_ZOOM_HALF_LIFE); mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt); } @@ -1828,7 +1827,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) if (isAgentAvatarValid()) { LLVector3d camera_lag_d; - F32 lag_interp = LLCriticalDamp::getInterpolant(InterpDeltaCameraLagHalfLife); + F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); LLVector3 target_lag; LLVector3 vel = gAgent.getVelocity(); @@ -1873,7 +1872,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) } else { - mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(InterpDeltaCameraLagHalfLife)); + mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(0.15f)); } camera_lag_d.setVec(mCameraLag); diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index dc0e256ebb..d29181a3ce 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -492,83 +492,97 @@ F32 LLDrawable::updateXform(BOOL undamped) BOOL damped = !undamped; // Position - LLVector3 old_pos = mXform.getPosition(); - - // get agent position or parent-relative position as appropriate - // - LLVector3 target_pos = mXform.isRoot() ? mVObjp->getPositionAgent() : mVObjp->getPosition(); - + LLVector3 old_pos(mXform.getPosition()); + LLVector3 target_pos; + if (mXform.isRoot()) + { + // get root position in your agent's region + target_pos = mVObjp->getPositionAgent(); + } + else + { + // parent-relative position + target_pos = mVObjp->getPosition(); + } + // Rotation LLQuaternion old_rot(mXform.getRotation()); LLQuaternion target_rot = mVObjp->getRotation(); - //scaling LLVector3 target_scale = mVObjp->getScale(); LLVector3 old_scale = mCurrentScale; LLVector3 dest_scale = target_scale; - LLVector3 scale_vec = old_scale-target_scale; - - static const F32 dot_threshold = 1.0f - FLT_EPSILON; - - F32 dist_squared = dist_vec_squared(old_pos, target_pos); - - bool translated = dist_squared > 0.0f; - bool rotated = !mVObjp->getAngularVelocity().isExactlyZero() || (dot(old_rot, target_rot) < dot_threshold); - bool scaled = (scale_vec * scale_vec) > MIN_INTERPOLATE_DISTANCE_SQUARED; - // Damping + // Damping + F32 dist_squared = 0.f; + F32 camdist2 = (mDistanceWRTCamera * mDistanceWRTCamera); + if (damped && isVisible()) { - F32 lerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaObjectDampingConstant); + F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); - dist_squared = dist_vec_squared(new_pos, old_pos); + dist_squared = dist_vec_squared(new_pos, target_pos); LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); - dist_squared += fabs(1.f - dot(new_rot, old_rot)) * 10.f; + // FIXME: This can be negative! It is be possible for some rots to 'cancel out' pos or size changes. + dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); - dist_squared += dist_vec_squared(new_scale, old_scale); + dist_squared += dist_vec_squared(new_scale, target_scale); - // If our lerp isn't moving too far, substitue the lerp'd pos for our target for this frame - // - if (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED) + if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && + (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) { // interpolate target_pos = new_pos; target_rot = new_rot; target_scale = new_scale; } - else + else if (mVObjp->getAngularVelocity().isExactlyZero()) { - llinfos << "skipping update due to overly large lerp" << llendl; + // snap to final position (only if no target omega is applied) + dist_squared = 0.0f; + if (getVOVolume() && !isRoot()) + { //child prim snapping to some position, needs a rebuild + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } } } + else + { + // The following fixes MAINT-1742 but breaks vehicles similar to MAINT-2275 + // dist_squared = dist_vec_squared(old_pos, target_pos); - if (translated || rotated || scaled) - { - if (scaled) - { - mCurrentScale = target_scale; - } + // The following fixes MAINT-2247 but causes MAINT-2275 + //dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; + //dist_squared += dist_vec_squared(old_scale, target_scale); + } + LLVector3 vec = mCurrentScale-target_scale; + + if (vec*vec > MIN_INTERPOLATE_DISTANCE_SQUARED) + { //scale change requires immediate rebuild + mCurrentScale = target_scale; + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } + else if (!isRoot() && + (!mVObjp->getAngularVelocity().isExactlyZero() || + dist_squared > 0.f)) + { //child prim moving relative to parent, tag as needing to be rendered atomically and rebuild dist_squared = 1.f; //keep this object on the move list - - //child prim moving relative to parent, tag as needing to be rendered atomically - // - if (!isRoot() && !isState(LLDrawable::ANIMATED_CHILD)) + if (!isState(LLDrawable::ANIMATED_CHILD)) { setState(LLDrawable::ANIMATED_CHILD); - } - - // Mark any components that need to be rebuilt based on what change transpired - // - if (!rotated && !scaled) - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); - else gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); - - mVObjp->dirtySpatialGroup(); + mVObjp->dirtySpatialGroup(); + } } + else if (!isRoot() + && ( dist_vec_squared(old_pos, target_pos) > 0.f + || (1.f - dot(old_rot, target_rot)) > 0.f)) + { // update child prims moved from LSL + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } else if (!getVOVolume() && !isAvatar()) { movePartition(); @@ -767,7 +781,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) } pos -= camera.getOrigin(); - mDistanceWRTCamera = 20.0f;//llround(pos.magVec(), 0.01f); + mDistanceWRTCamera = llround(pos.magVec(), 0.01f); mVObjp->updateLOD(); } } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 643ce63f29..e7a3f9b390 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -940,7 +940,7 @@ void LLFastTimerView::draw() } //interpolate towards new maximum - last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); if (last_max - cur_max <= 1 || cur_max - last_max <= 1) { last_max = cur_max; @@ -948,7 +948,7 @@ void LLFastTimerView::draw() F32 alpha_target = last_max > cur_max ? llmin((F32) last_max/ (F32) cur_max - 1.f,1.f) : llmin((F32) cur_max/ (F32) last_max - 1.f,1.f); - alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); if (mHoverID != NULL) { diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index 10d31df22c..d6ebe44daa 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -525,11 +525,11 @@ void LLFloaterColorPicker::draw() if (gFocusMgr.childHasMouseCapture(getDragHandle())) { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); + mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); } else { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); + mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); } mPipetteBtn->setToggleState(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); @@ -1113,4 +1113,3 @@ void LLFloaterColorPicker::stopUsingPipette() LLToolMgr::getInstance()->clearTransientTool(); } } - diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 103eaace88..d8d62e5bbb 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -478,7 +478,7 @@ void LLSnapshotLivePreview::draw() { if (mFlashAlpha < 1.f) { - mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); + mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(0.02f)); } else { @@ -487,7 +487,7 @@ void LLSnapshotLivePreview::draw() } else { - mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaSmallish) * 0.5f); + mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(0.15f)); } // Draw shining animation if appropriate. @@ -2500,4 +2500,3 @@ BOOL LLSnapshotFloaterView::handleHover(S32 x, S32 y, MASK mask) } return TRUE; } - diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 23241b57c4..3aa16b4413 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -1293,7 +1293,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) // animate current height towards target height if (llabs(mCurHeight - mTargetHeight) > 1.f) { - mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(mIsOpen ? InterpDeltaFolderOpenTime : InterpDeltaFolderCloseTime)); + mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(mIsOpen ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT)); requestArrange(); @@ -2538,11 +2538,11 @@ void LLFolderViewFolder::draw() } else if (mIsOpen) { - mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(0.04f)); } else { - mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); + mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(0.025f)); } bool possibly_has_children = false; @@ -2899,4 +2899,3 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde } } } - diff --git a/indra/newview/llfollowcam.cpp b/indra/newview/llfollowcam.cpp index a3c1996512..b670af1782 100644 --- a/indra/newview/llfollowcam.cpp +++ b/indra/newview/llfollowcam.cpp @@ -148,16 +148,14 @@ LLFollowCamParams::~LLFollowCamParams() { } //--------------------------------------------------------- void LLFollowCamParams::setPositionLag( F32 p ) { - mPositionLag = llclamp(p, FOLLOW_CAM_MIN_POSITION_LAG, FOLLOW_CAM_MAX_POSITION_LAG); - LLCriticalDamp::setInterpolantConstant(InterpDeltaPositionLag, mPositionLag); + mPositionLag = llclamp(p, FOLLOW_CAM_MIN_POSITION_LAG, FOLLOW_CAM_MAX_POSITION_LAG); } //--------------------------------------------------------- void LLFollowCamParams::setFocusLag( F32 f ) { - mFocusLag = llclamp(f, FOLLOW_CAM_MIN_FOCUS_LAG, FOLLOW_CAM_MAX_FOCUS_LAG); - LLCriticalDamp::setInterpolantConstant(InterpDeltaFocusLag, mFocusLag); + mFocusLag = llclamp(f, FOLLOW_CAM_MIN_FOCUS_LAG, FOLLOW_CAM_MAX_FOCUS_LAG); } @@ -186,7 +184,6 @@ void LLFollowCamParams::setPitch( F32 p ) void LLFollowCamParams::setBehindnessLag( F32 b ) { mBehindnessLag = llclamp(b, FOLLOW_CAM_MIN_BEHINDNESS_LAG, FOLLOW_CAM_MAX_BEHINDNESS_LAG); - LLCriticalDamp::setInterpolantConstant(InterpDeltaBehindnessLag, mBehindnessLag); } //--------------------------------------------------------- @@ -331,11 +328,11 @@ void LLFollowCam::update() F32 force = focusOffsetDistance - focusThresholdNormalizedByDistance; */ - F32 focusLagLerp = LLCriticalDamp::getInterpolant(InterpDeltaFocusLag); + F32 focusLagLerp = LLCriticalDamp::getInterpolant( mFocusLag ); focus_pt_agent = lerp( focus_pt_agent, whereFocusWantsToBe, focusLagLerp ); mSimulatedFocusGlobal = gAgent.getPosGlobalFromAgent(focus_pt_agent); } - mRelativeFocus = lerp(mRelativeFocus, (focus_pt_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mRelativeFocus = lerp(mRelativeFocus, (focus_pt_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(0.05f)); }// if focus is not locked --------------------------------------------- @@ -418,7 +415,7 @@ void LLFollowCam::update() //------------------------------------------------------------------------------------------------- if ( distanceFromPositionToIdealPosition > mPositionThreshold ) { - F32 positionPullLerp = LLCriticalDamp::getInterpolant(InterpDeltaPositionLag); + F32 positionPullLerp = LLCriticalDamp::getInterpolant( mPositionLag ); simulated_pos_agent = lerp( simulated_pos_agent, whereCameraPositionWantsToBe, positionPullLerp ); } @@ -438,7 +435,7 @@ void LLFollowCam::update() updateBehindnessConstraint(gAgent.getPosAgentFromGlobal(mSimulatedFocusGlobal), simulated_pos_agent); mSimulatedPositionGlobal = gAgent.getPosGlobalFromAgent(simulated_pos_agent); - mRelativePos = lerp(mRelativePos, (simulated_pos_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mRelativePos = lerp(mRelativePos, (simulated_pos_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(0.05f)); } // if position is not locked ----------------------------------------------------------- @@ -493,7 +490,7 @@ BOOL LLFollowCam::updateBehindnessConstraint(LLVector3 focus, LLVector3& cam_pos if ( cameraOffsetAngle > mBehindnessMaxAngle ) { - F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLCriticalDamp::getInterpolant(InterpDeltaBehindnessLag); + F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLCriticalDamp::getInterpolant(mBehindnessLag); cam_position = focus + horizontalSubjectBack * (slerp(fraction, camera_offset_rotation, LLQuaternion::DEFAULT)); cam_position.mV[VZ] = cameraZ; // clamp z value back to what it was before we started messing with it constraint_active = TRUE; diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index b94681b340..482294c8a6 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -980,7 +980,7 @@ void LLHUDNameTag::updateAll() // { // continue; // } - (*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(InterpDeltaPositionDampingTC)); + (*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(POSITION_DAMPING_TC)); } } @@ -1083,4 +1083,3 @@ F32 LLHUDNameTag::LLHUDTextSegment::getWidth(const LLFontGL* font) return width; } } - diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp index 748ac7a16e..826e8d560a 100644 --- a/indra/newview/llmaniprotate.cpp +++ b/indra/newview/llmaniprotate.cpp @@ -240,7 +240,7 @@ void LLManipRotate::render() if (mManipPart == LL_ROT_Z) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.pushMatrix(); { // selected part @@ -251,7 +251,7 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_Y) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.pushMatrix(); { gGL.rotatef( 90.f, 1.f, 0.f, 0.f ); @@ -262,7 +262,7 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_X) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.pushMatrix(); { gGL.rotatef( 90.f, 0.f, 1.f, 0.f ); @@ -273,13 +273,13 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_ROLL) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } else if (mManipPart == LL_NO_PART) { if (mHighlightedPart == LL_NO_PART) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } LLGLEnable cull_face(GL_CULL_FACE); @@ -294,7 +294,7 @@ void LLManipRotate::render() { if (mHighlightedPart == LL_ROT_Z) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.scalef(mManipulatorScales.mV[VZ], mManipulatorScales.mV[VZ], mManipulatorScales.mV[VZ]); // hovering over part gl_ring( mRadiusMeters, width_meters, LLColor4( 0.f, 0.f, 1.f, 1.f ), LLColor4( 0.f, 0.f, 1.f, 0.5f ), CIRCLE_STEPS, i); @@ -312,7 +312,7 @@ void LLManipRotate::render() gGL.rotatef( 90.f, 1.f, 0.f, 0.f ); if (mHighlightedPart == LL_ROT_Y) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.scalef(mManipulatorScales.mV[VY], mManipulatorScales.mV[VY], mManipulatorScales.mV[VY]); // hovering over part gl_ring( mRadiusMeters, width_meters, LLColor4( 0.f, 1.f, 0.f, 1.f ), LLColor4( 0.f, 1.f, 0.f, 0.5f ), CIRCLE_STEPS, i); @@ -330,7 +330,7 @@ void LLManipRotate::render() gGL.rotatef( 90.f, 0.f, 1.f, 0.f ); if (mHighlightedPart == LL_ROT_X) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.scalef(mManipulatorScales.mV[VX], mManipulatorScales.mV[VX], mManipulatorScales.mV[VX]); // hovering over part @@ -346,7 +346,7 @@ void LLManipRotate::render() if (mHighlightedPart == LL_ROT_ROLL) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } } diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 9802d5503e..00a0bf8894 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -535,11 +535,11 @@ void LLManipScale::highlightManipulators(S32 x, S32 y) { if (mHighlightedPart == MANIPULATOR_IDS[i]) { - mManipulatorScales[i] = lerp(mManipulatorScales[i], SELECTED_MANIPULATOR_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales[i] = lerp(mManipulatorScales[i], SELECTED_MANIPULATOR_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } else { - mManipulatorScales[i] = lerp(mManipulatorScales[i], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales[i] = lerp(mManipulatorScales[i], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } } @@ -2082,4 +2082,3 @@ BOOL LLManipScale::canAffectSelection() } return can_scale; } - diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index 9d287e7a03..0228807dc8 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -1922,18 +1922,18 @@ void LLManipTranslate::renderTranslationHandles() { if (index == mManipPart - LL_X_ARROW || index == mHighlightedPart - LL_X_ARROW) { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); } else if (index == mManipPart - LL_YZ_PLANE || index == mHighlightedPart - LL_YZ_PLANE) { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); } else { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); } } @@ -2323,4 +2323,3 @@ BOOL LLManipTranslate::canAffectSelection() } return can_move; } - diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 274497f2b5..1bda7640bd 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -162,7 +162,7 @@ void LLNetMap::draw() static LLUICachedControl auto_center("MiniMapAutoCenter", true); if (auto_center) { - mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(0.1f)); } // Prepare a scissor region @@ -987,4 +987,3 @@ void LLNetMap::handleStopTracking (const LLSD& userdata) LLTracker::stopTracking ((void*)LLTracker::isTracking(NULL)); } } - diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index cf9d95455e..343316d30a 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6108,14 +6108,6 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); gGL.begin(LLRender::LINES); { - // Lines require an even number of verts so repeat the first - // vert if we don't meet that requirement - // - if (mSilhouetteVertices.size() & 0x1) - { - mSilhouetteVertices.push_back(mSilhouetteVertices[0]); - } - for(S32 i = 0; i < mSilhouetteVertices.size(); i += 2) { u_coord += u_divisor * LLSelectMgr::sHighlightUScale; @@ -7555,4 +7547,3 @@ void LLSelectMgr::sendSelectionMove() //saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); } - diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 8c5844eca7..ec36cf48c2 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -549,11 +549,11 @@ void LLFloaterTexturePicker::draw() if (gFocusMgr.childHasMouseCapture(getDragHandle())) { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); + mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); } else { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); + mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); } updateImageStats(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 3f97659c66..9ffc64312d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1033,7 +1033,7 @@ void render_hud_attachments() // clamp target zoom level to reasonable values gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); // smoothly interpolate current zoom level - gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); + gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f)); if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices()) { @@ -1593,4 +1593,3 @@ void display_cleanup() { gDisconnectedImagep = NULL; } - diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index d28da507ea..4efd59685e 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2913,7 +2913,7 @@ void LLVOAvatar::idleUpdateWindEffect() LLVector3 velocity = getVelocity(); F32 speed = velocity.length(); //RN: velocity varies too much frame to frame for this to work - mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); + mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLCriticalDamp::getInterpolant(0.02f)); mLastVel = velocity; LLVector4 wind; wind.setVec(getRegion()->mWind.getVelocityNoisy(getPositionAgent(), 4.f) - velocity); @@ -2934,10 +2934,13 @@ void LLVOAvatar::idleUpdateWindEffect() wind.mV[VW] = llmin(0.025f + (speed * 0.015f) + hover_strength, 0.5f); F32 interp; - interp = LLCriticalDamp::getInterpolant(InterpDeltaSmall); - if (wind.mV[VW] <= mWindVec.mV[VW]) + if (wind.mV[VW] > mWindVec.mV[VW]) { - interp *= 2.0f; + interp = LLCriticalDamp::getInterpolant(0.2f); + } + else + { + interp = LLCriticalDamp::getInterpolant(0.4f); } mWindVec = lerp(mWindVec, wind, interp); @@ -3798,6 +3801,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) // Set the root rotation, but do so incrementally so that it // lags in time by some fixed amount. + //F32 u = LLCriticalDamp::getInterpolant(PELVIS_LAG); F32 pelvis_lag_time = 0.f; if (self_in_mouselook) { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3c831bafa0..7adf18b6d0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1268,7 +1268,7 @@ BOOL LLVOVolume::calcLOD() else { distance = mDrawable->mDistanceWRTCamera; - radius = getVolume() ? getVolume()->mLODScaleBias.scaledVec(getScale()).length() : getScale().length(); + radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length(); } //hold onto unmodified distance for debugging @@ -2990,8 +2990,7 @@ void LLVOVolume::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_p //transform view vector into volume space view_vector -= getRenderPosition(); - // WTF...why is silhouette generation touching a variable used all over the place?! - //mDrawable->mDistanceWRTCamera = view_vector.length(); + mDrawable->mDistanceWRTCamera = view_vector.length(); LLQuaternion worldRot = getRenderRotation(); view_vector = view_vector * ~worldRot; if (!isVolumeGlobal()) diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 7c3bc5988c..eeaa30aafb 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -302,8 +302,8 @@ void LLWorldMapView::draw() mVisibleRegions.clear(); // animate pan if necessary - sPanX = lerp(sPanX, sTargetPanX, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); - sPanY = lerp(sPanY, sTargetPanY, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + sPanX = lerp(sPanX, sTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); + sPanY = lerp(sPanY, sTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); const S32 width = getRect().getWidth(); const S32 height = getRect().getHeight(); -- cgit v1.2.3 From e8dfa28697c177e8ed08ff76a9b81f920805a92f Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 14 Mar 2013 14:12:26 -0700 Subject: Rollback Maestro interp changes --- indra/llcharacter/lleditingmotion.cpp | 4 +- indra/llcharacter/llheadrotmotion.cpp | 4 +- indra/llcharacter/llkeyframemotion.cpp | 6 +- indra/llcharacter/llkeyframewalkmotion.cpp | 6 +- indra/llcharacter/llmotion.cpp | 4 +- indra/llcharacter/lltargetingmotion.cpp | 2 +- indra/llcommon/llcriticaldamp.cpp | 50 +++++++++----- indra/llcommon/llcriticaldamp.h | 82 +---------------------- indra/llui/llbutton.cpp | 5 +- indra/llui/lllayoutstack.cpp | 12 ++-- indra/llui/llmenugl.cpp | 2 +- indra/llui/llscrollbar.cpp | 5 +- indra/llui/lltabcontainer.cpp | 3 +- indra/newview/llagentcamera.cpp | 23 +++---- indra/newview/lldrawable.cpp | 104 ++++++++++++++++------------- indra/newview/llfasttimerview.cpp | 4 +- indra/newview/llfloatercolorpicker.cpp | 5 +- indra/newview/llfloatersnapshot.cpp | 5 +- indra/newview/llfolderviewitem.cpp | 7 +- indra/newview/llfollowcam.cpp | 17 ++--- indra/newview/llhudnametag.cpp | 3 +- indra/newview/llmaniprotate.cpp | 18 ++--- indra/newview/llmanipscale.cpp | 5 +- indra/newview/llmaniptranslate.cpp | 13 ++-- indra/newview/llnetmap.cpp | 3 +- indra/newview/llselectmgr.cpp | 9 --- indra/newview/lltexturectrl.cpp | 4 +- indra/newview/llviewerdisplay.cpp | 3 +- indra/newview/llvoavatar.cpp | 12 ++-- indra/newview/llworldmapview.cpp | 4 +- 30 files changed, 179 insertions(+), 245 deletions(-) (limited to 'indra') diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp index 35508e0a87..4e8c3268c5 100644 --- a/indra/llcharacter/lleditingmotion.cpp +++ b/indra/llcharacter/lleditingmotion.cpp @@ -38,6 +38,8 @@ // Constants //----------------------------------------------------------------------------- const LLQuaternion EDIT_MOTION_WRIST_ROTATION(F_PI_BY_TWO * 0.7f, LLVector3(1.0f, 0.0f, 0.0f)); +const F32 TARGET_LAG_HALF_LIFE = 0.1f; // half-life of IK targeting +const F32 TORSO_LAG_HALF_LIFE = 0.2f; const F32 MAX_TIME_DELTA = 2.f; //max two seconds a frame for calculating interpolation S32 LLEditingMotion::sHandPose = LLHandMotion::HAND_POSE_RELAXED_R; @@ -230,7 +232,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) mIKSolver.solve(); // use blending... - F32 slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTargetLagHalfLife); + F32 slerp_amt = LLCriticalDamp::getInterpolant(TARGET_LAG_HALF_LIFE); shoulderRot = slerp(slerp_amt, mShoulderJoint.getRotation(), shoulderRot); elbowRot = slerp(slerp_amt, mElbowJoint.getRotation(), elbowRot); diff --git a/indra/llcharacter/llheadrotmotion.cpp b/indra/llcharacter/llheadrotmotion.cpp index 1eddd0f449..2b1aa194a9 100644 --- a/indra/llcharacter/llheadrotmotion.cpp +++ b/indra/llcharacter/llheadrotmotion.cpp @@ -182,8 +182,8 @@ BOOL LLHeadRotMotion::onUpdate(F32 time, U8* joint_mask) LLQuaternion currentRootRotWorld = mRootJoint->getWorldRotation(); LLQuaternion currentInvRootRotWorld = ~currentRootRotWorld; - F32 head_slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaHeadLookAtLagHalfLife); - F32 torso_slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTorsoLookAtLagHalfLife); + F32 head_slerp_amt = LLCriticalDamp::getInterpolant(HEAD_LOOKAT_LAG_HALF_LIFE); + F32 torso_slerp_amt = LLCriticalDamp::getInterpolant(TORSO_LOOKAT_LAG_HALF_LIFE); LLVector3* targetPos = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index f394cf2635..905d1c2d26 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -1031,11 +1031,11 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 if (constraint->mSharedData->mChainLength != 0 && dist_vec_squared(root_pos, target_pos) * 0.95f > constraint->mTotalLength * constraint->mTotalLength) { - constraint->mWeight = lerp(constraint->mWeight, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + constraint->mWeight = lerp(constraint->mWeight, 0.f, LLCriticalDamp::getInterpolant(0.1f)); } else { - constraint->mWeight = lerp(constraint->mWeight, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaSmallish)); + constraint->mWeight = lerp(constraint->mWeight, 1.f, LLCriticalDamp::getInterpolant(0.3f)); } F32 weight = constraint->mWeight * ((shared_data->mEaseOutStopTime == 0.f) ? 1.f : @@ -1084,7 +1084,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 F32 time_constant = 1.f / clamp_rescale(constraint->mFixupDistanceRMS, 0.f, 0.5f, 0.2f, 8.f); // llinfos << "Interpolant " << LLCriticalDamp::getInterpolant(time_constant, FALSE) << " and fixup distance " << constraint->mFixupDistanceRMS << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << llendl; positions[joint_num] = lerp(positions[joint_num], kinematic_position, - LLCriticalDamp::getInterpolant(time_constant)); + LLCriticalDamp::getInterpolant(time_constant, FALSE)); } S32 iteration_count; diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp index d17c123e54..8422553beb 100644 --- a/indra/llcharacter/llkeyframewalkmotion.cpp +++ b/indra/llcharacter/llkeyframewalkmotion.cpp @@ -287,7 +287,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) F32 desired_speed_multiplier = llclamp(speed / foot_speed, min_speed_multiplier, ANIM_SPEED_MAX); // blend towards new speed adjustment value - F32 new_speed_adjust = lerp(mAdjustedSpeed, desired_speed_multiplier, LLCriticalDamp::getInterpolant(InterpDeltaSpeedAdjustTime)); + F32 new_speed_adjust = lerp(mAdjustedSpeed, desired_speed_multiplier, LLCriticalDamp::getInterpolant(SPEED_ADJUST_TIME_CONSTANT)); // limit that rate at which the speed adjustment changes F32 speedDelta = llclamp(new_speed_adjust - mAdjustedSpeed, -SPEED_ADJUST_MAX_SEC * delta_time, SPEED_ADJUST_MAX_SEC * delta_time); @@ -305,8 +305,8 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) { // standing/turning // damp out speed adjustment to 0 - mAnimSpeed = lerp(mAnimSpeed, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaSmall)); - //mPelvisOffset = lerp(mPelvisOffset, LLVector3::zero, LLCriticalDamp::getInterpolant(InterpDeltaSmall)); + mAnimSpeed = lerp(mAnimSpeed, 1.f, LLCriticalDamp::getInterpolant(0.2f)); + //mPelvisOffset = lerp(mPelvisOffset, LLVector3::zero, LLCriticalDamp::getInterpolant(0.2f)); } // broadcast walk speed change diff --git a/indra/llcharacter/llmotion.cpp b/indra/llcharacter/llmotion.cpp index d4db0d84c9..a07f9f4d2e 100644 --- a/indra/llcharacter/llmotion.cpp +++ b/indra/llcharacter/llmotion.cpp @@ -73,7 +73,7 @@ void LLMotion::fadeOut() { if (mFadeWeight > 0.01f) { - mFadeWeight = lerp(mFadeWeight, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaFadeWeight)); + mFadeWeight = lerp(mFadeWeight, 0.f, LLCriticalDamp::getInterpolant(0.15f)); } else { @@ -88,7 +88,7 @@ void LLMotion::fadeIn() { if (mFadeWeight < 0.99f) { - mFadeWeight = lerp(mFadeWeight, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaFadeWeight)); + mFadeWeight = lerp(mFadeWeight, 1.f, LLCriticalDamp::getInterpolant(0.15f)); } else { diff --git a/indra/llcharacter/lltargetingmotion.cpp b/indra/llcharacter/lltargetingmotion.cpp index 6ce6ce31d6..fa5f06328e 100644 --- a/indra/llcharacter/lltargetingmotion.cpp +++ b/indra/llcharacter/lltargetingmotion.cpp @@ -106,7 +106,7 @@ BOOL LLTargetingMotion::onActivate() //----------------------------------------------------------------------------- BOOL LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) { - F32 slerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaTorsoTargetLagHalfLife); + F32 slerp_amt = LLCriticalDamp::getInterpolant(TORSO_TARGET_HALF_LIFE); LLVector3 target; LLVector3* lookAtPoint = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); diff --git a/indra/llcommon/llcriticaldamp.cpp b/indra/llcommon/llcriticaldamp.cpp index 27fef0e6dc..49aac9ce75 100644 --- a/indra/llcommon/llcriticaldamp.cpp +++ b/indra/llcommon/llcriticaldamp.cpp @@ -32,9 +32,8 @@ // static members //----------------------------------------------------------------------------- LLFrameTimer LLCriticalDamp::sInternalTimer; +std::map LLCriticalDamp::sInterpolants; F32 LLCriticalDamp::sTimeDelta; -F32 LLCriticalDamp::sInterpolants[kNumCachedInterpolants]; -F32 LLCriticalDamp::sInterpolatedValues[kNumCachedInterpolants]; //----------------------------------------------------------------------------- // LLCriticalDamp() @@ -42,17 +41,6 @@ F32 LLCriticalDamp::sInterpolatedValues[kNumCachedInterpolants]; LLCriticalDamp::LLCriticalDamp() { sTimeDelta = 0.f; - - // Init the core interpolant values (to which many, many enums map) - // - setInterpolantConstant(InterpDelta_0_025, 0.025f); - setInterpolantConstant(InterpDelta_0_05, 0.05f ); - setInterpolantConstant(InterpDelta_0_06, 0.06f); - setInterpolantConstant(InterpDelta_0_10, 0.10f); - setInterpolantConstant(InterpDelta_0_15, 0.15f); - setInterpolantConstant(InterpDelta_0_20, 0.20f); - setInterpolantConstant(InterpDelta_0_25, 0.25f); - setInterpolantConstant(InterpDelta_0_30, 0.30f); } // static @@ -63,10 +51,40 @@ void LLCriticalDamp::updateInterpolants() { sTimeDelta = sInternalTimer.getElapsedTimeAndResetF32(); - U32 i; - for (i = 0; i < kNumCachedInterpolants; i++) + F32 time_constant; + + for (std::map::iterator iter = sInterpolants.begin(); + iter != sInterpolants.end(); iter++) + { + time_constant = iter->first; + F32 new_interpolant = 1.f - pow(2.f, -sTimeDelta / time_constant); + new_interpolant = llclamp(new_interpolant, 0.f, 1.f); + sInterpolants[time_constant] = new_interpolant; + } +} + +//----------------------------------------------------------------------------- +// getInterpolant() +//----------------------------------------------------------------------------- +F32 LLCriticalDamp::getInterpolant(const F32 time_constant, BOOL use_cache) +{ + if (time_constant == 0.f) + { + return 1.f; + } + + if (use_cache && sInterpolants.count(time_constant)) { - sInterpolatedValues[i] = llclamp(sTimeDelta / sInterpolants[ i], 0.0f, 1.0f); + return sInterpolants[time_constant]; } + + F32 interpolant = 1.f - pow(2.f, -sTimeDelta / time_constant); + interpolant = llclamp(interpolant, 0.f, 1.f); + if (use_cache) + { + sInterpolants[time_constant] = interpolant; + } + + return interpolant; } diff --git a/indra/llcommon/llcriticaldamp.h b/indra/llcommon/llcriticaldamp.h index 19a2ddb77a..52f052ae25 100644 --- a/indra/llcommon/llcriticaldamp.h +++ b/indra/llcommon/llcriticaldamp.h @@ -32,98 +32,22 @@ #include "llframetimer.h" -// These enums each represent one fixed-time delta value -// that we interpolate once given the actual sTimeDelta time -// that has passed. This allows us to calculate the interp portion -// of those values once and then look them up repeatedly per frame. -// -enum InterpDelta -{ - InterpDelta_0_025, // 0.025 - InterpDeltaTeenier = InterpDelta_0_025, - InterpDeltaFolderOpenTime = InterpDelta_0_025, - InterpDeltaFolderCloseTime = InterpDelta_0_025, - InterpDeltaCameraFocusHalfLife = InterpDelta_0_025, // USED TO BE ZERO.... - - InterpDelta_0_05, // 0.05 - InterpDeltaTeeny = InterpDelta_0_05, - - InterpDelta_0_06, // 0.06 - InterpDeltaObjectDampingConstant = InterpDelta_0_06, - InterpDeltaCameraZoomHalfLife = InterpDelta_0_06, - InterpDeltaFovZoomHalfLife = InterpDelta_0_06, - InterpDeltaManipulatorScaleHalfLife = InterpDelta_0_06, - InterpDeltaContextFadeTime = InterpDelta_0_06, - - InterpDelta_0_10, // 0.10 - InterpDeltaSmaller = InterpDelta_0_10, - InterpDeltaTargetLagHalfLife = InterpDelta_0_10, - InterpDeltaSpeedAdjustTime = InterpDelta_0_10, - - InterpDelta_0_15, // 0.15 - InterpDeltaFadeWeight = InterpDelta_0_15, - InterpDeltaHeadLookAtLagHalfLife = InterpDelta_0_15, - - InterpDelta_0_20, // 0.20 - InterpDeltaSmall = InterpDelta_0_20, - InterpDeltaTorsoLagHalfLife = InterpDelta_0_20, - InterpDeltaPositionDampingTC = InterpDelta_0_20, - - InterpDelta_0_25, // 0.25 - InterpDeltaCameraLagHalfLife = InterpDelta_0_25, - InterpDeltaTorsoTargetLagHalfLife = InterpDelta_0_25, - InterpDeltaTorsoLookAtLagHalfLife = InterpDelta_0_25, - - InterpDelta_0_30, // 0.3 - InterpDeltaSmallish = InterpDelta_0_30, - - // Dynamically set interpolants which use setInterpolantConstant - // - InterpDeltaCameraSmoothingHalfLife, - InterpDeltaBehindnessLag, - InterpDeltaFocusLag, - InterpDeltaPositionLag, - InterpDeltaOpenTime, - InterpDeltaCloseTime, - - kNumCachedInterpolants -}; - class LL_COMMON_API LLCriticalDamp { public: LLCriticalDamp(); - // Updates all the known interp delta values for fast lookup in calls to getInterpolant(InterpDelta) - // + // MANIPULATORS static void updateInterpolants(); - static inline void setInterpolantConstant(InterpDelta whichDelta, const F32 time_constant) - { - llassert(whichDelta < kNumCachedInterpolants); - sInterpolants[whichDelta] = time_constant; - } - // ACCESSORS - static inline F32 getInterpolant(InterpDelta whichDelta) - { - llassert(whichDelta < kNumCachedInterpolants); - return sInterpolatedValues[whichDelta]; - } - - static inline F32 getInterpolant(const F32 time_constant) - { - return llclamp((sTimeDelta / time_constant), 0.0f, 1.0f); - } + static F32 getInterpolant(const F32 time_constant, BOOL use_cache = TRUE); protected: static LLFrameTimer sInternalTimer; // frame timer for calculating deltas - //static std::map sInterpolants; - static F32 sInterpolants[kNumCachedInterpolants]; - static F32 sInterpolatedValues[kNumCachedInterpolants]; + static std::map sInterpolants; static F32 sTimeDelta; }; #endif // LL_LLCRITICALDAMP_H - diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 3dfcb3ffa1..705fe16559 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -758,11 +758,11 @@ void LLButton::draw() mCurGlowStrength = lerp(mCurGlowStrength, mFlashing ? (flash? 1.0 : 0.0) : mHoverGlowStrength, - LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + LLCriticalDamp::getInterpolant(0.05f)); } else { - mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f)); } // Draw button image, if available. @@ -1247,4 +1247,3 @@ BOOL LLButton::handleDoubleClick(S32 x, S32 y, MASK mask) // just treat a double click as a second click return handleMouseDown(x, y, mask); } - diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 32383b1f1d..3adc1a6c70 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -229,10 +229,7 @@ LLLayoutStack::LLLayoutStack(const LLLayoutStack::Params& p) mOpenTimeConstant(p.open_time_constant), mCloseTimeConstant(p.close_time_constant), mResizeBarOverlap(p.resize_bar_overlap) -{ - LLCriticalDamp::setInterpolantConstant(InterpDeltaCloseTime, mCloseTimeConstant); - LLCriticalDamp::setInterpolantConstant(InterpDeltaOpenTime, mOpenTimeConstant); -} +{} LLLayoutStack::~LLLayoutStack() { @@ -595,7 +592,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaOpenTime)); + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(mOpenTimeConstant)); if (panelp->mVisibleAmt > 0.99f) { panelp->mVisibleAmt = 1.f; @@ -620,7 +617,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaCloseTime)); + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); if (panelp->mVisibleAmt < 0.001f) { panelp->mVisibleAmt = 0.f; @@ -647,7 +644,7 @@ bool LLLayoutStack::animatePanels() { if (!mAnimatedThisFrame) { - panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLCriticalDamp::getInterpolant(InterpDeltaCloseTime)); + panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); } if (llabs(panelp->mCollapseAmt - collapse_state) < 0.001f) @@ -858,4 +855,3 @@ void LLLayoutStack::updateResizeBarLimits() previous_visible_panelp = visible_panelp; } } - diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index f142be885d..cd6cc6a75e 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -3673,7 +3673,7 @@ void LLTearOffMenu::draw() if (getRect().getHeight() != mTargetHeight) { // animate towards target height - reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)))); + reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(0.05f)))); } LLFloater::draw(); } diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index d65b4431a8..5d3bf7a670 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -493,11 +493,11 @@ void LLScrollbar::draw() BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y)); if (hovered) { - mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f)); } else { - mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f)); } // Draw background and thumb. @@ -642,4 +642,3 @@ void LLScrollbar::onLineDownBtnPressed( const LLSD& data ) { changeLine( mStepSize, TRUE ); } - diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 1e64cd0df8..5fc2cc350d 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -406,7 +406,7 @@ void LLTabContainer::draw() } } - setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(InterpDeltaTeeny))); + setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(0.08f))); BOOL has_scroll_arrows = !getTabsHidden() && ((mMaxScrollPos > 0) || (mScrollPosPixels > 0)); if (!mIsVertical) @@ -2046,4 +2046,3 @@ void LLTabContainer::commitHoveredButton(S32 x, S32 y) } } } - diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index a40d9cd318..9025c7af8b 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -179,7 +179,7 @@ LLAgentCamera::LLAgentCamera() : clearGeneralKeys(); clearOrbitKeys(); - clearPanKeys(); + clearPanKeys(); } // Requires gSavedSettings to be initialized. @@ -192,9 +192,6 @@ void LLAgentCamera::init() mDrawDistance = gSavedSettings.getF32("RenderFarClip"); - const F32 SMOOTHING_HALF_LIFE = 0.02f; - LLCriticalDamp::setInterpolantConstant(InterpDeltaCameraSmoothingHalfLife, gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE); - LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW); // Leave at 0.1 meters until we have real near clip management LLViewerCamera::getInstance()->setNear(0.1f); @@ -340,7 +337,7 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) LLVector3 agent_at_axis = gAgent.getAtAxis(); agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector()); agent_at_axis.normalize(); - gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(InterpDeltaSmall))); + gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); } setFocusOnAvatar(TRUE, ANIMATE); @@ -1249,7 +1246,7 @@ void LLAgentCamera::updateCamera() gAgentCamera.clearPanKeys(); // lerp camera focus offset - mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(InterpDeltaCameraFocusHalfLife)); + mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(CAMERA_FOCUS_HALF_LIFE)); if ( mCameraMode == CAMERA_MODE_FOLLOW ) { @@ -1364,8 +1361,10 @@ void LLAgentCamera::updateCamera() mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode; if (cameraThirdPerson() && !mCameraSmoothingStop) - { - F32 smoothing = LLCriticalDamp::getInterpolant(InterpDeltaCameraSmoothingHalfLife); + { + const F32 SMOOTHING_HALF_LIFE = 0.02f; + + F32 smoothing = LLCriticalDamp::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE); if (!mFocusObject) // we differentiate on avatar mode { @@ -1395,7 +1394,7 @@ void LLAgentCamera::updateCamera() } - mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(InterpDeltaFovZoomHalfLife)); + mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(FOV_ZOOM_HALF_LIFE)); // llinfos << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << llendl; @@ -1810,7 +1809,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) if (mTargetCameraDistance != mCurrentCameraDistance) { - F32 camera_lerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaCameraZoomHalfLife); + F32 camera_lerp_amt = LLCriticalDamp::getInterpolant(CAMERA_ZOOM_HALF_LIFE); mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt); } @@ -1828,7 +1827,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) if (isAgentAvatarValid()) { LLVector3d camera_lag_d; - F32 lag_interp = LLCriticalDamp::getInterpolant(InterpDeltaCameraLagHalfLife); + F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); LLVector3 target_lag; LLVector3 vel = gAgent.getVelocity(); @@ -1873,7 +1872,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) } else { - mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(InterpDeltaCameraLagHalfLife)); + mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(0.15f)); } camera_lag_d.setVec(mCameraLag); diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 235da41998..d29181a3ce 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -492,83 +492,97 @@ F32 LLDrawable::updateXform(BOOL undamped) BOOL damped = !undamped; // Position - LLVector3 old_pos = mXform.getPosition(); - - // get agent position or parent-relative position as appropriate - // - LLVector3 target_pos = mXform.isRoot() ? mVObjp->getPositionAgent() : mVObjp->getPosition(); - + LLVector3 old_pos(mXform.getPosition()); + LLVector3 target_pos; + if (mXform.isRoot()) + { + // get root position in your agent's region + target_pos = mVObjp->getPositionAgent(); + } + else + { + // parent-relative position + target_pos = mVObjp->getPosition(); + } + // Rotation LLQuaternion old_rot(mXform.getRotation()); LLQuaternion target_rot = mVObjp->getRotation(); - //scaling LLVector3 target_scale = mVObjp->getScale(); LLVector3 old_scale = mCurrentScale; LLVector3 dest_scale = target_scale; - LLVector3 scale_vec = old_scale-target_scale; - - static const F32 dot_threshold = 1.0f - FLT_EPSILON; - - F32 dist_squared = dist_vec_squared(old_pos, target_pos); - - bool translated = dist_squared > 0.0f; - bool rotated = !mVObjp->getAngularVelocity().isExactlyZero() || (dot(old_rot, target_rot) < dot_threshold); - bool scaled = (scale_vec * scale_vec) > MIN_INTERPOLATE_DISTANCE_SQUARED; - // Damping + // Damping + F32 dist_squared = 0.f; + F32 camdist2 = (mDistanceWRTCamera * mDistanceWRTCamera); + if (damped && isVisible()) { - F32 lerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaObjectDampingConstant); + F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); - dist_squared = dist_vec_squared(new_pos, old_pos); + dist_squared = dist_vec_squared(new_pos, target_pos); LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); - dist_squared += fabs(1.f - dot(new_rot, old_rot)) * 10.f; + // FIXME: This can be negative! It is be possible for some rots to 'cancel out' pos or size changes. + dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); - dist_squared += dist_vec_squared(new_scale, old_scale); + dist_squared += dist_vec_squared(new_scale, target_scale); - // If our lerp isn't moving too far, substitue the lerp'd pos for our target for this frame - // - if (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED) + if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && + (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) { // interpolate target_pos = new_pos; target_rot = new_rot; target_scale = new_scale; } - else + else if (mVObjp->getAngularVelocity().isExactlyZero()) { - llinfos << "skipping update due to overly large lerp" << llendl; + // snap to final position (only if no target omega is applied) + dist_squared = 0.0f; + if (getVOVolume() && !isRoot()) + { //child prim snapping to some position, needs a rebuild + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } } } + else + { + // The following fixes MAINT-1742 but breaks vehicles similar to MAINT-2275 + // dist_squared = dist_vec_squared(old_pos, target_pos); - if (translated || rotated || scaled) - { - if (scaled) - { - mCurrentScale = target_scale; - } + // The following fixes MAINT-2247 but causes MAINT-2275 + //dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; + //dist_squared += dist_vec_squared(old_scale, target_scale); + } + LLVector3 vec = mCurrentScale-target_scale; + + if (vec*vec > MIN_INTERPOLATE_DISTANCE_SQUARED) + { //scale change requires immediate rebuild + mCurrentScale = target_scale; + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } + else if (!isRoot() && + (!mVObjp->getAngularVelocity().isExactlyZero() || + dist_squared > 0.f)) + { //child prim moving relative to parent, tag as needing to be rendered atomically and rebuild dist_squared = 1.f; //keep this object on the move list - - //child prim moving relative to parent, tag as needing to be rendered atomically - // - if (!isRoot() && !isState(LLDrawable::ANIMATED_CHILD)) + if (!isState(LLDrawable::ANIMATED_CHILD)) { setState(LLDrawable::ANIMATED_CHILD); - } - - // Mark any components that need to be rebuilt based on what change transpired - // - if (!rotated && !scaled) - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); - else gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); - - mVObjp->dirtySpatialGroup(); + mVObjp->dirtySpatialGroup(); + } } + else if (!isRoot() + && ( dist_vec_squared(old_pos, target_pos) > 0.f + || (1.f - dot(old_rot, target_rot)) > 0.f)) + { // update child prims moved from LSL + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } else if (!getVOVolume() && !isAvatar()) { movePartition(); diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 643ce63f29..e7a3f9b390 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -940,7 +940,7 @@ void LLFastTimerView::draw() } //interpolate towards new maximum - last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); if (last_max - cur_max <= 1 || cur_max - last_max <= 1) { last_max = cur_max; @@ -948,7 +948,7 @@ void LLFastTimerView::draw() F32 alpha_target = last_max > cur_max ? llmin((F32) last_max/ (F32) cur_max - 1.f,1.f) : llmin((F32) cur_max/ (F32) last_max - 1.f,1.f); - alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); if (mHoverID != NULL) { diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index 10d31df22c..d6ebe44daa 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -525,11 +525,11 @@ void LLFloaterColorPicker::draw() if (gFocusMgr.childHasMouseCapture(getDragHandle())) { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); + mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); } else { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); + mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); } mPipetteBtn->setToggleState(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); @@ -1113,4 +1113,3 @@ void LLFloaterColorPicker::stopUsingPipette() LLToolMgr::getInstance()->clearTransientTool(); } } - diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 103eaace88..d8d62e5bbb 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -478,7 +478,7 @@ void LLSnapshotLivePreview::draw() { if (mFlashAlpha < 1.f) { - mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); + mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(0.02f)); } else { @@ -487,7 +487,7 @@ void LLSnapshotLivePreview::draw() } else { - mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaSmallish) * 0.5f); + mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(0.15f)); } // Draw shining animation if appropriate. @@ -2500,4 +2500,3 @@ BOOL LLSnapshotFloaterView::handleHover(S32 x, S32 y, MASK mask) } return TRUE; } - diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 23241b57c4..3aa16b4413 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -1293,7 +1293,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) // animate current height towards target height if (llabs(mCurHeight - mTargetHeight) > 1.f) { - mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(mIsOpen ? InterpDeltaFolderOpenTime : InterpDeltaFolderCloseTime)); + mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(mIsOpen ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT)); requestArrange(); @@ -2538,11 +2538,11 @@ void LLFolderViewFolder::draw() } else if (mIsOpen) { - mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(0.04f)); } else { - mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); + mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(0.025f)); } bool possibly_has_children = false; @@ -2899,4 +2899,3 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde } } } - diff --git a/indra/newview/llfollowcam.cpp b/indra/newview/llfollowcam.cpp index a3c1996512..b670af1782 100644 --- a/indra/newview/llfollowcam.cpp +++ b/indra/newview/llfollowcam.cpp @@ -148,16 +148,14 @@ LLFollowCamParams::~LLFollowCamParams() { } //--------------------------------------------------------- void LLFollowCamParams::setPositionLag( F32 p ) { - mPositionLag = llclamp(p, FOLLOW_CAM_MIN_POSITION_LAG, FOLLOW_CAM_MAX_POSITION_LAG); - LLCriticalDamp::setInterpolantConstant(InterpDeltaPositionLag, mPositionLag); + mPositionLag = llclamp(p, FOLLOW_CAM_MIN_POSITION_LAG, FOLLOW_CAM_MAX_POSITION_LAG); } //--------------------------------------------------------- void LLFollowCamParams::setFocusLag( F32 f ) { - mFocusLag = llclamp(f, FOLLOW_CAM_MIN_FOCUS_LAG, FOLLOW_CAM_MAX_FOCUS_LAG); - LLCriticalDamp::setInterpolantConstant(InterpDeltaFocusLag, mFocusLag); + mFocusLag = llclamp(f, FOLLOW_CAM_MIN_FOCUS_LAG, FOLLOW_CAM_MAX_FOCUS_LAG); } @@ -186,7 +184,6 @@ void LLFollowCamParams::setPitch( F32 p ) void LLFollowCamParams::setBehindnessLag( F32 b ) { mBehindnessLag = llclamp(b, FOLLOW_CAM_MIN_BEHINDNESS_LAG, FOLLOW_CAM_MAX_BEHINDNESS_LAG); - LLCriticalDamp::setInterpolantConstant(InterpDeltaBehindnessLag, mBehindnessLag); } //--------------------------------------------------------- @@ -331,11 +328,11 @@ void LLFollowCam::update() F32 force = focusOffsetDistance - focusThresholdNormalizedByDistance; */ - F32 focusLagLerp = LLCriticalDamp::getInterpolant(InterpDeltaFocusLag); + F32 focusLagLerp = LLCriticalDamp::getInterpolant( mFocusLag ); focus_pt_agent = lerp( focus_pt_agent, whereFocusWantsToBe, focusLagLerp ); mSimulatedFocusGlobal = gAgent.getPosGlobalFromAgent(focus_pt_agent); } - mRelativeFocus = lerp(mRelativeFocus, (focus_pt_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mRelativeFocus = lerp(mRelativeFocus, (focus_pt_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(0.05f)); }// if focus is not locked --------------------------------------------- @@ -418,7 +415,7 @@ void LLFollowCam::update() //------------------------------------------------------------------------------------------------- if ( distanceFromPositionToIdealPosition > mPositionThreshold ) { - F32 positionPullLerp = LLCriticalDamp::getInterpolant(InterpDeltaPositionLag); + F32 positionPullLerp = LLCriticalDamp::getInterpolant( mPositionLag ); simulated_pos_agent = lerp( simulated_pos_agent, whereCameraPositionWantsToBe, positionPullLerp ); } @@ -438,7 +435,7 @@ void LLFollowCam::update() updateBehindnessConstraint(gAgent.getPosAgentFromGlobal(mSimulatedFocusGlobal), simulated_pos_agent); mSimulatedPositionGlobal = gAgent.getPosGlobalFromAgent(simulated_pos_agent); - mRelativePos = lerp(mRelativePos, (simulated_pos_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(InterpDeltaTeeny)); + mRelativePos = lerp(mRelativePos, (simulated_pos_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(0.05f)); } // if position is not locked ----------------------------------------------------------- @@ -493,7 +490,7 @@ BOOL LLFollowCam::updateBehindnessConstraint(LLVector3 focus, LLVector3& cam_pos if ( cameraOffsetAngle > mBehindnessMaxAngle ) { - F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLCriticalDamp::getInterpolant(InterpDeltaBehindnessLag); + F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLCriticalDamp::getInterpolant(mBehindnessLag); cam_position = focus + horizontalSubjectBack * (slerp(fraction, camera_offset_rotation, LLQuaternion::DEFAULT)); cam_position.mV[VZ] = cameraZ; // clamp z value back to what it was before we started messing with it constraint_active = TRUE; diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index b94681b340..482294c8a6 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -980,7 +980,7 @@ void LLHUDNameTag::updateAll() // { // continue; // } - (*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(InterpDeltaPositionDampingTC)); + (*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(POSITION_DAMPING_TC)); } } @@ -1083,4 +1083,3 @@ F32 LLHUDNameTag::LLHUDTextSegment::getWidth(const LLFontGL* font) return width; } } - diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp index 748ac7a16e..826e8d560a 100644 --- a/indra/newview/llmaniprotate.cpp +++ b/indra/newview/llmaniprotate.cpp @@ -240,7 +240,7 @@ void LLManipRotate::render() if (mManipPart == LL_ROT_Z) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.pushMatrix(); { // selected part @@ -251,7 +251,7 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_Y) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.pushMatrix(); { gGL.rotatef( 90.f, 1.f, 0.f, 0.f ); @@ -262,7 +262,7 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_X) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.pushMatrix(); { gGL.rotatef( 90.f, 0.f, 1.f, 0.f ); @@ -273,13 +273,13 @@ void LLManipRotate::render() } else if (mManipPart == LL_ROT_ROLL) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } else if (mManipPart == LL_NO_PART) { if (mHighlightedPart == LL_NO_PART) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } LLGLEnable cull_face(GL_CULL_FACE); @@ -294,7 +294,7 @@ void LLManipRotate::render() { if (mHighlightedPart == LL_ROT_Z) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.scalef(mManipulatorScales.mV[VZ], mManipulatorScales.mV[VZ], mManipulatorScales.mV[VZ]); // hovering over part gl_ring( mRadiusMeters, width_meters, LLColor4( 0.f, 0.f, 1.f, 1.f ), LLColor4( 0.f, 0.f, 1.f, 0.5f ), CIRCLE_STEPS, i); @@ -312,7 +312,7 @@ void LLManipRotate::render() gGL.rotatef( 90.f, 1.f, 0.f, 0.f ); if (mHighlightedPart == LL_ROT_Y) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.scalef(mManipulatorScales.mV[VY], mManipulatorScales.mV[VY], mManipulatorScales.mV[VY]); // hovering over part gl_ring( mRadiusMeters, width_meters, LLColor4( 0.f, 1.f, 0.f, 1.f ), LLColor4( 0.f, 1.f, 0.f, 0.5f ), CIRCLE_STEPS, i); @@ -330,7 +330,7 @@ void LLManipRotate::render() gGL.rotatef( 90.f, 0.f, 1.f, 0.f ); if (mHighlightedPart == LL_ROT_X) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); gGL.scalef(mManipulatorScales.mV[VX], mManipulatorScales.mV[VX], mManipulatorScales.mV[VX]); // hovering over part @@ -346,7 +346,7 @@ void LLManipRotate::render() if (mHighlightedPart == LL_ROT_ROLL) { - mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } } diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 9802d5503e..00a0bf8894 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -535,11 +535,11 @@ void LLManipScale::highlightManipulators(S32 x, S32 y) { if (mHighlightedPart == MANIPULATOR_IDS[i]) { - mManipulatorScales[i] = lerp(mManipulatorScales[i], SELECTED_MANIPULATOR_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales[i] = lerp(mManipulatorScales[i], SELECTED_MANIPULATOR_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } else { - mManipulatorScales[i] = lerp(mManipulatorScales[i], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mManipulatorScales[i] = lerp(mManipulatorScales[i], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE)); } } @@ -2082,4 +2082,3 @@ BOOL LLManipScale::canAffectSelection() } return can_scale; } - diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index 9d287e7a03..0228807dc8 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -1922,18 +1922,18 @@ void LLManipTranslate::renderTranslationHandles() { if (index == mManipPart - LL_X_ARROW || index == mHighlightedPart - LL_X_ARROW) { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); } else if (index == mManipPart - LL_YZ_PLANE || index == mHighlightedPart - LL_YZ_PLANE) { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); } else { - mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); - mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(InterpDeltaManipulatorScaleHalfLife)); + mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); + mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE )); } } @@ -2323,4 +2323,3 @@ BOOL LLManipTranslate::canAffectSelection() } return can_move; } - diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 274497f2b5..1bda7640bd 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -162,7 +162,7 @@ void LLNetMap::draw() static LLUICachedControl auto_center("MiniMapAutoCenter", true); if (auto_center) { - mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(0.1f)); } // Prepare a scissor region @@ -987,4 +987,3 @@ void LLNetMap::handleStopTracking (const LLSD& userdata) LLTracker::stopTracking ((void*)LLTracker::isTracking(NULL)); } } - diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index cf9d95455e..343316d30a 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6108,14 +6108,6 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); gGL.begin(LLRender::LINES); { - // Lines require an even number of verts so repeat the first - // vert if we don't meet that requirement - // - if (mSilhouetteVertices.size() & 0x1) - { - mSilhouetteVertices.push_back(mSilhouetteVertices[0]); - } - for(S32 i = 0; i < mSilhouetteVertices.size(); i += 2) { u_coord += u_divisor * LLSelectMgr::sHighlightUScale; @@ -7555,4 +7547,3 @@ void LLSelectMgr::sendSelectionMove() //saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); } - diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 8c5844eca7..ec36cf48c2 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -549,11 +549,11 @@ void LLFloaterTexturePicker::draw() if (gFocusMgr.childHasMouseCapture(getDragHandle())) { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); + mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); } else { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(InterpDeltaContextFadeTime)); + mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME)); } updateImageStats(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 3f97659c66..9ffc64312d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1033,7 +1033,7 @@ void render_hud_attachments() // clamp target zoom level to reasonable values gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); // smoothly interpolate current zoom level - gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); + gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f)); if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices()) { @@ -1593,4 +1593,3 @@ void display_cleanup() { gDisconnectedImagep = NULL; } - diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index d28da507ea..4efd59685e 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2913,7 +2913,7 @@ void LLVOAvatar::idleUpdateWindEffect() LLVector3 velocity = getVelocity(); F32 speed = velocity.length(); //RN: velocity varies too much frame to frame for this to work - mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLCriticalDamp::getInterpolant(InterpDeltaTeenier)); + mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLCriticalDamp::getInterpolant(0.02f)); mLastVel = velocity; LLVector4 wind; wind.setVec(getRegion()->mWind.getVelocityNoisy(getPositionAgent(), 4.f) - velocity); @@ -2934,10 +2934,13 @@ void LLVOAvatar::idleUpdateWindEffect() wind.mV[VW] = llmin(0.025f + (speed * 0.015f) + hover_strength, 0.5f); F32 interp; - interp = LLCriticalDamp::getInterpolant(InterpDeltaSmall); - if (wind.mV[VW] <= mWindVec.mV[VW]) + if (wind.mV[VW] > mWindVec.mV[VW]) { - interp *= 2.0f; + interp = LLCriticalDamp::getInterpolant(0.2f); + } + else + { + interp = LLCriticalDamp::getInterpolant(0.4f); } mWindVec = lerp(mWindVec, wind, interp); @@ -3798,6 +3801,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) // Set the root rotation, but do so incrementally so that it // lags in time by some fixed amount. + //F32 u = LLCriticalDamp::getInterpolant(PELVIS_LAG); F32 pelvis_lag_time = 0.f; if (self_in_mouselook) { diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 7c3bc5988c..eeaa30aafb 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -302,8 +302,8 @@ void LLWorldMapView::draw() mVisibleRegions.clear(); // animate pan if necessary - sPanX = lerp(sPanX, sTargetPanX, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); - sPanY = lerp(sPanY, sTargetPanY, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + sPanX = lerp(sPanX, sTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); + sPanY = lerp(sPanY, sTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); const S32 width = getRect().getWidth(); const S32 height = getRect().getHeight(); -- cgit v1.2.3 From 54d8249691aea2b1bd3cd21d2569c977ff469e6f Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Thu, 14 Mar 2013 06:56:23 -0700 Subject: Fix mismerge losing rollback change --- indra/llcharacter/llkeyframewalkmotion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp index 8422553beb..69f064b615 100644 --- a/indra/llcharacter/llkeyframewalkmotion.cpp +++ b/indra/llcharacter/llkeyframewalkmotion.cpp @@ -383,7 +383,7 @@ BOOL LLFlyAdjustMotion::onUpdate(F32 time, U8* joint_mask) F32 target_roll = llclamp(ang_vel.mV[VZ], -4.f, 4.f) * roll_factor; // roll is critically damped interpolation between current roll and angular velocity-derived target roll - mRoll = lerp(mRoll, target_roll, LLCriticalDamp::getInterpolant(InterpDeltaSmaller)); + mRoll = lerp(mRoll, target_roll, LLCriticalDamp::getInterpolant(0.1f)); LLQuaternion roll(mRoll, LLVector3(0.f, 0.f, 1.f)); mPelvisState->setRotation(roll); -- cgit v1.2.3 From cc2e0caa5f26baf29ce6cccb120ea95621cfe038 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 14 Mar 2013 13:22:23 -0500 Subject: Fix for broken LoD. Reviewed by Graham. --- indra/newview/lldrawable.cpp | 2 +- indra/newview/llvovolume.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index dc0e256ebb..235da41998 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -767,7 +767,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) } pos -= camera.getOrigin(); - mDistanceWRTCamera = 20.0f;//llround(pos.magVec(), 0.01f); + mDistanceWRTCamera = llround(pos.magVec(), 0.01f); mVObjp->updateLOD(); } } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3ce32b40bb..9dcdd467e7 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1299,9 +1299,9 @@ BOOL LLVOVolume::calcLOD() if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_LOD_INFO) && mDrawable->getFace(0)) { - //setDebugText(llformat("%.2f:%.2f, %d", debug_distance, radius, cur_detail)); + setDebugText(llformat("%.2f:%.2f, %d", mDrawable->mDistanceWRTCamera, radius, cur_detail)); - setDebugText(llformat("%d", mDrawable->getFace(0)->getTextureIndex())); + //setDebugText(llformat("%d", mDrawable->getFace(0)->getTextureIndex())); } if (cur_detail != mLOD) @@ -2993,7 +2993,7 @@ void LLVOVolume::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_p //transform view vector into volume space view_vector -= getRenderPosition(); - mDrawable->mDistanceWRTCamera = view_vector.length(); + //mDrawable->mDistanceWRTCamera = view_vector.length(); LLQuaternion worldRot = getRenderRotation(); view_vector = view_vector * ~worldRot; if (!isVolumeGlobal()) -- cgit v1.2.3 From 830e3ea0ec83070b56b805e43cb3ad261c413802 Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Fri, 15 Mar 2013 16:30:11 -0700 Subject: [MAINT-2386] Viewer crashes when user move landmarks from Inventory -> Landmarks or Places to Favorite bar - Fixed a bug where the viewer would crash when adding multiple landmarks to an empty favorites bar [Reviewer] Kelly --- indra/newview/llfavoritesbar.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 4cbc9cab4a..eb2b4b1ba2 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -1,4 +1,4 @@ -/** +]/** * @file llfavoritesbar.cpp * @brief LLFavoritesBarCtrl class implementation * @@ -546,6 +546,10 @@ void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, con bool insert_before = true; if (!mItems.empty()) { + // [MAINT-2386] When multiple landmarks are selected and dragged onto an empty favorites bar, + // the viewer would crash when casting mLastTab below, as mLastTab is still null when the + // second landmark is being added. + // To ensure mLastTab is valid, we need to call updateButtons() at the end of this function dest = dynamic_cast(mLandingTab); if (!dest) { @@ -616,6 +620,11 @@ void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, con cb); } + // [MAINT-2386] Ensure the favorite button has been created and is valid. + // This also ensures that mLastTab will be valid when dropping multiple + // landmarks to an empty favorites bar. + updateButtons(); + llinfos << "Copied inventory item #" << item->getUUID() << " to favorites." << llendl; } -- cgit v1.2.3 From 5216e9579f05b133b0cbd3fda9d5f7322ed4aacf Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Mon, 18 Mar 2013 11:39:24 -0700 Subject: Found an errant right bracket at the top of the file -- whoopsie! --- indra/newview/llfavoritesbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index eb2b4b1ba2..b5f5a1d169 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -1,4 +1,4 @@ -]/** +/** * @file llfavoritesbar.cpp * @brief LLFavoritesBarCtrl class implementation * -- cgit v1.2.3 From 79edd066a4ddce341b556642bf6b98ef761d59f6 Mon Sep 17 00:00:00 2001 From: callum_linden Date: Mon, 18 Mar 2013 17:00:29 -0700 Subject: MAINT-2497 FIX (Viewer) - viewer side change that goes with server side fix - adds direction when you set a TP landing point --- indra/newview/llfloaterland.cpp | 9 +++++++-- indra/newview/llviewermessage.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 5f58577a7c..22dd688be1 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -2025,6 +2025,10 @@ void LLPanelLandOptions::refresh() mSnapshotCtrl->setImageAssetID(parcel->getSnapshotID()); mSnapshotCtrl->setEnabled( can_change_identity ); + // find out where we're looking and convert that to an angle in degrees on a regular compass (not the internal representation) + LLVector3 user_look_at = parcel->getUserLookAt(); + U32 user_look_at_angle = ( (U32)( ( atan2(user_look_at[1], -user_look_at[0]) + F_PI * 2 ) * RAD_TO_DEG + 0.5) - 90) % 360; + LLVector3 pos = parcel->getUserLocation(); if (pos.isExactlyZero()) { @@ -2032,10 +2036,11 @@ void LLPanelLandOptions::refresh() } else { - mLocationText->setTextArg("[LANDING]",llformat("%d, %d, %d", + mLocationText->setTextArg("[LANDING]",llformat("%d, %d, %d (%d\xC2\xB0)", llround(pos.mV[VX]), llround(pos.mV[VY]), - llround(pos.mV[VZ]))); + llround(pos.mV[VZ]), + user_look_at_angle)); } mSetBtn->setEnabled( can_change_landing_point ); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 6e02fafd01..bdb09b4c6f 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4065,7 +4065,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) { LLTracker::stopTracking(NULL); } - else if ( is_teleport && !gAgent.getTeleportKeepsLookAt() ) + else if ( is_teleport && !gAgent.getTeleportKeepsLookAt() && look_at.isExactlyZero()) { //look at the beacon LLVector3 global_agent_pos = agent_pos; -- cgit v1.2.3 From a8245c51b9cd6fac1d26932dbb1fcf052f00da18 Mon Sep 17 00:00:00 2001 From: Maestro Linden Date: Tue, 19 Mar 2013 19:25:24 +0000 Subject: MAINT-2506 added viewer support for PERMISSION_SILENT_ESTATE_MANAGEMENT and PERMISSION_OVERRIDE_ANIMATIONS. Reviewed by Simon. --- indra/lscript/lscript_byteformat.h | 6 ++++++ indra/lscript/lscript_compile/indra.l | 2 ++ indra/newview/app_settings/keywords.ini | 2 ++ indra/newview/llviewermessage.cpp | 10 ++++++++-- indra/newview/skins/default/xui/en/strings.xml | 7 +++++-- 5 files changed, 23 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/lscript/lscript_byteformat.h b/indra/lscript/lscript_byteformat.h index a294def734..9650574622 100644 --- a/indra/lscript/lscript_byteformat.h +++ b/indra/lscript/lscript_byteformat.h @@ -530,6 +530,9 @@ typedef enum e_lscript_runtime_permissions SCRIPT_PERMISSION_TRACK_CAMERA, SCRIPT_PERMISSION_CONTROL_CAMERA, SCRIPT_PERMISSION_TELEPORT, + SCRIPT_PERMISSION_EXPERIENCE, + SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT, + SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS, SCRIPT_PERMISSION_EOF } LSCRIPTRunTimePermissions; @@ -547,6 +550,9 @@ const U32 LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_EOF] = (0x1 << 10),// SCRIPT_PERMISSION_TRACK_CAMERA (0x1 << 11),// SCRIPT_PERMISSION_CONTROL_CAMERA (0x1 << 12),// SCRIPT_PERMISSION_TELEPORT + (0x1 << 13),// SCRIPT_PERMISSION_EXPERIENCE + (0x1 << 14),// SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT + (0x1 << 15),// SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS }; // http_request string constants diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index 3f844d0fd1..42c89b8709 100644 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -214,6 +214,8 @@ extern "C" { int yyerror(const char *fmt, ...); } "PERMISSION_TRACK_CAMERA" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TRACK_CAMERA]; return(INTEGER_CONSTANT); } "PERMISSION_CONTROL_CAMERA" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_CONTROL_CAMERA]; return(INTEGER_CONSTANT); } "PERMISSION_TELEPORT" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TELEPORT]; return(INTEGER_CONSTANT); } +"PERMISSION_SILENT_ESTATE_MANAGEMENT" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT]; return(INTEGER_CONSTANT); } +"PERMISSION_OVERRIDE_ANIMATIONS" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS]; return(INTEGER_CONSTANT); } "INVENTORY_TEXTURE" { count(); yylval.ival = LLAssetType::AT_TEXTURE; return(INTEGER_CONSTANT); } "INVENTORY_SOUND" { count(); yylval.ival = LLAssetType::AT_SOUND; return(INTEGER_CONSTANT); } diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 0b346286c8..56b549ab62 100644 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -92,6 +92,8 @@ PERMISSION_CHANGE_LINKS Passed to llRequestPermissions library function to req PERMISSION_TRACK_CAMERA Passed to llRequestPermissions library function to request permission to track agent's camera PERMISSION_CONTROL_CAMERA Passed to llRequestPermissions library function to request permission to change agent's camera PERMISSION_TELEPORT Passed to llRequestPermissions library function to request permission to teleport agent +PERMISSION_SILENT_ESTATE_MANAGEMENT Passed to llRequestPermissions library function to request permission to modify estate settings without notifying the owner +PERMISSION_OVERRIDE_ANIMATIONS Passed to llRequestPermissions library function to request permission to change agent's default animations DEBUG_CHANNEL Chat channel reserved for debug and error messages from scripts PUBLIC_CHANNEL Chat channel that broadcasts to all nearby users diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index bdb09b4c6f..d7d82e1d67 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -160,7 +160,10 @@ const std::string SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] = "ChangePermissions", "TrackYourCamera", "ControlYourCamera", - "TeleportYourAgent" + "TeleportYourAgent", + "ExperiencePlaceholder", + "ManageEstateSilently", + "ChangeYourDefaultAnimations" }; const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] = @@ -176,7 +179,10 @@ const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] = FALSE, // ChangePermissions FALSE, // TrackYourCamera, FALSE, // ControlYourCamera - FALSE // TeleportYourAgent + FALSE, // TeleportYourAgent + FALSE, // ExperiencePlaceholder + FALSE, // ManageEstateSilently + FALSE // ChangeYourDefaultAnimations }; bool friendship_offer_callback(const LLSD& notification, const LLSD& response) diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 0f4424a7f9..6be044d03c 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -404,8 +404,11 @@ Please try logging in again in a minute. Add and remove joints with other objects Change its permissions Track your camera - Control your camera - Teleport you + Control your camera + Teleport you + Manage your estates silently + Change your default animations + Not Connected -- cgit v1.2.3 From 5dbb0a31da9bb3fb5ff7c5ead5d90808f9e4b797 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 20 Mar 2013 11:37:11 -0700 Subject: MAINT-2510 : Time can go backwards for viewer animation, assert fires. Reviewed by Kelly --- indra/llcharacter/llkeyframemotion.cpp | 3 ++- indra/newview/llmeshrepository.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 905d1c2d26..07ef52228e 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -672,7 +672,8 @@ BOOL LLKeyframeMotion::onActivate() //----------------------------------------------------------------------------- BOOL LLKeyframeMotion::onUpdate(F32 time, U8* joint_mask) { - llassert(time >= 0.f); + // llassert(time >= 0.f); // This will fire + time = llmax(0.f, time); if (mJointMotionList->mLoop) { diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 306f29f703..7a857ea7be 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -288,7 +288,7 @@ public: ~LLMeshSkinInfoResponder() { - llassert(mProcessed); + //llassert(mProcessed); this will assert due to a timeout (not handled?) MAINT-2511 } virtual void completedRaw(U32 status, const std::string& reason, @@ -313,7 +313,7 @@ public: ~LLMeshDecompositionResponder() { - llassert(mProcessed); + //llassert(mProcessed); this will assert due to a timeout (not handled?) MAINT-2511 } virtual void completedRaw(U32 status, const std::string& reason, @@ -338,7 +338,7 @@ public: ~LLMeshPhysicsShapeResponder() { - llassert(mProcessed); + //llassert(mProcessed); this will assert due to a timeout (not handled?) MAINT-2511 } virtual void completedRaw(U32 status, const std::string& reason, -- cgit v1.2.3 From 8e54ae95d1417f51edd6c68c389fd6cd7322ca52 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 20 Mar 2013 15:25:14 -0700 Subject: Prototype code for "simple imposter" mode rendering of avatars. Reviewed by Kelly --- indra/newview/app_settings/settings.xml | 26 ++- indra/newview/lldrawpoolavatar.cpp | 135 ++++++------- indra/newview/llviewermenu.cpp | 59 ++++++ indra/newview/llvoavatar.cpp | 221 ++++++++++++++++----- indra/newview/llvoavatar.h | 29 ++- indra/newview/pipeline.cpp | 14 +- .../skins/default/xui/en/menu_attachment_other.xml | 35 ++++ .../skins/default/xui/en/menu_avatar_other.xml | 39 +++- indra/newview/skins/default/xui/en/menu_viewer.xml | 9 + 9 files changed, 440 insertions(+), 127 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d2c3c6089c..21c278fd3b 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9370,7 +9370,7 @@ RenderAutoMuteRenderCostLimit Comment - Maximum render cost before an avatar is automatically visually muted (0 for no limit). + Maximum render weight before an avatar is automatically visually muted (0 to not use this limit). Persist 1 Type @@ -9381,7 +9381,7 @@ RenderAutoMuteSurfaceAreaLimit Comment - Maximum surface area of attachments before an avatar is automatically visually muted (0 for no limit). + Maximum surface area of attachments before an avatar is automatically visually muted (0 to not use this limit). Persist 1 Type @@ -9389,6 +9389,28 @@ Value 0 + RenderAutoMuteEnabled + + Comment + Apply visual muting to high cost, non-friends, not in IM, or somewhat distant avatars + Persist + 1 + Type + Boolean + Value + 0 + + RenderAutoMuteVisibilityRank + + Comment + Number of avatars to show normally for visual muting mode. + Persist + 1 + Type + U32 + Value + 0 + RenderAutoHideSurfaceAreaLimit diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index d5afa25c9c..3d7407ab54 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1163,88 +1163,85 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) } else if (pass >= 3 && pass <= 9) { //render rigged attachments - if (!avatarp->isVisuallyMuted()) + if (!avatarp->isVisuallyMuted()) // These details are skipped for visually muted (plain imposter) avatars { - if (pass == 3) - { - if (is_deferred_render) - { - renderDeferredRiggedSimple(avatarp); - } - else - { - renderRiggedSimple(avatarp); - } - } + if (pass == 3) // To do - use switch statement + { + if (is_deferred_render) + { + renderDeferredRiggedSimple(avatarp); + } + else + { + renderRiggedSimple(avatarp); + } + } else if (pass == 4) - { - if (is_deferred_render) - { - renderDeferredRiggedBump(avatarp); - } - else - { - renderRiggedFullbright(avatarp); - } - } + { + if (is_deferred_render) + { + renderDeferredRiggedBump(avatarp); + } + else + { + renderRiggedFullbright(avatarp); + } + } else if (pass == 5) - { - renderRiggedShinySimple(avatarp); - } + { + renderRiggedShinySimple(avatarp); + } else if (pass == 6) - { - renderRiggedFullbrightShiny(avatarp); - } - else if (pass >= 7 && pass < 9) - { - if (pass == 7) - { - renderRiggedAlpha(avatarp); - } - else if (pass == 8) - { - renderRiggedFullbrightAlpha(avatarp); - } - } + { + renderRiggedFullbrightShiny(avatarp); + } + else if (pass == 7) + { + renderRiggedAlpha(avatarp); + } + else if (pass == 8) + { + renderRiggedFullbrightAlpha(avatarp); + } else if (pass == 9) - { - renderRiggedGlow(avatarp); - } + { + renderRiggedGlow(avatarp); + } } } else { - if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) - { - LLMatrix4 rot_mat; - LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); - LLMatrix4 cfr(OGL_TO_CFR_ROTATION); - rot_mat *= cfr; + if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) + { + LLMatrix4 rot_mat; + LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); + LLMatrix4 cfr(OGL_TO_CFR_ROTATION); + rot_mat *= cfr; - LLVector4 wind; - wind.setVec(avatarp->mWindVec); - wind.mV[VW] = 0; - wind = wind * rot_mat; - wind.mV[VW] = avatarp->mWindVec.mV[VW]; - - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); - F32 phase = -1.f * (avatarp->mRipplePhase); - - F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); - LLVector4 sin_params(freq, freq, freq, phase); - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); - - LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); - gravity = gravity * rot_mat; - sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); - } + LLVector4 wind; + wind.setVec(avatarp->mWindVec); + wind.mV[VW] = 0; + wind = wind * rot_mat; + wind.mV[VW] = avatarp->mWindVec.mV[VW]; + + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); + F32 phase = -1.f * (avatarp->mRipplePhase); + + F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); + LLVector4 sin_params(freq, freq, freq, phase); + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); + + LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); + gravity = gravity * rot_mat; + sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); + } - if( !single_avatar || (avatarp == single_avatar) ) - { - avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); + if( !single_avatar || (avatarp == single_avatar) ) + { + avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); + } } } -} void LLDrawPoolAvatar::getRiggedGeometry(LLFace* face, LLPointer& buffer, U32 data_mask, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face) { diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 4c99e65c99..aab4d93882 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2934,6 +2934,63 @@ bool enable_object_unmute() } } + +// 0 = normal, 1 = always, 2 = never +class LLAvatarCheckImposterMode : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); + if (!object) return false; + + LLVOAvatar* avatar = find_avatar_from_object(object); + if (!avatar) return false; + + U32 mode = userdata.asInteger(); + switch (mode) + { + case 0: + return (avatar->getVisualMuteSettings() == LLVOAvatar::VISUAL_MUTE_NOT_SET); + case 1: + return (avatar->getVisualMuteSettings() == LLVOAvatar::ALWAYS_VISUAL_MUTE); + case 2: + return (avatar->getVisualMuteSettings() == LLVOAvatar::NEVER_VISUAL_MUTE); + default: + return false; + } + } // handleEvent() +}; + +// 0 = normal, 1 = always, 2 = never +class LLAvatarSetImposterMode : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); + if (!object) return false; + + LLVOAvatar* avatar = find_avatar_from_object(object); + if (!avatar) return false; + + U32 mode = userdata.asInteger(); + switch (mode) + { + case 0: + avatar->setVisualMuteSettings(LLVOAvatar::VISUAL_MUTE_NOT_SET); + return true; + case 1: + avatar->setVisualMuteSettings(LLVOAvatar::VISUAL_MUTE_NOT_SET); + return true; + case 2: + avatar->setVisualMuteSettings(LLVOAvatar::NEVER_VISUAL_MUTE); + return true; + default: + return false; + } + } // handleEvent() +}; + + class LLObjectMute : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -8644,6 +8701,8 @@ void initialize_menus() view_listener_t::addMenu( new LLCheckPanelPeopleTab(), "SideTray.CheckPanelPeopleTab"); // Avatar pie menu + view_listener_t::addMenu(new LLAvatarCheckImposterMode(), "Avatar.CheckImposterMode"); + view_listener_t::addMenu(new LLAvatarSetImposterMode(), "Avatar.SetImposterMode"); view_listener_t::addMenu(new LLObjectMute(), "Avatar.Mute"); view_listener_t::addMenu(new LLAvatarAddFriend(), "Avatar.AddFriend"); view_listener_t::addMenu(new LLAvatarAddContact(), "Avatar.AddContact"); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 7d099d690a..cce4925e0a 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -62,6 +62,7 @@ #include "llhudmanager.h" #include "llhudnametag.h" #include "llhudtext.h" // for mText/mDebugText +#include "llimview.h" #include "llinitparam.h" #include "llkeyframefallmotion.h" #include "llkeyframestandmotion.h" @@ -784,6 +785,13 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mLastPelvisToFoot = 0.0f; mPelvisFixup = 0.0f; mLastPelvisFixup = 0.0f; + + mCachedVisualMute = !isSelf(); + mCachedVisualMuteUpdateTime = LLFrameTimer::getTotalSeconds() + 5.0; + mVisuallyMuteSetting = VISUAL_MUTE_NOT_SET; + + F32 color_value = (F32) (getID().mData[0]); + mMutedAVColor = calcMutedAVColor(color_value, 0, 256); } std::string LLVOAvatar::avString() const @@ -3435,24 +3443,82 @@ void LLVOAvatar::slamPosition() mRoot.updateWorldMatrixChildren(); } -bool LLVOAvatar::isVisuallyMuted() const +bool LLVOAvatar::isVisuallyMuted() { - bool ret = false; + bool muted = false; + + // Priority order (highest priority first) + // * own avatar is never visually muted + // * if on the "always draw normally" list, draw them normally + // * if on the "always visually mute" list, mute them + // * draw them normally if they meet the following criteria: + // - within the closest N avatars OR on friends list OR in an IM chat + // - AND aren't over the thresholds + // * otherwise visually mute all other avatars if (!isSelf()) { + static LLCachedControl render_mute_enabled(gSavedSettings, "RenderAutoMuteEnabled"); static LLCachedControl max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit"); static LLCachedControl max_attachment_area(gSavedSettings, "RenderAutoMuteSurfaceAreaLimit"); static LLCachedControl max_render_cost(gSavedSettings, "RenderAutoMuteRenderCostLimit"); - - U32 max_cost = (U32) (max_render_cost*(LLVOAvatar::sLODFactor+0.5)); + static LLCachedControl visibility_rank(gSavedSettings, "RenderAutoMuteVisibilityRank"); + + if (mVisuallyMuteSetting == ALWAYS_VISUAL_MUTE) + { // Always want to see this AV as an imposter + muted = true; + } + else if (mVisuallyMuteSetting == NEVER_VISUAL_MUTE) + { // Never show as imposter + muted = false; + } + else if (render_mute_enabled) + { + F64 now = LLFrameTimer::getTotalSeconds(); + + if (now < mCachedVisualMuteUpdateTime) + { // Use cached mute value + muted = mCachedVisualMute; + } + else + { // Determine if visually muted or not + + U32 max_cost = (U32) (max_render_cost*(LLVOAvatar::sLODFactor+0.5)); - ret = LLMuteList::getInstance()->isMuted(getID()) || - (mAttachmentSurfaceArea > max_attachment_area && max_attachment_area > 0.f) || - (mVisualComplexity > max_cost && max_render_cost > 0); + muted = LLMuteList::getInstance()->isMuted(getID()) || + (mAttachmentGeometryBytes > max_attachment_bytes && max_attachment_bytes > 0) || + (mAttachmentSurfaceArea > max_attachment_area && max_attachment_area > 0.f) || + (mVisualComplexity > max_cost && max_render_cost > 0); + + // Could be part of the grand || collection above, but yanked out to make the logic visible + if (!muted) + { + if (visibility_rank > 0) + { // They are above the visibilty rank - mute them + muted = (mVisibilityRank > visibility_rank); + } + + if (muted || // Don't mute friends or IMs + visibility_rank == 0) + { + muted = !(LLAvatarTracker::instance().isBuddy(getID())); + if (muted) + { // Not a friend, so they are muted ... are they in an IM? + LLUUID session_id = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL,getID()); + muted = !gIMMgr->hasSession(session_id); + } + } + } + + // Save visual mute state and set interval for updating + const F64 SECONDS_BETWEEN_RENDER_AUTO_MUTE_UPDATES = 1.5; + mCachedVisualMuteUpdateTime = now + SECONDS_BETWEEN_RENDER_AUTO_MUTE_UPDATES; + mCachedVisualMute = muted; + } + } } - return ret; + return muted; } //------------------------------------------------------------------------ @@ -3509,7 +3575,8 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) // the rest should only be done occasionally for far away avatars //-------------------------------------------------------------------- - if (visible && (!isSelf() || isVisuallyMuted()) && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter) + bool visually_muted = isVisuallyMuted(); + if (visible && (!isSelf() || visually_muted) && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter) { const LLVector4a* ext = mDrawable->getSpatialExtents(); LLVector4a size; @@ -3518,8 +3585,8 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) F32 impostor_area = 256.f*512.f*(8.125f - LLVOAvatar::sLODFactor*8.f); - if (isVisuallyMuted()) - { // muted avatars update at 16 hz + if (visually_muted) + { // visually muted avatars update at 16 hz mUpdatePeriod = 16; } else if (mVisibilityRank <= LLVOAvatar::sMaxVisible || @@ -4295,23 +4362,23 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) BOOL first_pass = TRUE; if (!LLDrawPoolAvatar::sSkipOpaque) { - bool muted = isVisuallyMuted(); + bool visually_muted = isVisuallyMuted(); if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender) { - if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy || muted) + if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy || visually_muted) { num_indices += mMeshLOD[MESH_ID_HEAD]->render(mAdjustedPixelArea, TRUE, mIsDummy); first_pass = FALSE; } } - if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy || muted) + if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy || visually_muted) { num_indices += mMeshLOD[MESH_ID_UPPER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); first_pass = FALSE; } - if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy || muted) + if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy || visually_muted) { num_indices += mMeshLOD[MESH_ID_LOWER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); first_pass = FALSE; @@ -8396,7 +8463,7 @@ void LLVOAvatar::updateImpostors() LLCharacter::sAllowInstancesChange = TRUE ; } -BOOL LLVOAvatar::isImpostor() const +BOOL LLVOAvatar::isImpostor() { return sUseImpostors && (isVisuallyMuted() || (mUpdatePeriod >= IMPOSTOR_PERIOD)) ? TRUE : FALSE; } @@ -8441,15 +8508,13 @@ void LLVOAvatar::getImpostorValues(LLVector4a* extents, LLVector3& angle, F32& d angle.mV[2] = da; } + void LLVOAvatar::idleUpdateRenderCost() { static LLCachedControl max_render_cost(gSavedSettings, "RenderAutoMuteRenderCostLimit"); - static const U32 ARC_BODY_PART_COST = 200; static const U32 ARC_LIMIT = 20000; - static std::set all_textures; - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_ATTACHMENT_BYTES)) { //set debug text to attachment geometry bytes here so render cost will override setDebugText(llformat("%.1f KB, %.2f m^2", mAttachmentGeometryBytes/1024.f, mAttachmentSurfaceArea)); @@ -8460,6 +8525,69 @@ void LLVOAvatar::idleUpdateRenderCost() return; } + calculateUpdateRenderCost(); // Update mVisualComplexity if needed + + doRenderCostNagging(max_render_cost); // Remind the user their AV is too complex + + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHAME)) + { + std::string viz_string = LLVOAvatar::rezStatusToString(getRezzedStatus()); + setDebugText(llformat("%s %d", viz_string.c_str(), mVisualComplexity)); + F32 green = 1.f-llclamp(((F32) mVisualComplexity-(F32)ARC_LIMIT)/(F32)ARC_LIMIT, 0.f, 1.f); + F32 red = llmin((F32) mVisualComplexity/(F32)ARC_LIMIT, 1.f); + mText->setColor(LLColor4(red,green,0,1)); + } +} + + +// Remind the user about their expensive avatar +void LLVOAvatar::doRenderCostNagging(U32 max_render_cost) +{ + if (isSelf()) + { + static S32 sOldComplexity = 0; + static F64 sLastRenderCostNagTime = 0.0; + + const F64 RENDER_NAG_INTERVAL = 60.0; + + F64 now = LLFrameTimer::getTotalSeconds(); + if (sLastRenderCostNagTime > 0.0 && + (now - sLastRenderCostNagTime) > RENDER_NAG_INTERVAL && + sOldComplexity != mVisualComplexity) + { + sOldComplexity = mVisualComplexity; + + if (max_render_cost > 0) + { //pop up notification that you have exceeded a render cost limit + if (mVisualComplexity > max_render_cost+max_render_cost/2) + { + LLNotificationsUtil::add("ExceededHighDetailRenderCost"); + sLastRenderCostNagTime = now; + } + else if (mVisualComplexity > max_render_cost) + { + LLNotificationsUtil::add("ExceededMidDetailRenderCost"); + sLastRenderCostNagTime = now; + } + else if (mVisualComplexity > max_render_cost/2) + { + LLNotificationsUtil::add("ExceededLowDetailRenderCost"); + sLastRenderCostNagTime = now; + } + } + } + } +} + + +// Calculations for mVisualComplexity value +void LLVOAvatar::calculateUpdateRenderCost() +{ + static const U32 ARC_BODY_PART_COST = 200; + + // Diagnostic list of all textures on our avatar + static std::set all_textures; + if (mVisualComplexityStale) { mVisualComplexityStale = FALSE; @@ -8526,8 +8654,6 @@ void LLVOAvatar::idleUpdateRenderCost() } - - // Diagnostic output to identify all avatar-related textures. // Does not affect rendering cost calculation. // Could be wrapped in a debug option if output becomes problematic. @@ -8568,34 +8694,37 @@ void LLVOAvatar::idleUpdateRenderCost() } } - if (isSelf() && max_render_cost > 0 && mVisualComplexity != cost) - { //pop up notification that you have exceeded a render cost limit - if (cost > max_render_cost+max_render_cost/2) - { - LLNotificationsUtil::add("ExceededHighDetailRenderCost"); - } - else if (cost > max_render_cost) - { - LLNotificationsUtil::add("ExceededMidDetailRenderCost"); - } - else if (cost > max_render_cost/2) - { - LLNotificationsUtil::add("ExceededLowDetailRenderCost"); - } - } - mVisualComplexity = cost; } +} - - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHAME)) - { - std::string viz_string = LLVOAvatar::rezStatusToString(getRezzedStatus()); - setDebugText(llformat("%s %d", viz_string.c_str(), mVisualComplexity)); - F32 green = 1.f-llclamp(((F32) mVisualComplexity-(F32)ARC_LIMIT)/(F32)ARC_LIMIT, 0.f, 1.f); - F32 red = llmin((F32) mVisualComplexity/(F32)ARC_LIMIT, 1.f); - mText->setColor(LLColor4(red,green,0,1)); - } + +// static +LLColor4 LLVOAvatar::calcMutedAVColor(F32 value, S32 range_low, S32 range_high) +{ + F32 clamped_value = llmin(value, (F32) range_high); + clamped_value = llmax(value, (F32) range_low); + F32 spectrum = (clamped_value / range_high); // spectrum is between 0 and 1.f + + // Array of colors. These are arranged so only one RGB color changes between each step, + // and it loops back to red so there is an even distribution. It is not a heat map + const S32 NUM_SPECTRUM_COLORS = 7; + static LLColor4 * spectrum_color[NUM_SPECTRUM_COLORS] = { &LLColor4::red, &LLColor4::magenta, &LLColor4::blue, &LLColor4::cyan, &LLColor4::green, &LLColor4::yellow, &LLColor4::red }; + + spectrum = spectrum * (NUM_SPECTRUM_COLORS - 1); // Scale to range of number of colors + S32 spectrum_index_1 = floor(spectrum); // Desired color will be after this index + S32 spectrum_index_2 = spectrum_index_1 + 1; // and before this index (inclusive) + F32 fractBetween = spectrum - (F32)(spectrum_index_1); // distance between the two indexes (0-1) + + LLColor4 new_color = lerp(*spectrum_color[spectrum_index_1], *spectrum_color[spectrum_index_2], fractBetween); + //new_color.normalize(); + + //llinfos << "From value " << std::setprecision(3) << value << " returning color " << new_color + // << " using indexes " << spectrum_index_1 << ", " << spectrum_index_2 + // << " and fractBetween " << fractBetween + // << llendl; + + return new_color; } // static diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 386d9d7746..0e7bf7a6c9 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -253,7 +253,14 @@ public: static void invalidateNameTags(); void addNameTagLine(const std::string& line, const LLColor4& color, S32 style, const LLFontGL* font); void idleUpdateRenderCost(); + void doRenderCostNagging(U32 max_render_cost); + void calculateUpdateRenderCost(); void updateVisualComplexity() { mVisualComplexityStale = TRUE; } + + S32 getVisualComplexity() { return mVisualComplexity; }; + S32 getUpdatePeriod() { return mUpdatePeriod; }; + const LLColor4 & getMutedAVColor() { return mMutedAVColor; }; + void idleUpdateBelowWater(); //-------------------------------------------------------------------- @@ -304,11 +311,14 @@ public: return mPhases; } + static LLColor4 calcMutedAVColor(F32 value, S32 range_low, S32 range_high); + protected: BOOL updateIsFullyLoaded(); BOOL processFullyLoadedChange(bool loading); void updateRuthTimer(bool loading); F32 calcMorphAmount(); + private: BOOL mFirstFullyVisible; BOOL mFullyLoaded; @@ -317,6 +327,7 @@ private: S32 mFullyLoadedFrameCounter; S32 mVisualComplexity; BOOL mVisualComplexityStale; + LLColor4 mMutedAVColor; LLFrameTimer mFullyLoadedTimer; LLFrameTimer mRuthTimer; @@ -437,7 +448,16 @@ private: public: U32 renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0); - bool isVisuallyMuted() const; + bool isVisuallyMuted(); + + enum VisualMuteSettings + { + VISUAL_MUTE_NOT_SET = 0, + ALWAYS_VISUAL_MUTE = 1, + NEVER_VISUAL_MUTE = 2 + }; + void setVisualMuteSettings(VisualMuteSettings set) { mVisuallyMuteSetting = set; }; + VisualMuteSettings getVisualMuteSettings() { return mVisuallyMuteSetting; }; U32 renderRigid(); U32 renderSkinned(EAvatarRenderPass pass); @@ -461,6 +481,11 @@ private: S32 mUpdatePeriod; S32 mNumInitFaces; //number of faces generated when creating the avatar drawable, does not inculde splitted faces due to long vertex buffer. + bool mCachedVisualMute; // cached return value for isVisuallyMuted() + F64 mCachedVisualMuteUpdateTime; // Time to update mCachedVisualMute + + VisualMuteSettings mVisuallyMuteSetting; // Always or never visually mute this AV + //-------------------------------------------------------------------- // Morph masks //-------------------------------------------------------------------- @@ -493,7 +518,7 @@ private: // Impostors //-------------------------------------------------------------------- public: - BOOL isImpostor() const; + BOOL isImpostor(); BOOL needsImpostorUpdate() const; const LLVector3& getImpostorOffset() const; const LLVector2& getImpostorDim() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index df7a3c7593..61e42bbcee 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2862,7 +2862,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera) llassert(vobj); // trying to catch a bad assumption if (vobj) // this test may not be needed, see above { - const LLVOAvatar* av = vobj->asAvatar(); + LLVOAvatar* av = vobj->asAvatar(); if (av && av->isImpostor()) { return; @@ -10103,11 +10103,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) assertInitialized(); - bool muted = avatar->isVisuallyMuted(); + bool visually_muted = avatar->isVisuallyMuted(); pushRenderTypeMask(); - if (muted) + if (visually_muted) { andRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES); } @@ -10251,7 +10251,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) F32 old_alpha = LLDrawPoolAvatar::sMinimumAlpha; - if (muted) + if (visually_muted) { //disable alpha masking for muted avatars (get whole skin silhouette) LLDrawPoolAvatar::sMinimumAlpha = 0.f; } @@ -10282,7 +10282,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) LLGLDisable blend(GL_BLEND); - if (muted) + if (visually_muted) { gGL.setColorMask(true, true); @@ -10317,8 +10317,8 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) gGL.diffuseColor4ub(64,64,64,255); } else - { //blue visually muted avatar - gGL.diffuseColor4ub(72,61,139,255); + { // Visually muted avatar + gGL.diffuseColor4fv( avatar->getMutedAVColor().mV ); } { diff --git a/indra/newview/skins/default/xui/en/menu_attachment_other.xml b/indra/newview/skins/default/xui/en/menu_attachment_other.xml index 00d4b1dab1..87fa7c3f00 100644 --- a/indra/newview/skins/default/xui/en/menu_attachment_other.xml +++ b/indra/newview/skins/default/xui/en/menu_attachment_other.xml @@ -104,8 +104,43 @@ + + + + + + + + + + + + + + + + + + - @@ -95,8 +97,43 @@ + + + + + + + + + + + + + + + + + + + + + Date: Wed, 20 Mar 2013 15:25:41 -0700 Subject: Don't assert on HTTP_NOT_FOUND for some mesh data. Reviewed by Kelly --- indra/newview/llmeshrepository.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 7a857ea7be..809f85a7b5 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2177,7 +2177,7 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason, // and (somewhat more optional than the others) retries // again after some set period of time - llassert(status == HTTP_SERVICE_UNAVAILABLE || status == HTTP_REQUEST_TIME_OUT || status == HTTP_INTERNAL_ERROR); + llassert(status == HTTP_NOT_FOUND || status == HTTP_SERVICE_UNAVAILABLE || status == HTTP_REQUEST_TIME_OUT || status == HTTP_INTERNAL_ERROR); if (status == HTTP_SERVICE_UNAVAILABLE || status == HTTP_REQUEST_TIME_OUT || status == HTTP_INTERNAL_ERROR) { //retry -- cgit v1.2.3 From c9bdc734fd9d48de263999226c49b557d5c5af81 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 22 Mar 2013 11:29:32 -0700 Subject: MAINT-2518 : Viewer LLViewerTextureList::removeImageFromList() shouldn't crash Reviewed by Kelly. --- indra/newview/llviewertexturelist.cpp | 60 ++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 18 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 82d990cf97..466d75233b 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -515,15 +515,17 @@ void LLViewerTextureList::addImageToList(LLViewerFetchedTexture *image) llassert_always(mInitialized) ; llassert(image); if (image->isInImageList()) - { - llerrs << "LLViewerTextureList::addImageToList - Image already in list" << llendl; + { // Flag is already set? + llwarns << "LLViewerTextureList::addImageToList - image " << image->getID() << " already in list" << llendl; } - if((mImageList.insert(image)).second != true) + else { - llerrs << "Error happens when insert image to mImageList!" << llendl ; + if((mImageList.insert(image)).second != true) + { + llwarns << "Error happens when insert image " << image->getID() << " into mImageList!" << llendl ; + } + image->setInImageList(TRUE) ; } - - image->setInImageList(TRUE) ; } void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image) @@ -531,24 +533,46 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image) assert_main_thread(); llassert_always(mInitialized) ; llassert(image); - if (!image->isInImageList()) + + S32 count = 0; + if (image->isInImageList()) { - llinfos << "RefCount: " << image->getNumRefs() << llendl ; + count = mImageList.erase(image) ; + if(count != 1) + { + llwarns << "Image " << image->getID() + << " had mInImageList set but mImageList.erase() returned " << count + << llendl; + } + } + else + { // Something is wrong, image is expected in list or callers should check first + llwarns << "Calling removeImageFromList() for " << image->getID() + << " but doesn't have mInImageList set" + << " ref count is " << image->getNumRefs() + << llendl; uuid_map_t::iterator iter = mUUIDMap.find(image->getID()); - if(iter == mUUIDMap.end() || iter->second != image) + if(iter == mUUIDMap.end()) + { + llwarns << "Image " << image->getID() << " is also not in mUUIDMap!" << llendl ; + } + else if (iter->second != image) + { + llwarns << "Image " << image->getID() << " was in mUUIDMap but with different pointer" << llendl ; + } + else { - llinfos << "Image is not in mUUIDMap!" << llendl ; + llwarns << "Image " << image->getID() << " was in mUUIDMap with same pointer" << llendl ; + } + count = mImageList.erase(image) ; + if(count != 0) + { // it was in the list already? + llwarns << "Image " << image->getID() + << " had mInImageList false but mImageList.erase() returned " << count + << llendl; } - llerrs << "LLViewerTextureList::removeImageFromList - Image not in list" << llendl; } - S32 count = mImageList.erase(image) ; - if(count != 1) - { - llinfos << image->getID() << llendl ; - llerrs << "Error happens when remove image from mImageList: " << count << llendl ; - } - image->setInImageList(FALSE) ; } -- cgit v1.2.3 From fcf894af255e8b931af09883aa8ee2a900199d39 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 22 Mar 2013 13:13:09 -0700 Subject: Lighten imposter avatar colors a bit per feedeback. --- indra/newview/llvoavatar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index cce4925e0a..76df6dc0ed 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -8717,7 +8717,8 @@ LLColor4 LLVOAvatar::calcMutedAVColor(F32 value, S32 range_low, S32 range_high) F32 fractBetween = spectrum - (F32)(spectrum_index_1); // distance between the two indexes (0-1) LLColor4 new_color = lerp(*spectrum_color[spectrum_index_1], *spectrum_color[spectrum_index_2], fractBetween); - //new_color.normalize(); + new_color.normalize(); + new_color *= 0.9f; //llinfos << "From value " << std::setprecision(3) << value << " returning color " << new_color // << " using indexes " << spectrum_index_1 << ", " << spectrum_index_2 -- cgit v1.2.3 From 395f8baf03622f3a36b03b8e31679e3b594b1757 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 22 Mar 2013 14:03:39 -0700 Subject: Fix simple bug in LLAvatarSetImposterMode::handleEvent() --- indra/newview/llviewermenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index aab4d93882..2d18600540 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2979,7 +2979,7 @@ class LLAvatarSetImposterMode : public view_listener_t avatar->setVisualMuteSettings(LLVOAvatar::VISUAL_MUTE_NOT_SET); return true; case 1: - avatar->setVisualMuteSettings(LLVOAvatar::VISUAL_MUTE_NOT_SET); + avatar->setVisualMuteSettings(LLVOAvatar::ALWAYS_VISUAL_MUTE); return true; case 2: avatar->setVisualMuteSettings(LLVOAvatar::NEVER_VISUAL_MUTE); -- cgit v1.2.3 From e1d133d73f93f52193397c5fe9cbfa532f4359ed Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 22 Mar 2013 16:54:21 -0700 Subject: MAINT-1452 : Viewer floods the log file with hundreds of exactly the same lines. Reviewed by Kelly --- indra/newview/llvovolume.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index e0ed13a3a7..426ad8bc21 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1157,28 +1157,38 @@ void LLVOVolume::sculpt() S32 current_discard = getVolume()->getSculptLevel() ; if(current_discard < -2) { - static S32 low_sculpty_discard_warning_count = 100; - if (++low_sculpty_discard_warning_count >= 100) - { // Log first time, then every 100 afterwards otherwise this can flood the logs + static S32 low_sculpty_discard_warning_count = 1; + S32 exponent = llmax(1, llfloor( log10((F64) low_sculpty_discard_warning_count) )); + S32 interval = pow(10.0, exponent); + if ( low_sculpty_discard_warning_count < 10 || + (low_sculpty_discard_warning_count % interval) == 0) + { // Log first 10 time, then decreasing intervals afterwards otherwise this can flood the logs llwarns << "WARNING!!: Current discard for sculpty " << mSculptTexture->getID() << " at " << current_discard - << " is less than -2." << llendl; - low_sculpty_discard_warning_count = 0; + << " is less than -2." + << " Hit this " << low_sculpty_discard_warning_count << " times" + << llendl; } + low_sculpty_discard_warning_count++; // corrupted volume... don't update the sculpty return; } else if (current_discard > MAX_DISCARD_LEVEL) { - static S32 high_sculpty_discard_warning_count = 100; - if (++high_sculpty_discard_warning_count >= 100) - { // Log first time, then every 100 afterwards otherwise this can flood the logs + static S32 high_sculpty_discard_warning_count = 1; + S32 exponent = llmax(1, llfloor( log10((F64) high_sculpty_discard_warning_count) )); + S32 interval = pow(10.0, exponent); + if ( high_sculpty_discard_warning_count < 10 || + (high_sculpty_discard_warning_count % interval) == 0) + { // Log first 10 time, then decreasing intervals afterwards otherwise this can flood the logs llwarns << "WARNING!!: Current discard for sculpty " << mSculptTexture->getID() << " at " << current_discard - << " is more than than allowed max of " << MAX_DISCARD_LEVEL << llendl; - high_sculpty_discard_warning_count = 0; + << " is more than than allowed max of " << MAX_DISCARD_LEVEL + << ". Hit this " << high_sculpty_discard_warning_count << " times" + << llendl; } + high_sculpty_discard_warning_count++; // corrupted volume... don't update the sculpty return; -- cgit v1.2.3 From 6bb7fd40d0fdc7902f1ac9db06a479121c177d0d Mon Sep 17 00:00:00 2001 From: Maestro Linden Date: Tue, 26 Mar 2013 21:25:10 +0000 Subject: MAINT-2507 Added syntax highlighting for new particle system settings (from MAINT-2410). Reviewed by Kelly. --- indra/newview/app_settings/keywords.ini | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra') diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 56b549ab62..ef0f78d4d4 100644 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -131,6 +131,7 @@ PSYS_PART_FOLLOW_VELOCITY_MASK PSYS_PART_TARGET_POS_MASK PSYS_PART_EMISSIVE_MASK PSYS_PART_TARGET_LINEAR_MASK +PSYS_PART_RIBBON_MASK PSYS_SRC_PATTERN PSYS_SRC_INNERANGLE Deprecated -- Use PSYS_SRC_ANGLE_BEGIN @@ -147,12 +148,24 @@ PSYS_SRC_ACCEL PSYS_SRC_TEXTURE PSYS_SRC_TARGET_KEY PSYS_SRC_OMEGA +PSYS_PART_BLEND_FUNC_SOURCE +PSYS_PART_BLEND_FUNC_DEST +PSYS_PART_START_GLOW +PSYS_PART_END_GLOW PSYS_SRC_PATTERN_DROP PSYS_SRC_PATTERN_EXPLODE PSYS_SRC_PATTERN_ANGLE PSYS_SRC_PATTERN_ANGLE_CONE PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY +PSYS_PART_BF_ONE +PSYS_PART_BF_ZERO +PSYS_PART_BF_DEST_COLOR +PSYS_PART_BF_SOURCE_COLOR +PSYS_PART_BF_ONE_MINUS_DEST_COLOR +PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR +PSYS_PART_BF_SOURCE_ALPHA +PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA OBJECT_UNKNOWN_DETAIL Returned by llGetObjectDetails when passed an invalid object parameter type OBJECT_NAME Used with llGetObjectDetails to get an object's name -- cgit v1.2.3 From d8dc74b83349752768d99b77c92a284955ee04e4 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 28 Mar 2013 16:06:07 -0700 Subject: MAINT-2426 : Viewer support for new simulator AvatarRenderInfo capability. Reviewed by Kelly --- indra/newview/CMakeLists.txt | 2 + indra/newview/llappviewer.cpp | 4 + indra/newview/llavatarrenderinfoaccountant.cpp | 360 +++++++++++++++++++++++++ indra/newview/llavatarrenderinfoaccountant.h | 54 ++++ indra/newview/llspatialpartition.cpp | 2 + indra/newview/llviewerregion.cpp | 5 + indra/newview/llviewerregion.h | 4 + indra/newview/llvoavatar.cpp | 3 + indra/newview/llvoavatar.h | 23 +- indra/newview/llvovolume.cpp | 2 + 10 files changed, 455 insertions(+), 4 deletions(-) create mode 100644 indra/newview/llavatarrenderinfoaccountant.cpp create mode 100644 indra/newview/llavatarrenderinfoaccountant.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index bd0169fb2f..cb96dfeb48 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -113,6 +113,7 @@ set(viewer_SOURCE_FILES llavatariconctrl.cpp llavatarlist.cpp llavatarlistitem.cpp + llavatarrenderinfoaccountant.cpp llavatarpropertiesprocessor.cpp llblockedlistitem.cpp llblocklist.cpp @@ -702,6 +703,7 @@ set(viewer_HEADER_FILES llavatarlist.h llavatarlistitem.h llavatarpropertiesprocessor.h + llavatarrenderinfoaccountant.h llblockedlistitem.h llblocklist.h llbox.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 4745157c8b..7404d2d228 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -97,6 +97,7 @@ #include "llupdaterservice.h" #include "llfloatertexturefetchdebugger.h" #include "llspellcheck.h" +#include "llavatarrenderinfoaccountant.h" // Linden library includes #include "llavatarnamecache.h" @@ -4587,6 +4588,9 @@ void LLAppViewer::idle() gObjectList.updateApparentAngles(gAgent); } + // Update AV render info + LLAvatarRenderInfoAccountant::idle(); + { LLFastTimer t(FTM_AUDIO_UPDATE); diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp new file mode 100644 index 0000000000..04a79f7d4c --- /dev/null +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -0,0 +1,360 @@ +/** + * @file llavatarrenderinfoaccountant.cpp + * @author Dave Simmons + * @date 2013-02-28 + * @brief + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, 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$ + */ + +// Precompiled header +#include "llviewerprecompiledheaders.h" +// associated header +#include "llavatarrenderinfoaccountant.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "llcharacter.h" +#include "llhttpclient.h" +#include "lltimer.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" +#include "llvoavatar.h" +#include "llworld.h" + + +// Use this for debugging +//#define LL_AVATAR_RENDER_INFO_LOG_SPAM + +static const std::string KEY_AGENTS = "agents"; // map +static const std::string KEY_WEIGHT = "weight"; // integer +static const std::string KEY_GEOMETRY = "geometry"; // integer +static const std::string KEY_SURFACE = "surface"; // float + +static const std::string KEY_IDENTIFIER = "identifier"; +static const std::string KEY_MESSAGE = "message"; +static const std::string KEY_ERROR = "error"; + + +// Send data updates about once per minute, only need per-frame resolution +LLFrameTimer LLAvatarRenderInfoAccountant::sRenderInfoReportTimer; + + +// HTTP responder class for GET request for avatar render weight information +class LLAvatarRenderInfoGetResponder : public LLHTTPClient::Responder +{ +public: + LLAvatarRenderInfoGetResponder(U64 region_handle) : mRegionHandle(region_handle) + { + } + + virtual void error(U32 statusNum, const std::string& reason) + { + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); + if (regionp) + { + llwarns << "HTTP error result for avatar weight GET: " << statusNum + << ", " << reason + << " returned by region " << regionp->getName() + << llendl; + } + else + { + llwarns << "Avatar render weight GET error recieved but region not found for " + << mRegionHandle + << ", error " << statusNum + << ", " << reason + << llendl; + } + + } + + virtual void result(const LLSD& content) + { + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); + if (regionp) + { + #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM + llinfos << "Result for avatar weights request for region " << regionp->getName() << ":" << llendl; + #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + + if (content.isMap()) + { + if (content.has(KEY_AGENTS)) + { + const LLSD & agents = content[KEY_AGENTS]; + if (agents.isMap()) + { + LLSD::map_const_iterator report_iter = agents.beginMap(); + while (report_iter != agents.endMap()) + { + LLUUID target_agent_id = LLUUID(report_iter->first); + const LLSD & agent_info_map = report_iter->second; + LLViewerObject* avatarp = gObjectList.findObject(target_agent_id); + if (avatarp && + avatarp->isAvatar() && + agent_info_map.isMap()) + { // Extract the data for this avatar + + #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM + llinfos << " Agent " << target_agent_id + << ": " << agent_info_map << llendl; + #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + + if (agent_info_map.has(KEY_WEIGHT)) + { + ((LLVOAvatar *) avatarp)->setReportedVisualComplexity(agent_info_map[KEY_WEIGHT].asInteger()); + } + if (agent_info_map.has(KEY_GEOMETRY)) + { + ((LLVOAvatar *) avatarp)->setReportedAttachmentGeometryBytes(agent_info_map[KEY_GEOMETRY].asInteger()); + } + if (agent_info_map.has(KEY_SURFACE)) + { + ((LLVOAvatar *) avatarp)->setReportedAttachmentSurfaceArea((F32) agent_info_map[KEY_SURFACE].asReal()); + } + } + report_iter++; + } + } + } // has "agents" + else if (content.has(KEY_ERROR)) + { + const LLSD & error = content[KEY_ERROR]; + llwarns << "Avatar render info GET error: " + << error[KEY_IDENTIFIER] + << ": " << error[KEY_MESSAGE] + << " from region " << regionp->getName() + << llendl; + } + } + } + else + { + llinfos << "Avatar render weight info recieved but region not found for " + << mRegionHandle << llendl; + } + } + +private: + U64 mRegionHandle; +}; + + +// HTTP responder class for POST request for avatar render weight information +class LLAvatarRenderInfoPostResponder : public LLHTTPClient::Responder +{ +public: + LLAvatarRenderInfoPostResponder(U64 region_handle) : mRegionHandle(region_handle) + { + } + + virtual void error(U32 statusNum, const std::string& reason) + { + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); + if (regionp) + { + llwarns << "HTTP error result for avatar weight POST: " << statusNum + << ", " << reason + << " returned by region " << regionp->getName() + << llendl; + } + else + { + llwarns << "Avatar render weight POST error recieved but region not found for " + << mRegionHandle + << ", error " << statusNum + << ", " << reason + << llendl; + } + } + + virtual void result(const LLSD& content) + { + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); + if (regionp) + { + #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM + llinfos << "Result for avatar weights POST for region " << regionp->getName() + << ": " << content << llendl; + #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + + if (content.isMap()) + { + if (content.has(KEY_ERROR)) + { + const LLSD & error = content[KEY_ERROR]; + llwarns << "Avatar render info POST error: " + << error[KEY_IDENTIFIER] + << ": " << error[KEY_MESSAGE] + << " from region " << regionp->getName() + << llendl; + } + } + } + else + { + llinfos << "Avatar render weight POST result recieved but region not found for " + << mRegionHandle << llendl; + } + } + +private: + U64 mRegionHandle; +}; + + +// static +// Send request for one region, no timer checks +void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regionp) +{ + std::string url = regionp->getCapability("AvatarRenderInfo"); + if (!url.empty()) + { + #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM + llinfos << "Sending avatar render info to region " + << regionp->getName() + << " from " << url + << llendl; + #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + + // Build the render info to POST to the region + LLSD report = LLSD::emptyMap(); + LLSD agents = LLSD::emptyMap(); + + std::vector::iterator iter = LLCharacter::sInstances.begin(); + while( iter != LLCharacter::sInstances.end() ) + { + LLVOAvatar* avatar = dynamic_cast(*iter); + if (avatar && + avatar->getRezzedStatus() == 2 && // Fully rezzed + !avatar->isDead() && // Not dead yet + avatar->getObjectHost() == regionp->getHost()) // Ensure it's on the same region + { + avatar->calculateUpdateRenderCost(); // Make sure the numbers are up-to-date + + LLSD info = LLSD::emptyMap(); + if (avatar->getVisualComplexity() > 0) + { + info[KEY_WEIGHT] = avatar->getVisualComplexity(); + } + if (avatar->getAttachmentGeometryBytes() > 0) + { + info[KEY_GEOMETRY] = (S32) avatar->getAttachmentGeometryBytes(); + } + if (avatar->getAttachmentSurfaceArea() > 0.f) + { + info[KEY_SURFACE] = avatar->getAttachmentSurfaceArea(); + } + if (info.size() > 0) + { + agents[avatar->getID().asString()] = info; + } + + #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM + llinfos << "Sending avatar render info for " << avatar->getID() + << ": " << info << llendl; + #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + } + iter++; + } + + report[KEY_AGENTS] = agents; + if (agents.size() > 0) + { + LLHTTPClient::post(url, report, new LLAvatarRenderInfoPostResponder(regionp->getHandle())); + } + } +} + + + + +// static +// Send request for one region, no timer checks +void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regionp) +{ + std::string url = regionp->getCapability("AvatarRenderInfo"); + if (!url.empty()) + { + #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM + llinfos << "Requesting avatar render info for region " + << regionp->getName() + << " from " << url + << llendl; + #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + + // First send a request to get the latest data + LLHTTPClient::get(url, new LLAvatarRenderInfoGetResponder(regionp->getHandle())); + } +} + + +// static +// Called every frame - send render weight requests to every region +void LLAvatarRenderInfoAccountant::idle() +{ + if (sRenderInfoReportTimer.hasExpired()) + { + const F32 SECS_BETWEEN_REGION_SCANS = 5.f; // Scan the region list every 5 seconds + const F32 SECS_BETWEEN_REGION_REQUEST = 60.0; // Update each region every 60 seconds + + S32 num_avs = LLCharacter::sInstances.size(); + + // Check all regions and see if it's time to fetch/send data + for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); + iter != LLWorld::getInstance()->getRegionList().end(); ++iter) + { + LLViewerRegion* regionp = *iter; + if (regionp && + regionp->isAlive() && + regionp->capabilitiesReceived() && // Region has capability URLs available + regionp->getRenderInfoRequestTimer().hasExpired()) // Time to make request + { + sendRenderInfoToRegion(regionp); + getRenderInfoFromRegion(regionp); + + // Reset this regions timer, moving to longer intervals if there are lots of avatars around + regionp->getRenderInfoRequestTimer().resetWithExpiry(SECS_BETWEEN_REGION_REQUEST + (2.f * num_avs)); + } + } + + // We scanned all the regions, reset the request timer. + sRenderInfoReportTimer.resetWithExpiry(SECS_BETWEEN_REGION_SCANS); + } +} + + +// static +// Make sRenderInfoReportTimer expire so the next call to idle() will scan and query a new region +// called via LLViewerRegion::setCapabilitiesReceived() boost signals when the capabilities +// are returned for a new LLViewerRegion, and is the earliest time to get render info +void LLAvatarRenderInfoAccountant::expireRenderInfoReportTimer() +{ + #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM + llinfos << "Viewer has new region capabilities" << llendl; + #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + + sRenderInfoReportTimer.resetWithExpiry(0.f); +} + diff --git a/indra/newview/llavatarrenderinfoaccountant.h b/indra/newview/llavatarrenderinfoaccountant.h new file mode 100644 index 0000000000..5b4a4d3db2 --- /dev/null +++ b/indra/newview/llavatarrenderinfoaccountant.h @@ -0,0 +1,54 @@ +/** + * @file llavatarrenderinfoaccountant.h + * @author Dave Simmons + * @date 2013-02-28 + * @brief + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, 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$ + */ + +#if ! defined(LL_llavatarrenderinfoaccountant_H) +#define LL_llavatarrenderinfoaccountant_H + +class LLViewerRegion; + +// Class to gather avatar rendering information +// that is sent to or fetched from regions. +class LLAvatarRenderInfoAccountant +{ +public: + LLAvatarRenderInfoAccountant() {}; + ~LLAvatarRenderInfoAccountant() {}; + + static void sendRenderInfoToRegion(LLViewerRegion * regionp); + static void getRenderInfoFromRegion(LLViewerRegion * regionp); + + static void expireRenderInfoReportTimer(); + + static void idle(); + +private: + // Send data updates about once per minute, only need per-frame resolution + static LLFrameTimer sRenderInfoReportTimer; +}; + +#endif /* ! defined(LL_llavatarrenderinfoaccountant_H) */ diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 759e1a7b4c..1d30b19308 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1404,7 +1404,9 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node) if (bridge->mAvatar.notNull()) { bridge->mAvatar->mAttachmentGeometryBytes -= mGeometryBytes; + bridge->mAvatar->mAttachmentGeometryBytes = llmax(bridge->mAvatar->mAttachmentGeometryBytes, 0); bridge->mAvatar->mAttachmentSurfaceArea -= mSurfaceArea; + bridge->mAvatar->mAttachmentSurfaceArea = llmax(bridge->mAvatar->mAttachmentSurfaceArea, 0.f); } } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index e4234a538d..eb5a0b8d37 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -44,6 +44,7 @@ #include "llagent.h" #include "llagentcamera.h" +#include "llavatarrenderinfoaccountant.h" #include "llcallingcard.h" #include "llcaphttpsender.h" #include "llcapabilitylistener.h" @@ -333,6 +334,9 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mImpl->mObjectPartition.push_back(new LLBridgePartition()); //PARTITION_BRIDGE mImpl->mObjectPartition.push_back(new LLHUDParticlePartition());//PARTITION_HUD_PARTICLE mImpl->mObjectPartition.push_back(NULL); //PARTITION_NONE + + mRenderInfoRequestTimer.resetWithExpiry(0.f); // Set timer to be expired + setCapabilitiesReceivedCallback(boost::bind(&LLAvatarRenderInfoAccountant::expireRenderInfoReportTimer)); } @@ -1514,6 +1518,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("AgentState"); capabilityNames.append("AttachmentResources"); capabilityNames.append("AvatarPickerSearch"); + capabilityNames.append("AvatarRenderInfo"); capabilityNames.append("CharacterProperties"); capabilityNames.append("ChatSessionRequest"); capabilityNames.append("CopyInventoryFromNotecard"); diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index c9fffaf30e..2d3a622e42 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -365,6 +365,8 @@ public: LLDynamicArray mMapAvatars; LLDynamicArray mMapAvatarIDs; + LLFrameTimer & getRenderInfoRequestTimer() { return mRenderInfoRequestTimer; }; + private: LLViewerRegionImpl * mImpl; @@ -421,6 +423,8 @@ private: BOOL mReleaseNotesRequested; LLSD mSimulatorFeatures; + + LLFrameTimer mRenderInfoRequestTimer; }; inline BOOL LLViewerRegion::getAllowDamage() const diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 9e5d44eb1f..1fc20fd207 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -662,6 +662,9 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mSpecialRenderMode(0), mAttachmentGeometryBytes(0), mAttachmentSurfaceArea(0.f), + mReportedVisualComplexity(-1), + mReportedAttachmentGeometryBytes(-1), + mReportedAttachmentSurfaceArea(-1.f), mTurning(FALSE), mPelvisToFoot(0.f), mLastSkeletonSerialNum( 0 ), diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 0e7bf7a6c9..495d3e9483 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -257,9 +257,20 @@ public: void calculateUpdateRenderCost(); void updateVisualComplexity() { mVisualComplexityStale = TRUE; } - S32 getVisualComplexity() { return mVisualComplexity; }; - S32 getUpdatePeriod() { return mUpdatePeriod; }; - const LLColor4 & getMutedAVColor() { return mMutedAVColor; }; + S32 getVisualComplexity() { return mVisualComplexity; }; // Numbers calculated here by rendering AV + S32 getAttachmentGeometryBytes() { return mAttachmentGeometryBytes; }; // number of bytes in attached geometry + F32 getAttachmentSurfaceArea() { return mAttachmentSurfaceArea; }; // estimated surface area of attachments + + S32 getReportedVisualComplexity() { return mReportedVisualComplexity; }; // Numbers as reported by the SL server + void setReportedVisualComplexity(S32 value) { mReportedVisualComplexity = value; }; + S32 getReportedAttachmentGeometryBytes() { return mReportedAttachmentGeometryBytes; }; //number of bytes in attached geometry + void setReportedAttachmentGeometryBytes(S32 value) { mReportedAttachmentGeometryBytes = value; }; + F32 getReportedAttachmentSurfaceArea() { return mReportedAttachmentSurfaceArea; }; //estimated surface area of attachments + void setReportedAttachmentSurfaceArea(F32 value) { mReportedAttachmentSurfaceArea = value; }; + + S32 getUpdatePeriod() { return mUpdatePeriod; }; + const LLColor4 & getMutedAVColor() { return mMutedAVColor; }; + void idleUpdateBelowWater(); @@ -469,9 +480,13 @@ public: static void restoreGL(); BOOL mIsDummy; // for special views S32 mSpecialRenderMode; // special lighting - U32 mAttachmentGeometryBytes; //number of bytes in attached geometry + S32 mAttachmentGeometryBytes; //number of bytes in attached geometry F32 mAttachmentSurfaceArea; //estimated surface area of attachments + S32 mReportedVisualComplexity; // Numbers as reported by the SL server + S32 mReportedAttachmentGeometryBytes; //number of bytes in attached geometry + F32 mReportedAttachmentSurfaceArea; //estimated surface area of attachments + private: bool shouldAlphaMask(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 426ad8bc21..71ee2da216 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4242,7 +4242,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (pAvatarVO) { pAvatarVO->mAttachmentGeometryBytes -= group->mGeometryBytes; + pAvatarVO->mAttachmentGeometryBytes = llmax(pAvatarVO->mAttachmentGeometryBytes, 0); pAvatarVO->mAttachmentSurfaceArea -= group->mSurfaceArea; + pAvatarVO->mAttachmentSurfaceArea = llmax(pAvatarVO->mAttachmentSurfaceArea, 0.f); } group->mGeometryBytes = 0; -- cgit v1.2.3 From bdf8cacc4cd216d7df8212177587a21979d2a883 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 1 Apr 2013 14:35:12 -0700 Subject: MAINT-2511 : Mesh requests not handling time outs. Reviewed by Kelly --- indra/newview/llmeshrepository.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 809f85a7b5..5154809240 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -288,7 +288,14 @@ public: ~LLMeshSkinInfoResponder() { - //llassert(mProcessed); this will assert due to a timeout (not handled?) MAINT-2511 + if (!LLApp::isQuitting() && + !mProcessed && + mMeshID.notNull()) + { // Something went wrong, retry + llwarns << "Timeout or service unavailable, retrying loadMeshSkinInfo() for " << mMeshID << llendl; + LLMeshRepository::sHTTPRetryCount++; + gMeshRepo.mThread->loadMeshSkinInfo(mMeshID); + } } virtual void completedRaw(U32 status, const std::string& reason, @@ -313,7 +320,14 @@ public: ~LLMeshDecompositionResponder() { - //llassert(mProcessed); this will assert due to a timeout (not handled?) MAINT-2511 + if (!LLApp::isQuitting() && + !mProcessed && + mMeshID.notNull()) + { // Something went wrong, retry + llwarns << "Timeout or service unavailable, retrying loadMeshDecomposition() for " << mMeshID << llendl; + LLMeshRepository::sHTTPRetryCount++; + gMeshRepo.mThread->loadMeshDecomposition(mMeshID); + } } virtual void completedRaw(U32 status, const std::string& reason, @@ -338,7 +352,14 @@ public: ~LLMeshPhysicsShapeResponder() { - //llassert(mProcessed); this will assert due to a timeout (not handled?) MAINT-2511 + if (!LLApp::isQuitting() && + !mProcessed && + mMeshID.notNull()) + { // Something went wrong, retry + llwarns << "Timeout or service unavailable, retrying loadMeshPhysicsShape() for " << mMeshID << llendl; + LLMeshRepository::sHTTPRetryCount++; + gMeshRepo.mThread->loadMeshPhysicsShape(mMeshID); + } } virtual void completedRaw(U32 status, const std::string& reason, @@ -1984,7 +2005,7 @@ void LLMeshSkinInfoResponder::completedRaw(U32 status, const std::string& reason { if (status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE) { //timeout or service unavailable, try again - llwarns << "Timeout or service unavailable, retrying." << llendl; + llwarns << "Timeout or service unavailable, retrying loadMeshSkinInfo() for " << mMeshID << llendl; LLMeshRepository::sHTTPRetryCount++; gMeshRepo.mThread->loadMeshSkinInfo(mMeshID); } @@ -2047,7 +2068,7 @@ void LLMeshDecompositionResponder::completedRaw(U32 status, const std::string& r { if (status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE) { //timeout or service unavailable, try again - llwarns << "Timeout or service unavailable, retrying." << llendl; + llwarns << "Timeout or service unavailable, retrying loadMeshDecomposition() for " << mMeshID << llendl; LLMeshRepository::sHTTPRetryCount++; gMeshRepo.mThread->loadMeshDecomposition(mMeshID); } @@ -2111,7 +2132,7 @@ void LLMeshPhysicsShapeResponder::completedRaw(U32 status, const std::string& re { if (status == HTTP_INTERNAL_ERROR || status == HTTP_SERVICE_UNAVAILABLE) { //timeout or service unavailable, try again - llwarns << "Timeout or service unavailable, retrying." << llendl; + llwarns << "Timeout or service unavailable, retrying loadMeshPhysicsShape() for " << mMeshID << llendl; LLMeshRepository::sHTTPRetryCount++; gMeshRepo.mThread->loadMeshPhysicsShape(mMeshID); } -- cgit v1.2.3 From 15e2f76615581341a861ed0e37da96170e2aee61 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 3 Apr 2013 16:26:11 -0700 Subject: MAINT-2558 - Add viewer debug setting for more logging on avatar render info. Reviewed by Kelly --- indra/newview/app_settings/settings.xml | 11 ++++ indra/newview/llavatarrenderinfoaccountant.cpp | 77 +++++++++++++++----------- indra/newview/llavatarrenderinfoaccountant.h | 2 + 3 files changed, 57 insertions(+), 33 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 384e83a2a0..4c6940500e 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9400,6 +9400,17 @@ Value 0 + RenderAutoMuteLogging + + Comment + Show extra information in viewer logs about avatar rendering costs + Persist + 1 + Type + Boolean + Value + 0 + RenderAutoMuteVisibilityRank Comment diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 04a79f7d4c..54144677f4 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -37,15 +37,13 @@ #include "llcharacter.h" #include "llhttpclient.h" #include "lltimer.h" +#include "llviewercontrol.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llvoavatar.h" #include "llworld.h" -// Use this for debugging -//#define LL_AVATAR_RENDER_INFO_LOG_SPAM - static const std::string KEY_AGENTS = "agents"; // map static const std::string KEY_WEIGHT = "weight"; // integer static const std::string KEY_GEOMETRY = "geometry"; // integer @@ -94,9 +92,10 @@ public: LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); if (regionp) { - #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM - llinfos << "Result for avatar weights request for region " << regionp->getName() << ":" << llendl; - #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + llinfos << "Result for avatar weights request for region " << regionp->getName() << ":" << llendl; + } if (content.isMap()) { @@ -116,10 +115,11 @@ public: agent_info_map.isMap()) { // Extract the data for this avatar - #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM - llinfos << " Agent " << target_agent_id - << ": " << agent_info_map << llendl; - #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + llinfos << " Agent " << target_agent_id + << ": " << agent_info_map << llendl; + } if (agent_info_map.has(KEY_WEIGHT)) { @@ -194,10 +194,11 @@ public: LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); if (regionp) { - #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM - llinfos << "Result for avatar weights POST for region " << regionp->getName() - << ": " << content << llendl; - #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + llinfos << "Result for avatar weights POST for region " << regionp->getName() + << ": " << content << llendl; + } if (content.isMap()) { @@ -231,12 +232,13 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio std::string url = regionp->getCapability("AvatarRenderInfo"); if (!url.empty()) { - #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM - llinfos << "Sending avatar render info to region " - << regionp->getName() - << " from " << url - << llendl; - #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + if (logRenderInfo()) + { + llinfos << "Sending avatar render info to region " + << regionp->getName() + << " from " << url + << llendl; + } // Build the render info to POST to the region LLSD report = LLSD::emptyMap(); @@ -271,10 +273,11 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio agents[avatar->getID().asString()] = info; } - #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM - llinfos << "Sending avatar render info for " << avatar->getID() - << ": " << info << llendl; - #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + if (logRenderInfo()) + { + llinfos << "Sending avatar render info for " << avatar->getID() + << ": " << info << llendl; + } } iter++; } @@ -297,12 +300,13 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi std::string url = regionp->getCapability("AvatarRenderInfo"); if (!url.empty()) { - #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM - llinfos << "Requesting avatar render info for region " - << regionp->getName() - << " from " << url - << llendl; - #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + if (logRenderInfo()) + { + llinfos << "Requesting avatar render info for region " + << regionp->getName() + << " from " << url + << llendl; + } // First send a request to get the latest data LLHTTPClient::get(url, new LLAvatarRenderInfoGetResponder(regionp->getHandle())); @@ -351,10 +355,17 @@ void LLAvatarRenderInfoAccountant::idle() // are returned for a new LLViewerRegion, and is the earliest time to get render info void LLAvatarRenderInfoAccountant::expireRenderInfoReportTimer() { - #ifdef LL_AVATAR_RENDER_INFO_LOG_SPAM - llinfos << "Viewer has new region capabilities" << llendl; - #endif // LL_AVATAR_RENDER_INFO_LOG_SPAM + if (logRenderInfo()) + { + llinfos << "Viewer has new region capabilities" << llendl; + } sRenderInfoReportTimer.resetWithExpiry(0.f); } +// static +bool LLAvatarRenderInfoAccountant::logRenderInfo() +{ + static LLCachedControl render_mute_logging_enabled(gSavedSettings, "RenderAutoMuteLogging"); + return render_mute_logging_enabled; +} diff --git a/indra/newview/llavatarrenderinfoaccountant.h b/indra/newview/llavatarrenderinfoaccountant.h index 5b4a4d3db2..97dd9f0ad3 100644 --- a/indra/newview/llavatarrenderinfoaccountant.h +++ b/indra/newview/llavatarrenderinfoaccountant.h @@ -46,6 +46,8 @@ public: static void idle(); + static bool logRenderInfo(); + private: // Send data updates about once per minute, only need per-frame resolution static LLFrameTimer sRenderInfoReportTimer; -- cgit v1.2.3 From 1d3f018e812daf5fb7834258940b13a2239106b4 Mon Sep 17 00:00:00 2001 From: callum_linden Date: Tue, 9 Apr 2013 17:04:57 -0700 Subject: MAINT-2417 FIX Update Graphics tab layout --- indra/newview/llfloaterpreference.cpp | 29 ++++--- indra/newview/llfloaterpreference.h | 3 +- .../default/xui/en/panel_preferences_graphics1.xml | 96 +++++++++++++++++++--- 3 files changed, 105 insertions(+), 23 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index a28af2101b..cdfaab88eb 100755 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -337,7 +337,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.HardwareDefaults", boost::bind(&LLFloaterPreference::setHardwareDefaults, this)); mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreference::onVertexShaderEnable, this)); mCommitCallbackRegistrar.add("Pref.WindowedMod", boost::bind(&LLFloaterPreference::onCommitWindowedMode, this)); - mCommitCallbackRegistrar.add("Pref.UpdateSliderText", boost::bind(&LLFloaterPreference::onUpdateSliderText,this, _1,_2)); + mCommitCallbackRegistrar.add("Pref.UpdateSliderText", boost::bind(&LLFloaterPreference::refreshUI,this)); mCommitCallbackRegistrar.add("Pref.QualityPerformance", boost::bind(&LLFloaterPreference::onChangeQuality, this, _2)); mCommitCallbackRegistrar.add("Pref.applyUIColor", boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2)); mCommitCallbackRegistrar.add("Pref.getUIColor", boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2)); @@ -1147,6 +1147,8 @@ void LLFloaterPreference::refreshEnabledState() //Deferred/SSAO/Shadows LLCheckBoxCtrl* ctrl_deferred = getChild("UseLightShaders"); + LLCheckBoxCtrl* ctrl_deferred2 = getChild("UseLightShaders2"); + BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && shaders && @@ -1155,11 +1157,13 @@ void LLFloaterPreference::refreshEnabledState() (ctrl_wind_light->get()) ? TRUE : FALSE; ctrl_deferred->setEnabled(enabled); - + ctrl_deferred2->setEnabled(enabled); + LLCheckBoxCtrl* ctrl_ssao = getChild("UseSSAO"); LLCheckBoxCtrl* ctrl_dof = getChild("UseDoF"); LLComboBox* ctrl_shadow = getChild("ShadowDetail"); + // note, okay here to get from ctrl_deferred as it's twin, ctrl_deferred2 will alway match it enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE); ctrl_ssao->setEnabled(enabled); @@ -1185,6 +1189,7 @@ void LLFloaterPreference::disableUnavailableSettings() LLCheckBoxCtrl* ctrl_wind_light = getChild("WindLightUseAtmosShaders"); LLCheckBoxCtrl* ctrl_avatar_impostors = getChild("AvatarImpostors"); LLCheckBoxCtrl* ctrl_deferred = getChild("UseLightShaders"); + LLCheckBoxCtrl* ctrl_deferred2 = getChild("UseLightShaders2"); LLComboBox* ctrl_shadows = getChild("ShadowDetail"); LLCheckBoxCtrl* ctrl_ssao = getChild("UseSSAO"); LLCheckBoxCtrl* ctrl_dof = getChild("UseDoF"); @@ -1218,6 +1223,8 @@ void LLFloaterPreference::disableUnavailableSettings() ctrl_deferred->setEnabled(FALSE); ctrl_deferred->setValue(FALSE); + ctrl_deferred2->setEnabled(FALSE); + ctrl_deferred2->setValue(FALSE); } // disabled windlight @@ -1238,6 +1245,8 @@ void LLFloaterPreference::disableUnavailableSettings() ctrl_deferred->setEnabled(FALSE); ctrl_deferred->setValue(FALSE); + ctrl_deferred2->setEnabled(FALSE); + ctrl_deferred2->setValue(FALSE); } // disabled deferred @@ -1255,6 +1264,8 @@ void LLFloaterPreference::disableUnavailableSettings() ctrl_deferred->setEnabled(FALSE); ctrl_deferred->setValue(FALSE); + ctrl_deferred2->setEnabled(FALSE); + ctrl_deferred2->setValue(FALSE); } // disabled deferred SSAO @@ -1299,6 +1310,8 @@ void LLFloaterPreference::disableUnavailableSettings() ctrl_deferred->setEnabled(FALSE); ctrl_deferred->setValue(FALSE); + ctrl_deferred2->setEnabled(FALSE); + ctrl_deferred2->setValue(FALSE); } // disabled cloth @@ -1327,6 +1340,7 @@ void LLFloaterPreference::refresh() updateSliderText(getChild("FlexibleMeshDetail", true), getChild("FlexibleMeshDetailText", true)); updateSliderText(getChild("TreeMeshDetail", true), getChild("TreeMeshDetailText", true)); updateSliderText(getChild("AvatarMeshDetail", true), getChild("AvatarMeshDetailText", true)); + updateSliderText(getChild("AvatarMeshDetail2", true), getChild("AvatarMeshDetailText2", true)); updateSliderText(getChild("AvatarPhysicsDetail", true), getChild("AvatarPhysicsDetailText", true)); updateSliderText(getChild("TerrainMeshDetail", true), getChild("TerrainMeshDetailText", true)); updateSliderText(getChild("RenderPostProcess", true), getChild("PostProcessText", true)); @@ -1578,16 +1592,9 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im getChildView("chat_font_size")->setEnabled(TRUE); } -void LLFloaterPreference::onUpdateSliderText(LLUICtrl* ctrl, const LLSD& name) +void LLFloaterPreference::refreshUI() { - std::string ctrl_name = name.asString(); - - if ((ctrl_name =="" )|| !hasChild(ctrl_name, true)) - return; - - LLTextBox* text_box = getChild(name.asString()); - LLSliderCtrl* slider = dynamic_cast(ctrl); - updateSliderText(slider, text_box); + refresh(); } void LLFloaterPreference::updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box) diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 22e80a21cb..cb180f6f1e 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -154,8 +154,7 @@ public: void onChangeQuality(const LLSD& data); void updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box); - void onUpdateSliderText(LLUICtrl* ctrl, const LLSD& name); -// void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator); + void refreshUI(); void onCommitParcelMediaAutoPlayEnable(); void onCommitMediaEnabled(); diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml index 4ed95f0758..7abc67494f 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml @@ -177,10 +177,86 @@ width="80"> Ultra + + + + + Low + + + + m + + + + + width="256" /> Date: Thu, 11 Apr 2013 13:27:11 -0700 Subject: Clean up transfer manager code and log messages. Reviewed by Kelly --- indra/llmessage/lltransfermanager.cpp | 60 +++++++++++++++++++++-------------- indra/llmessage/lltransfermanager.h | 4 +-- 2 files changed, 39 insertions(+), 25 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/lltransfermanager.cpp b/indra/llmessage/lltransfermanager.cpp index 034680caf8..38b743fb75 100644 --- a/indra/llmessage/lltransfermanager.cpp +++ b/indra/llmessage/lltransfermanager.cpp @@ -606,16 +606,21 @@ void LLTransferManager::processTransferAbort(LLMessageSystem *msgp, void **) void LLTransferManager::reliablePacketCallback(void **user_data, S32 result) { LLUUID *transfer_idp = (LLUUID *)user_data; - if (result) + if (result && + transfer_idp != NULL) { - llwarns << "Aborting reliable transfer " << *transfer_idp << " due to failed reliable resends!" << llendl; LLTransferSource *tsp = gTransferManager.findTransferSource(*transfer_idp); if (tsp) { + llwarns << "Aborting reliable transfer " << *transfer_idp << " due to failed reliable resends!" << llendl; LLTransferSourceChannel *tscp = tsp->mChannelp; tsp->abortTransfer(); tscp->deleteTransfer(tsp); } + else + { + llwarns << "Aborting reliable transfer " << *transfer_idp << " but can't find the LLTransferSource object" << llendl; + } } delete transfer_idp; } @@ -892,22 +897,26 @@ LLTransferSource *LLTransferSourceChannel::findTransferSource(const LLUUID &tran } -BOOL LLTransferSourceChannel::deleteTransfer(LLTransferSource *tsp) +void LLTransferSourceChannel::deleteTransfer(LLTransferSource *tsp) { - - LLPriQueueMap::pqm_iter iter; - for (iter = mTransferSources.mMap.begin(); iter != mTransferSources.mMap.end(); iter++) + if (tsp) { - if (iter->second == tsp) + LLPriQueueMap::pqm_iter iter; + for (iter = mTransferSources.mMap.begin(); iter != mTransferSources.mMap.end(); iter++) { - delete tsp; - mTransferSources.mMap.erase(iter); - return TRUE; + if (iter->second == tsp) + { + delete tsp; + mTransferSources.mMap.erase(iter); + return; + } } - } - llerrs << "Unable to find transfer source to delete!" << llendl; - return FALSE; + llwarns << "Unable to find transfer source id " + << tsp->getID() + << " to delete!" + << llendl; + } } @@ -1008,21 +1017,26 @@ LLTransferTarget *LLTransferTargetChannel::findTransferTarget(const LLUUID &tran } -BOOL LLTransferTargetChannel::deleteTransfer(LLTransferTarget *ttp) +void LLTransferTargetChannel::deleteTransfer(LLTransferTarget *ttp) { - tt_iter iter; - for (iter = mTransferTargets.begin(); iter != mTransferTargets.end(); iter++) + if (ttp) { - if (*iter == ttp) + tt_iter iter; + for (iter = mTransferTargets.begin(); iter != mTransferTargets.end(); iter++) { - delete ttp; - mTransferTargets.erase(iter); - return TRUE; + if (*iter == ttp) + { + delete ttp; + mTransferTargets.erase(iter); + return; + } } - } - llerrs << "Unable to find transfer target to delete!" << llendl; - return FALSE; + llwarns << "Unable to find transfer target id " + << ttp->getID() + << " to delete!" + << llendl; + } } diff --git a/indra/llmessage/lltransfermanager.h b/indra/llmessage/lltransfermanager.h index 252e05d1d1..6aad153c24 100644 --- a/indra/llmessage/lltransfermanager.h +++ b/indra/llmessage/lltransfermanager.h @@ -199,7 +199,7 @@ public: void addTransferSource(LLTransferSource *sourcep); LLTransferSource *findTransferSource(const LLUUID &transfer_id); - BOOL deleteTransfer(LLTransferSource *tsp); + void deleteTransfer(LLTransferSource *tsp); void setThrottleID(const S32 throttle_id) { mThrottleID = throttle_id; } @@ -232,7 +232,7 @@ public: const F32 priority); LLTransferTarget *findTransferTarget(const LLUUID &transfer_id); - BOOL deleteTransfer(LLTransferTarget *ttp); + void deleteTransfer(LLTransferTarget *ttp); LLTransferChannelType getChannelType() const { return mChannelType; } -- cgit v1.2.3 From cd8cd8c265abb0c568ee7b925551023c8081c298 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 12 Apr 2013 09:26:59 -0700 Subject: Fix merge oddities --- indra/llui/llkeywords.cpp | 1 - indra/llui/lllayoutstack.cpp | 1 - indra/llui/lltoolbar.cpp | 1 - indra/lscript/lscript_execute/lscript_readlso.cpp | 2 -- 4 files changed, 5 deletions(-) (limited to 'indra') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 5f9dbb33ad..26d27d1f34 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -367,7 +367,6 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLW const llwchar* base = wtext.c_str(); const llwchar* cur = base; - (void)line; while( *cur ) { if( *cur == '\n' || cur == base ) diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 7115ad496a..dff98f33b9 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -476,7 +476,6 @@ void LLLayoutStack::createResizeBar(LLLayoutPanel* panelp) if (lp->mResizeBar == NULL) { LLResizeBar::Side side = (mOrientation == HORIZONTAL) ? LLResizeBar::RIGHT : LLResizeBar::BOTTOM; - (void)resize_bar_rect; LLResizeBar::Params resize_params; resize_params.name("resize"); resize_params.resizing_view(lp); diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 5d0ac9eeb4..3d9f5cbbc2 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -838,7 +838,6 @@ void LLToolBar::draw() if (mDragAndDropTarget && !mButtonCommands.empty()) { LLRect caret_rect = caret->getRect(); - (void)toolbar_rect; if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { caret->setRect(LLRect(mDragx-caret_rect.getWidth()/2+1, diff --git a/indra/lscript/lscript_execute/lscript_readlso.cpp b/indra/lscript/lscript_execute/lscript_readlso.cpp index c88b43ed83..6384a57100 100644 --- a/indra/lscript/lscript_execute/lscript_readlso.cpp +++ b/indra/lscript/lscript_execute/lscript_readlso.cpp @@ -145,7 +145,6 @@ void LLScriptLSOParse::printGlobals(LLFILE *fp) // get offset to skip past name varoffset = global_v_offset; bytestream2integer(mRawData, global_v_offset); - (void)offset; //hush little compiler // get typeexport type = *(mRawData + global_v_offset++); @@ -355,7 +354,6 @@ void LLScriptLSOParse::printStates(LLFILE *fp) { temp_end = bytestream2integer(mRawData, read_ahead); bytestream2integer(mRawData, read_ahead); - (void)dummy; if ( (temp_end < opcode_end) &&(temp_end > event_offset)) { -- cgit v1.2.3 From 569b75bae934e89bfe872e6d8994a850c0051475 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 15 Apr 2013 11:56:15 -0700 Subject: MAINT-2595 - Viewer spams log at startup with caps issue. Reviewed by Kelly --- indra/newview/llvoicevivox.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 9b5d981aa5..ac35bd4287 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -532,25 +532,25 @@ void LLVivoxVoiceClient::requestVoiceAccountProvision(S32 retries) { LLViewerRegion *region = gAgent.getRegion(); - if ( region && (mVoiceEnabled || !mIsInitialized)) + // If we've not received the capability yet, return. + // the password will remain empty, so we'll remain in + // stateIdle + if ( region && + region->capabilitiesReceived() && + (mVoiceEnabled || !mIsInitialized)) { std::string url = region->getCapability("ProvisionVoiceAccountRequest"); - if ( url.empty() ) + if ( !url.empty() ) { - // we've not received the capability yet, so return. - // the password will remain empty, so we'll remain in - // stateIdle - return; - } + LLHTTPClient::post( + url, + LLSD(), + new LLVivoxVoiceAccountProvisionResponder(retries)); - LLHTTPClient::post( - url, - LLSD(), - new LLVivoxVoiceAccountProvisionResponder(retries)); - - setState(stateConnectorStart); + setState(stateConnectorStart); + } } } -- cgit v1.2.3 From c6991c9c75ff125654b68992c61a3c17c39bf5c5 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 15 Apr 2013 13:51:18 -0700 Subject: MAINT-2598 : Viewer logs warning about VoiceServiceConnectionStateChangedEvent --- indra/newview/llvoicevivox.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index ac35bd4287..abead02174 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -7660,6 +7660,9 @@ void LLVivoxProtocolParser::processResponse(std::string tag) */ // We don't need to process this, but we also shouldn't warn on it, since that confuses people. } + else if (!stricmp(eventTypeCstr, "VoiceServiceConnectionStateChangedEvent")) + { // Yet another ignored event + } else { LL_WARNS("VivoxProtocolParser") << "Unknown event type " << eventTypeString << LL_ENDL; -- cgit v1.2.3 From 205938b652bc9218494835afadce095b29f1d19d Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 15 Apr 2013 16:27:13 -0700 Subject: Fix crash introduced by LLInstanceTrackerBase optimization. Reviewed by Kelly --- indra/llcommon/llinstancetracker.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 65ef4322f6..89430f82d7 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -32,7 +32,9 @@ // external library headers // other Linden headers -static void* sInstanceTrackerData[ kInstanceTrackTypeCount ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static bool sInstanceTrackerData_initialized = false; +static void* sInstanceTrackerData[ kInstanceTrackTypeCount ]; + void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t) { @@ -41,6 +43,15 @@ void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t) // the pair and returns a std::pair of (iterator, true). If the specified // key DOES exist, insert() simply returns (iterator, false). One lookup // handles both cases. + if (!sInstanceTrackerData_initialized) + { + for (S32 i = 0; i < (S32) kInstanceTrackTypeCount; i++) + { + sInstanceTrackerData[i] = NULL; + } + sInstanceTrackerData_initialized = true; + } + return sInstanceTrackerData[t]; } -- cgit v1.2.3 From 98f438656b3f4ae8a0b6fbd6327cfff3ef243545 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 15 Apr 2013 16:29:14 -0700 Subject: MAINT-2548 : Add debug viewer render info for AV metrics. Reviewed by Kelly --- indra/newview/app_settings/settings.xml | 11 ++++++ indra/newview/llviewerwindow.cpp | 43 ++++++++++++++++++++-- indra/newview/skins/default/xui/en/menu_viewer.xml | 10 +++++ 3 files changed, 61 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c7895fbd99..75c38ad62f 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2136,6 +2136,17 @@ Value 0 + DebugShowAvatarRenderInfo + + Comment + Show avatar render cost information + Persist + 1 + Type + Boolean + Value + 0 + DebugShowColor Comment diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index b3bb584881..bb71707db6 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -332,9 +332,10 @@ public: mTextColor = LLColor4( 0.86f, 0.86f, 0.86f, 1.f ); // Draw stuff growing up from right lower corner of screen - U32 xpos = mWindow->getWorldViewWidthScaled() - 350; - U32 ypos = 64; - const U32 y_inc = 20; + S32 xpos = mWindow->getWorldViewWidthScaled() - 400; + xpos = llmax(xpos, 0); + S32 ypos = 64; + const S32 y_inc = 20; clearText(); @@ -634,6 +635,42 @@ public: LLVertexBuffer::sSetCount = LLImageGL::sUniqueCount = gPipeline.mNumVisibleNodes = LLPipeline::sVisibleLightCount = 0; } + if (gSavedSettings.getBOOL("DebugShowAvatarRenderInfo")) + { + std::map sorted_avs; + + std::vector::iterator sort_iter = LLCharacter::sInstances.begin(); + while (sort_iter != LLCharacter::sInstances.end()) + { + LLVOAvatar* avatar = dynamic_cast(*sort_iter); + if (avatar && + !avatar->isDead()) // Not dead yet + { + // Stuff into a sorted map so the display is ordered + sorted_avs[avatar->getFullname()] = avatar; + } + sort_iter++; + } + + std::string trunc_name; + std::map::reverse_iterator av_iter = sorted_avs.rbegin(); // Put "A" at the top + while (av_iter != sorted_avs.rend()) + { + LLVOAvatar* avatar = av_iter->second; + + avatar->calculateUpdateRenderCost(); // Make sure the numbers are up-to-date + + trunc_name = utf8str_truncate(avatar->getFullname(), 16); + addText(xpos, ypos, llformat("%s : rez %d, weight %d, bytes %d area %.2f", + trunc_name.c_str(), + avatar->getRezzedStatus(), + avatar->getVisualComplexity(), + avatar->getAttachmentGeometryBytes(), + avatar->getAttachmentSurfaceArea())); + ypos += y_inc; + av_iter++; + } + } if (gSavedSettings.getBOOL("DebugShowRenderMatrices")) { addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLProjection[12], gGLProjection[13], gGLProjection[14], gGLProjection[15])); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 1197f1ce1f..f66272aa2e 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2205,6 +2205,16 @@ + + + + Date: Wed, 17 Apr 2013 11:17:46 -0700 Subject: Some minor cleanups while hunting crashes. Reviewed by Kelly --- indra/llcommon/llcommon.cpp | 1 + indra/llcommon/llinstancetracker.h | 8 +++++++- indra/llcommon/llthread.cpp | 3 ++- indra/llcommon/llthread.h | 2 ++ indra/newview/llflexibleobject.cpp | 5 ++++- indra/newview/llviewerobject.h | 18 ++++++++++-------- 6 files changed, 26 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index 8be9e4f4de..b938b0e65a 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -44,6 +44,7 @@ void LLCommon::initClass() } LLTimer::initClass(); LLThreadSafeRefCount::initThreadSafeRefCount(); + assert_main_thread(); // Make sure we record the main thread // LLWorkerThread::initClass(); // LLFrameCallbackManager::initClass(); } diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 0f952f56ac..b290526754 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -102,6 +102,8 @@ protected: }; }; +LL_COMMON_API void assert_main_thread(); + /// This mix-in class adds support for tracking all instances of the specified class parameter T /// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup /// If KEY is not provided, then instances are stored in a simple set @@ -116,7 +118,11 @@ class LLInstanceTracker : public LLInstanceTrackerBase InstanceMap sMap; }; static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } - static InstanceMap& getMap_() { return getStatic().sMap; } + static InstanceMap& getMap_() + { + // assert_main_thread(); fwiw this class is not thread safe, and it used by multiple threads. Bad things happen. + return getStatic().sMap; + } public: class instance_iter : public boost::iterator_facade diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 6c117f7daf..60adeeaeb7 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -67,7 +67,8 @@ LL_COMMON_API void assert_main_thread() static U32 s_thread_id = LLThread::currentID(); if (LLThread::currentID() != s_thread_id) { - llerrs << "Illegal execution outside main thread." << llendl; + llwarns << "Illegal execution from thread id " << (S32) LLThread::currentID() + << " outside main thread " << (S32) s_thread_id << llendl; } } diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 8c95b1c0e5..11594f276e 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -311,4 +311,6 @@ public: //============================================================================ +extern LL_COMMON_API void assert_main_thread(); + #endif // LL_LLTHREAD_H diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index bf479dc92e..98c0c0bf51 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -294,6 +294,9 @@ void LLVolumeImplFlexible::onSetVolume(const LLVolumeParams &volume_params, cons void LLVolumeImplFlexible::updateRenderRes() { + if (!mAttributes) + return; + LLDrawable* drawablep = mVO->mDrawable; S32 new_res = mAttributes->getSimulateLOD(); @@ -435,7 +438,7 @@ void LLVolumeImplFlexible::doFlexibleUpdate() } } - if(!mInitialized) + if(!mInitialized || !mAttributes) { //the object is not visible return ; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 1b4291a1d1..40e09a4f41 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -112,14 +112,6 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate protected: ~LLViewerObject(); // use unref() - // TomY: Provide for a list of extra parameter structures, mapped by structure name - struct ExtraParameter - { - BOOL in_use; - LLNetworkData *data; - }; - std::map mExtraParameterList; - public: typedef std::list > child_list_t; typedef std::list > vobj_list_t; @@ -545,6 +537,8 @@ public: std::vector mUnselectedChildrenPositions ; private: + // TomY: Provide for a list of extra parameter structures, mapped by structure name + struct ExtraParameter; ExtraParameter* createNewParameterEntry(U16 param_type); ExtraParameter* getExtraParameterEntry(U16 param_type) const; ExtraParameter* getExtraParameterEntryCreate(U16 param_type); @@ -782,6 +776,14 @@ private: LLUUID mAttachmentItemID; // ItemID of the associated object is in user inventory. EObjectUpdateType mLastUpdateType; BOOL mLastUpdateCached; + + // TomY: Provide for a list of extra parameter structures, mapped by structure name + struct ExtraParameter + { + BOOL in_use; + LLNetworkData *data; + }; + std::map mExtraParameterList; }; /////////////////// -- cgit v1.2.3 From 57d88fdccb397257642530b36cbe918df65b41f4 Mon Sep 17 00:00:00 2001 From: Simon Linden Date: Thu, 18 Apr 2013 18:22:57 -0700 Subject: MAINT-2605 : Eliminate LLControlGroup::set warning in log when starting the viewer --- indra/newview/app_settings/settings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 75c38ad62f..8e4bf2a384 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14525,5 +14525,18 @@ Value 0 + + VersionChannelName + + Comment + Version information generated by running the viewer + Persist + 1 + Type + String + Value + + + -- cgit v1.2.3 From b7235f1a4492bf4365d241e239eb49fb3ae8bb3e Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 22 Apr 2013 14:35:07 -0400 Subject: MAINT-2612: Remove no-longer-valid unused-var warning suppressions. Somehow viewer-cat acquired a lot of source lines (in several different files) of the form: (void)somevar; where ?somevar? was not declared. Apparently someone introduced an unused declaration of ?somevar?, encountered unused-variable warnings, introduced the (void) casts to suppress those warnings, then deleted the declarations -- without deleting the (void) casts. It seems worth noting that the resulting code should not have compiled successfully on any platform. --- indra/test/io.cpp | 1 - indra/test/llstreamtools_tut.cpp | 7 ------- indra/test/lltemplatemessagebuilder_tut.cpp | 1 - 3 files changed, 9 deletions(-) (limited to 'indra') diff --git a/indra/test/io.cpp b/indra/test/io.cpp index 62e516accb..47a67deed0 100644 --- a/indra/test/io.cpp +++ b/indra/test/io.cpp @@ -1141,7 +1141,6 @@ namespace tut ensure("Connected to server", connected); lldebugs << "connected" << llendl; pump_loop(mPump,0.1f); - (void)elapsed; count = mPump->runningChains(); ensure_equals("server chain onboard", count, 2); lldebugs << "** Client is connected." << llendl; diff --git a/indra/test/llstreamtools_tut.cpp b/indra/test/llstreamtools_tut.cpp index a9bb15d911..354c3dfe10 100644 --- a/indra/test/llstreamtools_tut.cpp +++ b/indra/test/llstreamtools_tut.cpp @@ -389,13 +389,10 @@ namespace tut is.str(str = " First Second \t \r \n Third Fourth-ShouldThisBePartOfFourth Fifth\n"); actual_result = ""; get_word(actual_result, is); // First - (void)ret; actual_result = ""; get_word(actual_result, is); // Second - (void)ret; actual_result = ""; get_word(actual_result, is); // Third - (void)ret; // the current implementation of get_word seems inconsistent with // skip_to_next_word. skip_to_next_word treats any character other @@ -486,7 +483,6 @@ namespace tut is.str(str = "First Second \t \r\n Third Fourth-ShouldThisBePartOfFourth IsThisFifth\n"); actual_result = ""; get_line(actual_result, is); - (void)ret; expected_result = "First Second \t \r\n"; ensure_equals("get_line: 1", actual_result, expected_result); @@ -551,7 +547,6 @@ namespace tut is.str(str = "Should not skip lone \r.\r\n"); actual_result = ""; get_line(actual_result, is); - (void)ret; expected_result = "Should not skip lone \r.\r\n"; ensure_equals("get_line: carriage return skipped even though not followed by newline", actual_result, expected_result); } @@ -569,7 +564,6 @@ namespace tut is.str(str = "\n"); actual_result = ""; get_line(actual_result, is); - (void)ret; expected_result = "\n"; ensure_equals("get_line: Just newline", actual_result, expected_result); } @@ -588,7 +582,6 @@ namespace tut is.str(str = "First Line.\nSecond Line.\n"); actual_result = ""; get_line(actual_result, is, 255); - (void)ret; expected_result = "First Line.\n"; ensure_equals("get_line: Basic Operation", actual_result, expected_result); diff --git a/indra/test/lltemplatemessagebuilder_tut.cpp b/indra/test/lltemplatemessagebuilder_tut.cpp index 3d3edab102..dde70f98c8 100644 --- a/indra/test/lltemplatemessagebuilder_tut.cpp +++ b/indra/test/lltemplatemessagebuilder_tut.cpp @@ -963,7 +963,6 @@ namespace tut memset(buffer, 0xcc, bufferSize); reader->getString(_PREHASH_Test1, _PREHASH_Test0, bufferSize, outBuffer); - (void)outValue2; ensure_equals("Ensure present value ", outValue, inValue); ensure_equals("Ensure unchanged buffer ", strlen(outBuffer), 0); delete reader; -- cgit v1.2.3 From 4bd3fef6f7018a0092c02aeba61af43265d12ceb Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 22 Apr 2013 13:29:33 -0700 Subject: MAINT-2612 fix issues between extern C linkage and yyval ifdefs on Mac with toolchain > 4.5.1 --- indra/lscript/lscript_compile/indra.l | 8 +++++++- indra/lscript/lscript_compile/indra.y | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index 0d93f5cba2..ab0d31ec46 100644 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -79,11 +79,17 @@ void parse_string(); #define yyfree indra_free +#if LL_DARWIN +int yyparse( void ); +int yylex( void ); +int yyerror(const char *fmt, ...); +#else #if defined(__cplusplus) -extern "C" { int yylex( void ); } extern "C" { int yyparse( void ); } +extern "C" { int yylex( void ); } extern "C" { int yyerror(const char *fmt, ...); } #endif +#endif %} diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y index e4b10ffdd9..8df0e8ad83 100644 --- a/indra/lscript/lscript_compile/indra.y +++ b/indra/lscript/lscript_compile/indra.y @@ -2,8 +2,10 @@ #include "linden_common.h" #include "lscript_tree.h" - #ifdef __cplusplus + #if !LL_DARWIN + #ifdef __cplusplus extern "C" { + #endif #endif int yylex(void); @@ -20,9 +22,11 @@ #pragma warning( disable : 4065 ) // warning: switch statement contains 'default' but no 'case' labels #endif + #if !LL_DARWIN #ifdef __cplusplus } #endif + #endif %} %union -- cgit v1.2.3 From 104f576400370a468c87fca6657ae5db0688c3c0 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 23 Apr 2013 16:27:24 -0700 Subject: Fix Windows Debug build --- indra/llplugin/slplugin/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra') diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt index 03412d95d5..5d2b1d922e 100644 --- a/indra/llplugin/slplugin/CMakeLists.txt +++ b/indra/llplugin/slplugin/CMakeLists.txt @@ -53,6 +53,9 @@ add_executable(SLPlugin set_target_properties(SLPlugin PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/slplugin_info.plist +if (WINDOWS) + LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMTD\"" +endif (WINDOWS) ) target_link_libraries(SLPlugin -- cgit v1.2.3 From e2eca610459362eda50f6a5edfb9ed5269fd5e51 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 23 Apr 2013 16:31:20 -0700 Subject: Revert LLThreadSafeRefCount optimization; caps fetching was failing. Reviewed by Kelly --- indra/llcommon/llthread.h | 68 +++++++++++++++++++++++++++++++++++++++++++++- indra/llui/llmodaldialog.h | 2 +- 2 files changed, 68 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 11594f276e..a6eb14db9d 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -225,6 +225,71 @@ void LLThread::unlockData() // see llmemory.h for LLPointer<> definition +#if (1) // Old code - see comment below +class LL_COMMON_API LLThreadSafeRefCount +{ +public: + static void initThreadSafeRefCount(); // creates sMutex + static void cleanupThreadSafeRefCount(); // destroys sMutex + +private: + static LLMutex* sMutex; + +protected: + virtual ~LLThreadSafeRefCount(); // use unref() + +public: + LLThreadSafeRefCount(); + LLThreadSafeRefCount(const LLThreadSafeRefCount&); + LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) + { + if (sMutex) + { + sMutex->lock(); + } + mRef = 0; + if (sMutex) + { + sMutex->unlock(); + } + return *this; + } + + + + void ref() + { + if (sMutex) sMutex->lock(); + mRef++; + if (sMutex) sMutex->unlock(); + } + + S32 unref() + { + llassert(mRef >= 1); + if (sMutex) sMutex->lock(); + S32 res = --mRef; + if (sMutex) sMutex->unlock(); + if (0 == res) + { + delete this; + return 0; + } + return res; + } + S32 getNumRefs() const + { + return mRef; + } + +private: + S32 mRef; +}; + +#else + // New code - This was from https://bitbucket.org/lindenlab/viewer-cat/commits/b03bb43e4ead57f904cb3c1e9745dc8460de6efc + // and attempts + class LL_COMMON_API LLThreadSafeRefCount { public: @@ -263,7 +328,7 @@ public: // so that two threads who get into the if in parallel // don't both attempt to the delete. // - mRef--; + mRef--; // Simon: why not if (mRef == 1) delete this; ? There still seems to be a window where mRef could be modified if (mRef == 0) delete this; if (sMutex) sMutex->unlock(); @@ -280,6 +345,7 @@ public: private: LLAtomic32< S32 > mRef; }; +#endif // new code /** * intrusive pointer support for LLThreadSafeRefCount diff --git a/indra/llui/llmodaldialog.h b/indra/llui/llmodaldialog.h index 4e09d11d77..f81273b96a 100644 --- a/indra/llui/llmodaldialog.h +++ b/indra/llui/llmodaldialog.h @@ -40,7 +40,7 @@ class LLModalDialog : public LLFloater { public: LLModalDialog( const LLSD& key, BOOL modal = true ); - /*virtual*/ ~LLModalDialog(); + virtual ~LLModalDialog(); /*virtual*/ BOOL postBuild(); -- cgit v1.2.3 From 87ba85eaabbfd5fd7ad8ca8136f4783b1d932264 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 24 Apr 2013 09:35:38 -0700 Subject: =?UTF-8?q?=C3=AF=C2=BB=C2=BFdiff=20-r=2059c7bed66dfd=20indra/llco?= =?UTF-8?q?mmon/lleventapi.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- indra/llcommon/lleventapi.h | 4 +- indra/llcommon/lleventtimer.h | 2 +- indra/llcommon/llfasttimer.cpp | 8 +-- indra/llcommon/llfasttimer.h | 4 +- indra/llcommon/llinstancetracker.cpp | 22 -------- indra/llcommon/llinstancetracker.h | 58 +++------------------ indra/llcommon/llleap.h | 2 +- indra/llcommon/llsingleton.cpp | 1 - indra/llcommon/llsingleton.h | 60 ++++------------------ indra/llcommon/tests/llinstancetracker_test.cpp | 6 +-- indra/llrender/llgl.h | 4 +- indra/llui/llconsole.h | 2 +- indra/llui/llfloater.h | 2 +- indra/llui/lllayoutstack.h | 2 +- indra/llui/llnotifications.cpp | 4 +- indra/llui/llnotifications.h | 6 +-- indra/llwindow/llwindow.h | 2 +- indra/llxml/llcontrol.cpp | 2 +- indra/llxml/llcontrol.h | 10 ++-- indra/newview/llfloaterwebcontent.cpp | 2 +- indra/newview/llfloaterwebcontent.h | 4 +- indra/newview/llmediactrl.cpp | 2 +- indra/newview/llmediactrl.h | 2 +- indra/newview/llnamelistctrl.h | 2 +- indra/newview/lltoast.cpp | 3 +- indra/newview/lltoast.h | 2 +- indra/newview/lltoastnotifypanel.cpp | 2 +- indra/newview/lltoastnotifypanel.h | 2 +- indra/newview/lltoolselect.h | 2 +- indra/newview/tests/llagentaccess_test.cpp | 2 +- indra/newview/tests/lllogininstance_test.cpp | 2 +- indra/newview/tests/llremoteparcelrequest_test.cpp | 2 +- indra/newview/tests/llsecapi_test.cpp | 2 +- indra/newview/tests/llsechandler_basic_test.cpp | 2 +- indra/newview/tests/llslurl_test.cpp | 2 +- indra/newview/tests/lltranslate_test.cpp | 2 +- indra/newview/tests/llviewerhelputil_test.cpp | 2 +- indra/newview/tests/llviewernetwork_test.cpp | 2 +- indra/newview/tests/llworldmipmap_test.cpp | 2 +- 39 files changed, 68 insertions(+), 176 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h index 10c7e7a23f..5991fe8fd5 100644 --- a/indra/llcommon/lleventapi.h +++ b/indra/llcommon/lleventapi.h @@ -41,10 +41,10 @@ * Deriving from LLInstanceTracker lets us enumerate instances. */ class LL_COMMON_API LLEventAPI: public LLDispatchListener, - public INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) + public LLInstanceTracker { typedef LLDispatchListener lbase; - typedef INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) ibase; + typedef LLInstanceTracker ibase; public: diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h index e55f851758..dc918121e1 100644 --- a/indra/llcommon/lleventtimer.h +++ b/indra/llcommon/lleventtimer.h @@ -33,7 +33,7 @@ #include "lltimer.h" // class for scheduling a function to be called at a given frequency (approximate, inprecise) -class LL_COMMON_API LLEventTimer : public INSTANCE_TRACKER(LLEventTimer) +class LL_COMMON_API LLEventTimer : public LLInstanceTracker { public: diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 9b15804e97..51a9441cd5 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -107,17 +107,13 @@ class NamedTimerFactory : public LLSingleton { public: NamedTimerFactory() - : mTimerRoot(NULL) - {} - - /*virtual */ void initSingleton() + : mTimerRoot(new LLFastTimer::NamedTimer("root")) { - mTimerRoot = new LLFastTimer::NamedTimer("root"); mRootFrameState.setNamedTimer(mTimerRoot); mTimerRoot->setFrameState(&mRootFrameState); mTimerRoot->mParent = mTimerRoot; mTimerRoot->setCollapsed(false); - mRootFrameState.mParent = &mRootFrameState; + mRootFrameState.mParent = &mRootFrameState; } ~NamedTimerFactory() diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index a6b34bdc69..a99a1d88af 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -63,7 +63,7 @@ public: // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances class LL_COMMON_API NamedTimer - : public LLInstanceTracker + : public LLInstanceTracker { friend class DeclareTimer; public: @@ -139,7 +139,7 @@ public: // used to statically declare a new named timer class LL_COMMON_API DeclareTimer - : public LLInstanceTracker< DeclareTimer, InstanceTrackType_DeclareTimer > + : public LLInstanceTracker< DeclareTimer > { friend class LLFastTimer; public: diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 89430f82d7..247d0dc4fb 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -32,26 +32,4 @@ // external library headers // other Linden headers -static bool sInstanceTrackerData_initialized = false; -static void* sInstanceTrackerData[ kInstanceTrackTypeCount ]; - - -void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t) -{ - // std::map::insert() is just what we want here. You attempt to insert a - // (key, value) pair. If the specified key doesn't yet exist, it inserts - // the pair and returns a std::pair of (iterator, true). If the specified - // key DOES exist, insert() simply returns (iterator, false). One lookup - // handles both cases. - if (!sInstanceTrackerData_initialized) - { - for (S32 i = 0; i < (S32) kInstanceTrackTypeCount; i++) - { - sInstanceTrackerData[i] = NULL; - } - sInstanceTrackerData_initialized = true; - } - - return sInstanceTrackerData[t]; -} diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index b290526754..361182380a 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -38,33 +38,6 @@ #include #include -enum InstanceTrackType -{ - InstanceTrackType_LLEventAPI, - InstanceTrackType_LLEventTimer, - InstanceTrackType_NamedTimer, - InstanceTrackType_DeclareTimer, - InstanceTrackType_LLLeap, - InstanceTrackType_LLGLNamePool, - InstanceTrackType_LLConsole, - InstanceTrackType_LLFloater, - InstanceTrackType_LLFloaterWebContent, - InstanceTrackType_LLLayoutStack, - InstanceTrackType_LLNotificationContext, - InstanceTrackType_LLWindow, - InstanceTrackType_LLControlGroup, - InstanceTrackType_LLControlCache, - InstanceTrackType_LLMediaCtrl, - InstanceTrackType_LLNameListCtrl, - InstanceTrackType_LLToast, - InstanceTrackType_Keyed, // for integ tests - InstanceTrackType_Unkeyed, // for integ tests - kInstanceTrackTypeCount -}; - -#define INSTANCE_TRACKER(T) LLInstanceTracker< T, InstanceTrackType_##T > -#define INSTANCE_TRACKER_KEYED(T,K) LLInstanceTracker< T, InstanceTrackType_##T, K > - /** * Base class manages "class-static" data that must actually have singleton * semantics: one instance per process, rather than one instance per module as @@ -73,22 +46,7 @@ enum InstanceTrackType class LL_COMMON_API LLInstanceTrackerBase { protected: - /// Get a process-unique void* pointer slot for the specified type_info - //static void * & getInstances(std::type_info const & info); - static void * & getInstances(InstanceTrackType t); - - /// Find or create a STATICDATA instance for the specified TRACKED class. - /// STATICDATA must be default-constructible. - template - static STATICDATA& getStatic() - { - void *& instances = getInstances(TRACKEDTYPE); - if (! instances) - { - instances = new STATICDATA; - } - return *static_cast(instances); - } + /// It's not essential to derive your STATICDATA (for use with /// getStatic()) from StaticBase; it's just that both known @@ -108,16 +66,16 @@ LL_COMMON_API void assert_main_thread(); /// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup /// If KEY is not provided, then instances are stored in a simple set /// @NOTE: see explicit specialization below for default KEY==T* case -template +template class LLInstanceTracker : public LLInstanceTrackerBase { - typedef LLInstanceTracker MyT; + typedef LLInstanceTracker self_t; typedef typename std::map InstanceMap; struct StaticData: public StaticBase { InstanceMap sMap; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } + static StaticData& getStatic() { static StaticData sData; return sData;} static InstanceMap& getMap_() { // assert_main_thread(); fwiw this class is not thread safe, and it used by multiple threads. Bad things happen. @@ -263,16 +221,16 @@ private: /// explicit specialization for default case where KEY is T* /// use a simple std::set -template -class LLInstanceTracker : public LLInstanceTrackerBase +template +class LLInstanceTracker : public LLInstanceTrackerBase { - typedef LLInstanceTracker MyT; + typedef LLInstanceTracker self_t; typedef typename std::set InstanceSet; struct StaticData: public StaticBase { InstanceSet sSet; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } + static StaticData& getStatic() { static StaticData sData; return sData; } static InstanceSet& getSet_() { return getStatic().sSet; } public: diff --git a/indra/llcommon/llleap.h b/indra/llcommon/llleap.h index d4e138f4be..e33f25e530 100644 --- a/indra/llcommon/llleap.h +++ b/indra/llcommon/llleap.h @@ -29,7 +29,7 @@ * LLLeap* pointer should be validated before use by * LLLeap::getInstance(LLLeap*) (see LLInstanceTracker). */ -class LL_COMMON_API LLLeap: public INSTANCE_TRACKER(LLLeap) +class LL_COMMON_API LLLeap: public LLInstanceTracker { public: diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp index eb8e2c9456..9b49e52377 100644 --- a/indra/llcommon/llsingleton.cpp +++ b/indra/llcommon/llsingleton.cpp @@ -28,5 +28,4 @@ #include "llsingleton.h" -std::map * LLSingletonRegistry::sSingletonMap = NULL; diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 49d99f2cd0..84afeb563e 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -30,38 +30,6 @@ #include #include -/// @brief A global registry of all singletons to prevent duplicate allocations -/// across shared library boundaries -class LL_COMMON_API LLSingletonRegistry { - private: - typedef std::map TypeMap; - static TypeMap * sSingletonMap; - - static void checkInit() - { - if(sSingletonMap == NULL) - { - sSingletonMap = new TypeMap(); - } - } - - public: - template static void * & get() - { - std::string name(typeid(T).name()); - - checkInit(); - - // the first entry of the pair returned by insert will be either the existing - // iterator matching our key, or the newly inserted NULL initialized entry - // see "Insert element" in http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html - TypeMap::iterator result = - sSingletonMap->insert(std::make_pair(name, (void*)NULL)).first; - - return result->second; - } -}; - // LLSingleton implements the getInstance() method part of the Singleton // pattern. It can't make the derived class constructors protected, though, so // you have to do that yourself. @@ -93,7 +61,6 @@ class LLSingleton : private boost::noncopyable private: typedef enum e_init_state { - UNINITIALIZED, CONSTRUCTING, INITIALIZING, INITIALIZED, @@ -109,8 +76,11 @@ private: SingletonInstanceData() : mSingletonInstance(NULL), - mInitState(UNINITIALIZED) - {} + mInitState(CONSTRUCTING) + { + mSingletonInstance = new DERIVED_TYPE(); + mInitState = INITIALIZING; + } ~SingletonInstanceData() { @@ -159,16 +129,8 @@ public: static SingletonInstanceData& getData() { // this is static to cache the lookup results - static void * & registry = LLSingletonRegistry::get(); - - // *TODO - look into making this threadsafe - if(NULL == registry) - { - static SingletonInstanceData data; - registry = &data; - } - - return *static_cast(registry); + static SingletonInstanceData sData; + return sData; } static DERIVED_TYPE* getInstance() @@ -185,13 +147,11 @@ public: llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; } - if (!data.mSingletonInstance) + if (data.mInitState == INITIALIZING) { - data.mInitState = CONSTRUCTING; - data.mSingletonInstance = new DERIVED_TYPE(); - data.mInitState = INITIALIZING; + // go ahead and flag ourselves as initialized so we can be reentrant during initialization + data.mInitState = INITIALIZED; data.mSingletonInstance->initSingleton(); - data.mInitState = INITIALIZED; } return data.mSingletonInstance; diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp index b2d82d1843..e769c3e22c 100644 --- a/indra/llcommon/tests/llinstancetracker_test.cpp +++ b/indra/llcommon/tests/llinstancetracker_test.cpp @@ -48,16 +48,16 @@ struct Badness: public std::runtime_error Badness(const std::string& what): std::runtime_error(what) {} }; -struct Keyed: public INSTANCE_TRACKER_KEYED(Keyed, std::string) +struct Keyed: public LLInstanceTracker { Keyed(const std::string& name): - INSTANCE_TRACKER_KEYED(Keyed, std::string)(name), + LLInstanceTracker(name), mName(name) {} std::string mName; }; -struct Unkeyed: public INSTANCE_TRACKER(Unkeyed) +struct Unkeyed: public LLInstanceTracker { Unkeyed(const std::string& thrw="") { diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 133c2de1f5..823de9d361 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -350,10 +350,10 @@ public: Generic pooling scheme for things which use GL names (used for occlusion queries and vertex buffer objects). Prevents thrashing of GL name caches by avoiding calls to glGenFoo and glDeleteFoo. */ -class LLGLNamePool : public INSTANCE_TRACKER(LLGLNamePool) +class LLGLNamePool : public LLInstanceTracker { public: - typedef INSTANCE_TRACKER(LLGLNamePool) tracker_t; + typedef LLInstanceTracker tracker_t; struct NameEntry { diff --git a/indra/llui/llconsole.h b/indra/llui/llconsole.h index b264aeb7eb..5ff05698b0 100644 --- a/indra/llui/llconsole.h +++ b/indra/llui/llconsole.h @@ -34,7 +34,7 @@ class LLSD; -class LLConsole : public LLFixedBuffer, public LLUICtrl, public INSTANCE_TRACKER(LLConsole) +class LLConsole : public LLFixedBuffer, public LLUICtrl, public LLInstanceTracker { public: diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index f28ceb0ce4..99d1d2614d 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -116,7 +116,7 @@ struct LLCoordFloater : LLCoord }; -class LLFloater : public LLPanel, public INSTANCE_TRACKER(LLFloater) +class LLFloater : public LLPanel, public LLInstanceTracker { friend class LLFloaterView; friend class LLFloaterReg; diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index a8b5466242..8e330278af 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -35,7 +35,7 @@ class LLLayoutPanel; -class LLLayoutStack : public LLView, public INSTANCE_TRACKER(LLLayoutStack) +class LLLayoutStack : public LLView, public LLInstanceTracker { public: diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 8bafbd53d8..1789f003b9 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -1121,7 +1121,7 @@ bool LLNotificationChannelBase::updateItem(const LLSD& payload, LLNotificationPt LLNotificationChannel::LLNotificationChannel(const Params& p) : LLNotificationChannelBase(p.filter()), - LLInstanceTracker(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString()), + LLInstanceTracker(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString()), mName(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString()) { BOOST_FOREACH(const std::string& source, p.sources) @@ -1135,7 +1135,7 @@ LLNotificationChannel::LLNotificationChannel(const std::string& name, const std::string& parent, LLNotificationFilter filter) : LLNotificationChannelBase(filter), - LLInstanceTracker(name), + LLInstanceTracker(name), mName(name) { // bind to notification broadcast diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 2561125aa5..cd3728305e 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -135,11 +135,11 @@ typedef LLFunctorRegistration LLNotificationFunctorRegi // context data that can be looked up via a notification's payload by the display logic // derive from this class to implement specific contexts -class LLNotificationContext : public INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID) +class LLNotificationContext : public LLInstanceTracker { public: - LLNotificationContext() : INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID)(LLUUID::generateNewID()) + LLNotificationContext() : LLInstanceTracker(LLUUID::generateNewID()) { } @@ -815,7 +815,7 @@ typedef boost::intrusive_ptr LLNotificationChannelPtr; class LLNotificationChannel : boost::noncopyable, public LLNotificationChannelBase, - public LLInstanceTracker + public LLInstanceTracker { LOG_CLASS(LLNotificationChannel); diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 06d7e4907a..78186004b8 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -39,7 +39,7 @@ class LLWindowCallbacks; // Refer to llwindow_test in test/common/llwindow for usage example -class LLWindow : public INSTANCE_TRACKER(LLWindow) +class LLWindow : public LLInstanceTracker { public: diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index f82750af47..666c03e9ff 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -316,7 +316,7 @@ LLPointer LLControlGroup::getControl(const std::string& name) //////////////////////////////////////////////////////////////////////////// LLControlGroup::LLControlGroup(const std::string& name) -: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) +: LLInstanceTracker(name) { mTypeString[TYPE_U32] = "U32"; mTypeString[TYPE_S32] = "S32"; diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 6ea010f4f9..ee7d1d50b7 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -180,7 +180,7 @@ T convert_from_llsd(const LLSD& sd, eControlType type, const std::string& contro } //const U32 STRING_CACHE_SIZE = 10000; -class LLControlGroup : public INSTANCE_TRACKER_KEYED(LLControlGroup, std::string) +class LLControlGroup : public LLInstanceTracker { LOG_CLASS(LLControlGroup); @@ -197,7 +197,7 @@ public: ~LLControlGroup(); void cleanup(); - typedef INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)::instance_iter instance_iter; + typedef LLInstanceTracker::instance_iter instance_iter; LLControlVariablePtr getControl(const std::string& name); @@ -306,7 +306,7 @@ public: //! without have to manually create and bind a listener to a local //! object. template -class LLControlCache : public LLRefCount, public LLInstanceTracker, InstanceTrackType_LLControlCache, std::string> +class LLControlCache : public LLRefCount, public LLInstanceTracker, std::string> { public: // This constructor will declare a control if it doesn't exist in the contol group @@ -314,7 +314,7 @@ public: const std::string& name, const T& default_value, const std::string& comment) - : LLInstanceTracker, InstanceTrackType_LLControlCache, std::string >(name) + : LLInstanceTracker, std::string >(name) { if(!group.controlExists(name)) { @@ -329,7 +329,7 @@ public: LLControlCache(LLControlGroup& group, const std::string& name) - : LLInstanceTracker, InstanceTrackType_LLControlCache, std::string >(name) + : LLInstanceTracker, std::string >(name) { if(!group.controlExists(name)) { diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index 94c3f4149c..3fe2518de6 100644 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -54,7 +54,7 @@ LLFloaterWebContent::_Params::_Params() LLFloaterWebContent::LLFloaterWebContent( const Params& params ) : LLFloater( params ), - INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string)(params.id()), + LLInstanceTracker(params.id()), mWebBrowser(NULL), mAddressCombo(NULL), mSecureLockIcon(NULL), diff --git a/indra/newview/llfloaterwebcontent.h b/indra/newview/llfloaterwebcontent.h index 409c15fb0b..86b5a5e00b 100644 --- a/indra/newview/llfloaterwebcontent.h +++ b/indra/newview/llfloaterwebcontent.h @@ -40,11 +40,11 @@ class LLIconCtrl; class LLFloaterWebContent : public LLFloater, public LLViewerMediaObserver, - public INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string) + public LLInstanceTracker { public: - typedef INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string) instance_tracker_t; + typedef LLInstanceTracker instance_tracker_t; LOG_CLASS(LLFloaterWebContent); struct _Params : public LLInitParam::Block<_Params> diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 6362165c77..2075aeed63 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -81,7 +81,7 @@ LLMediaCtrl::Params::Params() LLMediaCtrl::LLMediaCtrl( const Params& p) : LLPanel( p ), - INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID)(LLUUID::generateNewID()), + LLInstanceTracker(LLUUID::generateNewID()), mTextureDepthBytes( 4 ), mBorder(NULL), mFrequentUpdates( true ), diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index 4fed21bf22..6c38c1fb56 100644 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -42,7 +42,7 @@ class LLMediaCtrl : public LLPanel, public LLViewerMediaObserver, public LLViewerMediaEventEmitter, - public INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID) + public LLInstanceTracker { LOG_CLASS(LLMediaCtrl); public: diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h index d82727f018..92e82b672d 100644 --- a/indra/newview/llnamelistctrl.h +++ b/indra/newview/llnamelistctrl.h @@ -64,7 +64,7 @@ private: class LLNameListCtrl -: public LLScrollListCtrl, public INSTANCE_TRACKER(LLNameListCtrl) +: public LLScrollListCtrl, public LLInstanceTracker { public: diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index 49debe67f6..a26e47e1c8 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -572,7 +572,8 @@ S32 LLToast::notifyParent(const LLSD& info) //static void LLToast::updateClass() { - for (INSTANCE_TRACKER(LLToast)::instance_iter iter = INSTANCE_TRACKER(LLToast)::beginInstances(); iter != INSTANCE_TRACKER(LLToast)::endInstances(); ) + for (LLInstanceTracker::instance_iter iter = LLInstanceTracker::beginInstances(); + iter != LLInstanceTracker::endInstances(); ) { LLToast& toast = *iter++; diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index 718b464977..5da7120e84 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -69,7 +69,7 @@ private : * Represents toast pop-up. * This is a parent view for all toast panels. */ -class LLToast : public LLModalDialog, public INSTANCE_TRACKER(LLToast) +class LLToast : public LLModalDialog, public LLInstanceTracker { friend class LLToastLifeTimer; public: diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp index 9b5ccc0150..94d07b37ef 100644 --- a/indra/newview/lltoastnotifypanel.cpp +++ b/indra/newview/lltoastnotifypanel.cpp @@ -57,7 +57,7 @@ LLToastNotifyPanel::button_click_signal_t LLToastNotifyPanel::sButtonClickSignal LLToastNotifyPanel::LLToastNotifyPanel(const LLNotificationPtr& notification, const LLRect& rect, bool show_images) : LLToastPanel(notification), - LLInstanceTracker(notification->getID()) + LLInstanceTracker(notification->getID()) { init(rect, show_images); } diff --git a/indra/newview/lltoastnotifypanel.h b/indra/newview/lltoastnotifypanel.h index 5de75a7a9f..d02171b512 100644 --- a/indra/newview/lltoastnotifypanel.h +++ b/indra/newview/lltoastnotifypanel.h @@ -47,7 +47,7 @@ class LLNotificationForm; * @deprecated this class will be removed after all toast panel types are * implemented in separate classes. */ -class LLToastNotifyPanel: public LLToastPanel, public LLInstanceTracker +class LLToastNotifyPanel: public LLToastPanel, public LLInstanceTracker { public: /** diff --git a/indra/newview/lltoolselect.h b/indra/newview/lltoolselect.h index baa27f6071..74dababe8c 100644 --- a/indra/newview/lltoolselect.h +++ b/indra/newview/lltoolselect.h @@ -34,7 +34,7 @@ class LLObjectSelection; -class LLToolSelect : public LLTool, public LLSingleton +class LLToolSelect : public LLTool { public: LLToolSelect( LLToolComposite* composite ); diff --git a/indra/newview/tests/llagentaccess_test.cpp b/indra/newview/tests/llagentaccess_test.cpp index 426ad40342..05289f0309 100644 --- a/indra/newview/tests/llagentaccess_test.cpp +++ b/indra/newview/tests/llagentaccess_test.cpp @@ -40,7 +40,7 @@ static U32 test_preferred_maturity = SIM_ACCESS_PG; LLControlGroup::LLControlGroup(const std::string& name) - : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) +: LLInstanceTracker(name) { } diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp index 25da5939f1..7705b4c567 100644 --- a/indra/newview/tests/lllogininstance_test.cpp +++ b/indra/newview/tests/lllogininstance_test.cpp @@ -167,7 +167,7 @@ std::string LLGridManager::getAppSLURLBase(const std::string& grid_name) LLControlGroup gSavedSettings("Global"); LLControlGroup::LLControlGroup(const std::string& name) : - INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name){} + LLInstanceTracker(name){} LLControlGroup::~LLControlGroup() {} void LLControlGroup::setBOOL(const std::string& name, BOOL val) {} BOOL LLControlGroup::getBOOL(const std::string& name) { return FALSE; } diff --git a/indra/newview/tests/llremoteparcelrequest_test.cpp b/indra/newview/tests/llremoteparcelrequest_test.cpp index da273132db..ed66066b0a 100644 --- a/indra/newview/tests/llremoteparcelrequest_test.cpp +++ b/indra/newview/tests/llremoteparcelrequest_test.cpp @@ -69,7 +69,7 @@ void LLAgent::sendReliableMessage(void) { } LLUUID gAgentSessionID; LLUUID gAgentID; LLUIColor::LLUIColor(void) { } -LLControlGroup::LLControlGroup(std::string const & name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { } +LLControlGroup::LLControlGroup(std::string const & name) : LLInstanceTracker(name) { } LLControlGroup::~LLControlGroup(void) { } void LLUrlEntryParcel::processParcelInfo(const LLUrlEntryParcel::LLParcelData& parcel_data) { } diff --git a/indra/newview/tests/llsecapi_test.cpp b/indra/newview/tests/llsecapi_test.cpp index 83a4149971..703603e2db 100644 --- a/indra/newview/tests/llsecapi_test.cpp +++ b/indra/newview/tests/llsecapi_test.cpp @@ -37,7 +37,7 @@ // Mock objects for the dependencies of the code we're testing LLControlGroup::LLControlGroup(const std::string& name) -: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} +: LLInstanceTracker(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/llsechandler_basic_test.cpp b/indra/newview/tests/llsechandler_basic_test.cpp index 814010028f..0235400976 100644 --- a/indra/newview/tests/llsechandler_basic_test.cpp +++ b/indra/newview/tests/llsechandler_basic_test.cpp @@ -69,7 +69,7 @@ extern bool _cert_hostname_wildcard_match(const std::string& hostname, const std std::string gFirstName; std::string gLastName; LLControlGroup::LLControlGroup(const std::string& name) -: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} +: LLInstanceTracker(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp index d7debd6c67..09343ef227 100644 --- a/indra/newview/tests/llslurl_test.cpp +++ b/indra/newview/tests/llslurl_test.cpp @@ -35,7 +35,7 @@ // Mock objects for the dependencies of the code we're testing LLControlGroup::LLControlGroup(const std::string& name) -: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} +: LLInstanceTracker(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/lltranslate_test.cpp b/indra/newview/tests/lltranslate_test.cpp index c13660332d..fd9527d631 100644 --- a/indra/newview/tests/lltranslate_test.cpp +++ b/indra/newview/tests/lltranslate_test.cpp @@ -295,7 +295,7 @@ LLControlGroup gSavedSettings("test"); std::string LLUI::getLanguage() { return "en"; } std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { return "dummy"; } -LLControlGroup::LLControlGroup(const std::string& name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} +LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker(name) {} std::string LLControlGroup::getString(const std::string& name) { return "dummy"; } LLControlGroup::~LLControlGroup() {} diff --git a/indra/newview/tests/llviewerhelputil_test.cpp b/indra/newview/tests/llviewerhelputil_test.cpp index 102cad8852..710881d811 100644 --- a/indra/newview/tests/llviewerhelputil_test.cpp +++ b/indra/newview/tests/llviewerhelputil_test.cpp @@ -47,7 +47,7 @@ static std::string gOS; // Mock objects for the dependencies of the code we're testing LLControlGroup::LLControlGroup(const std::string& name) - : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} + : LLInstanceTracker(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index 725b5122fb..a1e97ea17e 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -35,7 +35,7 @@ // Mock objects for the dependencies of the code we're testing LLControlGroup::LLControlGroup(const std::string& name) -: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {} +: LLInstanceTracker(name) {} LLControlGroup::~LLControlGroup() {} BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, diff --git a/indra/newview/tests/llworldmipmap_test.cpp b/indra/newview/tests/llworldmipmap_test.cpp index a6a2f8d7b9..142d75bcfd 100644 --- a/indra/newview/tests/llworldmipmap_test.cpp +++ b/indra/newview/tests/llworldmipmap_test.cpp @@ -46,7 +46,7 @@ void LLGLTexture::setBoostLevel(S32 ) { } LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const std::string&, FTType, BOOL, LLGLTexture::EBoostLevel, S8, LLGLint, LLGLenum, const LLUUID& ) { return NULL; } -LLControlGroup::LLControlGroup(const std::string& name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { } +LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker(name) { } LLControlGroup::~LLControlGroup() { } std::string LLControlGroup::getString(const std::string& ) { return std::string("test_url"); } LLControlGroup gSavedSettings("test_settings"); -- cgit v1.2.3 From cbd3f4b9974c23dc127e080a090c26645b8aa00c Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 24 Apr 2013 10:24:42 -0700 Subject: Fix crash discovered during other testing. Reviewed by Kelly --- indra/newview/llmeshrepository.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index b1b31240e9..83b7cae347 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1235,8 +1235,8 @@ bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* dat mLODReqQ.push(req); LLMeshRepository::sLODProcessing++; } + mPendingLOD.erase(iter); } - mPendingLOD.erase(iter); } return true; -- cgit v1.2.3 From faf844ff996f205af6eb6b2ebd5290594da8d142 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 24 Apr 2013 10:59:25 -0700 Subject: Trivial change to note that earlier changeset 27742 (1c3262183eb5) is a re-work of the LLInstanceTracker code done by Richard. The commit comment is cryptic --- indra/llcommon/llinstancetracker.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 247d0dc4fb..64a313b5ff 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -32,4 +32,3 @@ // external library headers // other Linden headers - -- cgit v1.2.3 From cc3361352df3463e9ba16e57c04cc35e65821f33 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 24 Apr 2013 15:34:18 -0700 Subject: Follow-up code cleaning for LLToast work trying to get branch healthy. Reviewed by Kelly --- indra/newview/llfloaterimnearbychathandler.cpp | 13 ++++---- indra/newview/lltoast.cpp | 41 ++++++++++++++++++++++++-- indra/newview/lltoast.h | 1 + indra/newview/llviewerwindow.cpp | 4 +++ 4 files changed, 49 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp index 9ce5e12897..c4d7bbb7f6 100644 --- a/indra/newview/llfloaterimnearbychathandler.cpp +++ b/indra/newview/llfloaterimnearbychathandler.cpp @@ -187,14 +187,11 @@ void LLFloaterIMNearbyChatScreenChannel::deactivateToast(LLToast* toast) { toast_vec_t::iterator pos = std::find(m_active_toasts.begin(), m_active_toasts.end(), toast->getHandle()); - if (pos == m_active_toasts.end()) + if (pos != m_active_toasts.end()) { - llassert(pos == m_active_toasts.end()); - return; + LL_DEBUGS("NearbyChat") << "Deactivating toast" << llendl; + m_active_toasts.erase(pos); } - - LL_DEBUGS("NearbyChat") << "Deactivating toast" << llendl; - m_active_toasts.erase(pos); } void LLFloaterIMNearbyChatScreenChannel::createOverflowToast(S32 bottom, F32 timer) @@ -210,8 +207,8 @@ void LLFloaterIMNearbyChatScreenChannel::onToastDestroyed(LLToast* toast, bool a { // Viewer is quitting. // Immediately stop processing chat messages (EXT-1419). - mStopProcessing = true; -} + mStopProcessing = true; + } else { // The toast is being closed by user (STORM-192). diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index a26e47e1c8..4b60f49573 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -173,8 +173,20 @@ void LLToast::setHideButtonEnabled(bool enabled) //-------------------------------------------------------------------------- LLToast::~LLToast() -{ - mOnToastDestroyedSignal(this); +{ + if(LLApp::isQuitting()) + { + mOnFadeSignal.disconnect_all_slots(); + mOnDeleteToastSignal.disconnect_all_slots(); + mOnToastDestroyedSignal.disconnect_all_slots(); + mOnToastHoverSignal.disconnect_all_slots(); + mToastMouseEnterSignal.disconnect_all_slots(); + mToastMouseLeaveSignal.disconnect_all_slots(); + } + else + { + mOnToastDestroyedSignal(this); + } } //-------------------------------------------------------------------------- @@ -580,3 +592,28 @@ void LLToast::updateClass() toast.updateHoveredState(); } } + +// static +void LLToast::cleanupToasts() +{ + LL_CHECK_MEMORY; + + LLToast * toastp = NULL; + + while (LLInstanceTracker::instanceCount() > 0) + { + { // Need to scope iter to allow deletion + LLInstanceTracker::instance_iter iter = LLInstanceTracker::beginInstances(); + toastp = &(*iter); + } + + //llinfos << "Cleaning up toast id " << toastp->getNotificationID() << llendl; + + // LLToast destructor will remove it from the LLInstanceTracker. + if (!toastp) + break; // Don't get stuck in the loop if a null pointer somehow got on the list + + delete toastp; + } +} + diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index 5da7120e84..f02d7c2a1a 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -106,6 +106,7 @@ public: }; static void updateClass(); + static void cleanupToasts(); LLToast(const LLToast::Params& p); virtual ~LLToast(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index bb71707db6..136e61389a 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -150,6 +150,7 @@ #include "lltexturecache.h" #include "lltexturefetch.h" #include "lltextureview.h" +#include "lltoast.h" #include "lltool.h" #include "lltoolbarview.h" #include "lltoolcomp.h" @@ -2035,6 +2036,9 @@ void LLViewerWindow::shutdownViews() } llinfos << "Global views cleaned." << llendl ; + LLNotificationsUI::LLToast::cleanupToasts(); + llinfos << "Leftover toast cleaned up." << llendl; + // DEV-40930: Clear sModalStack. Otherwise, any LLModalDialog left open // will crump with LL_ERRS. LLModalDialog::shutdownModals(); -- cgit v1.2.3 From 7cb2f4f35856d4b51132d3915c05ac69dc3a90d5 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 24 Apr 2013 16:02:12 -0700 Subject: Remove an un-needed LL_CHECK_MEMORY check --- indra/newview/lltoast.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index 4b60f49573..d876c9a3f4 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -596,8 +596,6 @@ void LLToast::updateClass() // static void LLToast::cleanupToasts() { - LL_CHECK_MEMORY; - LLToast * toastp = NULL; while (LLInstanceTracker::instanceCount() > 0) -- cgit v1.2.3 From c4a45fca396bea8abf8362b15b5cf0f85e57ad6b Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 25 Apr 2013 11:05:06 -0700 Subject: Enhance "duplicate seed caps" log message ... this needs more investigation. Reviewed by Kelly --- indra/newview/llviewerregion.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 808bc9f3f7..62fb0ed8c1 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -301,12 +301,16 @@ public: if ( regionp->getRegionImpl()->mCapabilities.size() != regionp->getRegionImpl()->mSecondCapabilitiesTracker.size() ) { - llinfos<<"BaseCapabilitiesCompleteTracker "<<"Sim sent duplicate seed caps that differs in size - most likely content."<getName() + << " sent duplicate seed caps that differs in size - most likely content. " + << (S32) regionp->getRegionImpl()->mCapabilities.size() << " vs " << regionp->getRegionImpl()->mSecondCapabilitiesTracker.size() + << llendl; //todo#add cap debug versus original check? - /*CapabilityMap::const_iterator iter = regionp->getRegionImpl()->mCapabilities.begin(); + /* + CapabilityMap::const_iterator iter = regionp->getRegionImpl()->mCapabilities.begin(); while (iter!=regionp->getRegionImpl()->mCapabilities.end() ) { - llinfos<<"BaseCapabilitiesCompleteTracker Original "<first<<" "<< iter->second<first << " is " << iter->second << llendl; ++iter; } */ -- cgit v1.2.3 From 6e483af1f6b7a6f8d0f83e54d79a941607760f7b Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 25 Apr 2013 14:14:35 -0700 Subject: Revert ares and libcurl version update that was causing problems, revise curl handle duplication code. Reviewed by Kelly --- indra/llcorehttp/_httpinternal.h | 3 -- indra/llcorehttp/_httpoprequest.cpp | 13 +-------- indra/llcorehttp/_httpoprequest.h | 3 -- indra/llmessage/llcurl.cpp | 58 ++++++++++++++++++++++++++----------- indra/llmessage/llcurl.h | 11 ++----- 5 files changed, 45 insertions(+), 43 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpinternal.h b/indra/llcorehttp/_httpinternal.h index 14f744a9f1..008e4fd95c 100644 --- a/indra/llcorehttp/_httpinternal.h +++ b/indra/llcorehttp/_httpinternal.h @@ -146,9 +146,6 @@ const int HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS = 2; // Block allocation size (a tuning parameter) is found // in bufferarray.h. -// Compatibility controls -const bool HTTP_ENABLE_LINKSYS_WRT54G_V5_DNS_FIX = true; - } // end namespace LLCore #endif // _LLCORE_HTTP_INTERNAL_H_ diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 469ce75434..89dcd334f4 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -380,18 +380,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) // Get policy options HttpPolicyGlobal & policy(service->getPolicy().getGlobalOptions()); - mCurlHandle = LLCurlHandleHandler::getInstance()->CreateCurlHandle(); - - if (HTTP_ENABLE_LINKSYS_WRT54G_V5_DNS_FIX) - { - // The Linksys WRT54G V5 router has an issue with frequent - // DNS lookups from LAN machines. If they happen too often, - // like for every HTTP request, the router gets annoyed after - // about 700 or so requests and starts issuing TCP RSTs to - // new connections. Reuse the DNS lookups for even a few - // seconds and no RSTs. - curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, 15); - } + mCurlHandle = LLCurl::createStandardCurlHandle(); curl_easy_setopt(mCurlHandle, CURLOPT_WRITEFUNCTION, writeCallback); curl_easy_setopt(mCurlHandle, CURLOPT_READFUNCTION, readCallback); diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index e819f74079..74a349b0bf 100644 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -29,7 +29,6 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces -#include "llsingleton.h" #include #include @@ -66,8 +65,6 @@ class HttpOpRequest : public HttpOperation public: HttpOpRequest(); - friend class CurlHandleHandler; - protected: virtual ~HttpOpRequest(); // Use release() diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index c02483ccf5..081f070866 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -92,6 +92,7 @@ S32 LLCurl::sTotalHandles = 0 ; bool LLCurl::sNotQuitting = true; F32 LLCurl::sCurlRequestTimeOut = 120.f; //seonds S32 LLCurl::sMaxHandles = 256; //max number of handles, (multi handles and easy handles combined). +CURL* LLCurl::sCurlTemplateStandardHandle = NULL; void check_curl_code(CURLcode code) { @@ -1815,7 +1816,7 @@ CURL* LLCurl::newEasyHandle() } sTotalHandles++; - CURL* ret = LLCurlHandleHandler::getInstance()->CreateCurlHandle(); + CURL* ret = createStandardCurlHandle(); if(!ret) { llwarns << "failed to create curl handle." << llendl ; @@ -1849,23 +1850,46 @@ void LLCurlFF::check_multi_code(CURLMcode code) check_curl_multi_code(code); } -CURL* LLCurlHandleHandler::the_one_true_curl_handle; -LLCurlHandleHandler::LLCurlHandleHandler() +// Static +CURL* LLCurl::createStandardCurlHandle() { - the_one_true_curl_handle = curl_easy_init(); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_NOSIGNAL, 1); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_NOPROGRESS, 1); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_ENCODING, ""); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_AUTOREFERER, 1); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_SSL_VERIFYPEER, 1); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_SSL_VERIFYHOST, 0); - curl_easy_setopt(the_one_true_curl_handle, CURLOPT_DNS_CACHE_TIMEOUT, 0); -} + if (sCurlTemplateStandardHandle == NULL) + { // Late creation of the template curl handle + sCurlTemplateStandardHandle = curl_easy_init(); + if (sCurlTemplateStandardHandle == NULL) + { + llwarns << "curl error calling curl_easy_init()" << llendl; + } + else + { + CURLcode result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_NOSIGNAL, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_NOPROGRESS, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_ENCODING, ""); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_AUTOREFERER, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_FOLLOWLOCATION, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_SSL_VERIFYPEER, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_SSL_VERIFYHOST, 0); + check_curl_code(result); + + // The Linksys WRT54G V5 router has an issue with frequent + // DNS lookups from LAN machines. If they happen too often, + // like for every HTTP request, the router gets annoyed after + // about 700 or so requests and starts issuing TCP RSTs to + // new connections. Reuse the DNS lookups for even a few + // seconds and no RSTs. + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_DNS_CACHE_TIMEOUT, 15); + check_curl_code(result); + } + } -CURL* LLCurlHandleHandler::CreateCurlHandle() -{ - return curl_easy_duphandle(the_one_true_curl_handle); + return curl_easy_duphandle(sCurlTemplateStandardHandle); } diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index a03333157c..90b3f2815d 100644 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -53,14 +53,6 @@ class LLCurlThread; // For whatever reason, this is not typedef'd in curl.h typedef size_t (*curl_header_callback)(void *ptr, size_t size, size_t nmemb, void *stream); -class LLCurlHandleHandler : public LLSingleton -{ -public: - static CURL* the_one_true_curl_handle; - LLCurlHandleHandler(); - static CURL* CreateCurlHandle(); -}; - class LLCurl { LOG_CLASS(LLCurl); @@ -196,6 +188,8 @@ public: static CURL* newEasyHandle() ; static void deleteEasyHandle(CURL* handle) ; + static CURL* createStandardCurlHandle(); + private: static std::string sCAPath; static std::string sCAFile; @@ -205,6 +199,7 @@ private: static LLMutex* sHandleMutexp ; static S32 sTotalHandles ; static S32 sMaxHandles; + static CURL* sCurlTemplateStandardHandle; public: static bool sNotQuitting; static F32 sCurlRequestTimeOut; -- cgit v1.2.3 From b49f6e1e744e7650fbea77e5744343d223e962a3 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 25 Apr 2013 16:21:32 -0700 Subject: Clean up LLSingleton work - special case to re-create instance if it's been deleted. --- indra/llcommon/llsingleton.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 84afeb563e..550e3c0d20 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -145,7 +145,9 @@ public: if (data.mInitState == DELETED) { llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; - } + data.mSingletonInstance = new DERIVED_TYPE(); + data.mInitState = INITIALIZING; + } // Fall into INITIALIZING case below if (data.mInitState == INITIALIZING) { -- cgit v1.2.3 From 39638b0de3734fea2d112161a3289b67f7594ba3 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 26 Apr 2013 15:54:03 -0700 Subject: Convert LLThreadSafeRefCount back to atomic ref counting. Reviewed by Kelly --- indra/llcommon/llthread.h | 90 +++++------------------------------------------ 1 file changed, 9 insertions(+), 81 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index a6eb14db9d..f51d985b5f 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -225,7 +225,6 @@ void LLThread::unlockData() // see llmemory.h for LLPointer<> definition -#if (1) // Old code - see comment below class LL_COMMON_API LLThreadSafeRefCount { public: @@ -243,99 +242,28 @@ public: LLThreadSafeRefCount(const LLThreadSafeRefCount&); LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) { - if (sMutex) - { - sMutex->lock(); - } mRef = 0; - if (sMutex) - { - sMutex->unlock(); - } return *this; } - - void ref() { - if (sMutex) sMutex->lock(); mRef++; - if (sMutex) sMutex->unlock(); } - S32 unref() + void unref() { llassert(mRef >= 1); - if (sMutex) sMutex->lock(); - S32 res = --mRef; - if (sMutex) sMutex->unlock(); - if (0 == res) - { - delete this; - return 0; + if ((--mRef) == 0) // See note in llapr.h on atomic decrement operator return value. + { + // If we hit zero, the caller should be the only smart pointer owning the object and we can delete it. + // It is technically possible for a vanilla pointer to mess this up, or another thread to + // jump in, find this object, create another smart pointer and end up dangling, but if + // the code is that bad and not thread-safe, it's trouble already. + delete this; } - return res; - } - S32 getNumRefs() const - { - return mRef; } -private: - S32 mRef; -}; - -#else - // New code - This was from https://bitbucket.org/lindenlab/viewer-cat/commits/b03bb43e4ead57f904cb3c1e9745dc8460de6efc - // and attempts - -class LL_COMMON_API LLThreadSafeRefCount -{ -public: - static void initThreadSafeRefCount(); // creates sMutex - static void cleanupThreadSafeRefCount(); // destroys sMutex - -private: - static LLMutex* sMutex; - -protected: - virtual ~LLThreadSafeRefCount(); // use unref() - -public: - LLThreadSafeRefCount(); - LLThreadSafeRefCount(const LLThreadSafeRefCount&); - LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) - { - mRef = 0; - return *this; - } - - void ref() - { - mRef++; - } - - S32 unref() - { - llassert(mRef >= 1); - bool time_to_die = (mRef == 1); - if (time_to_die) - { - if (sMutex) sMutex->lock(); - // Looks redundant, but is very much not - // We need to check again once we've acquired the lock - // so that two threads who get into the if in parallel - // don't both attempt to the delete. - // - mRef--; // Simon: why not if (mRef == 1) delete this; ? There still seems to be a window where mRef could be modified - if (mRef == 0) - delete this; - if (sMutex) sMutex->unlock(); - return 0; - } - return --mRef; - } S32 getNumRefs() const { const S32 currentVal = mRef.CurrentValue(); @@ -345,7 +273,7 @@ public: private: LLAtomic32< S32 > mRef; }; -#endif // new code + /** * intrusive pointer support for LLThreadSafeRefCount -- cgit v1.2.3 From f9850aa5d2fbed3e039ac1a1015ff73065664f17 Mon Sep 17 00:00:00 2001 From: Monty Brandenberg Date: Mon, 29 Apr 2013 17:09:13 -0400 Subject: BUG-2295/MAINT-2624 [FIXED] Crash in HttpOpRequest::stageFromActive w/ Content-Range Don't rely on a response body being present should a Content-Range header be parsed. Unit tests captured the original crash and confirm the fix. --- indra/llcorehttp/_httpoprequest.cpp | 10 +- indra/llcorehttp/httpresponse.h | 9 +- indra/llcorehttp/tests/test_httprequest.hpp | 152 ++++++++++++++++++++++++- indra/llcorehttp/tests/test_llcorehttp_peer.py | 84 +++++++++++--- 4 files changed, 231 insertions(+), 24 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 89dcd334f4..12eed06b10 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. + * Copyright (C) 2012-2013, 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 @@ -186,9 +186,11 @@ void HttpOpRequest::stageFromActive(HttpService * service) if (mReplyLength) { // If non-zero, we received and processed a Content-Range - // header with the response. Verify that what it says - // is consistent with the received data. - if (mReplyLength != mReplyBody->size()) + // header with the response. If there is received data + // (and there may not be due to protocol violations, + // HEAD requests, etc., see BUG-2295) Verify that what it + // says is consistent with the received data. + if (mReplyBody && mReplyBody->size() && mReplyLength != mReplyBody->size()) { // Not as expected, fail the request mStatus = HttpStatus(HttpStatus::LLCORE, HE_INV_CONTENT_RANGE_HDR); diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h index 4a481db6ac..f19b521fbf 100644 --- a/indra/llcorehttp/httpresponse.h +++ b/indra/llcorehttp/httpresponse.h @@ -48,8 +48,9 @@ class HttpHeaders; /// individual pieces of the response. /// /// Typical usage will have the caller interrogate the object -/// and return from the handler callback. Instances are refcounted -/// and callers can bump the count and retain the object as needed. +/// during the handler callback and then simply returning. +/// But instances are refcounted and and callers can add a +/// reference and hold onto the object after the callback. /// /// Threading: Not intrinsically thread-safe. /// @@ -119,6 +120,10 @@ public: /// caller is going to have to make assumptions on receipt of /// a 206 status. The @full value may also be zero in cases of /// parsing problems or a wild-carded length response. + /// + /// These values will not necessarily agree with the data in + /// the body itself (if present). The BufferArray object + /// is authoritative for actual data length. void getRange(unsigned int * offset, unsigned int * length, unsigned int * full) const { *offset = mReplyOffset; diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index e5488cf941..16f39845bb 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. + * Copyright (C) 2012-2013, 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 @@ -2650,6 +2650,156 @@ void HttpRequestTestObjectType::test<21>() } } +// BUG-2295 Tests - Content-Range header received but no body +template <> template <> +void HttpRequestTestObjectType::test<22>() +{ + ScopedCurlInit ready; + + std::string url_base(get_base_url()); + // std::cerr << "Base: " << url_base << std::endl; + + set_test_name("BUG-2295"); + + // Handler can be stack-allocated *if* there are no dangling + // references to it after completion of this method. + // Create before memory record as the string copy will bump numbers. + TestHandler2 handler(this, "handler"); + + // record the total amount of dynamically allocated memory + mMemTotal = GetMemTotal(); + mHandlerCalls = 0; + + HttpRequest * req = NULL; + + try + { + // Get singletons created + HttpRequest::createService(); + + // Start threading early so that thread memory is invariant + // over the test. + HttpRequest::startThread(); + + // create a new ref counted object with an implicit reference + req = new HttpRequest(); + ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); + + // ====================================== + // Issue bug2295 GETs that will get a 206 + // ====================================== + mStatus = HttpStatus(206); + static const int test_count(3); + for (int i(0); i < test_count; ++i) + { + char buffer[128]; + sprintf(buffer, "/bug2295/%d/", i); + HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, + 0U, + url_base + buffer, + 0, + 25, + NULL, + NULL, + &handler); + ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); + } + + // Run the notification pump. + int count(0); + int limit(10); + while (count++ < limit && mHandlerCalls < test_count) + { + req->update(1000000); + usleep(100000); + } + ensure("Request executed in reasonable time", count < limit); + ensure("One handler invocation for each request", mHandlerCalls == test_count); + + // ====================================== + // Issue bug2295 GETs that will get a libcurl 18 (PARTIAL_FILE) + // ====================================== + mStatus = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_PARTIAL_FILE); + static const int test2_count(1); + for (int i(0); i < test2_count; ++i) + { + char buffer[128]; + sprintf(buffer, "/bug2295/00000012/%d/", i); + HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, + 0U, + url_base + buffer, + 0, + 25, + NULL, + NULL, + &handler); + ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); + } + + // Run the notification pump. + count = 0; + limit = 10; + while (count++ < limit && mHandlerCalls < (test_count + test2_count)) + { + req->update(1000000); + usleep(100000); + } + ensure("Request executed in reasonable time", count < limit); + ensure("One handler invocation for each request", mHandlerCalls == (test_count + test2_count)); + + // ====================================== + // Okay, request a shutdown of the servicing thread + // ====================================== + mStatus = HttpStatus(); + HttpHandle handle = req->requestStopThread(&handler); + ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); + + // Run the notification pump again + count = 0; + limit = 10; + while (count++ < limit && mHandlerCalls < (test_count + test2_count + 1)) + { + req->update(1000000); + usleep(100000); + } + ensure("Second request executed in reasonable time", count < limit); + ensure("Second handler invocation", mHandlerCalls == (test_count + test2_count + 1)); + + // See that we actually shutdown the thread + count = 0; + limit = 10; + while (count++ < limit && ! HttpService::isStopped()) + { + usleep(100000); + } + ensure("Thread actually stopped running", HttpService::isStopped()); + + // release the request object + delete req; + req = NULL; + + // Shut down service + HttpRequest::destroyService(); + + ensure("4 + 1 handler calls on the way out", (test_count + test2_count + 1) == mHandlerCalls); + +#if defined(WIN32) + // Can only do this memory test on Windows. On other platforms, + // the LL logging system holds on to memory and produces what looks + // like memory leaks... + + // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); + ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); +#endif + } + catch (...) + { + stop_thread(req); + delete req; + HttpRequest::destroyService(); + throw; + } +} } // end namespace tut diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py index 75a3c39ef2..7f8f765366 100644 --- a/indra/llcorehttp/tests/test_llcorehttp_peer.py +++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py @@ -9,7 +9,7 @@ $LicenseInfo:firstyear=2008&license=viewerlgpl$ Second Life Viewer Source Code -Copyright (C) 2012, Linden Research, Inc. +Copyright (C) 2012-2013, 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 @@ -47,6 +47,26 @@ from testrunner import freeport, run, debug, VERBOSE class TestHTTPRequestHandler(BaseHTTPRequestHandler): """This subclass of BaseHTTPRequestHandler is to receive and echo LLSD-flavored messages sent by the C++ LLHTTPClient. + + Target URLs are fairly free-form and are assembled by + concatinating fragments. Currently defined fragments + are: + - '/reflect/' Request headers are bounced back to caller + after prefixing with 'X-Reflect-' + - '/fail/' Body of request can contain LLSD with + 'reason' string and 'status' integer + which will become response header. + - '/bug2295/' 206 response, no data in body: + -- '/bug2295/0/' "Content-Range: bytes 0-75/2983" + -- '/bug2295/1/' "Content-Range: bytes 0-75/*" + -- '/bug2295/2/' "Content-Range: bytes 0-75/2983", + "Content-Length: 0" + -- '/bug2295/00000018/0/' Generates PARTIAL_FILE (18) error in libcurl. + "Content-Range: bytes 0-75/2983", + "Content-Length: 76" + + Some combinations make no sense, there's no effort to protect + you from that. """ def read(self): # The following logic is adapted from the library module @@ -107,22 +127,7 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler): if "/sleep/" in self.path: time.sleep(30) - if "fail" not in self.path: - data = data.copy() # we're going to modify - # Ensure there's a "reply" key in data, even if there wasn't before - data["reply"] = data.get("reply", llsd.LLSD("success")) - response = llsd.format_xml(data) - debug("success: %s", response) - self.send_response(200) - if "/reflect/" in self.path: - self.reflect_headers() - self.send_header("Content-type", "application/llsd+xml") - self.send_header("Content-Length", str(len(response))) - self.send_header("X-LL-Special", "Mememememe"); - self.end_headers() - if withdata: - self.wfile.write(response) - else: # fail requested + if "fail" in self.path: status = data.get("status", 500) # self.responses maps an int status to a (short, long) pair of # strings. We want the longer string. That's why we pass a string @@ -138,6 +143,51 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler): if "/reflect/" in self.path: self.reflect_headers() self.end_headers() + elif "/bug2295/" in self.path: + # Test for https://jira.secondlife.com/browse/BUG-2295 + # + # Client can receive a header indicating data should + # appear in the body without actually getting the body. + # Library needs to defend against this case. + # + if "/bug2295/0/" in self.path: + self.send_response(206) + self.send_header("Content-Range", "bytes 0-75/2983") + elif "/bug2295/1/" in self.path: + self.send_response(206) + self.send_header("Content-Range", "bytes 0-75/*") + elif "/bug2295/2/" in self.path: + self.send_response(206) + self.send_header("Content-Range", "bytes 0-75/2983") + self.send_header("Content-Length", "0") + elif "/bug2295/00000012/0/" in self.path: + self.send_response(206) + self.send_header("Content-Range", "bytes 0-75/2983") + self.send_header("Content-Length", "76") + else: + # Unknown request + self.send_response(400) + if "/reflect/" in self.path: + self.reflect_headers() + self.send_header("Content-type", "text/plain") + self.end_headers() + # No data + else: + # Normal response path + data = data.copy() # we're going to modify + # Ensure there's a "reply" key in data, even if there wasn't before + data["reply"] = data.get("reply", llsd.LLSD("success")) + response = llsd.format_xml(data) + debug("success: %s", response) + self.send_response(200) + if "/reflect/" in self.path: + self.reflect_headers() + self.send_header("Content-type", "application/llsd+xml") + self.send_header("Content-Length", str(len(response))) + self.send_header("X-LL-Special", "Mememememe"); + self.end_headers() + if withdata: + self.wfile.write(response) def reflect_headers(self): for name in self.headers.keys(): -- cgit v1.2.3 From 348d4b66806cca07c91cab63f810d3d986e12377 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 1 May 2013 14:44:09 -0700 Subject: Manually pull in Richard's fixes for llcommon/llsingleton.h --- indra/llcommon/llsingleton.h | 101 +++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 43 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 550e3c0d20..40002313f1 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -61,6 +61,7 @@ class LLSingleton : private boost::noncopyable private: typedef enum e_init_state { + UNINITIALIZED, CONSTRUCTING, INITIALIZING, INITIALIZED, @@ -68,23 +69,23 @@ private: } EInitState; // stores pointer to singleton instance - // and tracks initialization state of singleton - struct SingletonInstanceData + struct SingletonLifetimeManager { - EInitState mInitState; - DERIVED_TYPE* mSingletonInstance; - - SingletonInstanceData() - : mSingletonInstance(NULL), - mInitState(CONSTRUCTING) + SingletonLifetimeManager() + { + construct(); + } + + static void construct() { - mSingletonInstance = new DERIVED_TYPE(); - mInitState = INITIALIZING; + sData.mInitState = CONSTRUCTING; + sData.mInstance = new DERIVED_TYPE(); + sData.mInitState = INITIALIZING; } - ~SingletonInstanceData() + ~SingletonLifetimeManager() { - if (mInitState != DELETED) + if (sData.mInitState != DELETED) { deleteSingleton(); } @@ -94,9 +95,8 @@ private: public: virtual ~LLSingleton() { - SingletonInstanceData& data = getData(); - data.mSingletonInstance = NULL; - data.mInitState = DELETED; + sData.mInstance = NULL; + sData.mInitState = DELETED; } /** @@ -121,42 +121,46 @@ public: */ static void deleteSingleton() { - delete getData().mSingletonInstance; - getData().mSingletonInstance = NULL; - getData().mInitState = DELETED; + delete sData.mInstance; + sData.mInstance = NULL; + sData.mInitState = DELETED; } - static SingletonInstanceData& getData() - { - // this is static to cache the lookup results - static SingletonInstanceData sData; - return sData; - } static DERIVED_TYPE* getInstance() { - SingletonInstanceData& data = getData(); + static SingletonLifetimeManager sLifeTimeMgr; - if (data.mInitState == CONSTRUCTING) + switch (sData.mInitState) { + case UNINITIALIZED: + // should never be uninitialized at this point + llassert(false); + return NULL; + case CONSTRUCTING: llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << llendl; - } - - if (data.mInitState == DELETED) - { - llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; - data.mSingletonInstance = new DERIVED_TYPE(); - data.mInitState = INITIALIZING; - } // Fall into INITIALIZING case below - - if (data.mInitState == INITIALIZING) - { + return NULL; + case INITIALIZING: // go ahead and flag ourselves as initialized so we can be reentrant during initialization - data.mInitState = INITIALIZED; - data.mSingletonInstance->initSingleton(); + sData.mInitState = INITIALIZED; + sData.mInstance->initSingleton(); + return sData.mInstance; + case INITIALIZED: + return sData.mInstance; + case DELETED: + llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; + SingletonLifetimeManager::construct(); + sData.mInitState = INITIALIZED; + sData.mInstance->initSingleton(); + return sData.mInstance; } - - return data.mSingletonInstance; + + return NULL; + } + + static DERIVED_TYPE* getIfExists() + { + return sData.mInstance; } // Reference version of getInstance() @@ -170,18 +174,29 @@ public: // Use this to avoid accessing singletons before the can safely be constructed static bool instanceExists() { - return getData().mInitState == INITIALIZED; + return sData.mInitState == INITIALIZED; } // Has this singleton already been deleted? // Use this to avoid accessing singletons from a static object's destructor static bool destroyed() { - return getData().mInitState == DELETED; + return sData.mInitState == DELETED; } private: + virtual void initSingleton() {} + + struct SingletonData + { + EInitState mInitState; + DERIVED_TYPE* mInstance; + }; + static SingletonData sData; }; +template +typename LLSingleton::SingletonData LLSingleton::sData; + #endif -- cgit v1.2.3 From 88ae31a3adcdc9fabf45b4a7cf1e53bd08615875 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 2 May 2013 13:31:21 -0700 Subject: Fix line endings --- indra/newview/llviewerwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 136e61389a..c65caea3ec 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2036,8 +2036,8 @@ void LLViewerWindow::shutdownViews() } llinfos << "Global views cleaned." << llendl ; - LLNotificationsUI::LLToast::cleanupToasts(); - llinfos << "Leftover toast cleaned up." << llendl; + LLNotificationsUI::LLToast::cleanupToasts(); + llinfos << "Leftover toast cleaned up." << llendl; // DEV-40930: Clear sModalStack. Otherwise, any LLModalDialog left open // will crump with LL_ERRS. -- cgit v1.2.3 From 299433c544d23888169109c2ce5c4807f0d882b4 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 2 May 2013 15:13:05 -0700 Subject: Fix the cmake fix --- indra/llplugin/slplugin/CMakeLists.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt index 5d2b1d922e..20088293ff 100644 --- a/indra/llplugin/slplugin/CMakeLists.txt +++ b/indra/llplugin/slplugin/CMakeLists.txt @@ -50,13 +50,21 @@ add_executable(SLPlugin ${SLPlugin_SOURCE_FILES} ) +if (WINDOWS) set_target_properties(SLPlugin PROPERTIES - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/slplugin_info.plist -if (WINDOWS) LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMTD\"" -endif (WINDOWS) ) +elseif (DARWIN) +set_target_properties(SLPlugin + PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/slplugin_info.plist + ) +else () # LINUX +set_target_properties(SLPlugin + PROPERTIES + ) +endif () target_link_libraries(SLPlugin ${LLPLUGIN_LIBRARIES} -- cgit v1.2.3 From 291b38717805f7de41af447c651c5b91352d0a51 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 2 May 2013 15:36:26 -0700 Subject: Cmake doesn't like me --- indra/llplugin/slplugin/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt index 20088293ff..6e7fefeb21 100644 --- a/indra/llplugin/slplugin/CMakeLists.txt +++ b/indra/llplugin/slplugin/CMakeLists.txt @@ -55,15 +55,11 @@ set_target_properties(SLPlugin PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMTD\"" ) -elseif (DARWIN) +else () set_target_properties(SLPlugin PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/slplugin_info.plist ) -else () # LINUX -set_target_properties(SLPlugin - PROPERTIES - ) endif () target_link_libraries(SLPlugin -- cgit v1.2.3 From f5e8457e4e4fad1d823c51d86c01fdc2ae08401c Mon Sep 17 00:00:00 2001 From: Monty Brandenberg Date: Mon, 6 May 2013 12:12:05 -0400 Subject: BUG-2295/MAINT-2624 unexpected crash around Content-Range: header processing Not certain what the source of the short data is with one resident but I'm going to make these problems retryable as they are transport-related. Lift the retry detection into a method that should be reusable by others interested in determining what is retryable. Trace output handling on the libcurl debug callback was attrocious. Some unsafe length handling on my part was protected by a second layer of defense. Made that correct and more useful by logging actual data sizes during trace. --- indra/llcorehttp/_httpoprequest.cpp | 12 ++--- indra/llcorehttp/_httppolicy.cpp | 28 ++-------- indra/llcorehttp/httpcommon.cpp | 34 +++++++++++- indra/llcorehttp/httpcommon.h | 8 ++- indra/llcorehttp/tests/test_httprequest.hpp | 74 ++++++++++++++++++++------ indra/llcorehttp/tests/test_llcorehttp_peer.py | 13 ++++- 6 files changed, 121 insertions(+), 48 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 12eed06b10..207ed8e1e4 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -669,7 +669,7 @@ int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffe std::string safe_line; std::string tag; bool logit(false); - len = (std::min)(len, size_t(256)); // Keep things reasonable in all cases + const size_t log_len((std::min)(len, size_t(256))); // Keep things reasonable in all cases switch (info) { @@ -677,7 +677,7 @@ int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffe if (op->mTracing >= HTTP_TRACE_CURL_HEADERS) { tag = "TEXT"; - escape_libcurl_debug_data(buffer, len, true, safe_line); + escape_libcurl_debug_data(buffer, log_len, true, safe_line); logit = true; } break; @@ -686,7 +686,7 @@ int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffe if (op->mTracing >= HTTP_TRACE_CURL_HEADERS) { tag = "HEADERIN"; - escape_libcurl_debug_data(buffer, len, true, safe_line); + escape_libcurl_debug_data(buffer, log_len, true, safe_line); logit = true; } break; @@ -695,7 +695,7 @@ int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffe if (op->mTracing >= HTTP_TRACE_CURL_HEADERS) { tag = "HEADEROUT"; - escape_libcurl_debug_data(buffer, 2 * len, true, safe_line); // Goes out as one line + escape_libcurl_debug_data(buffer, log_len, true, safe_line); // Goes out as one line unlike header_in logit = true; } break; @@ -707,7 +707,7 @@ int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffe logit = true; if (op->mTracing >= HTTP_TRACE_CURL_BODIES) { - escape_libcurl_debug_data(buffer, len, false, safe_line); + escape_libcurl_debug_data(buffer, log_len, false, safe_line); } else { @@ -725,7 +725,7 @@ int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffe logit = true; if (op->mTracing >= HTTP_TRACE_CURL_BODIES) { - escape_libcurl_debug_data(buffer, len, false, safe_line); + escape_libcurl_debug_data(buffer, log_len, false, safe_line); } else { diff --git a/indra/llcorehttp/_httppolicy.cpp b/indra/llcorehttp/_httppolicy.cpp index 76c1e22431..014bd37e2e 100644 --- a/indra/llcorehttp/_httppolicy.cpp +++ b/indra/llcorehttp/_httppolicy.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. + * Copyright (C) 2012-2013, 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 @@ -319,33 +319,13 @@ bool HttpPolicy::cancel(HttpHandle handle) bool HttpPolicy::stageAfterCompletion(HttpOpRequest * op) { - static const HttpStatus cant_connect(HttpStatus::EXT_CURL_EASY, CURLE_COULDNT_CONNECT); - static const HttpStatus cant_res_proxy(HttpStatus::EXT_CURL_EASY, CURLE_COULDNT_RESOLVE_PROXY); - static const HttpStatus cant_res_host(HttpStatus::EXT_CURL_EASY, CURLE_COULDNT_RESOLVE_HOST); - static const HttpStatus send_error(HttpStatus::EXT_CURL_EASY, CURLE_SEND_ERROR); - static const HttpStatus recv_error(HttpStatus::EXT_CURL_EASY, CURLE_RECV_ERROR); - static const HttpStatus upload_failed(HttpStatus::EXT_CURL_EASY, CURLE_UPLOAD_FAILED); - static const HttpStatus op_timedout(HttpStatus::EXT_CURL_EASY, CURLE_OPERATION_TIMEDOUT); - static const HttpStatus post_error(HttpStatus::EXT_CURL_EASY, CURLE_HTTP_POST_ERROR); - // Retry or finalize if (! op->mStatus) { - // If this failed, we might want to retry. Have to inspect - // the status a little more deeply for those reasons worth retrying... - if (op->mPolicyRetries < op->mPolicyRetryLimit && - ((op->mStatus.isHttpStatus() && op->mStatus.mType >= 499 && op->mStatus.mType <= 599) || - cant_connect == op->mStatus || - cant_res_proxy == op->mStatus || - cant_res_host == op->mStatus || - send_error == op->mStatus || - recv_error == op->mStatus || - upload_failed == op->mStatus || - op_timedout == op->mStatus || - post_error == op->mStatus)) + // If this failed, we might want to retry. + if (op->mPolicyRetries < op->mPolicyRetryLimit && op->mStatus.isRetryable()) { - // Okay, worth a retry. We include 499 in this test as - // it's the old 'who knows?' error from many grid services... + // Okay, worth a retry. retryOp(op); return true; // still active/ready } diff --git a/indra/llcorehttp/httpcommon.cpp b/indra/llcorehttp/httpcommon.cpp index f2fcbf77a3..0738760763 100644 --- a/indra/llcorehttp/httpcommon.cpp +++ b/indra/llcorehttp/httpcommon.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. + * Copyright (C) 2012-2013, 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 @@ -116,6 +116,7 @@ std::string HttpStatus::toString() const { 415, "Unsupported Media Type" }, { 416, "Requested range not satisfiable" }, { 417, "Expectation Failed" }, + { 499, "Linden Catch-All" }, { 500, "Internal Server Error" }, { 501, "Not Implemented" }, { 502, "Bad Gateway" }, @@ -174,6 +175,37 @@ std::string HttpStatus::toString() const } return std::string("Unknown error"); } + + +// Pass true on statuses that might actually be cleared by a +// retry. Library failures, calling problems, etc. aren't +// going to be fixed by squirting bits all over the Net. +bool HttpStatus::isRetryable() const +{ + static const HttpStatus cant_connect(HttpStatus::EXT_CURL_EASY, CURLE_COULDNT_CONNECT); + static const HttpStatus cant_res_proxy(HttpStatus::EXT_CURL_EASY, CURLE_COULDNT_RESOLVE_PROXY); + static const HttpStatus cant_res_host(HttpStatus::EXT_CURL_EASY, CURLE_COULDNT_RESOLVE_HOST); + static const HttpStatus send_error(HttpStatus::EXT_CURL_EASY, CURLE_SEND_ERROR); + static const HttpStatus recv_error(HttpStatus::EXT_CURL_EASY, CURLE_RECV_ERROR); + static const HttpStatus upload_failed(HttpStatus::EXT_CURL_EASY, CURLE_UPLOAD_FAILED); + static const HttpStatus op_timedout(HttpStatus::EXT_CURL_EASY, CURLE_OPERATION_TIMEDOUT); + static const HttpStatus post_error(HttpStatus::EXT_CURL_EASY, CURLE_HTTP_POST_ERROR); + static const HttpStatus partial_file(HttpStatus::EXT_CURL_EASY, CURLE_PARTIAL_FILE); + static const HttpStatus inv_cont_range(HttpStatus::LLCORE, HE_INV_CONTENT_RANGE_HDR); + + return ((isHttpStatus() && mType >= 499 && mType <= 599) || // Include special 499 in retryables + *this == cant_connect || // Connection reset/endpoint problems + *this == cant_res_proxy || // DNS problems + *this == cant_res_host || // DNS problems + *this == send_error || // General socket problems + *this == recv_error || // General socket problems + *this == upload_failed || // Transport problem + *this == op_timedout || // Timer expired + *this == post_error || // Transport problem + *this == partial_file || // Data inconsistency in response + *this == inv_cont_range); // Short data read disagrees with content-range +} + } // end namespace LLCore diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index c0d4ec5aad..41fb5164cf 100644 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. + * Copyright (C) 2012-2013, 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 @@ -303,6 +303,12 @@ struct HttpStatus { return mType >= type_enum_t(100) && mType <= type_enum_t(999); } + + /// Returns true if the status is one that will be retried + /// internally. Provided for external consumption for cases + /// where that logic needs to be replicated. Only applies + /// to failed statuses, successful statuses will return false. + bool isRetryable() const; }; // end struct HttpStatus diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index 16f39845bb..ff84b04070 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -2670,10 +2670,15 @@ void HttpRequestTestObjectType::test<22>() mMemTotal = GetMemTotal(); mHandlerCalls = 0; + HttpOptions * options = NULL; HttpRequest * req = NULL; try { + // options set + options = new HttpOptions(); + options->setRetries(1); // Partial_File is retryable and can timeout in here + // Get singletons created HttpRequest::createService(); @@ -2699,7 +2704,7 @@ void HttpRequestTestObjectType::test<22>() url_base + buffer, 0, 25, - NULL, + options, NULL, &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -2707,18 +2712,19 @@ void HttpRequestTestObjectType::test<22>() // Run the notification pump. int count(0); - int limit(10); + int limit(30); while (count++ < limit && mHandlerCalls < test_count) { req->update(1000000); usleep(100000); } - ensure("Request executed in reasonable time", count < limit); - ensure("One handler invocation for each request", mHandlerCalls == test_count); + ensure("Request executed in reasonable time - ms1", count < limit); + ensure("One handler invocation for each request - ms1", mHandlerCalls == test_count); // ====================================== // Issue bug2295 GETs that will get a libcurl 18 (PARTIAL_FILE) // ====================================== + mHandlerCalls = 0; mStatus = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_PARTIAL_FILE); static const int test2_count(1); for (int i(0); i < test2_count; ++i) @@ -2730,7 +2736,39 @@ void HttpRequestTestObjectType::test<22>() url_base + buffer, 0, 25, + options, NULL, + &handler); + ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); + } + + // Run the notification pump. + count = 0; + limit = 30; + while (count++ < limit && mHandlerCalls < test2_count) + { + req->update(1000000); + usleep(100000); + } + ensure("Request executed in reasonable time - ms2", count < limit); + ensure("One handler invocation for each request - ms2", mHandlerCalls == test2_count); + + // ====================================== + // Issue bug2295 GETs that will get an llcorehttp HE_INV_CONTENT_RANGE_HDR status + // ====================================== + mHandlerCalls = 0; + mStatus = HttpStatus(HttpStatus::LLCORE, HE_INV_CONTENT_RANGE_HDR); + static const int test3_count(1); + for (int i(0); i < test3_count; ++i) + { + char buffer[128]; + sprintf(buffer, "/bug2295/inv_cont_range/%d/", i); + HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, + 0U, + url_base + buffer, + 0, + 25, + options, NULL, &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -2738,32 +2776,33 @@ void HttpRequestTestObjectType::test<22>() // Run the notification pump. count = 0; - limit = 10; - while (count++ < limit && mHandlerCalls < (test_count + test2_count)) + limit = 30; + while (count++ < limit && mHandlerCalls < test3_count) { req->update(1000000); usleep(100000); } - ensure("Request executed in reasonable time", count < limit); - ensure("One handler invocation for each request", mHandlerCalls == (test_count + test2_count)); + ensure("Request executed in reasonable time - ms3", count < limit); + ensure("One handler invocation for each request - ms3", mHandlerCalls == test3_count); // ====================================== // Okay, request a shutdown of the servicing thread // ====================================== mStatus = HttpStatus(); + mHandlerCalls = 0; HttpHandle handle = req->requestStopThread(&handler); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again count = 0; - limit = 10; - while (count++ < limit && mHandlerCalls < (test_count + test2_count + 1)) + limit = 20; + while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); usleep(100000); } - ensure("Second request executed in reasonable time", count < limit); - ensure("Second handler invocation", mHandlerCalls == (test_count + test2_count + 1)); + ensure("Shutdown request executed in reasonable time", count < limit); + ensure("Shutdown handler invocation", mHandlerCalls == 1); // See that we actually shutdown the thread count = 0; @@ -2773,7 +2812,14 @@ void HttpRequestTestObjectType::test<22>() usleep(100000); } ensure("Thread actually stopped running", HttpService::isStopped()); - + + // release options + if (options) + { + options->release(); + options = NULL; + } + // release the request object delete req; req = NULL; @@ -2781,8 +2827,6 @@ void HttpRequestTestObjectType::test<22>() // Shut down service HttpRequest::destroyService(); - ensure("4 + 1 handler calls on the way out", (test_count + test2_count + 1) == mHandlerCalls); - #if defined(WIN32) // Can only do this memory test on Windows. On other platforms, // the LL logging system holds on to memory and produces what looks diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py index 7f8f765366..8796ae57c7 100644 --- a/indra/llcorehttp/tests/test_llcorehttp_peer.py +++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py @@ -35,6 +35,10 @@ import time import select import getopt from threading import Thread +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from SocketServer import ThreadingMixIn @@ -64,6 +68,7 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler): -- '/bug2295/00000018/0/' Generates PARTIAL_FILE (18) error in libcurl. "Content-Range: bytes 0-75/2983", "Content-Length: 76" + -- '/bug2295/inv_cont_range/0/' Generates HE_INVALID_CONTENT_RANGE error in llcorehttp. Some combinations make no sense, there's no effort to protect you from that. @@ -150,6 +155,7 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler): # appear in the body without actually getting the body. # Library needs to defend against this case. # + body = None if "/bug2295/0/" in self.path: self.send_response(206) self.send_header("Content-Range", "bytes 0-75/2983") @@ -164,6 +170,10 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler): self.send_response(206) self.send_header("Content-Range", "bytes 0-75/2983") self.send_header("Content-Length", "76") + elif "/bug2295/inv_cont_range/0/" in self.path: + self.send_response(206) + self.send_header("Content-Range", "bytes 0-75/2983") + body = "Some text, but not enough." else: # Unknown request self.send_response(400) @@ -171,7 +181,8 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler): self.reflect_headers() self.send_header("Content-type", "text/plain") self.end_headers() - # No data + if body: + self.wfile.write(body) else: # Normal response path data = data.copy() # we're going to modify -- cgit v1.2.3 From dbfcd6c9c5709b74365c2538ba312685b09d22bf Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 May 2013 17:20:33 -0500 Subject: Optimization -- don't draw glow in alpha pool unless needed --- indra/llmath/llvolume.cpp | 6 +++- indra/llprimitive/llmodel.cpp | 37 +++++++++++++++++++ indra/llprimitive/llmodel.h | 4 ++- indra/newview/lldrawpoolalpha.cpp | 3 +- indra/newview/llspatialpartition.cpp | 3 +- indra/newview/llspatialpartition.h | 5 +-- indra/newview/llviewerpartsim.cpp | 2 +- indra/newview/llviewerpartsource.cpp | 2 +- indra/newview/llvopartgroup.cpp | 70 ++++++++++++++++++++++++------------ 9 files changed, 101 insertions(+), 31 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 602f2c29e5..7751ef87ee 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4520,7 +4520,11 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) S32 tc_size = (mNumVertices*sizeof(LLVector2)+0xF) & ~0xF; LLVector4a::memcpyNonAliased16((F32*) mPositions, (F32*) src.mPositions, vert_size); - LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) src.mNormals, vert_size); + + if (src.mNormals) + { + LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) src.mNormals, vert_size); + } if(src.mTexCoords) { diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index ef6eb75a6b..e236f98fe6 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1122,6 +1122,43 @@ void LLModel::getNormalizedScaleTranslation(LLVector3& scale_out, LLVector3& tra translation_out = mNormalizedTranslation; } +LLVector3 LLModel::getTransformedCenter(const LLMatrix4& mat) +{ + LLVector3 ret; + + if (!mVolumeFaces.empty()) + { + LLMatrix4a m; + m.loadu(mat); + + LLVector4a minv,maxv; + + LLVector4a t; + m.affineTransform(mVolumeFaces[0].mPositions[0], t); + minv = maxv = t; + + for (S32 i = 0; i < mVolumeFaces.size(); ++i) + { + LLVolumeFace& face = mVolumeFaces[i]; + + for (U32 j = 0; j < face.mNumVertices; ++j) + { + m.affineTransform(face.mPositions[j],t); + update_min_max(minv, maxv, t); + } + } + + minv.add(maxv); + minv.mul(0.5f); + + ret.set(minv.getF32ptr()); + } + + return ret; +} + + + void LLModel::setNumVolumeFaces(S32 count) { mVolumeFaces.resize(count); diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index 1cf528fd9f..aaafc55258 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -173,13 +173,15 @@ public: void optimizeVolumeFaces(); void offsetMesh( const LLVector3& pivotPoint ); void getNormalizedScaleTranslation(LLVector3& scale_out, LLVector3& translation_out); - + LLVector3 getTransformedCenter(const LLMatrix4& mat); + //reorder face list based on mMaterialList in this and reference so //order matches that of reference (material ordering touchup) bool matchMaterialOrder(LLModel* ref, int& refFaceCnt, int& modelFaceCnt ); bool isMaterialListSubset( LLModel* ref ); bool needToAddFaces( LLModel* ref, int& refFaceCnt, int& modelFaceCnt ); + std::vector mMaterialList; //data used for skin weights diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 6fa16825df..331744acb7 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -515,7 +515,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) // If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha. if (current_shader && draw_glow_for_this_partition && - params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE)) + params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE) && + (!params.mParticle || params.mHasGlow)) { static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_GLOW("Alpha Glow"); LLFastTimer t(FTM_RENDER_ALPHA_GLOW); diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 1ec56eb5f8..2a1d0d223c 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -4656,7 +4656,8 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, mDistance(0.f), mDrawMode(LLRender::TRIANGLES), mBlendFuncSrc(LLRender::BF_SOURCE_ALPHA), - mBlendFuncDst(LLRender::BF_ONE_MINUS_SOURCE_ALPHA) + mBlendFuncDst(LLRender::BF_ONE_MINUS_SOURCE_ALPHA), + mHasGlow(FALSE) { mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset); diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 08e77855c4..e9be93ce98 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -70,12 +70,12 @@ protected: public: void* operator new(size_t size) { - return ll_aligned_malloc_16(size); + return ll_aligned_malloc(size,64); } void operator delete(void* ptr) { - ll_aligned_free_16(ptr); + ll_aligned_free(ptr); } @@ -121,6 +121,7 @@ public: U32 mDrawMode; U32 mBlendFuncSrc; U32 mBlendFuncDst; + BOOL mHasGlow; struct CompareTexture { diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 21f1d2619c..96cd43a8ab 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -387,7 +387,7 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt) } // Do glow interpolation - part->mGlow.mV[3] = (U8) (lerp(part->mStartGlow, part->mEndGlow, frac)*255.f); + part->mGlow.mV[3] = (U8) llround(lerp(part->mStartGlow, part->mEndGlow, frac)*255.f); // Set the last update time to now. part->mLastUpdateTime = cur_time; diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp index 8c49ce646d..b6bbd6140d 100644 --- a/indra/newview/llviewerpartsource.cpp +++ b/indra/newview/llviewerpartsource.cpp @@ -313,7 +313,7 @@ void LLViewerPartSourceScript::update(const F32 dt) part->mStartGlow = mPartSysData.mPartData.mStartGlow; part->mEndGlow = mPartSysData.mPartData.mEndGlow; - part->mGlow = LLColor4U(0, 0, 0, (U8) (part->mStartGlow*255.f)); + part->mGlow = LLColor4U(0, 0, 0, (U8) llround(part->mStartGlow*255.f)); if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_DROP) { diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 53d67347d1..e5e627c1ea 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -273,6 +273,10 @@ void LLVOPartGroup::getBlendFunc(S32 idx, U32& src, U32& dst) src = part->mBlendFuncSource; dst = part->mBlendFuncDest; } + else + { + llerrs << "WTF?" << llendl; + } } LLVector3 LLVOPartGroup::getCameraPosition() const @@ -670,7 +674,7 @@ void LLVOPartGroup::getGeometry(S32 idx, } else { - pglow = LLColor4U(0, 0, 0, (U8) (255.f*part.mStartGlow)); + pglow = LLColor4U(0, 0, 0, (U8) llround(255.f*part.mStartGlow)); pcolor = part.mStartColor; } } @@ -685,10 +689,13 @@ void LLVOPartGroup::getGeometry(S32 idx, *colorsp++ = color; *colorsp++ = color; - *emissivep++ = pglow; - *emissivep++ = pglow; - *emissivep++ = part.mGlow; - *emissivep++ = part.mGlow; + //if (pglow.mV[3] || part.mGlow.mV[3]) + { //only write glow if it is not zero + *emissivep++ = pglow; + *emissivep++ = pglow; + *emissivep++ = part.mGlow; + *emissivep++ = part.mGlow; + } if (!(part.mFlags & LLPartData::LL_PART_EMISSIVE_MASK)) @@ -873,8 +880,17 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) LLStrider cur_col = colorsp + geom_idx; LLStrider cur_glow = emissivep + geom_idx; + LLColor4U* start_glow = cur_glow.get(); + object->getGeometry(facep->getTEOffset(), cur_vert, cur_norm, cur_tc, cur_col, cur_glow, cur_idx); + BOOL has_glow = FALSE; + + if (cur_glow.get() != start_glow) + { + has_glow = TRUE; + } + llassert(facep->getGeomCount() == 4); llassert(facep->getIndicesCount() == 6); @@ -894,26 +910,32 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) object->getBlendFunc(facep->getTEOffset(), bf_src, bf_dst); - if (idx >= 0 && - draw_vec[idx]->mTexture == facep->getTexture() && - draw_vec[idx]->mFullbright == fullbright && - draw_vec[idx]->mBlendFuncDst == bf_dst && - draw_vec[idx]->mBlendFuncSrc == bf_src) + + if (idx >= 0) { - if (draw_vec[idx]->mEnd == facep->getGeomIndex()-1) - { - batched = true; - draw_vec[idx]->mCount += facep->getIndicesCount(); - draw_vec[idx]->mEnd += facep->getGeomCount(); - draw_vec[idx]->mVSize = llmax(draw_vec[idx]->mVSize, vsize); - } - else if (draw_vec[idx]->mStart == facep->getGeomIndex()+facep->getGeomCount()+1) + LLDrawInfo* info = draw_vec[idx]; + + if (info->mTexture == facep->getTexture() && + info->mHasGlow == has_glow && + info->mFullbright == fullbright && + info->mBlendFuncDst == bf_dst && + info->mBlendFuncSrc == bf_src) { - batched = true; - draw_vec[idx]->mCount += facep->getIndicesCount(); - draw_vec[idx]->mStart -= facep->getGeomCount(); - draw_vec[idx]->mOffset = facep->getIndicesStart(); - draw_vec[idx]->mVSize = llmax(draw_vec[idx]->mVSize, vsize); + if (draw_vec[idx]->mEnd == facep->getGeomIndex()-1) + { + batched = true; + info->mCount += facep->getIndicesCount(); + info->mEnd += facep->getGeomCount(); + info->mVSize = llmax(draw_vec[idx]->mVSize, vsize); + } + else if (draw_vec[idx]->mStart == facep->getGeomIndex()+facep->getGeomCount()+1) + { + batched = true; + info->mCount += facep->getIndicesCount(); + info->mStart -= facep->getGeomCount(); + info->mOffset = facep->getIndicesStart(); + info->mVSize = llmax(draw_vec[idx]->mVSize, vsize); + } } } @@ -932,6 +954,8 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) info->mVSize = vsize; info->mBlendFuncDst = bf_dst; info->mBlendFuncSrc = bf_src; + info->mHasGlow = has_glow; + info->mParticle = TRUE; draw_vec.push_back(info); //for alpha sorting facep->setDrawInfo(info); -- cgit v1.2.3 From cd8e0b92e1c8f9f8544b1011e61c21c7789b93b7 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 9 May 2013 11:10:13 -0700 Subject: Tweak to ensure more avatar rendering info is sent to the simulator --- indra/newview/llavatarrenderinfoaccountant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 54144677f4..da4b6cf806 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -249,7 +249,7 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio { LLVOAvatar* avatar = dynamic_cast(*iter); if (avatar && - avatar->getRezzedStatus() == 2 && // Fully rezzed + avatar->getRezzedStatus() >= 2 && // Mostly rezzed (maybe without baked textures downloaded) !avatar->isDead() && // Not dead yet avatar->getObjectHost() == regionp->getHost()) // Ensure it's on the same region { -- cgit v1.2.3 From be9f71d16660e37fb058ddf05f20e6a80a272862 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 May 2013 15:40:02 -0500 Subject: MAINT-2647 Fix for some objects not rendering until first LoD switch/selection. --- indra/newview/lldrawable.cpp | 2 +- indra/newview/lldrawable.h | 1 - indra/newview/llviewerobject.cpp | 3 ++- indra/newview/llviewerobjectlist.cpp | 3 ++- indra/newview/pipeline.cpp | 5 ----- 5 files changed, 5 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 2e3a9119b8..31ab37f970 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -441,7 +441,7 @@ void LLDrawable::makeActive() } llassert(isAvatar() || isRoot() || mParent->isActive()); - } +} void LLDrawable::makeStatic(BOOL warning_enabled) diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 4608d16fec..4420a34fae 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -284,7 +284,6 @@ public: NEARBY_LIGHT = 0x00200000, // In gPipeline.mNearbyLightSet BUILT = 0x00400000, FORCE_INVISIBLE = 0x00800000, // stay invis until CLEAR_INVISIBLE is set (set of orphaned) - CLEAR_INVISIBLE = 0x01000000, // clear FORCE_INVISIBLE next draw frame REBUILD_SHADOW = 0x02000000, HAS_ALPHA = 0x04000000, RIGGED = 0x08000000, diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 9dc9932c86..e17b085eab 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -2137,7 +2137,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, if (mDrawable->isState(LLDrawable::FORCE_INVISIBLE) && !mOrphaned) { // lldebugs << "Clearing force invisible: " << mID << ":" << getPCodeString() << ":" << getPositionAgent() << llendl; - mDrawable->setState(LLDrawable::CLEAR_INVISIBLE); + mDrawable->clearState(LLDrawable::FORCE_INVISIBLE); + gPipeline.markRebuild( mDrawable, LLDrawable::REBUILD_ALL, TRUE ); } } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index fa79ac07e6..66615657d8 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -2064,8 +2064,9 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port) if (childp->mDrawable.notNull()) { // Make the drawable visible again and set the drawable parent - childp->mDrawable->setState(LLDrawable::CLEAR_INVISIBLE); + childp->mDrawable->clearState(LLDrawable::FORCE_INVISIBLE); childp->setDrawableParent(objectp->mDrawable); // LLViewerObjectList::findOrphans() + gPipeline.markRebuild( childp->mDrawable, LLDrawable::REBUILD_ALL, TRUE ); } // Make certain particles, icon and HUD aren't hidden diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 442c3ef124..16596f2574 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3320,11 +3320,6 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) { drawablep->setVisible(camera, NULL, FALSE); } - else if (drawablep->isState(LLDrawable::CLEAR_INVISIBLE)) - { - // clear invisible flag here to avoid single frame glitch - drawablep->clearState(LLDrawable::FORCE_INVISIBLE|LLDrawable::CLEAR_INVISIBLE); - } } if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) -- cgit v1.2.3 From 5717bcf4ae74b53b515c5f13027fed4475e65c9a Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 10 May 2013 12:15:25 -0700 Subject: MAINT-2672 Make windows flex/bison inputs identical to other platforms to make bison >= 2.7 work --- indra/lscript/lscript_compile/indra.l | 8 -------- indra/lscript/lscript_compile/indra.y | 11 ----------- 2 files changed, 19 deletions(-) (limited to 'indra') diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index ab0d31ec46..c5d11af22b 100755 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -79,17 +79,9 @@ void parse_string(); #define yyfree indra_free -#if LL_DARWIN int yyparse( void ); int yylex( void ); int yyerror(const char *fmt, ...); -#else -#if defined(__cplusplus) -extern "C" { int yyparse( void ); } -extern "C" { int yylex( void ); } -extern "C" { int yyerror(const char *fmt, ...); } -#endif -#endif %} diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y index 8df0e8ad83..a0a034d21c 100755 --- a/indra/lscript/lscript_compile/indra.y +++ b/indra/lscript/lscript_compile/indra.y @@ -2,12 +2,6 @@ #include "linden_common.h" #include "lscript_tree.h" - #if !LL_DARWIN - #ifdef __cplusplus - extern "C" { - #endif - #endif - int yylex(void); int yyparse( void ); int yyerror(const char *fmt, ...); @@ -22,11 +16,6 @@ #pragma warning( disable : 4065 ) // warning: switch statement contains 'default' but no 'case' labels #endif - #if !LL_DARWIN - #ifdef __cplusplus - } - #endif - #endif %} %union -- cgit v1.2.3 From 180dd12ed637c1f63a5013d25fbac002e1d94c93 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 10 May 2013 17:11:12 -0700 Subject: Add BuildVersion.cmake to great chain of life --- indra/cmake/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'indra') diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index 246b9680e8..10a23ea068 100755 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -12,6 +12,7 @@ set(cmake_SOURCE_FILES Audio.cmake BerkeleyDB.cmake Boost.cmake + BuildVersion.cmake CARes.cmake CMakeCopyIfDifferent.cmake ConfigurePkgConfig.cmake -- cgit v1.2.3 From 81ffd3fccac709a5903dd0d7572db50c50850347 Mon Sep 17 00:00:00 2001 From: Monty Brandenberg Date: Mon, 13 May 2013 18:32:03 -0400 Subject: Whinge reduction effort on the unit tests. Python 2.7 SocketServer library has new exception-throwing behavior when a client disconnects unannounced. Generally ignore exceptions as a result as we don't care about the server side. On HTTP trace-mode tests, spin a little faster and longer to give libcurl time to emit all the junk it wants to send us. Should reduce 'reasonable time' failures on tests <12> and <13>. --- indra/llcorehttp/tests/test_httprequest.hpp | 12 ++++----- indra/llcorehttp/tests/test_llcorehttp_peer.py | 35 +++++++++++++++++++++----- 2 files changed, 35 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index ff84b04070..e2021bac12 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -1226,11 +1226,11 @@ void HttpRequestTestObjectType::test<12>() // Run the notification pump. int count(0); - int limit(10); + int limit(200); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(10000); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1339,8 +1339,8 @@ void HttpRequestTestObjectType::test<13>() HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, 0U, url_base, - 0, - 0, + 0, + 0, opts, NULL, &handler); @@ -1352,11 +1352,11 @@ void HttpRequestTestObjectType::test<13>() // Run the notification pump. int count(0); - int limit(10); + int limit(200); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(10000); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py index 8796ae57c7..3c3af8dc75 100644 --- a/indra/llcorehttp/tests/test_llcorehttp_peer.py +++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py @@ -73,6 +73,8 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler): Some combinations make no sense, there's no effort to protect you from that. """ + ignore_exceptions = (Exception,) + def read(self): # The following logic is adapted from the library module # SimpleXMLRPCServer.py. @@ -112,20 +114,29 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler): def do_GET(self, withdata=True): # Of course, don't attempt to read data. - self.answer(dict(reply="success", status=200, - reason="Your GET operation worked")) + try: + self.answer(dict(reply="success", status=200, + reason="Your GET operation worked")) + except self.ignore_exceptions, e: + print >> sys.stderr, "Exception during GET (ignoring): %s" % str(e) def do_POST(self): # Read the provided POST data. # self.answer(self.read()) - self.answer(dict(reply="success", status=200, - reason=self.read())) + try: + self.answer(dict(reply="success", status=200, + reason=self.read())) + except self.ignore_exceptions, e: + print >> sys.stderr, "Exception during POST (ignoring): %s" % str(e) def do_PUT(self): # Read the provided PUT data. # self.answer(self.read()) - self.answer(dict(reply="success", status=200, - reason=self.read())) + try: + self.answer(dict(reply="success", status=200, + reason=self.read())) + except self.ignore_exceptions, e: + print >> sys.stderr, "Exception during PUT (ignoring): %s" % str(e) def answer(self, data, withdata=True): debug("%s.answer(%s): self.path = %r", self.__class__.__name__, data, self.path) @@ -223,6 +234,17 @@ class Server(ThreadingMixIn, HTTPServer): # operation of freeport() absolutely depends on it being off. allow_reuse_address = False + # Override of BaseServer.handle_error(). Not too interested + # in errors and the default handler emits a scary traceback + # to stderr which annoys some. Disable this override to get + # default behavior which *shouldn't* cause the program to return + # a failure status. + def handle_error(self, request, client_address): + print '-'*40 + print 'Ignoring exception during processing of request from', + print client_address + print '-'*40 + if __name__ == "__main__": do_valgrind = False path_search = False @@ -249,3 +271,4 @@ if __name__ == "__main__": args = ["valgrind", "--log-file=./valgrind.log"] + args path_search = True sys.exit(run(server=Thread(name="httpd", target=httpd.serve_forever), use_path=path_search, *args)) + -- cgit v1.2.3 From b864cecd6c938b18cf05f7695f33f4da3b608a47 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 13 May 2013 16:34:52 -0700 Subject: De-bork the viewer merge, causing black in-world images. Reviewed by Kelly --- indra/llrender/llimagegl.cpp | 9 +++------ indra/llrender/llshadermgr.cpp | 2 -- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 5aef2c972e..0a0429846a 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -715,12 +715,9 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) mMipLevels = wpo2(llmax(w, h)); - if (!gGLManager.mHasFramebufferObject) - { - //use legacy mipmap generation mode - glTexParameteri(mTarget, GL_GENERATE_MIPMAP, GL_TRUE); - } - + //use legacy mipmap generation mode (note: making this condional can cause rendering issues) + glTexParameteri(mTarget, GL_GENERATE_MIPMAP, GL_TRUE); + LLImageGL::setManualImage(mTarget, 0, mFormatInternal, w, h, mFormatPrimary, mFormatType, diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 825f80a6dc..4893b1d043 100755 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1120,8 +1120,6 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("matrixPalette"); - - mReservedUniforms.reserve(12); mReservedUniforms.push_back("screenTex"); mReservedUniforms.push_back("screenDepth"); mReservedUniforms.push_back("refTex"); -- cgit v1.2.3 From 8a83408185ab3aa8d05f2e13b6b8592329d4651a Mon Sep 17 00:00:00 2001 From: Monty Brandenberg Date: Tue, 14 May 2013 11:52:12 -0400 Subject: MAINT-2302 Tests frequently fail on Windows builds. I'm calling this the more correct fix. The httprequest tests actually talk to an HTTP server running in the Python test scaffold script. Under severe CPU competition, it may not get the cycles needed to start up and make progress. So this modifies the test to spin a little faster and dwell waiting on the server for a longer period. Hope this will be adequate to make the tests reliable. --- indra/llcorehttp/tests/test_httprequest.hpp | 245 ++++++++++++++-------------- 1 file changed, 127 insertions(+), 118 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index e2021bac12..900a699887 100755 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -45,6 +45,15 @@ using namespace LLCoreInt; +// spin/sleep waiting times for client/server exchange tests +// +// These are now fairly generous to try to get around timeout +// ('reasonable time') failures during execution on a heavily- +// loaded system where the unit test is in competition with +// other programs. +static const int LOOP_SLEEP_INTERVAL(10000); +static const int LOOP_COUNT_SHORT(500); // 5-second dwell time +static const int LOOP_COUNT_LONG(3000); // 30-second dwell time namespace { @@ -294,11 +303,11 @@ void HttpRequestTestObjectType::test<3>() // Run the notification pump. int count(0); - int limit(20); + int limit(LOOP_COUNT_SHORT); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -309,21 +318,21 @@ void HttpRequestTestObjectType::test<3>() // Run the notification pump again count = 0; - limit = 100; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -392,12 +401,12 @@ void HttpRequestTestObjectType::test<4>() // Run the notification pump. int count(0); - int limit(20); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 2) { req1->update(1000000); req2->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 2); @@ -409,22 +418,22 @@ void HttpRequestTestObjectType::test<4>() // Run the notification pump again count = 0; - limit = 100; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 3) { req1->update(1000000); req2->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 3); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -493,11 +502,11 @@ void HttpRequestTestObjectType::test<5>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_SHORT); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("NoOp notification received", mHandlerCalls == 1); @@ -569,11 +578,11 @@ void HttpRequestTestObjectType::test<6>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_SHORT); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("No notifications received", mHandlerCalls == 0); @@ -650,11 +659,11 @@ void HttpRequestTestObjectType::test<7>() // Run the notification pump. int count(0); - int limit(50); // With one retry, should fail quickish + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -666,21 +675,21 @@ void HttpRequestTestObjectType::test<7>() // Run the notification pump again count = 0; - limit = 100; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -766,11 +775,11 @@ void HttpRequestTestObjectType::test<8>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -782,21 +791,21 @@ void HttpRequestTestObjectType::test<8>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -876,11 +885,11 @@ void HttpRequestTestObjectType::test<9>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -892,21 +901,21 @@ void HttpRequestTestObjectType::test<9>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -988,11 +997,11 @@ void HttpRequestTestObjectType::test<10>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1004,21 +1013,21 @@ void HttpRequestTestObjectType::test<10>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1106,11 +1115,11 @@ void HttpRequestTestObjectType::test<11>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1122,21 +1131,21 @@ void HttpRequestTestObjectType::test<11>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1226,11 +1235,11 @@ void HttpRequestTestObjectType::test<12>() // Run the notification pump. int count(0); - int limit(200); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(10000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1242,21 +1251,21 @@ void HttpRequestTestObjectType::test<12>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1352,11 +1361,11 @@ void HttpRequestTestObjectType::test<13>() // Run the notification pump. int count(0); - int limit(200); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(10000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1369,21 +1378,21 @@ void HttpRequestTestObjectType::test<13>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1471,11 +1480,11 @@ void HttpRequestTestObjectType::test<14>() // Run the notification pump. int count(0); - int limit(50); // With one retry, should fail quickish + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1487,21 +1496,21 @@ void HttpRequestTestObjectType::test<14>() // Run the notification pump again count = 0; - limit = 100; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1594,11 +1603,11 @@ void HttpRequestTestObjectType::test<15>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1611,21 +1620,21 @@ void HttpRequestTestObjectType::test<15>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1724,11 +1733,11 @@ void HttpRequestTestObjectType::test<16>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1764,11 +1773,11 @@ void HttpRequestTestObjectType::test<16>() // Run the notification pump. count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 2); @@ -1783,21 +1792,21 @@ void HttpRequestTestObjectType::test<16>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 3) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 3); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1919,11 +1928,11 @@ void HttpRequestTestObjectType::test<17>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1938,21 +1947,21 @@ void HttpRequestTestObjectType::test<17>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2079,11 +2088,11 @@ void HttpRequestTestObjectType::test<18>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2098,21 +2107,21 @@ void HttpRequestTestObjectType::test<18>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2237,11 +2246,11 @@ void HttpRequestTestObjectType::test<19>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2255,21 +2264,21 @@ void HttpRequestTestObjectType::test<19>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2401,11 +2410,11 @@ void HttpRequestTestObjectType::test<20>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2420,21 +2429,21 @@ void HttpRequestTestObjectType::test<20>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2569,11 +2578,11 @@ void HttpRequestTestObjectType::test<21>() // Run the notification pump. int count(0); - int limit(10); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time", count < limit); ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2588,21 +2597,21 @@ void HttpRequestTestObjectType::test<21>() // Run the notification pump again count = 0; - limit = 10; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 2) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Second request executed in reasonable time", count < limit); ensure("Second handler invocation", mHandlerCalls == 2); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2712,11 +2721,11 @@ void HttpRequestTestObjectType::test<22>() // Run the notification pump. int count(0); - int limit(30); + int limit(LOOP_COUNT_LONG); while (count++ < limit && mHandlerCalls < test_count) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time - ms1", count < limit); ensure("One handler invocation for each request - ms1", mHandlerCalls == test_count); @@ -2744,11 +2753,11 @@ void HttpRequestTestObjectType::test<22>() // Run the notification pump. count = 0; - limit = 30; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < test2_count) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time - ms2", count < limit); ensure("One handler invocation for each request - ms2", mHandlerCalls == test2_count); @@ -2776,11 +2785,11 @@ void HttpRequestTestObjectType::test<22>() // Run the notification pump. count = 0; - limit = 30; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < test3_count) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Request executed in reasonable time - ms3", count < limit); ensure("One handler invocation for each request - ms3", mHandlerCalls == test3_count); @@ -2795,21 +2804,21 @@ void HttpRequestTestObjectType::test<22>() // Run the notification pump again count = 0; - limit = 20; + limit = LOOP_COUNT_LONG; while (count++ < limit && mHandlerCalls < 1) { req->update(1000000); - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Shutdown request executed in reasonable time", count < limit); ensure("Shutdown handler invocation", mHandlerCalls == 1); // See that we actually shutdown the thread count = 0; - limit = 10; + limit = LOOP_COUNT_SHORT; while (count++ < limit && ! HttpService::isStopped()) { - usleep(100000); + usleep(LOOP_SLEEP_INTERVAL); } ensure("Thread actually stopped running", HttpService::isStopped()); -- cgit v1.2.3 From f111b5b1135ee31434acb81d5a3e63e4812e257f Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 14 May 2013 09:24:58 -0700 Subject: Fix EOL characters --- indra/llcommon/llstringtable.h | 418 ++++++++++++++++---------------- indra/llrender/llpostprocess.h | 534 ++++++++++++++++++++--------------------- 2 files changed, 476 insertions(+), 476 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llstringtable.h b/indra/llcommon/llstringtable.h index 787a046741..ff09e71677 100755 --- a/indra/llcommon/llstringtable.h +++ b/indra/llcommon/llstringtable.h @@ -1,209 +1,209 @@ -/** - * @file llstringtable.h - * @brief The LLStringTable class provides a _fast_ method for finding - * unique copies of strings. - * - * $LicenseInfo:firstyear=2001&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$ - */ - -#ifndef LL_STRING_TABLE_H -#define LL_STRING_TABLE_H - -#include "lldefs.h" -#include "llformat.h" -#include "llstl.h" -#include -#include - -#if LL_WINDOWS -# if (_MSC_VER >= 1300 && _MSC_VER < 1400) -# define STRING_TABLE_HASH_MAP 1 -# endif -#else -//# define STRING_TABLE_HASH_MAP 1 -#endif - -const U32 MAX_STRINGS_LENGTH = 256; - -class LL_COMMON_API LLStringTableEntry -{ -public: - LLStringTableEntry(const char *str); - ~LLStringTableEntry(); - - void incCount() { mCount++; } - BOOL decCount() { return --mCount; } - - char *mString; - S32 mCount; -}; - -class LL_COMMON_API LLStringTable -{ -public: - LLStringTable(int tablesize); - ~LLStringTable(); - - char *checkString(const char *str); - char *checkString(const std::string& str); - LLStringTableEntry *checkStringEntry(const char *str); - LLStringTableEntry *checkStringEntry(const std::string& str); - - char *addString(const char *str); - char *addString(const std::string& str); - LLStringTableEntry *addStringEntry(const char *str); - LLStringTableEntry *addStringEntry(const std::string& str); - void removeString(const char *str); - - S32 mMaxEntries; - S32 mUniqueEntries; - -#if STRING_TABLE_HASH_MAP -#if LL_WINDOWS - typedef std::hash_multimap string_hash_t; -#else - typedef __gnu_cxx::hash_multimap string_hash_t; -#endif - string_hash_t mStringHash; -#else - typedef std::list string_list_t; - typedef string_list_t * string_list_ptr_t; - string_list_ptr_t *mStringList; -#endif -}; - -extern LL_COMMON_API LLStringTable gStringTable; - -//============================================================================ - -// This class is designed to be used locally, -// e.g. as a member of an LLXmlTree -// Strings can be inserted only, then quickly looked up - -typedef const std::string* LLStdStringHandle; - -class LL_COMMON_API LLStdStringTable -{ -public: - LLStdStringTable(S32 tablesize = 0) - { - if (tablesize == 0) - { - tablesize = 256; // default - } - // Make sure tablesize is power of 2 - for (S32 i = 31; i>0; i--) - { - if (tablesize & (1<= (3<<(i-1))) - tablesize = (1<<(i+1)); - else - tablesize = (1< > string_set_t; - string_set_t* mStringList; // [mTableSize] -}; - - -#endif +/** + * @file llstringtable.h + * @brief The LLStringTable class provides a _fast_ method for finding + * unique copies of strings. + * + * $LicenseInfo:firstyear=2001&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$ + */ + +#ifndef LL_STRING_TABLE_H +#define LL_STRING_TABLE_H + +#include "lldefs.h" +#include "llformat.h" +#include "llstl.h" +#include +#include + +#if LL_WINDOWS +# if (_MSC_VER >= 1300 && _MSC_VER < 1400) +# define STRING_TABLE_HASH_MAP 1 +# endif +#else +//# define STRING_TABLE_HASH_MAP 1 +#endif + +const U32 MAX_STRINGS_LENGTH = 256; + +class LL_COMMON_API LLStringTableEntry +{ +public: + LLStringTableEntry(const char *str); + ~LLStringTableEntry(); + + void incCount() { mCount++; } + BOOL decCount() { return --mCount; } + + char *mString; + S32 mCount; +}; + +class LL_COMMON_API LLStringTable +{ +public: + LLStringTable(int tablesize); + ~LLStringTable(); + + char *checkString(const char *str); + char *checkString(const std::string& str); + LLStringTableEntry *checkStringEntry(const char *str); + LLStringTableEntry *checkStringEntry(const std::string& str); + + char *addString(const char *str); + char *addString(const std::string& str); + LLStringTableEntry *addStringEntry(const char *str); + LLStringTableEntry *addStringEntry(const std::string& str); + void removeString(const char *str); + + S32 mMaxEntries; + S32 mUniqueEntries; + +#if STRING_TABLE_HASH_MAP +#if LL_WINDOWS + typedef std::hash_multimap string_hash_t; +#else + typedef __gnu_cxx::hash_multimap string_hash_t; +#endif + string_hash_t mStringHash; +#else + typedef std::list string_list_t; + typedef string_list_t * string_list_ptr_t; + string_list_ptr_t *mStringList; +#endif +}; + +extern LL_COMMON_API LLStringTable gStringTable; + +//============================================================================ + +// This class is designed to be used locally, +// e.g. as a member of an LLXmlTree +// Strings can be inserted only, then quickly looked up + +typedef const std::string* LLStdStringHandle; + +class LL_COMMON_API LLStdStringTable +{ +public: + LLStdStringTable(S32 tablesize = 0) + { + if (tablesize == 0) + { + tablesize = 256; // default + } + // Make sure tablesize is power of 2 + for (S32 i = 31; i>0; i--) + { + if (tablesize & (1<= (3<<(i-1))) + tablesize = (1<<(i+1)); + else + tablesize = (1< > string_set_t; + string_set_t* mStringList; // [mTableSize] +}; + + +#endif diff --git a/indra/llrender/llpostprocess.h b/indra/llrender/llpostprocess.h index 6894505753..ce17b6693d 100755 --- a/indra/llrender/llpostprocess.h +++ b/indra/llrender/llpostprocess.h @@ -1,267 +1,267 @@ -/** - * @file llpostprocess.h - * @brief LLPostProcess class definition - * - * $LicenseInfo:firstyear=2007&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$ - */ - -#ifndef LL_POSTPROCESS_H -#define LL_POSTPROCESS_H - -#include -#include -#include "llgl.h" -#include "llglheaders.h" -#include "llstaticstringtable.h" - -class LLPostProcess -{ -public: - - typedef enum _QuadType { - QUAD_NORMAL, - QUAD_NOISE, - QUAD_BLOOM_EXTRACT, - QUAD_BLOOM_COMBINE - } QuadType; - - /// GLSL Shader Encapsulation Struct - typedef LLStaticStringTable glslUniforms; - - struct PostProcessTweaks : public LLSD { - inline PostProcessTweaks() : LLSD(LLSD::emptyMap()) - { - } - - inline LLSD & brightMult() { - return (*this)["brightness_multiplier"]; - } - - inline LLSD & noiseStrength() { - return (*this)["noise_strength"]; - } - - inline LLSD & noiseSize() { - return (*this)["noise_size"]; - } - - inline LLSD & extractLow() { - return (*this)["extract_low"]; - } - - inline LLSD & extractHigh() { - return (*this)["extract_high"]; - } - - inline LLSD & bloomWidth() { - return (*this)["bloom_width"]; - } - - inline LLSD & bloomStrength() { - return (*this)["bloom_strength"]; - } - - inline LLSD & brightness() { - return (*this)["brightness"]; - } - - inline LLSD & contrast() { - return (*this)["contrast"]; - } - - inline LLSD & contrastBaseR() { - return (*this)["contrast_base"][0]; - } - - inline LLSD & contrastBaseG() { - return (*this)["contrast_base"][1]; - } - - inline LLSD & contrastBaseB() { - return (*this)["contrast_base"][2]; - } - - inline LLSD & contrastBaseIntensity() { - return (*this)["contrast_base"][3]; - } - - inline LLSD & saturation() { - return (*this)["saturation"]; - } - - inline LLSD & useNightVisionShader() { - return (*this)["enable_night_vision"]; - } - - inline LLSD & useBloomShader() { - return (*this)["enable_bloom"]; - } - - inline LLSD & useColorFilter() { - return (*this)["enable_color_filter"]; - } - - - inline F32 getBrightMult() const { - return F32((*this)["brightness_multiplier"].asReal()); - } - - inline F32 getNoiseStrength() const { - return F32((*this)["noise_strength"].asReal()); - } - - inline F32 getNoiseSize() const { - return F32((*this)["noise_size"].asReal()); - } - - inline F32 getExtractLow() const { - return F32((*this)["extract_low"].asReal()); - } - - inline F32 getExtractHigh() const { - return F32((*this)["extract_high"].asReal()); - } - - inline F32 getBloomWidth() const { - return F32((*this)["bloom_width"].asReal()); - } - - inline F32 getBloomStrength() const { - return F32((*this)["bloom_strength"].asReal()); - } - - inline F32 getBrightness() const { - return F32((*this)["brightness"].asReal()); - } - - inline F32 getContrast() const { - return F32((*this)["contrast"].asReal()); - } - - inline F32 getContrastBaseR() const { - return F32((*this)["contrast_base"][0].asReal()); - } - - inline F32 getContrastBaseG() const { - return F32((*this)["contrast_base"][1].asReal()); - } - - inline F32 getContrastBaseB() const { - return F32((*this)["contrast_base"][2].asReal()); - } - - inline F32 getContrastBaseIntensity() const { - return F32((*this)["contrast_base"][3].asReal()); - } - - inline F32 getSaturation() const { - return F32((*this)["saturation"].asReal()); - } - - }; - - bool initialized; - PostProcessTweaks tweaks; - - // the map of all availible effects - LLSD mAllEffects; - -private: - LLPointer mSceneRenderTexture ; - LLPointer mNoiseTexture ; - LLPointer mTempBloomTexture ; - -public: - LLPostProcess(void); - - ~LLPostProcess(void); - - void apply(unsigned int width, unsigned int height); - void invalidate() ; - - /// Perform global initialization for this class. - static void initClass(void); - - // Cleanup of global data that's only inited once per class. - static void cleanupClass(); - - void setSelectedEffect(std::string const & effectName); - - inline std::string const & getSelectedEffect(void) const { - return mSelectedEffectName; - } - - void saveEffect(std::string const & effectName); - -private: - /// read in from file - std::string mShaderErrorString; - unsigned int screenW; - unsigned int screenH; - - float noiseTextureScale; - - /// Shader Uniforms - glslUniforms nightVisionUniforms; - glslUniforms bloomExtractUniforms; - glslUniforms bloomBlurUniforms; - glslUniforms colorFilterUniforms; - - // the name of currently selected effect in mAllEffects - // invariant: tweaks == mAllEffects[mSelectedEffectName] - std::string mSelectedEffectName; - - /// General functions - void initialize(unsigned int width, unsigned int height); - void doEffects(void); - void applyShaders(void); - bool shadersEnabled(void); - - /// Night Vision Functions - void createNightVisionShader(void); - void applyNightVisionShader(void); - - /// Bloom Functions - void createBloomShader(void); - void applyBloomShader(void); - - /// Color Filter Functions - void createColorFilterShader(void); - void applyColorFilterShader(void); - - /// OpenGL Helper Functions - void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); - void createTexture(LLPointer& texture, unsigned int width, unsigned int height); - void copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height); - void createNoiseTexture(LLPointer& texture); - bool checkError(void); - void checkShaderError(GLhandleARB shader); - void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); - void viewOrthogonal(unsigned int width, unsigned int height); - void changeOrthogonal(unsigned int width, unsigned int height); - void viewPerspective(void); -}; - -extern LLPostProcess * gPostProcess; - - -#endif // LL_POSTPROCESS_H +/** + * @file llpostprocess.h + * @brief LLPostProcess class definition + * + * $LicenseInfo:firstyear=2007&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$ + */ + +#ifndef LL_POSTPROCESS_H +#define LL_POSTPROCESS_H + +#include +#include +#include "llgl.h" +#include "llglheaders.h" +#include "llstaticstringtable.h" + +class LLPostProcess +{ +public: + + typedef enum _QuadType { + QUAD_NORMAL, + QUAD_NOISE, + QUAD_BLOOM_EXTRACT, + QUAD_BLOOM_COMBINE + } QuadType; + + /// GLSL Shader Encapsulation Struct + typedef LLStaticStringTable glslUniforms; + + struct PostProcessTweaks : public LLSD { + inline PostProcessTweaks() : LLSD(LLSD::emptyMap()) + { + } + + inline LLSD & brightMult() { + return (*this)["brightness_multiplier"]; + } + + inline LLSD & noiseStrength() { + return (*this)["noise_strength"]; + } + + inline LLSD & noiseSize() { + return (*this)["noise_size"]; + } + + inline LLSD & extractLow() { + return (*this)["extract_low"]; + } + + inline LLSD & extractHigh() { + return (*this)["extract_high"]; + } + + inline LLSD & bloomWidth() { + return (*this)["bloom_width"]; + } + + inline LLSD & bloomStrength() { + return (*this)["bloom_strength"]; + } + + inline LLSD & brightness() { + return (*this)["brightness"]; + } + + inline LLSD & contrast() { + return (*this)["contrast"]; + } + + inline LLSD & contrastBaseR() { + return (*this)["contrast_base"][0]; + } + + inline LLSD & contrastBaseG() { + return (*this)["contrast_base"][1]; + } + + inline LLSD & contrastBaseB() { + return (*this)["contrast_base"][2]; + } + + inline LLSD & contrastBaseIntensity() { + return (*this)["contrast_base"][3]; + } + + inline LLSD & saturation() { + return (*this)["saturation"]; + } + + inline LLSD & useNightVisionShader() { + return (*this)["enable_night_vision"]; + } + + inline LLSD & useBloomShader() { + return (*this)["enable_bloom"]; + } + + inline LLSD & useColorFilter() { + return (*this)["enable_color_filter"]; + } + + + inline F32 getBrightMult() const { + return F32((*this)["brightness_multiplier"].asReal()); + } + + inline F32 getNoiseStrength() const { + return F32((*this)["noise_strength"].asReal()); + } + + inline F32 getNoiseSize() const { + return F32((*this)["noise_size"].asReal()); + } + + inline F32 getExtractLow() const { + return F32((*this)["extract_low"].asReal()); + } + + inline F32 getExtractHigh() const { + return F32((*this)["extract_high"].asReal()); + } + + inline F32 getBloomWidth() const { + return F32((*this)["bloom_width"].asReal()); + } + + inline F32 getBloomStrength() const { + return F32((*this)["bloom_strength"].asReal()); + } + + inline F32 getBrightness() const { + return F32((*this)["brightness"].asReal()); + } + + inline F32 getContrast() const { + return F32((*this)["contrast"].asReal()); + } + + inline F32 getContrastBaseR() const { + return F32((*this)["contrast_base"][0].asReal()); + } + + inline F32 getContrastBaseG() const { + return F32((*this)["contrast_base"][1].asReal()); + } + + inline F32 getContrastBaseB() const { + return F32((*this)["contrast_base"][2].asReal()); + } + + inline F32 getContrastBaseIntensity() const { + return F32((*this)["contrast_base"][3].asReal()); + } + + inline F32 getSaturation() const { + return F32((*this)["saturation"].asReal()); + } + + }; + + bool initialized; + PostProcessTweaks tweaks; + + // the map of all availible effects + LLSD mAllEffects; + +private: + LLPointer mSceneRenderTexture ; + LLPointer mNoiseTexture ; + LLPointer mTempBloomTexture ; + +public: + LLPostProcess(void); + + ~LLPostProcess(void); + + void apply(unsigned int width, unsigned int height); + void invalidate() ; + + /// Perform global initialization for this class. + static void initClass(void); + + // Cleanup of global data that's only inited once per class. + static void cleanupClass(); + + void setSelectedEffect(std::string const & effectName); + + inline std::string const & getSelectedEffect(void) const { + return mSelectedEffectName; + } + + void saveEffect(std::string const & effectName); + +private: + /// read in from file + std::string mShaderErrorString; + unsigned int screenW; + unsigned int screenH; + + float noiseTextureScale; + + /// Shader Uniforms + glslUniforms nightVisionUniforms; + glslUniforms bloomExtractUniforms; + glslUniforms bloomBlurUniforms; + glslUniforms colorFilterUniforms; + + // the name of currently selected effect in mAllEffects + // invariant: tweaks == mAllEffects[mSelectedEffectName] + std::string mSelectedEffectName; + + /// General functions + void initialize(unsigned int width, unsigned int height); + void doEffects(void); + void applyShaders(void); + bool shadersEnabled(void); + + /// Night Vision Functions + void createNightVisionShader(void); + void applyNightVisionShader(void); + + /// Bloom Functions + void createBloomShader(void); + void applyBloomShader(void); + + /// Color Filter Functions + void createColorFilterShader(void); + void applyColorFilterShader(void); + + /// OpenGL Helper Functions + void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); + void createTexture(LLPointer& texture, unsigned int width, unsigned int height); + void copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height); + void createNoiseTexture(LLPointer& texture); + bool checkError(void); + void checkShaderError(GLhandleARB shader); + void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); + void viewOrthogonal(unsigned int width, unsigned int height); + void changeOrthogonal(unsigned int width, unsigned int height); + void viewPerspective(void); +}; + +extern LLPostProcess * gPostProcess; + + +#endif // LL_POSTPROCESS_H -- cgit v1.2.3 From 119e9b47f57f35e7657d4b653b73f66558b1323d Mon Sep 17 00:00:00 2001 From: Monty Brandenberg Date: Tue, 14 May 2013 16:56:27 -0400 Subject: SH-4190 Reactivate unit tests neutered under MAINT-3202 HttpStatus unit tests have never caused a unit test failure but they do have the word 'error' in their text descriptions which gets picked up by the log processor in TC builds. So, reactivate the tests and reform the descriptions. --- indra/llcorehttp/tests/test_httpstatus.hpp | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/tests/test_httpstatus.hpp b/indra/llcorehttp/tests/test_httpstatus.hpp index 887315befc..b5538528c5 100755 --- a/indra/llcorehttp/tests/test_httpstatus.hpp +++ b/indra/llcorehttp/tests/test_httpstatus.hpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. + * Copyright (C) 2012-2013, 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 @@ -91,9 +91,6 @@ template <> template <> void HttpStatusTestObjectType::test<2>() { set_test_name("HttpStatus memory structure"); -#if LL_WINDOWS - skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif // Require that an HttpStatus object can be trivially // returned as a function return value in registers. @@ -106,10 +103,7 @@ void HttpStatusTestObjectType::test<2>() template <> template <> void HttpStatusTestObjectType::test<3>() { - set_test_name("HttpStatus valid error string conversion"); -#if LL_WINDOWS - skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif + set_test_name("HttpStatus valid status string conversion"); HttpStatus status; status.mType = HttpStatus::EXT_CURL_EASY; @@ -141,10 +135,7 @@ void HttpStatusTestObjectType::test<3>() template <> template <> void HttpStatusTestObjectType::test<4>() { - set_test_name("HttpStatus invalid error string conversion"); -#if LL_WINDOWS - skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif + set_test_name("HttpStatus invalid status string conversion"); HttpStatus status; status.mType = HttpStatus::EXT_CURL_EASY; @@ -170,9 +161,6 @@ template <> template <> void HttpStatusTestObjectType::test<5>() { set_test_name("HttpStatus equality/inequality testing"); -#if LL_WINDOWS - skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif // Make certain equality/inequality tests do not pass // through the bool conversion. Distinct successful @@ -193,9 +181,6 @@ template <> template <> void HttpStatusTestObjectType::test<6>() { set_test_name("HttpStatus basic HTTP status encoding"); -#if LL_WINDOWS - skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif HttpStatus status; status.mType = 200; @@ -242,10 +227,7 @@ void HttpStatusTestObjectType::test<6>() template <> template <> void HttpStatusTestObjectType::test<7>() { - set_test_name("HttpStatus HTTP error text strings"); -#if LL_WINDOWS - skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif + set_test_name("HttpStatus HTTP status text strings"); HttpStatus status(100, HE_REPLY_ERROR); std::string msg(status.toString()); -- cgit v1.2.3 From ec5bd94d59247e600f8f8702a543f99d40930d20 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 15 May 2013 11:00:00 -0700 Subject: BUG-2581 : [simon-ll-viewer-cat] Path cut, hollow and slice break planar texture mapping on prims. Credits to DaveP --- indra/llmath/llvolume.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 7751ef87ee..317d15f84e 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -5604,16 +5604,16 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) LLVector4a binormal; calc_binormal_from_triangle(binormal, *mCenter, cuv, - pos[0], tc[0], - pos[1], tc[1]); + mPositions[0], mTexCoords[0], + mPositions[1], mTexCoords[1]); binormal.normalize3fast(); LLVector4a normal; LLVector4a d0, d1; - d0.setSub(*mCenter, pos[0]); - d1.setSub(*mCenter, pos[1]); + d0.setSub(*mCenter, mPositions[0]); + d1.setSub(*mCenter, mPositions[1]); if (mTypeMask & TOP_MASK) { -- cgit v1.2.3 From 0cb2b30bfb239f05e1780cae5e3a7328a1474416 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 17 May 2013 11:45:06 -0700 Subject: Simple imposter AV rendering cleanup --- indra/newview/app_settings/settings.xml | 28 ++++------- indra/newview/llvoavatar.cpp | 55 +++------------------- indra/newview/llvoavatar.h | 1 - indra/newview/skins/default/xui/en/menu_viewer.xml | 9 ---- .../newview/skins/default/xui/en/notifications.xml | 39 --------------- 5 files changed, 15 insertions(+), 117 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 676ba57726..7cb45559fa 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9480,7 +9480,7 @@ RenderAutoMuteByteLimit Comment - Maximum bytes of attachments before an avatar is automatically visually muted (0 for no limit). + Maximum bytes of attachments before an avatar is rendered as a simple imposter (0 for no limit). Persist 1 Type @@ -9491,7 +9491,7 @@ RenderAutoMuteRenderCostLimit Comment - Maximum render weight before an avatar is automatically visually muted (0 to not use this limit). + Maximum render weight before an avatar is rendered as a simple imposter (0 to not use this limit). Persist 1 Type @@ -9502,7 +9502,7 @@ RenderAutoMuteSurfaceAreaLimit Comment - Maximum surface area of attachments before an avatar is automatically visually muted (0 to not use this limit). + Maximum surface area of attachments before an avatar is rendered as a simple imposter (0 to not use this limit). Persist 1 Type @@ -9510,16 +9510,16 @@ Value 0 - RenderAutoMuteEnabled + RenderAutoMuteThreshold Comment - Apply visual muting to high cost, non-friends, not in IM, or somewhat distant avatars + Threshold on the Avatar Detail slider where simple imposter mode is enabled. (less than 0 is always on, greather than 1 always off) Persist 1 Type - Boolean + F32 Value - 0 + 0.25 RenderAutoMuteLogging @@ -9531,19 +9531,7 @@ Boolean Value 0 - - RenderAutoMuteVisibilityRank - - Comment - Number of avatars to show normally for visual muting mode. - Persist - 1 - Type - U32 - Value - 0 - - + RenderAutoHideSurfaceAreaLimit Comment diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 3c25339037..4de2f4684e 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2999,11 +2999,10 @@ bool LLVOAvatar::isVisuallyMuted() if (!isSelf()) { - static LLCachedControl render_mute_enabled(gSavedSettings, "RenderAutoMuteEnabled"); + static LLCachedControl render_mute_threshold(gSavedSettings, "RenderAutoMuteThreshold"); static LLCachedControl max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit"); static LLCachedControl max_attachment_area(gSavedSettings, "RenderAutoMuteSurfaceAreaLimit"); static LLCachedControl max_render_cost(gSavedSettings, "RenderAutoMuteRenderCostLimit"); - static LLCachedControl visibility_rank(gSavedSettings, "RenderAutoMuteVisibilityRank"); if (mVisuallyMuteSetting == ALWAYS_VISUAL_MUTE) { // Always want to see this AV as an imposter @@ -3013,7 +3012,7 @@ bool LLVOAvatar::isVisuallyMuted() { // Never show as imposter muted = false; } - else if (render_mute_enabled) + else if (LLVOAvatar::sLODFactor <= render_mute_threshold) { F64 now = LLFrameTimer::getTotalSeconds(); @@ -3034,13 +3033,14 @@ bool LLVOAvatar::isVisuallyMuted() // Could be part of the grand || collection above, but yanked out to make the logic visible if (!muted) { - if (visibility_rank > 0) + if (sMaxVisible > 0) { // They are above the visibilty rank - mute them - muted = (mVisibilityRank > visibility_rank); + muted = (mVisibilityRank > sMaxVisible); } + /* Not used - always draw friends or those in IMs. Works nicely, needs UI? if (muted || // Don't mute friends or IMs - visibility_rank == 0) + sMaxVisible == 0) { muted = !(LLAvatarTracker::instance().isBuddy(getID())); if (muted) @@ -3049,6 +3049,7 @@ bool LLVOAvatar::isVisuallyMuted() muted = !gIMMgr->hasSession(session_id); } } + */ } // Save visual mute state and set interval for updating @@ -7879,8 +7880,6 @@ void LLVOAvatar::idleUpdateRenderCost() calculateUpdateRenderCost(); // Update mVisualComplexity if needed - doRenderCostNagging(max_render_cost); // Remind the user their AV is too complex - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHAME)) { std::string viz_string = LLVOAvatar::rezStatusToString(getRezzedStatus()); @@ -7892,46 +7891,6 @@ void LLVOAvatar::idleUpdateRenderCost() } -// Remind the user about their expensive avatar -void LLVOAvatar::doRenderCostNagging(U32 max_render_cost) -{ - if (isSelf()) - { - static S32 sOldComplexity = 0; - static F64 sLastRenderCostNagTime = 0.0; - - const F64 RENDER_NAG_INTERVAL = 60.0; - - F64 now = LLFrameTimer::getTotalSeconds(); - if (sLastRenderCostNagTime > 0.0 && - (now - sLastRenderCostNagTime) > RENDER_NAG_INTERVAL && - sOldComplexity != mVisualComplexity) - { - sOldComplexity = mVisualComplexity; - - if (max_render_cost > 0) - { //pop up notification that you have exceeded a render cost limit - if (mVisualComplexity > max_render_cost+max_render_cost/2) - { - LLNotificationsUtil::add("ExceededHighDetailRenderCost"); - sLastRenderCostNagTime = now; - } - else if (mVisualComplexity > max_render_cost) - { - LLNotificationsUtil::add("ExceededMidDetailRenderCost"); - sLastRenderCostNagTime = now; - } - else if (mVisualComplexity > max_render_cost/2) - { - LLNotificationsUtil::add("ExceededLowDetailRenderCost"); - sLastRenderCostNagTime = now; - } - } - } - } -} - - // Calculations for mVisualComplexity value void LLVOAvatar::calculateUpdateRenderCost() { diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 8862056066..afe1d56059 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -250,7 +250,6 @@ public: static void invalidateNameTags(); void addNameTagLine(const std::string& line, const LLColor4& color, S32 style, const LLFontGL* font); void idleUpdateRenderCost(); - void doRenderCostNagging(U32 max_render_cost); void calculateUpdateRenderCost(); void updateVisualComplexity() { mVisualComplexityStale = TRUE; } diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index f66272aa2e..9c8313f46c 100755 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -547,15 +547,6 @@ - - - - - - Your avatar has become too complex to be rendered by even high performance computers. Almost all Residents will see a low detail stand in instead of your actual avatar. - - - - - - Your avatar has become too complex to be rendered by most computers. Many Residents will see a low detail stand in instead of your actual avatar. - - - - - - Your avatar has become too complex to be rendered by some computers. Some Residents will see a low detail stand in instead of your actual avatar. - - - - Date: Mon, 20 May 2013 11:18:12 -0700 Subject: MAINT-2616 : Updated my Intel driver and now have orange in buttons and Inventory pull down bar causing blinks to screen. Pulled in FS code, Reviewed by Kelly --- indra/llrender/llglslshader.cpp | 1 + indra/llrender/llglslshader.h | 3 ++ indra/llrender/llrender2dutils.cpp | 22 ++++++++++- .../shaders/class1/interface/solidcolorIntelV.glsl | 44 ++++++++++++++++++++++ indra/newview/llselectmgr.cpp | 10 ++++- indra/newview/llviewershadermgr.cpp | 19 ++++++++++ 6 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/interface/solidcolorIntelV.glsl (limited to 'indra') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 298a03f32a..8a0ca95a78 100755 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -57,6 +57,7 @@ bool LLGLSLShader::sNoFixedFunction = false; //UI shader -- declared here so llui_libtest will link properly LLGLSLShader gUIProgram; LLGLSLShader gSolidColorProgram; +LLGLSLShader gSolidColorProgramIntel; BOOL shouldChange(const LLVector4& v1, const LLVector4& v2) { diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 019d5a86d6..cd097b8e0b 100755 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -160,5 +160,8 @@ extern LLGLSLShader gSolidColorProgram; //Alpha mask shader (declared here so llappearance can access properly) extern LLGLSLShader gAlphaMaskProgram; +// Solid color Shader for Intel Graphics +extern LLGLSLShader gSolidColorProgramIntel; + #endif diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp index d3cfbaf03a..3c6848efaa 100644 --- a/indra/llrender/llrender2dutils.cpp +++ b/indra/llrender/llrender2dutils.cpp @@ -443,7 +443,16 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex { if (LLGLSLShader::sNoFixedFunction) { - gSolidColorProgram.bind(); + // When running with a intel gfx card, do not use the solidcolor?.glsl files. Instead use a custom one + // for those cards. Passing color as a uniform and not a shader attribute + if(gGLManager.mIsIntel) + { + gSolidColorProgramIntel.bind(); + } + else + { + gSolidColorProgram.bind(); + } } else { @@ -454,7 +463,16 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex gGL.getTexUnit(0)->bind(image, true); - gGL.color4fv(color.mV); + // When running with a intel gfx card, do not use the solidcolor?.glsl files. Instead use a custom one + // for those cards. Passing color as a uniform and not a shader attribute + if( solid_color && LLGLSLShader::sNoFixedFunction && gGLManager.mIsIntel ) + { + gGL.diffuseColor4fv(color.mV); + } + else + { + gGL.color4fv(color.mV); + } const S32 NUM_VERTICES = 9 * 4; // 9 quads LLVector2 uv[NUM_VERTICES]; diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorIntelV.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorIntelV.glsl new file mode 100644 index 0000000000..dcf38c27ce --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorIntelV.glsl @@ -0,0 +1,44 @@ +/** + * @file solidcolorV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +uniform mat4 modelview_projection_matrix; + +uniform vec4 color; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); +// vertex_color = diffuse_color; + vertex_color = color; + vary_texcoord0 = texcoord0; +} + diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 4681efd3e5..02ace86b95 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6051,7 +6051,15 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) if (shader) { //switch to "solid color" program for SH-2690 -- works around driver bug causing bad triangles when rendering silhouettes - gSolidColorProgram.bind(); + if(gGLManager.mIsIntel) + { + gSolidColorProgramIntel.bind(); + gGL.diffuseColor4fv(color.mV); + } + else + { + gSolidColorProgram.bind(); + } } gGL.matrixMode(LLRender::MM_MODELVIEW); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 7d7889845d..ef5ccb5120 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -640,6 +640,7 @@ void LLViewerShaderMgr::unloadShaders() gTwoTextureAddProgram.unload(); gOneTextureNoColorProgram.unload(); gSolidColorProgram.unload(); + gSolidColorProgramIntel.unload(); gObjectFullbrightNoColorProgram.unload(); gObjectFullbrightNoColorWaterProgram.unload(); @@ -2703,6 +2704,24 @@ BOOL LLViewerShaderMgr::loadShadersInterface() } } + // When running with a intel gfx card, do not use the solidcolor?.glsl files. Instead use a custom one + // for those cards. Passing color as a uniform and not a shader attribute + if (success) + { + gSolidColorProgramIntel.mName = "Solid Color Shader for Intel"; + gSolidColorProgramIntel.mShaderFiles.clear(); + gSolidColorProgramIntel.mShaderFiles.push_back(make_pair("interface/solidcolorIntelV.glsl", GL_VERTEX_SHADER_ARB)); + gSolidColorProgramIntel.mShaderFiles.push_back(make_pair("interface/solidcolorF.glsl", GL_FRAGMENT_SHADER_ARB)); // The standard fragment shader is just fine. So keep it. + gSolidColorProgramIntel.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gSolidColorProgramIntel.createShader(NULL, NULL); + if (success) + { + gSolidColorProgramIntel.bind(); + gSolidColorProgramIntel.uniform1i(sTex0, 0); + gSolidColorProgramIntel.unbind(); + } + } + if (success) { gOcclusionProgram.mName = "Occlusion Shader"; -- cgit v1.2.3 From 8a16b55bf8a87d29c116d9061d9701e8b844cc7b Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 21 May 2013 09:11:50 -0700 Subject: MAINT-2711 : Add missing LSL constants for llGetObjectDetails() to the viewer. Reviewed by Kelly --- indra/llcommon/lllslconstants.h | 18 ++++++++++++++++++ indra/lscript/lscript_compile/indra.l | 18 ++++++++++++++++++ indra/newview/app_settings/keywords.ini | 19 +++++++++++++++++++ 3 files changed, 55 insertions(+) (limited to 'indra') diff --git a/indra/llcommon/lllslconstants.h b/indra/llcommon/lllslconstants.h index 9f32598e61..83fa5bc249 100755 --- a/indra/llcommon/lllslconstants.h +++ b/indra/llcommon/lllslconstants.h @@ -179,6 +179,24 @@ const S32 OBJECT_VELOCITY = 5; const S32 OBJECT_OWNER = 6; const S32 OBJECT_GROUP = 7; const S32 OBJECT_CREATOR = 8; +const S32 OBJECT_RUNNING_SCRIPT_COUNT = 9; +const S32 OBJECT_TOTAL_SCRIPT_COUNT = 10; +const S32 OBJECT_SCRIPT_MEMORY = 11; +const S32 OBJECT_SCRIPT_TIME = 12; +const S32 OBJECT_PRIM_EQUIVALENCE = 13; +const S32 OBJECT_SERVER_COST = 14; +const S32 OBJECT_STREAMING_COST = 15; +const S32 OBJECT_PHYSICS_COST = 16; +const S32 OBJECT_CHARACTER_TIME = 17; +const S32 OBJECT_ROOT = 18; +const S32 OBJECT_ATTACHED_POINT = 19; +const S32 OBJECT_PATHFINDING_TYPE = 20; +const S32 OBJECT_PHYSICS = 21; +const S32 OBJECT_PHANTOM = 22; +const S32 OBJECT_TEMP_ON_REZ = 23; +const S32 OBJECT_RENDER_WEIGHT = 24; +const S32 OBJECT_ATTACHMENT_GEOMETRY_BYTES = 25; +const S32 OBJECT_ATTACHMENT_SURFACE_AREA = 26; // llTextBox() magic token string - yes this is a hack. sue me. char const* const TEXTBOX_MAGIC_TOKEN = "!!llTextBox!!"; diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index c5d11af22b..e7de5b6210 100755 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -273,6 +273,24 @@ int yyerror(const char *fmt, ...); "OBJECT_OWNER" { count(); yylval.ival = OBJECT_OWNER; return(INTEGER_CONSTANT); } "OBJECT_GROUP" { count(); yylval.ival = OBJECT_GROUP; return(INTEGER_CONSTANT); } "OBJECT_CREATOR" { count(); yylval.ival = OBJECT_CREATOR; return(INTEGER_CONSTANT); } +"OBJECT_RUNNING_SCRIPT_COUNT" { count(); yylval.ival = OBJECT_RUNNING_SCRIPT_COUNT; return(INTEGER_CONSTANT); } +"OBJECT_TOTAL_SCRIPT_COUNT" { count(); yylval.ival = OBJECT_TOTAL_SCRIPT_COUNT; return(INTEGER_CONSTANT); } +"OBJECT_SCRIPT_MEMORY" { count(); yylval.ival = OBJECT_SCRIPT_MEMORY; return(INTEGER_CONSTANT); } +"OBJECT_SCRIPT_TIME" { count(); yylval.ival = OBJECT_SCRIPT_TIME; return(INTEGER_CONSTANT); } +"OBJECT_PRIM_EQUIVALENCE" { count(); yylval.ival = OBJECT_PRIM_EQUIVALENCE; return(INTEGER_CONSTANT); } +"OBJECT_SERVER_COST" { count(); yylval.ival = OBJECT_SERVER_COST; return(INTEGER_CONSTANT); } +"OBJECT_STREAMING_COST" { count(); yylval.ival = OBJECT_STREAMING_COST; return(INTEGER_CONSTANT); } +"OBJECT_PHYSICS_COST" { count(); yylval.ival = OBJECT_PHYSICS_COST; return(INTEGER_CONSTANT); } +"OBJECT_CHARACTER_TIME" { count(); yylval.ival = OBJECT_CHARACTER_TIME; return(INTEGER_CONSTANT); } +"OBJECT_ROOT" { count(); yylval.ival = OBJECT_ROOT; return(INTEGER_CONSTANT); } +"OBJECT_ATTACHED_POINT" { count(); yylval.ival = OBJECT_ATTACHED_POINT; return(INTEGER_CONSTANT); } +"OBJECT_PATHFINDING_TYPE" { count(); yylval.ival = OBJECT_PATHFINDING_TYPE; return(INTEGER_CONSTANT); } +"OBJECT_PHYSICS" { count(); yylval.ival = OBJECT_PHYSICS; return(INTEGER_CONSTANT); } +"OBJECT_PHANTOM" { count(); yylval.ival = OBJECT_PHANTOM; return(INTEGER_CONSTANT); } +"OBJECT_TEMP_ON_REZ" { count(); yylval.ival = OBJECT_TEMP_ON_REZ; return(INTEGER_CONSTANT); } +"OBJECT_RENDER_WEIGHT" { count(); yylval.ival = OBJECT_RENDER_WEIGHT; return(INTEGER_CONSTANT); } +"OBJECT_ATTACHMENT_GEOMETRY_BYTES" { count(); yylval.ival = OBJECT_ATTACHMENT_GEOMETRY_BYTES; return(INTEGER_CONSTANT); } +"OBJECT_ATTACHMENT_SURFACE_AREA" { count(); yylval.ival = OBJECT_ATTACHMENT_SURFACE_AREA; return(INTEGER_CONSTANT); } "TYPE_INTEGER" { count(); yylval.ival = LST_INTEGER; return(INTEGER_CONSTANT); } "TYPE_FLOAT" { count(); yylval.ival = LST_FLOATINGPOINT; return(INTEGER_CONSTANT); } diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 02adbc7af4..766c9a4604 100755 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -177,6 +177,25 @@ OBJECT_VELOCITY Used with llGetObjectDetails to get an object's velocity OBJECT_OWNER Used with llGetObjectDetails to get an object's owner's key. Will be NULL_KEY if group owned OBJECT_GROUP Used with llGetObjectDetails to get an object's group's key OBJECT_CREATOR Used with llGetObjectDetails to get an object's creator's key +OBJECT_RUNNING_SCRIPT_COUNT Used with llGetObjectDetails to get the number of running scripts in an object +OBJECT_TOTAL_SCRIPT_COUNT Used with llGetObjectDetails to get the total number of scripts in an object +OBJECT_SCRIPT_MEMORY Used with llGetObjectDetails to get the total amount of script memory in an object +OBJECT_SCRIPT_TIME Used with llGetObjectDetails to get the average script time used by an object +OBJECT_PRIM_EQUIVALENCE Used with llGetObjectDetails to get the prim equivalence of an object +OBJECT_SERVER_COST Used with llGetObjectDetails to get the server cost of an object +OBJECT_STREAMING_COST Used with llGetObjectDetails to get the streaming (download) cost of an object +OBJECT_PHYSICS_COST Used with llGetObjectDetails to get the physics cost of an object +OBJECT_CHARACTER_TIME Used with llGetObjectDetails to get the pathfinding time (seconds) for an object +OBJECT_ROOT Used with llGetObjectDetails to get root ID of an object +OBJECT_ATTACHED_POINT Used with llGetObjectDetails to get attachent point where an object is attached +OBJECT_PATHFINDING_TYPE Used with llGetObjectDetails to get the pathfinding setting of an object +OBJECT_PHYSICS Used with llGetObjectDetails to determine if the object is physical or not +OBJECT_PHANTOM Used with llGetObjectDetails to determine if the object is phantom or not +OBJECT_TEMP_ON_REZ Used with llGetObjectDetails to determine if the object is temporary or not +OBJECT_RENDER_WEIGHT Used with llGetObjectDetails to return an avatar's rendering weight +OBJECT_ATTACHMENT_GEOMETRY_BYTES Used with llGetObjectDetails to return an avatar's attachment rendering geometry bytes +OBJECT_ATTACHMENT_SURFACE_AREA Used with llGetObjectDetails to return an avatar's attachment surface area + # some vehicle params VEHICLE_TYPE_NONE -- cgit v1.2.3 From e5bdb0f0e1b3c48173e36b54da0f25c7d535df49 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 21 May 2013 13:50:49 -0700 Subject: MAINT-2676 - Set home to here - screen_home.bmp not saved. Reviewed by Kelly. --- indra/newview/llviewermessage.cpp | 52 ++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 9894ec7c07..d6ba803c46 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -5938,19 +5938,42 @@ bool attempt_standard_notification(LLMessageSystem* msgsystem) } +static void process_special_alert_messages(const std::string & message) +{ + // Do special handling for alert messages. This is a legacy hack, and any actual displayed + // text should be altered in the notifications.xml files. + if ( message == "You died and have been teleported to your home location") + { + LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT); + } + else if( message == "Home position set." ) + { + // save the home location image to disk + std::string snap_filename = gDirUtilp->getLindenUserDir(); + snap_filename += gDirUtilp->getDirDelimiter(); + snap_filename += SCREEN_HOME_FILENAME; + gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE); + } +} + + + void process_agent_alert_message(LLMessageSystem* msgsystem, void** user_data) { // make sure the cursor is back to the usual default since the // alert is probably due to some kind of error. gViewerWindow->getWindow()->resetBusyCount(); + std::string message; + msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, message); + + process_special_alert_messages(message); + if (!attempt_standard_notification(msgsystem)) { BOOL modal = FALSE; msgsystem->getBOOL("AlertData", "Modal", modal); - std::string buffer; - msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, buffer); - process_alert_core(buffer, modal); + process_alert_core(message, modal); } } @@ -5965,12 +5988,15 @@ void process_alert_message(LLMessageSystem *msgsystem, void **user_data) // alert is probably due to some kind of error. gViewerWindow->getWindow()->resetBusyCount(); + std::string message; + msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, message); + + process_special_alert_messages(message); + if (!attempt_standard_notification(msgsystem)) { BOOL modal = FALSE; - std::string buffer; - msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, buffer); - process_alert_core(buffer, modal); + process_alert_core(message, modal); } } @@ -6000,20 +6026,6 @@ bool handle_special_alerts(const std::string &pAlertName) void process_alert_core(const std::string& message, BOOL modal) { - // HACK -- handle callbacks for specific alerts. It also is localized in notifications.xml - if ( message == "You died and have been teleported to your home location") - { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT); - } - else if( message == "Home position set." ) - { - // save the home location image to disk - std::string snap_filename = gDirUtilp->getLindenUserDir(); - snap_filename += gDirUtilp->getDirDelimiter(); - snap_filename += SCREEN_HOME_FILENAME; - gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE); - } - const std::string ALERT_PREFIX("ALERT: "); const std::string NOTIFY_PREFIX("NOTIFY: "); if (message.find(ALERT_PREFIX) == 0) -- cgit v1.2.3 From 473474b94969799d2835191072c5bca1b7d431d8 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 22 May 2013 16:51:42 -0700 Subject: Revert changes for MAINT-2616 due to licensing issues, need a full patch submitted to be acceptable --- indra/llrender/llglslshader.cpp | 1 - indra/llrender/llglslshader.h | 3 -- indra/llrender/llrender2dutils.cpp | 22 +---------- .../shaders/class1/interface/solidcolorIntelV.glsl | 44 ---------------------- indra/newview/llselectmgr.cpp | 10 +---- indra/newview/llviewershadermgr.cpp | 19 ---------- 6 files changed, 3 insertions(+), 96 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class1/interface/solidcolorIntelV.glsl (limited to 'indra') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 8a0ca95a78..298a03f32a 100755 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -57,7 +57,6 @@ bool LLGLSLShader::sNoFixedFunction = false; //UI shader -- declared here so llui_libtest will link properly LLGLSLShader gUIProgram; LLGLSLShader gSolidColorProgram; -LLGLSLShader gSolidColorProgramIntel; BOOL shouldChange(const LLVector4& v1, const LLVector4& v2) { diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index cd097b8e0b..019d5a86d6 100755 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -160,8 +160,5 @@ extern LLGLSLShader gSolidColorProgram; //Alpha mask shader (declared here so llappearance can access properly) extern LLGLSLShader gAlphaMaskProgram; -// Solid color Shader for Intel Graphics -extern LLGLSLShader gSolidColorProgramIntel; - #endif diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp index 3c6848efaa..d3cfbaf03a 100644 --- a/indra/llrender/llrender2dutils.cpp +++ b/indra/llrender/llrender2dutils.cpp @@ -443,16 +443,7 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex { if (LLGLSLShader::sNoFixedFunction) { - // When running with a intel gfx card, do not use the solidcolor?.glsl files. Instead use a custom one - // for those cards. Passing color as a uniform and not a shader attribute - if(gGLManager.mIsIntel) - { - gSolidColorProgramIntel.bind(); - } - else - { - gSolidColorProgram.bind(); - } + gSolidColorProgram.bind(); } else { @@ -463,16 +454,7 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex gGL.getTexUnit(0)->bind(image, true); - // When running with a intel gfx card, do not use the solidcolor?.glsl files. Instead use a custom one - // for those cards. Passing color as a uniform and not a shader attribute - if( solid_color && LLGLSLShader::sNoFixedFunction && gGLManager.mIsIntel ) - { - gGL.diffuseColor4fv(color.mV); - } - else - { - gGL.color4fv(color.mV); - } + gGL.color4fv(color.mV); const S32 NUM_VERTICES = 9 * 4; // 9 quads LLVector2 uv[NUM_VERTICES]; diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorIntelV.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorIntelV.glsl deleted file mode 100644 index dcf38c27ce..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/solidcolorIntelV.glsl +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file solidcolorV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 modelview_projection_matrix; - -uniform vec4 color; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void main() -{ - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); -// vertex_color = diffuse_color; - vertex_color = color; - vary_texcoord0 = texcoord0; -} - diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 02ace86b95..4681efd3e5 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6051,15 +6051,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) if (shader) { //switch to "solid color" program for SH-2690 -- works around driver bug causing bad triangles when rendering silhouettes - if(gGLManager.mIsIntel) - { - gSolidColorProgramIntel.bind(); - gGL.diffuseColor4fv(color.mV); - } - else - { - gSolidColorProgram.bind(); - } + gSolidColorProgram.bind(); } gGL.matrixMode(LLRender::MM_MODELVIEW); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ef5ccb5120..7d7889845d 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -640,7 +640,6 @@ void LLViewerShaderMgr::unloadShaders() gTwoTextureAddProgram.unload(); gOneTextureNoColorProgram.unload(); gSolidColorProgram.unload(); - gSolidColorProgramIntel.unload(); gObjectFullbrightNoColorProgram.unload(); gObjectFullbrightNoColorWaterProgram.unload(); @@ -2704,24 +2703,6 @@ BOOL LLViewerShaderMgr::loadShadersInterface() } } - // When running with a intel gfx card, do not use the solidcolor?.glsl files. Instead use a custom one - // for those cards. Passing color as a uniform and not a shader attribute - if (success) - { - gSolidColorProgramIntel.mName = "Solid Color Shader for Intel"; - gSolidColorProgramIntel.mShaderFiles.clear(); - gSolidColorProgramIntel.mShaderFiles.push_back(make_pair("interface/solidcolorIntelV.glsl", GL_VERTEX_SHADER_ARB)); - gSolidColorProgramIntel.mShaderFiles.push_back(make_pair("interface/solidcolorF.glsl", GL_FRAGMENT_SHADER_ARB)); // The standard fragment shader is just fine. So keep it. - gSolidColorProgramIntel.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; - success = gSolidColorProgramIntel.createShader(NULL, NULL); - if (success) - { - gSolidColorProgramIntel.bind(); - gSolidColorProgramIntel.uniform1i(sTex0, 0); - gSolidColorProgramIntel.unbind(); - } - } - if (success) { gOcclusionProgram.mName = "Occlusion Shader"; -- cgit v1.2.3 From 8420e8d5db1b9987f57fa542d81e450f54aec16f Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 3 Jun 2013 15:53:34 -0700 Subject: Fix build --- indra/newview/llmeshrepository.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index b30576171e..83b7cae347 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1237,7 +1237,6 @@ bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* dat } mPendingLOD.erase(iter); } - } } return true; -- cgit v1.2.3 From 8511385a5407181ced7bb226d4054185c597d05e Mon Sep 17 00:00:00 2001 From: Simon Linden Date: Thu, 6 Jun 2013 18:16:44 -0700 Subject: MAINT-2764 : Planar texture mapping with bumpiness and path cut breaks under forward rendering. Will get Dave P to review --- indra/newview/llvovolume.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 00a109546e..98943b194e 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4268,8 +4268,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 bump_count = 0; U32 simple_count = 0; U32 alpha_count = 0; - - U32 useage = group->mSpatialPartition->mBufferUsage; @@ -4709,15 +4707,15 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bump_mask |= LLVertexBuffer::MAP_BINORMAL; genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, simple_count, FALSE, TRUE); genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, fullbright_count, FALSE, TRUE); - genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, bump_count, FALSE, FALSE); + genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, bump_count, FALSE, TRUE); genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, alpha_count, TRUE, TRUE); } else { - genDrawInfo(group, simple_mask, simple_faces, simple_count); - genDrawInfo(group, fullbright_mask, fullbright_faces, fullbright_count); + genDrawInfo(group, simple_mask, simple_faces, simple_count, FALSE, FALSE); + genDrawInfo(group, fullbright_mask, fullbright_faces, fullbright_count, FALSE, FALSE); genDrawInfo(group, bump_mask, bump_faces, bump_count, FALSE, FALSE); - genDrawInfo(group, alpha_mask, alpha_faces, alpha_count, TRUE); + genDrawInfo(group, alpha_mask, alpha_faces, alpha_count, TRUE, FALSE); } -- cgit v1.2.3 From f782e0192009b249edcb30ca2a5418ec7c1ddfa4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 15 Jun 2013 05:18:50 -0700 Subject: NORSPEC-267 fix UI feedback for materials edits not appearing for observers when obj was selected by them --- indra/llprimitive/lltextureentry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 597f078490..0db75a0e82 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -545,7 +545,7 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { mMaterialUpdatePending = true; mMaterialID = pMaterialID; - return TEM_CHANGE_NONE; + return TEM_CHANGE_TEXTURE; } mMaterialUpdatePending = false; -- cgit v1.2.3 From d75667560c35a578cc3876bde485ca2a44604992 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 15 Jun 2013 07:19:23 -0700 Subject: Silence spurious asserts when pool is cleared at exactly it's limit --- indra/llcommon/llapr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index a0802c6adf..b7815b0e35 100755 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -226,7 +226,7 @@ void LLVolatileAPRPool::clearVolatileAPRPool() llassert_always(mNumActiveRef > 0) ; } - llassert(mNumTotalRef < (FULL_VOLATILE_APR_POOL << 2)) ; + llassert(mNumTotalRef <= (FULL_VOLATILE_APR_POOL << 2)) ; } BOOL LLVolatileAPRPool::isFull() -- cgit v1.2.3 From c603eb5ece7ca2f2faa870bfd89f5f4e71e2b8f0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 17 Jun 2013 08:03:32 -0700 Subject: MAINT-318 prevent crashes from incomplete quads and lines and prevent drivers from crashing to desktop when passed short buffers --- indra/llrender/llrender.cpp | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index c60eb8d9d9..f2f1b62be0 100755 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1849,35 +1849,36 @@ void LLRender::flush() sUIVerts += mCount; } - if (gDebugGL) + //store mCount in a local variable to avoid re-entrance (drawArrays may call flush) + U32 count = mCount; + + if (mMode == LLRender::QUADS && !sGLCoreProfile) { - if (mMode == LLRender::QUADS && !sGLCoreProfile) + if (mCount%4 != 0) { - if (mCount%4 != 0) - { - llerrs << "Incomplete quad rendered." << llendl; - } + count -= (mCount % 4); + llwarns << "Incomplete quad requested." << llendl; } - - if (mMode == LLRender::TRIANGLES) + } + + if (mMode == LLRender::TRIANGLES) + { + if (mCount%3 != 0) { - if (mCount%3 != 0) - { - llerrs << "Incomplete triangle rendered." << llendl; - } + count -= (mCount % 3); + llwarns << "Incomplete triangle requested." << llendl; } - - if (mMode == LLRender::LINES) + } + + if (mMode == LLRender::LINES) + { + if (mCount%2 != 0) { - if (mCount%2 != 0) - { - llerrs << "Incomplete line rendered." << llendl; - } + count -= (mCount % 2); + llwarns << "Incomplete line requested." << llendl; } } - - //store mCount in a local variable to avoid re-entrance (drawArrays may call flush) - U32 count = mCount; + mCount = 0; if (mBuffer->useVBOs() && !mBuffer->isLocked()) -- cgit v1.2.3 From c1b7c8cacb6f6bcb8f6b9c7f73e059a41fee8c33 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 17 Jun 2013 12:56:08 -0700 Subject: NORSPEC-246 Force light func to use GL_R32F format for more precision on older nV mobile cards with single FP hardware --- indra/newview/pipeline.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 8942092221..4a1b182fd2 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1190,7 +1190,14 @@ void LLPipeline::releaseLUTBuffers() { if (mLightFunc) { - LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, GL_R16F, 0, 1, &mLightFunc); + U32 pix_format = GL_R16F; +#if LL_DARWIN + if (gGLManager.mIsMobileGF) + { + pix_format = GL_R32F; + } +#endif + LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, pix_format, 0, 1, &mLightFunc); mLightFunc = 0; } } @@ -1367,7 +1374,7 @@ void LLPipeline::createLUTBuffers() // This is fine, given we only need to create our LUT once per buffer initialization. spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); - // Since we use R16F, we no longer have a dynamic range issue we need to work around here. + // Since we use R16/32F, we no longer have a dynamic range issue we need to work around here. // Though some older drivers may not like this, newer drivers shouldn't have this problem. ls[y*lightResX+x] = spec; @@ -1390,9 +1397,16 @@ void LLPipeline::createLUTBuffers() } } - LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, GL_R16F, 1, &mLightFunc); + U32 pix_format = GL_R16F; +#if LL_DARWIN + if (gGLManager.mIsMobileGF) + { + pix_format = GL_R32F; + } +#endif + LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, pix_format, 1, &mLightFunc); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_R16F, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); //LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_UNSIGNED_BYTE, lightResX, lightResY, GL_RED, GL_UNSIGNED_BYTE, ls, false); gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); -- cgit v1.2.3 From 0dbe156e2317f8e34f2f0cfa65dc89ea30cd18f1 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 18 Jun 2013 09:10:13 -0700 Subject: NORSPEC-246 make 32F light LUT apply to all OS X machines as several non-nV cards were also failing --- indra/newview/pipeline.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4a1b182fd2..48f29b3237 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1192,10 +1192,9 @@ void LLPipeline::releaseLUTBuffers() { U32 pix_format = GL_R16F; #if LL_DARWIN - if (gGLManager.mIsMobileGF) - { - pix_format = GL_R32F; - } + // Need to work around limited precision with 10.6.8 and older drivers + // + pix_format = GL_R32F; #endif LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, pix_format, 0, 1, &mLightFunc); mLightFunc = 0; @@ -1399,10 +1398,9 @@ void LLPipeline::createLUTBuffers() U32 pix_format = GL_R16F; #if LL_DARWIN - if (gGLManager.mIsMobileGF) - { - pix_format = GL_R32F; - } + // Need to work around limited precision with 10.6.8 and older drivers + // + pix_format = GL_R32F; #endif LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, pix_format, 1, &mLightFunc); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); -- cgit v1.2.3 From 42a46595558c5d87f62c9fd8e52fdad1c6960e4d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 20 Jun 2013 09:34:30 -0700 Subject: NORSPEC-278 fix misuse of legacy bumps when rendering objects with TE bumpmap setting of 18 aka BUMPY_TEXTURE --- indra/newview/llvovolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3be1f52352..685f854573 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5354,7 +5354,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE; } - bool use_legacy_bump = te->getBumpmap() && (!mat || mat->getNormalID().isNull()); + bool use_legacy_bump = te->getBumpmap() && (te->getBumpmap() < 18) && (!mat || mat->getNormalID().isNull()); if (mat && LLPipeline::sRenderDeferred && !hud_group) { -- cgit v1.2.3 From 65f0972a64f77388752794610e6dedc27b9eb228 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 20 Jun 2013 12:41:46 -0700 Subject: NORSPEC-262 make drag and drop aware of editing context so that editing normal/spec textures causes application to the correct tex channel --- indra/newview/llfloatertools.h | 2 ++ indra/newview/llpanelface.cpp | 37 +++++++++++++++-------------- indra/newview/llpanelface.h | 21 +++++++++++++---- indra/newview/llselectmgr.cpp | 6 ++--- indra/newview/lltooldraganddrop.cpp | 47 ++++++++++++++++++++++++++++++++++++- indra/newview/pipeline.cpp | 4 +++- 6 files changed, 89 insertions(+), 28 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatertools.h b/indra/newview/llfloatertools.h index ecb0092a6f..189bae46c2 100755 --- a/indra/newview/llfloatertools.h +++ b/indra/newview/llfloatertools.h @@ -109,6 +109,8 @@ public: static void setGridMode(S32 mode); + LLPanelFace* getPanelFace() { return mPanelFace; } + private: void refresh(); void refreshMedia(); diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 911af9df04..3869219da6 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -66,7 +66,7 @@ #include "llvovolume.h" #include "lluictrlfactory.h" #include "llpluginclassmedia.h" -#include "llviewertexturelist.h" +#include "llviewertexturelist.h"// Update sel manager as to which channel we're editing so it can reflect the correct overlay UI // // Constant definitions for comboboxes @@ -89,6 +89,19 @@ const S32 SHINY_TEXTURE = 4; // use supplied specular map // std::string USE_TEXTURE; +LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit() +{ + LLComboBox* combobox_matmedia = getChild("combobox matmedia"); + LLComboBox* combobox_mattype = getChild("combobox mattype"); + + LLRender::eTexIndex channel_to_edit = (combobox_matmedia && combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? + (combobox_mattype ? (LLRender::eTexIndex)combobox_mattype->getCurrentIndex() : LLRender::DIFFUSE_MAP) : LLRender::DIFFUSE_MAP; + + channel_to_edit = (channel_to_edit == LLRender::NORMAL_MAP) ? (getCurrentNormalMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit; + channel_to_edit = (channel_to_edit == LLRender::SPECULAR_MAP) ? (getCurrentSpecularMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit; + return channel_to_edit; +} + // Things the UI provides... // LLUUID LLPanelFace::getCurrentNormalMap() { return getChild("bumpytexture control")->getImageAssetID(); } @@ -1194,7 +1207,8 @@ void LLPanelFace::updateUI() getChildView("checkbox fullbright")->setEnabled(editable); getChild("checkbox fullbright")->setTentative(!identical_fullbright); } - + + // Repeats per meter { F32 repeats_diff = 1.f; @@ -1218,6 +1232,9 @@ void LLPanelFace::updateUI() F32 repeats = 1.0f; U32 material_type = (combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? combobox_mattype->getCurrentIndex() : MATTYPE_DIFFUSE; + + LLSelectMgr::getInstance()->setTextureChannel(LLRender::eTexIndex(material_type)); + switch (material_type) { default: @@ -1328,18 +1345,6 @@ void LLPanelFace::updateUI() getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); } - // Update sel manager as to which channel we're editing so it can reflect the correct overlay UI - // NORSPEC-103 - LLRender::eTexIndex channel_to_edit = (combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? (LLRender::eTexIndex)combobox_mattype->getCurrentIndex() : LLRender::DIFFUSE_MAP; - - if ( ((channel_to_edit == LLRender::NORMAL_MAP) && material->getNormalID().isNull()) - ||((channel_to_edit == LLRender::SPECULAR_MAP) && material->getSpecularID().isNull())) - { - channel_to_edit = LLRender::DIFFUSE_MAP; - } - - LLSelectMgr::getInstance()->setTextureChannel(channel_to_edit); - // Bumpy (normal) texture_ctrl = getChild("bumpytexture control"); texture_ctrl->setImageAssetID(material->getNormalID()); @@ -1365,10 +1370,6 @@ void LLPanelFace::updateUI() updateBumpyControls(!material->getNormalID().isNull(), true); } } - else - { - LLSelectMgr::getInstance()->setTextureChannel(LLRender::DIFFUSE_MAP); - } } // Set variable values for numeric expressions diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 42c1f6bd48..834ad9e14c 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -100,6 +100,19 @@ public: void setMediaURL(const std::string& url); void setMediaType(const std::string& mime_type); + LLMaterialPtr createDefaultMaterial(LLMaterialPtr current_material) + { + LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial()); + llassert_always(new_material); + + // Preserve old diffuse alpha mode or assert correct default blend mode as appropriate for the alpha channel content of the diffuse texture + // + new_material->setDiffuseAlphaMode(current_material.isNull() ? (isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE) : current_material->getDiffuseAlphaMode()); + return new_material; + } + + LLRender::eTexIndex getTextureChannelToEdit(); + protected: void getState(); @@ -178,6 +191,8 @@ protected: static F32 valueGlow(LLViewerObject* object, S32 face); + + private: bool isAlpha() { return mIsAlpha; } @@ -234,7 +249,7 @@ private: { if (_edit) { - LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial()); + LLMaterialPtr new_material = _panel->createDefaultMaterial(current_material); llassert_always(new_material); // Determine correct alpha mode for current diffuse texture @@ -242,10 +257,6 @@ private: // U8 default_alpha_mode = (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - // Default to matching expected state of UI - // - new_material->setDiffuseAlphaMode(current_material.isNull() ? default_alpha_mode : current_material->getDiffuseAlphaMode()); - // Do "It"! // _edit->apply(new_material); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 0cbdbe16a3..7b397d46f3 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -91,7 +91,7 @@ #include "llvovolume.h" #include "pipeline.h" #include "llviewershadermgr.h" - +#include "llpanelface.h" #include "llglheaders.h" LLViewerObject* getSelectedParentObject(LLViewerObject *object) ; @@ -2534,7 +2534,7 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) if (tep && !tep->getMaterialParams().isNull()) { LLMaterialPtr orig = tep->getMaterialParams(); - LLMaterialPtr p = new LLMaterial(orig->asLLSD()); + LLMaterialPtr p = gFloaterTools->getPanelFace()->createDefaultMaterial(orig); p->setNormalRepeat(normal_scale_s, normal_scale_t); p->setSpecularRepeat(specular_scale_s, specular_scale_t); @@ -2560,8 +2560,8 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) if (tep && !tep->getMaterialParams().isNull()) { LLMaterialPtr orig = tep->getMaterialParams(); + LLMaterialPtr p = gFloaterTools->getPanelFace()->createDefaultMaterial(orig); - LLMaterialPtr p = new LLMaterial(orig->asLLSD()); p->setNormalRepeat(normal_scale_s, normal_scale_t); p->setSpecularRepeat(specular_scale_s, specular_scale_t); diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index e085834326..ef7d0cd81b 100755 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -58,6 +58,7 @@ #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llworld.h" +#include "llpanelface.h" // syntactic sugar #define callMemberFunction(object,ptrToMember) ((object).*(ptrToMember)) @@ -1163,7 +1164,51 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj, // update viewer side image in anticipation of update from simulator LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id); LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); - hit_obj->setTEImage(hit_face, image); + + LLTextureEntry* tep = hit_obj ? (hit_obj->getTE(hit_face)) : NULL; + + LLPanelFace* panel_face = gFloaterTools->getPanelFace(); + + if (gFloaterTools->getVisible() && panel_face) + { + switch (LLSelectMgr::getInstance()->getTextureChannel()) + { + + case 0: + default: + { + hit_obj->setTEImage(hit_face, image); + } + break; + + case 1: + { + LLMaterialPtr old_mat = tep->getMaterialParams(); + LLMaterialPtr new_mat = panel_face->createDefaultMaterial(old_mat); + new_mat->setNormalID(asset_id); + tep->setMaterialParams(new_mat); + hit_obj->setTENormalMap(hit_face, asset_id); + LLMaterialMgr::getInstance()->put(hit_obj->getID(), hit_face, *new_mat); + } + break; + + case 2: + { + LLMaterialPtr old_mat = tep->getMaterialParams(); + LLMaterialPtr new_mat = panel_face->createDefaultMaterial(old_mat); + new_mat->setSpecularID(asset_id); + tep->setMaterialParams(new_mat); + hit_obj->setTESpecularMap(hit_face, asset_id); + LLMaterialMgr::getInstance()->put(hit_obj->getID(), hit_face, *new_mat); + } + break; + } + } + else + { + hit_obj->setTEImage(hit_face, image); + } + dialog_refresh_all(); // send the update to the simulator diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 56a3ebe3a8..d37b086ae3 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -111,6 +111,8 @@ #include "llpathinglib.h" #include "llfloaterpathfindingconsole.h" #include "llfloaterpathfindingcharacters.h" +#include "llfloatertools.h" +#include "llpanelface.h" #include "llpathfindingpathtool.h" #ifdef _DEBUG @@ -3962,7 +3964,7 @@ void LLPipeline::postSort(LLCamera& camera) { mSelectedFaces.clear(); - LLPipeline::setRenderHighlightTextureChannel(LLSelectMgr::getInstance()->getTextureChannel()); + LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit()); // Draw face highlights for selected faces. if (LLSelectMgr::getInstance()->getTEMode()) -- cgit v1.2.3 From 3a8cdb5d46cd12a5aad001e4bcec5b26f6f748ce Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 20 Jun 2013 15:27:22 -0700 Subject: NORSPEC-277 WIP backout old-school normal permutation --- .../shaders/class1/deferred/blurLightF.glsl | 17 ----------- .../shaders/class1/deferred/materialF.glsl | 17 ----------- .../shaders/class1/deferred/multiPointLightF.glsl | 17 ----------- .../shaders/class1/deferred/multiSpotLightF.glsl | 17 ----------- .../shaders/class1/deferred/pointLightF.glsl | 17 ----------- .../shaders/class1/deferred/softenLightF.glsl | 17 ----------- .../shaders/class1/deferred/spotLightF.glsl | 17 ----------- .../shaders/class1/deferred/sunLightSSAOF.glsl | 17 ----------- .../shaders/class2/deferred/multiSpotLightF.glsl | 17 ----------- .../shaders/class2/deferred/softenLightF.glsl | 17 ----------- .../shaders/class2/deferred/spotLightF.glsl | 17 ----------- .../shaders/class2/deferred/sunLightF.glsl | 17 ----------- .../shaders/class2/deferred/sunLightSSAOF.glsl | 17 ----------- indra/newview/llviewershadermgr.cpp | 34 ---------------------- 14 files changed, 255 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl index 968a5f6b3d..a4f54dff70 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl @@ -59,22 +59,6 @@ vec4 getPosition(vec2 pos_screen) return pos; } -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -91,7 +75,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 618ea747f5..6cd8caa113 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -428,22 +428,6 @@ VARYING vec3 vary_normal; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -460,7 +444,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index 868526d457..c95aa8bb3c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -56,22 +56,6 @@ uniform float far_z; uniform mat4 inv_proj; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -88,7 +72,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 getPosition(vec2 pos_screen) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 97bf49a605..7d39ad7bc1 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -67,22 +67,6 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -99,7 +83,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 correctWithGamma(vec4 col) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index caf20ce707..106d48bd71 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -54,22 +54,6 @@ uniform vec2 screen_res; uniform mat4 inv_proj; uniform vec4 viewport; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -86,7 +70,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 getPosition(vec2 pos_screen) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 08583ad0f2..f0d2746700 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -78,22 +78,6 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec3 decode_normal (vec2 enc) { vec2 fenc = enc*4-2; @@ -104,7 +88,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 getPosition_d(vec2 pos_screen, float depth) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 1975b18652..045d1a00cd 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -65,22 +65,6 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -97,7 +81,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 correctWithGamma(vec4 col) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl index 6653f57ee1..c0a5865bef 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl @@ -49,22 +49,6 @@ VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; uniform vec2 screen_res; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -81,7 +65,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 getPosition(vec2 pos_screen) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 780df9ed1a..0deb4fe3b6 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -68,22 +68,6 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -100,7 +84,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 correctWithGamma(vec4 col) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 67bac1f7c2..6e05091b57 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,22 +78,6 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -110,7 +94,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 getPosition_d(vec2 pos_screen, float depth) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index fc0e6b2388..7a4337c277 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -68,22 +68,6 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -100,7 +84,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 correctWithGamma(vec4 col) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 7b09dd29dd..95c09d3238 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -65,22 +65,6 @@ uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -97,7 +81,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 getPosition(vec2 pos_screen) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 01e34ed792..b5ff6404ea 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -66,22 +66,6 @@ uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -98,7 +82,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 getPosition(vec2 pos_screen) { diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index e24237522a..fa9c2ce51f 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -42,22 +42,6 @@ #include "llvosky.h" #include "llrender.h" -#if LL_DARWIN -#include "OpenGL/OpenGL.h" - -// include spec exp clamp to fix older mac rendering artifacts -// -#define SINGLE_FP_PERMUTATION(shader) \ - if (gGLManager.mIsMobileGF) \ - { \ - shader.addPermutation("SINGLE_FP_ONLY","1"); \ - } - - -#else -#define SINGLE_FP_PERMUTATION(shader) -#endif - #ifdef LL_RELEASE_FOR_DOWNLOAD #define UNIFORM_ERRS LL_WARNS_ONCE("Shader") #else @@ -1308,8 +1292,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() bool has_skin = i & 0x10; gDeferredMaterialProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0"); - SINGLE_FP_PERMUTATION(gDeferredMaterialProgram[i]); - if (has_skin) { gDeferredMaterialProgram[i].mFeatures.hasObjectSkinning = true; @@ -1368,8 +1350,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - SINGLE_FP_PERMUTATION(gDeferredLightProgram); - success = gDeferredLightProgram.createShader(NULL, NULL); } @@ -1381,8 +1361,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMultiLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMultiLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - SINGLE_FP_PERMUTATION(gDeferredMultiLightProgram); - success = gDeferredMultiLightProgram.createShader(NULL, NULL); } @@ -1394,8 +1372,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - SINGLE_FP_PERMUTATION(gDeferredSpotLightProgram); - success = gDeferredSpotLightProgram.createShader(NULL, NULL); } @@ -1407,8 +1383,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMultiSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - SINGLE_FP_PERMUTATION(gDeferredMultiSpotLightProgram); - success = gDeferredMultiSpotLightProgram.createShader(NULL, NULL); } @@ -1436,8 +1410,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB)); gDeferredSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - SINGLE_FP_PERMUTATION(gDeferredSunProgram); - success = gDeferredSunProgram.createShader(NULL, NULL); } @@ -1449,8 +1421,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredBlurLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - SINGLE_FP_PERMUTATION(gDeferredBlurLightProgram); - success = gDeferredBlurLightProgram.createShader(NULL, NULL); } @@ -1482,8 +1452,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - SINGLE_FP_PERMUTATION(gDeferredAlphaProgram); - success = gDeferredAlphaProgram.createShader(NULL, NULL); // Hack @@ -1600,8 +1568,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSoftenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - SINGLE_FP_PERMUTATION(gDeferredSoftenProgram); - if (gSavedSettings.getBOOL("RenderDeferredSSAO")) { //if using SSAO, take screen space light map into account as if shadows are enabled gDeferredSoftenProgram.mShaderLevel = llmax(gDeferredSoftenProgram.mShaderLevel, 2); -- cgit v1.2.3 From 80552a465e9169b7326c346f4685790ea459823a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 21 Jun 2013 12:19:07 -0500 Subject: Only render bounding boxes for volumes in info display. --- indra/newview/llspatialpartition.cpp | 39 +++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 6638b6640d..6f1d962497 100755 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2234,6 +2234,18 @@ void drawBox(const LLVector4a& c, const LLVector4a& r) void drawBoxOutline(const LLVector3& pos, const LLVector3& size) { + + llassert(pos.isFinite()); + llassert(size.isFinite()); + + llassert(!llisnan(pos.mV[0])); + llassert(!llisnan(pos.mV[1])); + llassert(!llisnan(pos.mV[2])); + + llassert(!llisnan(size.mV[0])); + llassert(!llisnan(size.mV[1])); + llassert(!llisnan(size.mV[2])); + LLVector3 v1 = size.scaledVec(LLVector3( 1, 1,1)); LLVector3 v2 = size.scaledVec(LLVector3(-1, 1,1)); LLVector3 v3 = size.scaledVec(LLVector3(-1,-1,1)); @@ -2966,20 +2978,23 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE) const LLVector4a* ext; LLVector4a pos, size; - //render face bounding boxes - for (S32 i = 0; i < drawable->getNumFaces(); i++) + if (drawable->getVOVolume()) { - LLFace* facep = drawable->getFace(i); - if (facep) + //render face bounding boxes + for (S32 i = 0; i < drawable->getNumFaces(); i++) { - ext = facep->mExtents; + LLFace* facep = drawable->getFace(i); + if (facep) + { + ext = facep->mExtents; - pos.setAdd(ext[0], ext[1]); - pos.mul(0.5f); - size.setSub(ext[1], ext[0]); - size.mul(0.5f); + pos.setAdd(ext[0], ext[1]); + pos.mul(0.5f); + size.setSub(ext[1], ext[0]); + size.mul(0.5f); - drawBoxOutline(pos,size); + drawBoxOutline(pos,size); + } } } @@ -4097,6 +4112,10 @@ public: if (!group->isEmpty()) { gGL.diffuseColor3f(0,0,1); + + llassert(group->mObjectBounds[0].isFinite3()); + llassert(group->mObjectBounds[1].isFinite3()); + drawBoxOutline(group->mObjectBounds[0], group->mObjectBounds[1]); } -- cgit v1.2.3 From 4696eeeb30ce4d01c3bcbe74c9024f05d848968a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 21 Jun 2013 17:07:37 -0500 Subject: Merge cleanup. --- indra/newview/llface.cpp | 9 ++++--- indra/newview/llspatialpartition.cpp | 2 +- indra/newview/llviewershadermgr.cpp | 4 +-- indra/newview/llvovolume.cpp | 48 +++++++++++++++++++++++++----------- 4 files changed, 42 insertions(+), 21 deletions(-) (limited to 'indra') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 606a595ca4..b2e3300ab3 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -2053,17 +2053,18 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, mask.clear(); mask.setElement<3>(); - LLVector4a* src = vf.mBinormals; - LLVector4a* end = vf.mBinormals+num_vertices; + LLVector4a* src = vf.mTangents; + LLVector4a* end = vf.mTangents+num_vertices; while (src < end) { LLVector4a tangent_out; - mat_normal.rotate(vf.mTangents[i], tangent_out); + mat_normal.rotate(*src, tangent_out); tangent_out.normalize3fast(); - tangent_out.setSelectWithMask(mask, vf.mTangents[i], tangent_out); + tangent_out.setSelectWithMask(mask, *src, tangent_out); tangent_out.store4a(tangents); + src++; tangents += 4; } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index b5dab96d93..4752e72de0 100755 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -4687,7 +4687,7 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, mSpecColor(1.0f, 1.0f, 1.0f, 0.5f), mBlendFuncSrc(LLRender::BF_SOURCE_ALPHA), mBlendFuncDst(LLRender::BF_ONE_MINUS_SOURCE_ALPHA), - mHasGlow(FALSE) + mHasGlow(FALSE), mEnvIntensity(0.0f), mAlphaMaskCutoff(0.5f), mDiffuseAlphaMode(0) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ac5472a15a..ca0077bf27 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1492,7 +1492,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredFullbrightShinyProgram.createShader(NULL, &mShinyUniforms); + success = gDeferredFullbrightShinyProgram.createShader(NULL, NULL); } if (success) @@ -1522,7 +1522,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSkinnedFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredSkinnedFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; - success = gDeferredSkinnedFullbrightShinyProgram.createShader(NULL, &mShinyUniforms); + success = gDeferredSkinnedFullbrightShinyProgram.createShader(NULL, NULL); } if (success) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 48b4673fd8..e26c54c23c 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4408,15 +4408,19 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) static LLFace** fullbright_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64); static LLFace** bump_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64); static LLFace** simple_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64); - static LLFace** norm_faces = (LLFace*) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*), 64); - static LLFace** spec_faces = (LLFace*) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*), 64); - static LLFace** normspec_faces = (LLFace*) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*), 64); + static LLFace** norm_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*), 64); + static LLFace** spec_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*), 64); + static LLFace** normspec_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*), 64); static LLFace** alpha_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64); U32 fullbright_count = 0; U32 bump_count = 0; U32 simple_count = 0; U32 alpha_count = 0; + U32 norm_count = 0; + U32 spec_count = 0; + U32 normspec_count = 0; + U32 useage = group->mSpatialPartition->mBufferUsage; @@ -4822,24 +4826,40 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { if (mat->getSpecularID().notNull()) { //has normal and specular maps (needs texcoord1, texcoord2, and tangent) - normspec_faces.push_back(facep); + if (normspec_count < MAX_FACE_COUNT) + { + normspec_faces[normspec_count++] = facep; + } } else { //has normal map (needs texcoord1 and tangent) - norm_faces.push_back(facep); + if (norm_count < MAX_FACE_COUNT) + { + norm_faces[norm_count++] = facep; + } } } else if (mat->getSpecularID().notNull()) { //has specular map but no normal map, needs texcoord2 - spec_faces.push_back(facep); + if (spec_count < MAX_FACE_COUNT) + { + spec_faces[spec_count++] = facep; + } } else { //has neither specular map nor normal map, only needs texcoord0 - simple_faces.push_back(facep); + if (simple_count < MAX_FACE_COUNT) + { + simple_faces[simple_count++] = facep; + } } } else if (te->getBumpmap()) { //needs normal + tangent + if (bump_count < MAX_FACE_COUNT) + { + bump_faces[bump_count++] = facep; + } } else if (te->getShiny() || !te->getFullbright()) { //needs normal @@ -4942,13 +4962,13 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX; } - genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, batch_textures, FALSE); - genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, FALSE, batch_textures); - genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, TRUE, batch_textures); - genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, FALSE); - genDrawInfo(group, norm_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, norm_faces, FALSE, FALSE); - genDrawInfo(group, spec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, spec_faces, FALSE, FALSE); - genDrawInfo(group, normspec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, normspec_faces, FALSE, FALSE); + genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, simple_count, FALSE, batch_textures, FALSE); + genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, fullbright_count, FALSE, batch_textures); + genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, alpha_count, TRUE, batch_textures); + genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, bump_count, FALSE, FALSE); + genDrawInfo(group, norm_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, norm_faces, norm_count, FALSE, FALSE); + genDrawInfo(group, spec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, spec_faces, spec_count, FALSE, FALSE); + genDrawInfo(group, normspec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, normspec_faces, normspec_count, FALSE, FALSE); if (!LLPipeline::sDelayVBUpdate) { -- cgit v1.2.3 From 559173f71196602dd85211a786af7829ab2877c4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 24 Jun 2013 06:44:14 -0700 Subject: NORSPEC-280 include fix to downsampleDepthRect shader making GL 3.3. drivers cry --- .../app_settings/shaders/class1/interface/downsampleDepthRectF.glsl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl index 2f89b8ed72..0e5dc08183 100644 --- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +#extension GL_ARB_texture_rectangle : enable + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else -- cgit v1.2.3 From 4841eaddb9dcfe6c6290f430121a6407b4ebe322 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 24 Jun 2013 10:18:37 -0700 Subject: MATBUG-194 WIP investigate if light func sampling precision is causing whirly's wierdness --- indra/newview/pipeline.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d37b086ae3..9713f963b9 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1400,13 +1400,9 @@ void LLPipeline::createLUTBuffers() ls[y*lightResX+x] = k;*/ } } - - U32 pix_format = GL_R16F; -#if LL_DARWIN // Need to work around limited precision with 10.6.8 and older drivers // - pix_format = GL_R32F; -#endif + U32 pix_format = GL_R32F; LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, pix_format, 1, &mLightFunc); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); -- cgit v1.2.3 From c07f47dee88db5e041648b38d92b173cce65aa9f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 24 Jun 2013 19:28:02 -0700 Subject: NORSPEC-259 nerfed copyContentsToFramebuffer handling of non-FBO sources --- indra/llrender/llrendertarget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 6e22712b94..09ef780424 100755 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -572,8 +572,10 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0 { if (!source.mFBO) { - llerrs << "Cannot copy framebuffer contents for non FBO render targets." << llendl; + llwarns << "Cannot copy framebuffer contents for non FBO render targets." << llendl; + return; } + { GLboolean write_depth = mask & GL_DEPTH_BUFFER_BIT ? TRUE : FALSE; -- cgit v1.2.3 From 53789008221043052360dcff2c1faeb11c64d9f6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 25 Jun 2013 10:21:59 -0700 Subject: NORSPEC-250 add setting to force higher LUT precision and made LUT cleanup match creation --- indra/newview/app_settings/settings.xml | 12 ++++++++++++ indra/newview/pipeline.cpp | 21 +++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 344079b640..ebb01fb330 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8592,6 +8592,18 @@ + RenderSpecularPrecision + + Comment + Force 32-bit floating point LUT + Persist + 1 + Type + U32 + Value + 0 + + RenderSpecularResX Comment diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9713f963b9..442b0b6d2d 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1201,7 +1201,15 @@ void LLPipeline::releaseLUTBuffers() { if (mLightFunc) { - LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, GL_R16F, 0, 1, &mLightFunc); + U32 use_high_precision = gSavedSettings.getU32("RenderSpecularPrecision"); + + U32 pix_format = use_high_precision ? GL_R32F : GL_R16F; + +#if LL_DARWIN + pix_format = GL_R32F; +#endif + + LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, pix_format, 0, 1, &mLightFunc); mLightFunc = 0; } } @@ -1402,7 +1410,16 @@ void LLPipeline::createLUTBuffers() } // Need to work around limited precision with 10.6.8 and older drivers // - U32 pix_format = GL_R32F; + U32 use_high_precision = gSavedSettings.getU32("RenderSpecularPrecision"); + + U32 pix_format = use_high_precision ? GL_R32F : GL_R16F; + +#if LL_DARWIN + // Forced to work around 10.6.8. driver bugs on most every GPU + // + pix_format = GL_R32F; +#endif + LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, pix_format, 1, &mLightFunc); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); -- cgit v1.2.3 From 705a0ab6770459d89474b3495b05214315a49c94 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 25 Jun 2013 11:16:27 -0700 Subject: NORSPEC-288 WIP fixes the issue with normal gen, but may be a bigger perf hit than we want --- indra/llmath/llvector4a.inl | 20 +++++++++++ indra/llmath/llvolume.cpp | 83 ++++++++++++++++++++++++--------------------- 2 files changed, 64 insertions(+), 39 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 7c52ffef21..558fe09323 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -409,6 +409,26 @@ inline void LLVector4a::normalize3fast() mQ = _mm_mul_ps( mQ, approxRsqrt ); } +inline void LLVector4a::normalize3fast_checked(LLVector4a* d) +{ + if (!isFinite3()) + { + *this = d ? *d : LLVector4a(0,1,0,1); + return; + } + + LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); + + if (lenSqrd.getF32ptr()[0] <= FLT_EPSILON) + { + *this = d ? *d : LLVector4a(0,1,0,1); + return; + } + + const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ); + mQ = _mm_mul_ps( mQ, approxRsqrt ); +} + // Return true if this vector is normalized with respect to x,y,z up to tolerance inline LLBool32 LLVector4a::isNormalized3( F32 tolerance ) const { diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 14cebfe5aa..58cac57e7f 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4472,6 +4472,9 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, continue; //skip degenerate face } + LLVector4a default_norm; + default_norm.set(0,1,0,1); + //for each edge for (S32 k = 0; k < 3; k++) { S32 index = face.mEdge[j*3+k]; @@ -4493,14 +4496,14 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, norm_mat.rotate(n[v1], t); - t.normalize3fast(); + t.normalize3fast_checked(&default_norm); normals.push_back(LLVector3(t[0], t[1], t[2])); mat.affineTransform(v[v2], t); vertices.push_back(LLVector3(t[0], t[1], t[2])); norm_mat.rotate(n[v2], t); - t.normalize3fast(); + t.normalize3fast_checked(&default_norm); normals.push_back(LLVector3(t[0], t[1], t[2])); } } @@ -6096,6 +6099,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) { VertexData corners[4]; VertexData baseVert; + LLVector4a default_norm; + default_norm.set(0,1,0,1); + for(S32 t = 0; t < 4; t++) { corners[t].getPosition().load3( mesh[offset + (grid_size*t)].mPos.mV); @@ -6108,8 +6114,8 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) lhs.setSub(corners[1].getPosition(), corners[0].getPosition()); LLVector4a rhs; rhs.setSub(corners[2].getPosition(), corners[1].getPosition()); - baseVert.getNormal().setCross3(lhs, rhs); - baseVert.getNormal().normalize3fast(); + baseVert.getNormal().setCross3(lhs, rhs); + baseVert.getNormal().normalize3fast_checked(&default_norm); } if(!(mTypeMask & TOP_MASK)) @@ -6559,17 +6565,12 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) d1.setSub(mPositions[mIndices[2]], mPositions[mIndices[0]]); LLVector4a normal; - normal.setCross3(d0,d1); - - if (normal.dot3(normal).getF32() > F_APPROXIMATELY_ZERO) - { - normal.normalize3fast(); - } - else - { //degenerate, make up a value - normal.set(0,0,1); - } + LLVector4a default_norm; + default_norm.set(0,1,0,1); + normal.setCross3(d0,d1); + normal.normalize3fast_checked(&default_norm); + llassert(llfinite(normal.getF32ptr()[0])); llassert(llfinite(normal.getF32ptr()[1])); llassert(llfinite(normal.getF32ptr()[2])); @@ -6611,11 +6612,13 @@ void LLVolumeFace::createTangents() CalculateTangentArray(mNumVertices, mPositions, mNormals, mTexCoords, mNumIndices/3, mIndices, mTangents); //normalize tangents + LLVector4a default_norm; + default_norm.set(0,1,0,1); for (U32 i = 0; i < mNumVertices; i++) { //binorm[i].normalize3fast(); //bump map/planar projection code requires normals to be normalized - mNormals[i].normalize3fast(); + mNormals[i].normalize3fast_checked(&default_norm); } } } @@ -6793,6 +6796,9 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat mat.loadu(mat_in); norm_mat.loadu(norm_mat_in); + LLVector4a default_norm; + default_norm.set(0,1,0,1); + for (U32 i = 0; i < face.mNumVertices; ++i) { //transform appended face position and store @@ -6800,7 +6806,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat //transform appended face normal and store norm_mat.rotate(src_norm[i], dst_norm[i]); - dst_norm[i].normalize3fast(); + dst_norm[i].normalize3fast_checked(&default_norm); //copy appended face texture coordinate dst_tc[i] = src_tc[i]; @@ -7213,42 +7219,41 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal, const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent) { - //LLVector4a *tan1 = new LLVector4a[vertexCount * 2]; LLVector4a* tan1 = (LLVector4a*) ll_aligned_malloc_16(vertexCount*2*sizeof(LLVector4a)); - LLVector4a* tan2 = tan1 + vertexCount; + LLVector4a* tan2 = tan1 + vertexCount; memset(tan1, 0, vertexCount*2*sizeof(LLVector4a)); - for (U32 a = 0; a < triangleCount; a++) - { - U32 i1 = *index_array++; - U32 i2 = *index_array++; - U32 i3 = *index_array++; + for (U32 a = 0; a < triangleCount; a++) + { + U32 i1 = *index_array++; + U32 i2 = *index_array++; + U32 i3 = *index_array++; - const LLVector4a& v1 = vertex[i1]; - const LLVector4a& v2 = vertex[i2]; - const LLVector4a& v3 = vertex[i3]; + const LLVector4a& v1 = vertex[i1]; + const LLVector4a& v2 = vertex[i2]; + const LLVector4a& v3 = vertex[i3]; - const LLVector2& w1 = texcoord[i1]; - const LLVector2& w2 = texcoord[i2]; - const LLVector2& w3 = texcoord[i3]; + const LLVector2& w1 = texcoord[i1]; + const LLVector2& w2 = texcoord[i2]; + const LLVector2& w3 = texcoord[i3]; const F32* v1ptr = v1.getF32ptr(); const F32* v2ptr = v2.getF32ptr(); const F32* v3ptr = v3.getF32ptr(); - float x1 = v2ptr[0] - v1ptr[0]; - float x2 = v3ptr[0] - v1ptr[0]; - float y1 = v2ptr[1] - v1ptr[1]; - float y2 = v3ptr[1] - v1ptr[1]; - float z1 = v2ptr[2] - v1ptr[2]; - float z2 = v3ptr[2] - v1ptr[2]; + float x1 = v2ptr[0] - v1ptr[0]; + float x2 = v3ptr[0] - v1ptr[0]; + float y1 = v2ptr[1] - v1ptr[1]; + float y2 = v3ptr[1] - v1ptr[1]; + float z1 = v2ptr[2] - v1ptr[2]; + float z2 = v3ptr[2] - v1ptr[2]; - float s1 = w2.mV[0] - w1.mV[0]; - float s2 = w3.mV[0] - w1.mV[0]; - float t1 = w2.mV[1] - w1.mV[1]; - float t2 = w3.mV[1] - w1.mV[1]; + float s1 = w2.mV[0] - w1.mV[0]; + float s2 = w3.mV[0] - w1.mV[0]; + float t1 = w2.mV[1] - w1.mV[1]; + float t2 = w3.mV[1] - w1.mV[1]; F32 rd = s1*t2-s2*t1; -- cgit v1.2.3 From 280a9d9827e4e5e0e1408cc8f9c20ef792a6c714 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 25 Jun 2013 18:02:08 -0500 Subject: MATBUG-78 Fix for alpha lighting falloff not matching opaque lighting falloff (again). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 0899caa2af..143af0576c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -101,7 +101,7 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float float dist = d/la; da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); da *= da; - da *= 1.4; + da *= 2.0; // spotlight coefficient. diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 618ea747f5..10b6385809 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -142,7 +142,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe float dist = d/la; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; - dist_atten *= 1.4; + dist_atten *= 2.0; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); -- cgit v1.2.3 From de4892b3373ef0c4562dba43a05fd19c973e9f30 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 25 Jun 2013 16:25:22 -0700 Subject: NORSPEC-288 remove unassertable asserts from restoring code to condition normals for this fix --- indra/newview/llface.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index f021f4ed0f..700b31f8d3 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -817,12 +817,6 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, size.mul(scale); } - // Catch potential badness from normalization before it happens - // - llassert(mat_normal.mMatrix[0].isFinite3() && (mat_normal.mMatrix[0].dot3(mat_normal.mMatrix[0]).getF32() > F_APPROXIMATELY_ZERO)); - llassert(mat_normal.mMatrix[1].isFinite3() && (mat_normal.mMatrix[1].dot3(mat_normal.mMatrix[1]).getF32() > F_APPROXIMATELY_ZERO)); - llassert(mat_normal.mMatrix[2].isFinite3() && (mat_normal.mMatrix[2].dot3(mat_normal.mMatrix[2]).getF32() > F_APPROXIMATELY_ZERO)); - mat_normal.mMatrix[0].normalize3fast(); mat_normal.mMatrix[1].normalize3fast(); mat_normal.mMatrix[2].normalize3fast(); -- cgit v1.2.3 From 1c6783fdb564cb10ade2a585a874ce951fff34e6 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 26 Jun 2013 09:43:01 -0400 Subject: NORSPEC-29: use the MaxMaterialsPerTransaction simulator feature if available --- indra/newview/llmaterialmgr.cpp | 86 +++++++++++++++++++++++++--------------- indra/newview/llmaterialmgr.h | 2 + indra/newview/llviewerregion.cpp | 2 +- indra/newview/llviewerregion.h | 2 +- 4 files changed, 57 insertions(+), 35 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 16871adc4d..ad9958546c 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -50,13 +50,12 @@ #define MATERIALS_CAP_MATERIAL_FIELD "Material" #define MATERIALS_CAP_OBJECT_ID_FIELD "ID" #define MATERIALS_CAP_MATERIAL_ID_FIELD "MaterialID" +#define SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION "MaxMaterialsPerTransaction" -#define MATERIALS_GET_MAX_ENTRIES 50 +#define MATERIALS_DEFAULT_MAX_ENTRIES 50 #define MATERIALS_GET_TIMEOUT (60.f * 20) -#define MATERIALS_POST_MAX_ENTRIES 50 #define MATERIALS_POST_TIMEOUT (60.f * 5) #define MATERIALS_PUT_THROTTLE_SECS 1.f -#define MATERIALS_PUT_MAX_ENTRIES 50 /** * LLMaterialsResponder helper class @@ -595,8 +594,9 @@ void LLMaterialMgr::processGetQueue() LLSD materialsData = LLSD::emptyArray(); material_queue_t& materials = itRegionQueue->second; - material_queue_t::iterator loopMaterial = materials.begin(); - while ( (materials.end() != loopMaterial) && (materialsData.size() <= MATERIALS_GET_MAX_ENTRIES) ) + U32 max_entries = getMaxEntries(regionp); + material_queue_t::iterator loopMaterial = materials.begin(); + while ( (materials.end() != loopMaterial) && (materialsData.size() < max_entries) ) { material_queue_t::iterator itMaterial = loopMaterial++; materialsData.append((*itMaterial).asLLSD()); @@ -680,39 +680,43 @@ void LLMaterialMgr::processPutQueue() const LLUUID& object_id = itQueue->first; const LLViewerObject* objectp = gObjectList.findObject(object_id); - if ( (!objectp) || (!objectp->getRegion()) ) + if ( !objectp ) { - LL_WARNS("Materials") << "Object or object region is NULL" << LL_ENDL; - + LL_WARNS("Materials") << "Object is NULL" << LL_ENDL; mPutQueue.erase(itQueue); - continue; - } - - const LLViewerRegion* regionp = objectp->getRegion(); - if (!regionp->capabilitiesReceived()) - { - continue; } - - LLSD& facesData = requests[regionp]; - - facematerial_map_t& face_map = itQueue->second; - facematerial_map_t::iterator itFace = face_map.begin(); - while ( (face_map.end() != itFace) && (facesData.size() < MATERIALS_GET_MAX_ENTRIES) ) + else { - LLSD faceData = LLSD::emptyMap(); - faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(itFace->first); - faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast(objectp->getLocalID()); - if (!itFace->second.isNull()) + const LLViewerRegion* regionp = objectp->getRegion(); + if ( !regionp ) { - faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD(); + LL_WARNS("Materials") << "Object region is NULL" << LL_ENDL; + mPutQueue.erase(itQueue); + } + else if ( regionp->capabilitiesReceived()) + { + LLSD& facesData = requests[regionp]; + + facematerial_map_t& face_map = itQueue->second; + U32 max_entries = getMaxEntries(regionp); + facematerial_map_t::iterator itFace = face_map.begin(); + while ( (face_map.end() != itFace) && (facesData.size() < max_entries) ) + { + LLSD faceData = LLSD::emptyMap(); + faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(itFace->first); + faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast(objectp->getLocalID()); + if (!itFace->second.isNull()) + { + faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD(); + } + facesData.append(faceData); + face_map.erase(itFace++); + } + if (face_map.empty()) + { + mPutQueue.erase(itQueue); + } } - facesData.append(faceData); - face_map.erase(itFace++); - } - if (face_map.empty()) - { - mPutQueue.erase(itQueue); } } @@ -773,10 +777,26 @@ void LLMaterialMgr::clearGetQueues(const LLUUID& region_id) mGetAllPending.erase(region_id); mGetAllCallbacks.erase(region_id); } - void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) { clearGetQueues(regionp->getRegionID()); // Put doesn't need clearing: objects that can't be found will clean up in processPutQueue() } +U32 LLMaterialMgr::getMaxEntries(const LLViewerRegion* regionp) +{ + LLSD sim_features; + regionp->getSimulatorFeatures(sim_features); + U32 max_entries; + if ( sim_features.has( SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION ) + && sim_features[ SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION ].isInteger()) + { + max_entries = sim_features[ SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION ].asInteger(); + } + else + { + max_entries = MATERIALS_DEFAULT_MAX_ENTRIES; + } + return max_entries; +} + diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index e317a791ad..e83f1f4e01 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -124,6 +124,8 @@ protected: put_queue_t mPutQueue; material_map_t mMaterials; + + U32 getMaxEntries(const LLViewerRegion* regionp); }; #endif // LL_LLMATERIALMGR_H diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 8422708add..a4f6340d9e 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1219,7 +1219,7 @@ void LLViewerRegion::getInfo(LLSD& info) info["Region"]["Handle"]["y"] = (LLSD::Integer)y; } -void LLViewerRegion::getSimulatorFeatures(LLSD& sim_features) +void LLViewerRegion::getSimulatorFeatures(LLSD& sim_features) const { sim_features = mSimulatorFeatures; diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 56cd0c9ea1..031159183b 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -293,7 +293,7 @@ public: bool meshRezEnabled() const; bool meshUploadEnabled() const; - void getSimulatorFeatures(LLSD& info); + void getSimulatorFeatures(LLSD& info) const; void setSimulatorFeatures(const LLSD& info); -- cgit v1.2.3 From 5595888dd23b0ac526fc520eb20de6e11a2b62ee Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 26 Jun 2013 11:52:10 -0500 Subject: NORSPEC-290 Allow shader compiler to unroll loop in multiPointLightF --- .../shaders/class1/deferred/multiPointLightF.glsl | 91 +++++++++------------- indra/newview/featuretable_mac.txt | 4 +- indra/newview/llface.cpp | 6 -- indra/newview/llviewershadermgr.cpp | 27 ++++--- indra/newview/llviewershadermgr.h | 4 +- indra/newview/pipeline.cpp | 19 +++-- 6 files changed, 69 insertions(+), 82 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index 868526d457..6612892f6e 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -45,9 +45,8 @@ uniform float sun_wash; uniform int light_count; -#define MAX_LIGHT_COUNT 16 -uniform vec4 light[MAX_LIGHT_COUNT]; -uniform vec4 light_col[MAX_LIGHT_COUNT]; +uniform vec4 light[LIGHT_COUNT]; +uniform vec4 light_col[LIGHT_COUNT]; VARYING vec4 vary_fragcoord; uniform vec2 screen_res; @@ -122,73 +121,59 @@ void main() vec3 npos = normalize(-pos); // As of OSX 10.6.7 ATI Apple's crash when using a variable size loop - for (int i = 0; i < MAX_LIGHT_COUNT; ++i) + for (int i = 0; i < LIGHT_COUNT; ++i) { - bool light_contrib = (i < light_count); - vec3 lv = light[i].xyz-pos; float dist = length(lv); dist /= light[i].w; - if (dist > 1.0) + if (dist <= 1.0) { - light_contrib = false; - } - - float da = dot(norm, lv); - if (da < 0.0) - { - light_contrib = false; - } - - if (light_contrib) - { - lv = normalize(lv); - da = dot(norm, lv); + float da = dot(norm, lv); + if (da > 0.0) + { + lv = normalize(lv); + da = dot(norm, lv); - float fa = light_col[i].a+1.0; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; + float fa = light_col[i].a+1.0; + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; - dist_atten *= noise; + dist_atten *= noise; - float lit = da * dist_atten; + float lit = da * dist_atten; - vec3 col = light_col[i].rgb*lit*diff; + vec3 col = light_col[i].rgb*lit*diff; - //vec3 col = vec3(dist2, light_col[i].a, lit); + //vec3 col = vec3(dist2, light_col[i].a, lit); - if (spec.a > 0.0) - { - lit = min(da*6.0, 1.0) * dist_atten; - //vec3 ref = dot(pos+lv, norm); - vec3 h = normalize(lv+npos); - float nh = dot(norm, h); - float nv = dot(norm, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; - - float gtdenom = 2 * nh; - float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - - if (nh > 0.0) + if (spec.a > 0.0) { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*light_col[i].rgb*spec.rgb; - //col += spec.rgb; + lit = min(da*6.0, 1.0) * dist_atten; + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += lit*scol*light_col[i].rgb*spec.rgb; + //col += spec.rgb; + } } - } - out_col += col; + out_col += col; + } } } - if (dot(out_col, out_col) <= 0.0) - { - discard; - } - frag_color.rgb = out_col; frag_color.a = 0.0; } diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 1c0d45c11b..0bdd425504 100755 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -309,8 +309,8 @@ RenderVolumeLODFactor 1 2.0 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 -RenderDeferred 1 0 -RenderDeferredSSAO 1 0 +RenderDeferred 1 1 +RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 RenderFSAASamples 1 2 diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index f021f4ed0f..700b31f8d3 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -817,12 +817,6 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, size.mul(scale); } - // Catch potential badness from normalization before it happens - // - llassert(mat_normal.mMatrix[0].isFinite3() && (mat_normal.mMatrix[0].dot3(mat_normal.mMatrix[0]).getF32() > F_APPROXIMATELY_ZERO)); - llassert(mat_normal.mMatrix[1].isFinite3() && (mat_normal.mMatrix[1].dot3(mat_normal.mMatrix[1]).getF32() > F_APPROXIMATELY_ZERO)); - llassert(mat_normal.mMatrix[2].isFinite3() && (mat_normal.mMatrix[2].dot3(mat_normal.mMatrix[2]).getF32() > F_APPROXIMATELY_ZERO)); - mat_normal.mMatrix[0].normalize3fast(); mat_normal.mMatrix[1].normalize3fast(); mat_normal.mMatrix[2].normalize3fast(); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index e24237522a..e4f04a414d 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -199,7 +199,7 @@ LLGLSLShader gDeferredTreeShadowProgram; LLGLSLShader gDeferredAvatarProgram; LLGLSLShader gDeferredAvatarAlphaProgram; LLGLSLShader gDeferredLightProgram; -LLGLSLShader gDeferredMultiLightProgram; +LLGLSLShader gDeferredMultiLightProgram[16]; LLGLSLShader gDeferredSpotLightProgram; LLGLSLShader gDeferredMultiSpotLightProgram; LLGLSLShader gDeferredSunProgram; @@ -1128,7 +1128,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredImpostorProgram.unload(); gDeferredTerrainProgram.unload(); gDeferredLightProgram.unload(); - gDeferredMultiLightProgram.unload(); + for (U32 i = 0; i < LL_DEFERRED_MULTI_LIGHT_COUNT; ++i) + { + gDeferredMultiLightProgram[i].unload(); + } gDeferredSpotLightProgram.unload(); gDeferredMultiSpotLightProgram.unload(); gDeferredSunProgram.unload(); @@ -1373,17 +1376,21 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredLightProgram.createShader(NULL, NULL); } - if (success) + for (U32 i = 0; i < LL_DEFERRED_MULTI_LIGHT_COUNT; i++) { - gDeferredMultiLightProgram.mName = "Deferred MultiLight Shader"; - gDeferredMultiLightProgram.mShaderFiles.clear(); - gDeferredMultiLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredMultiLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredMultiLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + if (success) + { + gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i); + gDeferredMultiLightProgram[i].mShaderFiles.clear(); + gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredMultiLightProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredMultiLightProgram[i].addPermutation("LIGHT_COUNT", llformat("%d", i+1)); - SINGLE_FP_PERMUTATION(gDeferredMultiLightProgram); + SINGLE_FP_PERMUTATION(gDeferredMultiLightProgram[i]); - success = gDeferredMultiLightProgram.createShader(NULL, NULL); + success = gDeferredMultiLightProgram[i].createShader(NULL, NULL); + } } if (success) diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 438853cd6f..ed8167947d 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -30,6 +30,8 @@ #include "llshadermgr.h" #include "llmaterial.h" +#define LL_DEFERRED_MULTI_LIGHT_COUNT 16 + class LLViewerShaderMgr: public LLShaderMgr { public: @@ -341,7 +343,7 @@ extern LLGLSLShader gDeferredTerrainProgram; extern LLGLSLShader gDeferredTreeProgram; extern LLGLSLShader gDeferredTreeShadowProgram; extern LLGLSLShader gDeferredLightProgram; -extern LLGLSLShader gDeferredMultiLightProgram; +extern LLGLSLShader gDeferredMultiLightProgram[LL_DEFERRED_MULTI_LIGHT_COUNT]; extern LLGLSLShader gDeferredSpotLightProgram; extern LLGLSLShader gDeferredMultiSpotLightProgram; extern LLGLSLShader gDeferredSunProgram; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4801c52209..2eeedc8214 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8672,10 +8672,6 @@ void LLPipeline::renderDeferredLighting() vert[2].set(3,1,0); { - bindDeferredShader(gDeferredMultiLightProgram); - - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - LLGLDepthTest depth(GL_FALSE); //full screen blit @@ -8687,7 +8683,7 @@ void LLPipeline::renderDeferredLighting() U32 count = 0; - const U32 max_count = 8; + const U32 max_count = LL_DEFERRED_MULTI_LIGHT_COUNT; LLVector4 light[max_count]; LLVector4 col[max_count]; @@ -8710,17 +8706,20 @@ void LLPipeline::renderDeferredLighting() count++; if (count == max_count || fullscreen_lights.empty()) { - gDeferredMultiLightProgram.uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); - gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); - gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); - gDeferredMultiLightProgram.uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); + U32 idx = count-1; + bindDeferredShader(gDeferredMultiLightProgram[idx]); + gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); + gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; count = 0; + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); } } - unbindDeferredShader(gDeferredMultiLightProgram); + unbindDeferredShader(gDeferredMultiLightProgram[0]); bindDeferredShader(gDeferredMultiSpotLightProgram); -- cgit v1.2.3 From 2b5205c74395ca67dde8c2978e26c2e2d5d41b97 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 26 Jun 2013 15:33:07 -0500 Subject: Merge cleanup. --- indra/newview/llviewershadermgr.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index d195971c03..7bce629d3e 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1366,8 +1366,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMultiLightProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredMultiLightProgram[i].addPermutation("LIGHT_COUNT", llformat("%d", i+1)); - - SINGLE_FP_PERMUTATION(gDeferredMultiLightProgram[i]); success = gDeferredMultiLightProgram[i].createShader(NULL, NULL); } } -- cgit v1.2.3 From 06b024f60e6953f3b1de08523b511e0f0a777531 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 26 Jun 2013 19:16:49 -0500 Subject: MATBUG-194 Fix for crazy colors on projector shadows with NVIDIA OpenGL 3.3 implementations --- .../app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 4 ++++ indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 0deb4fe3b6..14f6afc8c2 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -318,6 +318,10 @@ void main() } } + + //not sure why, but this line prevents MATBUG-194 + col = max(col, vec3(0.0)); + frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 7a4337c277..6e0218cb9c 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -315,7 +315,10 @@ void main() } } } - + + //not sure why, but this line prevents MATBUG-194 + col = max(col, vec3(0.0)); + frag_color.rgb = col; frag_color.a = 0.0; } -- cgit v1.2.3 From 5f397fa58352fb58d79b72148904f925416f4978 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 28 Jun 2013 13:29:11 -0400 Subject: NORSPEC-206: read RenderMaterialsCapability throttle rate per second from simulator --- indra/newview/llmaterialmgr.cpp | 24 +++++++++++++----------- indra/newview/llmaterialmgr.h | 3 +++ indra/newview/llviewerregion.cpp | 32 ++++++++++++++++++++++++++++++++ indra/newview/llviewerregion.h | 8 ++++++++ 4 files changed, 56 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index ad9958546c..96dd402d84 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -543,11 +543,9 @@ void LLMaterialMgr::onIdle(void*) instancep->processGetAllQueue(); } - static LLFrameTimer mPutTimer; - if ( (!instancep->mPutQueue.empty()) && (mPutTimer.hasExpired()) ) + if (!instancep->mPutQueue.empty()) { instancep->processPutQueue(); - mPutTimer.resetWithExpiry(MATERIALS_PUT_THROTTLE_SECS); } } @@ -564,14 +562,14 @@ void LLMaterialMgr::processGetQueue() continue; } - const LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); + LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); if (!regionp) { LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL; mGetQueue.erase(itRegionQueue); continue; } - else if (!regionp->capabilitiesReceived()) + else if (!regionp->capabilitiesReceived() || regionp->materialsCapThrottled()) { continue; } @@ -628,6 +626,7 @@ void LLMaterialMgr::processGetQueue() LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << " for " << materialsData.size() << " materials." << "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; LLHTTPClient::post(capURL, postData, materialsResponder); + regionp->resetMaterialsCapThrottle(); } } @@ -646,7 +645,7 @@ void LLMaterialMgr::processGetAllQueue() clearGetQueues(region_id); // Invalidates region_id continue; } - else if (!regionp->capabilitiesReceived()) + else if (!regionp->capabilitiesReceived() || regionp->materialsCapThrottled()) { continue; } @@ -663,6 +662,7 @@ void LLMaterialMgr::processGetAllQueue() LL_DEBUGS("Materials") << "GET all for region " << region_id << "url " << capURL << LL_ENDL; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion)); LLHTTPClient::get(capURL, materialsResponder); + regionp->resetMaterialsCapThrottle(); mGetAllPending.insert(std::pair(region_id, LLFrameTimer::getTotalSeconds())); mGetAllQueue.erase(itRegion); // Invalidates region_id } @@ -670,7 +670,7 @@ void LLMaterialMgr::processGetAllQueue() void LLMaterialMgr::processPutQueue() { - typedef std::map regionput_request_map; + typedef std::map regionput_request_map; regionput_request_map requests; put_queue_t::iterator loopQueue = mPutQueue.begin(); @@ -687,13 +687,13 @@ void LLMaterialMgr::processPutQueue() } else { - const LLViewerRegion* regionp = objectp->getRegion(); + LLViewerRegion* regionp = objectp->getRegion(); if ( !regionp ) { LL_WARNS("Materials") << "Object region is NULL" << LL_ENDL; mPutQueue.erase(itQueue); } - else if ( regionp->capabilitiesReceived()) + else if ( regionp->capabilitiesReceived() && !regionp->materialsCapThrottled()) { LLSD& facesData = requests[regionp]; @@ -722,11 +722,12 @@ void LLMaterialMgr::processPutQueue() for (regionput_request_map::const_iterator itRequest = requests.begin(); itRequest != requests.end(); ++itRequest) { - std::string capURL = itRequest->first->getCapability(MATERIALS_CAPABILITY_NAME); + LLViewerRegion* regionp = itRequest->first; + std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); if (capURL.empty()) { LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME - << "' is not defined on region '" << itRequest->first->getName() << "'" << LL_ENDL; + << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; continue; } @@ -749,6 +750,7 @@ void LLMaterialMgr::processPutQueue() LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces to region " << itRequest->first->getName() << LL_ENDL; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)); LLHTTPClient::put(capURL, putData, materialsResponder); + regionp->resetMaterialsCapThrottle(); } else { diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index e83f1f4e01..2836019c27 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -126,6 +126,9 @@ protected: material_map_t mMaterials; U32 getMaxEntries(const LLViewerRegion* regionp); + + LLFrameTimer mCapThrottleTimer; + F32 getThrottleIntervalSecs(const LLUUID& region_id); }; #endif // LL_LLMATERIALMGR_H diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index a4f6340d9e..0f8decc643 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1944,3 +1944,35 @@ bool LLViewerRegion::dynamicPathfindingEnabled() const mSimulatorFeatures["DynamicPathfindingEnabled"].asBoolean()); } +void LLViewerRegion::resetMaterialsCapThrottle() +{ + F32 requests_per_sec = 1.0f; // original default; + if ( mSimulatorFeatures.has("RenderMaterialsCapability") + && mSimulatorFeatures["RenderMaterialsCapability"].isReal() ) + { + requests_per_sec = mSimulatorFeatures["RenderMaterialsCapability"].asReal(); + if ( requests_per_sec != 0.0f ) + { + requests_per_sec = 1.0f; + LL_WARNS("Materials") + << "region '" << getName() + << "' returned zero for RenderMaterialsCapability; using default " + << requests_per_sec << " per second" + << LL_ENDL; + } + LL_DEBUGS_ONCE("Materials") << "region '" << getName() + << "' RenderMaterialsCapability " << requests_per_sec + << LL_ENDL; + } + else + { + LL_DEBUGS("Materials") + << "region '" << getName() + << "' did not return RenderMaterialsCapability, using default " + << requests_per_sec << " per second" + << LL_ENDL; + } + + mMaterialsCapThrottleTimer.resetWithExpiry( 1.0f / requests_per_sec ); +} + diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 031159183b..a3db7f5ac7 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -43,6 +43,7 @@ #include "llcapabilityprovider.h" #include "m4math.h" // LLMatrix4 #include "llhttpclient.h" +#include "llframetimer.h" // Surface id's #define LAND 1 @@ -342,6 +343,10 @@ public: void getNeighboringRegionsStatus( std::vector& regions ); const LLViewerRegionImpl * getRegionImpl() const { return mImpl; } LLViewerRegionImpl * getRegionImplNC() { return mImpl; } + + // implements the materials capability throttle + bool materialsCapThrottled() const { return !mMaterialsCapThrottleTimer.hasExpired(); } + void resetMaterialsCapThrottle(); public: struct CompareDistance @@ -434,6 +439,9 @@ private: BOOL mReleaseNotesRequested; LLSD mSimulatorFeatures; + + // the materials capability throttle + LLFrameTimer mMaterialsCapThrottleTimer; }; inline BOOL LLViewerRegion::getRegionProtocol(U64 protocol) const -- cgit v1.2.3 From 7df863265f6f536aeae84dceab9140fb4465213c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 28 Jun 2013 13:32:01 -0500 Subject: NORSPEC-290 Shader optimization WIP -- remove a couple normalizes, pows, and divides from various lighting functions. --- indra/llrender/llrender.cpp | 2 +- .../shaders/class1/deferred/alphaF.glsl | 51 +++-- .../shaders/class1/deferred/alphaNonIndexedF.glsl | 150 ------------- .../class1/deferred/alphaNonIndexedNoColorF.glsl | 92 -------- .../shaders/class1/deferred/alphaSkinnedV.glsl | 136 ------------ .../shaders/class1/deferred/alphaV.glsl | 37 +--- .../class1/deferred/avatarAlphaNoColorV.glsl | 10 +- .../shaders/class1/deferred/avatarAlphaV.glsl | 153 ------------- .../shaders/class1/deferred/materialF.glsl | 8 +- .../shaders/class1/lighting/lightFuncV.glsl | 2 +- .../shaders/class1/objects/previewV.glsl | 4 +- .../shaders/class2/deferred/alphaNonIndexedF.glsl | 235 -------------------- .../class2/deferred/alphaNonIndexedNoColorF.glsl | 242 --------------------- .../shaders/class2/deferred/alphaSkinnedV.glsl | 156 ------------- .../shaders/class2/deferred/alphaV.glsl | 224 ------------------- .../shaders/class2/deferred/avatarAlphaV.glsl | 153 ------------- indra/newview/pipeline.cpp | 4 +- 17 files changed, 46 insertions(+), 1613 deletions(-) delete mode 100755 indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl delete mode 100755 indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl delete mode 100755 indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl delete mode 100755 indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl (limited to 'indra') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index b22ad60750..c4585936ee 100755 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1150,7 +1150,7 @@ void LLRender::syncLightState() position[i] = light->mPosition; direction[i] = light->mSpotDirection; - attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[3]); + attenuation[i].set(1.f/light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[3]); diffuse[i].set(light->mDiffuse.mV); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 143af0576c..af3f362208 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -61,6 +61,7 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec3 vary_pointlight_col_linear; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; @@ -82,7 +83,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) return vec3(a,a,a); } -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -92,14 +93,14 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float float da = 0.0; - if (d > 0.0 && la > 0.0 && fa > 0.0) +// if (d > 0.0 && la > 0.0 && fa > 0.0) { //normalize light vector - lv = normalize(lv); + lv /= d; //distance attenuation - float dist = d/la; - da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + float dist = d*la; + da = clamp(1.0-(dist+fa-1.0)/fa, 0.0, 1.0); da *= da; da *= 2.0; @@ -112,7 +113,7 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float da *= max(dot(n, lv), 0.0); } - return vec3(da,da,da); + return da; } #if HAS_SHADOW @@ -138,6 +139,25 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) void main() { +#ifdef USE_INDEXED_TEX + vec4 diff = diffuseLookup(vary_texcoord0.xy); +#else + vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); +#endif + +#ifdef USE_VERTEX_COLOR + float vertex_color_alpha = vertex_color.a; +#else + float vertex_color_alpha = 1.0; +#endif + + float alpha = vertex_color_alpha*diff.a; + + vec4 gamma_diff = diff; + + diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); + + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; frag *= screen_res; @@ -210,21 +230,6 @@ void main() } #endif -#ifdef USE_INDEXED_TEX - vec4 diff = diffuseLookup(vary_texcoord0.xy); -#else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); -#endif - vec4 gamma_diff = diff; - - diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); - -#ifdef USE_VERTEX_COLOR - float vertex_color_alpha = vertex_color.a; -#else - float vertex_color_alpha = 1.0; -#endif - vec3 normal = vary_norm; vec3 l = light_position[0].xyz; @@ -243,6 +248,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); + //convert to linear space color.rgb = pow(color.rgb, vec3(2.2)); col = vec4(0,0,0,0); @@ -257,8 +263,9 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * pow(vary_pointlight_col, vec3(2.2)) * col.rgb; + color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; + //convert to gamma space color.rgb = pow(color.rgb, vec3(1.0/2.2)); frag_color = color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl deleted file mode 100755 index 2ce44d599f..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl +++ /dev/null @@ -1,150 +0,0 @@ -/** - * @file alphaF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2DRect depthMap; -uniform sampler2D diffuseMap; - - -uniform vec2 screen_res; - -vec3 atmosLighting(vec3 light); -vec3 scaleSoftClip(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; -VARYING vec2 vary_texcoord0; -VARYING vec4 vertex_color; -VARYING vec3 vary_norm; - -uniform mat4 inv_proj; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = pow(max(dot(n,l),0.0), 0.7); - return vec3(a,a,a); -} - -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(pow(dot(n, lv), 0.7), 0.0); - } - - return vec3(da,da,da); -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -void main() -{ - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - vec4 pos = vec4(vary_position, 1.0); - - vec4 diff= texture2D(diffuseMap,vary_texcoord0.xy); - - vec3 n = vary_norm; - vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(n, l); - dlight = dlight * vary_directional.rgb * vary_pointlight_col; - - vec4 col = vec4(vary_ambient + dlight, vertex_color.a); - vec4 color = diff * col; - - color.rgb = atmosLighting(color.rgb); - - color.rgb = scaleSoftClip(color.rgb); - vec3 light_col = vec3(0,0,0); - - #define LIGHT_LOOP(i) \ - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - - LIGHT_LOOP(1) - LIGHT_LOOP(2) - LIGHT_LOOP(3) - LIGHT_LOOP(4) - LIGHT_LOOP(5) - LIGHT_LOOP(6) - LIGHT_LOOP(7) - - color.rgb += diff.rgb * vary_pointlight_col * light_col; - - color.rgb = pow(color.rgb, vec3(1.0/2.2)); - - frag_color = color; - //frag_color = vec4(1,0,1,1); - //frag_color = vec4(1,0,1,1)*shadow; - -} - diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl deleted file mode 100755 index 1113a9845b..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file alphaNonIndexedNoColorF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform float minimum_alpha; - -uniform sampler2DRect depthMap; -uniform sampler2D diffuseMap; - -uniform vec2 screen_res; - -vec3 atmosLighting(vec3 light); -vec3 scaleSoftClip(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; -VARYING vec2 vary_texcoord0; - -uniform mat4 inv_proj; - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -void main() -{ - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - vec4 pos = vec4(vary_position, 1.0); - - vec4 diff= texture2D(diffuseMap,vary_texcoord0.xy); - - if (diff.a < minimum_alpha) - { - discard; - } - - vec4 col = vec4(vary_ambient + vary_directional.rgb, 1.0); - vec4 color = diff * col; - - - color.rgb = atmosLighting(color.rgb); - - color.rgb = scaleSoftClip(color.rgb); - - color.rgb += diff.rgb * vary_pointlight_col.rgb; - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl deleted file mode 100755 index 5f93986f1d..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @file alphaSkinnedV.glsl - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 projection_matrix; -uniform mat4 modelview_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec3 normal; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -mat4 getObjectSkinnedTransform(); -void calcAtmospherics(vec3 inPositionEye); - -float calcDirectionalLight(vec3 n, vec3 l); - -vec3 atmosAmbient(vec3 light); -vec3 atmosAffectDirectionalLight(float lightIntensity); - -VARYING vec3 vary_position; -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_pointlight_col; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -VARYING vec3 vary_norm; - -uniform float near_clip; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return a; -} - -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - } - - return da; -} - -void main() -{ - vary_texcoord0 = texcoord0; - - vec4 pos; - vec3 norm; - - mat4 trans = getObjectSkinnedTransform(); - trans = modelview_matrix * trans; - - pos = trans * vec4(position.xyz, 1.0); - - norm = position.xyz + normal.xyz; - norm = normalize(( trans*vec4(norm, 1.0) ).xyz-pos.xyz); - vary_norm = norm; - vec4 frag_pos = projection_matrix * pos; - gl_Position = frag_pos; - - vary_position = pos.xyz; - - calcAtmospherics(pos.xyz); - - //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); - vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - vary_pointlight_col = diffuse_color.rgb; - col.rgb = vec3(0,0,0); - - // Add windlight lights - col.rgb = atmosAmbient(vec3(0.)); - - vary_ambient = col.rgb*diffuse_color.rgb; - vary_directional.rgb = atmosAffectDirectionalLight(1); - - col.rgb = col.rgb*diffuse_color.rgb; - - vertex_color = col; - - - - vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -} - - diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index 9d3ba564cd..cc63baa422 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl @@ -68,6 +68,7 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec3 vary_pointlight_col_linear; #ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; @@ -79,43 +80,8 @@ VARYING vec3 vary_norm; uniform float near_clip; -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - uniform vec3 sun_dir; -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - } - - return vec3(da,da,da); -} - void main() { vec4 pos; @@ -181,6 +147,7 @@ void main() vary_pointlight_col = diff; + vary_pointlight_col_linear = pow(diff, vec3(2.2)); col.rgb = vec3(0,0,0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl index c8ddefac26..145cf524d4 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl @@ -71,18 +71,18 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa vec3 lv = lp.xyz-v; //get distance - float d = dot(lv,lv); + float d = length(lv); float da = 0.0; - if (d > 0.0 && la > 0.0 && fa > 0.0) + //if (d > 0.0 && la > 0.0 && fa > 0.0) { //normalize light vector - lv = normalize(lv); + lv /= d; //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); + float dist = d*la; + da = clamp(1.0-(dist-1.0+fa)/fa, 0.0, 1.0); // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl deleted file mode 100755 index d6149fcc32..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @file avatarAlphaV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec3 normal; -ATTRIBUTE vec2 texcoord0; - -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); -mat4 getSkinnedTransform(); -void calcAtmospherics(vec3 inPositionEye); - -float calcDirectionalLight(vec3 n, vec3 l); -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight); - -vec3 atmosAmbient(vec3 light); -vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); - -VARYING vec3 vary_position; -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_pointlight_col; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - - -uniform float near_clip; - -uniform vec4 color; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return a; -} - -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - } - - return da; -} - -void main() -{ - vary_texcoord0 = texcoord0; - - vec4 pos; - vec3 norm; - - mat4 trans = getSkinnedTransform(); - vec4 pos_in = vec4(position.xyz, 1.0); - pos.x = dot(trans[0], pos_in); - pos.y = dot(trans[1], pos_in); - pos.z = dot(trans[2], pos_in); - pos.w = 1.0; - - norm.x = dot(trans[0].xyz, normal); - norm.y = dot(trans[1].xyz, normal); - norm.z = dot(trans[2].xyz, normal); - norm = normalize(norm); - - vec4 frag_pos = projection_matrix * pos; - gl_Position = frag_pos; - - vary_position = pos.xyz; - - calcAtmospherics(pos.xyz); - - vec4 col = vec4(0.0, 0.0, 0.0, 1.0); - - // Collect normal lights - col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z); - col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z); - col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z); - col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z); - col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z); - col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z); - - vary_pointlight_col = col.rgb*color.rgb; - - col.rgb = vec3(0,0,0); - - // Add windlight lights - col.rgb = atmosAmbient(vec3(0.)); - - vary_ambient = col.rgb*color.rgb; - vary_directional = color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0)); - - col.rgb = col.rgb * color.rgb; - - vertex_color = col; - - - - vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -} - - diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 53ade8ea64..27bb43110b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -133,14 +133,14 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe vec3 col = vec3(0,0,0); - if (d > 0.0 && la > 0.0 && fa > 0.0) + //if (d > 0.0 && la > 0.0 && fa > 0.0) { //normalize light vector - lv = normalize(lv); + lv /= d; //distance attenuation - float dist = d/la; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + float dist = d*la; + float dist_atten = clamp(1.0-(dist-1.0+fa)/fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index a9288b3df6..dc0b989e34 100755 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -45,7 +45,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa lv *= 1.0/d; //distance attenuation - float da = clamp(1.0/(la * d), 0.0, 1.0); + float da = clamp(1.0/(1.f/la * d), 0.0, 1.0); // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); diff --git a/indra/newview/app_settings/shaders/class1/objects/previewV.glsl b/indra/newview/app_settings/shaders/class1/objects/previewV.glsl index 7f3f84398b..c325a236d7 100755 --- a/indra/newview/app_settings/shaders/class1/objects/previewV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/previewV.glsl @@ -91,8 +91,8 @@ void main() // Collect normal lights (need to be divided by two, as we later multiply by 2) col.rgb += light_diffuse[1].rgb * calcDirectionalLight(norm, light_position[1].xyz); - col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].z); - col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].z); + col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], 1.f/light_attenuation[2].x, light_attenuation[2].z); + col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], 1.f/light_attenuation[3].x, light_attenuation[3].z); vertex_color = col*color; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl deleted file mode 100755 index 9670d59399..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl +++ /dev/null @@ -1,235 +0,0 @@ -/** - * @file alphaF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; -uniform sampler2DRect depthMap; -uniform sampler2D diffuseMap; - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform vec2 screen_res; - -vec3 atmosLighting(vec3 light); -vec3 scaleSoftClip(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; -VARYING vec2 vary_texcoord0; -VARYING vec4 vertex_color; -VARYING vec3 vary_norm; - -uniform vec2 shadow_res; -uniform float shadow_bias; - -uniform mat4 inv_proj; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = pow(max(dot(n,l),0.0), 0.7); - return vec3(a,a,a); -} - -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(pow(dot(n, lv), 0.7), 0.0); - } - - return vec3(da,da,da); -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos.xyz /= pos.w; - pos.w = 1.0; - return pos; -} - -float pcfShadow(sampler2DShadow shadowMap, vec4 stc) -{ - stc.xyz /= stc.w; - stc.z += shadow_bias; - - stc.x = floor(stc.x*shadow_res.x + fract(stc.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here - - float cs = shadow2D(shadowMap, stc.xyz).x; - float shadow = cs; - - shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - - return shadow*0.2; -} - - -void main() -{ - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - float shadow = 0.0; - vec4 pos = vec4(vary_position, 1.0); - - vec4 spos = pos; - - if (spos.z > -shadow_clip.w) - { - vec4 lpos; - - vec4 near_split = shadow_clip*-0.75; - vec4 far_split = shadow_clip*-1.25; - vec4 transition_domain = near_split-far_split; - float weight = 0.0; - - if (spos.z < near_split.z) - { - lpos = shadow_matrix[3]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos)*w; - weight += w; - shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); - } - - if (spos.z < near_split.y && spos.z > far_split.z) - { - lpos = shadow_matrix[2]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; - w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos)*w; - weight += w; - } - - if (spos.z < near_split.x && spos.z > far_split.y) - { - lpos = shadow_matrix[1]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; - w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos)*w; - weight += w; - } - - if (spos.z > far_split.x) - { - lpos = shadow_matrix[0]*spos; - - float w = 1.0; - w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - - shadow += pcfShadow(shadowMap0, lpos)*w; - weight += w; - } - - - shadow /= weight; - - } - else - { - shadow = 1.0; - } - vec3 n = vary_norm; - vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(n, l); - dlight = dlight * vary_directional.rgb * vary_pointlight_col; - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); - - vec4 col = vec4(vary_ambient + dlight*shadow, vertex_color.a); - vec4 color = diff * col; - - color.rgb = atmosLighting(color.rgb); - - color.rgb = scaleSoftClip(color.rgb); - vec3 light_col = vec3(0,0,0); - - #define LIGHT_LOOP(i) \ - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - - LIGHT_LOOP(1) - LIGHT_LOOP(2) - LIGHT_LOOP(3) - LIGHT_LOOP(4) - LIGHT_LOOP(5) - LIGHT_LOOP(6) - LIGHT_LOOP(7) - - color.rgb += diff.rgb * vary_pointlight_col * light_col; - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl deleted file mode 100755 index fae279fba0..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl +++ /dev/null @@ -1,242 +0,0 @@ -/** - * @file alphaNonIndexedNoColorF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform float minimum_alpha; - -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; -uniform sampler2DRect depthMap; -uniform sampler2D diffuseMap; - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform vec2 screen_res; - -vec3 atmosLighting(vec3 light); -vec3 scaleSoftClip(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; -VARYING vec2 vary_texcoord0; -VARYING vec3 vary_norm; - -uniform vec2 shadow_res; - -uniform float shadow_bias; - -uniform mat4 inv_proj; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = pow(max(dot(n,l),0.0), 0.7); - return vec3(a, a, a); -} - -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(pow(dot(n, lv), 0.7), 0.0); - } - - return vec3(da,da,da); -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos.xyz /= pos.w; - pos.w = 1.0; - return pos; -} - -float pcfShadow(sampler2DShadow shadowMap, vec4 stc) -{ - stc.xyz /= stc.w; - stc.z += shadow_bias; - - stc.x = floor(stc.x*shadow_res.x + fract(stc.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here - float cs = shadow2D(shadowMap, stc.xyz).x; - - float shadow = cs; - - shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - - return shadow*0.2; -} - - -void main() -{ - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - float shadow = 0.0; - vec4 pos = vec4(vary_position, 1.0); - - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); - - if (diff.a < minimum_alpha) - { - discard; - } - - vec4 spos = pos; - - if (spos.z > -shadow_clip.w) - { - vec4 lpos; - - vec4 near_split = shadow_clip*-0.75; - vec4 far_split = shadow_clip*-1.25; - vec4 transition_domain = near_split-far_split; - float weight = 0.0; - - if (spos.z < near_split.z) - { - lpos = shadow_matrix[3]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos)*w; - weight += w; - shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); - } - - if (spos.z < near_split.y && spos.z > far_split.z) - { - lpos = shadow_matrix[2]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; - w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos)*w; - weight += w; - } - - if (spos.z < near_split.x && spos.z > far_split.y) - { - lpos = shadow_matrix[1]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; - w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos)*w; - weight += w; - } - - if (spos.z > far_split.x) - { - lpos = shadow_matrix[0]*spos; - - float w = 1.0; - w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - - shadow += pcfShadow(shadowMap0, lpos)*w; - weight += w; - } - - - shadow /= weight; - } - else - { - shadow = 1.0; - } - vec3 n = vary_norm; - vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(n, l); - dlight = dlight * vary_directional.rgb * vary_pointlight_col; - - vec4 col = vec4(vary_ambient + dlight*shadow, 1.0); - vec4 color = diff * col; - - color.rgb = atmosLighting(color.rgb); - - color.rgb = scaleSoftClip(color.rgb); - vec3 light_col = vec3(0,0,0); - - #define LIGHT_LOOP(i) \ - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - - LIGHT_LOOP(1) - LIGHT_LOOP(2) - LIGHT_LOOP(3) - LIGHT_LOOP(4) - LIGHT_LOOP(5) - LIGHT_LOOP(6) - LIGHT_LOOP(7) - - color.rgb += diff.rgb * vary_pointlight_col * light_col; - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl deleted file mode 100755 index 7f4d82ecc6..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @file alphaSkinnedV.glsl - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 projection_matrix; -uniform mat4 texture_matrix0; -uniform mat4 modelview_matrix; -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec3 normal; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); -void calcAtmospherics(vec3 inPositionEye); - -float calcDirectionalLight(vec3 n, vec3 l); -mat4 getObjectSkinnedTransform(); -vec3 atmosAmbient(vec3 light); -vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; -VARYING vec3 vary_norm; - -uniform float near_clip; -uniform float shadow_offset; -uniform float shadow_bias; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return a; -} - -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ -//get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - } - - return da; -} - -void main() -{ - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - - mat4 mat = getObjectSkinnedTransform(); - - mat = modelview_matrix * mat; - - vec3 pos = (mat*vec4(position, 1.0)).xyz; - - gl_Position = projection_matrix * vec4(pos, 1.0); - - vec4 n = vec4(position, 1.0); - n.xyz += normal.xyz; - n.xyz = (mat*n).xyz; - n.xyz = normalize(n.xyz-pos.xyz); - - vec3 norm = n.xyz; - vary_norm = norm; - - float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); - vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; - - calcAtmospherics(pos.xyz); - - //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); - vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - - // Collect normal lights - col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z); - col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z); - col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z); - col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z); - col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z); - col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z); - - vary_pointlight_col = col.rgb*diffuse_color.rgb; - - col.rgb = vec3(0,0,0); - - // Add windlight lights - col.rgb = atmosAmbient(vec3(0.)); - - vary_ambient = col.rgb*diffuse_color.rgb; - vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a))); - - col.rgb = min(col.rgb*diffuse_color.rgb, 1.0); - - vertex_color = col; - - - - pos.xyz = (modelview_projection_matrix * vec4(position.xyz, 1.0)).xyz; - vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); - -} - diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl deleted file mode 100755 index 13c6ffc607..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ /dev/null @@ -1,224 +0,0 @@ -/** - * @file alphaV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat3 normal_matrix; -uniform mat4 texture_matrix0; -uniform mat4 projection_matrix; -uniform mat4 modelview_matrix; -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; - -#ifdef USE_INDEXED_TEX -void passTextureIndex(); -#endif - -ATTRIBUTE vec3 normal; - -#ifdef USE_VERTEX_COLOR -ATTRIBUTE vec4 diffuse_color; -#endif - -ATTRIBUTE vec2 texcoord0; - -#ifdef HAS_SKIN -mat4 getObjectSkinnedTransform(); -#else -#ifdef IS_AVATAR_SKIN -mat4 getSkinnedTransform(); -#endif -#endif - -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); -void calcAtmospherics(vec3 inPositionEye); - -vec3 calcDirectionalLight(vec3 n, vec3 l); - -vec3 atmosAmbient(vec3 light); -vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; - -#ifdef USE_VERTEX_COLOR -VARYING vec4 vertex_color; -#endif - -VARYING vec2 vary_texcoord0; -VARYING vec3 vary_norm; - -uniform float near_clip; -uniform float shadow_offset; -uniform float shadow_bias; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -uniform vec3 sun_dir; - -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return vec3(a,a,a); -} - -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - } - - return vec3(da,da,da); -} - -void main() -{ - vec4 pos; - vec3 norm; - - //transform vertex -#ifdef HAS_SKIN - mat4 trans = getObjectSkinnedTransform(); - trans = modelview_matrix * trans; - - pos = trans * vec4(position.xyz, 1.0); - - norm = position.xyz + normal.xyz; - norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz); - vec4 frag_pos = projection_matrix * pos; - gl_Position = frag_pos; -#else - -#ifdef IS_AVATAR_SKIN - mat4 trans = getSkinnedTransform(); - vec4 pos_in = vec4(position.xyz, 1.0); - pos.x = dot(trans[0], pos_in); - pos.y = dot(trans[1], pos_in); - pos.z = dot(trans[2], pos_in); - pos.w = 1.0; - - norm.x = dot(trans[0].xyz, normal); - norm.y = dot(trans[1].xyz, normal); - norm.z = dot(trans[2].xyz, normal); - norm = normalize(norm); - - vec4 frag_pos = projection_matrix * pos; - gl_Position = frag_pos; -#else - norm = normalize(normal_matrix * normal); - vec4 vert = vec4(position.xyz, 1.0); - pos = (modelview_matrix * vert); - gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); -#endif - -#endif - -#ifdef USE_INDEXED_TEX - passTextureIndex(); - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -#else - vary_texcoord0 = texcoord0; -#endif - - vary_norm = norm; - float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); - vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; - - calcAtmospherics(pos.xyz); - -#ifndef USE_VERTEX_COLOR - vec4 diffuse_color = vec4(1,1,1,1); -#endif - - //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); - vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - - vec3 dff = pow(diffuse_color.rgb, vec3(2.2f,2.2f,2.2f)); - - vary_pointlight_col = dff; - - col.rgb = vec3(0,0,0); - - // Add windlight lights - col.rgb = atmosAmbient(col.rgb); - - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0-ambient); - - col.rgb *= ambient; - - vary_directional.rgb = atmosAffectDirectionalLight(1.0f); - vary_ambient = col.rgb*dff; - - col.rgb = col.rgb*dff; - -#ifdef USE_VERTEX_COLOR - vertex_color = col; -#endif - -#ifdef HAS_SKIN - vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -#else - -#ifdef IS_AVATAR_SKIN - vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); -#else - pos = modelview_projection_matrix * vert; - vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); -#endif - -#endif - -} diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl deleted file mode 100755 index 44aaa98b97..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @file avatarAlphaV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec3 normal; -ATTRIBUTE vec2 texcoord0; - -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); -mat4 getSkinnedTransform(); -void calcAtmospherics(vec3 inPositionEye); - -float calcDirectionalLight(vec3 n, vec3 l); -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight); - -vec3 atmosAmbient(vec3 light); -vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); - -VARYING vec3 vary_position; -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_pointlight_col; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -uniform vec4 color; - -uniform float near_clip; -uniform float shadow_offset; -uniform float shadow_bias; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return a; -} - -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - } - - return da; -} - -void main() -{ - vary_texcoord0 = texcoord0; - - vec4 pos; - vec3 norm; - - mat4 trans = getSkinnedTransform(); - vec4 pos_in = vec4(position.xyz, 1.0); - pos.x = dot(trans[0], pos_in); - pos.y = dot(trans[1], pos_in); - pos.z = dot(trans[2], pos_in); - pos.w = 1.0; - - norm.x = dot(trans[0].xyz, normal); - norm.y = dot(trans[1].xyz, normal); - norm.z = dot(trans[2].xyz, normal); - norm = normalize(norm); - - gl_Position = projection_matrix * pos; - - float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); - vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; - - calcAtmospherics(pos.xyz); - - vec4 col = vec4(0.0, 0.0, 0.0, 1.0); - - // Collect normal lights - col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z); - col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z); - col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z); - col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z); - col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z); - col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z); - - vary_pointlight_col = col.rgb*color.rgb; - - col.rgb = vec3(0,0,0); - - // Add windlight lights - col.rgb = atmosAmbient(vec3(0.)); - - vary_ambient = col.rgb*color.rgb; - vary_directional = atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0)); - - col.rgb = col.rgb*color.rgb; - - vertex_color = col; - - - vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); -} - - diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 231508e253..7072c95c3e 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2710,14 +2710,14 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d { shader = &gDownsampleDepthRectProgram; shader->bind(); - shader->uniform2f("delta", 1.f, 1.f); + shader->uniform2f(sDelta, 1.f, 1.f); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, source.getWidth(), source.getHeight()); } else { shader = &gDownsampleDepthProgram; shader->bind(); - shader->uniform2f("delta", 1.f/source.getWidth(), 1.f/source.getHeight()); + shader->uniform2f(sDelta, 1.f/source.getWidth(), 1.f/source.getHeight()); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, 1.f, 1.f); } -- cgit v1.2.3 From 8ae792b38af42d26a0f588e9a8b778df99416fd5 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 28 Jun 2013 16:18:08 -0400 Subject: move reading of the sim features to LLViewerRegion for consistency, a couple of minor cleanups --- indra/newview/llmaterialmgr.cpp | 23 ++--------------------- indra/newview/llmaterialmgr.h | 5 ----- indra/newview/llviewerregion.cpp | 12 ++++++++++++ indra/newview/llviewerregion.h | 1 + 4 files changed, 15 insertions(+), 26 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 96dd402d84..658fea944d 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -50,9 +50,7 @@ #define MATERIALS_CAP_MATERIAL_FIELD "Material" #define MATERIALS_CAP_OBJECT_ID_FIELD "ID" #define MATERIALS_CAP_MATERIAL_ID_FIELD "MaterialID" -#define SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION "MaxMaterialsPerTransaction" -#define MATERIALS_DEFAULT_MAX_ENTRIES 50 #define MATERIALS_GET_TIMEOUT (60.f * 20) #define MATERIALS_POST_TIMEOUT (60.f * 5) #define MATERIALS_PUT_THROTTLE_SECS 1.f @@ -592,7 +590,7 @@ void LLMaterialMgr::processGetQueue() LLSD materialsData = LLSD::emptyArray(); material_queue_t& materials = itRegionQueue->second; - U32 max_entries = getMaxEntries(regionp); + U32 max_entries = regionp->getMaxMaterialsPerTransaction(); material_queue_t::iterator loopMaterial = materials.begin(); while ( (materials.end() != loopMaterial) && (materialsData.size() < max_entries) ) { @@ -698,7 +696,7 @@ void LLMaterialMgr::processPutQueue() LLSD& facesData = requests[regionp]; facematerial_map_t& face_map = itQueue->second; - U32 max_entries = getMaxEntries(regionp); + U32 max_entries = regionp->getMaxMaterialsPerTransaction(); facematerial_map_t::iterator itFace = face_map.begin(); while ( (face_map.end() != itFace) && (facesData.size() < max_entries) ) { @@ -785,20 +783,3 @@ void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) // Put doesn't need clearing: objects that can't be found will clean up in processPutQueue() } -U32 LLMaterialMgr::getMaxEntries(const LLViewerRegion* regionp) -{ - LLSD sim_features; - regionp->getSimulatorFeatures(sim_features); - U32 max_entries; - if ( sim_features.has( SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION ) - && sim_features[ SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION ].isInteger()) - { - max_entries = sim_features[ SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION ].asInteger(); - } - else - { - max_entries = MATERIALS_DEFAULT_MAX_ENTRIES; - } - return max_entries; -} - diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 2836019c27..e317a791ad 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -124,11 +124,6 @@ protected: put_queue_t mPutQueue; material_map_t mMaterials; - - U32 getMaxEntries(const LLViewerRegion* regionp); - - LLFrameTimer mCapThrottleTimer; - F32 getThrottleIntervalSecs(const LLUUID& region_id); }; #endif // LL_LLMATERIALMGR_H diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 0f8decc643..b541a35111 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1976,3 +1976,15 @@ void LLViewerRegion::resetMaterialsCapThrottle() mMaterialsCapThrottleTimer.resetWithExpiry( 1.0f / requests_per_sec ); } +U32 LLViewerRegion::getMaxMaterialsPerTransaction() const +{ + U32 max_entries = 50; // original hard coded default + if ( mSimulatorFeatures.has( "MaxMaterialsPerTransaction" ) + && mSimulatorFeatures[ "MaxMaterialsPerTransaction" ].isInteger()) + { + max_entries = mSimulatorFeatures[ "MaxMaterialsPerTransaction" ].asInteger(); + } + return max_entries; +} + + diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index a3db7f5ac7..109baccf9a 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -348,6 +348,7 @@ public: bool materialsCapThrottled() const { return !mMaterialsCapThrottleTimer.hasExpired(); } void resetMaterialsCapThrottle(); + U32 getMaxMaterialsPerTransaction() const; public: struct CompareDistance { -- cgit v1.2.3 From 1c9a4fc080bee955b5b18750fe8de7c24a3f912f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 1 Jul 2013 10:53:09 -0500 Subject: NORSPEC-290 Shader optimization WIP -- remove some more divides and normalizes from various lighting functions, rework flow control based on profile feedback. --- .../shaders/class1/deferred/multiPointLightF.glsl | 6 +- .../shaders/class1/deferred/pointLightF.glsl | 86 ++++++++++------------ .../shaders/class1/deferred/pointLightV.glsl | 2 +- indra/newview/pipeline.cpp | 6 +- 4 files changed, 46 insertions(+), 54 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index a955ef6e9d..ed51e01a53 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -107,14 +107,14 @@ void main() for (int i = 0; i < LIGHT_COUNT; ++i) { vec3 lv = light[i].xyz-pos; - float dist = length(lv); - dist /= light[i].w; + float d = length(lv); + float dist = d * light[i].w; if (dist <= 1.0) { float da = dot(norm, lv); if (da > 0.0) { - lv = normalize(lv); + lv /= d; da = dot(norm, lv); float fa = light_col[i].a+1.0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 106d48bd71..f162f70592 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -35,7 +35,7 @@ uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; uniform sampler2DRect normalMap; uniform samplerCube environmentMap; -uniform sampler2D noiseMap; +//uniform sampler2D noiseMap; uniform sampler2D lightFunc; uniform sampler2DRect depthMap; @@ -93,64 +93,56 @@ void main() vec3 pos = getPosition(frag.xy).xyz; vec3 lv = trans_center.xyz-pos; - float dist = length(lv); - dist /= size; - if (dist > 1.0) - { - discard; - } + float d = length(lv); - vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - norm = decode_normal(norm.xy); // unpack norm - float da = dot(norm, lv); - if (da < 0.0) + float dist = d*size; + + vec3 col = vec3(0.0); + if (dist <= 1.0) { - discard; - } + vec3 norm = texture2DRect(normalMap, frag.xy).xyz; + norm = decode_normal(norm.xy); // unpack norm + float da = dot(norm, lv); - norm = normalize(norm); - lv = normalize(lv); - da = dot(norm, lv); + norm = normalize(norm); + lv = normalize(lv); + da = max(dot(norm, lv), 0.0); - float noise = texture2D(noiseMap, frag.xy/128.0).b; + //float noise = texture2D(noiseMap, frag.xy/128.0).b; - vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = falloff+1.0; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; + col = texture2DRect(diffuseRect, frag.xy).rgb; + float fa = falloff+1.0; + float dist_atten = clamp(1.0-(dist-1.0+fa)/fa, 0.0, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; - float lit = da * dist_atten * noise; + float lit = da * dist_atten; // * noise; - col = color.rgb*lit*col; + col = color.rgb*lit*col; - vec4 spec = texture2DRect(specularRect, frag.xy); - if (spec.a > 0.0) - { - lit = min(da*6.0, 1.0) * dist_atten; - - vec3 npos = -normalize(pos); - vec3 h = normalize(lv+npos); - float nh = dot(norm, h); - float nv = dot(norm, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5; - float gtdenom = 2 * nh; - float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); - - if (nh > 0.0) + vec4 spec = texture2DRect(specularRect, frag.xy); + if (spec.a > 0.0) { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*color.rgb*spec.rgb; + lit = min(da*6.0, 1.0) * dist_atten; + + vec3 npos = -normalize(pos); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5; + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += lit*scol*color.rgb*spec.rgb; + } } } - if (dot(col, col) <= 0.0) - { - discard; - } - frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl index a5625fbc16..aeef09cf5f 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl @@ -37,7 +37,7 @@ VARYING vec3 trans_center; void main() { //transform vertex - vec3 p = position*size+center; + vec3 p = position*1.f/size+center; vec4 pos = modelview_projection_matrix * vec4(p.xyz, 1.0); vary_fragcoord = pos; trans_center = (modelview_matrix*vec4(center.xyz, 1.0)).xyz; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7072c95c3e..7fa0a972ad 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8680,7 +8680,7 @@ void LLPipeline::renderDeferredLighting() LLFastTimer ftm(FTM_LOCAL_LIGHTS); gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, 1.f/s); gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); gGL.syncMatrices(); @@ -8701,7 +8701,7 @@ void LLPipeline::renderDeferredLighting() glh::vec3f tc(c); mat.mult_matrix_vec(tc); - fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s)); + fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], 1.f/s)); light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); } } @@ -8786,7 +8786,7 @@ void LLPipeline::renderDeferredLighting() col[count].mV[1] = powf(col[count].mV[1], 2.2f); col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/ - far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z); + far_z = llmin(light[count].mV[2]-1.f/light[count].mV[3], far_z); //col[count] = pow4fsrgb(col[count], 2.2f); count++; if (count == max_count || fullscreen_lights.empty()) -- cgit v1.2.3 From d6d2f74fbbf22ba70166a97e15b6c3b39e42ac4d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 1 Jul 2013 16:27:20 -0500 Subject: NORSPEC-290 Shader optimization WIP -- compatibility pass with OpenGL 3.3, slight cleanup. --- indra/llrender/llglslshader.cpp | 18 +----------------- indra/llrender/llrender.cpp | 4 ++-- .../app_settings/shaders/class1/deferred/alphaF.glsl | 3 +-- .../shaders/class1/deferred/multiPointLightF.glsl | 14 ++------------ .../shaders/class1/deferred/pointLightF.glsl | 14 +++++--------- indra/newview/llviewerdisplay.cpp | 1 + indra/newview/pipeline.cpp | 9 ++------- 7 files changed, 14 insertions(+), 49 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 52b00f7c15..dfb73de6f3 100755 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -1203,23 +1203,7 @@ void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v) } } -void LLGLSLShader::uniform2i(const string& uniform, GLint i, GLint j) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(i,j,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform2iARB(location, i, j); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniform2i(const string& uniform, GLint i, GLint j) +void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j) { GLint location = getUniformLocation(uniform); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index c4585936ee..3393d352de 100755 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -832,8 +832,8 @@ LLLightState::LLLightState(S32 index) : mIndex(index), mEnabled(false), mConstantAtten(1.f), - mLinearAtten(0.f), - mQuadraticAtten(0.f), + mLinearAtten(1.f), + mQuadraticAtten(1.f), mSpotExponent(0.f), mSpotCutoff(180.f) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b666b7b0d9..4b428cb904 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -93,7 +93,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa float da = 0.0; -// if (d > 0.0 && la > 0.0 && fa > 0.0) + //if (d > 0.0 && la > 0.0 && fa > 0.0) { //normalize light vector lv /= d; @@ -230,7 +230,6 @@ void main() } #endif - vec4 gamma_diff = diff; vec3 normal = vary_norm; vec3 l = light_position[0].xyz; diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index ed51e01a53..5a08980fec 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -36,7 +36,6 @@ uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; uniform sampler2DRect normalMap; uniform samplerCube environmentMap; -uniform sampler2D noiseMap; uniform sampler2D lightFunc; @@ -99,7 +98,6 @@ void main() norm = normalize(norm); vec4 spec = texture2DRect(specularRect, frag.xy); vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; - float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 out_col = vec3(0,0,0); vec3 npos = normalize(-pos); @@ -122,14 +120,10 @@ void main() dist_atten *= dist_atten; dist_atten *= 2.0; - dist_atten *= noise; - float lit = da * dist_atten; vec3 col = light_col[i].rgb*lit*diff; - //vec3 col = vec3(dist2, light_col[i].a, lit); - if (spec.a > 0.0) { lit = min(da*6.0, 1.0) * dist_atten; @@ -144,12 +138,8 @@ void main() float gtdenom = 2 * nh; float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*light_col[i].rgb*spec.rgb; - //col += spec.rgb; - } + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += max(lit*scol*light_col[i].rgb*spec.rgb, vec3(0.0)); } out_col += col; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index f162f70592..b331258952 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -102,11 +102,10 @@ void main() { vec3 norm = texture2DRect(normalMap, frag.xy).xyz; norm = decode_normal(norm.xy); // unpack norm - float da = dot(norm, lv); - + norm = normalize(norm); lv = normalize(lv); - da = max(dot(norm, lv), 0.0); + float da = max(dot(norm, lv), 0.0); //float noise = texture2D(noiseMap, frag.xy/128.0).b; @@ -116,7 +115,7 @@ void main() dist_atten *= dist_atten; dist_atten *= 2.0; - float lit = da * dist_atten; // * noise; + float lit = da * dist_atten; col = color.rgb*lit*col; @@ -135,11 +134,8 @@ void main() float gtdenom = 2 * nh; float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*color.rgb*spec.rgb; - } + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += max(lit*scol*color.rgb*spec.rgb, vec3(0.0)); } } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 422f18566f..aae84709d8 100755 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -675,6 +675,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; gPipeline.updateCull(*LLViewerCamera::getInstance(), result, water_clip); + LLPipeline::sUnderWaterRender = FALSE; stop_glerror(); LLGLState::checkStates(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7fa0a972ad..14529099b5 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6316,13 +6316,6 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) F32 x = (3.f * (1.f + light->getLightFalloff())); // why this magic? probably trying to match a historic behavior. float linatten = x / (light_radius); // % of brightness at radius - if (LLPipeline::sRenderDeferred) - { - /*light_color.mV[0] = powf(light_color.mV[0], 2.2f); - light_color.mV[1] = powf(light_color.mV[1], 2.2f); - light_color.mV[2] = powf(light_color.mV[2], 2.2f);*/ - } - mHWLightColors[cur_light] = light_color; LLLightState* light_state = gGL.getLight(cur_light); @@ -6381,6 +6374,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) light->setDiffuse(LLColor4::black); light->setAmbient(LLColor4::black); light->setSpecular(LLColor4::black); + light->setQuadraticAttenuation(1.f); + light->setLinearAttenuation(1.f); } if (gAgentAvatarp && gAgentAvatarp->mSpecialRenderMode == 3) -- cgit v1.2.3 From dd31d9941fe1bfbccdfd0428abbe803b6c495f6c Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 2 Jul 2013 07:39:55 -0700 Subject: NORSPEC-296 make add_media button always available as long as the face is editable --- indra/newview/llfloatertools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index 14923eec3c..7b25291da7 100755 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -1328,7 +1328,7 @@ void LLFloaterTools::getMediaState() getChildView("media_tex")->setEnabled(bool_has_media && editable); getChildView("edit_media")->setEnabled(bool_has_media && LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo && editable ); getChildView("delete_media")->setEnabled(bool_has_media && editable ); - getChildView("add_media")->setEnabled(( ! bool_has_media ) && editable ); + getChildView("add_media")->setEnabled(editable); // TODO: display a list of all media on the face - use 'identical' flag } else // not all face has media but at least one does. @@ -1358,7 +1358,7 @@ void LLFloaterTools::getMediaState() getChildView("media_tex")->setEnabled(TRUE); getChildView("edit_media")->setEnabled(LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo); getChildView("delete_media")->setEnabled(TRUE); - getChildView("add_media")->setEnabled(FALSE ); + getChildView("add_media")->setEnabled(editable); } media_info->setText(media_title); -- cgit v1.2.3 From 418c8a72c875b30d1e0746422afa3caaa809e37b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 2 Jul 2013 07:39:55 -0700 Subject: NORSPEC-296 make add_media button always available as long as the face is editable --- indra/newview/llfloatertools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index 14923eec3c..7b25291da7 100755 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -1328,7 +1328,7 @@ void LLFloaterTools::getMediaState() getChildView("media_tex")->setEnabled(bool_has_media && editable); getChildView("edit_media")->setEnabled(bool_has_media && LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo && editable ); getChildView("delete_media")->setEnabled(bool_has_media && editable ); - getChildView("add_media")->setEnabled(( ! bool_has_media ) && editable ); + getChildView("add_media")->setEnabled(editable); // TODO: display a list of all media on the face - use 'identical' flag } else // not all face has media but at least one does. @@ -1358,7 +1358,7 @@ void LLFloaterTools::getMediaState() getChildView("media_tex")->setEnabled(TRUE); getChildView("edit_media")->setEnabled(LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo); getChildView("delete_media")->setEnabled(TRUE); - getChildView("add_media")->setEnabled(FALSE ); + getChildView("add_media")->setEnabled(editable); } media_info->setText(media_title); -- cgit v1.2.3 From ccc85777986e35c1f16ba71ac0f41bb16429f02e Mon Sep 17 00:00:00 2001 From: Maestro Linden Date: Tue, 2 Jul 2013 17:59:43 +0000 Subject: MAINT-1260 add missing PRIM_ constants to syntax highlighting. Reviewed by Kelly. --- indra/llcommon/lllslconstants.h | 13 +++++++++++++ indra/lscript/lscript_compile/indra.l | 12 +++++++++++- indra/newview/app_settings/keywords.ini | 13 +++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/lllslconstants.h b/indra/llcommon/lllslconstants.h index 83fa5bc249..efa66390e8 100755 --- a/indra/llcommon/lllslconstants.h +++ b/indra/llcommon/lllslconstants.h @@ -67,6 +67,19 @@ const S32 LSL_PRIM_TEXGEN = 22; const S32 LSL_PRIM_POINT_LIGHT = 23; const S32 LSL_PRIM_CAST_SHADOWS = 24; const S32 LSL_PRIM_GLOW = 25; +const S32 LSL_PRIM_TEXT = 26; +const S32 LSL_PRIM_NAME = 27; +const S32 LSL_PRIM_DESC = 28; +const S32 LSL_PRIM_ROT_LOCAL = 29; +const S32 LSL_PRIM_PHYSICS_SHAPE_TYPE = 30; +const S32 LSL_PRIM_OMEGA = 32; +const S32 LSL_PRIM_POS_LOCAL = 33; +const S32 LSL_PRIM_LINK_TARGET = 34; +const S32 LSL_PRIM_SLICE = 35; + +const S32 LSL_PRIM_PHYSICS_SHAPE_PRIM = 0; +const S32 LSL_PRIM_PHYSICS_SHAPE_NONE = 1; +const S32 LSL_PRIM_PHYSICS_SHAPE_CONVEX = 2; const S32 LSL_PRIM_TYPE_BOX = 0; const S32 LSL_PRIM_TYPE_CYLINDER= 1; diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index e7de5b6210..35cf8e85d4 100755 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -515,7 +515,17 @@ int yyerror(const char *fmt, ...); "PRIM_BUMP_SHINY" { count(); yylval.ival = LSL_PRIM_BUMP_SHINY; return(INTEGER_CONSTANT); } "PRIM_FULLBRIGHT" { count(); yylval.ival = LSL_PRIM_FULLBRIGHT; return(INTEGER_CONSTANT); } "PRIM_TEXGEN" { count(); yylval.ival = LSL_PRIM_TEXGEN; return(INTEGER_CONSTANT); } -"PRIM_GLOW" { count(); yylval.ival = LSL_PRIM_GLOW; return(INTEGER_CONSTANT); } +"PRIM_GLOW" { count(); yylval.ival = LSL_PRIM_GLOW; return(INTEGER_CONSTANT); } +"PRIM_TEXT" { count(); yylval.ival = LSL_PRIM_TEXT; return(INTEGER_CONSTANT); } +"PRIM_NAME" { count(); yylval.ival = LSL_PRIM_NAME; return(INTEGER_CONSTANT); } +"PRIM_DESC" { count(); yylval.ival = LSL_PRIM_DESC; return(INTEGER_CONSTANT); } +"PRIM_OMEGA" { count(); yylval.ival = LSL_PRIM_OMEGA; return(INTEGER_CONSTANT); } +"PRIM_LINK_TARGET" { count(); yylval.ival = LSL_PRIM_LINK_TARGET; return(INTEGER_CONSTANT); } +"PRIM_SLICE" { count(); yylval.ival = LSL_PRIM_SLICE; return(INTEGER_CONSTANT); } + +"PRIM_PHYSICS_SHAPE_PRIM" { count(); yylval.ival = LSL_PRIM_PHYSICS_SHAPE_PRIM; return(INTEGER_CONSTANT); } +"PRIM_PHYSICS_SHAPE_NONE" { count(); yylval.ival = LSL_PRIM_PHYSICS_SHAPE_NONE; return(INTEGER_CONSTANT); } +"PRIM_PHYSICS_SHAPE_CONVEX" { count(); yylval.ival = LSL_PRIM_PHYSICS_SHAPE_CONVEX; return(INTEGER_CONSTANT); } "PRIM_TYPE_BOX" { count(); yylval.ival = LSL_PRIM_TYPE_BOX; return(INTEGER_CONSTANT); } "PRIM_TYPE_CYLINDER" { count(); yylval.ival = LSL_PRIM_TYPE_CYLINDER; return(INTEGER_CONSTANT); } diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 766c9a4604..a292843f6c 100755 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -390,6 +390,19 @@ PRIM_BUMP_SHINY Followed by an integer face, one of PRIM_SHINY_NONE, PRIM_SHINY PRIM_FULLBRIGHT Followed by an integer face, and TRUE or FALSE PRIM_TEXGEN Followed by an integer face, and one of PRIM_TEXGEN_DEFAULT or PRIM_TEXGEN_PLANAR PRIM_GLOW Followed by an integer face, and a float from 0.0 to 1.0 specifying glow amount +PRIM_TEXT Followed by string text, vector color, and float alpha +PRIM_NAME Followed by string name +PRIM_DESC Followed by string description +PRIM_ROT_LOCAL Followed by rotation rot +PRIM_PHYSICS_SHAPE_TYPE Followed by PRIM_PHYSICS_SHAPE_PRIM, PRIM_PHYSICS_SHAPE_NONE, or PRIM_PHYSICS_SHAPE_CONVEX +PRIM_OMEGA Followed by vector axis, float spinrate, and float gain +PRIM_POS_LOCAL Followed by vector position +PRIM_LINK_TARGET Followed by integer link_target, then additional prim parameter flags +PRIM_SLICE Followed by vector slice + +PRIM_PHYSICS_SHAPE_PRIM Use the default physics shape +PRIM_PHYSICS_SHAPE_CONVEX Use the convex hull of the prim shape for physics +PRIM_PHYSICS_SHAPE_NONE Ignore this prim in the physics shape PRIM_TYPE_BOX Followed by integer hole shape, vector cut, float hollow, vector twist,:vector top size, and vector top shear PRIM_TYPE_CYLINDER Followed by integer hole shape, vector cut, float hollow, vector twist,:vector top size, and vector top shear -- cgit v1.2.3 From 9e5b4db92883bf27dc49d4c4af948ca0048f143c Mon Sep 17 00:00:00 2001 From: Maestro Linden Date: Tue, 2 Jul 2013 18:07:32 +0000 Subject: MAINT-1312 Fixed a typo in PRIM_TEMP_ON_REZ tooltip. Reviewed by Kelly. --- indra/newview/app_settings/keywords.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index a292843f6c..796c8c3c45 100755 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -378,7 +378,7 @@ PRIM_MATERIAL Followed by PRIM_MATERIAL_STONE, PRIM_MATERIAL_METAL, PRIM_MATERI PRIM_PHYSICS Sets physics to TRUE or FALSE PRIM_FLEXIBLE Followed by TRUE or FALSE, integer softness, float gravity, float friction, float wind, float tension, and vector force PRIM_POINT_LIGHT Followed by TRUE or FALSE, vector color, float intensity, float radius, float falloff -PRIM_TEMP_ON_REZ Sets temporay on rez to TRUE or FALSE +PRIM_TEMP_ON_REZ Sets temporary on rez to TRUE or FALSE PRIM_PHANTOM Sets phantom to TRUE or FALSE PRIM_CAST_SHADOWS DEPRECATED. Takes 1 parameter, an integer, but has no effect when set and always returns 0 if used in llGetPrimitiveParams PRIM_POSITION Sets primitive position to a vector position -- cgit v1.2.3 From e589f47e5e0a711ecb3045f3ed1335a721f39192 Mon Sep 17 00:00:00 2001 From: Maestro Linden Date: Tue, 2 Jul 2013 18:41:03 +0000 Subject: MAINT-528 added syntax highlighting for STATUS_BLOCK_GRAB_OBJECT and corrected related tooltips --- indra/lscript/lscript_compile/indra.l | 1 + indra/newview/app_settings/keywords.ini | 4 +++- indra/newview/skins/default/xui/en/strings.xml | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index 35cf8e85d4..8ed5f99a89 100755 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -161,6 +161,7 @@ int yyerror(const char *fmt, ...); "STATUS_DIE_AT_EDGE" { count(); yylval.ival = 0x80; return(INTEGER_CONSTANT); } "STATUS_RETURN_AT_EDGE" { count(); yylval.ival = 0x100; return(INTEGER_CONSTANT); } "STATUS_CAST_SHADOWS" { count(); yylval.ival = 0x200; return(INTEGER_CONSTANT); } +"STATUS_BLOCK_GRAB_OBJECT" { count(); yylval.ival = 0x400; return(INTEGER_CONSTANT); } "AGENT_FLYING" { count(); yylval.ival = AGENT_FLYING; return(INTEGER_CONSTANT); } "AGENT_ATTACHMENTS" { count(); yylval.ival = AGENT_ATTACHMENTS; return(INTEGER_CONSTANT); } diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 796c8c3c45..ef3c319da6 100755 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -62,10 +62,12 @@ STATUS_ROTATE_X Passed in the llSetStatus library function. If FALSE, object do STATUS_ROTATE_Y Passed in the llSetStatus library function. If FALSE, object doesn't rotate around local Y axis STATUS_ROTATE_Z Passed in the llSetStatus library function. If FALSE, object doesn't rotate around local Z axis STATUS_SANDBOX Passed in the llSetStatus library function. If TRUE, object can't cross region boundaries or move more than 10 meters from its start location -STATUS_BLOCK_GRAB Passed in the llSetStatus library function. If TRUE, object can't be grabbed and physically dragged +STATUS_BLOCK_GRAB Passed in the llSetStatus library function. If TRUE, root prim of linkset (or unlinked prim) can't be grabbed and physically dragged STATUS_DIE_AT_EDGE Passed in the llSetStatus library function. If TRUE, objects that reach the edge of the world just die:rather than teleporting back to the owner STATUS_RETURN_AT_EDGE Passed in the llSetStatus library function. If TRUE, script rezzed objects that reach the edge of the world:are returned rather than killed:STATUS_RETURN_AT_EDGE trumps STATUS_DIE_AT_EDGE if both are set STATUS_CAST_SHADOWS Passed in the llSetStatus library function. If TRUE, object casts shadows on other objects +STATUS_BLOCK_GRAB_OBJECT Passed in the llSetStatus library function. If TRUE, no prims in linkset can be grabbed or physically dragged + AGENT Passed in llSensor library function to look for other Agents ACTIVE Passed in llSensor library function to look for moving objects PASSIVE Passed in llSensor library function to look for objects that aren't moving diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index ef01f27da2..fb1846860c 100755 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -646,11 +646,11 @@ Returns the wind velocity at the object position + offset llSetStatus(integer status, integer value) -Sets status (STATUS_PHYSICS, STATUS_PHANTOM, STATUS_BLOCK_GRAB, STATUS_ROTATE_X, STATUS_ROTATE_Y, and/or STATUS_ROTATE_Z) to value +Sets status (STATUS_PHYSICS, STATUS_PHANTOM, STATUS_BLOCK_GRAB, STATUS_BLOCK_GRAB_OBJECT, STATUS_ROTATE_X, STATUS_ROTATE_Y, and/or STATUS_ROTATE_Z) to value integer llGetStatus(integer status) -Returns value of status (STATUS_PHYSICS, STATUS_PHANTOM, STATUS_BLOCK_GRAB, STATUS_ROTATE_X, STATUS_ROTATE_Y, and/or STATUS_ROTATE_Z) +Returns the boolean value of status (STATUS_PHYSICS, STATUS_PHANTOM, STATUS_BLOCK_GRAB, STATUS_BLOCK_GRAB_OBJECT, STATUS_ROTATE_X, STATUS_ROTATE_Y, or STATUS_ROTATE_Z) llSetScale(vector scale) -- cgit v1.2.3 From f1c04467f70ce7e5a048614fa7db631cd3a35a00 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 2 Jul 2013 13:12:08 -0700 Subject: NORSPEC-292 fix issues with managing LLNetworkData::PARAMS_LIGHT_IMAGE when demoting spotlights by removing their tex --- indra/newview/llpanelvolume.cpp | 13 ++++++++++++- indra/newview/lltexturectrl.cpp | 13 +++++++++++-- indra/newview/llvovolume.cpp | 6 ++++-- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 02d363d795..0b501f6a74 100755 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -710,9 +710,20 @@ void LLPanelVolume::onLightCancelColor(const LLSD& data) void LLPanelVolume::onLightCancelTexture(const LLSD& data) { LLTextureCtrl* LightTextureCtrl = getChild("light texture control"); + if (LightTextureCtrl) { - LightTextureCtrl->setImageAssetID(mLightSavedTexture); + LightTextureCtrl->setImageAssetID(LLUUID::null); + } + + LLVOVolume *volobjp = (LLVOVolume *) mObject.get(); + if(volobjp) + { + // Cancel the light texture as requested + // NORSPEC-292 + // + volobjp->setLightTextureID(LLUUID::null); + volobjp->setIsLight(TRUE,TRUE); } } diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 4676f7b251..2b1ed5858a 100755 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -133,7 +133,8 @@ public: PermissionMask getFilterPermMask(); void updateFilterPermMask(); void commitIfImmediateSet(); - + void commitCancel(); + void onFilterEdit(const std::string& search_string ); void setCanApply(bool can_preview, bool can_apply); @@ -706,6 +707,14 @@ void LLFloaterTexturePicker::commitIfImmediateSet() } } +void LLFloaterTexturePicker::commitCancel() +{ + if (!mNoCopyTextureSelected && mOwner && mCanApply) + { + mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CANCEL); + } +} + // static void LLFloaterTexturePicker::onBtnSetToDefault(void* userdata) { @@ -733,7 +742,7 @@ void LLFloaterTexturePicker::onBtnNone(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; self->setImageID( LLUUID::null ); - self->commitIfImmediateSet(); + self->commitCancel(); } /* diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 685f854573..d890548710 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2590,6 +2590,7 @@ void LLVOVolume::setLightTextureID(LLUUID id) if (hasLightTexture()) { setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE, FALSE, true); + parameterChanged(LLNetworkData::PARAMS_LIGHT_IMAGE, true); mLightTexture = NULL; } } @@ -2607,7 +2608,8 @@ void LLVOVolume::setSpotLightParams(LLVector3 params) void LLVOVolume::setIsLight(BOOL is_light) { - if (is_light != getIsLight()) + BOOL was_light = getIsLight(); + if (is_light != was_light) { if (is_light) { @@ -2792,7 +2794,7 @@ void LLVOVolume::updateSpotLightPriority() bool LLVOVolume::isLightSpotlight() const { LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE); - if (params) + if (params && getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE)) { return params->isLightSpotlight(); } -- cgit v1.2.3 From c262ef58fab4dcbe8d891f9acba285ddc2c296db Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 2 Jul 2013 13:16:23 -0700 Subject: NORSPEC-292 remove unnecessary call to setIsLight --- indra/newview/llpanelvolume.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 0b501f6a74..a1d60b5b16 100755 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -723,7 +723,6 @@ void LLPanelVolume::onLightCancelTexture(const LLSD& data) // NORSPEC-292 // volobjp->setLightTextureID(LLUUID::null); - volobjp->setIsLight(TRUE,TRUE); } } -- cgit v1.2.3 From 716f6b93355500c0aee378c0ce86a7dedcc24a9a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Jul 2013 15:30:42 -0500 Subject: NORSPEC-290 Disable occlusion culling for distortion render target since there are generally zero under water occluders. --- indra/newview/pipeline.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 14529099b5..97abbc2815 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9208,12 +9208,13 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) water_clip = 1; } + S32 occlusion = LLPipeline::sUseOcclusion; + LLPipeline::sUseOcclusion = 0; + if (!LLViewerCamera::getInstance()->cameraUnderWater()) { //generate planar reflection map //disable occlusion culling for reflection map for now - S32 occlusion = LLPipeline::sUseOcclusion; - LLPipeline::sUseOcclusion = 0; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glClearColor(0,0,0,0); mWaterRef.bindTarget(); @@ -9317,7 +9318,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.popMatrix(); mWaterRef.flush(); glh_set_current_modelview(current); - LLPipeline::sUseOcclusion = occlusion; } camera.setOrigin(camera_in.getOrigin()); @@ -9373,6 +9373,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLPipeline::sUnderWaterRender = FALSE; mWaterDis.flush(); } + + LLPipeline::sUseOcclusion = occlusion; last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate; LLPipeline::sReflectionRender = FALSE; -- cgit v1.2.3 From 9c8fdf5a49145f4147f50c16c4e1775386976798 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 2 Jul 2013 17:07:50 -0400 Subject: fix bug reading RenderMaterialsCapability, improve logging for NORSPEC-206 --- indra/newview/llviewerregion.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index b541a35111..e6fc82f761 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1951,7 +1951,7 @@ void LLViewerRegion::resetMaterialsCapThrottle() && mSimulatorFeatures["RenderMaterialsCapability"].isReal() ) { requests_per_sec = mSimulatorFeatures["RenderMaterialsCapability"].asReal(); - if ( requests_per_sec != 0.0f ) + if ( requests_per_sec == 0.0f ) { requests_per_sec = 1.0f; LL_WARNS("Materials") @@ -1960,9 +1960,9 @@ void LLViewerRegion::resetMaterialsCapThrottle() << requests_per_sec << " per second" << LL_ENDL; } - LL_DEBUGS_ONCE("Materials") << "region '" << getName() - << "' RenderMaterialsCapability " << requests_per_sec - << LL_ENDL; + LL_DEBUGS("Materials") << "region '" << getName() + << "' RenderMaterialsCapability " << requests_per_sec + << LL_ENDL; } else { -- cgit v1.2.3 From 930de04f51212195a2c7a877d235d4106f4d37e2 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Jul 2013 18:02:28 -0500 Subject: NORSPEC-287 Make alpha sRGB correction curves match OpenGL spec. --- .../shaders/class1/deferred/alphaF.glsl | 29 ++++++++++++++++++---- .../shaders/class1/deferred/materialF.glsl | 28 ++++++++++++++++++--- .../shaders/class1/deferred/multiPointLightF.glsl | 2 ++ .../shaders/class1/deferred/multiSpotLightF.glsl | 25 +++++++++++++++---- .../class1/deferred/postDeferredGammaCorrect.glsl | 13 +++++++++- .../shaders/class1/deferred/softenLightF.glsl | 26 +++++++++++++++++-- .../shaders/class2/deferred/softenLightF.glsl | 24 ++++++++++++++++-- indra/newview/lldrawable.cpp | 2 ++ 8 files changed, 131 insertions(+), 18 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 143af0576c..e80e4b0fcf 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -135,6 +135,26 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + void main() { @@ -217,7 +237,7 @@ void main() #endif vec4 gamma_diff = diff; - diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); + diff.rgb = srgb_to_linear(diff.rgb); #ifdef USE_VERTEX_COLOR float vertex_color_alpha = vertex_color.a; @@ -243,9 +263,8 @@ void main() color.rgb = scaleSoftClip(color.rgb); - color.rgb = pow(color.rgb, vec3(2.2)); + color.rgb = srgb_to_linear(color.rgb); col = vec4(0,0,0,0); - #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); @@ -257,9 +276,9 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * pow(vary_pointlight_col, vec3(2.2)) * col.rgb; + color.rgb += diff.rgb * srgb_to_linear(vary_pointlight_col) * col.rgb; - color.rgb = pow(color.rgb, vec3(1.0/2.2)); + color.rgb = linear_to_srgb(color.rgb); frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 53ade8ea64..027c6eeadb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -30,6 +30,28 @@ uniform float emissive_brightness; + +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + + #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) #ifdef DEFINE_GL_FRAGCOLOR @@ -459,7 +481,7 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vec3 old_diffcol = diffcol.rgb; - diffcol.rgb = pow(diffcol.rgb, vec3(2.2)); + diffcol.rgb = srgb_to_linear(diffcol.rgb); #endif #if HAS_SPECULAR_MAP @@ -648,7 +670,7 @@ void main() col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); //convert to linear space before adding local lights - col = pow(col, vec3(2.2)); + col = srgb_to_linear(col); vec3 npos = normalize(-pos.xyz); @@ -665,7 +687,7 @@ void main() //convert to gamma space for display on screen - col.rgb = pow(col.rgb, vec3(1.0/2.2)); + col.rgb = linear_to_srgb(col.rgb); frag_color.rgb = col.rgb; glare = min(glare, 1.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index a955ef6e9d..3ba6de8b76 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -99,6 +99,7 @@ void main() norm = normalize(norm); vec4 spec = texture2DRect(specularRect, frag.xy); vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; + float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 out_col = vec3(0,0,0); vec3 npos = normalize(-pos); @@ -157,6 +158,7 @@ void main() } } + frag_color.rgb = out_col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 7d39ad7bc1..11220bfa47 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -84,15 +84,30 @@ vec3 decode_normal (vec2 enc) return n; } -vec4 correctWithGamma(vec4 col) +vec3 srgb_to_linear(vec3 cs) { - return vec4(pow(col.rgb, vec3(2.2)), col.a); + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); + ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = tc-vec2(0.5); @@ -108,7 +123,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); + ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -126,7 +141,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); + ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = tc-vec2(0.5); diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 6f2cfae6d2..a3610bfffa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -38,9 +38,20 @@ VARYING vec2 vary_fragcoord; uniform float texture_gamma; +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + void main() { vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); - frag_color = pow(diff, vec4(texture_gamma, texture_gamma, texture_gamma, 1.0f)); + diff.rgb = linear_to_srgb(diff.rgb); + frag_color = diff; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index f0d2746700..dc2519bd0a 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -78,6 +78,28 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; + +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + + vec3 decode_normal (vec2 enc) { vec2 fenc = enc*4-2; @@ -313,7 +335,7 @@ void main() vec4 diffuse = texture2DRect(diffuseRect, tc); //convert to gamma space - diffuse.rgb = pow(diffuse.rgb, vec3(1.0/2.2)); + diffuse.rgb = linear_to_srgb(diffuse.rgb); vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec3 col; @@ -369,7 +391,7 @@ void main() col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } - col = pow(col, vec3(2.2)); + col = srgb_to_linear(col); //col = vec3(1,0,1); //col.g = envIntensity; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 6e05091b57..06447261b4 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,6 +78,26 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -326,7 +346,7 @@ void main() vec4 diffuse = texture2DRect(diffuseRect, tc); //convert to gamma space - diffuse.rgb = pow(diffuse.rgb, vec3(1.0/2.2)); + diffuse.rgb = linear_to_srgb(diffuse.rgb); vec3 col; float bloom = 0.0; @@ -392,7 +412,7 @@ void main() col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } - col = pow(col, vec3(2.2)); + col = srgb_to_linear(col); //col = vec3(1,0,1); //col.g = envIntensity; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 8c9fd4152a..2a333157f2 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -527,6 +527,8 @@ void LLDrawable::makeStatic(BOOL warning_enabled) } updatePartition(); } + + llassert(isAvatar() || isRoot() || mParent->isStatic()); } // Returns "distance" between target destination and resulting xfrom -- cgit v1.2.3 From f41c8f53412b3ca8500e72d9cde8e70ca0bc266e Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 2 Jul 2013 16:04:31 -0700 Subject: MAINT-2808 Viewer side : Stats for OBJECT_ATTACHMENT_GEOMETRY_BYTES and OBJECT_ATTACHMENT_SURFACE_AREA do not return to the 'no attachments' values after avatar removes last attachment --- indra/newview/llavatarrenderinfoaccountant.cpp | 4 ++-- indra/newview/llvoavatar.cpp | 4 ++-- indra/newview/llvovolume.cpp | 18 ++++++++++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index da4b6cf806..2a4ec6d320 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -260,11 +260,11 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio { info[KEY_WEIGHT] = avatar->getVisualComplexity(); } - if (avatar->getAttachmentGeometryBytes() > 0) + if (avatar->getAttachmentGeometryBytes() >= 0) { info[KEY_GEOMETRY] = (S32) avatar->getAttachmentGeometryBytes(); } - if (avatar->getAttachmentSurfaceArea() > 0.f) + if (avatar->getAttachmentSurfaceArea() >= 0.f) { info[KEY_SURFACE] = avatar->getAttachmentSurfaceArea(); } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 1aa38e6bfa..0ffd8ad119 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -667,8 +667,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, LLAvatarAppearance(&gAgentWearables), LLViewerObject(id, pcode, regionp), mSpecialRenderMode(0), - mAttachmentGeometryBytes(0), - mAttachmentSurfaceArea(0.f), + mAttachmentGeometryBytes(-1), + mAttachmentSurfaceArea(-1.f), mReportedVisualComplexity(-1), mReportedAttachmentGeometryBytes(-1), mReportedAttachmentSurfaceArea(-1.f), diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 4835ffcd8f..e3bd2b8621 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4998,8 +4998,22 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (pAvatarVO) { - pAvatarVO->mAttachmentGeometryBytes += group->mGeometryBytes; - pAvatarVO->mAttachmentSurfaceArea += group->mSurfaceArea; + if (pAvatarVO->mAttachmentGeometryBytes < 0) + { // First time through value is -1 + pAvatarVO->mAttachmentGeometryBytes = group->mGeometryBytes; + } + else + { + pAvatarVO->mAttachmentGeometryBytes += group->mGeometryBytes; + } + if (pAvatarVO->mAttachmentSurfaceArea < 0.f) + { // First time through value is -1 + pAvatarVO->mAttachmentSurfaceArea = group->mSurfaceArea; + } + else + { + pAvatarVO->mAttachmentSurfaceArea += group->mSurfaceArea; + } } } -- cgit v1.2.3 From ce6bb9538489b420d5f0827779912d7241dfa6c6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 2 Jul 2013 16:50:35 -0700 Subject: NORSPEC-293 nix gamma correction in fullbrightF causing this visual disparity --- .../app_settings/shaders/class1/deferred/fullbrightF.glsl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index dc1dead656..5bdb3115d9 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -45,19 +45,21 @@ vec3 fullbrightScaleSoftClip(vec3 light); void main() { #if HAS_DIFFUSE_LOOKUP - vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color; + vec4 color = diffuseLookup(vary_texcoord0.xy); #else - vec4 color = texture2D(diffuseMap, vary_texcoord0.xy)*vertex_color; + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); #endif color.rgb = pow(color.rgb,vec3(2.2f,2.2f,2.2f)); - - color.rgb = fullbrightAtmosTransport(color.rgb); + color.rgb *= vertex_color.rgb; + color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); - color.rgb = pow(color.rgb, vec3(1.0/2.2)); + // NORSPEC-293 + //color.rgb = pow(color.rgb, vec3(1.0/2.2)); - frag_color = color; + frag_color.rgb = color.rgb; + frag_color.a = color.a; } -- cgit v1.2.3 From ed3b5184990822162840e1e7611d338a880e67a6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 3 Jul 2013 10:42:03 -0700 Subject: NORSPEC-295 make a deferred path version of fullbright alpha mask shader so we can included gamma ops --- .../class1/deferred/fullbrightAlphaMaskF.glsl | 70 ++++++++++++++++++++++ indra/newview/lldrawpoolsimple.cpp | 15 ++++- indra/newview/llviewershadermgr.cpp | 17 ++++++ indra/newview/llviewershadermgr.h | 1 + 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl new file mode 100644 index 0000000000..5aa31b96df --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl @@ -0,0 +1,70 @@ +/** + * @file fullbrightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +#extension GL_ARB_texture_rectangle : enable + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +#if !HAS_DIFFUSE_LOOKUP +uniform sampler2D diffuseMap; +#endif + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +uniform float minimum_alpha; + +void main() +{ +#if HAS_DIFFUSE_LOOKUP + vec4 color = diffuseLookup(vary_texcoord0.xy); +#else + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); +#endif + + if (color.a < minimum_alpha) + { + discard; + } + + color.rgb = pow(color.rgb,vec3(2.2f,2.2f,2.2f)); + color.rgb *= vertex_color.rgb; + + color.rgb = fullbrightAtmosTransport(color.rgb); + color.rgb = fullbrightScaleSoftClip(color.rgb); + + color.rgb = pow(color.rgb, vec3(1.0/2.2)); + + frag_color.rgb = color.rgb; + frag_color.a = color.a; +} + diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 2cf9d833c6..e219769a0c 100755 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -625,14 +625,16 @@ S32 LLDrawPoolFullbright::getNumPasses() void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) { - gObjectFullbrightAlphaMaskProgram.bind(); + if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) { + gObjectFullbrightAlphaMaskProgram.bind(); gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); } else { - gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + gDeferredFullbrightAlphaMaskProgram.bind(); + gDeferredFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); } } @@ -646,7 +648,14 @@ void LLDrawPoolFullbrightAlphaMask::renderPostDeferred(S32 pass) void LLDrawPoolFullbrightAlphaMask::endPostDeferredPass(S32 pass) { - gObjectFullbrightAlphaMaskProgram.unbind(); + if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) + { + gObjectFullbrightAlphaMaskProgram.unbind(); + } + else + { + gDeferredFullbrightAlphaMaskProgram.unbind(); + } LLRenderPass::endRenderPass(pass); } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 7bce629d3e..6d9a0dd261 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -197,6 +197,7 @@ LLGLSLShader gDeferredAttachmentShadowProgram; LLGLSLShader gDeferredAlphaProgram; LLGLSLShader gDeferredAvatarEyesProgram; LLGLSLShader gDeferredFullbrightProgram; +LLGLSLShader gDeferredFullbrightAlphaMaskProgram; LLGLSLShader gDeferredEmissiveProgram; LLGLSLShader gDeferredPostProgram; LLGLSLShader gDeferredCoFProgram; @@ -290,6 +291,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredAlphaProgram); mShaderList.push_back(&gDeferredSkinnedAlphaProgram); mShaderList.push_back(&gDeferredFullbrightProgram); + mShaderList.push_back(&gDeferredFullbrightAlphaMaskProgram); mShaderList.push_back(&gDeferredFullbrightShinyProgram); mShaderList.push_back(&gDeferredSkinnedFullbrightShinyProgram); mShaderList.push_back(&gDeferredSkinnedFullbrightProgram); @@ -1130,6 +1132,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.unload(); gDeferredAlphaProgram.unload(); gDeferredFullbrightProgram.unload(); + gDeferredFullbrightAlphaMaskProgram.unload(); gDeferredEmissiveProgram.unload(); gDeferredAvatarEyesProgram.unload(); gDeferredPostProgram.unload(); @@ -1493,6 +1496,20 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredFullbrightProgram.createShader(NULL, NULL); } + if (success) + { + gDeferredFullbrightAlphaMaskProgram.mName = "Deferred Fullbright Alpha Mask Shader"; + gDeferredFullbrightAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; + gDeferredFullbrightAlphaMaskProgram.mFeatures.hasGamma = true; + gDeferredFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; + gDeferredFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + gDeferredFullbrightAlphaMaskProgram.mShaderFiles.clear(); + gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredFullbrightAlphaMaskProgram.createShader(NULL, NULL); + } + if (success) { gDeferredFullbrightShinyProgram.mName = "Deferred FullbrightShiny Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index ed8167947d..f3a419b1f2 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -363,6 +363,7 @@ extern LLGLSLShader gDeferredAvatarShadowProgram; extern LLGLSLShader gDeferredAttachmentShadowProgram; extern LLGLSLShader gDeferredAlphaProgram; extern LLGLSLShader gDeferredFullbrightProgram; +extern LLGLSLShader gDeferredFullbrightAlphaMaskProgram; extern LLGLSLShader gDeferredEmissiveProgram; extern LLGLSLShader gDeferredAvatarEyesProgram; extern LLGLSLShader gDeferredAvatarAlphaProgram; -- cgit v1.2.3 From d2855f9eecdfb80dca6c5a8b496ef9fe1b746843 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 3 Jul 2013 10:56:10 -0700 Subject: NORSPEC-293 better fix incorporating srgb_to_linear curve and applying texture gamma corrections to spot inputs --- .../class1/deferred/fullbrightAlphaMaskF.glsl | 24 ++++++++++++++++++++-- .../shaders/class1/deferred/fullbrightF.glsl | 24 +++++++++++++++++++--- .../shaders/class1/deferred/spotLightF.glsl | 22 +++++++++++++++++++- .../shaders/class2/deferred/alphaV.glsl | 22 +++++++++++++++++++- .../shaders/class2/deferred/multiSpotLightF.glsl | 12 ++++++++++- .../shaders/class2/deferred/spotLightF.glsl | 12 ++++++++++- 6 files changed, 107 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl index 5aa31b96df..3d93583e1e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl @@ -41,6 +41,26 @@ VARYING vec2 vary_texcoord0; vec3 fullbrightAtmosTransport(vec3 light); vec3 fullbrightScaleSoftClip(vec3 light); +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + uniform float minimum_alpha; void main() @@ -56,13 +76,13 @@ void main() discard; } - color.rgb = pow(color.rgb,vec3(2.2f,2.2f,2.2f)); + color.rgb = srgb_to_linear(color.rgb); color.rgb *= vertex_color.rgb; color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); - color.rgb = pow(color.rgb, vec3(1.0/2.2)); + color.rgb = linear_to_srgb(color.rgb); frag_color.rgb = color.rgb; frag_color.a = color.a; diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 5bdb3115d9..ec25f52ef5 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -41,6 +41,25 @@ VARYING vec2 vary_texcoord0; vec3 fullbrightAtmosTransport(vec3 light); vec3 fullbrightScaleSoftClip(vec3 light); +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} void main() { @@ -50,14 +69,13 @@ void main() vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); #endif - color.rgb = pow(color.rgb,vec3(2.2f,2.2f,2.2f)); + color.rgb = srgb_to_linear(color.rgb); color.rgb *= vertex_color.rgb; color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); - // NORSPEC-293 - //color.rgb = pow(color.rgb, vec3(1.0/2.2)); + color.rgb = linear_to_srgb(color.rgb); frag_color.rgb = color.rgb; frag_color.a = color.a; diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 045d1a00cd..61262c9eb5 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -82,9 +82,29 @@ vec3 decode_normal (vec2 enc) return n; } +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + vec4 correctWithGamma(vec4 col) { - return vec4(pow(col.rgb, vec3(2.2)), col.a); + return vec4(srgb_to_linear(col.rgb), col.a); } vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 13c6ffc607..fc60998ec3 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -85,6 +85,26 @@ uniform vec3 light_diffuse[8]; uniform vec3 sun_dir; +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -183,7 +203,7 @@ void main() //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - vec3 dff = pow(diffuse_color.rgb, vec3(2.2f,2.2f,2.2f)); + vec3 dff = srgb_to_linear(diffuse_color.rgb); vary_pointlight_col = dff; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 14f6afc8c2..0aac9d77de 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -85,9 +85,19 @@ vec3 decode_normal (vec2 enc) return n; } +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + vec4 correctWithGamma(vec4 col) { - return vec4(pow(col.rgb, vec3(2.2)), col.a); + return vec4(srgb_to_linear(col.rgb), col.a); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 6e0218cb9c..17c0d26f6d 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -85,9 +85,19 @@ vec3 decode_normal (vec2 enc) return n; } +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + vec4 correctWithGamma(vec4 col) { - return vec4(pow(col.rgb, vec3(2.2)), col.a); + return vec4(srgb_to_linear(col.rgb), col.a); } vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) -- cgit v1.2.3 From cf3b7bbe4b932b683d0d30c95505f45d16a1d2a7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 3 Jul 2013 12:59:29 -0500 Subject: NORSPEC-298 Fix for inconsistent alpha lighting when diffuse color is not white. --- .../shaders/class1/deferred/alphaF.glsl | 4 +- .../shaders/class1/deferred/alphaV.glsl | 15 +- .../shaders/class2/deferred/alphaV.glsl | 224 --------------------- 3 files changed, 15 insertions(+), 228 deletions(-) delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e80e4b0fcf..640e273415 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -61,6 +61,7 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec3 vary_pointlight_col_linear; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; @@ -228,6 +229,7 @@ void main() { shadow = 1.0; } + #endif #ifdef USE_INDEXED_TEX @@ -276,7 +278,7 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * srgb_to_linear(vary_pointlight_col) * col.rgb; + color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; color.rgb = linear_to_srgb(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index 9d3ba564cd..6b5b54b863 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl @@ -68,6 +68,7 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec3 vary_pointlight_col_linear; #ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; @@ -86,6 +87,16 @@ uniform vec3 light_diffuse[8]; uniform vec3 sun_dir; +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector @@ -178,10 +189,8 @@ void main() vec3 diff = diffuse_color.rgb; - - vary_pointlight_col = diff; - + vary_pointlight_col_linear = srgb_to_linear(diff); col.rgb = vec3(0,0,0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl deleted file mode 100755 index 13c6ffc607..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ /dev/null @@ -1,224 +0,0 @@ -/** - * @file alphaV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat3 normal_matrix; -uniform mat4 texture_matrix0; -uniform mat4 projection_matrix; -uniform mat4 modelview_matrix; -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; - -#ifdef USE_INDEXED_TEX -void passTextureIndex(); -#endif - -ATTRIBUTE vec3 normal; - -#ifdef USE_VERTEX_COLOR -ATTRIBUTE vec4 diffuse_color; -#endif - -ATTRIBUTE vec2 texcoord0; - -#ifdef HAS_SKIN -mat4 getObjectSkinnedTransform(); -#else -#ifdef IS_AVATAR_SKIN -mat4 getSkinnedTransform(); -#endif -#endif - -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); -void calcAtmospherics(vec3 inPositionEye); - -vec3 calcDirectionalLight(vec3 n, vec3 l); - -vec3 atmosAmbient(vec3 light); -vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; - -#ifdef USE_VERTEX_COLOR -VARYING vec4 vertex_color; -#endif - -VARYING vec2 vary_texcoord0; -VARYING vec3 vary_norm; - -uniform float near_clip; -uniform float shadow_offset; -uniform float shadow_bias; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -uniform vec3 sun_dir; - -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return vec3(a,a,a); -} - -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - } - - return vec3(da,da,da); -} - -void main() -{ - vec4 pos; - vec3 norm; - - //transform vertex -#ifdef HAS_SKIN - mat4 trans = getObjectSkinnedTransform(); - trans = modelview_matrix * trans; - - pos = trans * vec4(position.xyz, 1.0); - - norm = position.xyz + normal.xyz; - norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz); - vec4 frag_pos = projection_matrix * pos; - gl_Position = frag_pos; -#else - -#ifdef IS_AVATAR_SKIN - mat4 trans = getSkinnedTransform(); - vec4 pos_in = vec4(position.xyz, 1.0); - pos.x = dot(trans[0], pos_in); - pos.y = dot(trans[1], pos_in); - pos.z = dot(trans[2], pos_in); - pos.w = 1.0; - - norm.x = dot(trans[0].xyz, normal); - norm.y = dot(trans[1].xyz, normal); - norm.z = dot(trans[2].xyz, normal); - norm = normalize(norm); - - vec4 frag_pos = projection_matrix * pos; - gl_Position = frag_pos; -#else - norm = normalize(normal_matrix * normal); - vec4 vert = vec4(position.xyz, 1.0); - pos = (modelview_matrix * vert); - gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); -#endif - -#endif - -#ifdef USE_INDEXED_TEX - passTextureIndex(); - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -#else - vary_texcoord0 = texcoord0; -#endif - - vary_norm = norm; - float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); - vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; - - calcAtmospherics(pos.xyz); - -#ifndef USE_VERTEX_COLOR - vec4 diffuse_color = vec4(1,1,1,1); -#endif - - //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); - vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - - vec3 dff = pow(diffuse_color.rgb, vec3(2.2f,2.2f,2.2f)); - - vary_pointlight_col = dff; - - col.rgb = vec3(0,0,0); - - // Add windlight lights - col.rgb = atmosAmbient(col.rgb); - - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0-ambient); - - col.rgb *= ambient; - - vary_directional.rgb = atmosAffectDirectionalLight(1.0f); - vary_ambient = col.rgb*dff; - - col.rgb = col.rgb*dff; - -#ifdef USE_VERTEX_COLOR - vertex_color = col; -#endif - -#ifdef HAS_SKIN - vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -#else - -#ifdef IS_AVATAR_SKIN - vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); -#else - pos = modelview_projection_matrix * vert; - vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); -#endif - -#endif - -} -- cgit v1.2.3 From 6963c69c85144a8d20e4c67f65ec9334c8fde22d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 3 Jul 2013 11:42:52 -0700 Subject: NORSPEC-297 fix deferred fog using wrong ref point --- indra/newview/app_settings/shaders/class1/deferred/waterV.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl index ece34dcc4e..9734acf005 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl @@ -85,7 +85,7 @@ void main() pos.w = 1.0; pos = modelview_matrix*pos; - calcAtmospherics(view.xyz); + calcAtmospherics(pos.xyz); //pass wave parameters to pixel shader vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055; -- cgit v1.2.3 From 4ad86739c1b6823540fb596481621c089d3a3183 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 3 Jul 2013 15:10:54 -0500 Subject: NORSPEC-286 Make raycast code pay attention to diffuse alpha mode. --- indra/newview/llvovolume.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index d890548710..b545e99a32 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3724,8 +3724,30 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& { LLFace* face = mDrawable->getFace(face_hit); + bool ignore_alpha = false; + + const LLTextureEntry* te = face->getTextureEntry(); + if (te) + { + LLMaterial* mat = te->getMaterialParams(); + if (mat) + { + U8 mode = mat->getDiffuseAlphaMode(); + + if (mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE || + mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE) + { + ignore_alpha = true; + } + } + } + if (face && - (pick_transparent || !face->getTexture() || !face->getTexture()->hasGLTexture() || face->getTexture()->getMask(face->surfaceToTexture(tc, p, n)))) + (ignore_alpha || + pick_transparent || + !face->getTexture() || + !face->getTexture()->hasGLTexture() || + face->getTexture()->getMask(face->surfaceToTexture(tc, p, n)))) { local_end = p; if (face_hitp != NULL) -- cgit v1.2.3 From 5d7be3a4987c603500bbe3733870a378bd9eda92 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 8 Jul 2013 10:46:21 -0700 Subject: NORSPEC-300 stop-gap measure of clamping offsets > 0 until server-side fix to store negative values can be released --- indra/newview/skins/default/xui/en/panel_tools_texture.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index 5ac2ec2b20..426c0c4915 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -663,7 +663,7 @@ label_width="205" layout="topleft" left="10" - min_val="-1" + min_val="0" name="bumpyOffsetU" width="265" /> Date: Mon, 8 Jul 2013 12:17:41 -0700 Subject: NORSPEC-293 WIP fix black glowing fullbright, does not address deferred glow errors --- indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index ec25f52ef5..90518128fb 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -70,10 +70,10 @@ void main() #endif color.rgb = srgb_to_linear(color.rgb); - color.rgb *= vertex_color.rgb; color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); + color.rgb *= vertex_color.rgb; color.rgb = linear_to_srgb(color.rgb); -- cgit v1.2.3 From 167fc262734dfb72e33e57a0b309d0ce6a17ce47 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 9 Jul 2013 06:38:12 -0700 Subject: NORSPEC-291 WIP drop the no deferred underwater logic only --- indra/newview/lldrawpoolalpha.cpp | 11 +- indra/newview/llviewerdisplay.cpp | 8 +- indra/newview/pipeline.cpp | 523 ++++++++++++++++++++++++++++++++++++-- indra/newview/pipeline.h | 3 +- 4 files changed, 522 insertions(+), 23 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index c832e1401d..737da2e209 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -113,6 +113,15 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) gObjectFullbrightAlphaMaskProgram.setMinimumAlpha(0.33f); } + if (LLPipeline::sUnderWaterRender) + { + emissive_shader = &gObjectEmissiveWaterProgram; + } + else + { + emissive_shader = &gObjectEmissiveProgram; + } + deferred_render = TRUE; if (mVertexShaderLevel > 0) { @@ -352,7 +361,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) LLMaterial* mat = NULL; - if (deferred_render && !LLPipeline::sUnderWaterRender) + if (deferred_render) { mat = params.mMaterial; } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index f90b35a7bd..e6718ca618 100755 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -890,7 +890,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { gGL.setColorMask(true, true); - if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) + if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.bindTarget(); glClearColor(1,0,1,1); @@ -939,7 +939,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gGL.setColorMask(true, false); - if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) + if (LLPipeline::sRenderDeferred) { gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance()); } @@ -976,7 +976,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (to_texture) { - if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) + if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.flush(); if(LLRenderTarget::sUseFBO) @@ -1002,7 +1002,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } } - if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) + if (LLPipeline::sRenderDeferred) { gPipeline.renderDeferredLighting(); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c9f8a4d9ee..aed73be3c1 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2448,7 +2448,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl if (to_texture) { - if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) + if (LLPipeline::sRenderDeferred) { mOcclusionDepth.bindTarget(); } @@ -2593,7 +2593,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl if (to_texture) { - if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) + if (LLPipeline::sRenderDeferred) { mOcclusionDepth.flush(); } @@ -8891,6 +8891,495 @@ void LLPipeline::renderDeferredLighting() } +void LLPipeline::renderDeferredLightingToRenderTarget(LLRenderTarget* render_target) +{ + if (!sCull) + { + return; + } + + { + LLFastTimer ftm(FTM_RENDER_DEFERRED); + + LLViewerCamera* camera = LLViewerCamera::getInstance(); + { + LLGLDepthTest depth(GL_TRUE); + mDeferredDepth.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), + 0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); + } + + LLGLEnable multisample(0); + + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) + { + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); + } + + //ati doesn't seem to love actually using the stencil buffer on FBO's + LLGLDisable stencil(GL_STENCIL_TEST); + //glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); + //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + + gGL.setColorMask(true, true); + + //draw a cube around every light + LLVertexBuffer::unbind(); + + LLGLEnable cull(GL_CULL_FACE); + LLGLEnable blend(GL_BLEND); + + glh::matrix4f mat = glh_copy_matrix(gGLModelView); + + LLStrider vert; + mDeferredVB->getVertexStrider(vert); + + vert[0].set(-1,1,0); + vert[1].set(-1,-3,0); + vert[2].set(3,1,0); + + { + setupHWLights(NULL); //to set mSunDir; + LLVector4 dir(mSunDir, 0.f); + glh::vec4f tc(dir.mV); + mat.mult_matrix_vec(tc); + mTransformedSunDir.set(tc.v); + } + + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + stop_glerror(); + gGL.popMatrix(); + stop_glerror(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + stop_glerror(); + gGL.popMatrix(); + stop_glerror(); + + render_target = render_target ? render_target : &mScreen; + + llassert(render_target); + + render_target->bindTarget(); + + // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky + glClearColor(0,0,0,0); + render_target->clear(GL_COLOR_BUFFER_BIT); + + if (RenderDeferredAtmospheric) + { //apply sunlight contribution + LLFastTimer ftm(FTM_ATMOSPHERICS); + bindDeferredShader(gDeferredSoftenProgram); + { + LLGLDepthTest depth(GL_FALSE); + LLGLDisable blend(GL_BLEND); + LLGLDisable test(GL_ALPHA_TEST); + + //full screen blit + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + } + + unbindDeferredShader(gDeferredSoftenProgram); + } + + { //render non-deferred geometry (fullbright, alpha, etc) + LLGLDisable blend(GL_BLEND); + LLGLDisable stencil(GL_STENCIL_TEST); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + gPipeline.pushRenderTypeMask(); + + gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::END_RENDER_TYPES); + + + renderGeomPostDeferred(*LLViewerCamera::getInstance(), false); + gPipeline.popRenderTypeMask(); + } + + BOOL render_local = RenderLocalLights; + + if (render_local) + { + gGL.setSceneBlendType(LLRender::BT_ADD); + std::list fullscreen_lights; + LLDrawable::drawable_list_t spot_lights; + LLDrawable::drawable_list_t fullscreen_spot_lights; + + for (U32 i = 0; i < 2; i++) + { + mTargetShadowSpotLight[i] = NULL; + } + + std::list light_colors; + + LLVertexBuffer::unbind(); + + { + bindDeferredShader(gDeferredLightProgram); + + if (mCubeVB.isNull()) + { + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + } + + mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) + { + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + if (!volume) + { + continue; + } + + if (volume->isAttachment()) + { + if (!sRenderAttachedLights) + { + continue; + } + } + + + LLVector4a center; + center.load3(drawablep->getPositionAgent().mV); + const F32* c = center.getF32ptr(); + F32 s = volume->getLightRadius()*1.5f; + + LLColor3 col = volume->getLightColor(); + + if (col.magVecSquared() < 0.001f) + { + continue; + } + + if (s <= 0.001f) + { + continue; + } + + LLVector4a sa; + sa.splat(s); + if (camera->AABBInFrustumNoFarClip(center, sa) == 0) + { + continue; + } + + sVisibleLightCount++; + + if (camera->getOrigin().mV[0] > c[0] + s + 0.2f || + camera->getOrigin().mV[0] < c[0] - s - 0.2f || + camera->getOrigin().mV[1] > c[1] + s + 0.2f || + camera->getOrigin().mV[1] < c[1] - s - 0.2f || + camera->getOrigin().mV[2] > c[2] + s + 0.2f || + camera->getOrigin().mV[2] < c[2] - s - 0.2f) + { //draw box if camera is outside box + if (render_local) + { + if (volume->isLightSpotlight()) + { + drawablep->getVOVolume()->updateSpotLightPriority(); + spot_lights.push_back(drawablep); + continue; + } + + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + LLFastTimer ftm(FTM_LOCAL_LIGHTS); + gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + gGL.syncMatrices(); + + mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); + stop_glerror(); + } + } + else + { + if (volume->isLightSpotlight()) + { + drawablep->getVOVolume()->updateSpotLightPriority(); + fullscreen_spot_lights.push_back(drawablep); + continue; + } + + glh::vec3f tc(c); + mat.mult_matrix_vec(tc); + + fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s)); + light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); + } + } + unbindDeferredShader(gDeferredLightProgram); + } + + if (!spot_lights.empty()) + { + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + bindDeferredShader(gDeferredSpotLightProgram); + + mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); + + for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) + { + LLFastTimer ftm(FTM_PROJECTORS); + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + + LLVector4a center; + center.load3(drawablep->getPositionAgent().mV); + const F32* c = center.getF32ptr(); + F32 s = volume->getLightRadius()*1.5f; + + sVisibleLightCount++; + + setupSpotLight(gDeferredSpotLightProgram, drawablep); + + LLColor3 col = volume->getLightColor(); + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); + gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + gGL.syncMatrices(); + + mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); + } + gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); + unbindDeferredShader(gDeferredSpotLightProgram); + } + + //reset mDeferredVB to fullscreen triangle + mDeferredVB->getVertexStrider(vert); + vert[0].set(-1,1,0); + vert[1].set(-1,-3,0); + vert[2].set(3,1,0); + + { + bindDeferredShader(gDeferredMultiLightProgram); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + LLGLDepthTest depth(GL_FALSE); + + //full screen blit + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + U32 count = 0; + + const U32 max_count = 8; + LLVector4 light[max_count]; + LLVector4 col[max_count]; + + F32 far_z = 0.f; + + while (!fullscreen_lights.empty()) + { + LLFastTimer ftm(FTM_FULLSCREEN_LIGHTS); + light[count] = fullscreen_lights.front(); + fullscreen_lights.pop_front(); + col[count] = light_colors.front(); + light_colors.pop_front(); + + /*col[count].mV[0] = powf(col[count].mV[0], 2.2f); + col[count].mV[1] = powf(col[count].mV[1], 2.2f); + col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/ + + far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z); + //col[count] = pow4fsrgb(col[count], 2.2f); + count++; + if (count == max_count || fullscreen_lights.empty()) + { + gDeferredMultiLightProgram.uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); + gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); + gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); + gDeferredMultiLightProgram.uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); + far_z = 0.f; + count = 0; + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + } + + unbindDeferredShader(gDeferredMultiLightProgram); + + bindDeferredShader(gDeferredMultiSpotLightProgram); + + gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) + { + LLFastTimer ftm(FTM_PROJECTORS); + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + + LLVector3 center = drawablep->getPositionAgent(); + F32* c = center.mV; + F32 s = volume->getLightRadius()*1.5f; + + sVisibleLightCount++; + + glh::vec3f tc(c); + mat.mult_matrix_vec(tc); + + setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); + + LLColor3 col = volume->getLightColor(); + + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); + gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + + gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); + unbindDeferredShader(gDeferredMultiSpotLightProgram); + + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + } + } + + gGL.setColorMask(true, true); + } + + render_target->flush(); + + //gamma correct lighting + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + + { + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + LLVector2 tc1(0,0); + LLVector2 tc2((F32) render_target->getWidth()*2,(F32) render_target->getHeight()*2); + + render_target->bindTarget(); + // Apply gamma correction to the frame here. + gDeferredPostGammaCorrectProgram.bind(); + //mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + S32 channel = 0; + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, render_target->getUsage()); + if (channel > -1) + { + render_target->bindTexture(0,channel); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mScreen.getWidth(), mScreen.getHeight()); + + F32 gamma = 1.0f/1.8f; + + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, gamma); + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1,-1); + + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1,3); + + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3,-1); + + gGL.end(); + + gGL.getTexUnit(channel)->unbind(render_target->getUsage()); + gDeferredPostGammaCorrectProgram.unbind(); + render_target->flush(); + } + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + + render_target->bindTarget(); + + { //render non-deferred geometry (alpha, fullbright, glow) + LLGLDisable blend(GL_BLEND); + LLGLDisable stencil(GL_STENCIL_TEST); + + pushRenderTypeMask(); + andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_FULLBRIGHT, + LLPipeline::RENDER_TYPE_VOLUME, + LLPipeline::RENDER_TYPE_GLOW, + LLPipeline::RENDER_TYPE_BUMP, + LLPipeline::RENDER_TYPE_PASS_SIMPLE, + LLPipeline::RENDER_TYPE_PASS_ALPHA, + LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_BUMP, + LLPipeline::RENDER_TYPE_PASS_POST_BUMP, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, + LLPipeline::RENDER_TYPE_PASS_GLOW, + LLPipeline::RENDER_TYPE_PASS_GRASS, + LLPipeline::RENDER_TYPE_PASS_SHINY, + LLPipeline::RENDER_TYPE_PASS_INVISIBLE, + LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, + LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_ALPHA_MASK, + LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, + END_RENDER_TYPES); + + renderGeomPostDeferred(*LLViewerCamera::getInstance()); + popRenderTypeMask(); + } + + render_target->flush(); + +} + void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) { //construct frustum @@ -9182,22 +9671,22 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) if (LLDrawPoolWater::sNeedsReflectionUpdate) { - //initial sky pass (no user clip plane) - { //mask out everything but the sky - gPipeline.pushRenderTypeMask(); - gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::END_RENDER_TYPES); + //initial sky pass (no user clip plane) + { //mask out everything but the sky + gPipeline.pushRenderTypeMask(); + gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::END_RENDER_TYPES); - static LLCullResult result; - updateCull(camera, result); - stateSort(camera, result); + static LLCullResult result; + updateCull(camera, result); + stateSort(camera, result); renderGeom(camera, TRUE); - + gPipeline.popRenderTypeMask(); - } + } gPipeline.pushRenderTypeMask(); @@ -9279,7 +9768,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) mWaterDis.bindTarget(); LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1; mWaterDis.getViewport(gGLViewport); - + if (!LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsReflectionUpdate) { //clip out geometry on the same side of water as the camera @@ -9290,12 +9779,12 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) static LLCullResult result; updateCull(camera, result, water_clip, &plane); stateSort(camera, result); - + gGL.setColorMask(true, true); mWaterDis.clear(); gGL.setColorMask(true, false); - renderGeom(camera); + renderGeom(camera); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 70dcf80407..a8ad16b8fb 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -288,7 +288,8 @@ public: void unbindDeferredShader(LLGLSLShader& shader); void renderDeferredLighting(); - + void renderDeferredLightingToRenderTarget(LLRenderTarget* render_target); + void generateWaterReflection(LLCamera& camera); void generateSunShadow(LLCamera& camera); void generateHighlight(LLCamera& camera); -- cgit v1.2.3 From cb013b54c27257e25e429267fe0ea041a61bb6f8 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Tue, 9 Jul 2013 09:40:14 -0700 Subject: Remove failed renderDeferredLightingToRenderTarget experiment --- indra/newview/pipeline.cpp | 492 --------------------------------------------- indra/newview/pipeline.h | 2 +- 2 files changed, 1 insertion(+), 493 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index aed73be3c1..ace4417ee1 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8891,495 +8891,6 @@ void LLPipeline::renderDeferredLighting() } -void LLPipeline::renderDeferredLightingToRenderTarget(LLRenderTarget* render_target) -{ - if (!sCull) - { - return; - } - - { - LLFastTimer ftm(FTM_RENDER_DEFERRED); - - LLViewerCamera* camera = LLViewerCamera::getInstance(); - { - LLGLDepthTest depth(GL_TRUE); - mDeferredDepth.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), - 0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); - } - - LLGLEnable multisample(0); - - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); - } - - //ati doesn't seem to love actually using the stencil buffer on FBO's - LLGLDisable stencil(GL_STENCIL_TEST); - //glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); - //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - gGL.setColorMask(true, true); - - //draw a cube around every light - LLVertexBuffer::unbind(); - - LLGLEnable cull(GL_CULL_FACE); - LLGLEnable blend(GL_BLEND); - - glh::matrix4f mat = glh_copy_matrix(gGLModelView); - - LLStrider vert; - mDeferredVB->getVertexStrider(vert); - - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); - - { - setupHWLights(NULL); //to set mSunDir; - LLVector4 dir(mSunDir, 0.f); - glh::vec4f tc(dir.mV); - mat.mult_matrix_vec(tc); - mTransformedSunDir.set(tc.v); - } - - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - stop_glerror(); - gGL.popMatrix(); - stop_glerror(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - stop_glerror(); - gGL.popMatrix(); - stop_glerror(); - - render_target = render_target ? render_target : &mScreen; - - llassert(render_target); - - render_target->bindTarget(); - - // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky - glClearColor(0,0,0,0); - render_target->clear(GL_COLOR_BUFFER_BIT); - - if (RenderDeferredAtmospheric) - { //apply sunlight contribution - LLFastTimer ftm(FTM_ATMOSPHERICS); - bindDeferredShader(gDeferredSoftenProgram); - { - LLGLDepthTest depth(GL_FALSE); - LLGLDisable blend(GL_BLEND); - LLGLDisable test(GL_ALPHA_TEST); - - //full screen blit - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - } - - unbindDeferredShader(gDeferredSoftenProgram); - } - - { //render non-deferred geometry (fullbright, alpha, etc) - LLGLDisable blend(GL_BLEND); - LLGLDisable stencil(GL_STENCIL_TEST); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - gPipeline.pushRenderTypeMask(); - - gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - - - renderGeomPostDeferred(*LLViewerCamera::getInstance(), false); - gPipeline.popRenderTypeMask(); - } - - BOOL render_local = RenderLocalLights; - - if (render_local) - { - gGL.setSceneBlendType(LLRender::BT_ADD); - std::list fullscreen_lights; - LLDrawable::drawable_list_t spot_lights; - LLDrawable::drawable_list_t fullscreen_spot_lights; - - for (U32 i = 0; i < 2; i++) - { - mTargetShadowSpotLight[i] = NULL; - } - - std::list light_colors; - - LLVertexBuffer::unbind(); - - { - bindDeferredShader(gDeferredLightProgram); - - if (mCubeVB.isNull()) - { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); - } - - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) - { - LLDrawable* drawablep = *iter; - - LLVOVolume* volume = drawablep->getVOVolume(); - if (!volume) - { - continue; - } - - if (volume->isAttachment()) - { - if (!sRenderAttachedLights) - { - continue; - } - } - - - LLVector4a center; - center.load3(drawablep->getPositionAgent().mV); - const F32* c = center.getF32ptr(); - F32 s = volume->getLightRadius()*1.5f; - - LLColor3 col = volume->getLightColor(); - - if (col.magVecSquared() < 0.001f) - { - continue; - } - - if (s <= 0.001f) - { - continue; - } - - LLVector4a sa; - sa.splat(s); - if (camera->AABBInFrustumNoFarClip(center, sa) == 0) - { - continue; - } - - sVisibleLightCount++; - - if (camera->getOrigin().mV[0] > c[0] + s + 0.2f || - camera->getOrigin().mV[0] < c[0] - s - 0.2f || - camera->getOrigin().mV[1] > c[1] + s + 0.2f || - camera->getOrigin().mV[1] < c[1] - s - 0.2f || - camera->getOrigin().mV[2] > c[2] + s + 0.2f || - camera->getOrigin().mV[2] < c[2] - s - 0.2f) - { //draw box if camera is outside box - if (render_local) - { - if (volume->isLightSpotlight()) - { - drawablep->getVOVolume()->updateSpotLightPriority(); - spot_lights.push_back(drawablep); - continue; - } - - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - LLFastTimer ftm(FTM_LOCAL_LIGHTS); - gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - gGL.syncMatrices(); - - mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); - stop_glerror(); - } - } - else - { - if (volume->isLightSpotlight()) - { - drawablep->getVOVolume()->updateSpotLightPriority(); - fullscreen_spot_lights.push_back(drawablep); - continue; - } - - glh::vec3f tc(c); - mat.mult_matrix_vec(tc); - - fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s)); - light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); - } - } - unbindDeferredShader(gDeferredLightProgram); - } - - if (!spot_lights.empty()) - { - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - bindDeferredShader(gDeferredSpotLightProgram); - - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); - - for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) - { - LLFastTimer ftm(FTM_PROJECTORS); - LLDrawable* drawablep = *iter; - - LLVOVolume* volume = drawablep->getVOVolume(); - - LLVector4a center; - center.load3(drawablep->getPositionAgent().mV); - const F32* c = center.getF32ptr(); - F32 s = volume->getLightRadius()*1.5f; - - sVisibleLightCount++; - - setupSpotLight(gDeferredSpotLightProgram, drawablep); - - LLColor3 col = volume->getLightColor(); - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); - gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - gGL.syncMatrices(); - - mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); - } - gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); - unbindDeferredShader(gDeferredSpotLightProgram); - } - - //reset mDeferredVB to fullscreen triangle - mDeferredVB->getVertexStrider(vert); - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); - - { - bindDeferredShader(gDeferredMultiLightProgram); - - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - LLGLDepthTest depth(GL_FALSE); - - //full screen blit - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - U32 count = 0; - - const U32 max_count = 8; - LLVector4 light[max_count]; - LLVector4 col[max_count]; - - F32 far_z = 0.f; - - while (!fullscreen_lights.empty()) - { - LLFastTimer ftm(FTM_FULLSCREEN_LIGHTS); - light[count] = fullscreen_lights.front(); - fullscreen_lights.pop_front(); - col[count] = light_colors.front(); - light_colors.pop_front(); - - /*col[count].mV[0] = powf(col[count].mV[0], 2.2f); - col[count].mV[1] = powf(col[count].mV[1], 2.2f); - col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/ - - far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z); - //col[count] = pow4fsrgb(col[count], 2.2f); - count++; - if (count == max_count || fullscreen_lights.empty()) - { - gDeferredMultiLightProgram.uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); - gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); - gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); - gDeferredMultiLightProgram.uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); - far_z = 0.f; - count = 0; - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - } - - unbindDeferredShader(gDeferredMultiLightProgram); - - bindDeferredShader(gDeferredMultiSpotLightProgram); - - gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); - - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) - { - LLFastTimer ftm(FTM_PROJECTORS); - LLDrawable* drawablep = *iter; - - LLVOVolume* volume = drawablep->getVOVolume(); - - LLVector3 center = drawablep->getPositionAgent(); - F32* c = center.mV; - F32 s = volume->getLightRadius()*1.5f; - - sVisibleLightCount++; - - glh::vec3f tc(c); - mat.mult_matrix_vec(tc); - - setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); - - LLColor3 col = volume->getLightColor(); - - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); - gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - - gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); - unbindDeferredShader(gDeferredMultiSpotLightProgram); - - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - } - } - - gGL.setColorMask(true, true); - } - - render_target->flush(); - - //gamma correct lighting - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); - - { - LLGLDepthTest depth(GL_FALSE, GL_FALSE); - - LLVector2 tc1(0,0); - LLVector2 tc2((F32) render_target->getWidth()*2,(F32) render_target->getHeight()*2); - - render_target->bindTarget(); - // Apply gamma correction to the frame here. - gDeferredPostGammaCorrectProgram.bind(); - //mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - S32 channel = 0; - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, render_target->getUsage()); - if (channel > -1) - { - render_target->bindTexture(0,channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - - gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mScreen.getWidth(), mScreen.getHeight()); - - F32 gamma = 1.0f/1.8f; - - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, gamma); - - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1,-1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1,3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3,-1); - - gGL.end(); - - gGL.getTexUnit(channel)->unbind(render_target->getUsage()); - gDeferredPostGammaCorrectProgram.unbind(); - render_target->flush(); - } - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - - render_target->bindTarget(); - - { //render non-deferred geometry (alpha, fullbright, glow) - LLGLDisable blend(GL_BLEND); - LLGLDisable stencil(GL_STENCIL_TEST); - - pushRenderTypeMask(); - andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, - LLPipeline::RENDER_TYPE_FULLBRIGHT, - LLPipeline::RENDER_TYPE_VOLUME, - LLPipeline::RENDER_TYPE_GLOW, - LLPipeline::RENDER_TYPE_BUMP, - LLPipeline::RENDER_TYPE_PASS_SIMPLE, - LLPipeline::RENDER_TYPE_PASS_ALPHA, - LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_BUMP, - LLPipeline::RENDER_TYPE_PASS_POST_BUMP, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, - LLPipeline::RENDER_TYPE_PASS_GLOW, - LLPipeline::RENDER_TYPE_PASS_GRASS, - LLPipeline::RENDER_TYPE_PASS_SHINY, - LLPipeline::RENDER_TYPE_PASS_INVISIBLE, - LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, - LLPipeline::RENDER_TYPE_AVATAR, - LLPipeline::RENDER_TYPE_ALPHA_MASK, - LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, - END_RENDER_TYPES); - - renderGeomPostDeferred(*LLViewerCamera::getInstance()); - popRenderTypeMask(); - } - - render_target->flush(); - -} - void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) { //construct frustum @@ -11653,6 +11164,3 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id ) } } - - - diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index a8ad16b8fb..2f0fc3491d 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -288,7 +288,6 @@ public: void unbindDeferredShader(LLGLSLShader& shader); void renderDeferredLighting(); - void renderDeferredLightingToRenderTarget(LLRenderTarget* render_target); void generateWaterReflection(LLCamera& camera); void generateSunShadow(LLCamera& camera); @@ -955,3 +954,4 @@ extern BOOL gDebugPipeline; extern const LLMatrix4* gGLLastMatrix; #endif + -- cgit v1.2.3 From 326e20b0e5cd8e30d4b52c662a29aa2fc816b40d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Jul 2013 09:47:46 -0700 Subject: NORSPEC-291 WIP materials underwater w and wo alpha, water fog color broken, no refl, no water dis --- .../shaders/class1/deferred/materialF.glsl | 86 ++++++++++++++++--- .../shaders/class1/deferred/materialV.glsl | 9 +- .../shaders/class1/deferred/softenLightF.glsl | 54 +++++++++++- indra/newview/lldrawpoolavatar.cpp | 18 +++- indra/newview/lldrawpoolmaterials.cpp | 10 ++- indra/newview/lldrawpoolsky.cpp | 2 +- indra/newview/lldrawpoolwater.cpp | 8 +- indra/newview/lldrawpoolwlsky.cpp | 4 +- indra/newview/llviewerdisplay.cpp | 10 ++- indra/newview/llviewershadermgr.cpp | 97 +++++++++++++++++++++- indra/newview/llviewershadermgr.h | 3 + indra/newview/pipeline.cpp | 34 +++++--- 12 files changed, 293 insertions(+), 42 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 027c6eeadb..393074344b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -51,7 +51,6 @@ vec3 linear_to_srgb(vec3 cl) return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } - #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) #ifdef DEFINE_GL_FRAGCOLOR @@ -136,6 +135,57 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +#ifdef WATER_FOG +vec3 getPositionEye() +{ + return vary_PositionEye; +} + +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec4 color) +{ + //normalize view vector + vec3 view = normalize(getPositionEye()); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(getPositionEye() - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -221,10 +271,6 @@ vec4 getPosition_d(vec2 pos_screen, float depth) return pos; } -vec3 getPositionEye() -{ - return vary_PositionEye; -} vec3 getSunlitColor() { return vary_SunlitColor; @@ -417,6 +463,21 @@ out vec4 frag_data[3]; #else #define frag_data gl_FragData #endif + +VARYING vec3 vary_position; + +#ifdef WATER_FOG +vec3 vary_PositionEye; +vec3 getPositionEye() +{ + return vary_PositionEye; +} +void setPositionEye(vec3 e) +{ + vary_PositionEye = e; +} +#endif + #endif uniform sampler2D diffuseMap; @@ -672,7 +733,6 @@ void main() //convert to linear space before adding local lights col = srgb_to_linear(col); - vec3 npos = normalize(-pos.xyz); #define LIGHT_LOOP(i) col.rgb = col.rgb + calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare); @@ -685,17 +745,19 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) + glare = min(glare, 1.0); + float al = max(diffcol.a,glare)*vertex_color.a; - //convert to gamma space for display on screen - col.rgb = linear_to_srgb(col.rgb); - +#ifdef WATER_FOG + frag_color = applyWaterFogDeferred(vec4(col.rgb, al)); +#else frag_color.rgb = col.rgb; - glare = min(glare, 1.0); - frag_color.a = max(diffcol.a,glare)*vertex_color.a; + frag_color.a = al; +#endif #else frag_data[0] = final_color; frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. -#endif +#endif% } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index b25032866b..154db09583 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -43,10 +43,10 @@ uniform mat4 modelview_projection_matrix; uniform mat4 modelview_matrix; #endif -VARYING vec3 vary_position; - #endif +VARYING vec3 vary_position; + uniform mat4 texture_matrix0; ATTRIBUTE vec3 position; @@ -84,15 +84,14 @@ void main() mat = modelview_matrix * mat; vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; - -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vary_position = pos; -#endif + gl_Position = projection_matrix*vec4(pos,1.0); #else //transform vertex + vary_position = (modelview_projection_matrix * vec4(position.xyz, 1.0)).xyz; gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index dc2519bd0a..1706d41da0 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -175,6 +175,53 @@ void setAtmosAttenuation(vec3 v) vary_AtmosAttenuation = v; } + +#ifdef WATER_FOG +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec4 color) +{ + //normalize view vector + vec3 view = normalize(getPositionEye()); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(getPositionEye() - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + void calcAtmospherics(vec3 inPositionEye, float ambFactor) { vec3 P = inPositionEye; @@ -389,6 +436,12 @@ void main() { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + + #ifdef WATER_FOG + vec4 fogged = applyWaterFogDeferred(vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif } col = srgb_to_linear(col); @@ -398,6 +451,5 @@ void main() } frag_color.rgb = col; - frag_color.a = bloom; } diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 075299386e..45abb87bad 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -297,7 +297,14 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterialAlpha(S32 pass) pass += LLMaterial::SHADER_COUNT; - sVertexProgram = &gDeferredMaterialProgram[pass]; + if (LLPipeline::sUnderWaterRender) + { + sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); + } + else + { + sVertexProgram = &(gDeferredMaterialProgram[pass]); + } gPipeline.bindDeferredShader(*sVertexProgram); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -1092,7 +1099,14 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterial(S32 pass) { //skip alpha passes return; } - sVertexProgram = &gDeferredMaterialProgram[pass+LLMaterial::SHADER_COUNT]; + if (LLPipeline::sUnderWaterRender) + { + sVertexProgram = &gDeferredMaterialWaterProgram[pass+LLMaterial::SHADER_COUNT]; + } + else + { + sVertexProgram = &gDeferredMaterialProgram[pass+LLMaterial::SHADER_COUNT]; + } sVertexProgram->bind(); normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP); specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index 08a36bddf1..49619e6b1d 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -71,7 +71,15 @@ void LLDrawPoolMaterials::beginDeferredPass(S32 pass) 15, //LLRenderPass::PASS_NORMSPEC_GLOW, }; - mShader = &(gDeferredMaterialProgram[shader_idx[pass]]); + if (LLPipeline::sUnderWaterRender) + { + mShader = &(gDeferredMaterialWaterProgram[shader_idx[pass]]); + } + else + { + mShader = &(gDeferredMaterialProgram[shader_idx[pass]]); + } + mShader->bind(); diffuse_channel = mShader->enableTexture(LLShaderMgr::DIFFUSE_MAP); diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 7f7d9f65c6..d36b9ace94 100755 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -77,7 +77,7 @@ void LLDrawPoolSky::render(S32 pass) } // don't render sky under water (background just gets cleared to fog color) - if(mVertexShaderLevel > 0 && LLPipeline::sUnderWaterRender) + if(mVertexShaderLevel > 0 /*&& !LLPipeline::sRenderDeferred*/ && LLPipeline::sUnderWaterRender) { return; } diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 5ddc15df42..5b0b173926 100755 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -522,13 +522,13 @@ void LLDrawPoolWater::shade() F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight(); - if (deferred_render) + if (eyedepth < 0.f && LLPipeline::sWaterReflections) { - shader = &gDeferredWaterProgram; + shader = &gUnderWaterProgram; } - else if (eyedepth < 0.f && LLPipeline::sWaterReflections) + else if (deferred_render) { - shader = &gUnderWaterProgram; + shader = &gDeferredWaterProgram; } else { diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index b5faff7968..56b58aaeb4 100755 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -99,12 +99,12 @@ LLViewerTexture *LLDrawPoolWLSky::getDebugTexture() void LLDrawPoolWLSky::beginRenderPass( S32 pass ) { sky_shader = - LLPipeline::sUnderWaterRender ? + (LLPipeline::sUnderWaterRender /*&& !LLPipeline::sRenderDeferred*/) ? &gObjectFullbrightNoColorWaterProgram : &gWLSkyProgram; cloud_shader = - LLPipeline::sUnderWaterRender ? + (LLPipeline::sUnderWaterRender /*&& !LLPipeline::sRenderDeferred*/) ? &gObjectFullbrightNoColorWaterProgram : &gWLCloudProgram; } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index e6718ca618..d9fd171b4e 100755 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -893,7 +893,15 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.bindTarget(); - glClearColor(1,0,1,1); + if (LLPipeline::sUnderWaterRender) + { + const LLColor4 &col = LLDrawPoolWater::sWaterFogColor; + glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); + } + else + { + glClearColor(1,0,1,1); + } gPipeline.mDeferredScreen.clear(); } else diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 6d9a0dd261..88593346c0 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -168,6 +168,7 @@ LLGLSLShader gPostNightVisionProgram; // Deferred rendering shaders LLGLSLShader gDeferredImpostorProgram; LLGLSLShader gDeferredWaterProgram; +LLGLSLShader gDeferredUnderWaterProgram; LLGLSLShader gDeferredDiffuseProgram; LLGLSLShader gDeferredDiffuseAlphaMaskProgram; LLGLSLShader gDeferredNonIndexedDiffuseProgram; @@ -189,6 +190,7 @@ LLGLSLShader gDeferredMultiSpotLightProgram; LLGLSLShader gDeferredSunProgram; LLGLSLShader gDeferredBlurLightProgram; LLGLSLShader gDeferredSoftenProgram; +LLGLSLShader gDeferredSoftenWaterProgram; LLGLSLShader gDeferredShadowProgram; LLGLSLShader gDeferredShadowCubeProgram; LLGLSLShader gDeferredShadowAlphaMaskProgram; @@ -215,6 +217,7 @@ LLGLSLShader gNormalMapGenProgram; // Deferred materials shaders LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; +LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; LLViewerShaderMgr::LLViewerShaderMgr() : mVertexShaderLevel(SHADER_COUNT, 0), @@ -280,14 +283,23 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gUnderWaterProgram); mShaderList.push_back(&gDeferredSunProgram); mShaderList.push_back(&gDeferredSoftenProgram); + mShaderList.push_back(&gDeferredSoftenWaterProgram); mShaderList.push_back(&gDeferredMaterialProgram[1]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[1]); mShaderList.push_back(&gDeferredMaterialProgram[5]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[5]); mShaderList.push_back(&gDeferredMaterialProgram[9]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[9]); mShaderList.push_back(&gDeferredMaterialProgram[13]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[13]); mShaderList.push_back(&gDeferredMaterialProgram[1+LLMaterial::SHADER_COUNT]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredMaterialProgram[5+LLMaterial::SHADER_COUNT]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredAlphaProgram); mShaderList.push_back(&gDeferredSkinnedAlphaProgram); mShaderList.push_back(&gDeferredFullbrightProgram); @@ -1123,6 +1135,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSunProgram.unload(); gDeferredBlurLightProgram.unload(); gDeferredSoftenProgram.unload(); + gDeferredSoftenWaterProgram.unload(); gDeferredShadowProgram.unload(); gDeferredShadowCubeProgram.unload(); gDeferredShadowAlphaMaskProgram.unload(); @@ -1141,6 +1154,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPostGammaCorrectProgram.unload(); gFXAAProgram.unload(); gDeferredWaterProgram.unload(); + gDeferredUnderWaterProgram.unload(); gDeferredWLSkyProgram.unload(); gDeferredWLCloudProgram.unload(); gDeferredStarProgram.unload(); @@ -1152,6 +1166,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() for (U32 i = 0; i < LLMaterial::SHADER_COUNT*2; ++i) { gDeferredMaterialProgram[i].unload(); + gDeferredMaterialWaterProgram[i].unload(); } return TRUE; } @@ -1279,6 +1294,15 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false; gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false; + gDeferredMaterialWaterProgram[1].mFeatures.hasLighting = false; + gDeferredMaterialWaterProgram[5].mFeatures.hasLighting = false; + gDeferredMaterialWaterProgram[9].mFeatures.hasLighting = false; + gDeferredMaterialWaterProgram[13].mFeatures.hasLighting = false; + gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false; + gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false; + gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false; + gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false; + for (U32 i = 0; i < LLMaterial::SHADER_COUNT*2; ++i) { if (success) @@ -1305,6 +1329,35 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredMaterialProgram[i].createShader(NULL, NULL); } + + if (success) + { + gDeferredMaterialProgram[i].mName = llformat("Deferred Material Shader %d", i); + + U32 alpha_mode = i & 0x3; + + gDeferredMaterialWaterProgram[i].mShaderFiles.clear(); + gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredMaterialWaterProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredMaterialWaterProgram[i].addPermutation("HAS_NORMAL_MAP", i & 0x8? "1" : "0"); + gDeferredMaterialWaterProgram[i].addPermutation("HAS_SPECULAR_MAP", i & 0x4 ? "1" : "0"); + gDeferredMaterialWaterProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); + gDeferredMaterialWaterProgram[i].addPermutation("HAS_SUN_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); + bool has_skin = i & 0x10; + gDeferredMaterialWaterProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0"); + + gDeferredMaterialWaterProgram[i].addPermutation("WATER_FOG","1"); + gDeferredMaterialWaterProgram[i].mFeatures.hasWaterFog = true; + gDeferredMaterialWaterProgram[i].mShaderGroup = SHADER_WATER; + + if (has_skin) + { + gDeferredMaterialWaterProgram[i].mFeatures.hasObjectSkinning = true; + } + + success = gDeferredMaterialWaterProgram[i].createShader(NULL, NULL); + } } gDeferredMaterialProgram[1].mFeatures.hasLighting = true; @@ -1316,7 +1369,14 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; - + gDeferredMaterialWaterProgram[1].mFeatures.hasLighting = true; + gDeferredMaterialWaterProgram[5].mFeatures.hasLighting = true; + gDeferredMaterialWaterProgram[9].mFeatures.hasLighting = true; + gDeferredMaterialWaterProgram[13].mFeatures.hasLighting = true; + gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; + gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; + gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; + gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; if (success) { @@ -1582,6 +1642,21 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredWaterProgram.createShader(NULL, &mWaterUniforms); } + if (success) + { + // load water shader + /*gDeferredUnderWaterProgram.mName = "Deferred Under Water Shader"; + gDeferredUnderWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredUnderWaterProgram.mFeatures.hasGamma = true; + gDeferredUnderWaterProgram.mShaderFiles.clear(); + gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/underWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredUnderWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER]; + gDeferredUnderWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + + success = gDeferredUnderWaterProgram.createShader(NULL, &mWaterUniforms);*/ + } + if (success) { gDeferredSoftenProgram.mName = "Deferred Soften Shader"; @@ -1599,6 +1674,26 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredSoftenProgram.createShader(NULL, NULL); } + if (success) + { + gDeferredSoftenWaterProgram.mName = "Deferred Soften Underwater Shader"; + gDeferredSoftenWaterProgram.mFeatures.hasWaterFog = true; + gDeferredSoftenWaterProgram.mShaderFiles.clear(); + gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); + + gDeferredSoftenWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredSoftenWaterProgram.addPermutation("WATER_FOG", "1"); + gDeferredSoftenWaterProgram.mShaderGroup = SHADER_WATER; + + if (gSavedSettings.getBOOL("RenderDeferredSSAO")) + { //if using SSAO, take screen space light map into account as if shadows are enabled + gDeferredSoftenWaterProgram.mShaderLevel = llmax(gDeferredSoftenWaterProgram.mShaderLevel, 2); + } + + success = gDeferredSoftenWaterProgram.createShader(NULL, NULL); + } + if (success) { gDeferredShadowProgram.mName = "Deferred Shadow Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index f3a419b1f2..34a0f6b89d 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -330,6 +330,7 @@ extern LLGLSLShader gPostNightVisionProgram; // Deferred rendering shaders extern LLGLSLShader gDeferredImpostorProgram; extern LLGLSLShader gDeferredWaterProgram; +extern LLGLSLShader gDeferredUnderWaterProgram; extern LLGLSLShader gDeferredDiffuseProgram; extern LLGLSLShader gDeferredDiffuseAlphaMaskProgram; extern LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskProgram; @@ -350,6 +351,7 @@ extern LLGLSLShader gDeferredSunProgram; extern LLGLSLShader gDeferredBlurLightProgram; extern LLGLSLShader gDeferredAvatarProgram; extern LLGLSLShader gDeferredSoftenProgram; +extern LLGLSLShader gDeferredSoftenWaterProgram; extern LLGLSLShader gDeferredShadowProgram; extern LLGLSLShader gDeferredShadowCubeProgram; extern LLGLSLShader gDeferredShadowAlphaMaskProgram; @@ -377,5 +379,6 @@ extern LLGLSLShader gNormalMapGenProgram; // Deferred materials shaders extern LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; +extern LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; #endif diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index aed73be3c1..e9fb94239e 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8466,7 +8466,7 @@ void LLPipeline::renderDeferredLighting() if (RenderDeferredAtmospheric) { //apply sunlight contribution LLFastTimer ftm(FTM_ATMOSPHERICS); - bindDeferredShader(gDeferredSoftenProgram); + bindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -8488,7 +8488,7 @@ void LLPipeline::renderDeferredLighting() gGL.popMatrix(); } - unbindDeferredShader(gDeferredSoftenProgram); + unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); } { //render non-deferred geometry (fullbright, alpha, etc) @@ -8725,9 +8725,11 @@ void LLPipeline::renderDeferredLighting() count = 0; mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); +// seems like this should be done here... + //unbindDeferredShader(gDeferredMultiLightProgram[idx]); } } - + unbindDeferredShader(gDeferredMultiLightProgram[0]); bindDeferredShader(gDeferredMultiSpotLightProgram); @@ -8972,7 +8974,7 @@ void LLPipeline::renderDeferredLightingToRenderTarget(LLRenderTarget* render_tar if (RenderDeferredAtmospheric) { //apply sunlight contribution LLFastTimer ftm(FTM_ATMOSPHERICS); - bindDeferredShader(gDeferredSoftenProgram); + bindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -8994,7 +8996,7 @@ void LLPipeline::renderDeferredLightingToRenderTarget(LLRenderTarget* render_tar gGL.popMatrix(); } - unbindDeferredShader(gDeferredSoftenProgram); + unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); } { //render non-deferred geometry (fullbright, alpha, etc) @@ -9187,7 +9189,7 @@ void LLPipeline::renderDeferredLightingToRenderTarget(LLRenderTarget* render_tar vert[2].set(3,1,0); { - bindDeferredShader(gDeferredMultiLightProgram); + bindDeferredShader(gDeferredMultiLightProgram[0]); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -9225,17 +9227,25 @@ void LLPipeline::renderDeferredLightingToRenderTarget(LLRenderTarget* render_tar count++; if (count == max_count || fullscreen_lights.empty()) { - gDeferredMultiLightProgram.uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); - gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); - gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); - gDeferredMultiLightProgram.uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); + U32 idx = count-1; + bindDeferredShader(gDeferredMultiLightProgram[idx]); + + gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); + gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; count = 0; + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + // This "seems necessary"...ask davep if it's automagical + // + //unbindDeferredShader(gDeferredMultiLightProgram[idx]); } } - - unbindDeferredShader(gDeferredMultiLightProgram); + + unbindDeferredShader(gDeferredMultiLightProgram[0]); bindDeferredShader(gDeferredMultiSpotLightProgram); -- cgit v1.2.3 From fbf3d8b78137a5229ccfabd1e42a0712d92b061f Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 11 Jul 2013 16:21:23 -0700 Subject: NORSPEC-291 WIP materials underwater with haze, reflection broken, water dist broken --- .../shaders/class1/deferred/materialF.glsl | 37 +++++----------- .../shaders/class1/deferred/materialV.glsl | 1 + .../shaders/class1/deferred/softenLightF.glsl | 15 ++++--- .../shaders/class2/deferred/softenLightF.glsl | 9 ++++ indra/newview/lldrawpoolalpha.cpp | 6 +++ indra/newview/lldrawpoolavatar.cpp | 15 +++---- indra/newview/lldrawpoolmaterials.cpp | 9 ++-- indra/newview/lldrawpoolsky.cpp | 3 +- indra/newview/lldrawpoolwlsky.cpp | 5 ++- indra/newview/llviewerdisplay.cpp | 11 +---- indra/newview/llviewershadermgr.cpp | 50 ++++++++-------------- indra/newview/llviewershadermgr.h | 3 +- indra/newview/pipeline.cpp | 2 - 13 files changed, 70 insertions(+), 96 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 393074344b..9ce4d89df7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -136,20 +136,15 @@ uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; #ifdef WATER_FOG -vec3 getPositionEye() -{ - return vary_PositionEye; -} - uniform vec4 waterPlane; uniform vec4 waterFogColor; uniform float waterFogDensity; uniform float waterFogKS; -vec4 applyWaterFogDeferred(vec4 color) +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) { //normalize view vector - vec3 view = normalize(getPositionEye()); + vec3 view = normalize(pos); float es = -(dot(view, waterPlane.xyz)); //find intersection point with water plane and eye vector @@ -160,7 +155,7 @@ vec4 applyWaterFogDeferred(vec4 color) vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); //get object depth - float depth = length(getPositionEye() - int_v); + float depth = length(pos - int_v); //get "thickness" of water float l = max(depth, 0.1); @@ -463,21 +458,6 @@ out vec4 frag_data[3]; #else #define frag_data gl_FragData #endif - -VARYING vec3 vary_position; - -#ifdef WATER_FOG -vec3 vary_PositionEye; -vec3 getPositionEye() -{ - return vary_PositionEye; -} -void setPositionEye(vec3 e) -{ - vary_PositionEye = e; -} -#endif - #endif uniform sampler2D diffuseMap; @@ -749,15 +729,18 @@ void main() float al = max(diffcol.a,glare)*vertex_color.a; #ifdef WATER_FOG - frag_color = applyWaterFogDeferred(vec4(col.rgb, al)); -#else + vec4 temp = applyWaterFogDeferred(pos, vec4(col.rgb, al)); + col.rgb = temp.rgb; + al = temp.a; +#endif + frag_color.rgb = col.rgb; frag_color.a = al; -#endif #else frag_data[0] = final_color; frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. -#endif% +#endif } + diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index 154db09583..e44a6fcec8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -141,3 +141,4 @@ vary_normal = n; #endif #endif } + diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 1706d41da0..953f0189f0 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -133,6 +133,7 @@ vec3 getPositionEye() { return vary_PositionEye; } + vec3 getSunlitColor() { return vary_SunlitColor; @@ -182,10 +183,10 @@ uniform vec4 waterFogColor; uniform float waterFogDensity; uniform float waterFogKS; -vec4 applyWaterFogDeferred(vec4 color) +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) { //normalize view vector - vec3 view = normalize(getPositionEye()); + vec3 view = normalize(pos); float es = -(dot(view, waterPlane.xyz)); //find intersection point with water plane and eye vector @@ -196,7 +197,7 @@ vec4 applyWaterFogDeferred(vec4 color) vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); //get object depth - float depth = length(getPositionEye() - int_v); + float depth = length(pos - int_v); //get "thickness" of water float l = max(depth, 0.1); @@ -435,13 +436,14 @@ void main() if (norm.w < 0.5) { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); #ifdef WATER_FOG - vec4 fogged = applyWaterFogDeferred(vec4(col, bloom)); + vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); col = fogged.rgb; bloom = fogged.a; #endif + + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } col = srgb_to_linear(col); @@ -450,6 +452,7 @@ void main() //col.g = envIntensity; } - frag_color.rgb = col; + frag_color.rgb = col.rgb; frag_color.a = bloom; } + diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 06447261b4..4464358b1e 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -133,6 +133,13 @@ vec4 getPosition(vec2 pos_screen) return getPosition_d(pos_screen, depth); } +#ifdef WATER_FOG +vec3 getPositionEye(); +vec3 getSunlitColor(); +vec3 getAmblitColor(); +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); +#else vec3 getPositionEye() { return vary_PositionEye; @@ -153,6 +160,7 @@ vec3 getAtmosAttenuation() { return vary_AtmosAttenuation; } +#endif void setPositionEye(vec3 v) { @@ -421,3 +429,4 @@ void main() frag_color.rgb = col; frag_color.a = bloom; } + diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 737da2e209..e53c783161 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -405,6 +405,11 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) llassert(mask < LLMaterial::SHADER_COUNT); target_shader = &(gDeferredMaterialProgram[mask]); + if (LLPipeline::sUnderWaterRender) + { + target_shader = &(gDeferredMaterialWaterProgram[mask]); + } + if (current_shader != target_shader) { gPipeline.bindDeferredShader(*target_shader); @@ -554,3 +559,4 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) gPipeline.enableLightsDynamic(); } } + diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 45abb87bad..3815548dba 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -297,14 +297,12 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterialAlpha(S32 pass) pass += LLMaterial::SHADER_COUNT; + sVertexProgram = &gDeferredMaterialProgram[pass]; + if (LLPipeline::sUnderWaterRender) { sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); } - else - { - sVertexProgram = &(gDeferredMaterialProgram[pass]); - } gPipeline.bindDeferredShader(*sVertexProgram); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -1099,14 +1097,13 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterial(S32 pass) { //skip alpha passes return; } + sVertexProgram = &gDeferredMaterialProgram[pass+LLMaterial::SHADER_COUNT]; + if (LLPipeline::sUnderWaterRender) { - sVertexProgram = &gDeferredMaterialWaterProgram[pass+LLMaterial::SHADER_COUNT]; - } - else - { - sVertexProgram = &gDeferredMaterialProgram[pass+LLMaterial::SHADER_COUNT]; + sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); } + sVertexProgram->bind(); normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP); specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index 49619e6b1d..d1b5080650 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -71,15 +71,13 @@ void LLDrawPoolMaterials::beginDeferredPass(S32 pass) 15, //LLRenderPass::PASS_NORMSPEC_GLOW, }; + mShader = &(gDeferredMaterialProgram[shader_idx[pass]]); + if (LLPipeline::sUnderWaterRender) { mShader = &(gDeferredMaterialWaterProgram[shader_idx[pass]]); } - else - { - mShader = &(gDeferredMaterialProgram[shader_idx[pass]]); - } - + mShader->bind(); diffuse_channel = mShader->enableTexture(LLShaderMgr::DIFFUSE_MAP); @@ -223,3 +221,4 @@ void LLDrawPoolMaterials::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, gGL.matrixMode(LLRender::MM_MODELVIEW); } } + diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index d36b9ace94..ef8bdc3304 100755 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -77,7 +77,7 @@ void LLDrawPoolSky::render(S32 pass) } // don't render sky under water (background just gets cleared to fog color) - if(mVertexShaderLevel > 0 /*&& !LLPipeline::sRenderDeferred*/ && LLPipeline::sUnderWaterRender) + if(mVertexShaderLevel > 0 && LLPipeline::sUnderWaterRender) { return; } @@ -155,3 +155,4 @@ void LLDrawPoolSky::renderSkyCubeFace(U8 side) void LLDrawPoolSky::endRenderPass( S32 pass ) { } + diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 56b58aaeb4..53339222eb 100755 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -99,12 +99,12 @@ LLViewerTexture *LLDrawPoolWLSky::getDebugTexture() void LLDrawPoolWLSky::beginRenderPass( S32 pass ) { sky_shader = - (LLPipeline::sUnderWaterRender /*&& !LLPipeline::sRenderDeferred*/) ? + LLPipeline::sUnderWaterRender ? &gObjectFullbrightNoColorWaterProgram : &gWLSkyProgram; cloud_shader = - (LLPipeline::sUnderWaterRender /*&& !LLPipeline::sRenderDeferred*/) ? + LLPipeline::sUnderWaterRender ? &gObjectFullbrightNoColorWaterProgram : &gWLCloudProgram; } @@ -420,3 +420,4 @@ void LLDrawPoolWLSky::restoreGL() sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); } } + diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index d9fd171b4e..bbebeea3e0 100755 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -893,15 +893,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.bindTarget(); - if (LLPipeline::sUnderWaterRender) - { - const LLColor4 &col = LLDrawPoolWater::sWaterFogColor; - glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); - } - else - { - glClearColor(1,0,1,1); - } + glClearColor(1,0,1,1); gPipeline.mDeferredScreen.clear(); } else @@ -1631,3 +1623,4 @@ void display_cleanup() { gDisconnectedImagep = NULL; } + diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 88593346c0..3df8115402 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -168,7 +168,6 @@ LLGLSLShader gPostNightVisionProgram; // Deferred rendering shaders LLGLSLShader gDeferredImpostorProgram; LLGLSLShader gDeferredWaterProgram; -LLGLSLShader gDeferredUnderWaterProgram; LLGLSLShader gDeferredDiffuseProgram; LLGLSLShader gDeferredDiffuseAlphaMaskProgram; LLGLSLShader gDeferredNonIndexedDiffuseProgram; @@ -285,21 +284,21 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredSoftenProgram); mShaderList.push_back(&gDeferredSoftenWaterProgram); mShaderList.push_back(&gDeferredMaterialProgram[1]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[1]); mShaderList.push_back(&gDeferredMaterialProgram[5]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[5]); mShaderList.push_back(&gDeferredMaterialProgram[9]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[9]); mShaderList.push_back(&gDeferredMaterialProgram[13]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[13]); mShaderList.push_back(&gDeferredMaterialProgram[1+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredMaterialProgram[5+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[1]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[5]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[9]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[13]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT]); + mShaderList.push_back(&gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredAlphaProgram); mShaderList.push_back(&gDeferredSkinnedAlphaProgram); mShaderList.push_back(&gDeferredFullbrightProgram); @@ -1154,7 +1153,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPostGammaCorrectProgram.unload(); gFXAAProgram.unload(); gDeferredWaterProgram.unload(); - gDeferredUnderWaterProgram.unload(); gDeferredWLSkyProgram.unload(); gDeferredWLCloudProgram.unload(); gDeferredStarProgram.unload(); @@ -1332,7 +1330,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { - gDeferredMaterialProgram[i].mName = llformat("Deferred Material Shader %d", i); + gDeferredMaterialWaterProgram[i].mName = llformat("Deferred Underwater Material Shader %d", i); U32 alpha_mode = i & 0x3; @@ -1340,23 +1338,22 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMaterialWaterProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredMaterialWaterProgram[i].mShaderGroup = LLGLSLShader::SG_WATER; + gDeferredMaterialWaterProgram[i].addPermutation("HAS_NORMAL_MAP", i & 0x8? "1" : "0"); gDeferredMaterialWaterProgram[i].addPermutation("HAS_SPECULAR_MAP", i & 0x4 ? "1" : "0"); gDeferredMaterialWaterProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); gDeferredMaterialWaterProgram[i].addPermutation("HAS_SUN_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); bool has_skin = i & 0x10; gDeferredMaterialWaterProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0"); - gDeferredMaterialWaterProgram[i].addPermutation("WATER_FOG","1"); - gDeferredMaterialWaterProgram[i].mFeatures.hasWaterFog = true; - gDeferredMaterialWaterProgram[i].mShaderGroup = SHADER_WATER; if (has_skin) { gDeferredMaterialWaterProgram[i].mFeatures.hasObjectSkinning = true; } - success = gDeferredMaterialWaterProgram[i].createShader(NULL, NULL); + success = gDeferredMaterialWaterProgram[i].createShader(NULL, NULL);//&mWLUniforms); } } @@ -1377,6 +1374,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true; + if (success) { @@ -1642,21 +1640,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredWaterProgram.createShader(NULL, &mWaterUniforms); } - if (success) - { - // load water shader - /*gDeferredUnderWaterProgram.mName = "Deferred Under Water Shader"; - gDeferredUnderWaterProgram.mFeatures.calculatesAtmospherics = true; - gDeferredUnderWaterProgram.mFeatures.hasGamma = true; - gDeferredUnderWaterProgram.mShaderFiles.clear(); - gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/underWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredUnderWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER]; - gDeferredUnderWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - - success = gDeferredUnderWaterProgram.createShader(NULL, &mWaterUniforms);*/ - } - if (success) { gDeferredSoftenProgram.mName = "Deferred Soften Shader"; @@ -1677,21 +1660,21 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredSoftenWaterProgram.mName = "Deferred Soften Underwater Shader"; - gDeferredSoftenWaterProgram.mFeatures.hasWaterFog = true; gDeferredSoftenWaterProgram.mShaderFiles.clear(); + gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredSoftenWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredSoftenWaterProgram.addPermutation("WATER_FOG", "1"); - gDeferredSoftenWaterProgram.mShaderGroup = SHADER_WATER; + gDeferredSoftenWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; if (gSavedSettings.getBOOL("RenderDeferredSSAO")) { //if using SSAO, take screen space light map into account as if shadows are enabled gDeferredSoftenWaterProgram.mShaderLevel = llmax(gDeferredSoftenWaterProgram.mShaderLevel, 2); } - success = gDeferredSoftenWaterProgram.createShader(NULL, NULL); + success = gDeferredSoftenWaterProgram.createShader(NULL, &mWLUniforms); } if (success) @@ -3275,3 +3258,4 @@ LLViewerShaderMgr::shader_iter LLViewerShaderMgr::endShaders() const { return mShaderList.end(); } + diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 34a0f6b89d..5310076013 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -330,7 +330,6 @@ extern LLGLSLShader gPostNightVisionProgram; // Deferred rendering shaders extern LLGLSLShader gDeferredImpostorProgram; extern LLGLSLShader gDeferredWaterProgram; -extern LLGLSLShader gDeferredUnderWaterProgram; extern LLGLSLShader gDeferredDiffuseProgram; extern LLGLSLShader gDeferredDiffuseAlphaMaskProgram; extern LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskProgram; @@ -380,5 +379,5 @@ extern LLGLSLShader gNormalMapGenProgram; // Deferred materials shaders extern LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; extern LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; - #endif + diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a44cc73678..c605735170 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8725,8 +8725,6 @@ void LLPipeline::renderDeferredLighting() count = 0; mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); -// seems like this should be done here... - //unbindDeferredShader(gDeferredMultiLightProgram[idx]); } } -- cgit v1.2.3 From e9cdd0bfe8fe7f3bec0e6db7fba43e11f729af8a Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 11 Jul 2013 16:39:39 -0700 Subject: NORSPEC-291 WIP fix avatar disappearing --- .../app_settings/shaders/class1/deferred/materialV.glsl | 9 +++++---- .../shaders/class2/deferred/softenLightF.glsl | 8 -------- indra/newview/lldrawpoolavatar.cpp | 16 ++++++++-------- 3 files changed, 13 insertions(+), 20 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index e44a6fcec8..393d1e69da 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -43,10 +43,10 @@ uniform mat4 modelview_projection_matrix; uniform mat4 modelview_matrix; #endif -#endif - VARYING vec3 vary_position; +#endif + uniform mat4 texture_matrix0; ATTRIBUTE vec3 position; @@ -84,14 +84,15 @@ void main() mat = modelview_matrix * mat; vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; - vary_position = pos; +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + vary_position = pos; +#endif gl_Position = projection_matrix*vec4(pos,1.0); #else //transform vertex - vary_position = (modelview_projection_matrix * vec4(position.xyz, 1.0)).xyz; gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); #endif diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 4464358b1e..08aaa2237d 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -133,13 +133,6 @@ vec4 getPosition(vec2 pos_screen) return getPosition_d(pos_screen, depth); } -#ifdef WATER_FOG -vec3 getPositionEye(); -vec3 getSunlitColor(); -vec3 getAmblitColor(); -vec3 getAdditiveColor(); -vec3 getAtmosAttenuation(); -#else vec3 getPositionEye() { return vary_PositionEye; @@ -160,7 +153,6 @@ vec3 getAtmosAttenuation() { return vary_AtmosAttenuation; } -#endif void setPositionEye(vec3 v) { diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 3815548dba..86776b7e42 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -299,10 +299,10 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterialAlpha(S32 pass) sVertexProgram = &gDeferredMaterialProgram[pass]; - if (LLPipeline::sUnderWaterRender) - { - sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); - } + //if (LLPipeline::sUnderWaterRender) + //{ + // sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); + //} gPipeline.bindDeferredShader(*sVertexProgram); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -1099,10 +1099,10 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterial(S32 pass) } sVertexProgram = &gDeferredMaterialProgram[pass+LLMaterial::SHADER_COUNT]; - if (LLPipeline::sUnderWaterRender) - { - sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); - } + //if (LLPipeline::sUnderWaterRender) + //{ + // sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); + //} sVertexProgram->bind(); normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP); -- cgit v1.2.3 From d07ba61a850d926eda3e6a9abe54465c7a462676 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 11 Jul 2013 16:42:14 -0700 Subject: NORSPEC-291 really fix missing avatar --- indra/newview/lldrawpoolavatar.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 86776b7e42..59c9cf5a83 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -299,10 +299,10 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterialAlpha(S32 pass) sVertexProgram = &gDeferredMaterialProgram[pass]; - //if (LLPipeline::sUnderWaterRender) - //{ - // sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); - //} + if (LLPipeline::sUnderWaterRender) + { + sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); + } gPipeline.bindDeferredShader(*sVertexProgram); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -1099,10 +1099,10 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterial(S32 pass) } sVertexProgram = &gDeferredMaterialProgram[pass+LLMaterial::SHADER_COUNT]; - //if (LLPipeline::sUnderWaterRender) - //{ - // sVertexProgram = &(gDeferredMaterialWaterProgram[pass]); - //} + if (LLPipeline::sUnderWaterRender) + { + sVertexProgram = &(gDeferredMaterialWaterProgram[pass+LLMaterial::SHADER_COUNT]); + } sVertexProgram->bind(); normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP); -- cgit v1.2.3 From 37048620dd06867f8c7b5262410009ed4a1f371b Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 11 Jul 2013 17:51:20 -0700 Subject: MAINT-2879 : Viewer should revoke animation permissions with "Stop Animating Me" Reviewed by Kelly --- indra/newview/app_settings/settings.xml | 13 ++++++++++- indra/newview/llagent.cpp | 40 ++++++++++++++++++++++++++++++++- indra/newview/llagent.h | 1 + 3 files changed, 52 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 29ad355f75..3964ea5fac 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9697,7 +9697,18 @@ Value 1 - RotateRight + RevokePermsOnStopAnimation + + Comment + Clear animation permssions when choosing "Stop Animating Me" + Persist + 1 + Type + Boolean + Value + 1 + + RotateRight Comment Make the agent rotate to its right. diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 1a96699cff..3b83811c78 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -90,6 +90,7 @@ #include "llwindow.h" #include "llworld.h" #include "llworldmap.h" +#include "lscript_byteformat.h" #include "stringize.h" using namespace LLAvatarAppearanceDefines; @@ -3072,6 +3073,31 @@ void LLAgent::sendAnimationStateReset() sendReliableMessage(); } + +// Send a message to the region to revoke sepecified permissions on ALL scripts in the region +// If the target is an object in the region, permissions in scripts on that object are cleared. +// If it is the region ID, all scripts clear the permissions for this agent +void LLAgent::sendRevokePermissions(const LLUUID & target, U32 permissions) +{ + // Currently only the bits for SCRIPT_PERMISSION_TRIGGER_ANIMATION and SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS + // are supported by the server. Sending any other bits will cause the message to be dropped without changing permissions + + if (gAgentID.notNull() && gMessageSystem) + { + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_RevokePermissions); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, getID()); // Must be our ID + msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); + + msg->nextBlockFast(_PREHASH_Data); + msg->addUUIDFast(_PREHASH_ObjectID, target); // Must be in the region + msg->addS32Fast(_PREHASH_ObjectPermissions, (S32) permissions); + + sendReliableMessage(); + } +} + void LLAgent::sendWalkRun(bool running) { LLMessageSystem* msgsys = gMessageSystem; @@ -4175,9 +4201,21 @@ void LLAgent::stopCurrentAnimations() sendAnimationRequests(anim_ids, ANIM_REQUEST_STOP); - // Tell the region to clear any animation state overrides. + // Tell the region to clear any animation state overrides sendAnimationStateReset(); + // Revoke all animation permissions + if (mRegionp && + gSavedSettings.getBOOL("RevokePermsOnStopAnimation")) + { + U32 permissions = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TRIGGER_ANIMATION] | LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS]; + sendRevokePermissions(mRegionp->getRegionID(), permissions); + if (gAgentAvatarp->isSitting()) + { // Also stand up, since auto-granted sit animation permission has been revoked + gAgent.standUp(); + } + } + // re-assert at least the default standing animation, because // viewers get confused by avs with no associated anims. sendAnimationRequest(ANIM_AGENT_STAND, diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index c5b4476318..7fac17d098 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -432,6 +432,7 @@ public: void sendAnimationRequests(LLDynamicArray &anim_ids, EAnimRequest request); void sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request); void sendAnimationStateReset(); + void sendRevokePermissions(const LLUUID & target, U32 permissions); void endAnimationUpdateUI(); void unpauseAnimation() { mPauseRequest = NULL; } -- cgit v1.2.3 From a8c9d81a376244a372de60b8c2af44c577ee51e0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 12 Jul 2013 06:45:49 -0700 Subject: NORSPEC-291 WIP fix materials underwater with shadows on --- .../shaders/class2/deferred/softenLightF.glsl | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 08aaa2237d..9b72c5b57d 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -266,6 +266,52 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); } +#ifdef WATER_FOG +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) +{ + //normalize view vector + vec3 view = normalize(pos); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(pos - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + vec3 atmosLighting(vec3 light) { light *= getAtmosAttenuation().r; @@ -409,6 +455,13 @@ void main() if (norm.w < 0.5) { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); + + #ifdef WATER_FOG + vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } -- cgit v1.2.3 From b588865f3f56a338fc068b55ab1a408f89307f2b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 12 Jul 2013 08:04:40 -0700 Subject: NORSPEC-291 WIP first attempt at materials in reflection/waterdis maps --- indra/newview/pipeline.cpp | 620 ++++++++++++++++++++++++++++++++++++++++++++- indra/newview/pipeline.h | 1 + 2 files changed, 608 insertions(+), 13 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c605735170..cac347b3a5 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8891,6 +8891,539 @@ void LLPipeline::renderDeferredLighting() } +void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) +{ + if (!sCull) + { + return; + } + + { + LLFastTimer ftm(FTM_RENDER_DEFERRED); + + LLViewerCamera* camera = LLViewerCamera::getInstance(); + + /*{ + LLGLDepthTest depth(GL_TRUE); + mDeferredDepth.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), + 0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); + }*/ + + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) + { + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); + } + + //ati doesn't seem to love actually using the stencil buffer on FBO's + LLGLDisable stencil(GL_STENCIL_TEST); + //glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); + //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + + gGL.setColorMask(true, true); + + //draw a cube around every light + LLVertexBuffer::unbind(); + + LLGLEnable cull(GL_CULL_FACE); + LLGLEnable blend(GL_BLEND); + + glh::matrix4f mat = glh_copy_matrix(gGLModelView); + + LLStrider vert; + mDeferredVB->getVertexStrider(vert); + + vert[0].set(-1,1,0); + vert[1].set(-1,-3,0); + vert[2].set(3,1,0); + + { + setupHWLights(NULL); //to set mSunDir; + LLVector4 dir(mSunDir, 0.f); + glh::vec4f tc(dir.mV); + mat.mult_matrix_vec(tc); + mTransformedSunDir.set(tc.v); + } + + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + if (RenderDeferredSSAO || RenderShadowDetail > 0) + { + mDeferredLight.bindTarget(); + { //paint shadow/SSAO light map (direct lighting lightmap) + LLFastTimer ftm(FTM_SUN_SHADOW); + bindDeferredShader(gDeferredSunProgram, 0); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + glClearColor(1,1,1,1); + mDeferredLight.clear(GL_COLOR_BUFFER_BIT); + glClearColor(0,0,0,0); + + glh::matrix4f inv_trans = glh_get_current_modelview().inverse().transpose(); + + const U32 slice = 32; + F32 offset[slice*3]; + for (U32 i = 0; i < 4; i++) + { + for (U32 j = 0; j < 8; j++) + { + glh::vec3f v; + v.set_value(sinf(6.284f/8*j), cosf(6.284f/8*j), -(F32) i); + v.normalize(); + inv_trans.mult_matrix_vec(v); + v.normalize(); + offset[(i*8+j)*3+0] = v.v[0]; + offset[(i*8+j)*3+1] = v.v[2]; + offset[(i*8+j)*3+2] = v.v[1]; + } + } + + gDeferredSunProgram.uniform3fv("offset", slice, offset); + gDeferredSunProgram.uniform2f("screenRes", mDeferredLight.getWidth(), mDeferredLight.getHeight()); + + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } + + unbindDeferredShader(gDeferredSunProgram); + } + mDeferredLight.flush(); + } + + stop_glerror(); + gGL.popMatrix(); + stop_glerror(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + stop_glerror(); + gGL.popMatrix(); + stop_glerror(); + + // Done by callers... + // + //target->bindTarget(); + // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky + //glClearColor(0,0,0,0); + //target->clear(GL_COLOR_BUFFER_BIT); + + if (RenderDeferredAtmospheric) + { //apply sunlight contribution + LLFastTimer ftm(FTM_ATMOSPHERICS); + bindDeferredShader(gDeferredSoftenProgram); + { + LLGLDepthTest depth(GL_FALSE); + LLGLDisable blend(GL_BLEND); + LLGLDisable test(GL_ALPHA_TEST); + + //full screen blit + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + } + + unbindDeferredShader(gDeferredSoftenProgram); + } + + { //render non-deferred geometry (fullbright, alpha, etc) + LLGLDisable blend(GL_BLEND); + LLGLDisable stencil(GL_STENCIL_TEST); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + gPipeline.pushRenderTypeMask(); + + gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::END_RENDER_TYPES); + + + renderGeomPostDeferred(*LLViewerCamera::getInstance(), false); + gPipeline.popRenderTypeMask(); + } + + BOOL render_local = RenderLocalLights; + + if (render_local) + { + gGL.setSceneBlendType(LLRender::BT_ADD); + std::list fullscreen_lights; + LLDrawable::drawable_list_t spot_lights; + LLDrawable::drawable_list_t fullscreen_spot_lights; + + for (U32 i = 0; i < 2; i++) + { + mTargetShadowSpotLight[i] = NULL; + } + + std::list light_colors; + + LLVertexBuffer::unbind(); + + { + bindDeferredShader(gDeferredLightProgram); + + if (mCubeVB.isNull()) + { + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + } + + mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) + { + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + if (!volume) + { + continue; + } + + if (volume->isAttachment()) + { + if (!sRenderAttachedLights) + { + continue; + } + } + + + LLVector4a center; + center.load3(drawablep->getPositionAgent().mV); + const F32* c = center.getF32ptr(); + F32 s = volume->getLightRadius()*1.5f; + + LLColor3 col = volume->getLightColor(); + + if (col.magVecSquared() < 0.001f) + { + continue; + } + + if (s <= 0.001f) + { + continue; + } + + LLVector4a sa; + sa.splat(s); + if (camera->AABBInFrustumNoFarClip(center, sa) == 0) + { + continue; + } + + sVisibleLightCount++; + + if (camera->getOrigin().mV[0] > c[0] + s + 0.2f || + camera->getOrigin().mV[0] < c[0] - s - 0.2f || + camera->getOrigin().mV[1] > c[1] + s + 0.2f || + camera->getOrigin().mV[1] < c[1] - s - 0.2f || + camera->getOrigin().mV[2] > c[2] + s + 0.2f || + camera->getOrigin().mV[2] < c[2] - s - 0.2f) + { //draw box if camera is outside box + if (render_local) + { + if (volume->isLightSpotlight()) + { + drawablep->getVOVolume()->updateSpotLightPriority(); + spot_lights.push_back(drawablep); + continue; + } + + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + LLFastTimer ftm(FTM_LOCAL_LIGHTS); + gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + gGL.syncMatrices(); + + mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); + stop_glerror(); + } + } + else + { + if (volume->isLightSpotlight()) + { + drawablep->getVOVolume()->updateSpotLightPriority(); + fullscreen_spot_lights.push_back(drawablep); + continue; + } + + glh::vec3f tc(c); + mat.mult_matrix_vec(tc); + + fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s)); + light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); + } + } + unbindDeferredShader(gDeferredLightProgram); + } + + if (!spot_lights.empty()) + { + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + bindDeferredShader(gDeferredSpotLightProgram); + + mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); + + for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) + { + LLFastTimer ftm(FTM_PROJECTORS); + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + + LLVector4a center; + center.load3(drawablep->getPositionAgent().mV); + const F32* c = center.getF32ptr(); + F32 s = volume->getLightRadius()*1.5f; + + sVisibleLightCount++; + + setupSpotLight(gDeferredSpotLightProgram, drawablep); + + LLColor3 col = volume->getLightColor(); + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); + gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + gGL.syncMatrices(); + + mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); + } + gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); + unbindDeferredShader(gDeferredSpotLightProgram); + } + + //reset mDeferredVB to fullscreen triangle + mDeferredVB->getVertexStrider(vert); + vert[0].set(-1,1,0); + vert[1].set(-1,-3,0); + vert[2].set(3,1,0); + + { + LLGLDepthTest depth(GL_FALSE); + + //full screen blit + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + U32 count = 0; + + const U32 max_count = LL_DEFERRED_MULTI_LIGHT_COUNT; + LLVector4 light[max_count]; + LLVector4 col[max_count]; + + F32 far_z = 0.f; + + while (!fullscreen_lights.empty()) + { + LLFastTimer ftm(FTM_FULLSCREEN_LIGHTS); + light[count] = fullscreen_lights.front(); + fullscreen_lights.pop_front(); + col[count] = light_colors.front(); + light_colors.pop_front(); + + /*col[count].mV[0] = powf(col[count].mV[0], 2.2f); + col[count].mV[1] = powf(col[count].mV[1], 2.2f); + col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/ + + far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z); + //col[count] = pow4fsrgb(col[count], 2.2f); + count++; + if (count == max_count || fullscreen_lights.empty()) + { + U32 idx = count-1; + bindDeferredShader(gDeferredMultiLightProgram[idx]); + gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); + gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); + far_z = 0.f; + count = 0; + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + } + + unbindDeferredShader(gDeferredMultiLightProgram[0]); + + bindDeferredShader(gDeferredMultiSpotLightProgram); + + gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) + { + LLFastTimer ftm(FTM_PROJECTORS); + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + + LLVector3 center = drawablep->getPositionAgent(); + F32* c = center.mV; + F32 s = volume->getLightRadius()*1.5f; + + sVisibleLightCount++; + + glh::vec3f tc(c); + mat.mult_matrix_vec(tc); + + setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); + + LLColor3 col = volume->getLightColor(); + + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); + gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + + gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); + unbindDeferredShader(gDeferredMultiSpotLightProgram); + + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + } + } + + gGL.setColorMask(true, true); + } + + target->flush(); + + //gamma correct lighting + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + + { + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + LLVector2 tc1(0,0); + LLVector2 tc2((F32) target->getWidth()*2, + (F32) target->getHeight()*2); + + target->bindTarget(); + // Apply gamma correction to the frame here. + gDeferredPostGammaCorrectProgram.bind(); + //mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + S32 channel = 0; + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, target->getUsage()); + if (channel > -1) + { + target->bindTexture(0,channel); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, target->getWidth(), target->getHeight()); + + F32 gamma = 1.0/2.2; + + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, gamma); + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1,-1); + + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1,3); + + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3,-1); + + gGL.end(); + + gGL.getTexUnit(channel)->unbind(target->getUsage()); + gDeferredPostGammaCorrectProgram.unbind(); + target->flush(); + } + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + + target->bindTarget(); + + { //render non-deferred geometry (alpha, fullbright, glow) + LLGLDisable blend(GL_BLEND); + LLGLDisable stencil(GL_STENCIL_TEST); + + pushRenderTypeMask(); + andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_FULLBRIGHT, + LLPipeline::RENDER_TYPE_VOLUME, + LLPipeline::RENDER_TYPE_GLOW, + LLPipeline::RENDER_TYPE_BUMP, + LLPipeline::RENDER_TYPE_PASS_SIMPLE, + LLPipeline::RENDER_TYPE_PASS_ALPHA, + LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_BUMP, + LLPipeline::RENDER_TYPE_PASS_POST_BUMP, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, + LLPipeline::RENDER_TYPE_PASS_GLOW, + LLPipeline::RENDER_TYPE_PASS_GRASS, + LLPipeline::RENDER_TYPE_PASS_SHINY, + LLPipeline::RENDER_TYPE_PASS_INVISIBLE, + LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, + LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_ALPHA_MASK, + LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, + END_RENDER_TYPES); + + renderGeomPostDeferred(*LLViewerCamera::getInstance()); + popRenderTypeMask(); + } + + // Done by callers for flexibility + //target->flush(); +} + void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) { //construct frustum @@ -9145,7 +9678,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLPipeline::sUseOcclusion = 0; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glClearColor(0,0,0,0); + mWaterRef.bindTarget(); + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0; gGL.setColorMask(true, true); mWaterRef.clear(); @@ -9182,19 +9717,39 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) if (LLDrawPoolWater::sNeedsReflectionUpdate) { - //initial sky pass (no user clip plane) - { //mask out everything but the sky - gPipeline.pushRenderTypeMask(); - gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::END_RENDER_TYPES); + //initial sky pass (no user clip plane) + { //mask out everything but the sky + gPipeline.pushRenderTypeMask(); + gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::END_RENDER_TYPES); - static LLCullResult result; - updateCull(camera, result); - stateSort(camera, result); + static LLCullResult result; + updateCull(camera, result); + stateSort(camera, result); - renderGeom(camera, TRUE); +#if MATERIALS_IN_REFLECTIONS + if (LLPipeline::sRenderDeferred) + { + gGL.setColorMask(true, true); + renderGeomDeferred(camera); + gPipeline.mDeferredScreen.flush(); + if(LLRenderTarget::sUseFBO) + { + LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), + gPipeline.mDeferredScreen.getHeight(), 0, 0, + gPipeline.mDeferredScreen.getWidth(), + gPipeline.mDeferredScreen.getHeight(), + GL_DEPTH_BUFFER_BIT, GL_NEAREST); + } + renderDeferredLightingToRT(&mWaterRef); + } + else +#endif + { + renderGeom(camera, TRUE); + } gPipeline.popRenderTypeMask(); } @@ -9236,7 +9791,27 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) { gPipeline.grabReferences(ref_result); LLGLUserClipPlane clip_plane(plane, mat, projection); - renderGeom(camera); + +#if MATERIALS_IN_REFLECTIONS + if (LLPipeline::sRenderDeferred) + { + renderGeomDeferred(camera); + gPipeline.mDeferredScreen.flush(); + if(LLRenderTarget::sUseFBO) + { + LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), + gPipeline.mDeferredScreen.getHeight(), 0, 0, + gPipeline.mDeferredScreen.getWidth(), + gPipeline.mDeferredScreen.getHeight(), + GL_DEPTH_BUFFER_BIT, GL_NEAREST); + } + renderDeferredLightingToRT(&mWaterRef); + } + else +#endif + { + renderGeom(camera); + } } } @@ -9293,9 +9868,28 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.setColorMask(true, true); mWaterDis.clear(); - gGL.setColorMask(true, false); +#if MATERIALS_IN_REFLECTIONS + if (LLPipeline::sRenderDeferred) + { + renderGeomDeferred(camera); + gPipeline.mDeferredScreen.flush(); + if(LLRenderTarget::sUseFBO) + { + LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), + gPipeline.mDeferredScreen.getHeight(), 0, 0, + gPipeline.mDeferredScreen.getWidth(), + gPipeline.mDeferredScreen.getHeight(), + GL_DEPTH_BUFFER_BIT, GL_NEAREST); + } + renderDeferredLightingToRT(&mWaterDis); + } + else +#endif + { + gGL.setColorMask(true, false); renderGeom(camera); + } } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 2f0fc3491d..36b293b998 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -288,6 +288,7 @@ public: void unbindDeferredShader(LLGLSLShader& shader); void renderDeferredLighting(); + void renderDeferredLightingToRT(LLRenderTarget* target); void generateWaterReflection(LLCamera& camera); void generateSunShadow(LLCamera& camera); -- cgit v1.2.3 From 7766129495a9ac447ca2ccf44d631481d2cea911 Mon Sep 17 00:00:00 2001 From: "maxim@mnikolenko" Date: Fri, 12 Jul 2013 19:51:22 +0300 Subject: MAINT-2875 FIXED Shortcut was changed and menu item was added. --- indra/newview/skins/default/xui/en/menu_viewer.xml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 39fd519c70..db45e515ad 100755 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -93,7 +93,7 @@ + shortcut="PGUP"> + + + + Date: Fri, 12 Jul 2013 13:01:31 -0700 Subject: NORSPEC-291 WIP added underwater deferred program and more reflection pass work --- .../shaders/class1/deferred/underWaterF.glsl | 120 +++++++++++ indra/newview/lldrawpoolwater.cpp | 9 +- indra/newview/llviewershadermgr.cpp | 17 ++ indra/newview/llviewershadermgr.h | 1 + indra/newview/pipeline.cpp | 220 ++++++++++++++++----- indra/newview/pipeline.h | 3 +- 6 files changed, 315 insertions(+), 55 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl new file mode 100644 index 0000000000..c160b38cfe --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl @@ -0,0 +1,120 @@ +/** + * @file underWaterF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +uniform sampler2D diffuseMap; +uniform sampler2D bumpMap; +uniform sampler2D screenTex; +uniform sampler2D refTex; +uniform sampler2D screenDepth; + +uniform vec4 fogCol; +uniform vec3 lightDir; +uniform vec3 specular; +uniform float lightExp; +uniform vec2 fbScale; +uniform float refScale; +uniform float znear; +uniform float zfar; +uniform float kd; +uniform vec4 waterPlane; +uniform vec3 eyeVec; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; +uniform vec2 screenRes; + +//bigWave is (refCoord.w, view.w); +VARYING vec4 refCoord; +VARYING vec4 littleWave; +VARYING vec4 view; + +vec2 encode_normal(vec3 n) +{ + float f = sqrt(8 * n.z + 8); + return n.xy / f + 0.5; +} + +vec4 applyWaterFog(vec4 color, vec3 viewVec) +{ + //normalize view vector + vec3 view = normalize(viewVec); + float es = -view.z; + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + //get object depth + float depth = length(viewVec); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + //return vec4(1.0, 0.0, 1.0, 1.0); + return color * D + kc * L; + //depth /= 10.0; + //return vec4(depth,depth,depth,0.0); +} + +void main() +{ + vec4 color; + + //get detail normals + vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + vec3 wavef = normalize(wave1+wave2+wave3); + + //figure out distortion vector (ripply) + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + distort = distort+wavef.xy*refScale; + + vec4 fb = texture2D(screenTex, distort); + + frag_data[0] = vec4(fb.rgb, 0.5); // diffuse + frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec + frag_data[2] = vec4(encode_normal(wavef), 0.0, 0.0); // normalxyz, displace +} diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 5b0b173926..6774926f62 100755 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -524,7 +524,14 @@ void LLDrawPoolWater::shade() if (eyedepth < 0.f && LLPipeline::sWaterReflections) { - shader = &gUnderWaterProgram; + if (deferred_render) + { + shader = &gDeferredUnderWaterProgram; + } + else + { + shader = &gUnderWaterProgram; + } } else if (deferred_render) { diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 3df8115402..e9c3990e9a 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -168,6 +168,7 @@ LLGLSLShader gPostNightVisionProgram; // Deferred rendering shaders LLGLSLShader gDeferredImpostorProgram; LLGLSLShader gDeferredWaterProgram; +LLGLSLShader gDeferredUnderWaterProgram; LLGLSLShader gDeferredDiffuseProgram; LLGLSLShader gDeferredDiffuseAlphaMaskProgram; LLGLSLShader gDeferredNonIndexedDiffuseProgram; @@ -309,6 +310,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredEmissiveProgram); mShaderList.push_back(&gDeferredAvatarEyesProgram); mShaderList.push_back(&gDeferredWaterProgram); + mShaderList.push_back(&gDeferredUnderWaterProgram); mShaderList.push_back(&gDeferredAvatarAlphaProgram); mShaderList.push_back(&gDeferredWLSkyProgram); mShaderList.push_back(&gDeferredWLCloudProgram); @@ -1153,6 +1155,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPostGammaCorrectProgram.unload(); gFXAAProgram.unload(); gDeferredWaterProgram.unload(); + gDeferredUnderWaterProgram.unload(); gDeferredWLSkyProgram.unload(); gDeferredWLCloudProgram.unload(); gDeferredStarProgram.unload(); @@ -1640,6 +1643,20 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredWaterProgram.createShader(NULL, &mWaterUniforms); } + if (success) + { + // load water shader + gDeferredUnderWaterProgram.mName = "Deferred Under Water Shader"; + gDeferredUnderWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredUnderWaterProgram.mFeatures.hasGamma = true; + gDeferredUnderWaterProgram.mFeatures.hasTransport = true; + gDeferredUnderWaterProgram.mShaderFiles.clear(); + gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/underWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredUnderWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + success = gDeferredUnderWaterProgram.createShader(NULL, &mWaterUniforms); + } + if (success) { gDeferredSoftenProgram.mName = "Deferred Soften Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 5310076013..f14180d957 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -330,6 +330,7 @@ extern LLGLSLShader gPostNightVisionProgram; // Deferred rendering shaders extern LLGLSLShader gDeferredImpostorProgram; extern LLGLSLShader gDeferredWaterProgram; +extern LLGLSLShader gDeferredUnderWaterProgram; extern LLGLSLShader gDeferredDiffuseProgram; extern LLGLSLShader gDeferredDiffuseAlphaMaskProgram; extern LLGLSLShader gDeferredNonIndexedDiffuseAlphaMaskProgram; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index cac347b3a5..4e1eb4d8ad 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -122,6 +122,10 @@ //#define DEBUG_INDICES #endif +// Expensive and currently broken... +// +#define MATERIALS_IN_REFLECTIONS 0 + bool gShiftFrame = false; //cached settings @@ -4647,6 +4651,103 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) gGL.setColorMask(true, false); } +void LLPipeline::renderGeomDeferredToRT(LLCamera& camera) +{ + LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); + + LLFastTimer t(FTM_RENDER_GEOMETRY); + LLFastTimer t2(FTM_DEFERRED_POOLS); + + LLGLEnable cull(GL_CULL_FACE); + + LLGLEnable stencil(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF); + stop_glerror(); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + stop_glerror(); + + for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) + { + LLDrawPool *poolp = *iter; + if (hasRenderType(poolp->getType())) + { + poolp->prerender(); + } + } + + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + + LLVertexBuffer::unbind(); + + LLGLState::checkStates(); + LLGLState::checkTextureChannels(); + LLGLState::checkClientArrays(); + + U32 cur_type = 0; + + gGL.setColorMask(true, true); + + pool_set_t::iterator iter1 = mPools.begin(); + + while ( iter1 != mPools.end() ) + { + LLDrawPool *poolp = *iter1; + + cur_type = poolp->getType(); + + pool_set_t::iterator iter2 = iter1; + if (hasRenderType(poolp->getType()) && poolp->getNumDeferredPasses() > 0) + { + LLFastTimer t(FTM_DEFERRED_POOLRENDER); + + gGLLastMatrix = NULL; + gGL.loadMatrix(gGLModelView); + + for( S32 i = 0; i < poolp->getNumDeferredPasses(); i++ ) + { + LLVertexBuffer::unbind(); + poolp->beginDeferredPass(i); + for (iter2 = iter1; iter2 != mPools.end(); iter2++) + { + LLDrawPool *p = *iter2; + if (p->getType() != cur_type) + { + break; + } + + if ( !p->getSkipRenderFlag() ) { p->renderDeferred(i); } + } + poolp->endDeferredPass(i); + LLVertexBuffer::unbind(); + + if (gDebugGL || gDebugPipeline) + { + LLGLState::checkStates(); + } + } + } + else + { + // Skip all pools of this type + for (iter2 = iter1; iter2 != mPools.end(); iter2++) + { + LLDrawPool *p = *iter2; + if (p->getType() != cur_type) + { + break; + } + } + } + iter1 = iter2; + stop_glerror(); + } + + gGLLastMatrix = NULL; + gGL.loadMatrix(gGLModelView); + + gGL.setColorMask(true, false); +} + void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) { LLFastTimer t(FTM_POST_DEFERRED_POOLS); @@ -8047,10 +8148,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) static LLFastTimer::DeclareTimer FTM_BIND_DEFERRED("Bind Deferred"); -void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 noise_map) +void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRenderTarget* alternative_target, U32 noise_map) { LLFastTimer t(FTM_BIND_DEFERRED); + LLRenderTarget* render_target = alternative_target ? alternative_target : &mScreen; + if (noise_map == 0xFFFFFFFF) { noise_map = mNoiseMap; @@ -8120,7 +8223,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n { if (light_index > 0) { - mScreen.bindTexture(0, channel); + render_target->bindTexture(0, channel); } else { @@ -8903,11 +9006,11 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) LLViewerCamera* camera = LLViewerCamera::getInstance(); - /*{ + { LLGLDepthTest depth(GL_TRUE); mDeferredDepth.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), 0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); - }*/ + } LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); @@ -8957,7 +9060,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) mDeferredLight.bindTarget(); { //paint shadow/SSAO light map (direct lighting lightmap) LLFastTimer ftm(FTM_SUN_SHADOW); - bindDeferredShader(gDeferredSunProgram, 0); + bindDeferredShader(gDeferredSunProgram, 0, target); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); glClearColor(1,1,1,1); mDeferredLight.clear(GL_COLOR_BUFFER_BIT); @@ -9006,17 +9109,16 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) gGL.popMatrix(); stop_glerror(); - // Done by callers... - // - //target->bindTarget(); - // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky - //glClearColor(0,0,0,0); + target->bindTarget(); + + //clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky + //glClearColor(0,1,0,0); //target->clear(GL_COLOR_BUFFER_BIT); if (RenderDeferredAtmospheric) { //apply sunlight contribution LLFastTimer ftm(FTM_ATMOSPHERICS); - bindDeferredShader(gDeferredSoftenProgram); + bindDeferredShader(gDeferredSoftenProgram,0,target); { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -9077,7 +9179,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) LLVertexBuffer::unbind(); { - bindDeferredShader(gDeferredLightProgram); + bindDeferredShader(gDeferredLightProgram, 0, target); if (mCubeVB.isNull()) { @@ -9185,7 +9287,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) if (!spot_lights.empty()) { LLGLDepthTest depth(GL_TRUE, GL_FALSE); - bindDeferredShader(gDeferredSpotLightProgram); + bindDeferredShader(gDeferredSpotLightProgram,0, target); mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -9266,7 +9368,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) if (count == max_count || fullscreen_lights.empty()) { U32 idx = count-1; - bindDeferredShader(gDeferredMultiLightProgram[idx]); + bindDeferredShader(gDeferredMultiLightProgram[idx],0, target); gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); @@ -9280,7 +9382,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) unbindDeferredShader(gDeferredMultiLightProgram[0]); - bindDeferredShader(gDeferredMultiSpotLightProgram); + bindDeferredShader(gDeferredMultiSpotLightProgram, 0, target); gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); @@ -9420,8 +9522,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) popRenderTypeMask(); } - // Done by callers for flexibility - //target->flush(); + target->flush(); } void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) @@ -9733,17 +9834,12 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) if (LLPipeline::sRenderDeferred) { gGL.setColorMask(true, true); - renderGeomDeferred(camera); - gPipeline.mDeferredScreen.flush(); - if(LLRenderTarget::sUseFBO) - { - LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), - gPipeline.mDeferredScreen.getHeight(), 0, 0, - gPipeline.mDeferredScreen.getWidth(), - gPipeline.mDeferredScreen.getHeight(), - GL_DEPTH_BUFFER_BIT, GL_NEAREST); - } - renderDeferredLightingToRT(&mWaterRef); + gPipeline.mDeferredScreen.bindTarget(); + glClearColor(0,0,0,0); + gPipeline.mDeferredScreen.clear(); + + LLGLDepthTest d(GL_FALSE,GL_FALSE); + renderGeomDeferred(camera); } else #endif @@ -9754,6 +9850,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gPipeline.popRenderTypeMask(); } + gGL.setColorMask(true, false); gPipeline.pushRenderTypeMask(); clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER, @@ -9795,26 +9892,30 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) #if MATERIALS_IN_REFLECTIONS if (LLPipeline::sRenderDeferred) { + LLGLDepthTest d(GL_FALSE,GL_FALSE); renderGeomDeferred(camera); - gPipeline.mDeferredScreen.flush(); - if(LLRenderTarget::sUseFBO) - { - LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), - gPipeline.mDeferredScreen.getHeight(), 0, 0, - gPipeline.mDeferredScreen.getWidth(), - gPipeline.mDeferredScreen.getHeight(), - GL_DEPTH_BUFFER_BIT, GL_NEAREST); - } - renderDeferredLightingToRT(&mWaterRef); } else #endif { renderGeom(camera); - } + } } } +#if MATERIALS_IN_REFLECTIONS + if (LLPipeline::sRenderDeferred) + { + gPipeline.mDeferredScreen.flush(); + gPipeline.mWaterRef.copyContents(gPipeline.mDeferredScreen, + 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), + 0, 0, gPipeline.mWaterRef.getWidth(), gPipeline.mWaterRef.getHeight(), + 0, GL_NEAREST); + mWaterRef.flush(); + renderDeferredLightingToRT(&mWaterRef); + } +#endif + gPipeline.popRenderTypeMask(); } glCullFace(GL_BACK); @@ -9849,10 +9950,12 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLViewerCamera::updateFrustumPlanes(camera); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + LLColor4& col = LLDrawPoolWater::sWaterFogColor; glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); mWaterDis.bindTarget(); LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1; + mWaterDis.getViewport(gGLViewport); if (!LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsReflectionUpdate) @@ -9868,33 +9971,44 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.setColorMask(true, true); mWaterDis.clear(); + gGL.setColorMask(true, false); #if MATERIALS_IN_REFLECTIONS if (LLPipeline::sRenderDeferred) - { + { + + gPipeline.mDeferredScreen.bindTarget(); + gGL.setColorMask(true, true); + glClearColor(1,0,1,0); + gPipeline.mDeferredScreen.clear(); + renderGeomDeferred(camera); + gPipeline.mDeferredScreen.flush(); - if(LLRenderTarget::sUseFBO) - { - LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), - gPipeline.mDeferredScreen.getHeight(), 0, 0, - gPipeline.mDeferredScreen.getWidth(), - gPipeline.mDeferredScreen.getHeight(), - GL_DEPTH_BUFFER_BIT, GL_NEAREST); - } - renderDeferredLightingToRT(&mWaterDis); + + mWaterDis.copyContents(gPipeline.mDeferredScreen, + 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), + 0, 0, gPipeline.mWaterDis.getWidth(), gPipeline.mWaterDis.getHeight(), + 0, GL_NEAREST); + mWaterDis.flush(); } else #endif { - gGL.setColorMask(true, false); - renderGeom(camera); + renderGeom(camera); } - + +#if MATERIALS_IN_REFLECTIONS + if (LLPipeline::sRenderDeferred) + { + renderDeferredLightingToRT(&mWaterDis); + } +#endif } - LLPipeline::sUnderWaterRender = FALSE; mWaterDis.flush(); + LLPipeline::sUnderWaterRender = FALSE; + } last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 36b293b998..8764616fba 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -281,9 +281,10 @@ public: void renderGeom(LLCamera& camera, BOOL forceVBOUpdate = FALSE); void renderGeomDeferred(LLCamera& camera); + void renderGeomDeferredToRT(LLCamera& camera); void renderGeomPostDeferred(LLCamera& camera, bool do_occlusion=true); void renderGeomShadow(LLCamera& camera); - void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, U32 noise_map = 0xFFFFFFFF); + void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, LLRenderTarget* alternative_target = NULL, U32 noise_map = 0xFFFFFFFF); void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep); void unbindDeferredShader(LLGLSLShader& shader); -- cgit v1.2.3 From 7acf6fa449a1a8383f4cf1291dbebeff5f98283a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 15 Jul 2013 08:40:17 -0700 Subject: NORSPEC-291 WIP materials working underwater and in reflection and dis passes, not gamma correct, needs cleanup --- indra/newview/pipeline.cpp | 75 +++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4e1eb4d8ad..e5ea7d0381 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -124,7 +124,7 @@ // Expensive and currently broken... // -#define MATERIALS_IN_REFLECTIONS 0 +#define MATERIALS_IN_REFLECTIONS 1 bool gShiftFrame = false; @@ -1239,8 +1239,23 @@ void LLPipeline::createGLBuffers() if (LLPipeline::sWaterReflections) { //water reflection texture U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); - - mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE); + +#if MATERIALS_IN_REFLECTIONS + if (LLPipeline::sRenderDeferred) + { + mWaterRef.allocate(res,res,GL_SRGB8_ALPHA8,TRUE,FALSE); + } + else +#endif + mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE); + +#if MATERIALS_IN_REFLECTIONS + if (LLPipeline::sRenderDeferred) + { + mWaterDis.allocate(res,res,GL_SRGB8_ALPHA8,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); + } + else +#endif //always use FBO for mWaterDis so it can be used for avatar texture bakes mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); } @@ -8152,7 +8167,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen { LLFastTimer t(FTM_BIND_DEFERRED); - LLRenderTarget* render_target = alternative_target ? alternative_target : &mScreen; + (void)alternative_target; + //LLRenderTarget* render_target = alternative_target ? alternative_target : &mScreen; if (noise_map == 0xFFFFFFFF) { @@ -8221,11 +8237,11 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage()); if (channel > -1) { - if (light_index > 0) + /*if (light_index > 0) { render_target->bindTexture(0, channel); } - else + else*/ { mDeferredLight.bindTexture(0, channel); } @@ -9112,8 +9128,8 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) target->bindTarget(); //clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky - //glClearColor(0,1,0,0); - //target->clear(GL_COLOR_BUFFER_BIT); + glClearColor(0,0,0,0); + target->clear(GL_COLOR_BUFFER_BIT); if (RenderDeferredAtmospheric) { //apply sunlight contribution @@ -9431,7 +9447,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) gGL.setColorMask(true, true); } - target->flush(); + /*target->flush(); //gamma correct lighting gGL.matrixMode(LLRender::MM_PROJECTION); @@ -9488,7 +9504,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); - target->bindTarget(); + target->bindTarget();*/ { //render non-deferred geometry (alpha, fullbright, glow) LLGLDisable blend(GL_BLEND); @@ -9522,7 +9538,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) popRenderTypeMask(); } - target->flush(); + //target->flush(); } void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) @@ -9833,12 +9849,14 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) #if MATERIALS_IN_REFLECTIONS if (LLPipeline::sRenderDeferred) { - gGL.setColorMask(true, true); + mWaterRef.flush(); + + gPipeline.grabReferences(result); gPipeline.mDeferredScreen.bindTarget(); + gGL.setColorMask(true, true); glClearColor(0,0,0,0); gPipeline.mDeferredScreen.clear(); - LLGLDepthTest d(GL_FALSE,GL_FALSE); renderGeomDeferred(camera); } else @@ -9891,8 +9909,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) #if MATERIALS_IN_REFLECTIONS if (LLPipeline::sRenderDeferred) - { - LLGLDepthTest d(GL_FALSE,GL_FALSE); + { renderGeomDeferred(camera); } else @@ -9907,11 +9924,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.flush(); - gPipeline.mWaterRef.copyContents(gPipeline.mDeferredScreen, - 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), - 0, 0, gPipeline.mWaterRef.getWidth(), gPipeline.mWaterRef.getHeight(), - 0, GL_NEAREST); - mWaterRef.flush(); renderDeferredLightingToRT(&mWaterRef); } #endif @@ -9971,26 +9983,20 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.setColorMask(true, true); mWaterDis.clear(); + + gGL.setColorMask(true, false); #if MATERIALS_IN_REFLECTIONS + mWaterDis.flush(); if (LLPipeline::sRenderDeferred) - { - + { gPipeline.mDeferredScreen.bindTarget(); gGL.setColorMask(true, true); - glClearColor(1,0,1,0); + glClearColor(0,0,0,0); gPipeline.mDeferredScreen.clear(); - - renderGeomDeferred(camera); - - gPipeline.mDeferredScreen.flush(); - - mWaterDis.copyContents(gPipeline.mDeferredScreen, - 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), - 0, 0, gPipeline.mWaterDis.getWidth(), gPipeline.mWaterDis.getHeight(), - 0, GL_NEAREST); - mWaterDis.flush(); + gPipeline.grabReferences(result); + renderGeomDeferred(camera); } else #endif @@ -10000,7 +10006,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) #if MATERIALS_IN_REFLECTIONS if (LLPipeline::sRenderDeferred) - { + { + gPipeline.mDeferredScreen.flush(); renderDeferredLightingToRT(&mWaterDis); } #endif -- cgit v1.2.3 From a09d1ac79ab2172de11d6a3e08965ee6e2f5537a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 15 Jul 2013 11:49:31 -0700 Subject: NORSPEC-291 WIP clean-up and make materials rendering underwater a runtime setting --- indra/newview/app_settings/settings.xml | 11 +++ indra/newview/pipeline.cpp | 169 ++++++-------------------------- indra/newview/pipeline.h | 3 +- 3 files changed, 42 insertions(+), 141 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ebb01fb330..2d3b32159a 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9621,6 +9621,17 @@ Value 1 + RenderWaterMaterials + + Comment + Water planar reflections include materials rendering. + Persist + 1 + Type + S32 + Value + 0 + RenderWaterMipNormal Comment diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e5ea7d0381..ad082b5c74 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -122,7 +122,7 @@ //#define DEBUG_INDICES #endif -// Expensive and currently broken... +// Expensive // #define MATERIALS_IN_REFLECTIONS 1 @@ -1236,28 +1236,26 @@ void LLPipeline::createGLBuffers() updateRenderDeferred(); + bool materials_in_water = gSavedSettings.getS32("RenderWaterMaterials"); + if (LLPipeline::sWaterReflections) { //water reflection texture U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); -#if MATERIALS_IN_REFLECTIONS - if (LLPipeline::sRenderDeferred) + // Set up SRGB targets if we're doing deferred-path reflection rendering + // + if (LLPipeline::sRenderDeferred && materials_in_water) { mWaterRef.allocate(res,res,GL_SRGB8_ALPHA8,TRUE,FALSE); + //always use FBO for mWaterDis so it can be used for avatar texture bakes + mWaterDis.allocate(res,res,GL_SRGB8_ALPHA8,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); } else -#endif - mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE); - -#if MATERIALS_IN_REFLECTIONS - if (LLPipeline::sRenderDeferred) { - mWaterDis.allocate(res,res,GL_SRGB8_ALPHA8,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); + mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE); + //always use FBO for mWaterDis so it can be used for avatar texture bakes + mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); } - else -#endif - //always use FBO for mWaterDis so it can be used for avatar texture bakes - mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); } mHighlight.allocate(256,256,GL_RGBA, FALSE, FALSE); @@ -4666,103 +4664,6 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) gGL.setColorMask(true, false); } -void LLPipeline::renderGeomDeferredToRT(LLCamera& camera) -{ - LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); - - LLFastTimer t(FTM_RENDER_GEOMETRY); - LLFastTimer t2(FTM_DEFERRED_POOLS); - - LLGLEnable cull(GL_CULL_FACE); - - LLGLEnable stencil(GL_STENCIL_TEST); - glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF); - stop_glerror(); - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - stop_glerror(); - - for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) - { - LLDrawPool *poolp = *iter; - if (hasRenderType(poolp->getType())) - { - poolp->prerender(); - } - } - - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); - - LLVertexBuffer::unbind(); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); - - U32 cur_type = 0; - - gGL.setColorMask(true, true); - - pool_set_t::iterator iter1 = mPools.begin(); - - while ( iter1 != mPools.end() ) - { - LLDrawPool *poolp = *iter1; - - cur_type = poolp->getType(); - - pool_set_t::iterator iter2 = iter1; - if (hasRenderType(poolp->getType()) && poolp->getNumDeferredPasses() > 0) - { - LLFastTimer t(FTM_DEFERRED_POOLRENDER); - - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - - for( S32 i = 0; i < poolp->getNumDeferredPasses(); i++ ) - { - LLVertexBuffer::unbind(); - poolp->beginDeferredPass(i); - for (iter2 = iter1; iter2 != mPools.end(); iter2++) - { - LLDrawPool *p = *iter2; - if (p->getType() != cur_type) - { - break; - } - - if ( !p->getSkipRenderFlag() ) { p->renderDeferred(i); } - } - poolp->endDeferredPass(i); - LLVertexBuffer::unbind(); - - if (gDebugGL || gDebugPipeline) - { - LLGLState::checkStates(); - } - } - } - else - { - // Skip all pools of this type - for (iter2 = iter1; iter2 != mPools.end(); iter2++) - { - LLDrawPool *p = *iter2; - if (p->getType() != cur_type) - { - break; - } - } - } - iter1 = iter2; - stop_glerror(); - } - - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); - - gGL.setColorMask(true, false); -} - void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) { LLFastTimer t(FTM_POST_DEFERRED_POOLS); @@ -8163,13 +8064,10 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) static LLFastTimer::DeclareTimer FTM_BIND_DEFERRED("Bind Deferred"); -void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRenderTarget* alternative_target, U32 noise_map) +void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 noise_map) { LLFastTimer t(FTM_BIND_DEFERRED); - (void)alternative_target; - //LLRenderTarget* render_target = alternative_target ? alternative_target : &mScreen; - if (noise_map == 0xFFFFFFFF) { noise_map = mNoiseMap; @@ -8237,11 +8135,11 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage()); if (channel > -1) { - /*if (light_index > 0) + if (light_index > 0) { - render_target->bindTexture(0, channel); + mScreen.bindTexture(0, channel); } - else*/ + else { mDeferredLight.bindTexture(0, channel); } @@ -9076,7 +8974,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) mDeferredLight.bindTarget(); { //paint shadow/SSAO light map (direct lighting lightmap) LLFastTimer ftm(FTM_SUN_SHADOW); - bindDeferredShader(gDeferredSunProgram, 0, target); + bindDeferredShader(gDeferredSunProgram); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); glClearColor(1,1,1,1); mDeferredLight.clear(GL_COLOR_BUFFER_BIT); @@ -9134,7 +9032,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) if (RenderDeferredAtmospheric) { //apply sunlight contribution LLFastTimer ftm(FTM_ATMOSPHERICS); - bindDeferredShader(gDeferredSoftenProgram,0,target); + bindDeferredShader(gDeferredSoftenProgram); { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -9195,7 +9093,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) LLVertexBuffer::unbind(); { - bindDeferredShader(gDeferredLightProgram, 0, target); + bindDeferredShader(gDeferredLightProgram); if (mCubeVB.isNull()) { @@ -9303,7 +9201,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) if (!spot_lights.empty()) { LLGLDepthTest depth(GL_TRUE, GL_FALSE); - bindDeferredShader(gDeferredSpotLightProgram,0, target); + bindDeferredShader(gDeferredSpotLightProgram); mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -9384,7 +9282,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) if (count == max_count || fullscreen_lights.empty()) { U32 idx = count-1; - bindDeferredShader(gDeferredMultiLightProgram[idx],0, target); + bindDeferredShader(gDeferredMultiLightProgram[idx]); gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); @@ -9398,7 +9296,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) unbindDeferredShader(gDeferredMultiLightProgram[0]); - bindDeferredShader(gDeferredMultiSpotLightProgram, 0, target); + bindDeferredShader(gDeferredMultiSpotLightProgram); gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); @@ -9787,6 +9685,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) water_clip = 1; } + bool materials_in_water = gSavedSettings.getS32("RenderWaterMaterials"); + if (!LLViewerCamera::getInstance()->cameraUnderWater()) { //generate planar reflection map @@ -9846,8 +9746,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) updateCull(camera, result); stateSort(camera, result); -#if MATERIALS_IN_REFLECTIONS - if (LLPipeline::sRenderDeferred) + if (LLPipeline::sRenderDeferred && materials_in_water) { mWaterRef.flush(); @@ -9860,7 +9759,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) renderGeomDeferred(camera); } else -#endif { renderGeom(camera, TRUE); } @@ -9907,26 +9805,22 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gPipeline.grabReferences(ref_result); LLGLUserClipPlane clip_plane(plane, mat, projection); -#if MATERIALS_IN_REFLECTIONS - if (LLPipeline::sRenderDeferred) + if (LLPipeline::sRenderDeferred && materials_in_water) { renderGeomDeferred(camera); } else -#endif { renderGeom(camera); } } } -#if MATERIALS_IN_REFLECTIONS - if (LLPipeline::sRenderDeferred) + if (LLPipeline::sRenderDeferred && materials_in_water) { gPipeline.mDeferredScreen.flush(); renderDeferredLightingToRT(&mWaterRef); } -#endif gPipeline.popRenderTypeMask(); } @@ -9987,10 +9881,10 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.setColorMask(true, false); -#if MATERIALS_IN_REFLECTIONS - mWaterDis.flush(); - if (LLPipeline::sRenderDeferred) + + if (LLPipeline::sRenderDeferred && materials_in_water) { + mWaterDis.flush(); gPipeline.mDeferredScreen.bindTarget(); gGL.setColorMask(true, true); glClearColor(0,0,0,0); @@ -9999,18 +9893,15 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) renderGeomDeferred(camera); } else -#endif { renderGeom(camera); } -#if MATERIALS_IN_REFLECTIONS - if (LLPipeline::sRenderDeferred) + if (LLPipeline::sRenderDeferred && materials_in_water) { gPipeline.mDeferredScreen.flush(); renderDeferredLightingToRT(&mWaterDis); } -#endif } mWaterDis.flush(); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 8764616fba..36b293b998 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -281,10 +281,9 @@ public: void renderGeom(LLCamera& camera, BOOL forceVBOUpdate = FALSE); void renderGeomDeferred(LLCamera& camera); - void renderGeomDeferredToRT(LLCamera& camera); void renderGeomPostDeferred(LLCamera& camera, bool do_occlusion=true); void renderGeomShadow(LLCamera& camera); - void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, LLRenderTarget* alternative_target = NULL, U32 noise_map = 0xFFFFFFFF); + void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, U32 noise_map = 0xFFFFFFFF); void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep); void unbindDeferredShader(LLGLSLShader& shader); -- cgit v1.2.3 From a540ae81c42f1c7be87bda73d060b7ba8eaa0654 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 15 Jul 2013 13:46:01 -0700 Subject: NORSPEC-291 first attempt at gamma correction of materials in reflections --- .../shaders/class1/deferred/underWaterF.glsl | 22 +++++++++++++++- .../shaders/class1/deferred/waterF.glsl | 29 +++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl index c160b38cfe..938947bbce 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl @@ -56,6 +56,26 @@ VARYING vec4 refCoord; VARYING vec4 littleWave; VARYING vec4 view; +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -114,7 +134,7 @@ void main() vec4 fb = texture2D(screenTex, distort); - frag_data[0] = vec4(fb.rgb, 0.5); // diffuse + frag_data[0] = vec4(linear_to_srgb(fb.rgb), 1.0); // diffuse frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec frag_data[2] = vec4(encode_normal(wavef), 0.0, 0.0); // normalxyz, displace } diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index daa2fb390a..17288873c8 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -67,6 +67,26 @@ VARYING vec4 littleWave; VARYING vec4 view; VARYING vec4 vary_position; +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -116,6 +136,10 @@ void main() vec2 refvec3 = distort+refdistort3/dmod_scale; vec4 refcol3 = texture2D(refTex, refvec3); + refcol1.rgb = srgb_to_linear(refcol1.rgb); + refcol2.rgb = srgb_to_linear(refcol2.rgb); + refcol3.rgb = srgb_to_linear(refcol3.rgb); + vec4 refcol = refcol1 + refcol2 + refcol3; float df1 = df.x + df.y + df.z; refcol *= df1 * 0.333; @@ -131,6 +155,9 @@ void main() vec2 refvec4 = distort+refdistort4/dmod; float dweight = min(dist2*blurMultiplier, 1.0); vec4 baseCol = texture2D(refTex, refvec4); + + baseCol.rgb = srgb_to_linear(baseCol.rgb); + refcol = mix(baseCol*df2, refcol, dweight); //get specular component @@ -165,7 +192,7 @@ void main() //wavef = normalize(wavef); vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz; - frag_data[0] = vec4(color.rgb, 0.5); // diffuse + frag_data[0] = vec4(linear_to_srgb(color.rgb), 0.5); // diffuse frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec frag_data[2] = vec4(encode_normal(screenspacewavef), 0.0, 0.0); // normalxyz, displace } -- cgit v1.2.3 From 2c5b265e3988c3d3f036ec9df6bd18bf86fc84f8 Mon Sep 17 00:00:00 2001 From: callum_linden Date: Mon, 15 Jul 2013 16:31:32 -0700 Subject: MAINT-2849 FIX Certain streams that play with FMod do not play with FModEx --- indra/llaudio/llstreamingaudio_fmodex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llaudio/llstreamingaudio_fmodex.cpp b/indra/llaudio/llstreamingaudio_fmodex.cpp index 42f30aa1c4..266fa2f57b 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.cpp +++ b/indra/llaudio/llstreamingaudio_fmodex.cpp @@ -310,7 +310,7 @@ LLAudioStreamManagerFMODEX::LLAudioStreamManagerFMODEX(FMOD::System *system, con { mInternetStreamURL = url; - FMOD_RESULT result = mSystem->createStream(url.c_str(), FMOD_2D | FMOD_NONBLOCKING | FMOD_IGNORETAGS, 0, &mInternetStream); + FMOD_RESULT result = mSystem->createStream(url.c_str(), FMOD_2D | FMOD_NONBLOCKING | FMOD_MPEGSEARCH | FMOD_IGNORETAGS, 0, &mInternetStream); if (result!= FMOD_OK) { -- cgit v1.2.3 From 749eef31fa7b33438e1e110faf584512d75338a4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 15 Jul 2013 17:38:38 -0700 Subject: NORSPEC-265 WIP imposters work in non-deferred and ALM but are forward-only render --- indra/newview/lldrawpoolavatar.cpp | 8 +++++++- indra/newview/pipeline.cpp | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 59c9cf5a83..87e9071c4d 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -681,12 +681,16 @@ void LLDrawPoolAvatar::beginDeferredImpostor() LLVOAvatar::sNumVisibleAvatars = 0; } +#if DEFERRED_IMPOSTORS sVertexProgram = &gDeferredImpostorProgram; specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - +#else + sVertexProgram = &gImpostorProgram; + sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); +#endif sVertexProgram->bind(); sVertexProgram->setMinimumAlpha(0.01f); } @@ -1248,6 +1252,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) if (impostor) { +#if DEFERRED_IMPOSTORS if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && avatarp->mImpostor.isComplete()) { if (normal_channel > -1) @@ -1259,6 +1264,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) avatarp->mImpostor.bindTexture(1, specular_channel); } } +#endif avatarp->renderImpostor(LLColor4U(255,255,255,255), sDiffuseChannel); } return; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ad082b5c74..fc79f1c31f 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -11254,7 +11254,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) S32 occlusion = sUseOcclusion; sUseOcclusion = 0; - sReflectionRender = sRenderDeferred ? FALSE : TRUE; + //sReflectionRender = sRenderDeferred ? FALSE : TRUE; sShadowRender = TRUE; sImpostorRender = TRUE; @@ -11351,25 +11351,27 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) LLFastTimer t(FTM_IMPOSTOR_ALLOCATE); avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,FALSE); +#if DEFERRED_IMPOSTORS if (LLPipeline::sRenderDeferred) { addDeferredAttachments(avatar->mImpostor); } - +#endif + gGL.getTexUnit(0)->bind(&avatar->mImpostor); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } - else if(resX != avatar->mImpostor.getWidth() || - resY != avatar->mImpostor.getHeight()) + else if(resX != avatar->mImpostor.getWidth() || resY != avatar->mImpostor.getHeight()) { LLFastTimer t(FTM_IMPOSTOR_RESIZE); avatar->mImpostor.resize(resX,resY,GL_RGBA); } - avatar->mImpostor.bindTarget(); + avatar->mImpostor.bindTarget(); } +#if DEFERRED_IMPOSTORS if (LLPipeline::sRenderDeferred) { avatar->mImpostor.clear(); @@ -11377,20 +11379,24 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) renderGeomPostDeferred(camera); } else - { +#endif + { LLGLEnable scissor(GL_SCISSOR_TEST); - glScissor(0, 0, resX, resY); + glScissor(0, 0, resX, resY); avatar->mImpostor.clear(); renderGeom(camera); } { //create alpha mask based on depth buffer (grey out if muted) LLFastTimer t(FTM_IMPOSTOR_BACKGROUND); + +#if DEFERRED_IMPOSTORS if (LLPipeline::sRenderDeferred) { GLuint buff = GL_COLOR_ATTACHMENT0; glDrawBuffersARB(1, &buff); } +#endif LLGLDisable blend(GL_BLEND); -- cgit v1.2.3 From d76e6e2337142e3e819fcf757f396b3089e97e71 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 16 Jul 2013 06:10:05 -0700 Subject: NORSPEC-240 make alpha-masked fullbright objs use fullbright alpha mask rendering --- .../shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl | 2 +- indra/newview/llvovolume.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl index 59d109b886..8525e13333 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl @@ -50,7 +50,7 @@ void main() { discard; } - + frag_data[0] = vec4(col.rgb, 0.0); frag_data[1] = vec4(0,0,0,0); vec3 nvn = normalize(vary_normal); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index b545e99a32..8ed6a08aae 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4604,7 +4604,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (mode == LLMaterial::DIFFUSE_ALPHA_MODE_MASK && te->getColor().mV[3] >= 0.999f) { - pool->addRiggedFace(facep, fullbright ? LLDrawPoolAvatar::RIGGED_FULLBRIGHT : LLDrawPoolAvatar::RIGGED_SIMPLE); + pool->addRiggedFace(facep, fullbright ? LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA_MASK : LLDrawPoolAvatar::RIGGED_ALPHA_MASK); } else if (is_alpha || (te->getColor().mV[3] < 0.999f)) { @@ -5390,7 +5390,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: { if (te->getColor().mV[3] >= 0.999f) { - material_pass = true; + registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK); } else { -- cgit v1.2.3 From f0f30c976bba99842cf0451621e14c690ef3ceae Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 16 Jul 2013 06:26:02 -0700 Subject: NORSPEC-240 revert part of change causing regression in non-ALM rendering --- indra/newview/llvovolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8ed6a08aae..3d6c5398d5 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4604,7 +4604,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (mode == LLMaterial::DIFFUSE_ALPHA_MODE_MASK && te->getColor().mV[3] >= 0.999f) { - pool->addRiggedFace(facep, fullbright ? LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA_MASK : LLDrawPoolAvatar::RIGGED_ALPHA_MASK); + pool->addRiggedFace(facep, fullbright ? LLDrawPoolAvatar::RIGGED_FULLBRIGHT : LLDrawPoolAvatar::RIGGED_SIMPLE); } else if (is_alpha || (te->getColor().mV[3] < 0.999f)) { -- cgit v1.2.3 From f618b7d5cc84a83739a8ac6c3eea7d0a7d4f22cd Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 16 Jul 2013 10:25:06 -0700 Subject: NORSPEC-293 WIP fix fullbrightF order of ops to match non-deferred with fullbright+glow+texcolor --- indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index ec25f52ef5..33c07a6e08 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -69,8 +69,8 @@ void main() vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); #endif - color.rgb = srgb_to_linear(color.rgb); color.rgb *= vertex_color.rgb; + color.rgb = srgb_to_linear(color.rgb); color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); -- cgit v1.2.3 From 1587999b0329c76d108fcd1efe2d3fb768043e9e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 16 Jul 2013 12:03:42 -0700 Subject: Add info to vert buffer warnings to track down fullbright alpha mask crasher --- indra/llrender/llvertexbuffer.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 01541026b1..b1ef6e0576 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -2239,7 +2239,32 @@ void LLVertexBuffer::setBuffer(U32 data_mask) if ((data_mask & required_mask) != required_mask) { - llwarns << "Shader consumption mismatches data provision." << llendl; + + U32 unsatisfied_mask = (required_mask & ~data_mask); + U32 i = 0; + + while (i < 15) + { + switch ((unsatisfied_mask & (1 << i))) + { + case MAP_VERTEX: llinfos << "Missing vert pos" << llendl; break; + case MAP_NORMAL: llinfos << "Missing normals" << llendl; break; + case MAP_TEXCOORD0: llinfos << "Missing TC 0" << llendl; break; + case MAP_TEXCOORD1: llinfos << "Missing TC 1" << llendl; break; + case MAP_TEXCOORD2: llinfos << "Missing TC 2" << llendl; break; + case MAP_TEXCOORD3: llinfos << "Missing TC 3" << llendl; break; + case MAP_COLOR: llinfos << "Missing vert color" << llendl; break; + case MAP_EMISSIVE: llinfos << "Missing emissive" << llendl; break; + case MAP_TANGENT: llinfos << "Missing tangent" << llendl; break; + case MAP_WEIGHT: llinfos << "Missing weight" << llendl; break; + case MAP_WEIGHT4: llinfos << "Missing weightx4" << llendl; break; + case MAP_CLOTHWEIGHT: llinfos << "Missing clothweight" << llendl; break; + case MAP_TEXTURE_INDEX: llinfos << "Missing tex index" << llendl; break; + default: llinfos << "Missing who effin knows" << llendl; + } + } + + llerrs << "Shader consumption mismatches data provision." << llendl; } } } -- cgit v1.2.3 From 9aeb3b48d77ce9e22445b4bca23d36f651bb9395 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 17 Jul 2013 08:03:09 -0700 Subject: NORSPEC-291 fix materials underwater, disable attempt at materials in reflect/distort RTs --- .../app_settings/shaders/class1/deferred/waterF.glsl | 2 +- indra/newview/pipeline.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 17288873c8..46d5b9b612 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -192,7 +192,7 @@ void main() //wavef = normalize(wavef); vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz; - frag_data[0] = vec4(linear_to_srgb(color.rgb), 0.5); // diffuse + frag_data[0] = vec4(color.rgb, 0.5); // diffuse frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec frag_data[2] = vec4(encode_normal(screenspacewavef), 0.0, 0.0); // normalxyz, displace } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index fc79f1c31f..d88cb30887 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -122,9 +122,9 @@ //#define DEBUG_INDICES #endif -// Expensive +// Expensive and currently broken // -#define MATERIALS_IN_REFLECTIONS 1 +#define MATERIALS_IN_REFLECTIONS 0 bool gShiftFrame = false; @@ -1236,7 +1236,11 @@ void LLPipeline::createGLBuffers() updateRenderDeferred(); - bool materials_in_water = gSavedSettings.getS32("RenderWaterMaterials"); + bool materials_in_water = false; + +#if MATERIALS_IN_REFLECTIONS + materials_in_water = gSavedSettings.getS32("RenderWaterMaterials"); +#endif if (LLPipeline::sWaterReflections) { //water reflection texture @@ -9685,7 +9689,11 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) water_clip = 1; } - bool materials_in_water = gSavedSettings.getS32("RenderWaterMaterials"); + bool materials_in_water = false; + +#if MATERIALS_IN_REFLECTIONS + materials_in_water = gSavedSettings.getS32("RenderWaterMaterials"); +#endif if (!LLViewerCamera::getInstance()->cameraUnderWater()) { //generate planar reflection map -- cgit v1.2.3 From 0160491f888917d830ca3d827cc1f28f07363fed Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 17 Jul 2013 10:29:02 -0700 Subject: NORSPEC-291 put back conversion to srgb in deferred water shader --- indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 46d5b9b612..17288873c8 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -192,7 +192,7 @@ void main() //wavef = normalize(wavef); vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz; - frag_data[0] = vec4(color.rgb, 0.5); // diffuse + frag_data[0] = vec4(linear_to_srgb(color.rgb), 0.5); // diffuse frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec frag_data[2] = vec4(encode_normal(screenspacewavef), 0.0, 0.0); // normalxyz, displace } -- cgit v1.2.3 From 8712086a4bcf1f0f7527a916baafc9e65667e4e8 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Thu, 18 Jul 2013 06:37:22 -0700 Subject: NORSPEC-314 work-around mystery mac GeForce crash from new shader for nspec 295 --- indra/newview/lldrawpoolsimple.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra') diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index e219769a0c..87fbeaf2c0 100755 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -633,8 +633,15 @@ void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) } else { +#if LL_DARWIN + // the OS X 10.6.8 GeForce driver is a real POS + // this is a work-around for NORSPEC-314 + gObjectFullbrightAlphaMaskProgram.bind(); + gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); +#else gDeferredFullbrightAlphaMaskProgram.bind(); gDeferredFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); +#endif } } @@ -654,7 +661,11 @@ void LLDrawPoolFullbrightAlphaMask::endPostDeferredPass(S32 pass) } else { +#if LL_DARWIN + gObjectFullbrightAlphaMaskProgram.unbind(); +#else gDeferredFullbrightAlphaMaskProgram.unbind(); +#endif } LLRenderPass::endRenderPass(pass); } -- cgit v1.2.3 From 94abe75dea90ee91dd044161d8587279b0bfae13 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 21 Jul 2013 08:15:21 -0700 Subject: NORSPEC-315 NORSPEC-316 NORSPEC-312 fix various haze and gamma correction issues, alpha-blend objects still missing haze underwater --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- .../shaders/class1/deferred/fullbrightAlphaMaskF.glsl | 7 ++++--- .../shaders/class1/deferred/fullbrightF.glsl | 5 +++-- .../app_settings/shaders/class1/deferred/materialF.glsl | 12 ++++++++++++ .../shaders/class1/deferred/softenLightF.glsl | 13 ++++++------- .../app_settings/shaders/class1/deferred/waterF.glsl | 5 ++++- .../shaders/class2/deferred/softenLightF.glsl | 16 +++++++--------- indra/newview/llvovolume.cpp | 3 ++- indra/newview/pipeline.cpp | 4 +++- 9 files changed, 42 insertions(+), 25 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 640e273415..b64852f17b 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -281,7 +281,7 @@ void main() color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; color.rgb = linear_to_srgb(color.rgb); - + //color.rgb = vec3(1,0,1); frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl index 3d93583e1e..a74256de81 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl @@ -71,7 +71,8 @@ void main() vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); #endif - if (color.a < minimum_alpha) + float final_alpha = color.a * vertex_color.a; + if (final_alpha < minimum_alpha) { discard; } @@ -83,8 +84,8 @@ void main() color.rgb = fullbrightScaleSoftClip(color.rgb); color.rgb = linear_to_srgb(color.rgb); - + //color.rgb = vec3(1,0,1); frag_color.rgb = color.rgb; - frag_color.a = color.a; + frag_color.a = final_alpha; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 33c07a6e08..5876efedec 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -69,14 +69,15 @@ void main() vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); #endif - color.rgb *= vertex_color.rgb; + color.rgb = srgb_to_linear(color.rgb); + color.rgb *= vertex_color.rgb; color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); color.rgb = linear_to_srgb(color.rgb); - + //color.rgb = vec3(1,0,1); frag_color.rgb = color.rgb; frag_color.a = color.a; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 9ce4d89df7..954a27b698 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -266,6 +266,13 @@ vec4 getPosition_d(vec2 pos_screen, float depth) return pos; } +#ifndef WATER_FOG +vec3 getPositionEye() +{ + return vary_PositionEye; +} +#endif + vec3 getSunlitColor() { return vary_SunlitColor; @@ -728,6 +735,10 @@ void main() glare = min(glare, 1.0); float al = max(diffcol.a,glare)*vertex_color.a; + + //convert to gamma space for display on screen + col.rgb = linear_to_srgb(col.rgb); + #ifdef WATER_FOG vec4 temp = applyWaterFogDeferred(pos, vec4(col.rgb, al)); col.rgb = temp.rgb; @@ -738,6 +749,7 @@ void main() frag_color.a = al; #else + //final_color.rgb = vec3(1,0,1); frag_data[0] = final_color; frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 953f0189f0..950512a79d 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -436,16 +436,15 @@ void main() if (norm.w < 0.5) { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - - #ifdef WATER_FOG - vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); - col = fogged.rgb; - bloom = fogged.a; - #endif - col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } + #ifdef WATER_FOG + vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + col = srgb_to_linear(col); //col = vec3(1,0,1); diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 17288873c8..7415415290 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -192,7 +192,10 @@ void main() //wavef = normalize(wavef); vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz; - frag_data[0] = vec4(linear_to_srgb(color.rgb), 0.5); // diffuse + // this is needed for materials in reflections, but not otherwise + // + //frag_data[0] = vec4(linear_to_srgb(color.rgb), 0.5); // diffuse + frag_data[0] = vec4(color.rgb, 0.5); // diffuse frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec frag_data[2] = vec4(encode_normal(screenspacewavef), 0.0, 0.0); // normalxyz, displace } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 9b72c5b57d..0c71b4f554 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -455,23 +455,21 @@ void main() if (norm.w < 0.5) { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - - #ifdef WATER_FOG - vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); - col = fogged.rgb; - bloom = fogged.a; - #endif - col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } + #ifdef WATER_FOG + vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + col = srgb_to_linear(col); //col = vec3(1,0,1); //col.g = envIntensity; } - + frag_color.rgb = col; frag_color.a = bloom; } - diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3d6c5398d5..c4b4c76254 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5379,6 +5379,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } bool use_legacy_bump = te->getBumpmap() && (te->getBumpmap() < 18) && (!mat || mat->getNormalID().isNull()); + bool opaque = te->getColor().mV[3] >= 0.999f; if (mat && LLPipeline::sRenderDeferred && !hud_group) { @@ -5388,7 +5389,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: { if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) { - if (te->getColor().mV[3] >= 0.999f) + if (opaque) { registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d88cb30887..d89ad615ae 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -11262,7 +11262,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) S32 occlusion = sUseOcclusion; sUseOcclusion = 0; - //sReflectionRender = sRenderDeferred ? FALSE : TRUE; + + sReflectionRender = sRenderDeferred ? FALSE : TRUE; + sShadowRender = TRUE; sImpostorRender = TRUE; -- cgit v1.2.3 From caefe0e74cf553de41c6c8748dd2ea5ef4d82c06 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 21 Jul 2013 14:28:54 -0700 Subject: NORSPEC-311 fix alpha / opaque lighting diffs --- indra/newview/app_settings/settings.xml | 11 +++ .../shaders/class1/deferred/alphaF.glsl | 56 +++++++++++++- .../class1/deferred/fullbrightAlphaMaskF.glsl | 55 +++++++++++++- .../shaders/class1/deferred/fullbrightF.glsl | 73 +++++++++++++++++- .../shaders/class1/deferred/fullbrightV.glsl | 9 ++- .../class1/deferred/postDeferredGammaCorrect.glsl | 2 +- indra/newview/lldrawpoolalpha.cpp | 14 +++- indra/newview/lldrawpoolsimple.cpp | 48 +++++++++--- indra/newview/llviewershadermgr.cpp | 88 +++++++++++++++++++++- indra/newview/llviewershadermgr.h | 3 + indra/newview/pipeline.cpp | 8 +- 11 files changed, 336 insertions(+), 31 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2d3b32159a..6570189c5b 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8894,6 +8894,17 @@ Value 1.0 + RenderDeferredDisplayGamma + + Comment + Gamma ramp exponent for final correction before display gamma. + Persist + 1 + Type + F32 + Value + 1.8 + RenderGLCoreProfile Comment diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b64852f17b..69b0f8f012 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -136,6 +136,52 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif +#if WATER_FOG +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) +{ + //normalize view vector + vec3 view = normalize(pos); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(pos - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + vec3 srgb_to_linear(vec3 cs) { @@ -240,8 +286,9 @@ void main() vec4 gamma_diff = diff; diff.rgb = srgb_to_linear(diff.rgb); - + #ifdef USE_VERTEX_COLOR + diff.rgb *= vertex_color.rgb; float vertex_color_alpha = vertex_color.a; #else float vertex_color_alpha = 1.0; @@ -266,6 +313,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); color.rgb = srgb_to_linear(color.rgb); + col = vec4(0,0,0,0); #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); @@ -281,7 +329,11 @@ void main() color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; color.rgb = linear_to_srgb(color.rgb); - //color.rgb = vec3(1,0,1); + +#if WATER_FOG + color = applyWaterFogDeferred(pos.xyz, color); +#endif + frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl index a74256de81..00743abe34 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl @@ -61,6 +61,52 @@ vec3 linear_to_srgb(vec3 cl) return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } +#ifdef WATER_FOG +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) +{ + //normalize view vector + vec3 view = normalize(pos); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(pos - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + uniform float minimum_alpha; void main() @@ -72,7 +118,7 @@ void main() #endif float final_alpha = color.a * vertex_color.a; - if (final_alpha < minimum_alpha) + if (color.a < minimum_alpha) { discard; } @@ -84,7 +130,12 @@ void main() color.rgb = fullbrightScaleSoftClip(color.rgb); color.rgb = linear_to_srgb(color.rgb); - //color.rgb = vec3(1,0,1); + + +#ifdef WATER_FOG + color = applyWaterFogDeferred(pos, vec4(color)); +#endif + frag_color.rgb = color.rgb; frag_color.a = final_alpha; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 5876efedec..1e8df68a72 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -35,12 +35,63 @@ out vec4 frag_color; uniform sampler2D diffuseMap; #endif +VARYING vec3 vary_position; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; vec3 fullbrightAtmosTransport(vec3 light); vec3 fullbrightScaleSoftClip(vec3 light); +#if HAS_ALPHA_MASK +uniform float minimum_alpha; +#endif + +#ifdef WATER_FOG +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) +{ + //normalize view vector + vec3 view = normalize(pos); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(pos - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + vec3 srgb_to_linear(vec3 cs) { @@ -69,15 +120,31 @@ void main() vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); #endif + float final_alpha = color.a * vertex_color.a; + +#if HAS_ALPHA_MASK + if (color.a < minimum_alpha) + { + discard; + } +#endif - color.rgb = srgb_to_linear(color.rgb); color.rgb *= vertex_color.rgb; + color.rgb = srgb_to_linear(color.rgb); + color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); - + color.rgb = linear_to_srgb(color.rgb); - //color.rgb = vec3(1,0,1); + +#ifdef WATER_FOG + vec3 pos = vary_position; + vec4 fogged = applyWaterFogDeferred(pos, vec4(color.rgb, final_alpha)); + color.rgb = fogged.rgb; + color.a = fogged.a; +#endif + frag_color.rgb = color.rgb; frag_color.a = color.a; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl index 3f09a15375..22f47b7572 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl @@ -40,6 +40,9 @@ vec3 atmosAffectDirectionalLight(float lightIntensity); vec3 scaleDownLight(vec3 light); vec3 scaleUpLight(vec3 light); +#if WATER_FOG +VARYING vec3 vary_position; +#endif VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -53,7 +56,11 @@ void main() passTextureIndex(); gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); - + +#if WATER_FOG + vary_position = pos.xyz; +#endif + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; calcAtmospherics(pos.xyz); diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index a3610bfffa..59b027a045 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -51,7 +51,7 @@ vec3 linear_to_srgb(vec3 cl) void main() { vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); - diff.rgb = linear_to_srgb(diff.rgb); + diff.rgb = pow(diff.rgb,vec3(texture_gamma)); frag_color = diff; } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index e53c783161..973e263572 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -93,11 +93,21 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) if (pass == 0) { - simple_shader = &gDeferredAlphaProgram; - fullbright_shader = &gObjectFullbrightProgram; + if (LLPipeline::sUnderWaterRender) + { + simple_shader = &gDeferredAlphaWaterProgram; + fullbright_shader = &gDeferredFullbrightWaterProgram; + } + else + { + simple_shader = &gDeferredAlphaProgram; + fullbright_shader = &gDeferredFullbrightProgram; + } + fullbright_shader->bind(); fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); fullbright_shader->unbind(); + //prime simple shader (loads shadow relevant uniforms) gPipeline.bindDeferredShader(*simple_shader); } diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 87fbeaf2c0..d51b84cfbc 100755 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -111,7 +111,14 @@ void LLDrawPoolGlow::render(S32 pass) LLGLSLShader* shader = LLPipeline::sUnderWaterRender ? &gObjectEmissiveWaterProgram : &gObjectEmissiveProgram; shader->bind(); - shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.f); + if (LLPipeline::sRenderDeferred) + { + shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } + else + { + shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.f); + } LLGLDepthTest depth(GL_TRUE, GL_FALSE); gGL.setColorMask(false, true); @@ -536,7 +543,15 @@ void LLDrawPoolFullbright::prerender() void LLDrawPoolFullbright::beginPostDeferredPass(S32 pass) { - gDeferredFullbrightProgram.bind(); + if (LLPipeline::sUnderWaterRender) + { + gDeferredFullbrightWaterProgram.bind(); + } + else + { + gDeferredFullbrightProgram.bind(); + } + } void LLDrawPoolFullbright::renderPostDeferred(S32 pass) @@ -550,7 +565,14 @@ void LLDrawPoolFullbright::renderPostDeferred(S32 pass) void LLDrawPoolFullbright::endPostDeferredPass(S32 pass) { - gDeferredFullbrightProgram.unbind(); + if (LLPipeline::sUnderWaterRender) + { + gDeferredFullbrightWaterProgram.unbind(); + } + else + { + gDeferredFullbrightProgram.unbind(); + } LLRenderPass::endRenderPass(pass); } @@ -633,15 +655,17 @@ void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) } else { -#if LL_DARWIN - // the OS X 10.6.8 GeForce driver is a real POS - // this is a work-around for NORSPEC-314 - gObjectFullbrightAlphaMaskProgram.bind(); - gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); -#else - gDeferredFullbrightAlphaMaskProgram.bind(); - gDeferredFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); -#endif + if (LLPipeline::sUnderWaterRender) + { + gDeferredFullbrightAlphaMaskWaterProgram.bind(); + gDeferredFullbrightAlphaMaskWaterProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } + else + { + gDeferredFullbrightAlphaMaskProgram.bind(); + gDeferredFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } + } } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index e9c3990e9a..f0e4825279 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -197,9 +197,12 @@ LLGLSLShader gDeferredShadowAlphaMaskProgram; LLGLSLShader gDeferredAvatarShadowProgram; LLGLSLShader gDeferredAttachmentShadowProgram; LLGLSLShader gDeferredAlphaProgram; +LLGLSLShader gDeferredAlphaWaterProgram; LLGLSLShader gDeferredAvatarEyesProgram; LLGLSLShader gDeferredFullbrightProgram; LLGLSLShader gDeferredFullbrightAlphaMaskProgram; +LLGLSLShader gDeferredFullbrightWaterProgram; +LLGLSLShader gDeferredFullbrightAlphaMaskWaterProgram; LLGLSLShader gDeferredEmissiveProgram; LLGLSLShader gDeferredPostProgram; LLGLSLShader gDeferredCoFProgram; @@ -301,9 +304,12 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredAlphaProgram); + mShaderList.push_back(&gDeferredAlphaWaterProgram); mShaderList.push_back(&gDeferredSkinnedAlphaProgram); mShaderList.push_back(&gDeferredFullbrightProgram); - mShaderList.push_back(&gDeferredFullbrightAlphaMaskProgram); + mShaderList.push_back(&gDeferredFullbrightAlphaMaskProgram); + mShaderList.push_back(&gDeferredFullbrightWaterProgram); + mShaderList.push_back(&gDeferredFullbrightAlphaMaskWaterProgram); mShaderList.push_back(&gDeferredFullbrightShinyProgram); mShaderList.push_back(&gDeferredSkinnedFullbrightShinyProgram); mShaderList.push_back(&gDeferredSkinnedFullbrightProgram); @@ -1145,8 +1151,11 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarProgram.unload(); gDeferredAvatarAlphaProgram.unload(); gDeferredAlphaProgram.unload(); + gDeferredAlphaWaterProgram.unload(); gDeferredFullbrightProgram.unload(); gDeferredFullbrightAlphaMaskProgram.unload(); + gDeferredFullbrightWaterProgram.unload(); + gDeferredFullbrightAlphaMaskWaterProgram.unload(); gDeferredEmissiveProgram.unload(); gDeferredAvatarEyesProgram.unload(); gDeferredPostProgram.unload(); @@ -1518,7 +1527,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1"); - gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); + //gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); + gDeferredAlphaProgram.addPermutation("WATER_FOG", "0"); gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1529,6 +1539,42 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mFeatures.hasLighting = true; } + if (success) + { + gDeferredAlphaWaterProgram.mName = "Deferred Alpha Underwater Shader"; + gDeferredAlphaWaterProgram.mFeatures.atmosphericHelpers = true; + gDeferredAlphaWaterProgram.mFeatures.calculatesLighting = false; + gDeferredAlphaWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredAlphaWaterProgram.mFeatures.hasGamma = true; + gDeferredAlphaWaterProgram.mFeatures.hasAtmospherics = true; + gDeferredAlphaWaterProgram.mFeatures.hasLighting = false; + gDeferredAlphaWaterProgram.mFeatures.isAlphaLighting = true; + gDeferredAlphaWaterProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels + if (mVertexShaderLevel[SHADER_DEFERRED] < 1) + { + gDeferredAlphaWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + } + else + { //shave off some texture units for shadow maps + gDeferredAlphaWaterProgram.mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); + } + gDeferredAlphaWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gDeferredAlphaWaterProgram.mShaderFiles.clear(); + gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAlphaWaterProgram.addPermutation("USE_INDEXED_TEX", "1"); + //gDeferredAlphaWaterProgram.addPermutation("USE_VERTEX_COLOR", "1"); + gDeferredAlphaWaterProgram.addPermutation("WATER_FOG", "1"); + gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); + gDeferredAlphaWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + + success = gDeferredAlphaWaterProgram.createShader(NULL, NULL); + + // Hack + gDeferredAlphaWaterProgram.mFeatures.calculatesLighting = true; + gDeferredAlphaWaterProgram.mFeatures.hasLighting = true; + } + if (success) { gDeferredAvatarEyesProgram.mName = "Deferred Avatar Eyes Shader"; @@ -1559,18 +1605,52 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { - gDeferredFullbrightAlphaMaskProgram.mName = "Deferred Fullbright Alpha Mask Shader"; + gDeferredFullbrightAlphaMaskProgram.mName = "Deferred Fullbright Alpha Masking Shader"; gDeferredFullbrightAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.hasGamma = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightAlphaMaskProgram.mShaderFiles.clear(); gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredFullbrightAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredFullbrightAlphaMaskProgram.addPermutation("HAS_ALPHA_MASK","1"); success = gDeferredFullbrightAlphaMaskProgram.createShader(NULL, NULL); } + if (success) + { + gDeferredFullbrightWaterProgram.mName = "Deferred Fullbright Underwater Shader"; + gDeferredFullbrightWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredFullbrightWaterProgram.mFeatures.hasGamma = true; + gDeferredFullbrightWaterProgram.mFeatures.hasTransport = true; + gDeferredFullbrightWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + gDeferredFullbrightWaterProgram.mShaderFiles.clear(); + gDeferredFullbrightWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredFullbrightWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredFullbrightWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gDeferredFullbrightWaterProgram.addPermutation("WATER_FOG","1"); + success = gDeferredFullbrightWaterProgram.createShader(NULL, NULL); + } + + if (success) + { + gDeferredFullbrightAlphaMaskWaterProgram.mName = "Deferred Fullbright Underwater Alpha Masking Shader"; + gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasGamma = true; + gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasTransport = true; + gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.clear(); + gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightAlphaMaskWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredFullbrightAlphaMaskWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("HAS_ALPHA_MASK","1"); + gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("WATER_FOG","1"); + success = gDeferredFullbrightAlphaMaskWaterProgram.createShader(NULL, NULL); + } + if (success) { gDeferredFullbrightShinyProgram.mName = "Deferred FullbrightShiny Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index f14180d957..5fa9b82170 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -366,6 +366,9 @@ extern LLGLSLShader gDeferredAttachmentShadowProgram; extern LLGLSLShader gDeferredAlphaProgram; extern LLGLSLShader gDeferredFullbrightProgram; extern LLGLSLShader gDeferredFullbrightAlphaMaskProgram; +extern LLGLSLShader gDeferredAlphaWaterProgram; +extern LLGLSLShader gDeferredFullbrightWaterProgram; +extern LLGLSLShader gDeferredFullbrightAlphaMaskWaterProgram; extern LLGLSLShader gDeferredEmissiveProgram; extern LLGLSLShader gDeferredAvatarEyesProgram; extern LLGLSLShader gDeferredAvatarAlphaProgram; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d89ad615ae..c593c85ce7 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8831,9 +8831,9 @@ void LLPipeline::renderDeferredLighting() gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mScreen.getWidth(), mScreen.getHeight()); - F32 gamma = 1.0/2.2; + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, gamma); + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); @@ -9380,9 +9380,9 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, target->getWidth(), target->getHeight()); - F32 gamma = 1.0/2.2; + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, gamma); + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); -- cgit v1.2.3 From b8e23afe8185b69102d28acdc5905225e1a97914 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 21 Jul 2013 14:33:25 -0700 Subject: NORSPEC-311 NORSPEC-312 remove unused shader and correct default for display gamma exposed in settings --- indra/newview/app_settings/settings.xml | 2 +- .../class1/deferred/fullbrightAlphaMaskF.glsl | 142 --------------------- 2 files changed, 1 insertion(+), 143 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 6570189c5b..830cd33593 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8903,7 +8903,7 @@ Type F32 Value - 1.8 + 2.2 RenderGLCoreProfile diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl deleted file mode 100644 index 00743abe34..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @file fullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -#if !HAS_DIFFUSE_LOOKUP -uniform sampler2D diffuseMap; -#endif - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} - -#ifdef WATER_FOG -uniform vec4 waterPlane; -uniform vec4 waterFogColor; -uniform float waterFogDensity; -uniform float waterFogKS; - -vec4 applyWaterFogDeferred(vec3 pos, vec4 color) -{ - //normalize view vector - vec3 view = normalize(pos); - float es = -(dot(view, waterPlane.xyz)); - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(pos - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; -} -#endif - -uniform float minimum_alpha; - -void main() -{ -#if HAS_DIFFUSE_LOOKUP - vec4 color = diffuseLookup(vary_texcoord0.xy); -#else - vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); -#endif - - float final_alpha = color.a * vertex_color.a; - if (color.a < minimum_alpha) - { - discard; - } - - color.rgb = srgb_to_linear(color.rgb); - color.rgb *= vertex_color.rgb; - - color.rgb = fullbrightAtmosTransport(color.rgb); - color.rgb = fullbrightScaleSoftClip(color.rgb); - - color.rgb = linear_to_srgb(color.rgb); - - -#ifdef WATER_FOG - color = applyWaterFogDeferred(pos, vec4(color)); -#endif - - frag_color.rgb = color.rgb; - frag_color.a = final_alpha; -} - -- cgit v1.2.3 From 710b529372f4d7da699318c4761963ae9dde9a63 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 21 Jul 2013 16:29:05 -0700 Subject: NORSPEC-311 NORSPEC-312 make mac happy with shader ifdefs for haze/masking --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 ++-- indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl | 4 ++-- indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl | 4 ++-- indra/newview/llviewershadermgr.cpp | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 69b0f8f012..69b29269c7 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -136,7 +136,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif -#if WATER_FOG +#ifdef WATER_FOG uniform vec4 waterPlane; uniform vec4 waterFogColor; uniform float waterFogDensity; @@ -330,7 +330,7 @@ void main() color.rgb = linear_to_srgb(color.rgb); -#if WATER_FOG +#ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 1e8df68a72..a6f55dfb46 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -42,7 +42,7 @@ VARYING vec2 vary_texcoord0; vec3 fullbrightAtmosTransport(vec3 light); vec3 fullbrightScaleSoftClip(vec3 light); -#if HAS_ALPHA_MASK +#ifdef HAS_ALPHA_MASK uniform float minimum_alpha; #endif @@ -122,7 +122,7 @@ void main() float final_alpha = color.a * vertex_color.a; -#if HAS_ALPHA_MASK +#ifdef HAS_ALPHA_MASK if (color.a < minimum_alpha) { discard; diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl index 22f47b7572..8e899e3e0f 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl @@ -40,7 +40,7 @@ vec3 atmosAffectDirectionalLight(float lightIntensity); vec3 scaleDownLight(vec3 light); vec3 scaleUpLight(vec3 light); -#if WATER_FOG +#ifdef WATER_FOG VARYING vec3 vary_position; #endif @@ -57,7 +57,7 @@ void main() gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); -#if WATER_FOG +#ifdef WATER_FOG vary_position = pos.xyz; #endif diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index f0e4825279..25f2fbda07 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1528,7 +1528,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1"); //gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); - gDeferredAlphaProgram.addPermutation("WATER_FOG", "0"); gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; -- cgit v1.2.3 From 6f62251a3d29ced4193a9a80965f33fe0318d5a0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 22 Jul 2013 10:29:49 -0700 Subject: MATBUG-306 fix alpha knock-on from underwater lightcurve matching --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 8 ++++---- indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 9 +++------ indra/newview/llviewershadermgr.cpp | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 69b29269c7..2eef99dea7 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -288,8 +288,7 @@ void main() diff.rgb = srgb_to_linear(diff.rgb); #ifdef USE_VERTEX_COLOR - diff.rgb *= vertex_color.rgb; - float vertex_color_alpha = vertex_color.a; + float vertex_color_alpha = diff.a * vertex_color.a; #else float vertex_color_alpha = 1.0; #endif @@ -306,8 +305,9 @@ void main() vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); #endif - vec4 color = gamma_diff * col; - + vec4 color = col; + color.rgb *= gamma_diff.rgb; + color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 7415415290..34189deaad 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -186,16 +186,13 @@ void main() color.rgb = atmosTransport(color.rgb); color.rgb = scaleSoftClip(color.rgb); - //color.a = spec * sunAngle2; + color.a = sunAngle2; //wavef.z *= 0.1f; //wavef = normalize(wavef); vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz; - // this is needed for materials in reflections, but not otherwise - // - //frag_data[0] = vec4(linear_to_srgb(color.rgb), 0.5); // diffuse - frag_data[0] = vec4(color.rgb, 0.5); // diffuse + frag_data[0] = vec4(color.rgb, color.a); // diffuse frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec - frag_data[2] = vec4(encode_normal(screenspacewavef), 0.0, 0.0); // normalxyz, displace + frag_data[2] = vec4(encode_normal(screenspacewavef.xyz*0.5+0.5), screenspacewavef.z * 0.16, 0.0);// normalxyz, env intensity } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 25f2fbda07..8411fd250b 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1527,7 +1527,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1"); - //gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); + gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1562,7 +1562,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaWaterProgram.addPermutation("USE_INDEXED_TEX", "1"); - //gDeferredAlphaWaterProgram.addPermutation("USE_VERTEX_COLOR", "1"); + gDeferredAlphaWaterProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredAlphaWaterProgram.addPermutation("WATER_FOG", "1"); gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); gDeferredAlphaWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; -- cgit v1.2.3 From dcee5fe14f1299f7cbfe535e696ac213e7636bb8 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 22 Jul 2013 15:00:35 -0700 Subject: NORSPEC-320 fix fullbright alpha breakage when not underwater --- indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index a6f55dfb46..a532b67cd9 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -143,6 +143,8 @@ void main() vec4 fogged = applyWaterFogDeferred(pos, vec4(color.rgb, final_alpha)); color.rgb = fogged.rgb; color.a = fogged.a; +#else + color.a = final_alpha; #endif frag_color.rgb = color.rgb; -- cgit v1.2.3 From 3c1b6d6dc0585e695030eefa5bc4998ba8e11683 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 22 Jul 2013 16:47:58 -0700 Subject: NORSPEC-285 NORSPEC-311 fix gamma correction of diffuse-only objects not matching the rest of the sRGB herd --- .../shaders/class1/deferred/diffuseIndexedF.glsl | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index adc361d7a2..997c8d61d3 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -39,15 +39,34 @@ vec2 encode_normal(vec3 n) return n.xy / f + 0.5; } +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} void main() { - vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; + vec3 col = vertex_color.rgb * srgb_to_linear(diffuseLookup(vary_texcoord0.xy).rgb); vec3 spec; spec.rgb = vec3(vertex_color.a); - frag_data[0] = vec4(col, 0.0); + frag_data[0] = vec4(linear_to_srgb(col), 0.0); frag_data[1] = vec4(spec, vertex_color.a); // spec vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0); -- cgit v1.2.3 From 920ca152c662eec12f0e6bcc4fd19feb978e88d4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 22 Jul 2013 20:48:24 -0700 Subject: NORSPEC-314 WIP see if this ruse gets past the decrepit GeForce driver --- .../class1/deferred/fullbrightAlphaMaskF.glsl | 149 +++++++++++++++++++++ .../shaders/class1/deferred/fullbrightF.glsl | 9 -- indra/newview/llviewershadermgr.cpp | 6 +- 3 files changed, 151 insertions(+), 13 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl new file mode 100644 index 0000000000..eb7a95513c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl @@ -0,0 +1,149 @@ +/** + * @file fullbrightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +#extension GL_ARB_texture_rectangle : enable + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +#if !HAS_DIFFUSE_LOOKUP +uniform sampler2D diffuseMap; +#endif + +VARYING vec3 vary_position; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +uniform float minimum_alpha; + +#ifdef WATER_FOG +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) +{ + //normalize view vector + vec3 view = normalize(pos); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(pos - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + +void main() +{ +#if HAS_DIFFUSE_LOOKUP + vec4 color = diffuseLookup(vary_texcoord0.xy); +#else + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); +#endif + + float final_alpha = color.a * vertex_color.a; + + if (color.a < minimum_alpha) + { + discard; + } + + color.rgb *= vertex_color.rgb; + color.rgb = srgb_to_linear(color.rgb); + + + color.rgb = fullbrightAtmosTransport(color.rgb); + color.rgb = fullbrightScaleSoftClip(color.rgb); + + color.rgb = linear_to_srgb(color.rgb); + +#ifdef WATER_FOG + vec3 pos = vary_position; + vec4 fogged = applyWaterFogDeferred(pos, vec4(color.rgb, final_alpha)); + color.rgb = fogged.rgb; + color.a = fogged.a; +#else + color.a = final_alpha; +#endif + + frag_color.rgb = color.rgb; + frag_color.a = color.a; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index a532b67cd9..21349e8c63 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -122,17 +122,8 @@ void main() float final_alpha = color.a * vertex_color.a; -#ifdef HAS_ALPHA_MASK - if (color.a < minimum_alpha) - { - discard; - } -#endif - color.rgb *= vertex_color.rgb; color.rgb = srgb_to_linear(color.rgb); - - color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 8411fd250b..07953c38fb 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1611,9 +1611,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightAlphaMaskProgram.mShaderFiles.clear(); gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredFullbrightAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - gDeferredFullbrightAlphaMaskProgram.addPermutation("HAS_ALPHA_MASK","1"); success = gDeferredFullbrightAlphaMaskProgram.createShader(NULL, NULL); } @@ -1642,10 +1641,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.clear(); gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredFullbrightAlphaMaskWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredFullbrightAlphaMaskWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("HAS_ALPHA_MASK","1"); gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("WATER_FOG","1"); success = gDeferredFullbrightAlphaMaskWaterProgram.createShader(NULL, NULL); } -- cgit v1.2.3 From fa74313e7db1132cd76313864d72aac27902a126 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 04:52:59 -0700 Subject: NORSPEC-314 WIP make work-around easier to flip and add 9800M as an evil mac --- indra/llrender/llgl.cpp | 3 ++- indra/newview/lldrawpoolsimple.cpp | 40 ++++++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 088ba95b75..351fd98ced 100755 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -647,7 +647,8 @@ bool LLGLManager::initGL() } #if LL_DARWIN else if ((mGLRenderer.find("9400M") != std::string::npos) - || (mGLRenderer.find("9600M") != std::string::npos)) + || (mGLRenderer.find("9600M") != std::string::npos) + || (mGLRenderer.find("9800M") != std::string::npos)) { mIsMobileGF = TRUE; } diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index d51b84cfbc..06e8a3537a 100755 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -37,6 +37,7 @@ #include "llviewershadermgr.h" #include "llrender.h" +#define GE_FORCE_WORKAROUND LL_DARWIN static LLGLSLShader* simple_shader = NULL; static LLGLSLShader* fullbright_shader = NULL; @@ -654,7 +655,20 @@ void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); } else - { + { + +#if GE_FORCE_WORKAROUND + // Work-around until we can figure out why the right shader causes + // the GeForce driver to go tango uniform on OS X 10.6.8 only + // + if (gGLManager.mIsMobileGF) + { + gObjectFullbrightAlphaMaskProgram.bind(); + gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + return; + } +#endif + if (LLPipeline::sUnderWaterRender) { gDeferredFullbrightAlphaMaskWaterProgram.bind(); @@ -665,7 +679,6 @@ void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) gDeferredFullbrightAlphaMaskProgram.bind(); gDeferredFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); } - } } @@ -685,11 +698,26 @@ void LLDrawPoolFullbrightAlphaMask::endPostDeferredPass(S32 pass) } else { -#if LL_DARWIN - gObjectFullbrightAlphaMaskProgram.unbind(); -#else - gDeferredFullbrightAlphaMaskProgram.unbind(); + +#if GE_FORCE_WORKAROUND + // Work-around until we can figure out why the right shader causes + // the GeForce driver to go tango uniform on OS X 10.6.8 only + // + if (gGLManager.mIsMobileGF) + { + gObjectFullbrightAlphaMaskProgram.unbind(); + } + else #endif + if (LLPipeline::sUnderWaterRender) + { + gDeferredFullbrightAlphaMaskWaterProgram.unbind(); + } + else + { + gDeferredFullbrightAlphaMaskProgram.unbind(); + } + } LLRenderPass::endRenderPass(pass); } -- cgit v1.2.3 From d8102b2c5c0c925064356006aa7f2f6081fc6852 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 08:37:35 -0700 Subject: NORSPEC-293 hazy glowing fullbright begone --- .../class1/deferred/fullbrightAlphaMaskF.glsl | 149 --------------------- .../shaders/class1/deferred/fullbrightF.glsl | 23 +++- indra/newview/llviewershadermgr.cpp | 6 +- 3 files changed, 23 insertions(+), 155 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl deleted file mode 100644 index eb7a95513c..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl +++ /dev/null @@ -1,149 +0,0 @@ -/** - * @file fullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -#if !HAS_DIFFUSE_LOOKUP -uniform sampler2D diffuseMap; -#endif - -VARYING vec3 vary_position; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -uniform float minimum_alpha; - -#ifdef WATER_FOG -uniform vec4 waterPlane; -uniform vec4 waterFogColor; -uniform float waterFogDensity; -uniform float waterFogKS; - -vec4 applyWaterFogDeferred(vec3 pos, vec4 color) -{ - //normalize view vector - vec3 view = normalize(pos); - float es = -(dot(view, waterPlane.xyz)); - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(pos - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; -} -#endif - -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} - -void main() -{ -#if HAS_DIFFUSE_LOOKUP - vec4 color = diffuseLookup(vary_texcoord0.xy); -#else - vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); -#endif - - float final_alpha = color.a * vertex_color.a; - - if (color.a < minimum_alpha) - { - discard; - } - - color.rgb *= vertex_color.rgb; - color.rgb = srgb_to_linear(color.rgb); - - - color.rgb = fullbrightAtmosTransport(color.rgb); - color.rgb = fullbrightScaleSoftClip(color.rgb); - - color.rgb = linear_to_srgb(color.rgb); - -#ifdef WATER_FOG - vec3 pos = vary_position; - vec4 fogged = applyWaterFogDeferred(pos, vec4(color.rgb, final_alpha)); - color.rgb = fogged.rgb; - color.a = fogged.a; -#else - color.a = final_alpha; -#endif - - frag_color.rgb = color.rgb; - frag_color.a = color.a; -} - diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 21349e8c63..da2585f662 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -39,8 +39,16 @@ VARYING vec3 vary_position; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); +vec3 fullbrightAtmosTransportDeferred(vec3 light) +{ + return light; +} + +vec3 fullbrightScaleSoftClipDeferred(vec3 light) +{ + //soft clip effect: + return light; +} #ifdef HAS_ALPHA_MASK uniform float minimum_alpha; @@ -122,10 +130,17 @@ void main() float final_alpha = color.a * vertex_color.a; +#ifdef HAS_ALPHA_MASK + if (color.a < minimum_alpha) + { + discard; + } +#endif + color.rgb *= vertex_color.rgb; color.rgb = srgb_to_linear(color.rgb); - color.rgb = fullbrightAtmosTransport(color.rgb); - color.rgb = fullbrightScaleSoftClip(color.rgb); + color.rgb = fullbrightAtmosTransportDeferred(color.rgb); + color.rgb = fullbrightScaleSoftClipDeferred(color.rgb); color.rgb = linear_to_srgb(color.rgb); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 07953c38fb..c24284fda2 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1611,7 +1611,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightAlphaMaskProgram.mShaderFiles.clear(); gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("HAS_ALPHA_MASK","1"); gDeferredFullbrightAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredFullbrightAlphaMaskProgram.createShader(NULL, NULL); } @@ -1641,9 +1642,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.clear(); gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredFullbrightAlphaMaskWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredFullbrightAlphaMaskWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("HAS_ALPHA_MASK","1"); gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("WATER_FOG","1"); success = gDeferredFullbrightAlphaMaskWaterProgram.createShader(NULL, NULL); } -- cgit v1.2.3 From 18c7ef32762a6c23fdb1dfe875669fd9ebab0bfe Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 11:36:25 -0700 Subject: Fix regression causing fullbright alpha-masked objects to be opaque --- indra/newview/llviewershadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index c24284fda2..ad29c413e5 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1612,7 +1612,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightAlphaMaskProgram.mShaderFiles.clear(); gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("HAS_ALPHA_MASK","1"); + gDeferredFullbrightAlphaMaskProgram.addPermutation("HAS_ALPHA_MASK","1"); gDeferredFullbrightAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredFullbrightAlphaMaskProgram.createShader(NULL, NULL); } -- cgit v1.2.3 From b411179bd0cffdf02b3109b72c7b79e4f7a5a2e3 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 13:48:57 -0700 Subject: NORSPEC-314 make work-around apply to all Macs for now --- indra/newview/lldrawpoolsimple.cpp | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 06e8a3537a..aee9d19d19 100755 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -657,18 +657,13 @@ void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) else { +// Work-around until we can figure out why the right shader causes +// the GeForce driver to go tango uniform on OS X 10.6.8 only +// #if GE_FORCE_WORKAROUND - // Work-around until we can figure out why the right shader causes - // the GeForce driver to go tango uniform on OS X 10.6.8 only - // - if (gGLManager.mIsMobileGF) - { - gObjectFullbrightAlphaMaskProgram.bind(); - gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); - return; - } -#endif - + gObjectFullbrightAlphaMaskProgram.bind(); + gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); +#else if (LLPipeline::sUnderWaterRender) { gDeferredFullbrightAlphaMaskWaterProgram.bind(); @@ -679,7 +674,9 @@ void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) gDeferredFullbrightAlphaMaskProgram.bind(); gDeferredFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); } +#endif } + } void LLDrawPoolFullbrightAlphaMask::renderPostDeferred(S32 pass) @@ -699,16 +696,12 @@ void LLDrawPoolFullbrightAlphaMask::endPostDeferredPass(S32 pass) else { -#if GE_FORCE_WORKAROUND - // Work-around until we can figure out why the right shader causes - // the GeForce driver to go tango uniform on OS X 10.6.8 only - // - if (gGLManager.mIsMobileGF) - { - gObjectFullbrightAlphaMaskProgram.unbind(); - } - else -#endif +// Work-around until we can figure out why the right shader causes +// the GeForce driver to go tango uniform on OS X 10.6.8 only +// +#if GE_FORCE_WORKAROUND + gObjectFullbrightAlphaMaskProgram.unbind(); +#else if (LLPipeline::sUnderWaterRender) { gDeferredFullbrightAlphaMaskWaterProgram.unbind(); @@ -717,6 +710,7 @@ void LLDrawPoolFullbrightAlphaMask::endPostDeferredPass(S32 pass) { gDeferredFullbrightAlphaMaskProgram.unbind(); } +#endif } LLRenderPass::endRenderPass(pass); -- cgit v1.2.3 From 96869baaefae1f322bff5114429e7fa73b6d4bf9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 14:28:52 -0700 Subject: NORSPEC-285 NORSPEC-298 alpha vs diff color differences --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- .../app_settings/shaders/class1/deferred/diffuseIndexedF.glsl | 4 ++-- indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 2 +- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 2 +- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 8 +++----- 5 files changed, 8 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 2eef99dea7..c8c23c6ce4 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -79,7 +79,7 @@ uniform vec2 screen_res; vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); - a = pow(a, 1.0/1.3); + //a = pow(a, 1.0/1.3); return vec3(a,a,a); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index 997c8d61d3..10b899c91d 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -61,12 +61,12 @@ vec3 linear_to_srgb(vec3 cl) void main() { - vec3 col = vertex_color.rgb * srgb_to_linear(diffuseLookup(vary_texcoord0.xy).rgb); + vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; vec3 spec; spec.rgb = vec3(vertex_color.a); - frag_data[0] = vec4(linear_to_srgb(col), 0.0); + frag_data[0] = vec4(col, 0.0); frag_data[1] = vec4(spec, vertex_color.a); // spec vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 954a27b698..52842c27cc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -672,7 +672,7 @@ void main() col.rgb *= ambient; - col.rgb = col.rgb + atmosAffectDirectionalLight(pow(final_da, 1.0/1.3)); + col.rgb = col.rgb + atmosAffectDirectionalLight(final_da); //pow(final_da, 1.0/1.3)); col.rgb *= old_diffcol.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 950512a79d..1f5cab6cd5 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -378,7 +378,7 @@ void main() norm.xyz = decode_normal(norm.xy); // unpack norm float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - da = pow(da, 1.0/1.3); + //da = pow(da, 1.0/1.3); vec4 diffuse = texture2DRect(diffuseRect, tc); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 0c71b4f554..233985631b 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -385,8 +385,8 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - float light_gamma = 1.0/1.3; - da = pow(da, light_gamma); + //float light_gamma = 1.0/1.3; + //da = pow(da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -400,12 +400,10 @@ void main() vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); + //scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); float scol = max(scol_ambocc.r, diffuse.a); - - float ambocc = scol_ambocc.g; calcAtmospherics(pos.xyz, ambocc); -- cgit v1.2.3 From 72a0ae58e909b017c07e543bc99adc1db5e89180 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 16:09:58 -0700 Subject: NORSPEC-293 fix sRGB to linear conversion to not scrooge the darks --- .../shaders/class1/deferred/alphaF.glsl | 5 +++++ .../shaders/class1/deferred/diffuseIndexedF.glsl | 25 +++------------------- .../shaders/class1/deferred/materialF.glsl | 5 +++++ .../shaders/class1/deferred/softenLightF.glsl | 5 +++++ .../shaders/class2/deferred/softenLightF.glsl | 13 ++++++++--- 5 files changed, 28 insertions(+), 25 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index c8c23c6ce4..b928761358 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -189,6 +189,11 @@ vec3 srgb_to_linear(vec3 cs) cl = { { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + vec3 low_range = cs / vec3(12.92); + + if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) + return low_range; + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index 10b899c91d..6fe34b887a 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -39,34 +39,15 @@ vec2 encode_normal(vec3 n) return n.xy / f + 0.5; } -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} - void main() { - vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; + vec4 diff = diffuseLookup(vary_texcoord0.xy); + vec3 col = vertex_color.rgb * diff.rgb; vec3 spec; spec.rgb = vec3(vertex_color.a); - frag_data[0] = vec4(col, 0.0); + frag_data[0] = vec4(col, 0); frag_data[1] = vec4(spec, vertex_color.a); // spec vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 52842c27cc..e028eef900 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -38,6 +38,11 @@ vec3 srgb_to_linear(vec3 cs) cl = { { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + vec3 low_range = cs / vec3(12.92); + + if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) + return low_range; + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 1f5cab6cd5..6f11e8427c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -86,6 +86,11 @@ vec3 srgb_to_linear(vec3 cs) cl = { { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + vec3 low_range = cs / vec3(12.92); + + if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) + return low_range; + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 233985631b..dbb32c40f4 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -85,6 +85,11 @@ vec3 srgb_to_linear(vec3 cs) cl = { { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + vec3 low_range = cs / vec3(12.92); + + if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) + return low_range; + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); } @@ -420,6 +425,7 @@ void main() col *= diffuse.rgb; + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection @@ -445,11 +451,10 @@ void main() vec3 refcol = textureCube(environmentMap, env_vec).rgb; - col = mix(col.rgb, refcol, - envIntensity); + col = mix(col.rgb, refcol, envIntensity); } - + if (norm.w < 0.5) { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); @@ -462,6 +467,8 @@ void main() bloom = fogged.a; #endif + + col = srgb_to_linear(col); //col = vec3(1,0,1); -- cgit v1.2.3 From e290dd3fa175c2a891cc4f4e0c401edb10cedfb4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 04:03:27 -0700 Subject: NORSPEC-311 make post deferred (alpha objects) respect same gamma ramp as deferred (opaque objects) --- indra/llrender/llshadermgr.cpp | 3 ++- indra/llrender/llshadermgr.h | 3 ++- .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 11 +++++++++-- .../app_settings/shaders/class1/deferred/fullbrightF.glsl | 5 +++++ .../app_settings/shaders/class1/deferred/materialF.glsl | 9 +++++++-- .../shaders/class1/deferred/postDeferredGammaCorrect.glsl | 8 ++++++-- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 9 ++++++--- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 7 +++++-- indra/newview/lldrawpoolalpha.cpp | 5 +++++ indra/newview/pipeline.cpp | 4 ++-- 10 files changed, 49 insertions(+), 15 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index fea4ee2819..942f6dc86f 100755 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1138,7 +1138,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("global_gamma"); mReservedUniforms.push_back("texture_gamma"); - + mReservedUniforms.push_back("display_gamma"); + mReservedUniforms.push_back("specular_color"); mReservedUniforms.push_back("env_intensity"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index c049e935b8..2cbeea5049 100755 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -168,7 +168,8 @@ public: GLOBAL_GAMMA, TEXTURE_GAMMA, - + DISPLAY_GAMMA, + SPECULAR_COLOR, ENVIRONMENT_INTENSITY, diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b928761358..e836e9750f 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,6 +35,8 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +uniform float display_gamma; + #if HAS_SHADOW uniform sampler2DShadow shadowMap0; uniform sampler2DShadow shadowMap1; @@ -204,6 +206,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -295,7 +302,7 @@ void main() #ifdef USE_VERTEX_COLOR float vertex_color_alpha = diff.a * vertex_color.a; #else - float vertex_color_alpha = 1.0; + float vertex_color_alpha = diff.a; #endif vec3 normal = vary_norm; @@ -333,7 +340,7 @@ void main() color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; - color.rgb = linear_to_srgb(color.rgb); + color.rgb = pow(color.rgb,vec3(display_gamma)); #ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index da2585f662..da4ebfea58 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -117,6 +117,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index e028eef900..a46fbd9516 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -53,6 +53,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -701,7 +706,7 @@ void main() col += spec_contrib; } - col = mix(col.rgb, old_diffcol.rgb, diffuse.a); + col = mix(col.rgb, diffcol.rgb, diffuse.a); if (envIntensity > 0.0) { @@ -754,7 +759,7 @@ void main() frag_color.a = al; #else - //final_color.rgb = vec3(1,0,1); + //final_color.rgb = old_diffcol.rgb; frag_data[0] = final_color; frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 59b027a045..01f9d99682 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -36,7 +36,7 @@ uniform sampler2DRect diffuseRect; uniform vec2 screen_res; VARYING vec2 vary_fragcoord; -uniform float texture_gamma; +uniform float display_gamma; vec3 linear_to_srgb(vec3 cl) { @@ -45,13 +45,17 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } void main() { vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); - diff.rgb = pow(diff.rgb,vec3(texture_gamma)); + diff.rgb = pow(diff.rgb,vec3(display_gamma)); frag_color = diff; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 6f11e8427c..045b449bbf 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -101,6 +101,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -403,9 +408,7 @@ void main() ambient = (1.0-ambient); col.rgb *= ambient; - - col += atmosAffectDirectionalLight(max(min(da, 1.0), 0.0)); - + col += atmosAffectDirectionalLight(max(min(da, 1.0), 0.0)); col *= diffuse.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index dbb32c40f4..fa67c4ecea 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -100,6 +100,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -467,8 +472,6 @@ void main() bloom = fogged.a; #endif - - col = srgb_to_linear(col); //col = vec3(1,0,1); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 973e263572..6302cf6b00 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -103,13 +103,18 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) simple_shader = &gDeferredAlphaProgram; fullbright_shader = &gDeferredFullbrightProgram; } + + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); fullbright_shader->bind(); fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + fullbright_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); fullbright_shader->unbind(); //prime simple shader (loads shadow relevant uniforms) gPipeline.bindDeferredShader(*simple_shader); + + simple_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); } else { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c593c85ce7..165b28beb5 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8833,7 +8833,7 @@ void LLPipeline::renderDeferredLighting() F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); @@ -9382,7 +9382,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); -- cgit v1.2.3 From 4854444e24e6e6629d0db30dd107f68535fd086e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 06:11:22 -0700 Subject: MATBUG-315 remove unused uniforms from depth downsample frag shaders as they anger some shader compilers despite not being used --- .../newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl | 2 -- .../app_settings/shaders/class1/interface/downsampleDepthRectF.glsl | 2 -- 2 files changed, 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl index 6523a06d22..f8efd7cb4a 100644 --- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl @@ -31,8 +31,6 @@ out vec4 frag_color; uniform sampler2D depthMap; -uniform float delta; - VARYING vec2 tc0; VARYING vec2 tc1; VARYING vec2 tc2; diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl index 0e5dc08183..942c5888e7 100644 --- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl @@ -33,8 +33,6 @@ out vec4 frag_color; uniform sampler2DRect depthMap; -uniform float delta; - VARYING vec2 tc0; VARYING vec2 tc1; VARYING vec2 tc2; -- cgit v1.2.3 From 7e2c4cd91df9f8d696d77e21e58ba9937977ab3d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 08:26:28 -0700 Subject: NORSPEC-314 fix discrepancies between alpha and non-alpha deferred point/spot atten --- .../shaders/class1/deferred/alphaF.glsl | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e836e9750f..ea6d22d9c2 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -85,7 +85,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) return vec3(a,a,a); } -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -93,7 +93,9 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float //get distance float d = length(lv); - float da = 0.0; + float da = 1.0; + + vec3 col = vec3(0); if (d > 0.0 && la > 0.0 && fa > 0.0) { @@ -102,20 +104,25 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float //distance attenuation float dist = d/la; - da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - da *= da; - da *= 2.0; - + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 //angular attenuation - da *= max(dot(n, lv), 0.0); + da *= max(dot(n, lv), 0.0); + + float lit = max(da * dist_atten,0.0); + + col = light_col * lit * diffuse; + + // no spec for alpha shader... } - return vec3(da,da,da); + return max(col, vec3(0.0,0.0,0.0)); } #if HAS_SHADOW @@ -321,15 +328,12 @@ void main() color.rgb *= gamma_diff.rgb; color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - - color.rgb = srgb_to_linear(color.rgb); col = vec4(0,0,0,0); - #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - + #define LIGHT_LOOP(i) col.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + LIGHT_LOOP(1) LIGHT_LOOP(2) LIGHT_LOOP(3) @@ -338,8 +342,12 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; + // keep it linear + // + color.rgb = srgb_to_linear(color.rgb) + col.rgb; + // ramp directly to display gamma as we're POST-deferred + // color.rgb = pow(color.rgb,vec3(display_gamma)); #ifdef WATER_FOG -- cgit v1.2.3 From d6b4124fb96768aad8840490efa31d9b800cb3ea Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 11:21:40 -0700 Subject: NORSPEC-311 WIP move to per-pixel alpha lighting and make spot/point calcs match more closely --- .../shaders/class1/deferred/alphaF.glsl | 285 ++++++++++++++++++--- .../shaders/class1/deferred/alphaV.glsl | 103 +------- .../shaders/class1/deferred/materialF.glsl | 9 +- .../shaders/class1/deferred/multiSpotLightF.glsl | 2 +- .../shaders/class1/deferred/pointLightF.glsl | 2 +- .../shaders/class1/deferred/spotLightF.glsl | 2 +- .../shaders/class2/deferred/multiSpotLightF.glsl | 2 +- .../shaders/class2/deferred/spotLightF.glsl | 2 +- indra/newview/llviewershadermgr.cpp | 15 -- 9 files changed, 256 insertions(+), 166 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ea6d22d9c2..f4298d2bde 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -36,6 +36,24 @@ out vec4 frag_color; #endif uniform float display_gamma; +uniform vec4 gamma; +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform float haze_horizon; +uniform float haze_density; +uniform float cloud_shadow; +uniform float density_multiplier; +uniform float distance_multiplier; +uniform float max_y; +uniform vec4 glow; +uniform float scene_light_strength; +uniform mat3 env_mat; +uniform mat3 ssao_effect_mat; + +uniform vec3 sun_dir; #if HAS_SHADOW uniform sampler2DShadow shadowMap0; @@ -55,29 +73,26 @@ uniform float shadow_bias; uniform sampler2D diffuseMap; #endif -vec3 atmosLighting(vec3 light); -vec3 scaleSoftClip(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; -VARYING vec3 vary_pointlight_col_linear; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; - -#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; -#endif + +vec3 vary_PositionEye; +vec3 vary_SunlitColor; +vec3 vary_AmblitColor; +vec3 vary_AdditiveColor; +vec3 vary_AtmosAttenuation; + +uniform mat4 inv_proj; +uniform vec2 screen_res; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -uniform vec2 screen_res; - vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -191,6 +206,192 @@ vec4 applyWaterFogDeferred(vec3 pos, vec4 color) } #endif +vec3 getSunlitColor() +{ + return vary_SunlitColor; +} +vec3 getAmblitColor() +{ + return vary_AmblitColor; +} +vec3 getAdditiveColor() +{ + return vary_AdditiveColor; +} +vec3 getAtmosAttenuation() +{ + return vary_AtmosAttenuation; +} + +void setPositionEye(vec3 v) +{ + vary_PositionEye = v; +} + +void setSunlitColor(vec3 v) +{ + vary_SunlitColor = v; +} + +void setAmblitColor(vec3 v) +{ + vary_AmblitColor = v; +} + +void setAdditiveColor(vec3 v) +{ + vary_AdditiveColor = v; +} + +void setAtmosAttenuation(vec3 v) +{ + vary_AtmosAttenuation = v; +} + +void calcAtmospherics(vec3 inPositionEye, float ambFactor) { + + vec3 P = inPositionEye; + setPositionEye(P); + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = sunlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier); + + //final atmosphere attenuation factor + setAtmosAttenuation(temp1.rgb); + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .03); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + //add "minimum anti-solar illumination" + temp2.x += .25; + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; + + /* decrease value and saturation (that in HSV, not HSL) for occluded areas + * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html + * // The following line of code performs the equivalent of: + * float ambAlpha = tmpAmbient.a; + * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis + * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); + * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); + */ + tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); + + //haze color + setAdditiveColor( + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + + tmpAmbient))); + + //brightness of surface both sunlight and ambient + setSunlitColor(vec3(sunlight * .5)); + setAmblitColor(vec3(tmpAmbient * .25)); + setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); +} + +vec3 atmosLighting(vec3 light) +{ + light *= getAtmosAttenuation().r; + light += getAdditiveColor(); + return (2.0 * light); +} + +vec3 atmosTransport(vec3 light) { + light *= getAtmosAttenuation().r; + light += getAdditiveColor() * 2.0; + return light; +} +vec3 atmosGetDiffuseSunlightColor() +{ + return getSunlitColor(); +} + +vec3 scaleDownLight(vec3 light) +{ + return (light / vec3(scene_light_strength, scene_light_strength, scene_light_strength)); +} + +vec3 scaleUpLight(vec3 light) +{ + return (light * vec3(scene_light_strength, scene_light_strength, scene_light_strength)); +} + +vec3 atmosAmbient(vec3 light) +{ + return getAmblitColor() + (light * vec3(0.5f, 0.5f, 0.5f)); +} + +vec3 atmosAffectDirectionalLight(float lightIntensity) +{ + return getSunlitColor() * vec3(lightIntensity, lightIntensity, lightIntensity); +} + +vec3 scaleSoftClip(vec3 light) +{ + //soft clip effect: + vec3 zeroes = vec3(0.0f, 0.0f, 0.0f); + vec3 ones = vec3(1.0f, 1.0f, 1.0f); + + light = ones - clamp(light, zeroes, ones); + light = ones - pow(light, gamma.xxx); + + return light; +} + +vec3 fullbrightAtmosTransport(vec3 light) { + float brightness = dot(light.rgb, vec3(0.33333)); + + return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); +} + +vec3 fullbrightScaleSoftClip(vec3 light) +{ + //soft clip effect: + return light; +} + vec3 srgb_to_linear(vec3 cs) { @@ -229,13 +430,15 @@ void main() vec4 pos = vec4(vary_position, 1.0); + float shadow = 1.0; -#if HAS_SHADOW - float shadow = 0.0; +#if HAS_SHADOW vec4 spos = pos; if (spos.z > -shadow_clip.w) { + shadow = 0.0; + vec4 lpos; vec4 near_split = shadow_clip*-0.75; @@ -294,7 +497,6 @@ void main() { shadow = 1.0; } - #endif #ifdef USE_INDEXED_TEX @@ -303,36 +505,43 @@ void main() vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif vec4 gamma_diff = diff; - - diff.rgb = srgb_to_linear(diff.rgb); -#ifdef USE_VERTEX_COLOR - float vertex_color_alpha = diff.a * vertex_color.a; -#else - float vertex_color_alpha = diff.a; -#endif + diff.rgb = srgb_to_linear(diff.rgb); + diff.rgb *= vertex_color.rgb; + + float final_alpha = diff.a * vertex_color.a; - vec3 normal = vary_norm; + vec3 norm = vary_norm; + + calcAtmospherics(pos.xyz, 1.0); - vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(normal, l); - dlight = dlight * vary_directional.rgb * vary_pointlight_col; + float da =dot(norm.xyz, sun_dir.xyz); + float final_da = da; + final_da = min(final_da, shadow); + final_da = max(final_da, final_alpha); + final_da = max(final_da, 0.0f); -#if HAS_SHADOW - vec4 col = vec4(vary_ambient + dlight * shadow, vertex_color_alpha); -#else - vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); -#endif + vec4 color = vec4(0,0,0,0); - vec4 color = col; + color.rgb = atmosAmbient(color.rgb); + color.a = final_alpha; + + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0-ambient); + + color.rgb *= ambient; + + color.rgb += atmosAffectDirectionalLight(final_da); color.rgb *= gamma_diff.rgb; - color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - - col = vec4(0,0,0,0); + color.rgb = mix(atmosLighting(color.rgb), fullbrightAtmosTransport(color.rgb), diff.a); + color.rgb = mix(scaleSoftClip(color.rgb), fullbrightScaleSoftClip(color.rgb), diff.a); + + vec4 light = vec4(0,0,0,0); - #define LIGHT_LOOP(i) col.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -344,7 +553,7 @@ void main() // keep it linear // - color.rgb = srgb_to_linear(color.rgb) + col.rgb; + color.rgb = srgb_to_linear(color.rgb) + light.rgb; // ramp directly to display gamma as we're POST-deferred // diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index 6b5b54b863..3696234af6 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl @@ -41,10 +41,7 @@ void passTextureIndex(); ATTRIBUTE vec3 normal; -#ifdef USE_VERTEX_COLOR ATTRIBUTE vec4 diffuse_color; -#endif - ATTRIBUTE vec2 texcoord0; #ifdef HAS_SKIN @@ -55,78 +52,14 @@ mat4 getSkinnedTransform(); #endif #endif -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); -void calcAtmospherics(vec3 inPositionEye); - -vec3 atmosAmbient(vec3 light); -vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; -VARYING vec3 vary_pointlight_col_linear; - -#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; -#endif - VARYING vec2 vary_texcoord0; - VARYING vec3 vary_norm; uniform float near_clip; -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -uniform vec3 sun_dir; - -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = dot(lv,lv); - - float da = 0.0; - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - } - - return vec3(da,da,da); -} - void main() { vec4 pos; @@ -179,40 +112,7 @@ void main() vary_norm = norm; vary_position = pos.xyz; - calcAtmospherics(pos.xyz); - -#ifndef USE_VERTEX_COLOR - vec4 diffuse_color = vec4(1,1,1,1); -#endif - //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); - vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - - vec3 diff = diffuse_color.rgb; - - vary_pointlight_col = diff; - vary_pointlight_col_linear = srgb_to_linear(diff); - - col.rgb = vec3(0,0,0); - - // Add windlight lights - col.rgb = atmosAmbient(col.rgb); - - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0-ambient); - - col.rgb *= ambient; - - vary_ambient = col.rgb*diff.rgb; - - vary_directional.rgb = atmosAffectDirectionalLight(1.0f); - - col.rgb = col.rgb*diff.rgb; - -#ifdef USE_VERTEX_COLOR - vertex_color = col; -#endif + vertex_color = diffuse_color; #ifdef HAS_SKIN vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); @@ -228,4 +128,3 @@ void main() #endif } - diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index a46fbd9516..b8c5360486 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -538,7 +538,7 @@ void main() #endif #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - vec3 old_diffcol = diffcol.rgb; + vec3 gamma_diff = diffcol.rgb; diffcol.rgb = srgb_to_linear(diffcol.rgb); #endif @@ -558,7 +558,7 @@ void main() dot(norm.xyz,vary_mat1), dot(norm.xyz,vary_mat2)); #else - vec4 norm = vec4(0,0,0,1.0); + vec4 norm = vec4(0,1,0,1.0); vec3 tnorm = vary_normal; #endif @@ -683,8 +683,7 @@ void main() col.rgb *= ambient; col.rgb = col.rgb + atmosAffectDirectionalLight(final_da); //pow(final_da, 1.0/1.3)); - col.rgb *= old_diffcol.rgb; - + col.rgb *= gamma_diff.rgb; float glare = 0.0; @@ -745,7 +744,6 @@ void main() glare = min(glare, 1.0); float al = max(diffcol.a,glare)*vertex_color.a; - //convert to gamma space for display on screen col.rgb = linear_to_srgb(col.rgb); @@ -759,7 +757,6 @@ void main() frag_color.a = al; #else - //final_color.rgb = old_diffcol.rgb; frag_data[0] = final_color; frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 11220bfa47..3b6724479c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -198,7 +198,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff+1.0; + float fa = falloff; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 106d48bd71..4ca0c35d91 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -115,7 +115,7 @@ void main() float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = falloff+1.0; + float fa = falloff; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 61262c9eb5..53732e961c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -201,7 +201,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff+1.0; + float fa = falloff; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 0aac9d77de..4af0970726 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -207,7 +207,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff+1.0; + float fa = falloff; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 17c0d26f6d..544a0a6730 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -204,7 +204,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff+1.0; + float fa = falloff; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ad29c413e5..4a43a1255a 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1263,9 +1263,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedAlphaProgram.mName = "Deferred Skinned Alpha Shader"; gDeferredSkinnedAlphaProgram.mFeatures.atmosphericHelpers = true; gDeferredSkinnedAlphaProgram.mFeatures.hasObjectSkinning = true; - gDeferredSkinnedAlphaProgram.mFeatures.calculatesAtmospherics = true; - gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true; - gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = false; gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = false; gDeferredSkinnedAlphaProgram.mFeatures.isAlphaLighting = true; @@ -1275,7 +1272,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredSkinnedAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredSkinnedAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1"); - gDeferredSkinnedAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredSkinnedAlphaProgram.addPermutation("HAS_SKIN", "1"); gDeferredSkinnedAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); success = gDeferredSkinnedAlphaProgram.createShader(NULL, NULL); @@ -1508,9 +1504,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mName = "Deferred Alpha Shader"; gDeferredAlphaProgram.mFeatures.atmosphericHelpers = true; gDeferredAlphaProgram.mFeatures.calculatesLighting = false; - gDeferredAlphaProgram.mFeatures.calculatesAtmospherics = true; - gDeferredAlphaProgram.mFeatures.hasGamma = true; - gDeferredAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredAlphaProgram.mFeatures.hasLighting = false; gDeferredAlphaProgram.mFeatures.isAlphaLighting = true; gDeferredAlphaProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels @@ -1527,7 +1520,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1"); - gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1543,9 +1535,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaWaterProgram.mName = "Deferred Alpha Underwater Shader"; gDeferredAlphaWaterProgram.mFeatures.atmosphericHelpers = true; gDeferredAlphaWaterProgram.mFeatures.calculatesLighting = false; - gDeferredAlphaWaterProgram.mFeatures.calculatesAtmospherics = true; - gDeferredAlphaWaterProgram.mFeatures.hasGamma = true; - gDeferredAlphaWaterProgram.mFeatures.hasAtmospherics = true; gDeferredAlphaWaterProgram.mFeatures.hasLighting = false; gDeferredAlphaWaterProgram.mFeatures.isAlphaLighting = true; gDeferredAlphaWaterProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels @@ -1562,7 +1551,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaWaterProgram.addPermutation("USE_INDEXED_TEX", "1"); - gDeferredAlphaWaterProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredAlphaWaterProgram.addPermutation("WATER_FOG", "1"); gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); gDeferredAlphaWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1858,9 +1846,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mFeatures.atmosphericHelpers = true; gDeferredAvatarAlphaProgram.mFeatures.hasSkinning = true; gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = false; - gDeferredAvatarAlphaProgram.mFeatures.calculatesAtmospherics = true; - gDeferredAvatarAlphaProgram.mFeatures.hasGamma = true; - gDeferredAvatarAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredAvatarAlphaProgram.mFeatures.hasLighting = false; gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true; gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true; -- cgit v1.2.3 From e681d19ea678ae378807b2054d33b6b1abcb8b6b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 12:17:39 -0700 Subject: MATBUG-306 regression fix, vert color applied in wrong colorspace --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f4298d2bde..e3be7a52ec 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -504,11 +504,11 @@ void main() #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - vec4 gamma_diff = diff; - - diff.rgb = srgb_to_linear(diff.rgb); diff.rgb *= vertex_color.rgb; + vec4 gamma_diff = diff; + diff.rgb = srgb_to_linear(diff.rgb); + float final_alpha = diff.a * vertex_color.a; vec3 norm = vary_norm; -- cgit v1.2.3 From e21ab706b93229964e59fa1d4c221ead30983486 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 15:43:38 -0700 Subject: NORSPEC-324 when using display_gamma, actually set display_gamma --- indra/newview/lldrawpoolavatar.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra') diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 87e9071c4d..b6eee124e1 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -49,6 +49,7 @@ #include "llappviewer.h" #include "llrendersphere.h" #include "llviewerpartsim.h" +#include "llviewercontrol.h" // for gSavedSettings static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK; static U32 sBufferUsage = GL_STREAM_DRAW_ARB; @@ -281,6 +282,11 @@ void LLDrawPoolAvatar::beginDeferredRiggedAlpha() { sVertexProgram = &gDeferredSkinnedAlphaProgram; gPipeline.bindDeferredShader(*sVertexProgram); + + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gPipeline.enableLightsDynamic(); } @@ -890,6 +896,8 @@ void LLDrawPoolAvatar::beginRiggedGlow() sVertexProgram->bind(); sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, LLPipeline::sRenderDeferred ? 2.2f : 1.1f); + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); } } @@ -942,6 +950,9 @@ void LLDrawPoolAvatar::beginRiggedFullbright() else { sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); } } } @@ -1043,6 +1054,8 @@ void LLDrawPoolAvatar::beginRiggedFullbrightShiny() else { sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); } } } -- cgit v1.2.3 From 24cef8d36b13c02ec06c58cc66d9bce040891069 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 17:43:56 -0700 Subject: NORSPEC-326 eliminate identity theft causing mac nV mobile shader compilation fail --- indra/newview/llviewershadermgr.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 4a43a1255a..1ea176565b 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1261,7 +1261,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredSkinnedAlphaProgram.mName = "Deferred Skinned Alpha Shader"; - gDeferredSkinnedAlphaProgram.mFeatures.atmosphericHelpers = true; gDeferredSkinnedAlphaProgram.mFeatures.hasObjectSkinning = true; gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = false; gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = false; @@ -1502,7 +1501,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredAlphaProgram.mName = "Deferred Alpha Shader"; - gDeferredAlphaProgram.mFeatures.atmosphericHelpers = true; + gDeferredAlphaProgram.mFeatures.calculatesLighting = false; gDeferredAlphaProgram.mFeatures.hasLighting = false; gDeferredAlphaProgram.mFeatures.isAlphaLighting = true; @@ -1533,7 +1532,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredAlphaWaterProgram.mName = "Deferred Alpha Underwater Shader"; - gDeferredAlphaWaterProgram.mFeatures.atmosphericHelpers = true; gDeferredAlphaWaterProgram.mFeatures.calculatesLighting = false; gDeferredAlphaWaterProgram.mFeatures.hasLighting = false; gDeferredAlphaWaterProgram.mFeatures.isAlphaLighting = true; @@ -1843,7 +1841,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredAvatarAlphaProgram.mName = "Avatar Alpha Shader"; - gDeferredAvatarAlphaProgram.mFeatures.atmosphericHelpers = true; gDeferredAvatarAlphaProgram.mFeatures.hasSkinning = true; gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = false; gDeferredAvatarAlphaProgram.mFeatures.hasLighting = false; -- cgit v1.2.3 From f357269c38a8627aeb67c82c5ee34b49336e0d8b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 25 Jul 2013 09:36:13 -0700 Subject: NORSPEC-325 WIP restore gamma (uncorrected) attenuation and unify sRGB conversion in one place --- indra/llrender/llglslshader.cpp | 1 + indra/llrender/llglslshader.h | 1 + indra/llrender/llshadermgr.cpp | 13 +++++- indra/llrender/llshadermgr.h | 5 ++- .../shaders/class1/deferred/alphaF.glsl | 38 +++-------------- .../shaders/class1/deferred/diffuseIndexedF.glsl | 6 +-- .../shaders/class1/deferred/fullbrightF.glsl | 28 ++----------- .../shaders/class1/deferred/materialF.glsl | 45 ++++---------------- .../shaders/class1/deferred/multiSpotLightF.glsl | 23 ++-------- .../shaders/class1/deferred/pointLightF.glsl | 2 +- .../class1/deferred/postDeferredGammaCorrect.glsl | 14 +------ .../shaders/class1/deferred/softenLightF.glsl | 38 +++-------------- .../shaders/class1/deferred/spotLightF.glsl | 23 ++-------- .../app_settings/shaders/class1/deferred/srgb.glsl | 49 ++++++++++++++++++++++ .../shaders/class1/deferred/underWaterF.glsl | 21 +--------- .../shaders/class1/deferred/waterF.glsl | 21 +--------- .../shaders/class2/deferred/multiSpotLightF.glsl | 16 ++----- .../shaders/class2/deferred/softenLightF.glsl | 43 ++++--------------- .../shaders/class2/deferred/spotLightF.glsl | 13 ++---- indra/newview/llviewershadermgr.cpp | 23 +++++++++- 20 files changed, 139 insertions(+), 284 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/deferred/srgb.glsl (limited to 'indra') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index ac16e30796..b854218e3d 100755 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -87,6 +87,7 @@ LLShaderFeatures::LLShaderFeatures() , mIndexedTextureChannels(0) , disableTextureIndex(false) , hasAlphaMask(false) + , hasSRGB(false) { } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index eabdb9fc92..dadffeb6c4 100755 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -50,6 +50,7 @@ public: S32 mIndexedTextureChannels; bool disableTextureIndex; bool hasAlphaMask; + bool hasSRGB; // char numLights; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 942f6dc86f..c3e76f5e0e 100755 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -175,6 +175,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) // Attach Fragment Shader Features Next /////////////////////////////////////// + if (features->hasSRGB) + { + if (!shader->attachObject("deferred/srgb.glsl")) + { + return FALSE; + } + } + if(features->calculatesAtmospherics) { if (features->hasWaterFog) @@ -1137,12 +1145,13 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("projectionMap"); mReservedUniforms.push_back("global_gamma"); - mReservedUniforms.push_back("texture_gamma"); - mReservedUniforms.push_back("display_gamma"); + mReservedUniforms.push_back("texture_gamma"); mReservedUniforms.push_back("specular_color"); mReservedUniforms.push_back("env_intensity"); + mReservedUniforms.push_back("display_gamma"); + llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); std::set dupe_check; diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 2cbeea5049..3c282bf24f 100755 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -167,12 +167,13 @@ public: DEFERRED_PROJECTION, GLOBAL_GAMMA, - TEXTURE_GAMMA, - DISPLAY_GAMMA, + TEXTURE_GAMMA, SPECULAR_COLOR, ENVIRONMENT_INTENSITY, + DISPLAY_GAMMA, + END_RESERVED_UNIFORMS } eGLSLReservedUniforms; diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e3be7a52ec..075699c591 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -93,10 +93,13 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); - //a = pow(a, 1.0/1.3); + a = pow(a, 1.0/1.3); return vec3(a,a,a); } @@ -392,37 +395,6 @@ vec3 fullbrightScaleSoftClip(vec3 light) return light; } -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - vec3 low_range = cs / vec3(12.92); - - if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) - return low_range; - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} - - void main() { vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; @@ -533,7 +505,7 @@ void main() color.rgb *= ambient; - color.rgb += atmosAffectDirectionalLight(final_da); + color.rgb += atmosAffectDirectionalLight(pow(final_da, 1.0/1.3)); color.rgb *= gamma_diff.rgb; color.rgb = mix(atmosLighting(color.rgb), fullbrightAtmosTransport(color.rgb), diff.a); diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index 6fe34b887a..adc361d7a2 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -39,15 +39,15 @@ vec2 encode_normal(vec3 n) return n.xy / f + 0.5; } + void main() { - vec4 diff = diffuseLookup(vary_texcoord0.xy); - vec3 col = vertex_color.rgb * diff.rgb; + vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; vec3 spec; spec.rgb = vec3(vertex_color.a); - frag_data[0] = vec4(col, 0); + frag_data[0] = vec4(col, 0.0); frag_data[1] = vec4(spec, vertex_color.a); // spec vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index da4ebfea58..00548ea826 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -39,6 +39,9 @@ VARYING vec3 vary_position; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + vec3 fullbrightAtmosTransportDeferred(vec3 light) { return light; @@ -100,31 +103,6 @@ vec4 applyWaterFogDeferred(vec3 pos, vec4 color) } #endif -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} - void main() { #if HAS_DIFFUSE_LOOKUP diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index b8c5360486..d3bd55da7a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -30,37 +30,6 @@ uniform float emissive_brightness; - -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - vec3 low_range = cs / vec3(12.92); - - if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) - return low_range; - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} - #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) #ifdef DEFINE_GL_FRAGCOLOR @@ -145,6 +114,9 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + #ifdef WATER_FOG uniform vec4 waterPlane; uniform vec4 waterFogColor; @@ -558,7 +530,7 @@ void main() dot(norm.xyz,vary_mat1), dot(norm.xyz,vary_mat2)); #else - vec4 norm = vec4(0,1,0,1.0); + vec4 norm = vec4(0,0,0,1.0); vec3 tnorm = vary_normal; #endif @@ -682,7 +654,7 @@ void main() col.rgb *= ambient; - col.rgb = col.rgb + atmosAffectDirectionalLight(final_da); //pow(final_da, 1.0/1.3)); + col.rgb = col.rgb + atmosAffectDirectionalLight(pow(final_da, 1.0/1.3)); col.rgb *= gamma_diff.rgb; float glare = 0.0; @@ -705,7 +677,7 @@ void main() col += spec_contrib; } - col = mix(col.rgb, diffcol.rgb, diffuse.a); + col = mix(col.rgb, gamma_diff.rgb, diffuse.a); if (envIntensity > 0.0) { @@ -724,11 +696,11 @@ void main() } col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); //convert to linear space before adding local lights col = srgb_to_linear(col); - + vec3 npos = normalize(-pos.xyz); #define LIGHT_LOOP(i) col.rgb = col.rgb + calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare); @@ -747,6 +719,7 @@ void main() //convert to gamma space for display on screen col.rgb = linear_to_srgb(col.rgb); + #ifdef WATER_FOG vec4 temp = applyWaterFogDeferred(pos, vec4(col.rgb, al)); col.rgb = temp.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 3b6724479c..0b62c4ec09 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -84,25 +84,8 @@ vec3 decode_normal (vec2 enc) return n; } -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { @@ -198,7 +181,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff; + float fa = falloff+1.0; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 4ca0c35d91..106d48bd71 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -115,7 +115,7 @@ void main() float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = falloff; + float fa = falloff+1.0; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 01f9d99682..89530f4082 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -38,19 +38,7 @@ VARYING vec2 vary_fragcoord; uniform float display_gamma; -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} +vec3 linear_to_srgb(vec3 cl); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 045b449bbf..39d613e02b 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -78,37 +78,8 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; - -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - vec3 low_range = cs / vec3(12.92); - - if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) - return low_range; - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} - +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec3 decode_normal (vec2 enc) { @@ -143,7 +114,6 @@ vec3 getPositionEye() { return vary_PositionEye; } - vec3 getSunlitColor() { return vary_SunlitColor; @@ -388,7 +358,7 @@ void main() norm.xyz = decode_normal(norm.xy); // unpack norm float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - //da = pow(da, 1.0/1.3); + da = pow(da, 1.0/1.3); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -408,7 +378,9 @@ void main() ambient = (1.0-ambient); col.rgb *= ambient; + col += atmosAffectDirectionalLight(max(min(da, 1.0), 0.0)); + col *= diffuse.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 53732e961c..251abfd119 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -82,25 +82,8 @@ vec3 decode_normal (vec2 enc) return n; } -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec4 correctWithGamma(vec4 col) { @@ -201,7 +184,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff; + float fa = falloff+1.0; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl new file mode 100644 index 0000000000..177f6c25f8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl @@ -0,0 +1,49 @@ +/** + * @file srgb.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + return mix(high_range, low_range, lessThanEqual(cs,vec3(0.04045))); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /* { 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + return mix(high_range, low_range, lessThan(cl,vec3(0.0031308))); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl index 938947bbce..858c3a1fe9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl @@ -56,25 +56,8 @@ VARYING vec4 refCoord; VARYING vec4 littleWave; VARYING vec4 view; -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec2 encode_normal(vec3 n) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 34189deaad..5538c41d1c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -67,25 +67,8 @@ VARYING vec4 littleWave; VARYING vec4 view; VARYING vec4 vary_position; -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec2 encode_normal(vec3 n) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 4af0970726..6d1cedee39 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -68,6 +68,9 @@ uniform vec2 screen_res; uniform mat4 inv_proj; +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -85,22 +88,11 @@ vec3 decode_normal (vec2 enc) return n; } -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - vec4 correctWithGamma(vec4 col) { return vec4(srgb_to_linear(col.rgb), col.a); } - vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); @@ -207,7 +199,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff; + float fa = falloff+1.0; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index fa67c4ecea..db2faa65d7 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,35 +78,8 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - vec3 low_range = cs / vec3(12.92); - - if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) - return low_range; - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec2 encode_normal(vec3 n) { @@ -395,8 +368,8 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - //float light_gamma = 1.0/1.3; - //da = pow(da, light_gamma); + float light_gamma = 1.0/1.3; + da = pow(da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -410,10 +383,12 @@ void main() vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - //scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); + scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); float scol = max(scol_ambocc.r, diffuse.a); + + float ambocc = scol_ambocc.g; calcAtmospherics(pos.xyz, ambocc); @@ -430,7 +405,6 @@ void main() col *= diffuse.rgb; - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection @@ -456,7 +430,8 @@ void main() vec3 refcol = textureCube(environmentMap, env_vec).rgb; - col = mix(col.rgb, refcol, envIntensity); + col = mix(col.rgb, refcol, + envIntensity); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 544a0a6730..cfb483ab54 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -85,15 +85,8 @@ vec3 decode_normal (vec2 enc) return n; } -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec4 correctWithGamma(vec4 col) { @@ -204,7 +197,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff; + float fa = falloff+1.0; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 1ea176565b..aa3d2f8349 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -911,6 +911,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/transportF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "environment/waterFogF.glsl", mVertexShaderLevel[SHADER_WATER] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/srgb.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); @@ -1185,7 +1186,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { - gDeferredDiffuseProgram.mName = "Deferred Diffuse Shader"; + gDeferredDiffuseProgram.mName = "Deferred Diffuse Shader"; gDeferredDiffuseProgram.mShaderFiles.clear(); gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1261,6 +1262,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredSkinnedAlphaProgram.mName = "Deferred Skinned Alpha Shader"; + gDeferredSkinnedAlphaProgram.mFeatures.hasSRGB = true; gDeferredSkinnedAlphaProgram.mFeatures.hasObjectSkinning = true; gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = false; gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = false; @@ -1317,6 +1319,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() U32 alpha_mode = i & 0x3; gDeferredMaterialProgram[i].mShaderFiles.clear(); + gDeferredMaterialProgram[i].mFeatures.hasSRGB = true; gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMaterialProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1342,6 +1345,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() U32 alpha_mode = i & 0x3; gDeferredMaterialWaterProgram[i].mShaderFiles.clear(); + gDeferredMaterialWaterProgram[i].mFeatures.hasSRGB = true; gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMaterialWaterProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1430,6 +1434,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i); gDeferredMultiLightProgram[i].mShaderFiles.clear(); + gDeferredMultiLightProgram[i].mFeatures.hasSRGB = true; gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMultiLightProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1442,6 +1447,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredSpotLightProgram.mName = "Deferred SpotLight Shader"; gDeferredSpotLightProgram.mShaderFiles.clear(); + gDeferredSpotLightProgram.mFeatures.hasSRGB = true; gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1453,6 +1459,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredMultiSpotLightProgram.mName = "Deferred MultiSpotLight Shader"; gDeferredMultiSpotLightProgram.mShaderFiles.clear(); + gDeferredMultiSpotLightProgram.mFeatures.hasSRGB = true; gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMultiSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1502,6 +1509,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredAlphaProgram.mName = "Deferred Alpha Shader"; + gDeferredAlphaProgram.mFeatures.hasSRGB = true; gDeferredAlphaProgram.mFeatures.calculatesLighting = false; gDeferredAlphaProgram.mFeatures.hasLighting = false; gDeferredAlphaProgram.mFeatures.isAlphaLighting = true; @@ -1532,6 +1540,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredAlphaWaterProgram.mName = "Deferred Alpha Underwater Shader"; + gDeferredAlphaWaterProgram.mFeatures.hasSRGB = true; gDeferredAlphaWaterProgram.mFeatures.calculatesLighting = false; gDeferredAlphaWaterProgram.mFeatures.hasLighting = false; gDeferredAlphaWaterProgram.mFeatures.isAlphaLighting = true; @@ -1577,6 +1586,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredFullbrightProgram.mName = "Deferred Fullbright Shader"; + gDeferredFullbrightProgram.mFeatures.hasSRGB = true; gDeferredFullbrightProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightProgram.mFeatures.hasGamma = true; gDeferredFullbrightProgram.mFeatures.hasTransport = true; @@ -1591,6 +1601,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredFullbrightAlphaMaskProgram.mName = "Deferred Fullbright Alpha Masking Shader"; + gDeferredFullbrightAlphaMaskProgram.mFeatures.hasSRGB = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.hasGamma = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; @@ -1606,6 +1617,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredFullbrightWaterProgram.mName = "Deferred Fullbright Underwater Shader"; + gDeferredFullbrightWaterProgram.mFeatures.hasSRGB = true; gDeferredFullbrightWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightWaterProgram.mFeatures.hasGamma = true; gDeferredFullbrightWaterProgram.mFeatures.hasTransport = true; @@ -1622,6 +1634,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredFullbrightAlphaMaskWaterProgram.mName = "Deferred Fullbright Underwater Alpha Masking Shader"; + gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasSRGB = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasGamma = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasTransport = true; @@ -1653,6 +1666,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredSkinnedFullbrightProgram.mName = "Skinned Fullbright Shader"; + gDeferredSkinnedFullbrightProgram.mFeatures.hasSRGB = true; gDeferredSkinnedFullbrightProgram.mFeatures.calculatesAtmospherics = true; gDeferredSkinnedFullbrightProgram.mFeatures.hasGamma = true; gDeferredSkinnedFullbrightProgram.mFeatures.hasTransport = true; @@ -1698,6 +1712,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { // load water shader gDeferredWaterProgram.mName = "Deferred Water Shader"; + gDeferredWaterProgram.mFeatures.hasSRGB = true; gDeferredWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredWaterProgram.mFeatures.hasGamma = true; gDeferredWaterProgram.mFeatures.hasTransport = true; @@ -1712,6 +1727,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { // load water shader gDeferredUnderWaterProgram.mName = "Deferred Under Water Shader"; + gDeferredUnderWaterProgram.mFeatures.hasSRGB = true; gDeferredUnderWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredUnderWaterProgram.mFeatures.hasGamma = true; gDeferredUnderWaterProgram.mFeatures.hasTransport = true; @@ -1726,6 +1742,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredSoftenProgram.mName = "Deferred Soften Shader"; gDeferredSoftenProgram.mShaderFiles.clear(); + gDeferredSoftenProgram.mFeatures.hasSRGB = true; gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1743,7 +1760,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredSoftenWaterProgram.mName = "Deferred Soften Underwater Shader"; gDeferredSoftenWaterProgram.mShaderFiles.clear(); - + gDeferredSoftenWaterProgram.mFeatures.hasSRGB = true; gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1841,6 +1858,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredAvatarAlphaProgram.mName = "Avatar Alpha Shader"; + gDeferredAvatarAlphaProgram.mFeatures.hasSRGB = true; gDeferredAvatarAlphaProgram.mFeatures.hasSkinning = true; gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = false; gDeferredAvatarAlphaProgram.mFeatures.hasLighting = false; @@ -1864,6 +1882,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredPostGammaCorrectProgram.mName = "Deferred Gamma Correction Post Process"; gDeferredPostGammaCorrectProgram.mShaderFiles.clear(); + gDeferredPostGammaCorrectProgram.mFeatures.hasSRGB = true; gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrect.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredPostGammaCorrectProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; -- cgit v1.2.3 From 6d21cd2ae1e8a32ccaf750a97199407fb1cacdef Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 25 Jul 2013 11:09:45 -0700 Subject: NORSPEC-324 set gamma value for avatar alpha shader too for gamma correct eyelashes --- indra/newview/lldrawpoolavatar.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra') diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index b6eee124e1..e2a23ef56f 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -273,6 +273,9 @@ void LLDrawPoolAvatar::beginPostDeferredAlpha() gPipeline.bindDeferredShader(*sVertexProgram); + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + sVertexProgram->setMinimumAlpha(0.2f); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); -- cgit v1.2.3 From 3045dd6c5113d03fd0b0453ce916fc2a1c27c4e0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 25 Jul 2013 12:13:21 -0700 Subject: Make use of vertex_color selectable per shader with alphaF/alphaV again --- .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 11 +++++++++-- .../newview/app_settings/shaders/class1/deferred/alphaV.glsl | 11 ++++++++++- indra/newview/llviewershadermgr.cpp | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 075699c591..52858f45f4 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -77,7 +77,10 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; + +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; +#endif vec3 vary_PositionEye; vec3 vary_SunlitColor; @@ -476,13 +479,17 @@ void main() #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif + +#ifdef USE_VERTEX_COLOR + float final_alpha = diff.a * vertex_color.a; diff.rgb *= vertex_color.rgb; +#else + float final_alpha = diff.a; +#endif vec4 gamma_diff = diff; diff.rgb = srgb_to_linear(diff.rgb); - float final_alpha = diff.a * vertex_color.a; - vec3 norm = vary_norm; calcAtmospherics(pos.xyz, 1.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index 3696234af6..60d414f2ff 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl @@ -41,7 +41,10 @@ void passTextureIndex(); ATTRIBUTE vec3 normal; +#ifdef USE_VERTEX_COLOR ATTRIBUTE vec4 diffuse_color; +#endif + ATTRIBUTE vec2 texcoord0; #ifdef HAS_SKIN @@ -54,7 +57,11 @@ mat4 getSkinnedTransform(); VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; + +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; +#endif + VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; @@ -112,8 +119,10 @@ void main() vary_norm = norm; vary_position = pos.xyz; +#ifdef USE_VERTEX_COLOR vertex_color = diffuse_color; - +#endif + #ifdef HAS_SKIN vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); #else diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index aa3d2f8349..f17e88f312 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1274,6 +1274,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredSkinnedAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1"); gDeferredSkinnedAlphaProgram.addPermutation("HAS_SKIN", "1"); + gDeferredSkinnedAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredSkinnedAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); success = gDeferredSkinnedAlphaProgram.createShader(NULL, NULL); @@ -1528,6 +1529,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1"); gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); + gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; success = gDeferredAlphaProgram.createShader(NULL, NULL); @@ -1559,6 +1561,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredAlphaWaterProgram.addPermutation("USE_INDEXED_TEX", "1"); gDeferredAlphaWaterProgram.addPermutation("WATER_FOG", "1"); + gDeferredAlphaWaterProgram.addPermutation("USE_VERTEX_COLOR", "1"); gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); gDeferredAlphaWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; -- cgit v1.2.3 From 73703191e0fc91e022d01c91740c1deade8cbaf5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 26 Jul 2013 12:44:05 -0700 Subject: NORSPEC-327 modify 'select' ops in srgb shader code to mollify the doddering mac GLSL compiler --- .../app_settings/shaders/class1/deferred/srgb.glsl | 24 ++++++++++++++++++++++ indra/newview/llviewershadermgr.cpp | 9 +++++++- 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl index 177f6c25f8..d532835bf1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +// OLD_SELECT work-around missing mix(vec3,vec,bvec3) in older GLSL versions (*cough* MAC *cough*) + vec3 srgb_to_linear(vec3 cs) { @@ -32,7 +34,17 @@ vec3 srgb_to_linear(vec3 cs) vec3 low_range = cs / vec3(12.92); vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else return mix(high_range, low_range, lessThanEqual(cs,vec3(0.04045))); +#endif } vec3 linear_to_srgb(vec3 cl) @@ -45,5 +57,17 @@ vec3 linear_to_srgb(vec3 cl) cl = clamp(cl, vec3(0), vec3(1)); vec3 low_range = cl * 12.92; vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else return mix(high_range, low_range, lessThan(cl,vec3(0.0031308))); +#endif } + diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index f17e88f312..6e2139ea9e 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -911,7 +911,6 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/transportF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "environment/waterFogF.glsl", mVertexShaderLevel[SHADER_WATER] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/srgb.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); @@ -937,6 +936,14 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/srgb.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) ); + +// work-around for missing mix(vec3,vec3,bvec3) on decrepit GLSLs +// +#if LL_DARWIN + attribs["OLD_SELECT"] = "1"; +#endif + for (U32 i = 0; i < shaders.size(); i++) { // Note usage of GL_FRAGMENT_SHADER_ARB -- cgit v1.2.3 From 0f5dbc1935b17d41b98d26f550cf67d3faa69dce Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sun, 28 Jul 2013 14:03:56 -0700 Subject: NORSPEC-314 fix the fullbright alpha mask logic --- indra/newview/llvovolume.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c4b4c76254..406591046f 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5385,7 +5385,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: { bool material_pass = false; - if (fullbright) + // do NOT use 'fullbright' for this logic or you risk sending + // things without normals down the materials pipeline and will + // render poorly if not crash NORSPEC-240,314 + // + if (te->getFullbright()) { if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK) { -- cgit v1.2.3 From c5fc5d9b46121bb0d44d3b35402d604514e2dd4e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 28 Jul 2013 15:43:10 -0700 Subject: NORSPEC-323 fix norm/tangent gen for prim caps --- indra/llmath/llvolume.cpp | 253 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 202 insertions(+), 51 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 58cac57e7f..b90830ddd8 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -94,6 +94,16 @@ const S32 SCULPT_MIN_AREA_DETAIL = 1; extern BOOL gDebugGL; +void calc_tangent_from_triangle( + LLVector4a& normal, + LLVector4a& tangent_out, + const LLVector4a& v1, + const LLVector2& w1, + const LLVector4a& v2, + const LLVector2& w2, + const LLVector4a& v3, + const LLVector2& w3); + BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm) { LLVector3 test = (pt2-pt1)%(pt3-pt2); @@ -1594,7 +1604,7 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, S32 sides = (S32)llfloor(llfloor((MIN_DETAIL_FACES * detail + twist_mag * 3.5f * (detail-0.5f))) * params.getRevolutions()); if (is_sculpted) - sides = llmax(sculpt_size, 1); + sides = llmax(sculpt_size,1); genNGon(params, sides); } @@ -2062,7 +2072,7 @@ LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL ge generate(); - if (mParams.getSculptID().isNull() && mParams.getSculptType() == LL_SCULPT_TYPE_NONE || mParams.getSculptType() == LL_SCULPT_TYPE_MESH) + if (mParams.getSculptID().isNull() && ((mParams.getSculptType() == LL_SCULPT_TYPE_NONE) || (mParams.getSculptType() == LL_SCULPT_TYPE_MESH))) { createVolumeFaces(); } @@ -4472,9 +4482,6 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, continue; //skip degenerate face } - LLVector4a default_norm; - default_norm.set(0,1,0,1); - //for each edge for (S32 k = 0; k < 3; k++) { S32 index = face.mEdge[j*3+k]; @@ -4496,14 +4503,14 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, norm_mat.rotate(n[v1], t); - t.normalize3fast_checked(&default_norm); + t.normalize3fast(); normals.push_back(LLVector3(t[0], t[1], t[2])); mat.affineTransform(v[v2], t); vertices.push_back(LLVector3(t[0], t[1], t[2])); norm_mat.rotate(n[v2], t); - t.normalize3fast_checked(&default_norm); + t.normalize3fast(); normals.push_back(LLVector3(t[0], t[1], t[2])); } } @@ -5282,6 +5289,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) if (src.mTangents) { allocateTangents(src.mNumVertices); + llassert(mTangents); LLVector4a::memcpyNonAliased16((F32*) mTangents, (F32*) src.mTangents, vert_size); } else @@ -5293,6 +5301,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) if (src.mWeights) { allocateWeights(src.mNumVertices); + llassert(mWeights); LLVector4a::memcpyNonAliased16((F32*) mWeights, (F32*) src.mWeights, vert_size); } else @@ -5308,14 +5317,14 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) LLVector4a::memcpyNonAliased16((F32*) mIndices, (F32*) src.mIndices, idx_size); } - + //delete return *this; } LLVolumeFace::~LLVolumeFace() { - ll_aligned_free_16(mExtents); + ll_aligned_free_16(mExtents); mExtents = NULL; freeData(); @@ -5325,7 +5334,7 @@ void LLVolumeFace::freeData() { ll_aligned_free_16(mPositions); mPositions = NULL; - ll_aligned_free_16( mNormals); + ll_aligned_free_16(mNormals); mNormals = NULL; ll_aligned_free_16(mTexCoords); mTexCoords = NULL; @@ -5911,10 +5920,10 @@ void LLVolumeFace::cacheOptimize() wght = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); } - LLVector4a* binorm = NULL; + LLVector4a* tangent = NULL; if (mTangents) { - binorm = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); + tangent = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); } //allocate mapping of old indices to new indices @@ -5939,7 +5948,7 @@ void LLVolumeFace::cacheOptimize() } if (mTangents) { - binorm[cur_idx] = mTangents[idx]; + tangent[cur_idx] = mTangents[idx]; } cur_idx++; @@ -5961,7 +5970,7 @@ void LLVolumeFace::cacheOptimize() mNormals = norm; mTexCoords = tc; mWeights = wght; - mTangents = binorm; + mTangents = tangent; //std::string result = llformat("ACMR pre/post: %.3f/%.3f -- %d triangles %d breaks", pre_acmr, post_acmr, mNumIndices/3, breaks); //llinfos << result << llendl; @@ -6099,9 +6108,6 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) { VertexData corners[4]; VertexData baseVert; - LLVector4a default_norm; - default_norm.set(0,1,0,1); - for(S32 t = 0; t < 4; t++) { corners[t].getPosition().load3( mesh[offset + (grid_size*t)].mPos.mV); @@ -6115,7 +6121,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) LLVector4a rhs; rhs.setSub(corners[2].getPosition(), corners[1].getPosition()); baseVert.getNormal().setCross3(lhs, rhs); - baseVert.getNormal().normalize3fast_checked(&default_norm); + baseVert.getNormal().normalize3fast(); } if(!(mTypeMask & TOP_MASK)) @@ -6312,6 +6318,43 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) cuv = (min_uv + max_uv)*0.5f; + + LLVector4a tangent; + calc_tangent_from_triangle( + *norm, + tangent, + *mCenter, cuv, + pos[0], tc[0], + pos[1], tc[1]); + + if (tangent.getLength3() < 0.01) + { + tangent.set(1,0,0,1); + } + else + { + LLVector4a default_tangent; + default_tangent.set(1,0,0,1); + tangent.normalize3fast_checked(&default_tangent); + } + + LLVector4a normal; + LLVector4a d0, d1; + + d0.setSub(*mCenter, pos[0]); + d1.setSub(*mCenter, pos[1]); + + if (mTypeMask & TOP_MASK) + { + normal.setCross3(d0, d1); + } + else + { + normal.setCross3(d1, d0); + } + + normal.normalize3fast_checked(); + VertexData vd; vd.setPosition(*mCenter); vd.mTexCoord = cuv; @@ -6323,7 +6366,15 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) num_vertices++; } - + + allocateTangents(num_vertices); + + for (S32 i = 0; i < num_vertices; i++) + { + mTangents[i].load4a(tangent.getF32ptr()); + norm[i].load4a(normal.getF32ptr()); + } + if (partial_build) { return TRUE; @@ -6559,31 +6610,6 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) } - LLVector4a d0,d1; - - d0.setSub(mPositions[mIndices[1]], mPositions[mIndices[0]]); - d1.setSub(mPositions[mIndices[2]], mPositions[mIndices[0]]); - - LLVector4a normal; - LLVector4a default_norm; - default_norm.set(0,1,0,1); - - normal.setCross3(d0,d1); - normal.normalize3fast_checked(&default_norm); - - llassert(llfinite(normal.getF32ptr()[0])); - llassert(llfinite(normal.getF32ptr()[1])); - llassert(llfinite(normal.getF32ptr()[2])); - - llassert(!llisnan(normal.getF32ptr()[0])); - llassert(!llisnan(normal.getF32ptr()[1])); - llassert(!llisnan(normal.getF32ptr()[2])); - - for (S32 i = 0; i < num_vertices; i++) - { - norm[i].load4a(normal.getF32ptr()); - } - return TRUE; } @@ -6616,9 +6642,9 @@ void LLVolumeFace::createTangents() default_norm.set(0,1,0,1); for (U32 i = 0; i < mNumVertices; i++) { - //binorm[i].normalize3fast(); + //tangent[i].normalize3fast(); //bump map/planar projection code requires normals to be normalized - mNormals[i].normalize3fast_checked(&default_norm); + mNormals[i].normalize3fast_checked(); } } } @@ -6693,7 +6719,7 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con void LLVolumeFace::allocateTangents(S32 num_verts) { - ll_aligned_free_16(mTangents); + ll_aligned_free_16(mTangents); mTangents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); } @@ -6796,9 +6822,6 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat mat.loadu(mat_in); norm_mat.loadu(norm_mat_in); - LLVector4a default_norm; - default_norm.set(0,1,0,1); - for (U32 i = 0; i < face.mNumVertices; ++i) { //transform appended face position and store @@ -6806,7 +6829,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat //transform appended face normal and store norm_mat.rotate(src_norm[i], dst_norm[i]); - dst_norm[i].normalize3fast_checked(&default_norm); + dst_norm[i].normalize3fast_checked(); //copy appended face texture coordinate dst_tc[i] = src_tc[i]; @@ -7215,6 +7238,134 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) return TRUE; } +// Finds binormal based on three vertices with texture coordinates. +// Fills in dummy values if the triangle has degenerate texture coordinates. +void calc_binormal_from_triangle(LLVector4a& binormal, + + const LLVector4a& pos0, + const LLVector2& tex0, + const LLVector4a& pos1, + const LLVector2& tex1, + const LLVector4a& pos2, + const LLVector2& tex2) +{ + LLVector4a rx0( pos0[VX], tex0.mV[VX], tex0.mV[VY] ); + LLVector4a rx1( pos1[VX], tex1.mV[VX], tex1.mV[VY] ); + LLVector4a rx2( pos2[VX], tex2.mV[VX], tex2.mV[VY] ); + + LLVector4a ry0( pos0[VY], tex0.mV[VX], tex0.mV[VY] ); + LLVector4a ry1( pos1[VY], tex1.mV[VX], tex1.mV[VY] ); + LLVector4a ry2( pos2[VY], tex2.mV[VX], tex2.mV[VY] ); + + LLVector4a rz0( pos0[VZ], tex0.mV[VX], tex0.mV[VY] ); + LLVector4a rz1( pos1[VZ], tex1.mV[VX], tex1.mV[VY] ); + LLVector4a rz2( pos2[VZ], tex2.mV[VX], tex2.mV[VY] ); + + LLVector4a lhs, rhs; + + LLVector4a r0; + lhs.setSub(rx0, rx1); rhs.setSub(rx0, rx2); + r0.setCross3(lhs, rhs); + + LLVector4a r1; + lhs.setSub(ry0, ry1); rhs.setSub(ry0, ry2); + r1.setCross3(lhs, rhs); + + LLVector4a r2; + lhs.setSub(rz0, rz1); rhs.setSub(rz0, rz2); + r2.setCross3(lhs, rhs); + + if( r0[VX] && r1[VX] && r2[VX] ) + { + binormal.set( + -r0[VZ] / r0[VX], + -r1[VZ] / r1[VX], + -r2[VZ] / r2[VX]); + // binormal.normVec(); + } + else + { + binormal.set( 0, 1 , 0 ); + } +} + +// Finds binormal based on three vertices with texture coordinates. +// Fills in dummy values if the triangle has degenerate texture coordinates. +void calc_tangent_from_triangle( + LLVector4a& normal, + LLVector4a& tangent_out, + const LLVector4a& v1, + const LLVector2& w1, + const LLVector4a& v2, + const LLVector2& w2, + const LLVector4a& v3, + const LLVector2& w3) +{ + const F32* v1ptr = v1.getF32ptr(); + const F32* v2ptr = v2.getF32ptr(); + const F32* v3ptr = v3.getF32ptr(); + + float x1 = v2ptr[0] - v1ptr[0]; + float x2 = v3ptr[0] - v1ptr[0]; + float y1 = v2ptr[1] - v1ptr[1]; + float y2 = v3ptr[1] - v1ptr[1]; + float z1 = v2ptr[2] - v1ptr[2]; + float z2 = v3ptr[2] - v1ptr[2]; + + float s1 = w2.mV[0] - w1.mV[0]; + float s2 = w3.mV[0] - w1.mV[0]; + float t1 = w2.mV[1] - w1.mV[1]; + float t2 = w3.mV[1] - w1.mV[1]; + + F32 rd = s1*t2-s2*t1; + + float r = ((rd*rd) > FLT_EPSILON) ? 1.0F / rd : 1024.f; //some made up large ratio for division by zero + + llassert(llfinite(r)); + llassert(!llisnan(r)); + + LLVector4a sdir( + (t2 * x1 - t1 * x2) * r, + (t2 * y1 - t1 * y2) * r, + (t2 * z1 - t1 * z2) * r); + + LLVector4a tdir( + (s1 * x2 - s2 * x1) * r, + (s1 * y2 - s2 * y1) * r, + (s1 * z2 - s2 * z1) * r); + + LLVector4a n = normal; + LLVector4a t = sdir; + + LLVector4a ncrosst; + ncrosst.setCross3(n,t); + + // Gram-Schmidt orthogonalize + n.mul(n.dot3(t).getF32()); + + LLVector4a tsubn; + tsubn.setSub(t,n); + + if (tsubn.dot3(tsubn).getF32() > F_APPROXIMATELY_ZERO) + { + tsubn.normalize3fast_checked(); + + // Calculate handedness + F32 handedness = ncrosst.dot3(tdir).getF32() < 0.f ? -1.f : 1.f; + + tsubn.getF32ptr()[3] = handedness; + + tangent_out = tsubn; + } + else + { + // degenerate, make up a value + // + tangent_out.set(0,0,1,1); + } + +} + //adapted from Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”. Terathon Software 3D Graphics Library, 2001. http://www.terathon.com/code/tangent.html void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal, const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent) -- cgit v1.2.3 From be89f2f8fb234cc8d0d511df2384422d92e134b8 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sun, 28 Jul 2013 18:29:51 -0700 Subject: NORSPEC-314 fixed another mac-specific stupidity by splitting out a new srgb_mac version of the shader --- .../app_settings/shaders/class1/deferred/srgb.glsl | 33 ++----------- .../shaders/class1/deferred/srgb_mac.glsl | 54 ++++++++++++++++++++++ indra/newview/llviewershadermgr.cpp | 6 ++- 3 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/deferred/srgb_mac.glsl (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl index d532835bf1..587f3d5a94 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl @@ -23,51 +23,24 @@ * $/LicenseInfo$ */ -// OLD_SELECT work-around missing mix(vec3,vec,bvec3) in older GLSL versions (*cough* MAC *cough*) - vec3 srgb_to_linear(vec3 cs) { - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - vec3 low_range = cs / vec3(12.92); vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); bvec3 lte = lessThanEqual(cs,vec3(0.04045)); -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lessThanEqual(cs,vec3(0.04045))); -#endif + return mix(high_range, low_range, lte); + } vec3 linear_to_srgb(vec3 cl) { - /* { 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - cl = clamp(cl, vec3(0), vec3(1)); vec3 low_range = cl * 12.92; vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; bvec3 lt = lessThan(cl,vec3(0.0031308)); + return mix(high_range, low_range, lt); -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lessThan(cl,vec3(0.0031308))); -#endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb_mac.glsl b/indra/newview/app_settings/shaders/class1/deferred/srgb_mac.glsl new file mode 100644 index 0000000000..6cc1e6e798 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/srgb_mac.glsl @@ -0,0 +1,54 @@ +/** + * @file srgb.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + + bvec3 lt = lessThan(cl,vec3(0.0031308)); + + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +} + diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 6e2139ea9e..545a236f81 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -936,12 +936,14 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/srgb.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) ); // work-around for missing mix(vec3,vec3,bvec3) on decrepit GLSLs // #if LL_DARWIN - attribs["OLD_SELECT"] = "1"; + attribs["OLD_SELECT"] = "1"; + index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/srgb_mac.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) ); +#else + index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/srgb.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) ); #endif for (U32 i = 0; i < shaders.size(); i++) -- cgit v1.2.3 From b44e7303d85ffc59afe34a97342d83a04b180c48 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Mon, 29 Jul 2013 18:59:45 -0700 Subject: NORSPEC-314 WIP fix srgb_mac use and issues found with RenderDebugGL on Mac --- indra/llrender/llshadermgr.cpp | 5 ++++ indra/llrender/llvertexbuffer.cpp | 57 +++++++++++++++++++++++++++++++++---- indra/newview/lldrawpoolalpha.cpp | 3 +- indra/newview/llviewershadermgr.cpp | 1 - indra/newview/pipeline.cpp | 19 ++++++------- 5 files changed, 68 insertions(+), 17 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index c3e76f5e0e..21b8322bf1 100755 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -177,7 +177,12 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasSRGB) { +#if LL_DARWIN + if (!shader->attachObject("deferred/srgb_mac.glsl")) + +#else if (!shader->attachObject("deferred/srgb.glsl")) +#endif { return FALSE; } diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index b1ef6e0576..f1249a842a 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -753,10 +753,10 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi U16* idx = ((U16*) getIndicesPointer())+indices_offset; stop_glerror(); - LLGLSLShader::startProfile(); - glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, + LLGLSLShader::startProfile(); + glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, idx); - LLGLSLShader::stopProfile(count, mode); + LLGLSLShader::stopProfile(count, mode); stop_glerror(); @@ -2209,11 +2209,32 @@ void LLVertexBuffer::bindForFeedback(U32 channel, U32 type, U32 index, U32 count #endif } +void DumpComponents(U32 mask) +{ + llinfos << + ((mask & LLVertexBuffer::MAP_VERTEX) ? "vertex:" : " ") << + ((mask & LLVertexBuffer::MAP_NORMAL) ? "norms:" : " ") << + ((mask & LLVertexBuffer::MAP_TEXCOORD0) ? "TC0:" : " ") << + ((mask & LLVertexBuffer::MAP_TEXCOORD1) ? "TC1:" : " ") << + ((mask & LLVertexBuffer::MAP_TEXCOORD2) ? "TC2:" : " ") << + ((mask & LLVertexBuffer::MAP_TEXCOORD3) ? "TC3:" : " ") << + ((mask & LLVertexBuffer::MAP_COLOR) ? "color:" : " ") << + ((mask & LLVertexBuffer::MAP_EMISSIVE) ? "emissive:" : " ") << + ((mask & LLVertexBuffer::MAP_TANGENT) ? "tangents" : " ") << llendl; +} + // Set for rendering void LLVertexBuffer::setBuffer(U32 data_mask) { flush(); + if((getTypeMask() & data_mask) != data_mask) + { + llinfos << "Missing VB stream components." << llendl; + DumpComponents(data_mask & ~getTypeMask()); + data_mask &= getTypeMask(); + } + //set up pointers if the data mask is different ... bool setup = (sLastMask != data_mask); @@ -2237,15 +2258,36 @@ void LLVertexBuffer::setBuffer(U32 data_mask) } } + static bool done_done_it = false; + + if (!done_done_it) + { + done_done_it = true; + + llinfos << + "MAP_VERTEX: " << MAP_VERTEX << + "MAP_VERTEX: " << MAP_NORMAL << + "MAP_VERTEX: " << MAP_TEXCOORD0 << + "MAP_VERTEX: " << MAP_TEXCOORD1 << + "MAP_VERTEX: " << MAP_TEXCOORD2 << + "MAP_VERTEX: " << MAP_TEXCOORD3 << + "MAP_VERTEX: " << MAP_COLOR << + "MAP_VERTEX: " << MAP_EMISSIVE << + "MAP_VERTEX: " << MAP_TANGENT << llendl; + + + } + if ((data_mask & required_mask) != required_mask) { U32 unsatisfied_mask = (required_mask & ~data_mask); U32 i = 0; - while (i < 15) + while (i < TYPE_MAX) { - switch ((unsatisfied_mask & (1 << i))) + U32 unsatisfied_flag = unsatisfied_mask & (1 << i); + switch (unsatisfied_flag) { case MAP_VERTEX: llinfos << "Missing vert pos" << llendl; break; case MAP_NORMAL: llinfos << "Missing normals" << llendl; break; @@ -2264,6 +2306,11 @@ void LLVertexBuffer::setBuffer(U32 data_mask) } } + if (unsatisfied_mask & (1 << TYPE_INDEX)) + { + llinfos << "Missing indices" << llendl; + } + llerrs << "Shader consumption mismatches data provision." << llendl; } } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 6302cf6b00..f4f63e1042 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -529,7 +529,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) } } - params.mVertexBuffer->setBuffer(mask); + params.mVertexBuffer->setBuffer(mask & ~(params.mFullbright ? (LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2) : 0)); + params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 545a236f81..73177d549b 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1444,7 +1444,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i); gDeferredMultiLightProgram[i].mShaderFiles.clear(); - gDeferredMultiLightProgram[i].mFeatures.hasSRGB = true; gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMultiLightProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 165b28beb5..05390f64f0 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8695,12 +8695,6 @@ void LLPipeline::renderDeferredLighting() unbindDeferredShader(gDeferredSpotLightProgram); } - //reset mDeferredVB to fullscreen triangle - mDeferredVB->getVertexStrider(vert); - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); - { LLGLDepthTest depth(GL_FALSE); @@ -8719,6 +8713,10 @@ void LLPipeline::renderDeferredLighting() F32 far_z = 0.f; + bindDeferredShader(gDeferredMultiLightProgram[0]); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + while (!fullscreen_lights.empty()) { LLFastTimer ftm(FTM_FULLSCREEN_LIGHTS); @@ -8743,14 +8741,15 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; - count = 0; - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + count = 0; + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + unbindDeferredShader(gDeferredMultiLightProgram[idx]); } } - - unbindDeferredShader(gDeferredMultiLightProgram[0]); + unbindDeferredShader(gDeferredMultiLightProgram[0]); + bindDeferredShader(gDeferredMultiSpotLightProgram); gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); -- cgit v1.2.3 From f86a7c04d3c265f4d61d99d1d7fdb7e35c4bc3f6 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 30 Jul 2013 11:33:58 -0700 Subject: NORSPEC-314 rollback unified srgb shader code to see if we can get past Mac 10.6.8 nV driver issues --- indra/llrender/llglslshader.cpp | 6 +++- indra/llrender/llglslshader.h | 1 - indra/llrender/llshadermgr.cpp | 13 -------- .../shaders/class1/deferred/alphaF.glsl | 38 +++++++++++++++++++-- .../shaders/class1/deferred/fullbrightF.glsl | 39 ++++++++++++++++++++-- .../shaders/class1/deferred/materialF.glsl | 38 +++++++++++++++++++-- .../shaders/class1/deferred/multiSpotLightF.glsl | 38 +++++++++++++++++++-- .../shaders/class1/deferred/softenLightF.glsl | 39 ++++++++++++++++++++-- .../shaders/class1/deferred/spotLightF.glsl | 38 +++++++++++++++++++-- .../shaders/class1/deferred/underWaterF.glsl | 38 +++++++++++++++++++-- .../shaders/class1/deferred/waterF.glsl | 38 +++++++++++++++++++-- .../shaders/class2/deferred/multiSpotLightF.glsl | 38 +++++++++++++++++++-- .../shaders/class2/deferred/softenLightF.glsl | 38 +++++++++++++++++++-- .../shaders/class2/deferred/spotLightF.glsl | 38 +++++++++++++++++++-- indra/newview/llviewershadermgr.cpp | 28 ---------------- 15 files changed, 403 insertions(+), 65 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index b854218e3d..40aff36dac 100755 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -87,7 +87,6 @@ LLShaderFeatures::LLShaderFeatures() , mIndexedTextureChannels(0) , disableTextureIndex(false) , hasAlphaMask(false) - , hasSRGB(false) { } @@ -375,6 +374,11 @@ BOOL LLGLSLShader::createShader(vector * attributes, // Create program mProgramObject = glCreateProgramObjectARB(); + +#if LL_DARWIN + // work-around missing mix(vec3,vec3,bvec3) + mDefines["OLD_SELECT"] = "1"; +#endif //compile new source vector< pair >::iterator fileIter = mShaderFiles.begin(); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index dadffeb6c4..eabdb9fc92 100755 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -50,7 +50,6 @@ public: S32 mIndexedTextureChannels; bool disableTextureIndex; bool hasAlphaMask; - bool hasSRGB; // char numLights; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 21b8322bf1..63404abeff 100755 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -175,19 +175,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) // Attach Fragment Shader Features Next /////////////////////////////////////// - if (features->hasSRGB) - { -#if LL_DARWIN - if (!shader->attachObject("deferred/srgb_mac.glsl")) - -#else - if (!shader->attachObject("deferred/srgb.glsl")) -#endif - { - return FALSE; - } - } - if(features->calculatesAtmospherics) { if (features->hasWaterFog) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 52858f45f4..d11f67ee58 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -96,8 +96,42 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec3 calcDirectionalLight(vec3 n, vec3 l) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 00548ea826..f22b16965c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -39,8 +39,43 @@ VARYING vec3 vary_position; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); + +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec3 fullbrightAtmosTransportDeferred(vec3 light) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index d3bd55da7a..b3ae81d494 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -114,8 +114,42 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} #ifdef WATER_FOG uniform vec4 waterPlane; diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 0b62c4ec09..ed68e38891 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -83,9 +83,43 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 39d613e02b..0febbcd6e0 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -78,8 +78,43 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} + vec3 decode_normal (vec2 enc) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 251abfd119..48c9cd363c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -82,8 +82,42 @@ vec3 decode_normal (vec2 enc) return n; } -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec4 correctWithGamma(vec4 col) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl index 858c3a1fe9..78f841c733 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl @@ -56,8 +56,42 @@ VARYING vec4 refCoord; VARYING vec4 littleWave; VARYING vec4 view; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec2 encode_normal(vec3 n) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 5538c41d1c..d49ff72cf0 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -67,8 +67,42 @@ VARYING vec4 littleWave; VARYING vec4 view; VARYING vec4 vary_position; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec2 encode_normal(vec3 n) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 6d1cedee39..df750d3cec 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -68,8 +68,42 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec2 encode_normal(vec3 n) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index db2faa65d7..cc34285d65 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,8 +78,42 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec2 encode_normal(vec3 n) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index cfb483ab54..bb6afbbf62 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -85,8 +85,42 @@ vec3 decode_normal (vec2 enc) return n; } -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec4 correctWithGamma(vec4 col) { diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 73177d549b..264655029a 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -936,16 +936,6 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - -// work-around for missing mix(vec3,vec3,bvec3) on decrepit GLSLs -// -#if LL_DARWIN - attribs["OLD_SELECT"] = "1"; - index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/srgb_mac.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) ); -#else - index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/srgb.glsl", mVertexShaderLevel[SHADER_DEFERRED] ) ); -#endif - for (U32 i = 0; i < shaders.size(); i++) { // Note usage of GL_FRAGMENT_SHADER_ARB @@ -1271,7 +1261,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredSkinnedAlphaProgram.mName = "Deferred Skinned Alpha Shader"; - gDeferredSkinnedAlphaProgram.mFeatures.hasSRGB = true; gDeferredSkinnedAlphaProgram.mFeatures.hasObjectSkinning = true; gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = false; gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = false; @@ -1329,7 +1318,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() U32 alpha_mode = i & 0x3; gDeferredMaterialProgram[i].mShaderFiles.clear(); - gDeferredMaterialProgram[i].mFeatures.hasSRGB = true; gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMaterialProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1355,7 +1343,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() U32 alpha_mode = i & 0x3; gDeferredMaterialWaterProgram[i].mShaderFiles.clear(); - gDeferredMaterialWaterProgram[i].mFeatures.hasSRGB = true; gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMaterialWaterProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1456,7 +1443,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredSpotLightProgram.mName = "Deferred SpotLight Shader"; gDeferredSpotLightProgram.mShaderFiles.clear(); - gDeferredSpotLightProgram.mFeatures.hasSRGB = true; gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1468,7 +1454,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredMultiSpotLightProgram.mName = "Deferred MultiSpotLight Shader"; gDeferredMultiSpotLightProgram.mShaderFiles.clear(); - gDeferredMultiSpotLightProgram.mFeatures.hasSRGB = true; gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredMultiSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; @@ -1518,7 +1503,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredAlphaProgram.mName = "Deferred Alpha Shader"; - gDeferredAlphaProgram.mFeatures.hasSRGB = true; gDeferredAlphaProgram.mFeatures.calculatesLighting = false; gDeferredAlphaProgram.mFeatures.hasLighting = false; gDeferredAlphaProgram.mFeatures.isAlphaLighting = true; @@ -1550,7 +1534,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredAlphaWaterProgram.mName = "Deferred Alpha Underwater Shader"; - gDeferredAlphaWaterProgram.mFeatures.hasSRGB = true; gDeferredAlphaWaterProgram.mFeatures.calculatesLighting = false; gDeferredAlphaWaterProgram.mFeatures.hasLighting = false; gDeferredAlphaWaterProgram.mFeatures.isAlphaLighting = true; @@ -1597,7 +1580,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredFullbrightProgram.mName = "Deferred Fullbright Shader"; - gDeferredFullbrightProgram.mFeatures.hasSRGB = true; gDeferredFullbrightProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightProgram.mFeatures.hasGamma = true; gDeferredFullbrightProgram.mFeatures.hasTransport = true; @@ -1612,7 +1594,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredFullbrightAlphaMaskProgram.mName = "Deferred Fullbright Alpha Masking Shader"; - gDeferredFullbrightAlphaMaskProgram.mFeatures.hasSRGB = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.hasGamma = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; @@ -1628,7 +1609,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredFullbrightWaterProgram.mName = "Deferred Fullbright Underwater Shader"; - gDeferredFullbrightWaterProgram.mFeatures.hasSRGB = true; gDeferredFullbrightWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightWaterProgram.mFeatures.hasGamma = true; gDeferredFullbrightWaterProgram.mFeatures.hasTransport = true; @@ -1645,7 +1625,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredFullbrightAlphaMaskWaterProgram.mName = "Deferred Fullbright Underwater Alpha Masking Shader"; - gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasSRGB = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasGamma = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasTransport = true; @@ -1677,7 +1656,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredSkinnedFullbrightProgram.mName = "Skinned Fullbright Shader"; - gDeferredSkinnedFullbrightProgram.mFeatures.hasSRGB = true; gDeferredSkinnedFullbrightProgram.mFeatures.calculatesAtmospherics = true; gDeferredSkinnedFullbrightProgram.mFeatures.hasGamma = true; gDeferredSkinnedFullbrightProgram.mFeatures.hasTransport = true; @@ -1723,7 +1701,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { // load water shader gDeferredWaterProgram.mName = "Deferred Water Shader"; - gDeferredWaterProgram.mFeatures.hasSRGB = true; gDeferredWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredWaterProgram.mFeatures.hasGamma = true; gDeferredWaterProgram.mFeatures.hasTransport = true; @@ -1738,7 +1715,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { // load water shader gDeferredUnderWaterProgram.mName = "Deferred Under Water Shader"; - gDeferredUnderWaterProgram.mFeatures.hasSRGB = true; gDeferredUnderWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredUnderWaterProgram.mFeatures.hasGamma = true; gDeferredUnderWaterProgram.mFeatures.hasTransport = true; @@ -1753,7 +1729,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredSoftenProgram.mName = "Deferred Soften Shader"; gDeferredSoftenProgram.mShaderFiles.clear(); - gDeferredSoftenProgram.mFeatures.hasSRGB = true; gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1771,7 +1746,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredSoftenWaterProgram.mName = "Deferred Soften Underwater Shader"; gDeferredSoftenWaterProgram.mShaderFiles.clear(); - gDeferredSoftenWaterProgram.mFeatures.hasSRGB = true; gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1869,7 +1843,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredAvatarAlphaProgram.mName = "Avatar Alpha Shader"; - gDeferredAvatarAlphaProgram.mFeatures.hasSRGB = true; gDeferredAvatarAlphaProgram.mFeatures.hasSkinning = true; gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = false; gDeferredAvatarAlphaProgram.mFeatures.hasLighting = false; @@ -1893,7 +1866,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredPostGammaCorrectProgram.mName = "Deferred Gamma Correction Post Process"; gDeferredPostGammaCorrectProgram.mShaderFiles.clear(); - gDeferredPostGammaCorrectProgram.mFeatures.hasSRGB = true; gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrect.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredPostGammaCorrectProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; -- cgit v1.2.3 From 42ce98e8bfe3fd633e15f703d5ffdad64c2965a5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 30 Jul 2013 13:44:12 -0700 Subject: NORSPEC-314 cleanup debug-only code...seems to fix NORSPEC-328 as well somehow --- indra/llrender/llvertexbuffer.cpp | 45 ++++++++++++++------------------------- indra/newview/pipeline.cpp | 14 ++++++------ 2 files changed, 23 insertions(+), 36 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index f1249a842a..fd7b846928 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -2230,9 +2230,16 @@ void LLVertexBuffer::setBuffer(U32 data_mask) if((getTypeMask() & data_mask) != data_mask) { - llinfos << "Missing VB stream components." << llendl; - DumpComponents(data_mask & ~getTypeMask()); - data_mask &= getTypeMask(); + if (gDebugGL) + { + // Dump info about what was missing + // + DumpComponents(data_mask & ~getTypeMask()); + llwarns << "Missing VB stream components. ^^" << llendl; + } + // Make sure we don't write checks we can't cash below... + // + data_mask = (data_mask & getTypeMask()); } //set up pointers if the data mask is different ... @@ -2257,27 +2264,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) required_mask |= required; } } - - static bool done_done_it = false; - - if (!done_done_it) - { - done_done_it = true; - - llinfos << - "MAP_VERTEX: " << MAP_VERTEX << - "MAP_VERTEX: " << MAP_NORMAL << - "MAP_VERTEX: " << MAP_TEXCOORD0 << - "MAP_VERTEX: " << MAP_TEXCOORD1 << - "MAP_VERTEX: " << MAP_TEXCOORD2 << - "MAP_VERTEX: " << MAP_TEXCOORD3 << - "MAP_VERTEX: " << MAP_COLOR << - "MAP_VERTEX: " << MAP_EMISSIVE << - "MAP_VERTEX: " << MAP_TANGENT << llendl; - - - } - + if ((data_mask & required_mask) != required_mask) { @@ -2302,14 +2289,14 @@ void LLVertexBuffer::setBuffer(U32 data_mask) case MAP_WEIGHT4: llinfos << "Missing weightx4" << llendl; break; case MAP_CLOTHWEIGHT: llinfos << "Missing clothweight" << llendl; break; case MAP_TEXTURE_INDEX: llinfos << "Missing tex index" << llendl; break; - default: llinfos << "Missing who effin knows" << llendl; + default: llinfos << "Missing who effin knows: " << unsatisfied_flag << llendl; } } - if (unsatisfied_mask & (1 << TYPE_INDEX)) - { - llinfos << "Missing indices" << llendl; - } + if (unsatisfied_mask & (1 << TYPE_INDEX)) + { + llinfos << "Missing indices" << llendl; + } llerrs << "Shader consumption mismatches data provision." << llendl; } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 05390f64f0..9aa375767b 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8695,6 +8695,12 @@ void LLPipeline::renderDeferredLighting() unbindDeferredShader(gDeferredSpotLightProgram); } + //reset mDeferredVB to fullscreen triangle + mDeferredVB->getVertexStrider(vert); + vert[0].set(-1,1,0); + vert[1].set(-1,-3,0); + vert[2].set(3,1,0); + { LLGLDepthTest depth(GL_FALSE); @@ -8713,10 +8719,6 @@ void LLPipeline::renderDeferredLighting() F32 far_z = 0.f; - bindDeferredShader(gDeferredMultiLightProgram[0]); - - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - while (!fullscreen_lights.empty()) { LLFastTimer ftm(FTM_FULLSCREEN_LIGHTS); @@ -8742,13 +8744,11 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; count = 0; - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); unbindDeferredShader(gDeferredMultiLightProgram[idx]); } } - - unbindDeferredShader(gDeferredMultiLightProgram[0]); bindDeferredShader(gDeferredMultiSpotLightProgram); -- cgit v1.2.3 From 4a3c99beb228680b297e9a3388df3290b594cd57 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 1 Aug 2013 10:34:36 -0700 Subject: NORSPEC-304 fix glow pass rendering over alpha pass after ALM toggle --- indra/newview/lldrawpoolalpha.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index f4f63e1042..bd8ecdb166 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -545,8 +545,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) emissive_shader->bind(); - // glow doesn't use vertex colors from the mesh data - params.mVertexBuffer->setBuffer((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); + params.mVertexBuffer->setBuffer(mask & LLVertexBuffer::MAP_EMISSIVE); // do the actual drawing, again params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); -- cgit v1.2.3 From 2d065562f1dabd090a12b75f1aa4233ce9d7ce33 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 1 Aug 2013 14:01:37 -0700 Subject: NORSPEC-336 fix glow regression from 304 fix --- indra/newview/lldrawpoolalpha.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index bd8ecdb166..1cc81fa863 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -545,7 +545,10 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) emissive_shader->bind(); - params.mVertexBuffer->setBuffer(mask & LLVertexBuffer::MAP_EMISSIVE); + U32 final_mask = params.mFullbright ? (mask | LLVertexBuffer::MAP_EMISSIVE) + : ((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); + + params.mVertexBuffer->setBuffer(final_mask); // do the actual drawing, again params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); -- cgit v1.2.3 From 14c7108ca3f646a8f7fd0d024ca200919bbf79bf Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 3 Aug 2013 06:52:56 -0700 Subject: NORSPEC-304 NORSPEC-334 NORSPEC-336 fix black glow overdraw without breaking glow --- indra/newview/lldrawpoolalpha.cpp | 5 +---- indra/newview/llvovolume.cpp | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 1cc81fa863..237579cec5 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -545,10 +545,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) emissive_shader->bind(); - U32 final_mask = params.mFullbright ? (mask | LLVertexBuffer::MAP_EMISSIVE) - : ((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); - - params.mVertexBuffer->setBuffer(final_mask); + params.mVertexBuffer->setBuffer((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); // do the actual drawing, again params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 406591046f..3eb5b19de5 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4881,7 +4881,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (emissive) { //emissive faces are present, include emissive byte to preserve batching simple_mask = simple_mask | LLVertexBuffer::MAP_EMISSIVE; - alpha_mask = alpha_mask | LLVertexBuffer::MAP_EMISSIVE; + + // doing this seems to cause NORSPEC-304 + //alpha_mask = alpha_mask | LLVertexBuffer::MAP_EMISSIVE; + bump_mask = bump_mask | LLVertexBuffer::MAP_EMISSIVE; fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_EMISSIVE; norm_mask = norm_mask | LLVertexBuffer::MAP_EMISSIVE; -- cgit v1.2.3 From 9557926fff5992276811c1b1d9aa371ede9004a8 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 3 Aug 2013 08:25:03 -0700 Subject: NORSPEC-332 fix fullbright tex indexing fail --- indra/newview/lldrawpoolalpha.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 237579cec5..fca4492fbb 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -529,7 +529,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) } } - params.mVertexBuffer->setBuffer(mask & ~(params.mFullbright ? (LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2) : 0)); + params.mVertexBuffer->setBuffer(mask & ~(params.mFullbright ? (LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2) : 0)); params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); -- cgit v1.2.3 From 938ad0c640a72dc7ee8bf39ad138e6d84d1d0a1e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 4 Aug 2013 05:21:34 -0700 Subject: NORSPEC-305 -NORSPEC-335 fix scale and HUD anim regression from materials changes in CL 28424 --- indra/newview/llviewerobject.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 6f7b2f40e6..f29a00e4c4 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4410,12 +4410,10 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri void LLViewerObject::refreshMaterials() { - setChanged(ALL_CHANGED); + setChanged(TEXTURE); if (mDrawable.notNull()) { gPipeline.markTextured(mDrawable); - gPipeline.markRebuild(mDrawable,LLDrawable::REBUILD_ALL); - dirtySpatialGroup(TRUE); } } -- cgit v1.2.3 From 08e429e27df488cb8740eb82f3fb10d5011e6f5d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 5 Aug 2013 06:23:13 -0700 Subject: NORSPEC-285 NORSPEC-293 NORSPEC-298 fix ighting diffs between alpha/non/ALM/non-ALM --- .../shaders/class1/deferred/alphaF.glsl | 48 ++++++--- .../shaders/class1/deferred/materialF.glsl | 108 ++++++++++++--------- .../class1/deferred/postDeferredGammaCorrect.glsl | 22 ++++- .../shaders/class1/deferred/softenLightF.glsl | 10 +- 4 files changed, 125 insertions(+), 63 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d11f67ee58..d0c7cc9dde 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -133,6 +133,23 @@ vec3 linear_to_srgb(vec3 cl) } +vec2 encode_normal(vec3 n) +{ + float f = sqrt(8 * n.z + 8); + return n.xy / f + 0.5; +} + +vec3 decode_normal (vec2 enc) +{ + vec2 fenc = enc*4-2; + float f = dot(fenc,fenc); + float g = sqrt(1-f/4); + vec3 n; + n.xy = fenc*g; + n.z = 1-f/2; + return n; +} + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -527,33 +544,42 @@ void main() vec3 norm = vary_norm; calcAtmospherics(pos.xyz, 1.0); - - float da =dot(norm.xyz, sun_dir.xyz); + + vec2 abnormal = encode_normal(norm.xyz); + norm.xyz = decode_normal(abnormal.xy); + + float da = dot(norm.xyz, sun_dir.xyz); + float final_da = da; final_da = min(final_da, shadow); - final_da = max(final_da, final_alpha); final_da = max(final_da, 0.0f); + final_da = min(final_da, 1.0f); + final_da = pow(final_da, 1.0/1.3); vec4 color = vec4(0,0,0,0); color.rgb = atmosAmbient(color.rgb); color.a = final_alpha; - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); + float ambient = abs(da); ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); color.rgb *= ambient; - color.rgb += atmosAffectDirectionalLight(pow(final_da, 1.0/1.3)); + color.rgb += atmosAffectDirectionalLight(final_da); color.rgb *= gamma_diff.rgb; - color.rgb = mix(atmosLighting(color.rgb), fullbrightAtmosTransport(color.rgb), diff.a); - color.rgb = mix(scaleSoftClip(color.rgb), fullbrightScaleSoftClip(color.rgb), diff.a); + color.rgb = mix(diff.rgb, color.rgb, final_alpha); + + color.rgb = atmosLighting(color.rgb); + color.rgb = scaleSoftClip(color.rgb); vec4 light = vec4(0,0,0,0); - + + color.rgb = srgb_to_linear(color.rgb); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) @@ -566,11 +592,11 @@ void main() // keep it linear // - color.rgb = srgb_to_linear(color.rgb) + light.rgb; + color.rgb += light.rgb; - // ramp directly to display gamma as we're POST-deferred + // straight to display gamma, we're post-deferred // - color.rgb = pow(color.rgb,vec3(display_gamma)); + color.rgb = linear_to_srgb(color.rgb); #ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index b3ae81d494..8202b4978f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -29,6 +29,44 @@ #define DIFFUSE_ALPHA_MODE_EMISSIVE 3 uniform float emissive_brightness; +uniform float display_gamma; + +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) @@ -114,43 +152,6 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - #ifdef WATER_FOG uniform vec4 waterPlane; uniform vec4 waterFogColor; @@ -571,6 +572,9 @@ void main() norm.xyz = tnorm; norm.xyz = normalize(norm.xyz); + vec2 abnormal = encode_normal(norm.xyz); + norm.xyz = decode_normal(abnormal.xy); + vec4 final_color = diffcol; #if (DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE) @@ -666,7 +670,7 @@ void main() vec4 diffuse = final_color; float envIntensity = final_normal.z; - vec3 col = vec3(0.0f,0.0f,0.0f); + vec3 col = vec3(0.0f,0.0f,0.0f); float bloom = 0.0; calcAtmospherics(pos.xyz, 1.0); @@ -674,23 +678,28 @@ void main() vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); float da =dot(norm.xyz, sun_dir.xyz); + float final_da = da; final_da = min(final_da, shadow); - final_da = max(final_da, diffuse.a); + //final_da = max(final_da, diffuse.a); final_da = max(final_da, 0.0f); + final_da = min(final_da, 1.0f); + final_da = pow(final_da, 1.0/1.3); col.rgb = atmosAmbient(col); - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); + float ambient = min(abs(da), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); col.rgb *= ambient; - col.rgb = col.rgb + atmosAffectDirectionalLight(pow(final_da, 1.0/1.3)); + col.rgb = col.rgb + atmosAffectDirectionalLight(final_da); + col.rgb *= gamma_diff.rgb; + float glare = 0.0; if (spec.a > 0.0) // specular reflection @@ -711,7 +720,8 @@ void main() col += spec_contrib; } - col = mix(col.rgb, gamma_diff.rgb, diffuse.a); + + col = mix(col.rgb, diffcol.rgb, diffuse.a); if (envIntensity > 0.0) { @@ -729,15 +739,20 @@ void main() glare += cur_glare; } - col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + //col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); + //col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + + col = atmosLighting(col); + col = scaleSoftClip(col); //convert to linear space before adding local lights col = srgb_to_linear(col); vec3 npos = normalize(-pos.xyz); - #define LIGHT_LOOP(i) col.rgb = col.rgb + calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare); + vec3 light = vec3(0,0,0); + + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -747,13 +762,14 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) + col.rgb += light.rgb; + glare = min(glare, 1.0); float al = max(diffcol.a,glare)*vertex_color.a; //convert to gamma space for display on screen col.rgb = linear_to_srgb(col.rgb); - #ifdef WATER_FOG vec4 temp = applyWaterFogDeferred(pos, vec4(col.rgb, al)); col.rgb = temp.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 89530f4082..4e2f98aa29 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -38,12 +38,30 @@ VARYING vec2 vary_fragcoord; uniform float display_gamma; -vec3 linear_to_srgb(vec3 cl); +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} + void main() { vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); - diff.rgb = pow(diff.rgb,vec3(display_gamma)); + diff.rgb = linear_to_srgb(diff.rgb); frag_color = diff; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 0febbcd6e0..ebe5e57bb7 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -98,7 +98,6 @@ vec3 srgb_to_linear(vec3 cs) vec3 linear_to_srgb(vec3 cl) { - cl = clamp(cl, vec3(0), vec3(1)); vec3 low_range = cl * 12.92; vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; bvec3 lt = lessThan(cl,vec3(0.0031308)); @@ -392,8 +391,11 @@ void main() float envIntensity = norm.z; norm.xyz = decode_normal(norm.xy); // unpack norm - float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - da = pow(da, 1.0/1.3); + float da = dot(norm.xyz, sun_dir.xyz); + + float final_da = max(0.0,da); + final_da = min(final_da, 1.0f); + final_da = pow(final_da, 1.0/1.3); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -414,7 +416,7 @@ void main() col.rgb *= ambient; - col += atmosAffectDirectionalLight(max(min(da, 1.0), 0.0)); + col += atmosAffectDirectionalLight(final_da); col *= diffuse.rgb; -- cgit v1.2.3 From 614ee255c6ed782138daecbc8aa886fb0f4e93e2 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 5 Aug 2013 09:12:41 -0700 Subject: NORSPEC-336 intentionally rebreak 304 to fix glow while we find a fix that works for both --- indra/newview/llvovolume.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3eb5b19de5..5dc59197ca 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4880,11 +4880,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (emissive) { //emissive faces are present, include emissive byte to preserve batching - simple_mask = simple_mask | LLVertexBuffer::MAP_EMISSIVE; - - // doing this seems to cause NORSPEC-304 - //alpha_mask = alpha_mask | LLVertexBuffer::MAP_EMISSIVE; - + simple_mask = simple_mask | LLVertexBuffer::MAP_EMISSIVE; + alpha_mask = alpha_mask | LLVertexBuffer::MAP_EMISSIVE; bump_mask = bump_mask | LLVertexBuffer::MAP_EMISSIVE; fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_EMISSIVE; norm_mask = norm_mask | LLVertexBuffer::MAP_EMISSIVE; -- cgit v1.2.3 From fe69b4049bdbdf36a179ccc28a2f253af13e61c5 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Mon, 5 Aug 2013 10:16:17 -0700 Subject: NORSPEC-304 NORSPEC-336 another attempt as resolving black glow overdraw without breaking glow (even for alpha-blended) faces --- indra/newview/lldrawpoolalpha.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index fca4492fbb..b5d37ba5cc 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -128,14 +128,22 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) gObjectFullbrightAlphaMaskProgram.setMinimumAlpha(0.33f); } - if (LLPipeline::sUnderWaterRender) - { - emissive_shader = &gObjectEmissiveWaterProgram; - } - else - { - emissive_shader = &gObjectEmissiveProgram; - } + + if (LLPipeline::sRenderDeferred) + { + emissive_shader = &gDeferredEmissiveProgram; + } + else + { + if (LLPipeline::sUnderWaterRender) + { + emissive_shader = &gObjectEmissiveWaterProgram; + } + else + { + emissive_shader = &gObjectEmissiveProgram; + } + } deferred_render = TRUE; if (mVertexShaderLevel > 0) -- cgit v1.2.3 From 5b400d50e1f25667e2c865d85fd93546ffe7f96f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 6 Aug 2013 14:16:46 -0700 Subject: NORSPEC-322 NORSPEC-342 fix issues with black impostors and missing alpha attachments on impostors --- .../shaders/class1/deferred/impostorF.glsl | 31 +++++++++++++++++++--- indra/newview/lldrawpoolalpha.cpp | 9 +++++-- indra/newview/lldrawpoolavatar.cpp | 21 +++------------ indra/newview/pipeline.cpp | 21 +++++++-------- 4 files changed, 48 insertions(+), 34 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index bc0719cb82..d52744103f 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -38,6 +38,31 @@ uniform sampler2D specularMap; VARYING vec2 vary_texcoord0; +vec2 encode_normal(vec3 n) +{ + float f = sqrt(8 * n.z + 8); + return n.xy / f + 0.5; +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} + void main() { vec4 col = texture2D(diffuseMap, vary_texcoord0.xy); @@ -47,7 +72,7 @@ void main() discard; } - frag_data[0] = vec4(col.rgb, col.a * 0.005); - frag_data[1] = texture2D(specularMap, vary_texcoord0.xy); - frag_data[2] = vec4(texture2D(normalMap, vary_texcoord0.xy).xyz, 0.0); + frag_data[0] = vec4(linear_to_srgb(col.rgb), col.a); + frag_data[1] = vec4(texture2D(specularMap, vary_texcoord0.xy)); + frag_data[2] = vec4(texture2D(normalMap, vary_texcoord0.xy).xy,0,0); } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index b5d37ba5cc..60e22c08dc 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -224,8 +224,13 @@ void LLDrawPoolAlpha::render(S32 pass) gGL.setColorMask(true, true); } - LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy || - (deferred_render && pass == 1) ? GL_TRUE : GL_FALSE); + bool write_depth = LLDrawPoolWater::sSkipScreenCopy + || (deferred_render && pass == 1) + // we want depth written so that rendered alpha will + // contribute to the alpha mask used for impostors + || LLPipeline::sImpostorRender; + + LLGLDepthTest depth(GL_TRUE, write_depth ? GL_TRUE : GL_FALSE); if (deferred_render && pass == 1) { diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index e2a23ef56f..9434b51685 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -505,7 +505,7 @@ S32 LLDrawPoolAvatar::getNumDeferredPasses() { if (LLPipeline::sImpostorRender) { - return 3; + return 19; } else { @@ -690,28 +690,15 @@ void LLDrawPoolAvatar::beginDeferredImpostor() LLVOAvatar::sNumVisibleAvatars = 0; } -#if DEFERRED_IMPOSTORS sVertexProgram = &gDeferredImpostorProgram; - - specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); - normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); - sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); -#else - sVertexProgram = &gImpostorProgram; - sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); -#endif - sVertexProgram->bind(); + gPipeline.bindDeferredShader(*sVertexProgram); sVertexProgram->setMinimumAlpha(0.01f); } void LLDrawPoolAvatar::endDeferredImpostor() { sShaderLevel = mVertexShaderLevel; - sVertexProgram->disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); - sVertexProgram->disableTexture(LLViewerShaderMgr::SPECULAR_MAP); - sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - sVertexProgram->unbind(); - gGL.getTexUnit(0)->activate(); + gPipeline.unbindDeferredShader(*sVertexProgram); } void LLDrawPoolAvatar::beginDeferredRigid() @@ -1268,7 +1255,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) if (impostor) { -#if DEFERRED_IMPOSTORS if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && avatarp->mImpostor.isComplete()) { if (normal_channel > -1) @@ -1280,7 +1266,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) avatarp->mImpostor.bindTexture(1, specular_channel); } } -#endif avatarp->renderImpostor(LLColor4U(255,255,255,255), sDiffuseChannel); } return; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9aa375767b..29b7e30655 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -11358,15 +11358,18 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) if (!avatar->mImpostor.isComplete()) { LLFastTimer t(FTM_IMPOSTOR_ALLOCATE); - avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,FALSE); + -#if DEFERRED_IMPOSTORS if (LLPipeline::sRenderDeferred) { + avatar->mImpostor.allocate(resX,resY,GL_SRGB8_ALPHA8,TRUE,FALSE); addDeferredAttachments(avatar->mImpostor); } -#endif - + else + { + avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,FALSE); + } + gGL.getTexUnit(0)->bind(&avatar->mImpostor); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -11374,38 +11377,34 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) else if(resX != avatar->mImpostor.getWidth() || resY != avatar->mImpostor.getHeight()) { LLFastTimer t(FTM_IMPOSTOR_RESIZE); - avatar->mImpostor.resize(resX,resY,GL_RGBA); + avatar->mImpostor.resize(resX,resY,LLPipeline::sRenderDeferred ? GL_SRGB8_ALPHA8 : GL_RGBA); } avatar->mImpostor.bindTarget(); } -#if DEFERRED_IMPOSTORS if (LLPipeline::sRenderDeferred) { - avatar->mImpostor.clear(); + avatar->mImpostor.clear(); renderGeomDeferred(camera); renderGeomPostDeferred(camera); } else -#endif { LLGLEnable scissor(GL_SCISSOR_TEST); glScissor(0, 0, resX, resY); avatar->mImpostor.clear(); renderGeom(camera); } - + { //create alpha mask based on depth buffer (grey out if muted) LLFastTimer t(FTM_IMPOSTOR_BACKGROUND); -#if DEFERRED_IMPOSTORS if (LLPipeline::sRenderDeferred) { GLuint buff = GL_COLOR_ATTACHMENT0; glDrawBuffersARB(1, &buff); } -#endif LLGLDisable blend(GL_BLEND); -- cgit v1.2.3 From 83fa549b56826f55f0f30244dbceda77a8a5dbfe Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 6 Aug 2013 18:02:26 -0700 Subject: NORSPEC-322 NORSPEC-342 WIP fix black deferred impostors, lighting bugs remain --- indra/newview/lldrawpoolavatar.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra') diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 9434b51685..9dbc85d121 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -691,6 +691,9 @@ void LLDrawPoolAvatar::beginDeferredImpostor() } sVertexProgram = &gDeferredImpostorProgram; + specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); + normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); + sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gPipeline.bindDeferredShader(*sVertexProgram); sVertexProgram->setMinimumAlpha(0.01f); } @@ -698,7 +701,12 @@ void LLDrawPoolAvatar::beginDeferredImpostor() void LLDrawPoolAvatar::endDeferredImpostor() { sShaderLevel = mVertexShaderLevel; + sVertexProgram->disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); + sVertexProgram->disableTexture(LLViewerShaderMgr::SPECULAR_MAP); + sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gPipeline.unbindDeferredShader(*sVertexProgram); + sVertexProgram = NULL; + sDiffuseChannel = 0; } void LLDrawPoolAvatar::beginDeferredRigid() -- cgit v1.2.3 From bfe2377a9a3061094e3c1fa10bb0afed06cac709 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 7 Aug 2013 08:42:35 -0700 Subject: NORSPEC-342 WIP fix issues with skimpy clothes getting too skimpy in impostors --- .../shaders/class1/deferred/impostorF.glsl | 20 ++++++++++++--- indra/newview/lldrawpoolalpha.cpp | 2 +- indra/newview/pipeline.cpp | 29 +++++++++++++++++++++- indra/newview/pipeline.h | 1 + 4 files changed, 47 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index d52744103f..d1eaabf901 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -38,6 +38,17 @@ uniform sampler2D specularMap; VARYING vec2 vary_texcoord0; +vec3 decode_normal (vec2 enc) +{ + vec2 fenc = enc*4-2; + float f = dot(fenc,fenc); + float g = sqrt(1-f/4); + vec3 n; + n.xy = fenc*g; + n.z = 1-f/2; + return n; +} + vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -72,7 +83,10 @@ void main() discard; } - frag_data[0] = vec4(linear_to_srgb(col.rgb), col.a); - frag_data[1] = vec4(texture2D(specularMap, vary_texcoord0.xy)); - frag_data[2] = vec4(texture2D(normalMap, vary_texcoord0.xy).xy,0,0); + vec4 norm = texture2D(normalMap, vary_texcoord0.xy); + vec4 spec = texture2D(specularMap, vary_texcoord0.xy); + + frag_data[0] = vec4(col.rgb, col.a); + frag_data[1] = spec; + frag_data[2] = vec4(norm.xy,0,0); } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 60e22c08dc..8b2cbb1b9d 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -228,7 +228,7 @@ void LLDrawPoolAlpha::render(S32 pass) || (deferred_render && pass == 1) // we want depth written so that rendered alpha will // contribute to the alpha mask used for impostors - || LLPipeline::sImpostorRender; + || LLPipeline::sImpostorRenderAlphaDepthPass; LLGLDepthTest depth(GL_TRUE, write_depth ? GL_TRUE : GL_FALSE); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 29b7e30655..9378c89eb7 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -379,6 +379,7 @@ BOOL LLPipeline::sWaterReflections = FALSE; BOOL LLPipeline::sRenderGlow = FALSE; BOOL LLPipeline::sReflectionRender = FALSE; BOOL LLPipeline::sImpostorRender = FALSE; +BOOL LLPipeline::sImpostorRenderAlphaDepthPass = FALSE; BOOL LLPipeline::sUnderWaterRender = FALSE; BOOL LLPipeline::sTextureBindTest = FALSE; BOOL LLPipeline::sRenderFrameTest = FALSE; @@ -11387,14 +11388,40 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) { avatar->mImpostor.clear(); renderGeomDeferred(camera); + + renderGeomPostDeferred(camera); + + // Shameless hack time: render it all again, + // this time writing the depth + // values we need to generate the alpha mask below + // while preserving the alpha-sorted color rendering + // from the previous pass + // + sImpostorRenderAlphaDepthPass = true; + // depth-only here... + // + gGL.setColorMask(false,false); renderGeomPostDeferred(camera); + sImpostorRenderAlphaDepthPass = false; } else - { + { LLGLEnable scissor(GL_SCISSOR_TEST); glScissor(0, 0, resX, resY); avatar->mImpostor.clear(); renderGeom(camera); + + // Shameless hack time: render it all again, + // this time writing the depth + // values we need to generate the alpha mask below + // while preserving the alpha-sorted color rendering + // from the previous pass + // + sImpostorRenderAlphaDepthPass = true; + // depth-only here... + // + gGL.setColorMask(false,false); + renderGeom(camera); } { //create alpha mask based on depth buffer (grey out if muted) diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 36b293b998..5e68524067 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -588,6 +588,7 @@ public: static BOOL sPickAvatar; static BOOL sReflectionRender; static BOOL sImpostorRender; + static BOOL sImpostorRenderAlphaDepthPass; static BOOL sUnderWaterRender; static BOOL sRenderGlow; static BOOL sTextureBindTest; -- cgit v1.2.3 From f3952f9a8dc368c991d9aaac174bfee5a0dd90e9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 7 Aug 2013 13:35:08 -0700 Subject: NORSPEC-329 fix mangling of diffuse alpha mode by material edits when only one face really has alpha --- indra/newview/llpanelface.h | 15 ++++++++++++++- indra/newview/llviewerobject.cpp | 24 ++++++++++++++++++++++++ indra/newview/llviewerobject.h | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 834ad9e14c..06a45644d0 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -255,7 +255,20 @@ private: // Determine correct alpha mode for current diffuse texture // (i.e. does it have an alpha channel that makes alpha mode useful) // - U8 default_alpha_mode = (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE); + // _panel->isAlpha() "lies" when one face has alpha and the rest do not (NORSPEC-329) + // need to get per-face answer to this question for sane alpha mode retention on updates. + // + U8 default_alpha_mode = object->isImageAlphaBlended(face) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + + if (!current_material.isNull()) + { + default_alpha_mode = current_material->getDiffuseAlphaMode(); + } + + // Insure we don't inherit the default of blend by accident... + // this will be stomped by a legit request to change the alpha mode by the apply() below + // + new_material->setDiffuseAlphaMode(default_alpha_mode); // Do "It"! // diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f29a00e4c4..0070240803 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4517,6 +4517,30 @@ LLViewerTexture *LLViewerObject::getTEImage(const U8 face) const } +bool LLViewerObject::isImageAlphaBlended(const U8 te) const +{ + LLViewerTexture* image = getTEImage(te); + LLGLenum format = image ? image->getPrimaryFormat() : GL_RGB; + switch (format) + { + case GL_RGBA: + case GL_ALPHA: + { + return true; + } + break; + + case GL_RGB: break; + default: + { + llwarns << "Unexpected tex format in LLViewerObject::isImageAlphaBlended...returning no alpha." << llendl; + } + break; + } + + return false; +} + LLViewerTexture *LLViewerObject::getTENormalMap(const U8 face) const { // llassert(mTEImages); diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index ea0d55cda5..16f1f403d3 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -339,6 +339,8 @@ public: LLViewerTexture *getTENormalMap(const U8 te) const; LLViewerTexture *getTESpecularMap(const U8 te) const; + bool isImageAlphaBlended(const U8 te) const; + void fitFaceTexture(const U8 face); void sendTEUpdate() const; // Sends packed representation of all texture entry information -- cgit v1.2.3 From e156e3ff32469d5efdfd4fb96969b8cc4bc056b8 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 7 Aug 2013 15:37:53 -0700 Subject: NORSPEC-343 protect against edits that would set non-alpha faces to diffuse alpha mode blend --- indra/newview/llpanelface.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 06a45644d0..86642e5635 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -258,7 +258,8 @@ private: // _panel->isAlpha() "lies" when one face has alpha and the rest do not (NORSPEC-329) // need to get per-face answer to this question for sane alpha mode retention on updates. // - U8 default_alpha_mode = object->isImageAlphaBlended(face) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + bool is_alpha_face = object->isImageAlphaBlended(face); + U8 default_alpha_mode = is_alpha_face ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; if (!current_material.isNull()) { @@ -278,6 +279,11 @@ private: LLUUID new_normal_map_id = new_material->getNormalID(); LLUUID new_spec_map_id = new_material->getSpecularID(); + if ((new_alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) && !is_alpha_face) + { + new_alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + } + bool is_default_blend_mode = (new_alpha_mode == default_alpha_mode); bool is_need_material = !is_default_blend_mode || !new_normal_map_id.isNull() || !new_spec_map_id.isNull(); -- cgit v1.2.3 From 79686b6974bb07063f2ff470d4ff0cfd38ac8847 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Wed, 7 Aug 2013 16:30:27 -0700 Subject: NORSPEC-342 fix alpha objects appearing black in impostor images --- indra/newview/lldrawpoolalpha.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 8b2cbb1b9d..ba83c95518 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -548,7 +548,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); // If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha. - if (current_shader && + if (current_shader && + !LLPipeline::sImpostorRender && draw_glow_for_this_partition && params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE)) { -- cgit v1.2.3 From 9c1b45b16763d452a3c9175186217d005a9cfd2b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 7 Aug 2013 17:23:23 -0700 Subject: NORSPEC-343 fix oversight and actually apply override to new material when no alpha is present --- indra/newview/llpanelface.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra') diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 86642e5635..562d293d56 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -282,6 +282,7 @@ private: if ((new_alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) && !is_alpha_face) { new_alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + new_material->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE); } bool is_default_blend_mode = (new_alpha_mode == default_alpha_mode); -- cgit v1.2.3 From e34f088104af64bf4468ff0d2f525a898f531bfb Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 11 Aug 2013 08:49:05 -0700 Subject: NORSPEC-341 fix issues with water reflection coloring and abnormals --- .../shaders/class1/deferred/waterF.glsl | 33 +++++++--------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index d49ff72cf0..72c46e240d 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -153,16 +153,12 @@ void main() vec2 refvec3 = distort+refdistort3/dmod_scale; vec4 refcol3 = texture2D(refTex, refvec3); - refcol1.rgb = srgb_to_linear(refcol1.rgb); - refcol2.rgb = srgb_to_linear(refcol2.rgb); - refcol3.rgb = srgb_to_linear(refcol3.rgb); - vec4 refcol = refcol1 + refcol2 + refcol3; float df1 = df.x + df.y + df.z; refcol *= df1 * 0.333; vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; - //wavef.z *= max(-viewVec.z, 0.1); + wavef.z *= max(-viewVec.z, 0.1); wavef = normalize(wavef); float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; @@ -173,15 +169,13 @@ void main() float dweight = min(dist2*blurMultiplier, 1.0); vec4 baseCol = texture2D(refTex, refvec4); - baseCol.rgb = srgb_to_linear(baseCol.rgb); - refcol = mix(baseCol*df2, refcol, dweight); //get specular component - //float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); + float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); //harden specular - //spec = pow(spec, 128.0); + spec = pow(spec, 128.0); //figure out distortion vector (ripply) vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); @@ -192,24 +186,17 @@ void main() // Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); - float shadow = 1.0; vec4 pos = vary_position; - - //vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz; - vec4 spos = pos; - //spec *= shadow; - //color.rgb += spec * specular; - + color.rgb += spec * specular; + color.rgb = atmosTransport(color.rgb); color.rgb = scaleSoftClip(color.rgb); - color.a = sunAngle2; + color.a = spec * sunAngle2; - //wavef.z *= 0.1f; - //wavef = normalize(wavef); - vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz; + vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz); - frag_data[0] = vec4(color.rgb, color.a); // diffuse - frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec - frag_data[2] = vec4(encode_normal(screenspacewavef.xyz*0.5+0.5), screenspacewavef.z * 0.16, 0.0);// normalxyz, env intensity + frag_data[0] = vec4(color.rgb, color); // diffuse + frag_data[1] = vec4(0); // speccolor, spec + frag_data[2] = vec4(encode_normal(screenspacewavef.xyz*0.5+0.5), 0.05, 0);// normalxy, 0, 0 } -- cgit v1.2.3 From 61129c73c97accf297943d6bc5beea3c09579084 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 12 Aug 2013 10:12:09 -0700 Subject: NORSPEC-346 fix knock-on causing alpha mask edits to cause materials to get removed and revert to alpha blend --- indra/newview/llpanelface.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 562d293d56..46b3375f64 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -259,8 +259,13 @@ private: // need to get per-face answer to this question for sane alpha mode retention on updates. // bool is_alpha_face = object->isImageAlphaBlended(face); - U8 default_alpha_mode = is_alpha_face ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + // need to keep this original answer for valid comparisons in logic below + // + U8 original_default_alpha_mode = is_alpha_face ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + + U8 default_alpha_mode = original_default_alpha_mode; + if (!current_material.isNull()) { default_alpha_mode = current_material->getDiffuseAlphaMode(); @@ -285,7 +290,7 @@ private: new_material->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE); } - bool is_default_blend_mode = (new_alpha_mode == default_alpha_mode); + bool is_default_blend_mode = (new_alpha_mode == original_default_alpha_mode); bool is_need_material = !is_default_blend_mode || !new_normal_map_id.isNull() || !new_spec_map_id.isNull(); if (!is_need_material) -- cgit v1.2.3 From 51dfcb9c67f7c3464bf3640adfdd87a061f60390 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 12 Aug 2013 15:55:25 -0700 Subject: NORSPEC-342 WIP MATBUG-347 make impostor rendering not contribute to depth for mostly-transparent buffer pixels, aka hair in ALM only --- .../shaders/class1/deferred/alphaF.glsl | 19 +++++++++-- .../shaders/class1/deferred/impostorF.glsl | 2 ++ indra/newview/lldrawpoolalpha.cpp | 11 +++++-- indra/newview/lldrawpoolavatar.cpp | 8 ++--- indra/newview/llviewershadermgr.cpp | 37 ++++++++++++++++++++++ indra/newview/llviewershadermgr.h | 1 + indra/newview/pipeline.cpp | 5 +++ 7 files changed, 74 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d0c7cc9dde..f35ff25dcb 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -531,6 +531,19 @@ void main() vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif +#if FOR_IMPOSTOR + vec4 color; + color.rgb = diff.rgb; + color.a = diff.a; + + // Insure we don't pollute depth with invis pixels in impostor rendering + // + if (color.a < 0.01) + { + discard; + } +#else + #ifdef USE_VERTEX_COLOR float final_alpha = diff.a * vertex_color.a; diff.rgb *= vertex_color.rgb; @@ -538,6 +551,7 @@ void main() float final_alpha = diff.a; #endif + vec4 gamma_diff = diff; diff.rgb = srgb_to_linear(diff.rgb); @@ -567,11 +581,10 @@ void main() ambient = (1.0-ambient); color.rgb *= ambient; - color.rgb += atmosAffectDirectionalLight(final_da); color.rgb *= gamma_diff.rgb; - color.rgb = mix(diff.rgb, color.rgb, final_alpha); + //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); @@ -600,6 +613,8 @@ void main() #ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); +#endif + #endif frag_color = color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index d1eaabf901..506323fdce 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -86,6 +86,8 @@ void main() vec4 norm = texture2D(normalMap, vary_texcoord0.xy); vec4 spec = texture2D(specularMap, vary_texcoord0.xy); + col.rgb = linear_to_srgb(col.rgb); + frag_data[0] = vec4(col.rgb, col.a); frag_data[1] = spec; frag_data[2] = vec4(norm.xy,0,0); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index ba83c95518..a8010d17d6 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -93,7 +93,12 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) if (pass == 0) { - if (LLPipeline::sUnderWaterRender) + if (LLPipeline::sImpostorRender) + { + simple_shader = &gDeferredAlphaImpostorProgram; + fullbright_shader = &gDeferredFullbrightProgram; + } + else if (LLPipeline::sUnderWaterRender) { simple_shader = &gDeferredAlphaWaterProgram; fullbright_shader = &gDeferredFullbrightWaterProgram; @@ -116,7 +121,7 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) simple_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); } - else + else if (!LLPipeline::sImpostorRender) { //update depth buffer sampler gPipeline.mScreen.flush(); @@ -156,7 +161,7 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) void LLDrawPoolAlpha::endPostDeferredPass(S32 pass) { - if (pass == 1) + if (pass == 1 && !LLPipeline::sImpostorRender) { gPipeline.mDeferredDepth.flush(); gPipeline.mScreen.bindTarget(); diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 9dbc85d121..8b1e934224 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -691,7 +691,7 @@ void LLDrawPoolAvatar::beginDeferredImpostor() } sVertexProgram = &gDeferredImpostorProgram; - specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); + specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gPipeline.bindDeferredShader(*sVertexProgram); @@ -701,12 +701,12 @@ void LLDrawPoolAvatar::beginDeferredImpostor() void LLDrawPoolAvatar::endDeferredImpostor() { sShaderLevel = mVertexShaderLevel; - sVertexProgram->disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); + sVertexProgram->disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); sVertexProgram->disableTexture(LLViewerShaderMgr::SPECULAR_MAP); sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gPipeline.unbindDeferredShader(*sVertexProgram); - sVertexProgram = NULL; - sDiffuseChannel = 0; + sVertexProgram = NULL; + sDiffuseChannel = 0; } void LLDrawPoolAvatar::beginDeferredRigid() diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 264655029a..b2f7949388 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -197,6 +197,7 @@ LLGLSLShader gDeferredShadowAlphaMaskProgram; LLGLSLShader gDeferredAvatarShadowProgram; LLGLSLShader gDeferredAttachmentShadowProgram; LLGLSLShader gDeferredAlphaProgram; +LLGLSLShader gDeferredAlphaImpostorProgram; LLGLSLShader gDeferredAlphaWaterProgram; LLGLSLShader gDeferredAvatarEyesProgram; LLGLSLShader gDeferredFullbrightProgram; @@ -304,6 +305,8 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredAlphaProgram); + mShaderList.push_back(&gDeferredAlphaProgram); + mShaderList.push_back(&gDeferredAlphaImpostorProgram); mShaderList.push_back(&gDeferredAlphaWaterProgram); mShaderList.push_back(&gDeferredSkinnedAlphaProgram); mShaderList.push_back(&gDeferredFullbrightProgram); @@ -1531,6 +1534,40 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mFeatures.hasLighting = true; } + if (success) + { + gDeferredAlphaImpostorProgram.mName = "Deferred Alpha Shader"; + + gDeferredAlphaImpostorProgram.mFeatures.calculatesLighting = false; + gDeferredAlphaImpostorProgram.mFeatures.hasLighting = false; + gDeferredAlphaImpostorProgram.mFeatures.isAlphaLighting = true; + gDeferredAlphaImpostorProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels + if (mVertexShaderLevel[SHADER_DEFERRED] < 1) + { + gDeferredAlphaImpostorProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + } + else + { //shave off some texture units for shadow maps + gDeferredAlphaImpostorProgram.mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); + } + + gDeferredAlphaImpostorProgram.mShaderFiles.clear(); + gDeferredAlphaImpostorProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAlphaImpostorProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAlphaImpostorProgram.addPermutation("USE_INDEXED_TEX", "1"); + gDeferredAlphaImpostorProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); + gDeferredAlphaImpostorProgram.addPermutation("USE_VERTEX_COLOR", "1"); + gDeferredAlphaImpostorProgram.addPermutation("FOR_IMPOSTOR", "1"); + + gDeferredAlphaImpostorProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + + success = gDeferredAlphaImpostorProgram.createShader(NULL, NULL); + + // Hack + gDeferredAlphaImpostorProgram.mFeatures.calculatesLighting = true; + gDeferredAlphaImpostorProgram.mFeatures.hasLighting = true; + } + if (success) { gDeferredAlphaWaterProgram.mName = "Deferred Alpha Underwater Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 5fa9b82170..08c1ce6911 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -364,6 +364,7 @@ extern LLGLSLShader gDeferredPostGammaCorrectProgram; extern LLGLSLShader gDeferredAvatarShadowProgram; extern LLGLSLShader gDeferredAttachmentShadowProgram; extern LLGLSLShader gDeferredAlphaProgram; +extern LLGLSLShader gDeferredAlphaImpostorProgram; extern LLGLSLShader gDeferredFullbrightProgram; extern LLGLSLShader gDeferredFullbrightAlphaMaskProgram; extern LLGLSLShader gDeferredAlphaWaterProgram; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9378c89eb7..31baf4188b 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -11402,7 +11402,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) // gGL.setColorMask(false,false); renderGeomPostDeferred(camera); + sImpostorRenderAlphaDepthPass = false; + } else { @@ -11418,10 +11420,13 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) // from the previous pass // sImpostorRenderAlphaDepthPass = true; + // depth-only here... // gGL.setColorMask(false,false); renderGeom(camera); + + sImpostorRenderAlphaDepthPass = false; } { //create alpha mask based on depth buffer (grey out if muted) -- cgit v1.2.3 From a43a762c0ddf3ecac2056b36d0ede1f99e71231e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 12 Aug 2013 17:22:47 -0700 Subject: NORSPEC-342 fix blocky hair in ALM from writing depth for transparent pixels in impostor rendering --- indra/newview/lldrawpoolalpha.cpp | 8 +++++++- indra/newview/lldrawpoolsimple.cpp | 6 +++++- indra/newview/llviewershadermgr.cpp | 25 +++++++++++++++++++++++++ indra/newview/llviewershadermgr.h | 1 + 4 files changed, 38 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index a8010d17d6..5ebc58fb7d 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -181,7 +181,13 @@ void LLDrawPoolAlpha::beginRenderPass(S32 pass) { LLFastTimer t(FTM_RENDER_ALPHA); - if (LLPipeline::sUnderWaterRender) + if (LLPipeline::sImpostorRender) + { + simple_shader = &gObjectSimpleImpostorProgram; + fullbright_shader = &gObjectFullbrightProgram; + emissive_shader = &gObjectEmissiveProgram; + } + else if (LLPipeline::sUnderWaterRender) { simple_shader = &gObjectSimpleWaterProgram; fullbright_shader = &gObjectFullbrightWaterProgram; diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index aee9d19d19..8926f64c64 100755 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -156,7 +156,11 @@ void LLDrawPoolSimple::beginRenderPass(S32 pass) { LLFastTimer t(FTM_RENDER_SIMPLE); - if (LLPipeline::sUnderWaterRender) + if (LLPipeline::sImpostorRender) + { + simple_shader = &gObjectSimpleImpostorProgram; + } + else if (LLPipeline::sUnderWaterRender) { simple_shader = &gObjectSimpleWaterProgram; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index b2f7949388..995eb599b8 100755 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -83,6 +83,7 @@ LLGLSLShader gAlphaMaskProgram; //object shaders LLGLSLShader gObjectSimpleProgram; +LLGLSLShader gObjectSimpleImpostorProgram; LLGLSLShader gObjectPreviewProgram; LLGLSLShader gObjectSimpleWaterProgram; LLGLSLShader gObjectSimpleAlphaMaskProgram; @@ -237,6 +238,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gWaterProgram); mShaderList.push_back(&gAvatarEyeballProgram); mShaderList.push_back(&gObjectSimpleProgram); + mShaderList.push_back(&gObjectSimpleImpostorProgram); mShaderList.push_back(&gObjectPreviewProgram); mShaderList.push_back(&gImpostorProgram); mShaderList.push_back(&gObjectFullbrightNoColorProgram); @@ -729,6 +731,7 @@ void LLViewerShaderMgr::unloadShaders() gObjectFullbrightNoColorProgram.unload(); gObjectFullbrightNoColorWaterProgram.unload(); gObjectSimpleProgram.unload(); + gObjectSimpleImpostorProgram.unload(); gObjectPreviewProgram.unload(); gImpostorProgram.unload(); gObjectSimpleAlphaMaskProgram.unload(); @@ -2020,6 +2023,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightNoColorProgram.unload(); gObjectFullbrightNoColorWaterProgram.unload(); gObjectSimpleProgram.unload(); + gObjectSimpleImpostorProgram.unload(); gObjectPreviewProgram.unload(); gImpostorProgram.unload(); gObjectSimpleAlphaMaskProgram.unload(); @@ -2440,6 +2444,27 @@ BOOL LLViewerShaderMgr::loadShadersObject() success = gObjectSimpleProgram.createShader(NULL, NULL); } + if (success) + { + gObjectSimpleImpostorProgram.mName = "Simple Impostor Shader"; + gObjectSimpleImpostorProgram.mFeatures.calculatesLighting = true; + gObjectSimpleImpostorProgram.mFeatures.calculatesAtmospherics = true; + gObjectSimpleImpostorProgram.mFeatures.hasGamma = true; + gObjectSimpleImpostorProgram.mFeatures.hasAtmospherics = true; + gObjectSimpleImpostorProgram.mFeatures.hasLighting = true; + gObjectSimpleImpostorProgram.mFeatures.mIndexedTextureChannels = 0; + // force alpha mask version of lighting so we can weed out + // transparent pixels from impostor temp buffer + // + gObjectSimpleImpostorProgram.mFeatures.hasAlphaMask = true; + gObjectSimpleImpostorProgram.mShaderFiles.clear(); + gObjectSimpleImpostorProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectSimpleImpostorProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectSimpleImpostorProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + + success = gObjectSimpleImpostorProgram.createShader(NULL, NULL); + } + if (success) { gObjectSimpleWaterProgram.mName = "Simple Water Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 08c1ce6911..e4684c19d5 100755 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -242,6 +242,7 @@ extern LLGLSLShader gOneTextureNoColorProgram; //object shaders extern LLGLSLShader gObjectSimpleProgram; +extern LLGLSLShader gObjectSimpleImpostorProgram; extern LLGLSLShader gObjectPreviewProgram; extern LLGLSLShader gObjectSimpleAlphaMaskProgram; extern LLGLSLShader gObjectSimpleWaterProgram; -- cgit v1.2.3 From e586f0325f23363e0223162f4643c7c4c1dfe4a4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 12 Aug 2013 17:45:11 -0700 Subject: NORSPEC-342 tweak shader to work on mac og glsl --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f35ff25dcb..d1abebf84c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -531,7 +531,7 @@ void main() vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif -#if FOR_IMPOSTOR +#ifdef FOR_IMPOSTOR vec4 color; color.rgb = diff.rgb; color.a = diff.a; -- cgit v1.2.3 From 5fb214a37fd68cf6f9b33206a7952db3351e05b5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 13 Aug 2013 20:30:07 -0700 Subject: NORSPEC-342 fix the invisi-feet --- indra/newview/pipeline.cpp | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 31baf4188b..314a2ae295 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -11240,26 +11240,32 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) } else { - andRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, - LLPipeline::RENDER_TYPE_AVATAR, - LLPipeline::RENDER_TYPE_BUMP, - LLPipeline::RENDER_TYPE_GRASS, - LLPipeline::RENDER_TYPE_SIMPLE, - LLPipeline::RENDER_TYPE_FULLBRIGHT, - LLPipeline::RENDER_TYPE_ALPHA, - LLPipeline::RENDER_TYPE_INVISIBLE, - LLPipeline::RENDER_TYPE_PASS_SIMPLE, - LLPipeline::RENDER_TYPE_PASS_ALPHA, - LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, - LLPipeline::RENDER_TYPE_PASS_SHINY, - LLPipeline::RENDER_TYPE_PASS_INVISIBLE, - LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, - END_RENDER_TYPES); + andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_FULLBRIGHT, + LLPipeline::RENDER_TYPE_VOLUME, + LLPipeline::RENDER_TYPE_GLOW, + LLPipeline::RENDER_TYPE_BUMP, + LLPipeline::RENDER_TYPE_PASS_SIMPLE, + LLPipeline::RENDER_TYPE_PASS_ALPHA, + LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_BUMP, + LLPipeline::RENDER_TYPE_PASS_POST_BUMP, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, + LLPipeline::RENDER_TYPE_PASS_GLOW, + LLPipeline::RENDER_TYPE_PASS_GRASS, + LLPipeline::RENDER_TYPE_PASS_SHINY, + LLPipeline::RENDER_TYPE_PASS_INVISIBLE, + LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, + LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_ALPHA_MASK, + LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, + LLPipeline::RENDER_TYPE_INVISIBLE, + LLPipeline::RENDER_TYPE_ALPHA, + END_RENDER_TYPES); } - + S32 occlusion = sUseOcclusion; sUseOcclusion = 0; -- cgit v1.2.3 From 55c36ab7dbee9463c3df72d60cdc882cdeb69b9d Mon Sep 17 00:00:00 2001 From: Arun Bapu Date: Wed, 14 Aug 2013 11:35:06 -0700 Subject: Fix for NORSPEC 271 - Transparent prims in Materials Viewer are incorrectly affecting depth of field by modifying the depth buffer --- indra/newview/lldrawpoolalpha.cpp | 27 ++++++++++++++++++++++----- indra/newview/lldrawpoolalpha.h | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index ba83c95518..9c510d360f 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -100,7 +100,7 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) } else { - simple_shader = &gDeferredAlphaProgram; + simple_shader = &gDeferredAlphaProgram; fullbright_shader = &gDeferredFullbrightProgram; } @@ -276,11 +276,11 @@ void LLDrawPoolAlpha::render(S32 pass) if (mVertexShaderLevel > 0) { - renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2); + renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2, pass); } else { - renderAlpha(getVertexDataMask()); + renderAlpha(getVertexDataMask(), pass); } gGL.setColorMask(true, false); @@ -352,7 +352,7 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask) } } -void LLDrawPoolAlpha::renderAlpha(U32 mask) +void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) { BOOL initialized_lighting = FALSE; BOOL light_enabled = TRUE; @@ -385,6 +385,23 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) continue; } + // Fix for bug - NORSPEC-271 + // If the face is more than 90% transparent, then don't update the Depth buffer for Dof + // We don't want the nearly invisible objects to cause of DoF effects + if(pass == 1) + { + LLFace* face = params.mFace; + if(face) + { + const LLTextureEntry* tep = face->getTextureEntry(); + if(tep) + { + if(tep->getColor().mV[3] < 0.1f) + continue; + } + } + } + LLRenderPass::applyModelMatrix(params); LLMaterial* mat = NULL; @@ -548,7 +565,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); // If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha. - if (current_shader && + if (current_shader && !LLPipeline::sImpostorRender && draw_glow_for_this_partition && params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE)) diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h index 43122218ed..d064a3a324 100755 --- a/indra/newview/lldrawpoolalpha.h +++ b/indra/newview/lldrawpoolalpha.h @@ -63,7 +63,7 @@ public: /*virtual*/ void prerender(); void renderGroupAlpha(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE); - void renderAlpha(U32 mask); + void renderAlpha(U32 mask, S32 pass); void renderAlphaHighlight(U32 mask); static BOOL sShowDebugAlpha; -- cgit v1.2.3 From 8f4a481610f64fc37b00fae1c71f57ece3972d8f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 14 Aug 2013 16:31:50 -0700 Subject: NORSPEC-342 add simple pass type to things rendered for impostors to fix missing shoes/belts/handbags/cigarettecases/etc --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 314a2ae295..bade7a9f52 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -11262,7 +11262,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) LLPipeline::RENDER_TYPE_ALPHA_MASK, LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, LLPipeline::RENDER_TYPE_INVISIBLE, - LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_SIMPLE, END_RENDER_TYPES); } -- cgit v1.2.3 From 141c34cff46a7f2be868df45aa1a8de7b95fa4a4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 15 Aug 2013 08:00:47 -0700 Subject: NORSPEC-342 NORSPEC-352 make impostor alpha shader use vertex alpha to remedy unsightly blemishes, boxes, and the occasional extra wing. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d1abebf84c..cd7a76db28 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -534,11 +534,17 @@ void main() #ifdef FOR_IMPOSTOR vec4 color; color.rgb = diff.rgb; - color.a = diff.a; + +#ifdef USE_VERTEX_COLOR + float final_alpha = diff.a * vertex_color.a; + diff.rgb *= vertex_color.rgb; +#else + float final_alpha = diff.a; +#endif // Insure we don't pollute depth with invis pixels in impostor rendering // - if (color.a < 0.01) + if (final_alpha < 0.01) { discard; } -- cgit v1.2.3 From dc63061714b0872a123ca769cd3683ab233c9915 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 15 Aug 2013 09:37:54 -0700 Subject: NORSPEC-352 for non-ALM rendering, make lighting shader with alpha masking obey vertex alpha --- indra/llrender/llrendertarget.cpp | 2 +- .../newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 09ef780424..a011e81b99 100755 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -113,7 +113,7 @@ void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt) sBytesAllocated += pix_diff*4; } } - + bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples) { diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl index eaaa7b208d..cad5b9ff04 100755 --- a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl @@ -41,13 +41,13 @@ void default_lighting() { vec4 color = diffuseLookup(vary_texcoord0.xy); + color *= vertex_color; + if (color.a < minimum_alpha) { discard; } - color.rgb *= vertex_color.rgb; - color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); -- cgit v1.2.3 From 80256fdbf5fe444c177be793b12d0da58ce2b608 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 15 Aug 2013 10:07:41 -0700 Subject: NORSPEC-349 make render targets use original formats when resizing impostors and fix alpha for deferred impostor shader --- indra/llrender/llrendertarget.cpp | 6 ++++-- indra/llrender/llrendertarget.h | 2 +- indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl | 2 +- indra/newview/pipeline.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index a011e81b99..731e0bc2b3 100755 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -79,7 +79,7 @@ LLRenderTarget::~LLRenderTarget() release(); } -void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt) +void LLRenderTarget::resize(U32 resx, U32 resy) { //for accounting, get the number of pixels added/subtracted S32 pix_diff = (resx*resy)-(mResX*mResY); @@ -87,10 +87,12 @@ void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt) mResX = resx; mResY = resy; + llassert(mInternalFormat.size() == mTex.size()); + for (U32 i = 0; i < mTex.size(); ++i) { //resize color attachments gGL.getTexUnit(0)->bindManual(mUsage, mTex[i]); - LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false); + LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, mInternalFormat[i], mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false); sBytesAllocated += pix_diff*4; } diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index 66a9874a6b..336441661c 100755 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h @@ -79,7 +79,7 @@ public: // CAUTION: if the GL runs out of memory attempting to resize, this render target will be undefined // DO NOT use for screen space buffers or for scratch space for an image that might be uploaded // DO use for render targets that resize often and aren't likely to ruin someone's day if they break - void resize(U32 resx, U32 resy, U32 color_fmt); + void resize(U32 resx, U32 resy); //add color buffer attachment //limit of 4 color attachments per render target diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index 506323fdce..f8fdde43f9 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -88,7 +88,7 @@ void main() col.rgb = linear_to_srgb(col.rgb); - frag_data[0] = vec4(col.rgb, col.a); + frag_data[0] = vec4(col.rgb, 0.0); frag_data[1] = spec; frag_data[2] = vec4(norm.xy,0,0); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bade7a9f52..1ca4115a5e 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -11384,7 +11384,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) else if(resX != avatar->mImpostor.getWidth() || resY != avatar->mImpostor.getHeight()) { LLFastTimer t(FTM_IMPOSTOR_RESIZE); - avatar->mImpostor.resize(resX,resY,LLPipeline::sRenderDeferred ? GL_SRGB8_ALPHA8 : GL_RGBA); + avatar->mImpostor.resize(resX,resY); } avatar->mImpostor.bindTarget(); -- cgit v1.2.3 From 62011c2871bdb09b92c56d2959eed64ba6ec3e1f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 19 Aug 2013 12:56:04 -0700 Subject: Fix merge issues from genBBoxes optimizations fighting with genBBoxes optimizations and missing statics --- indra/llmath/llvolume.cpp | 157 +++++++++++++++++++++---------------------- indra/newview/llface.cpp | 98 ++++++++++----------------- indra/newview/llface.h | 3 +- indra/newview/llvovolume.cpp | 2 +- indra/newview/pipeline.cpp | 2 + indra/newview/pipeline.h | 4 +- 6 files changed, 119 insertions(+), 147 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index ad0ca618a0..a030d889af 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -136,6 +136,82 @@ BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* cent return true; } +// Finds tangent vec based on three vertices with texture coordinates. +// Fills in dummy values if the triangle has degenerate texture coordinates. +void calc_tangent_from_triangle( + LLVector4a& normal, + LLVector4a& tangent_out, + const LLVector4a& v1, + const LLVector2& w1, + const LLVector4a& v2, + const LLVector2& w2, + const LLVector4a& v3, + const LLVector2& w3) +{ + const F32* v1ptr = v1.getF32ptr(); + const F32* v2ptr = v2.getF32ptr(); + const F32* v3ptr = v3.getF32ptr(); + + float x1 = v2ptr[0] - v1ptr[0]; + float x2 = v3ptr[0] - v1ptr[0]; + float y1 = v2ptr[1] - v1ptr[1]; + float y2 = v3ptr[1] - v1ptr[1]; + float z1 = v2ptr[2] - v1ptr[2]; + float z2 = v3ptr[2] - v1ptr[2]; + + float s1 = w2.mV[0] - w1.mV[0]; + float s2 = w3.mV[0] - w1.mV[0]; + float t1 = w2.mV[1] - w1.mV[1]; + float t2 = w3.mV[1] - w1.mV[1]; + + F32 rd = s1*t2-s2*t1; + + float r = ((rd*rd) > FLT_EPSILON) ? 1.0F / rd : 1024.f; //some made up large ratio for division by zero + + llassert(llfinite(r)); + llassert(!llisnan(r)); + + LLVector4a sdir( + (t2 * x1 - t1 * x2) * r, + (t2 * y1 - t1 * y2) * r, + (t2 * z1 - t1 * z2) * r); + + LLVector4a tdir( + (s1 * x2 - s2 * x1) * r, + (s1 * y2 - s2 * y1) * r, + (s1 * z2 - s2 * z1) * r); + + LLVector4a n = normal; + LLVector4a t = sdir; + + LLVector4a ncrosst; + ncrosst.setCross3(n,t); + + // Gram-Schmidt orthogonalize + n.mul(n.dot3(t).getF32()); + + LLVector4a tsubn; + tsubn.setSub(t,n); + + if (tsubn.dot3(tsubn).getF32() > F_APPROXIMATELY_ZERO) + { + tsubn.normalize3fast_checked(); + + // Calculate handedness + F32 handedness = ncrosst.dot3(tdir).getF32() < 0.f ? -1.f : 1.f; + + tsubn.getF32ptr()[3] = handedness; + + tangent_out = tsubn; + } + else + { + // degenerate, make up a value + // + tangent_out.set(0,0,1,1); + } + +} // intersect test between triangle vert0, vert1, vert2 and a ray from orig in direction dir. @@ -5908,10 +5984,10 @@ void LLVolumeFace::cacheOptimize() wght = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); } - LLVector4a* binorm = NULL; + LLVector4a* tangent = NULL; if (mTangents) { - binorm = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); + tangent = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); } //allocate mapping of old indices to new indices @@ -7277,83 +7353,6 @@ void calc_binormal_from_triangle(LLVector4a& binormal, } } -// Finds binormal based on three vertices with texture coordinates. -// Fills in dummy values if the triangle has degenerate texture coordinates. -void calc_tangent_from_triangle( - LLVector4a& normal, - LLVector4a& tangent_out, - const LLVector4a& v1, - const LLVector2& w1, - const LLVector4a& v2, - const LLVector2& w2, - const LLVector4a& v3, - const LLVector2& w3) -{ - const F32* v1ptr = v1.getF32ptr(); - const F32* v2ptr = v2.getF32ptr(); - const F32* v3ptr = v3.getF32ptr(); - - float x1 = v2ptr[0] - v1ptr[0]; - float x2 = v3ptr[0] - v1ptr[0]; - float y1 = v2ptr[1] - v1ptr[1]; - float y2 = v3ptr[1] - v1ptr[1]; - float z1 = v2ptr[2] - v1ptr[2]; - float z2 = v3ptr[2] - v1ptr[2]; - - float s1 = w2.mV[0] - w1.mV[0]; - float s2 = w3.mV[0] - w1.mV[0]; - float t1 = w2.mV[1] - w1.mV[1]; - float t2 = w3.mV[1] - w1.mV[1]; - - F32 rd = s1*t2-s2*t1; - - float r = ((rd*rd) > FLT_EPSILON) ? 1.0F / rd : 1024.f; //some made up large ratio for division by zero - - llassert(llfinite(r)); - llassert(!llisnan(r)); - - LLVector4a sdir( - (t2 * x1 - t1 * x2) * r, - (t2 * y1 - t1 * y2) * r, - (t2 * z1 - t1 * z2) * r); - - LLVector4a tdir( - (s1 * x2 - s2 * x1) * r, - (s1 * y2 - s2 * y1) * r, - (s1 * z2 - s2 * z1) * r); - - LLVector4a n = normal; - LLVector4a t = sdir; - - LLVector4a ncrosst; - ncrosst.setCross3(n,t); - - // Gram-Schmidt orthogonalize - n.mul(n.dot3(t).getF32()); - - LLVector4a tsubn; - tsubn.setSub(t,n); - - if (tsubn.dot3(tsubn).getF32() > F_APPROXIMATELY_ZERO) - { - tsubn.normalize3fast_checked(); - - // Calculate handedness - F32 handedness = ncrosst.dot3(tdir).getF32() < 0.f ? -1.f : 1.f; - - tsubn.getF32ptr()[3] = handedness; - - tangent_out = tsubn; - } - else - { - // degenerate, make up a value - // - tangent_out.set(0,0,1,1); - } - -} - //adapted from Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”. Terathon Software 3D Graphics Library, 2001. http://www.terathon.com/code/tangent.html void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal, const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent) diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 700b31f8d3..53e5b55b89 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -768,7 +768,7 @@ bool less_than_max_mag(const LLVector4a& vec) } BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, - const LLMatrix4& mat_vert_in, const LLMatrix3& mat_normal_in, BOOL global_volume) + const LLMatrix4& mat_vert_in, BOOL global_volume) { //get bounding box if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION | LLDrawable::REBUILD_RIGGED)) @@ -777,10 +777,6 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, LLMatrix4a mat_vert; mat_vert.loadu(mat_vert_in); - LLMatrix4a mat_normal; - mat_normal.loadu(mat_normal_in); - - //VECTORIZE THIS LLVector4a min,max; if (f >= volume.getNumVolumeFaces()) @@ -797,95 +793,69 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, llassert(less_than_max_mag(max)); //min, max are in volume space, convert to drawable render space - LLVector4a center; - LLVector4a t; - t.setAdd(min, max); - t.mul(0.5f); - mat_vert.affineTransform(t, center); - LLVector4a size; - size.setSub(max, min); - size.mul(0.5f); - llassert(less_than_max_mag(min)); - llassert(less_than_max_mag(max)); + //get 8 corners of bounding box + LLVector4Logical mask[6]; - if (!global_volume) + for (U32 i = 0; i < 6; ++i) { - //VECTORIZE THIS - LLVector4a scale; - scale.load3(mDrawablep->getVObj()->getScale().mV); - size.mul(scale); + mask[i].clear(); } - mat_normal.mMatrix[0].normalize3fast(); - mat_normal.mMatrix[1].normalize3fast(); - mat_normal.mMatrix[2].normalize3fast(); + mask[0].setElement<2>(); //001 + mask[1].setElement<1>(); //010 + mask[2].setElement<1>(); //011 + mask[2].setElement<2>(); + mask[3].setElement<0>(); //100 + mask[4].setElement<0>(); //101 + mask[4].setElement<2>(); + mask[5].setElement<0>(); //110 + mask[5].setElement<1>(); - LLVector4a v[4]; + LLVector4a v[8]; - //get 4 corners of bounding box - mat_normal.rotate(size,v[0]); + v[6] = min; + v[7] = max; - //VECTORIZE THIS - LLVector4a scale; - - scale.set(-1.f, -1.f, 1.f); - scale.mul(size); - mat_normal.rotate(scale, v[1]); + for (U32 i = 0; i < 6; ++i) + { + v[i].setSelectWithMask(mask[i], min, max); + } - scale.set(1.f, -1.f, -1.f); - scale.mul(size); - mat_normal.rotate(scale, v[2]); + LLVector4a tv[8]; - scale.set(-1.f, 1.f, -1.f); - scale.mul(size); - mat_normal.rotate(scale, v[3]); + //transform bounding box into drawable space + for (U32 i = 0; i < 8; ++i) + { + mat_vert.affineTransform(v[i], tv[i]); + } + //find bounding box LLVector4a& newMin = mExtents[0]; LLVector4a& newMax = mExtents[1]; - newMin = newMax = center; - - llassert(less_than_max_mag(center)); + newMin = newMax = tv[0]; - for (U32 i = 0; i < 4; i++) + for (U32 i = 1; i < 8; ++i) { - LLVector4a delta; - delta.setAbs(v[i]); - LLVector4a min; - min.setSub(center, delta); - LLVector4a max; - max.setAdd(center, delta); - - newMin.setMin(newMin,min); - newMax.setMax(newMax,max); - - llassert(less_than_max_mag(newMin)); - llassert(less_than_max_mag(newMax)); + newMin.setMin(newMin, tv[i]); + newMax.setMax(newMax, tv[i]); } if (!mDrawablep->isActive()) - { + { // Shift position for region LLVector4a offset; offset.load3(mDrawablep->getRegion()->getOriginAgent().mV); newMin.add(offset); newMax.add(offset); - - llassert(less_than_max_mag(newMin)); - llassert(less_than_max_mag(newMax)); } + LLVector4a t; t.setAdd(newMin, newMax); t.mul(0.5f); - llassert(less_than_max_mag(t)); - - //VECTORIZE THIS mCenterLocal.set(t.getF32ptr()); - llassert(less_than_max_mag(newMin)); - llassert(less_than_max_mag(newMax)); - t.setSub(newMax,newMin); mBoundingSphereRadius = t.getLength3().getF32()*0.5f; diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 763634a3ab..66b5f13740 100755 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -194,8 +194,7 @@ public: void setSize(S32 numVertices, S32 num_indices = 0, bool align = false); - BOOL genVolumeBBoxes(const LLVolume &volume, S32 f, - const LLMatrix4& mat, BOOL global_volume = FALSE); + BOOL genVolumeBBoxes(const LLVolume &volume, S32 f,const LLMatrix4& mat, BOOL global_volume = FALSE); void init(LLDrawable* drawablep, LLViewerObject* objp); void destroy(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 113bdd2ce3..33b26494de 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1458,7 +1458,7 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global) continue; } res &= face->genVolumeBBoxes(*volume, i, - mRelativeXform, mRelativeXformInvTrans, + mRelativeXform, /*mRelativeXformInvTrans,*/ (mVolumeImpl && mVolumeImpl->isVolumeGlobal()) || force_global); if (rebuild) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c4286e73eb..8be7b2ab53 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -169,6 +169,7 @@ S32 LLPipeline::RenderGlowIterations; F32 LLPipeline::RenderGlowWidth; F32 LLPipeline::RenderGlowStrength; BOOL LLPipeline::RenderDepthOfField; +BOOL LLPipeline::RenderDepthOfFieldInEditMode; F32 LLPipeline::CameraFocusTransitionTime; F32 LLPipeline::CameraFNumber; F32 LLPipeline::CameraFocalLength; @@ -379,6 +380,7 @@ BOOL LLPipeline::sWaterReflections = FALSE; BOOL LLPipeline::sRenderGlow = FALSE; BOOL LLPipeline::sReflectionRender = FALSE; BOOL LLPipeline::sImpostorRender = FALSE; +BOOL LLPipeline::sImpostorRenderAlphaDepthPass = FALSE; BOOL LLPipeline::sUnderWaterRender = FALSE; BOOL LLPipeline::sTextureBindTest = FALSE; BOOL LLPipeline::sRenderFrameTest = FALSE; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index f0bebbe20d..fbbcf8f06d 100755 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -295,7 +295,8 @@ public: void unbindDeferredShader(LLGLSLShader& shader); void renderDeferredLighting(); - + void renderDeferredLightingToRT(LLRenderTarget* target); + void generateWaterReflection(LLCamera& camera); void generateSunShadow(LLCamera& camera); void generateHighlight(LLCamera& camera); @@ -594,6 +595,7 @@ public: static BOOL sPickAvatar; static BOOL sReflectionRender; static BOOL sImpostorRender; + static BOOL sImpostorRenderAlphaDepthPass; static BOOL sUnderWaterRender; static BOOL sRenderGlow; static BOOL sTextureBindTest; -- cgit v1.2.3 From 8675ed0491efee860ac1b2d1d5fe88d150768217 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 19 Aug 2013 16:04:28 -0700 Subject: Fix merge regressions from missed changes to LoD updates --- indra/llrender/llvertexbuffer.cpp | 28 ---------------------------- indra/newview/lldrawpoolalpha.cpp | 3 +-- indra/newview/lldrawpoolavatar.cpp | 10 ++++++++++ indra/newview/llvovolume.cpp | 7 +++++++ 4 files changed, 18 insertions(+), 30 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index fd7b846928..6a7cec3bad 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -2209,39 +2209,11 @@ void LLVertexBuffer::bindForFeedback(U32 channel, U32 type, U32 index, U32 count #endif } -void DumpComponents(U32 mask) -{ - llinfos << - ((mask & LLVertexBuffer::MAP_VERTEX) ? "vertex:" : " ") << - ((mask & LLVertexBuffer::MAP_NORMAL) ? "norms:" : " ") << - ((mask & LLVertexBuffer::MAP_TEXCOORD0) ? "TC0:" : " ") << - ((mask & LLVertexBuffer::MAP_TEXCOORD1) ? "TC1:" : " ") << - ((mask & LLVertexBuffer::MAP_TEXCOORD2) ? "TC2:" : " ") << - ((mask & LLVertexBuffer::MAP_TEXCOORD3) ? "TC3:" : " ") << - ((mask & LLVertexBuffer::MAP_COLOR) ? "color:" : " ") << - ((mask & LLVertexBuffer::MAP_EMISSIVE) ? "emissive:" : " ") << - ((mask & LLVertexBuffer::MAP_TANGENT) ? "tangents" : " ") << llendl; -} - // Set for rendering void LLVertexBuffer::setBuffer(U32 data_mask) { flush(); - if((getTypeMask() & data_mask) != data_mask) - { - if (gDebugGL) - { - // Dump info about what was missing - // - DumpComponents(data_mask & ~getTypeMask()); - llwarns << "Missing VB stream components. ^^" << llendl; - } - // Make sure we don't write checks we can't cash below... - // - data_mask = (data_mask & getTypeMask()); - } - //set up pointers if the data mask is different ... bool setup = (sLastMask != data_mask); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 500fad4f78..e4ebfea665 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -399,7 +399,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) // Fix for bug - NORSPEC-271 // If the face is more than 90% transparent, then don't update the Depth buffer for Dof // We don't want the nearly invisible objects to cause of DoF effects - if(pass == 1) + if(pass == 1 && !LLPipeline::sImpostorRender) { LLFace* face = params.mFace; if(face) @@ -577,7 +577,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) // If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha. if (current_shader && - !LLPipeline::sImpostorRender && draw_glow_for_this_partition && params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE)) { diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 120920a4b0..66bbc6819b 100755 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -136,6 +136,16 @@ void LLDrawPoolAvatar::prerender() { sBufferUsage = GL_STREAM_DRAW_ARB; } + + if (!mDrawFace.empty()) + { + const LLFace *facep = mDrawFace[0]; + if (facep && facep->getDrawable()) + { + LLVOAvatar* avatarp = (LLVOAvatar *)facep->getDrawable()->getVObj().get(); + updateRiggedVertexBuffers(avatarp); + } + } } LLMatrix4& LLDrawPoolAvatar::getModelView() diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 33b26494de..6b3611b796 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4863,7 +4863,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (is_rigged) { + if (!drawablep->isState(LLDrawable::RIGGED)) + { drawablep->setState(LLDrawable::RIGGED); + + //first time this is drawable is being marked as rigged, + // do another LoD update to use avatar bounding box + vobj->updateLOD(); + } } else { -- cgit v1.2.3 From 10419d802f88e7636a6ca45c6025b7e19b3ca3c7 Mon Sep 17 00:00:00 2001 From: mberezhnoy Date: Wed, 21 Aug 2013 17:44:39 +0300 Subject: MAINT-3020 ([CHUI] Torn off nearby chat is no longer visible after exiting mouselook) --- indra/newview/llfloaterimcontainer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index 4591b80ac4..836a455a67 100755 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -674,13 +674,18 @@ void LLFloaterIMContainer::setVisible(BOOL visible) void LLFloaterIMContainer::getDetachedConversationFloaters(floater_list_t& floaters) { typedef conversations_widgets_map::value_type conv_pair; + LLFloaterIMNearbyChat *nearby_chat = LLFloaterReg::findTypedInstance("nearby_chat"); + BOOST_FOREACH(conv_pair item, mConversationsWidgets) { LLConversationViewSession* widget = dynamic_cast(item.second); if (widget) { LLFloater* session_floater = widget->getSessionFloater(); - if (session_floater && session_floater->isDetachedAndNotMinimized()) + + // Exclude nearby chat from output, as it should be handled separately + if (session_floater && session_floater->isDetachedAndNotMinimized() + && session_floater != nearby_chat) { floaters.push_back(session_floater); } -- cgit v1.2.3 From 19726783cddb0ac3d34a510c083976e6f9661b49 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Fri, 23 Aug 2013 14:44:46 -0700 Subject: MAINT-3046 make LLNotifications clear out vecs of LLNotificationChannelPtr so singleton cleanup doesn't do things it really ought not do --- indra/llcommon/llinitparam.h | 3 ++- indra/llcommon/llinstancetracker.h | 1 + indra/llui/llnotifications.cpp | 6 +++++- indra/llui/llnotifications.h | 7 +++++++ indra/newview/llappviewer.cpp | 2 ++ 5 files changed, 17 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index ae836645b9..b3b56321d3 100755 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -1952,7 +1952,7 @@ namespace LLInitParam class Mandatory : public TypedParam { typedef TypedParam super_t; - typedef Mandatory self_t; + typedef Mandatory self_t; typedef typename super_t::value_t value_t; typedef typename super_t::default_value_t default_value_t; @@ -1980,6 +1980,7 @@ namespace LLInitParam static bool validate(const Param* p) { // valid only if provided + llassert(p); return static_cast(p)->isProvided(); } diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 361182380a..7ef7d101db 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -212,6 +212,7 @@ private: } void remove_() { + if (getMap_().find(mInstanceKey) != getMap_().end()) getMap_().erase(mInstanceKey); } diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 1789f003b9..0a79f2f588 100755 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -1125,7 +1125,7 @@ LLNotificationChannel::LLNotificationChannel(const Params& p) mName(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString()) { BOOST_FOREACH(const std::string& source, p.sources) -{ + { connectToChannel(source); } } @@ -1209,6 +1209,10 @@ LLNotifications::LLNotifications() LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Notification.Show", boost::bind(&LLNotifications::addFromCallback, this, _2)); } +void LLNotifications::clear() +{ + mDefaultChannels.clear(); +} // The expiration channel gets all notifications that are cancelled bool LLNotifications::expirationFilter(LLNotificationPtr pNotification) diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index cd3728305e..3b620084ee 100755 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -874,6 +874,13 @@ class LLNotifications : friend class LLSingleton; public: + + // Needed to clear up RefCounted things prior to actual destruction + // as the singleton nature of the class makes them do "bad things" + // on at least Mac, if not all 3 platforms + // + void clear(); + // load all notification descriptions from file // calling more than once will overwrite existing templates // but never delete a template diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 1874cba4a4..75595f502f 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1614,6 +1614,8 @@ bool LLAppViewer::cleanup() //ditch LLVOAvatarSelf instance gAgentAvatarp = NULL; + LLNotifications::instance().clear(); + // workaround for DEV-35406 crash on shutdown LLEventPumps::instance().reset(); -- cgit v1.2.3 From f638fc803dbd53985253237efb12b1707f42d49d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 23 Aug 2013 17:34:30 -0700 Subject: MAINT-3046 fix test regression from debug llassert accidentally checked in with crash fix --- indra/llcommon/llinitparam.h | 1 - 1 file changed, 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index b3b56321d3..03ab0fb67f 100755 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -1980,7 +1980,6 @@ namespace LLInitParam static bool validate(const Param* p) { // valid only if provided - llassert(p); return static_cast(p)->isProvided(); } -- cgit v1.2.3 From 3f5e6280dbee3414d464a96a8d9d037c30adb123 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 26 Aug 2013 14:16:28 -0700 Subject: Tweak MAINT-3046 fix for faster remove_() performance --- indra/llcommon/llinstancetracker.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 7ef7d101db..55187d8325 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -212,8 +212,11 @@ private: } void remove_() { - if (getMap_().find(mInstanceKey) != getMap_().end()) - getMap_().erase(mInstanceKey); + typename InstanceMap::iterator iter = getMap_().find(mInstanceKey); + if (iter != getMap_().end()) + { + getMap_().erase(iter); + } } private: -- cgit v1.2.3 From dc54af030e8f60b2b871be901664ffae1fc934e9 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 27 Aug 2013 14:57:43 -0700 Subject: MAINT-3065 : Avatar render info's 'geometry' stat is unpredictable for linked objects Removed "geometry" and "surface" Reviewed by Kelly --- indra/llcommon/lllslconstants.h | 2 -- indra/lscript/lscript_compile/indra.l | 2 -- indra/newview/app_settings/keywords.ini | 2 -- indra/newview/llavatarrenderinfoaccountant.cpp | 31 +++++--------------------- indra/newview/llvoavatar.cpp | 2 -- indra/newview/llvoavatar.h | 6 ----- 6 files changed, 5 insertions(+), 40 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/lllslconstants.h b/indra/llcommon/lllslconstants.h index efa66390e8..926ce32d75 100755 --- a/indra/llcommon/lllslconstants.h +++ b/indra/llcommon/lllslconstants.h @@ -208,8 +208,6 @@ const S32 OBJECT_PHYSICS = 21; const S32 OBJECT_PHANTOM = 22; const S32 OBJECT_TEMP_ON_REZ = 23; const S32 OBJECT_RENDER_WEIGHT = 24; -const S32 OBJECT_ATTACHMENT_GEOMETRY_BYTES = 25; -const S32 OBJECT_ATTACHMENT_SURFACE_AREA = 26; // llTextBox() magic token string - yes this is a hack. sue me. char const* const TEXTBOX_MAGIC_TOKEN = "!!llTextBox!!"; diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index 8ed5f99a89..88dfc2e9f3 100755 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -290,8 +290,6 @@ int yyerror(const char *fmt, ...); "OBJECT_PHANTOM" { count(); yylval.ival = OBJECT_PHANTOM; return(INTEGER_CONSTANT); } "OBJECT_TEMP_ON_REZ" { count(); yylval.ival = OBJECT_TEMP_ON_REZ; return(INTEGER_CONSTANT); } "OBJECT_RENDER_WEIGHT" { count(); yylval.ival = OBJECT_RENDER_WEIGHT; return(INTEGER_CONSTANT); } -"OBJECT_ATTACHMENT_GEOMETRY_BYTES" { count(); yylval.ival = OBJECT_ATTACHMENT_GEOMETRY_BYTES; return(INTEGER_CONSTANT); } -"OBJECT_ATTACHMENT_SURFACE_AREA" { count(); yylval.ival = OBJECT_ATTACHMENT_SURFACE_AREA; return(INTEGER_CONSTANT); } "TYPE_INTEGER" { count(); yylval.ival = LST_INTEGER; return(INTEGER_CONSTANT); } "TYPE_FLOAT" { count(); yylval.ival = LST_FLOATINGPOINT; return(INTEGER_CONSTANT); } diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index ef3c319da6..5ff8408943 100755 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -195,8 +195,6 @@ OBJECT_PHYSICS Used with llGetObjectDetails to determine if the object is phy OBJECT_PHANTOM Used with llGetObjectDetails to determine if the object is phantom or not OBJECT_TEMP_ON_REZ Used with llGetObjectDetails to determine if the object is temporary or not OBJECT_RENDER_WEIGHT Used with llGetObjectDetails to return an avatar's rendering weight -OBJECT_ATTACHMENT_GEOMETRY_BYTES Used with llGetObjectDetails to return an avatar's attachment rendering geometry bytes -OBJECT_ATTACHMENT_SURFACE_AREA Used with llGetObjectDetails to return an avatar's attachment surface area # some vehicle params diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 2a4ec6d320..89c1b2a186 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -46,8 +46,6 @@ static const std::string KEY_AGENTS = "agents"; // map static const std::string KEY_WEIGHT = "weight"; // integer -static const std::string KEY_GEOMETRY = "geometry"; // integer -static const std::string KEY_SURFACE = "surface"; // float static const std::string KEY_IDENTIFIER = "identifier"; static const std::string KEY_MESSAGE = "message"; @@ -125,14 +123,6 @@ public: { ((LLVOAvatar *) avatarp)->setReportedVisualComplexity(agent_info_map[KEY_WEIGHT].asInteger()); } - if (agent_info_map.has(KEY_GEOMETRY)) - { - ((LLVOAvatar *) avatarp)->setReportedAttachmentGeometryBytes(agent_info_map[KEY_GEOMETRY].asInteger()); - } - if (agent_info_map.has(KEY_SURFACE)) - { - ((LLVOAvatar *) avatarp)->setReportedAttachmentSurfaceArea((F32) agent_info_map[KEY_SURFACE].asReal()); - } } report_iter++; } @@ -259,24 +249,13 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio if (avatar->getVisualComplexity() > 0) { info[KEY_WEIGHT] = avatar->getVisualComplexity(); - } - if (avatar->getAttachmentGeometryBytes() >= 0) - { - info[KEY_GEOMETRY] = (S32) avatar->getAttachmentGeometryBytes(); - } - if (avatar->getAttachmentSurfaceArea() >= 0.f) - { - info[KEY_SURFACE] = avatar->getAttachmentSurfaceArea(); - } - if (info.size() > 0) - { agents[avatar->getID().asString()] = info; - } - if (logRenderInfo()) - { - llinfos << "Sending avatar render info for " << avatar->getID() - << ": " << info << llendl; + if (logRenderInfo()) + { + llinfos << "Sending avatar render info for " << avatar->getID() + << ": " << info << llendl; + } } } iter++; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 0ffd8ad119..6a504e10c4 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -670,8 +670,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mAttachmentGeometryBytes(-1), mAttachmentSurfaceArea(-1.f), mReportedVisualComplexity(-1), - mReportedAttachmentGeometryBytes(-1), - mReportedAttachmentSurfaceArea(-1.f), mTurning(FALSE), mLastSkeletonSerialNum( 0 ), mIsSitting(FALSE), diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index be2d69a41a..295175133c 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -259,10 +259,6 @@ public: S32 getReportedVisualComplexity() { return mReportedVisualComplexity; }; // Numbers as reported by the SL server void setReportedVisualComplexity(S32 value) { mReportedVisualComplexity = value; }; - S32 getReportedAttachmentGeometryBytes() { return mReportedAttachmentGeometryBytes; }; //number of bytes in attached geometry - void setReportedAttachmentGeometryBytes(S32 value) { mReportedAttachmentGeometryBytes = value; }; - F32 getReportedAttachmentSurfaceArea() { return mReportedAttachmentSurfaceArea; }; //estimated surface area of attachments - void setReportedAttachmentSurfaceArea(F32 value) { mReportedAttachmentSurfaceArea = value; }; S32 getUpdatePeriod() { return mUpdatePeriod; }; const LLColor4 & getMutedAVColor() { return mMutedAVColor; }; @@ -416,8 +412,6 @@ public: F32 mAttachmentSurfaceArea; //estimated surface area of attachments S32 mReportedVisualComplexity; // Numbers as reported by the SL server - S32 mReportedAttachmentGeometryBytes; //number of bytes in attached geometry - F32 mReportedAttachmentSurfaceArea; //estimated surface area of attachments private: bool shouldAlphaMask(); -- cgit v1.2.3 From d8f700d6ac68388d021e923efa5d89e7d5852bd5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 28 Aug 2013 09:14:29 -0700 Subject: NORSPEC-355 NORSPEC-356 replaced llerrs with asserts to avoid crashes from false alarms in release --- indra/newview/lldrawable.cpp | 8 +++++++- indra/newview/llviewertexturelist.cpp | 16 ++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 2a333157f2..9682f38227 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -132,10 +132,16 @@ void LLDrawable::destroy() sNumZombieDrawables--; } + // Attempt to catch violations of this in debug, + // knowing that some false alarms may result + // + llassert(!LLSpatialGroup::sNoDelete); + + /* cannot be guaranteed and causes crashes on false alarms if (LLSpatialGroup::sNoDelete) { llerrs << "Illegal deletion of LLDrawable!" << llendl; - } + }*/ std::for_each(mFaces.begin(), mFaces.end(), DeletePointer()); mFaces.clear(); diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index d9f3548a29..487a06949a 100755 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -562,11 +562,11 @@ void LLViewerTextureList::addImageToList(LLViewerFetchedTexture *image) llassert(image); if (image->isInImageList()) { - llerrs << "LLViewerTextureList::addImageToList - Image already in list" << llendl; + llinfos << "LLViewerTextureList::addImageToList - Image already in list" << llendl; } if((mImageList.insert(image)).second != true) { - llerrs << "Error happens when insert image to mImageList!" << llendl ; + llinfos << "Error happens when insert image to mImageList!" << llendl ; } image->setInImageList(TRUE) ; @@ -585,32 +585,32 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image) { llinfos << "Image is not in mUUIDMap!" << llendl ; } - llerrs << "LLViewerTextureList::removeImageFromList - Image not in list" << llendl; + llinfos << "LLViewerTextureList::removeImageFromList - Image not in list" << llendl; } S32 count = mImageList.erase(image) ; + llassert(count == 1); if(count != 1) { - llinfos << image->getID() << llendl ; - llerrs << "Error happens when remove image from mImageList: " << count << llendl ; + llinfos << image->getID() << " removed with non-one count of " << count << llendl; } image->setInImageList(FALSE) ; } void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image) -{ +{ if (!new_image) { - llwarning("No image to add to image list", 0); return; } + llassert(new_image); LLUUID image_id = new_image->getID(); LLViewerFetchedTexture *image = findImage(image_id); if (image) { - llwarns << "Image with ID " << image_id << " already in list" << llendl; + llinfos << "Image with ID " << image_id << " already in list" << llendl; } sNumImages++; -- cgit v1.2.3 From ef7826a930071f1829fe81d12da75b048159acc7 Mon Sep 17 00:00:00 2001 From: Maestro Linden Date: Wed, 28 Aug 2013 23:49:53 +0000 Subject: MAINT-2506 Fix typo in PERMISSION_SILENT_ESTATE_MANAGEMENT keyword. Reviewed by Kelly. --- indra/newview/app_settings/keywords.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 5ff8408943..ad843bca14 100755 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -94,7 +94,7 @@ PERMISSION_CHANGE_LINKS Passed to llRequestPermissions library function to req PERMISSION_TRACK_CAMERA Passed to llRequestPermissions library function to request permission to track agent's camera PERMISSION_CONTROL_CAMERA Passed to llRequestPermissions library function to request permission to change agent's camera PERMISSION_TELEPORT Passed to llRequestPermissions library function to request permission to teleport agent -SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT Passed to llRequestPermissions library function to request permission to silently modify estate access lists +PERMISSION_SILENT_ESTATE_MANAGEMENT Passed to llRequestPermissions library function to request permission to silently modify estate access lists PERMISSION_OVERRIDE_ANIMATIONS Passed to llRequestPermissions library function to request permission to override animations on agent PERMISSION_RETURN_OBJECTS Passed to llRequestPermissions library function to request permission to return objects -- cgit v1.2.3 From f37023a060fcf3d4b094028bf6244c1dc749aa1a Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Thu, 29 Aug 2013 12:11:41 +0300 Subject: MAINT-3048 FIXED Don't block IMs from Lindens even when "Only friends and groups can call or IM me" is set --- indra/newview/llimview.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 9e23755d73..2e53effcac 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -2670,7 +2670,8 @@ void LLIMMgr::addMessage( name_is_setted = true; } bool skip_message = false; - if (gSavedSettings.getBOOL("VoiceCallsFriendsOnly")) + bool from_linden = LLMuteList::getInstance()->isLinden(from); + if (gSavedSettings.getBOOL("VoiceCallsFriendsOnly") && !from_linden) { // Evaluate if we need to skip this message when that setting is true (default is false) skip_message = (LLAvatarTracker::instance().getBuddyInfo(other_participant_id) == NULL); // Skip non friends... @@ -2716,7 +2717,7 @@ void LLIMMgr::addMessage( // Logically it would make more sense to reject the session sooner, in another area of the // code, but the session has to be established inside the server before it can be left. - if (LLMuteList::getInstance()->isMuted(other_participant_id) && !LLMuteList::getInstance()->isLinden(from)) + if (LLMuteList::getInstance()->isMuted(other_participant_id) && !from_linden) { llwarns << "Leaving IM session from initiating muted resident " << from << llendl; if(!gIMMgr->leaveSession(new_session_id)) -- cgit v1.2.3 From cacefaf2fc1b95557aca62dc69dbe3744c6424b0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 30 Aug 2013 15:55:20 -0500 Subject: MAINT-2811 Fix for infinite loop on octree code during teleport. --- indra/llmath/llvolume.cpp | 30 +++++++++++++++++++----------- indra/newview/llviewermenu.cpp | 2 -- indra/newview/llviewerpartsim.cpp | 4 ++++ indra/newview/llviewerpartsim.h | 4 ++++ indra/newview/llvopartgroup.cpp | 21 +++++++++++++-------- 5 files changed, 40 insertions(+), 21 deletions(-) (limited to 'indra') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 773995cb86..0c329c69b2 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -802,6 +802,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai { // Scale by 4 to generate proper tex coords. mProfile[i].mul(scale); + llassert(mProfile[i].isFinite3()); } if (hollow) @@ -839,6 +840,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai { // Scale by 3 to generate proper tex coords. mProfile[i].mul(scale); + llassert(mProfile[i].isFinite3()); } if (path_open) @@ -989,6 +991,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai { mOpen = FALSE; mProfile.push_back(mProfile[0]); + llassert(mProfile[0].isFinite3()); mTotal++; } } @@ -2127,7 +2130,7 @@ BOOL LLVolume::generate() { rot_mat.rotate(*profile++, tmp); dst->setAdd(tmp,offset); - llassert(less_than_max_mag(*dst)); + llassert(dst->isFinite3()); ++dst; } } @@ -2840,6 +2843,8 @@ void LLVolume::sculptGeneratePlaceholder() p[1] = (F32)(sin(F_PI * v) * sin(2.0 * F_PI * u) * RADIUS); p[2] = (F32)(cos(F_PI * v) * RADIUS); + llassert(pt.isFinite3()); + } line += sizeT; } @@ -2927,6 +2932,8 @@ void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 LLVector4a scale(-1.f,1,1,1); pt.mul(scale); } + + llassert(pt.isFinite3()); } line += sizeT; @@ -5552,12 +5559,14 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) tc->mV[0] = (*p)[0]+0.5f; tc->mV[1] = (*p)[1]+0.5f; - llassert(less_than_max_mag(*src)); + llassert(src->isFinite3()); update_min_max(min,max,*src); update_min_max(min_uv, max_uv, *tc); *pos = *src; + llassert(pos->isFinite3()); + ++p; ++tc; ++src; @@ -5577,11 +5586,13 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) tc->mV[0] = (*p)[0]+0.5f; tc->mV[1] = 0.5f - (*p)[1]; - llassert(less_than_max_mag(*src)); + llassert(src->isFinite3()); update_min_max(min,max,*src); update_min_max(min_uv, max_uv, *tc); *pos = *src; + + llassert(pos->isFinite3()); ++p; ++tc; @@ -6468,8 +6479,11 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) // mQ = { 0, a[X]*b[Y] - a[Y]*b[X], a[Z]*b[X] - a[X]*b[Z], a[Y]*b[Z] - a[Z]*b[Y] } vector1 = _mm_sub_ps( vector2, _mm_mul_ps( amQ, bmQ )); + llassert(v1.isFinite3()); + v1.store4a((F32*) output); + output++; idx += 3; } @@ -6498,14 +6512,8 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) n1.add(c); n2.add(c); - llassert(llfinite(c.getF32ptr()[0])); - llassert(llfinite(c.getF32ptr()[1])); - llassert(llfinite(c.getF32ptr()[2])); - - llassert(!llisnan(c.getF32ptr()[0])); - llassert(!llisnan(c.getF32ptr()[1])); - llassert(!llisnan(c.getF32ptr()[2])); - + llassert(c.isFinite3()); + //even out quad contributions switch (i%2+1) { diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 33d4b65d4a..c6c1090f45 100755 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1073,8 +1073,6 @@ class LLAdvancedCheckInfoDisplay : public view_listener_t U32 info_display = info_display_from_string( userdata.asString() ); bool new_value = false; - LL_INFOS("ViewerMenu") << "check " << userdata.asString() << LL_ENDL; - if ( info_display != 0 ) { new_value = LLPipeline::toggleRenderDebugControl( (void*)info_display ); diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 96cd43a8ab..163c90019f 100755 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -160,7 +160,11 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 ¢er_agent, const F32 bo } mVOPartGroupp->setViewerPartGroup(this); mVOPartGroupp->setPositionAgent(getCenterAgent()); + + mBoxSide = box_side; + F32 scale = box_side * 0.5f; + mVOPartGroupp->setScale(LLVector3(scale,scale,scale)); //gPipeline.addObject(mVOPartGroupp); diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h index 095de2060c..2daa07ed8c 100755 --- a/indra/newview/llviewerpartsim.h +++ b/indra/newview/llviewerpartsim.h @@ -105,6 +105,9 @@ public: void shift(const LLVector3 &offset); + F32 getBoxRadius() { return mBoxRadius; } + F32 getBoxSide() { return mBoxSide; } + typedef std::vector part_list_t; part_list_t mParticles; @@ -125,6 +128,7 @@ public: protected: LLVector3 mCenterAgent; F32 mBoxRadius; + F32 mBoxSide; LLVector3 mMinObjPos; LLVector3 mMaxObjPos; diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index a65de0c047..1630b5d484 100755 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -176,24 +176,28 @@ BOOL LLVOPartGroup::isActive() const F32 LLVOPartGroup::getBinRadius() { - return mScale.mV[0]*2.f; + return mViewerPartGroupp->getBoxSide(); } void LLVOPartGroup::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) { const LLVector3& pos_agent = getPositionAgent(); - newMin.load3( (pos_agent - mScale).mV); - newMax.load3( (pos_agent + mScale).mV); + LLVector4a scale; + LLVector4a p; + + p.load3(pos_agent.mV); + + scale.splat(mScale.mV[0]+mViewerPartGroupp->getBoxSide()*0.5f); + + newMin.setSub(p, scale); + newMax.setAdd(p,scale); llassert(newMin.isFinite3()); llassert(newMax.isFinite3()); - LLVector4a pos; - pos.load3(pos_agent.mV); - - llassert(pos.isFinite3()); - mDrawable->setPositionGroup(pos); + llassert(p.isFinite3()); + mDrawable->setPositionGroup(p); } void LLVOPartGroup::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) @@ -459,6 +463,7 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) } //record max scale (used to stretch bounding box for visibility culling) + mScale.set(max_scale, max_scale, max_scale); mDrawable->movePartition(); -- cgit v1.2.3 From a0244eb6f9b4b9de5c7831f770ac508f9c0f378a Mon Sep 17 00:00:00 2001 From: mberezhnoy Date: Wed, 4 Sep 2013 09:20:33 +0300 Subject: MAINT-3073 ([CHUIBUG](You) feature is irritating, especially for emotes) --- indra/newview/llchathistory.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'indra') diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index af3c6eff11..43a733f918 100755 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -898,20 +898,10 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL LLStyle::Params link_params(body_message_params); link_params.overwriteFrom(LLStyleMap::instance().lookupAgent(chat.mFromID)); - if (from_me) - { std::string localized_name; - bool is_localized = LLTrans::findString(localized_name, "AgentNameSubst"); - mEditor->appendText((is_localized? localized_name:"(You)") + delimiter, - prependNewLineState, link_params); - prependNewLineState = false; - } - else - { // Add link to avatar's inspector and delimiter to message. - mEditor->appendText(std::string(link_params.link_href) + delimiter, - prependNewLineState, link_params); - prependNewLineState = false; - } + mEditor->appendText(std::string(link_params.link_href) + delimiter, + prependNewLineState, link_params); + prependNewLineState = false; } else { -- cgit v1.2.3 From e5597b83cf20b444d070316ffbbc13d33b4dcf2b Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Tue, 3 Sep 2013 20:24:49 +0300 Subject: CHUI-836 FIXED [CHUIBUG]Opening chat history from the conversation log sometimes crashes the viewer --- indra/newview/llfloaterconversationpreview.cpp | 39 +++++++++----------------- indra/newview/llfloaterconversationpreview.h | 3 +- 2 files changed, 16 insertions(+), 26 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterconversationpreview.cpp b/indra/newview/llfloaterconversationpreview.cpp index b570de14aa..7d2f151e0b 100755 --- a/indra/newview/llfloaterconversationpreview.cpp +++ b/indra/newview/llfloaterconversationpreview.cpp @@ -43,14 +43,15 @@ LLFloaterConversationPreview::LLFloaterConversationPreview(const LLSD& session_i mCurrentPage(0), mPageSize(gSavedSettings.getS32("ConversationHistoryPageSize")), mAccountName(session_id[LL_FCP_ACCOUNT_NAME]), - mCompleteName(session_id[LL_FCP_COMPLETE_NAME]) + mCompleteName(session_id[LL_FCP_COMPLETE_NAME]), + mMutex(NULL) { } BOOL LLFloaterConversationPreview::postBuild() { mChatHistory = getChild("chat_history"); - LLLoadHistoryThread::setLoadEndSignal(boost::bind(&LLFloaterConversationPreview::SetPages, this, _1, _2)); + LLLoadHistoryThread::setLoadEndSignal(boost::bind(&LLFloaterConversationPreview::setPages, this, _1, _2)); const LLConversation* conv = LLConversationLog::instance().getConversation(mSessionID); std::string name; @@ -95,14 +96,15 @@ BOOL LLFloaterConversationPreview::postBuild() return LLFloater::postBuild(); } -void LLFloaterConversationPreview::SetPages(std::list& messages, const std::string& file_name) +void LLFloaterConversationPreview::setPages(std::list& messages,const std::string& file_name) { if(file_name == mChatHistoryFileName) { + // additional protection to avoid changes of mMessages in setPages() + LLMutexLock lock(&mMutex); mMessages = messages; + mCurrentPage = (mMessages.size() ? (mMessages.size() - 1) / mPageSize : 0); - - mCurrentPage = mMessages.size() / mPageSize; mPageSpinner->setEnabled(true); mPageSpinner->setMaxValue(mCurrentPage+1); mPageSpinner->set(mCurrentPage+1); @@ -110,10 +112,9 @@ void LLFloaterConversationPreview::SetPages(std::list& messages, const std std::string total_page_num = llformat("/ %d", mCurrentPage+1); getChild("page_num_label")->setValue(total_page_num); mChatHistoryLoaded = true; - } - } + void LLFloaterConversationPreview::draw() { if(mChatHistoryLoaded) @@ -131,32 +132,21 @@ void LLFloaterConversationPreview::onOpen(const LLSD& key) void LLFloaterConversationPreview::showHistory() { - if (!mMessages.size()) + // additional protection to avoid changes of mMessages in setPages() + LLMutexLock lock(&mMutex); + + if (!mMessages.size() || mCurrentPage * mPageSize >= mMessages.size()) { return; } mChatHistory->clear(); - std::ostringstream message; std::list::const_iterator iter = mMessages.begin(); + std::advance(iter, mCurrentPage * mPageSize); - int delta = 0; - if (mCurrentPage) - { - int remainder = mMessages.size() % mPageSize; - delta = (remainder == 0) ? 0 : (mPageSize - remainder); - } - - std::advance(iter, (mCurrentPage * mPageSize) - delta); - - for (int msg_num = 0; (iter != mMessages.end() && msg_num < mPageSize); ++iter, ++msg_num) + for (int msg_num = 0; iter != mMessages.end() && msg_num < mPageSize; ++iter, ++msg_num) { - if (iter->size() == 0) - { - continue; - } - LLSD msg = *iter; LLUUID from_id = LLUUID::null; @@ -200,7 +190,6 @@ void LLFloaterConversationPreview::showHistory() mChatHistory->appendMessage(chat,chat_args); } - } void LLFloaterConversationPreview::onMoreHistoryBtnClick() diff --git a/indra/newview/llfloaterconversationpreview.h b/indra/newview/llfloaterconversationpreview.h index 389f3dfd09..f8796127ba 100755 --- a/indra/newview/llfloaterconversationpreview.h +++ b/indra/newview/llfloaterconversationpreview.h @@ -42,7 +42,7 @@ public: virtual ~LLFloaterConversationPreview(){}; virtual BOOL postBuild(); - void SetPages(std::list& messages,const std::string& file_name); + void setPages(std::list& messages,const std::string& file_name); virtual void draw(); virtual void onOpen(const LLSD& key); @@ -51,6 +51,7 @@ private: void onMoreHistoryBtnClick(); void showHistory(); + LLMutex mMutex; LLSpinCtrl* mPageSpinner; LLChatHistory* mChatHistory; LLUUID mSessionID; -- cgit v1.2.3 From cedc571e4b4f887af352e2561e5c4d31ea6982f6 Mon Sep 17 00:00:00 2001 From: dmitrykproductengine Date: Wed, 4 Sep 2013 13:09:35 +0300 Subject: MAINT-3095 FIXED Viewer crashes after opening Nearby chat history, if it is empty --- indra/newview/llfloaterconversationpreview.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfloaterconversationpreview.cpp b/indra/newview/llfloaterconversationpreview.cpp index b570de14aa..7cb313af33 100755 --- a/indra/newview/llfloaterconversationpreview.cpp +++ b/indra/newview/llfloaterconversationpreview.cpp @@ -126,7 +126,10 @@ void LLFloaterConversationPreview::draw() void LLFloaterConversationPreview::onOpen(const LLSD& key) { - showHistory(); + if(mChatHistoryLoaded) + { + showHistory(); + } } void LLFloaterConversationPreview::showHistory() -- cgit v1.2.3 From 5ffdeb4e0c560bbc3469cf9119509f71c3cf1231 Mon Sep 17 00:00:00 2001 From: callum_linden Date: Wed, 4 Sep 2013 10:44:26 -0700 Subject: MAINT-3016 FIX Viewer freeze... by reverting fix for MAINT-2849 (certain streams do not play) - freeze more important than no play --- indra/llaudio/llstreamingaudio_fmodex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llaudio/llstreamingaudio_fmodex.cpp b/indra/llaudio/llstreamingaudio_fmodex.cpp index 266fa2f57b..42f30aa1c4 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.cpp +++ b/indra/llaudio/llstreamingaudio_fmodex.cpp @@ -310,7 +310,7 @@ LLAudioStreamManagerFMODEX::LLAudioStreamManagerFMODEX(FMOD::System *system, con { mInternetStreamURL = url; - FMOD_RESULT result = mSystem->createStream(url.c_str(), FMOD_2D | FMOD_NONBLOCKING | FMOD_MPEGSEARCH | FMOD_IGNORETAGS, 0, &mInternetStream); + FMOD_RESULT result = mSystem->createStream(url.c_str(), FMOD_2D | FMOD_NONBLOCKING | FMOD_IGNORETAGS, 0, &mInternetStream); if (result!= FMOD_OK) { -- cgit v1.2.3 From a3be9d3467c068f8ed0d4f1c98484d132b1f1a5f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 5 Sep 2013 17:30:23 -0700 Subject: NORSPEC-360 fix issues with mip selection and TCs in projector fake env reflection --- .../app_settings/shaders/class1/deferred/multiSpotLightF.glsl | 9 +++------ .../app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 8 +++----- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index ed68e38891..86f9f227d5 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -310,14 +310,11 @@ void main() vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); - + stc /= stc.w; if (stc.z > 0.0) { - stc.xy /= stc.w; - - float fatten = clamp(envIntensity*envIntensity+envIntensity*0.5, 0.25, 1.0); + float fatten = clamp(envIntensity*envIntensity+envIntensity*0.25, 0.25, 1.0); - //stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); if (stc.x < 1.0 && @@ -325,7 +322,7 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-envIntensity*proj_lod).rgb*spec.rgb; + col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod).rgb*spec.rgb; } } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index df750d3cec..ed3458963d 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -333,14 +333,12 @@ void main() vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); + stc /= stc.w; if (stc.z > 0.0) { - stc.xy /= stc.w; - - float fatten = clamp(envIntensity*envIntensity+envIntensity*0.5, 0.25, 1.0); + float fatten = clamp(envIntensity*envIntensity+envIntensity*0.25, 0.25, 1.0); - //stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); if (stc.x < 1.0 && @@ -348,7 +346,7 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-envIntensity*proj_lod).rgb*shadow*spec.rgb; + col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod).rgb*shadow*spec.rgb; } } } -- cgit v1.2.3 From 980802e46859dc31f14d20e558a4e955e6976f48 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 5 Sep 2013 22:06:16 -0400 Subject: STORM-1552: detect, ignore, and delete invalid feature and gpu table files --- indra/newview/gpu_table.txt | 1 + indra/newview/llfeaturemanager.cpp | 115 ++++++++++++++++++++++++++----------- indra/newview/llfeaturemanager.h | 15 +++-- 3 files changed, 93 insertions(+), 38 deletions(-) (limited to 'indra') diff --git a/indra/newview/gpu_table.txt b/indra/newview/gpu_table.txt index 122577b132..23a065caff 100755 --- a/indra/newview/gpu_table.txt +++ b/indra/newview/gpu_table.txt @@ -1,3 +1,4 @@ +//GPU_TABLE - that token on line 1 tags this as a gpu table file // // Categorizes graphics chips into various classes by name // diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 9d292ce7bb..6158a778d3 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -261,7 +261,7 @@ BOOL LLFeatureManager::maskFeatures(const std::string& name) return maskList(*maskp); } -BOOL LLFeatureManager::loadFeatureTables() +bool LLFeatureManager::loadFeatureTables() { // *TODO - if I or anyone else adds something else to the skipped list // make this data driven. Put it in the feature table and parse it @@ -302,28 +302,36 @@ BOOL LLFeatureManager::loadFeatureTables() // use HTTP table if it exists std::string path; + bool parse_ok = false; if (gDirUtilp->fileExists(http_path)) { - path = http_path; + parse_ok = parseFeatureTable(http_path); + if (!parse_ok) + { + // the HTTP table failed to parse, so delete it + LLFile::remove(http_path); + LL_WARNS("RenderInit") << "Removed invalid feature table '" << http_path << "'" << LL_ENDL; + } } - else + + if (!parse_ok) { - path = app_path; + parse_ok = parseFeatureTable(app_path); } - - return parseFeatureTable(path); + return parse_ok; } -BOOL LLFeatureManager::parseFeatureTable(std::string filename) +bool LLFeatureManager::parseFeatureTable(std::string filename) { - llinfos << "Looking for feature table in " << filename << llendl; + LL_INFOS("RenderInit") << "Attempting to parse feature table from " << filename << LL_ENDL; llifstream file; std::string name; U32 version; + cleanupFeatureTables(); // in case an earlier attempt left partial results file.open(filename); /*Flawfinder: ignore*/ if (!file) @@ -338,13 +346,14 @@ BOOL LLFeatureManager::parseFeatureTable(std::string filename) if (name != "version") { LL_WARNS("RenderInit") << filename << " does not appear to be a valid feature table!" << LL_ENDL; - return FALSE; + return false; } mTableVersion = version; - + LLFeatureList *flp = NULL; - while (file >> name) + bool parse_ok = true; + while (file >> name && parse_ok) { char buffer[MAX_STRING]; /*Flawfinder: ignore*/ @@ -357,39 +366,58 @@ BOOL LLFeatureManager::parseFeatureTable(std::string filename) if (name == "list") { + LL_DEBUGS("RenderInit") << "Before new list" << std::endl; if (flp) { - //flp->dump(); + flp->dump(); } + else + { + LL_CONT << "No current list"; + } + LL_CONT << LL_ENDL; + // It's a new mask, create it. file >> name; - if (mMaskList.count(name)) + if (!mMaskList.count(name)) { - LL_ERRS("RenderInit") << "Overriding mask " << name << ", this is invalid!" << LL_ENDL; + flp = new LLFeatureList(name); + mMaskList[name] = flp; + } + else + { + LL_WARNS("RenderInit") << "Overriding mask " << name << ", this is invalid!" << LL_ENDL; + parse_ok = false; } - - flp = new LLFeatureList(name); - mMaskList[name] = flp; } else { if (!flp) { - LL_ERRS("RenderInit") << "Specified parameter before keyword!" << LL_ENDL; - return FALSE; + S32 available; + F32 recommended; + file >> available >> recommended; + flp->addFeature(name, available, recommended); + } + else + { + LL_WARNS("RenderInit") << "Specified parameter before keyword!" << LL_ENDL; + parse_ok = false; } - S32 available; - F32 recommended; - file >> available >> recommended; - flp->addFeature(name, available, recommended); } } file.close(); - return TRUE; + if (!parse_ok) + { + LL_WARNS("RenderInit") << "Discarding feature table data from " << filename << LL_ENDL; + cleanupFeatureTables(); + } + + return parse_ok; } -void LLFeatureManager::loadGPUClass() +bool LLFeatureManager::loadGPUClass() { // defaults mGPUClass = GPU_CLASS_UNKNOWN; @@ -407,29 +435,49 @@ void LLFeatureManager::loadGPUClass() // use HTTP table if it exists std::string path; + bool parse_ok = false; if (gDirUtilp->fileExists(http_path)) { - path = http_path; + parse_ok = parseGPUTable(http_path); + if (!parse_ok) + { + // the HTTP table failed to parse, so delete it + LLFile::remove(http_path); + LL_WARNS("RenderInit") << "Removed invalid gpu table '" << http_path << "'" << LL_ENDL; + } } - else + + if (!parse_ok) { - path = app_path; + parse_ok = parseGPUTable(app_path); } - parseGPUTable(path); + return parse_ok; // indicates that the file parsed correctly, not that the gpu was recognized } -void LLFeatureManager::parseGPUTable(std::string filename) +bool LLFeatureManager::parseGPUTable(std::string filename) { llifstream file; - + + LL_INFOS("RenderInit") << "Attempting to parse GPU table from " << filename << LL_ENDL; file.open(filename); - if (!file) + if (file) + { + const char recognizer[] = "//GPU_TABLE"; + char first_line[MAX_STRING]; + file.getline(first_line, MAX_STRING); + if (0 != strncmp(first_line, recognizer, strlen(recognizer))) + { + LL_WARNS("RenderInit") << "Invalid GPU table: " << filename << "!" << LL_ENDL; + return false; + } + } + else { LL_WARNS("RenderInit") << "Unable to open GPU table: " << filename << "!" << LL_ENDL; - return; + return false; } std::string rawRenderer = gGLManager.getRawGLString(); @@ -556,6 +604,7 @@ void LLFeatureManager::parseGPUTable(std::string filename) #if LL_DARWIN // never go over "Mid" settings by default on OS X mGPUClass = llmin(mGPUClass, GPU_CLASS_2); #endif + return true; } // responder saves table into file diff --git a/indra/newview/llfeaturemanager.h b/indra/newview/llfeaturemanager.h index 3b8d251236..95141b241d 100755 --- a/indra/newview/llfeaturemanager.h +++ b/indra/newview/llfeaturemanager.h @@ -75,7 +75,7 @@ public: void setFeatureAvailable(const std::string& name, const BOOL available); void setRecommendedLevel(const std::string& name, const F32 level); - BOOL loadFeatureList(LLFILE *fp); + bool loadFeatureList(LLFILE *fp); BOOL maskList(LLFeatureList &mask); @@ -114,7 +114,7 @@ public: void maskCurrentList(const std::string& name); // Mask the current feature list with the named list - BOOL loadFeatureTables(); + bool loadFeatureTables(); EGPUClass getGPUClass() { return mGPUClass; } std::string& getGPUString() { return mGPUString; } @@ -157,9 +157,14 @@ public: void fetchHTTPTables(); protected: - void loadGPUClass(); - BOOL parseFeatureTable(std::string filename); - void parseGPUTable(std::string filename); + bool loadGPUClass(); + + bool parseFeatureTable(std::string filename); + ///< @returns TRUE is file parsed correctly, FALSE if not + + bool parseGPUTable(std::string filename); + ///< @returns true if file parsed correctly, false if not - does not reflect whether or not the gpu was recognized + void initBaseMask(); -- cgit v1.2.3 From 40762b76436fb4259e59b92640384004b14c0b0d Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Fri, 6 Sep 2013 20:16:52 +0300 Subject: MAINT-3110 FIXED new crash in LLNotificationsUI::LLHandlerUtil::logToIMP2P --- indra/newview/llnotificationhandlerutil.cpp | 35 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'indra') diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index eb4601a469..ef4d735616 100755 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -125,24 +125,29 @@ void log_name_callback(const std::string& full_name, const std::string& from_nam // static void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification, bool to_file_only) { - LLUUID from_id = notification->getPayload()["from_id"]; + if (!gCacheName) + { + return; + } - if (from_id.isNull()) - { - // Normal behavior for system generated messages, don't spam. - // llwarns << " from_id for notification " << notification->getName() << " is null " << llendl; - return; - } + LLUUID from_id = notification->getPayload()["from_id"]; - if(to_file_only) - { - gCacheName->get(from_id, false, boost::bind(&log_name_callback, _2, "", notification->getMessage(), LLUUID())); - } - else - { - gCacheName->get(from_id, false, boost::bind(&log_name_callback, _2, INTERACTIVE_SYSTEM_FROM, notification->getMessage(), from_id)); - } + if (from_id.isNull()) + { + // Normal behavior for system generated messages, don't spam. + // llwarns << " from_id for notification " << notification->getName() << " is null " << llendl; + return; + } + + if(to_file_only) + { + gCacheName->get(from_id, false, boost::bind(&log_name_callback, _2, "", notification->getMessage(), LLUUID())); } + else + { + gCacheName->get(from_id, false, boost::bind(&log_name_callback, _2, INTERACTIVE_SYSTEM_FROM, notification->getMessage(), from_id)); + } +} // static void LLHandlerUtil::logGroupNoticeToIMGroup( -- cgit v1.2.3 From 36dea0dad802158a0e546220163f4461fbd3e204 Mon Sep 17 00:00:00 2001 From: "maxim@mnikolenko" Date: Mon, 9 Sep 2013 12:45:51 +0300 Subject: MAINT-3048 FIXED Show actual message instead of "Only friends and groups can call..." for Lindens. --- indra/newview/llviewermessage.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 151a7c6213..c38af1f990 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2361,7 +2361,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) BOOL is_owned_by_me = FALSE; BOOL is_friend = (LLAvatarTracker::instance().getBuddyInfo(from_id) == NULL) ? false : true; BOOL accept_im_from_only_friend = gSavedSettings.getBOOL("VoiceCallsFriendsOnly"); - + BOOL is_linden = chat.mSourceType != CHAT_SOURCE_OBJECT && + LLMuteList::getInstance()->isLinden(name); + chat.mMuted = is_muted; chat.mFromID = from_id; chat.mFromName = name; @@ -2461,7 +2463,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL; bool mute_im = is_muted; - if(accept_im_from_only_friend&&!is_friend) + if(accept_im_from_only_friend && !is_friend && !is_linden) { if (!gIMMgr->isNonFriendSessionNotified(session_id)) { -- cgit v1.2.3 From 93df4ff2fea7378ab5b5ac069c2fec808ec5027b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 9 Sep 2013 09:24:46 -0700 Subject: NORSPEC-362 address video mem leak on windows on maximize --- indra/newview/pipeline.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 8be7b2ab53..b4e59909db 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -796,14 +796,22 @@ void LLPipeline::resizeScreenTexture() GLuint resX = gViewerWindow->getWorldViewWidthRaw(); GLuint resY = gViewerWindow->getWorldViewHeightRaw(); - if (!allocateScreenBuffer(resX,resY)) - { //FAILSAFE: screen buffer allocation failed, disable deferred rendering if it's enabled - //NOTE: if the session closes successfully after this call, deferred rendering will be - // disabled on future sessions - if (LLPipeline::sRenderDeferred) + if ((resX != mScreen.getWidth()) || (resY != mScreen.getHeight())) + { + releaseScreenBuffers(); + if (!allocateScreenBuffer(resX,resY)) { - gSavedSettings.setBOOL("RenderDeferred", FALSE); - LLPipeline::refreshCachedSettings(); +#if PROBABLE_FALSE_DISABLES_OF_ALM_HERE + //FAILSAFE: screen buffer allocation failed, disable deferred rendering if it's enabled + //NOTE: if the session closes successfully after this call, deferred rendering will be + // disabled on future sessions + if (LLPipeline::sRenderDeferred) + { + gSavedSettings.setBOOL("RenderDeferred", FALSE); + LLPipeline::refreshCachedSettings(); + + } +#endif } } } @@ -1193,7 +1201,8 @@ void LLPipeline::releaseGLBuffers() mWaterRef.release(); mWaterDis.release(); - + mHighlight.release(); + for (U32 i = 0; i < 3; i++) { mGlow[i].release(); @@ -1223,12 +1232,12 @@ void LLPipeline::releaseScreenBuffers() mDeferredScreen.release(); mDeferredDepth.release(); mDeferredLight.release(); - - mHighlight.release(); + mOcclusionDepth.release(); for (U32 i = 0; i < 6; i++) { mShadow[i].release(); + mShadowOcclusion[i].release(); } } -- cgit v1.2.3 From bd0a8c7ee9f446a544fe27851d2d6b558545d772 Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Wed, 11 Sep 2013 00:41:10 +0300 Subject: MAINT-3128 FIXED Advanced graphical settings are not changing when dragging "Quality and Speed" slider --- indra/newview/llfeaturemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 6158a778d3..c47618e1ec 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -392,7 +392,7 @@ bool LLFeatureManager::parseFeatureTable(std::string filename) } else { - if (!flp) + if (flp) { S32 available; F32 recommended; -- cgit v1.2.3 From 5b7da1998a95ccf545ff3b5a38a62e79ee00e1bb Mon Sep 17 00:00:00 2001 From: Cinder Biscuits Date: Tue, 10 Sep 2013 22:12:18 +0000 Subject: BUG-3848: send_agent_resume() was not being called after snapshot. --- indra/newview/llfilepicker.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index b26d520557..c151b51c23 100755 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -857,6 +857,8 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) success = false; } + send_agent_resume(); + // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); return success; -- cgit v1.2.3 From 996ed16fa1b3eb005c90b67f8ea363fd423ef711 Mon Sep 17 00:00:00 2001 From: eli Date: Wed, 11 Sep 2013 15:15:34 -0700 Subject: FIX INTL-123 translation of Viewer Set36 for 9 languages (changed and new files) --- .../newview/skins/default/xui/de/floater_about.xml | 4 +- .../skins/default/xui/de/floater_bulk_perms.xml | 7 +- .../skins/default/xui/de/floater_goto_line.xml | 7 ++ .../skins/default/xui/de/floater_im_session.xml | 12 +-- .../default/xui/de/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/de/menu_attachment_other.xml | 2 + .../skins/default/xui/de/menu_attachment_self.xml | 2 + .../skins/default/xui/de/menu_avatar_other.xml | 2 + .../skins/default/xui/de/menu_avatar_self.xml | 2 + .../skins/default/xui/de/menu_conversation.xml | 1 + indra/newview/skins/default/xui/de/menu_land.xml | 1 + indra/newview/skins/default/xui/de/menu_login.xml | 8 +- .../skins/default/xui/de/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/de/menu_object.xml | 5 +- .../skins/default/xui/de/menu_url_agent.xml | 1 + .../skins/default/xui/de/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/de/menu_viewer.xml | 15 ++- .../newview/skins/default/xui/de/notifications.xml | 71 +++++++++++-- .../newview/skins/default/xui/de/panel_people.xml | 3 + .../default/xui/de/panel_preferences_chat.xml | 44 +++++--- .../default/xui/de/panel_preferences_graphics1.xml | 2 +- .../default/xui/de/panel_preferences_setup.xml | 1 + .../skins/default/xui/de/panel_script_ed.xml | 1 + .../skins/default/xui/de/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/de/role_actions.xml | 2 +- indra/newview/skins/default/xui/de/strings.xml | 36 +++++++ .../newview/skins/default/xui/es/floater_about.xml | 4 +- .../skins/default/xui/es/floater_bulk_perms.xml | 7 +- .../skins/default/xui/es/floater_goto_line.xml | 7 ++ .../skins/default/xui/es/floater_im_session.xml | 12 +-- .../default/xui/es/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/es/menu_attachment_other.xml | 2 + .../skins/default/xui/es/menu_attachment_self.xml | 2 + .../skins/default/xui/es/menu_avatar_other.xml | 2 + .../skins/default/xui/es/menu_avatar_self.xml | 2 + .../skins/default/xui/es/menu_conversation.xml | 1 + indra/newview/skins/default/xui/es/menu_land.xml | 1 + indra/newview/skins/default/xui/es/menu_login.xml | 8 +- .../skins/default/xui/es/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/es/menu_object.xml | 5 +- .../skins/default/xui/es/menu_url_agent.xml | 1 + .../skins/default/xui/es/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/es/menu_viewer.xml | 14 ++- .../newview/skins/default/xui/es/notifications.xml | 87 ++++++++++++---- .../newview/skins/default/xui/es/panel_people.xml | 3 + .../default/xui/es/panel_preferences_chat.xml | 70 +++++++------ .../default/xui/es/panel_preferences_graphics1.xml | 2 +- .../default/xui/es/panel_preferences_setup.xml | 1 + .../skins/default/xui/es/panel_script_ed.xml | 1 + .../skins/default/xui/es/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/es/role_actions.xml | 2 +- indra/newview/skins/default/xui/es/strings.xml | 36 +++++++ .../newview/skins/default/xui/fr/floater_about.xml | 2 + .../skins/default/xui/fr/floater_bulk_perms.xml | 7 +- .../skins/default/xui/fr/floater_goto_line.xml | 7 ++ .../skins/default/xui/fr/floater_im_session.xml | 12 +-- .../default/xui/fr/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/fr/menu_attachment_other.xml | 2 + .../skins/default/xui/fr/menu_attachment_self.xml | 2 + .../skins/default/xui/fr/menu_avatar_other.xml | 2 + .../skins/default/xui/fr/menu_avatar_self.xml | 2 + .../skins/default/xui/fr/menu_conversation.xml | 1 + indra/newview/skins/default/xui/fr/menu_land.xml | 1 + indra/newview/skins/default/xui/fr/menu_login.xml | 8 +- .../skins/default/xui/fr/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/fr/menu_object.xml | 5 +- .../skins/default/xui/fr/menu_url_agent.xml | 1 + .../skins/default/xui/fr/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/fr/menu_viewer.xml | 14 ++- .../newview/skins/default/xui/fr/notifications.xml | 73 ++++++++++--- .../newview/skins/default/xui/fr/panel_people.xml | 3 + .../default/xui/fr/panel_preferences_chat.xml | 46 +++++--- .../default/xui/fr/panel_preferences_graphics1.xml | 2 +- .../default/xui/fr/panel_preferences_setup.xml | 1 + .../skins/default/xui/fr/panel_script_ed.xml | 1 + .../skins/default/xui/fr/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/fr/role_actions.xml | 2 +- indra/newview/skins/default/xui/fr/strings.xml | 36 +++++++ .../newview/skins/default/xui/it/floater_about.xml | 4 +- .../skins/default/xui/it/floater_bulk_perms.xml | 7 +- .../skins/default/xui/it/floater_goto_line.xml | 7 ++ .../skins/default/xui/it/floater_im_session.xml | 12 +-- .../default/xui/it/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/it/menu_attachment_other.xml | 2 + .../skins/default/xui/it/menu_attachment_self.xml | 2 + .../skins/default/xui/it/menu_avatar_other.xml | 2 + .../skins/default/xui/it/menu_avatar_self.xml | 2 + .../skins/default/xui/it/menu_conversation.xml | 1 + indra/newview/skins/default/xui/it/menu_land.xml | 1 + indra/newview/skins/default/xui/it/menu_login.xml | 8 +- .../skins/default/xui/it/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/it/menu_object.xml | 5 +- .../skins/default/xui/it/menu_url_agent.xml | 1 + .../skins/default/xui/it/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/it/menu_viewer.xml | 14 ++- .../newview/skins/default/xui/it/notifications.xml | 79 +++++++++++--- .../newview/skins/default/xui/it/panel_people.xml | 3 + .../default/xui/it/panel_preferences_chat.xml | 40 ++++--- .../default/xui/it/panel_preferences_graphics1.xml | 2 +- .../default/xui/it/panel_preferences_setup.xml | 1 + .../skins/default/xui/it/panel_script_ed.xml | 1 + .../skins/default/xui/it/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/it/role_actions.xml | 2 +- indra/newview/skins/default/xui/it/strings.xml | 36 +++++++ .../newview/skins/default/xui/ja/floater_about.xml | 4 +- .../skins/default/xui/ja/floater_bulk_perms.xml | 7 +- .../skins/default/xui/ja/floater_goto_line.xml | 7 ++ .../skins/default/xui/ja/floater_im_session.xml | 12 +-- .../default/xui/ja/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/ja/menu_attachment_other.xml | 2 + .../skins/default/xui/ja/menu_attachment_self.xml | 2 + .../skins/default/xui/ja/menu_avatar_other.xml | 2 + .../skins/default/xui/ja/menu_avatar_self.xml | 2 + .../skins/default/xui/ja/menu_conversation.xml | 1 + indra/newview/skins/default/xui/ja/menu_land.xml | 1 + indra/newview/skins/default/xui/ja/menu_login.xml | 8 +- .../skins/default/xui/ja/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/ja/menu_object.xml | 5 +- .../skins/default/xui/ja/menu_url_agent.xml | 1 + .../skins/default/xui/ja/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/ja/menu_viewer.xml | 14 ++- .../newview/skins/default/xui/ja/notifications.xml | 87 ++++++++++++---- .../newview/skins/default/xui/ja/panel_people.xml | 3 + .../default/xui/ja/panel_preferences_chat.xml | 84 ++++++++------- .../default/xui/ja/panel_preferences_graphics1.xml | 2 +- .../default/xui/ja/panel_preferences_setup.xml | 1 + .../skins/default/xui/ja/panel_script_ed.xml | 1 + .../skins/default/xui/ja/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/ja/role_actions.xml | 4 +- indra/newview/skins/default/xui/ja/strings.xml | 36 +++++++ .../newview/skins/default/xui/pt/floater_about.xml | 4 +- .../skins/default/xui/pt/floater_bulk_perms.xml | 7 +- .../skins/default/xui/pt/floater_goto_line.xml | 7 ++ .../skins/default/xui/pt/floater_im_session.xml | 12 +-- .../default/xui/pt/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/pt/menu_attachment_other.xml | 2 + .../skins/default/xui/pt/menu_attachment_self.xml | 2 + .../skins/default/xui/pt/menu_avatar_other.xml | 2 + .../skins/default/xui/pt/menu_avatar_self.xml | 2 + .../skins/default/xui/pt/menu_conversation.xml | 1 + indra/newview/skins/default/xui/pt/menu_land.xml | 1 + indra/newview/skins/default/xui/pt/menu_login.xml | 8 +- .../skins/default/xui/pt/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/pt/menu_object.xml | 5 +- .../skins/default/xui/pt/menu_url_agent.xml | 1 + .../skins/default/xui/pt/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/pt/menu_viewer.xml | 14 ++- .../newview/skins/default/xui/pt/notifications.xml | 83 ++++++++++++--- .../newview/skins/default/xui/pt/panel_people.xml | 3 + .../default/xui/pt/panel_preferences_chat.xml | 66 +++++++----- .../default/xui/pt/panel_preferences_graphics1.xml | 2 +- .../default/xui/pt/panel_preferences_setup.xml | 1 + .../skins/default/xui/pt/panel_script_ed.xml | 1 + .../skins/default/xui/pt/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/pt/role_actions.xml | 2 +- indra/newview/skins/default/xui/pt/strings.xml | 36 +++++++ .../newview/skins/default/xui/ru/floater_about.xml | 2 + .../skins/default/xui/ru/floater_bulk_perms.xml | 7 +- .../skins/default/xui/ru/floater_goto_line.xml | 7 ++ .../skins/default/xui/ru/floater_im_session.xml | 12 +-- .../default/xui/ru/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/ru/menu_attachment_other.xml | 2 + .../skins/default/xui/ru/menu_attachment_self.xml | 2 + .../skins/default/xui/ru/menu_avatar_other.xml | 2 + .../skins/default/xui/ru/menu_avatar_self.xml | 2 + .../skins/default/xui/ru/menu_conversation.xml | 1 + indra/newview/skins/default/xui/ru/menu_land.xml | 1 + indra/newview/skins/default/xui/ru/menu_login.xml | 8 +- .../skins/default/xui/ru/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/ru/menu_object.xml | 5 +- .../skins/default/xui/ru/menu_url_agent.xml | 1 + .../skins/default/xui/ru/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/ru/menu_viewer.xml | 16 +-- .../newview/skins/default/xui/ru/notifications.xml | 61 +++++++++-- .../newview/skins/default/xui/ru/panel_people.xml | 3 + .../default/xui/ru/panel_preferences_chat.xml | 38 ++++--- .../default/xui/ru/panel_preferences_graphics1.xml | 2 +- .../default/xui/ru/panel_preferences_setup.xml | 1 + .../skins/default/xui/ru/panel_script_ed.xml | 1 + .../skins/default/xui/ru/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/ru/role_actions.xml | 2 +- indra/newview/skins/default/xui/ru/strings.xml | 36 +++++++ .../newview/skins/default/xui/tr/floater_about.xml | 2 + .../skins/default/xui/tr/floater_bulk_perms.xml | 7 +- .../skins/default/xui/tr/floater_goto_line.xml | 7 ++ .../skins/default/xui/tr/floater_im_session.xml | 12 +-- .../default/xui/tr/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/tr/menu_attachment_other.xml | 2 + .../skins/default/xui/tr/menu_attachment_self.xml | 2 + .../skins/default/xui/tr/menu_avatar_other.xml | 2 + .../skins/default/xui/tr/menu_avatar_self.xml | 2 + .../skins/default/xui/tr/menu_conversation.xml | 1 + indra/newview/skins/default/xui/tr/menu_land.xml | 1 + indra/newview/skins/default/xui/tr/menu_login.xml | 8 +- .../skins/default/xui/tr/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/tr/menu_object.xml | 5 +- .../skins/default/xui/tr/menu_url_agent.xml | 1 + .../skins/default/xui/tr/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/tr/menu_viewer.xml | 14 ++- .../newview/skins/default/xui/tr/notifications.xml | 65 ++++++++++-- .../newview/skins/default/xui/tr/panel_people.xml | 3 + .../default/xui/tr/panel_preferences_chat.xml | 44 +++++--- .../default/xui/tr/panel_preferences_graphics1.xml | 2 +- .../default/xui/tr/panel_preferences_setup.xml | 1 + .../skins/default/xui/tr/panel_script_ed.xml | 1 + .../skins/default/xui/tr/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/tr/role_actions.xml | 2 +- indra/newview/skins/default/xui/tr/strings.xml | 36 +++++++ .../newview/skins/default/xui/zh/floater_about.xml | 2 + .../skins/default/xui/zh/floater_bulk_perms.xml | 7 +- .../skins/default/xui/zh/floater_goto_line.xml | 7 ++ .../skins/default/xui/zh/floater_im_session.xml | 12 +-- .../default/xui/zh/floater_pathfinding_console.xml | 2 +- .../skins/default/xui/zh/menu_attachment_other.xml | 2 + .../skins/default/xui/zh/menu_attachment_self.xml | 2 + .../skins/default/xui/zh/menu_avatar_other.xml | 2 + .../skins/default/xui/zh/menu_avatar_self.xml | 2 + .../skins/default/xui/zh/menu_conversation.xml | 1 + indra/newview/skins/default/xui/zh/menu_land.xml | 1 + indra/newview/skins/default/xui/zh/menu_login.xml | 8 +- .../skins/default/xui/zh/menu_mute_particle.xml | 5 + indra/newview/skins/default/xui/zh/menu_object.xml | 5 +- .../skins/default/xui/zh/menu_url_agent.xml | 1 + .../skins/default/xui/zh/menu_url_objectim.xml | 1 + indra/newview/skins/default/xui/zh/menu_viewer.xml | 14 ++- .../newview/skins/default/xui/zh/notifications.xml | 57 +++++++++- .../newview/skins/default/xui/zh/panel_people.xml | 3 + .../default/xui/zh/panel_preferences_chat.xml | 46 +++++--- .../default/xui/zh/panel_preferences_graphics1.xml | 2 +- .../default/xui/zh/panel_preferences_setup.xml | 1 + .../skins/default/xui/zh/panel_script_ed.xml | 1 + .../skins/default/xui/zh/panel_tools_texture.xml | 116 +++++++++++++++++++++ .../newview/skins/default/xui/zh/role_actions.xml | 2 +- indra/newview/skins/default/xui/zh/strings.xml | 36 +++++++ 234 files changed, 2788 insertions(+), 483 deletions(-) create mode 100644 indra/newview/skins/default/xui/de/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/de/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/de/panel_tools_texture.xml create mode 100644 indra/newview/skins/default/xui/es/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/es/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/es/panel_tools_texture.xml create mode 100644 indra/newview/skins/default/xui/fr/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/fr/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/fr/panel_tools_texture.xml create mode 100644 indra/newview/skins/default/xui/it/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/it/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/it/panel_tools_texture.xml create mode 100644 indra/newview/skins/default/xui/ja/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/ja/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/ja/panel_tools_texture.xml create mode 100644 indra/newview/skins/default/xui/pt/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/pt/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/pt/panel_tools_texture.xml create mode 100644 indra/newview/skins/default/xui/ru/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/ru/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/ru/panel_tools_texture.xml create mode 100644 indra/newview/skins/default/xui/tr/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/tr/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/tr/panel_tools_texture.xml create mode 100644 indra/newview/skins/default/xui/zh/floater_goto_line.xml create mode 100644 indra/newview/skins/default/xui/zh/menu_mute_particle.xml create mode 100644 indra/newview/skins/default/xui/zh/panel_tools_texture.xml (limited to 'indra') diff --git a/indra/newview/skins/default/xui/de/floater_about.xml b/indra/newview/skins/default/xui/de/floater_about.xml index 5245467183..bc0eae7c5d 100755 --- a/indra/newview/skins/default/xui/de/floater_about.xml +++ b/indra/newview/skins/default/xui/de/floater_about.xml @@ -8,7 +8,9 @@ Kompiliert mit [COMPILER] version [COMPILER_VERSION] - Sie befinden sich in [POSITION_LOCAL_0,number,1], [POSITION_LOCAL_1,number,1], [POSITION_LOCAL_2,number,1] in [REGION] auf <nolink>[HOSTNAME]</nolink> ([HOSTIP]) + Sie befinden sich an [POSITION_LOCAL_0,number,1], [POSITION_LOCAL_1,number,1], [POSITION_LOCAL_2,number,1] in [REGION] auf <nolink>[HOSTNAME]</nolink> ([HOSTIP]) +SLURL: <nolink>[SLURL]</nolink> +(globale Koordinaten [POSITION_0,number,1], [POSITION_1,number,1], [POSITION_2,number,1]) [SERVER_VERSION] [SERVER_RELEASE_NOTES_URL] diff --git a/indra/newview/skins/default/xui/de/floater_bulk_perms.xml b/indra/newview/skins/default/xui/de/floater_bulk_perms.xml index 8f99fc933c..27a74c874e 100755 --- a/indra/newview/skins/default/xui/de/floater_bulk_perms.xml +++ b/indra/newview/skins/default/xui/de/floater_bulk_perms.xml @@ -1,5 +1,5 @@ - + Auswahl enthält keinen Inhalt, der bearbeitet werden kann. @@ -33,7 +33,7 @@