summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolbump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolbump.cpp')
-rw-r--r--indra/newview/lldrawpoolbump.cpp288
1 files changed, 169 insertions, 119 deletions
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index ed6e55b7bc..223e4a438c 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -2,31 +2,25 @@
* @file lldrawpoolbump.cpp
* @brief LLDrawPoolBump class implementation
*
- * $LicenseInfo:firstyear=2003&license=viewergpl$
- *
- * Copyright (c) 2003-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2003&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 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.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * 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.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * 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$
*/
@@ -37,21 +31,19 @@
#include "llstl.h"
#include "llviewercontrol.h"
#include "lldir.h"
-#include "llimagegl.h"
#include "m3math.h"
#include "m4math.h"
#include "v4math.h"
#include "llglheaders.h"
#include "llrender.h"
-#include "llagent.h"
#include "llcubemap.h"
#include "lldrawable.h"
#include "llface.h"
#include "llsky.h"
#include "lltextureentry.h"
#include "llviewercamera.h"
-#include "llviewerimagelist.h"
+#include "llviewertexturelist.h"
#include "pipeline.h"
#include "llspatialpartition.h"
#include "llviewershadermgr.h"
@@ -75,6 +67,7 @@ const U32 VERTEX_MASK_BUMP = LLVertexBuffer::MAP_VERTEX |LLVertexBuffer::MAP_TEX
U32 LLDrawPoolBump::sVertexMask = VERTEX_MASK_SHINY;
+
static LLGLSLShader* shader = NULL;
static S32 cube_channel = -1;
static S32 diffuse_channel = -1;
@@ -95,7 +88,16 @@ void LLStandardBumpmap::shutdown()
// static
void LLStandardBumpmap::restoreGL()
{
- llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
+ addstandard();
+}
+
+// static
+void LLStandardBumpmap::addstandard()
+{
+ // can't assert; we destroyGL and restoreGL a lot during *first* startup, which populates this list already, THEN we explicitly init the list as part of *normal* startup. Sigh. So clear the list every time before we (re-)add the standard bumpmaps.
+ //llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
+ clear();
+ llinfos << "Adding standard bumpmaps." << llendl;
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("None"); // BE_NO_BUMP
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Brightness"); // BE_BRIGHTNESS
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness"); // BE_DARKNESS
@@ -143,12 +145,14 @@ void LLStandardBumpmap::restoreGL()
// llinfos << "Loading bumpmap: " << bump_image_id << " from viewerart" << llendl;
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mLabel = label;
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage =
- gImageList.getImage(LLUUID(bump_image_id),
+ LLViewerTextureManager::getFetchedTexture(LLUUID(bump_image_id),
TRUE,
- FALSE,
+ LLViewerTexture::BOOST_NONE,
+ LLViewerTexture::LOD_TEXTURE,
0,
- 0);
- gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setLoadedCallback(LLBumpImageList::onSourceStandardLoaded, 0, TRUE, FALSE, NULL );
+ 0);
+ gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setBoostLevel(LLViewerTexture::BOOST_BUMP) ;
+ gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setLoadedCallback(LLBumpImageList::onSourceStandardLoaded, 0, TRUE, FALSE, NULL, NULL );
LLStandardBumpmap::sStandardBumpmapCount++;
}
@@ -156,8 +160,9 @@ void LLStandardBumpmap::restoreGL()
}
// static
-void LLStandardBumpmap::destroyGL()
+void LLStandardBumpmap::clear()
{
+ llinfos << "Clearing standard bumpmaps." << llendl;
for( U32 i = 0; i < LLStandardBumpmap::sStandardBumpmapCount; i++ )
{
gStandardBumpmapList[i].mLabel.assign("");
@@ -166,6 +171,12 @@ void LLStandardBumpmap::destroyGL()
sStandardBumpmapCount = 0;
}
+// static
+void LLStandardBumpmap::destroyGL()
+{
+ clear();
+}
+
////////////////////////////////////////////////////////////////
@@ -220,7 +231,7 @@ S32 LLDrawPoolBump::getNumPasses()
void LLDrawPoolBump::beginRenderPass(S32 pass)
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_BUMP);
+ LLFastTimer t(FTM_RENDER_BUMP);
switch( pass )
{
case 0:
@@ -247,7 +258,7 @@ void LLDrawPoolBump::beginRenderPass(S32 pass)
void LLDrawPoolBump::render(S32 pass)
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_BUMP);
+ LLFastTimer t(FTM_RENDER_BUMP);
if (!gPipeline.hasRenderType(LLDrawPool::POOL_SIMPLE))
{
@@ -280,7 +291,7 @@ void LLDrawPoolBump::render(S32 pass)
void LLDrawPoolBump::endRenderPass(S32 pass)
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_BUMP);
+ LLFastTimer t(FTM_RENDER_BUMP);
switch( pass )
{
case 0:
@@ -308,9 +319,9 @@ void LLDrawPoolBump::endRenderPass(S32 pass)
//static
void LLDrawPoolBump::beginShiny(bool invisible)
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY);
- if (!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY)||
- invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY))
+ LLFastTimer t(FTM_RENDER_SHINY);
+ if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))||
+ (invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)))
{
return;
}
@@ -383,9 +394,9 @@ void LLDrawPoolBump::beginShiny(bool invisible)
void LLDrawPoolBump::renderShiny(bool invisible)
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY);
- if (!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY)||
- invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY))
+ LLFastTimer t(FTM_RENDER_SHINY);
+ if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))||
+ (invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)))
{
return;
}
@@ -410,9 +421,9 @@ void LLDrawPoolBump::renderShiny(bool invisible)
void LLDrawPoolBump::endShiny(bool invisible)
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY);
- if (!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY)||
- invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY))
+ LLFastTimer t(FTM_RENDER_SHINY);
+ if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))||
+ (invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)))
{
return;
}
@@ -450,7 +461,7 @@ void LLDrawPoolBump::endShiny(bool invisible)
void LLDrawPoolBump::beginFullbrightShiny()
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY);
+ LLFastTimer t(FTM_RENDER_SHINY);
if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY))
{
return;
@@ -499,7 +510,7 @@ void LLDrawPoolBump::beginFullbrightShiny()
void LLDrawPoolBump::renderFullbrightShiny()
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY);
+ LLFastTimer t(FTM_RENDER_SHINY);
if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY))
{
return;
@@ -514,7 +525,7 @@ void LLDrawPoolBump::renderFullbrightShiny()
void LLDrawPoolBump::endFullbrightShiny()
{
- LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY);
+ LLFastTimer t(FTM_RENDER_SHINY);
if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY))
{
return;
@@ -560,8 +571,8 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL
params.mGroup->rebuildMesh();
}
params.mVertexBuffer->setBuffer(mask);
- params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
- gPipeline.addTrianglesDrawn(params.mCount/3);
+ params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+ gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
}
}
@@ -569,22 +580,25 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL
// static
BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel)
{
- LLImageGL* bump = NULL;
+ LLViewerTexture* bump = NULL;
U8 bump_code = params.mBump;
- LLViewerImage* tex = params.mTexture;
+
+ //Note: texture atlas does not support bump texture now.
+ LLViewerFetchedTexture* tex = LLViewerTextureManager::staticCastToFetchedTexture(params.mTexture) ;
+ if(!tex)
+ {
+ //if the texture is not a fetched texture
+ return FALSE;
+ }
switch( bump_code )
{
- case BE_NO_BUMP:
- bump = NULL;
+ case BE_NO_BUMP:
break;
case BE_BRIGHTNESS:
case BE_DARKNESS:
- if( tex )
- {
- bump = gBumpImageList.getBrightnessDarknessImage( tex, bump_code );
- }
+ bump = gBumpImageList.getBrightnessDarknessImage( tex, bump_code );
break;
default:
@@ -615,15 +629,15 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel)
}
//static
-void LLDrawPoolBump::beginBump()
+void LLDrawPoolBump::beginBump(U32 pass)
{
- if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+ if (!gPipeline.hasRenderBatches(pass))
{
return;
}
sVertexMask = VERTEX_MASK_BUMP;
- LLFastTimer t(LLFastTimer::FTM_RENDER_BUMP);
+ LLFastTimer t(FTM_RENDER_BUMP);
// Optional second pass: emboss bump map
stop_glerror();
@@ -660,14 +674,14 @@ void LLDrawPoolBump::beginBump()
}
//static
-void LLDrawPoolBump::renderBump()
+void LLDrawPoolBump::renderBump(U32 pass)
{
- if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+ if (!gPipeline.hasRenderBatches(pass))
{
return;
}
- LLFastTimer ftm(LLFastTimer::FTM_RENDER_BUMP);
+ LLFastTimer ftm(FTM_RENDER_BUMP);
LLGLDisable fog(GL_FOG);
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_LEQUAL);
LLGLEnable blend(GL_BLEND);
@@ -675,13 +689,13 @@ void LLDrawPoolBump::renderBump()
/// Get rid of z-fighting with non-bump pass.
LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -1.0f);
- renderBump(LLRenderPass::PASS_BUMP, sVertexMask);
+ renderBump(pass, sVertexMask);
}
//static
-void LLDrawPoolBump::endBump()
+void LLDrawPoolBump::endBump(U32 pass)
{
- if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+ if (!gPipeline.hasRenderBatches(pass))
{
return;
}
@@ -698,13 +712,25 @@ void LLDrawPoolBump::endBump()
gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
+S32 LLDrawPoolBump::getNumDeferredPasses()
+{
+ if (gSavedSettings.getBOOL("RenderObjectBump"))
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
void LLDrawPoolBump::beginDeferredPass(S32 pass)
{
if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
{
return;
}
- LLFastTimer ftm(LLFastTimer::FTM_RENDER_BUMP);
+ LLFastTimer ftm(FTM_RENDER_BUMP);
mShiny = TRUE;
gDeferredBumpProgram.bind();
diffuse_channel = gDeferredBumpProgram.enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
@@ -719,7 +745,7 @@ void LLDrawPoolBump::endDeferredPass(S32 pass)
{
return;
}
- LLFastTimer ftm(LLFastTimer::FTM_RENDER_BUMP);
+ LLFastTimer ftm(FTM_RENDER_BUMP);
mShiny = FALSE;
gDeferredBumpProgram.disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
gDeferredBumpProgram.disableTexture(LLViewerShaderMgr::BUMP_MAP);
@@ -733,7 +759,7 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
{
return;
}
- LLFastTimer ftm(LLFastTimer::FTM_RENDER_BUMP);
+ LLFastTimer ftm(FTM_RENDER_BUMP);
U32 type = LLRenderPass::PASS_BUMP;
LLCullResult::drawinfo_list_t::iterator begin = gPipeline.beginRenderMap(type);
@@ -752,21 +778,45 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
void LLDrawPoolBump::beginPostDeferredPass(S32 pass)
{
- beginFullbrightShiny();
+ switch (pass)
+ {
+ case 0:
+ beginFullbrightShiny();
+ break;
+ case 1:
+ beginBump(LLRenderPass::PASS_POST_BUMP);
+ break;
+ }
}
void LLDrawPoolBump::endPostDeferredPass(S32 pass)
{
- endFullbrightShiny();
+ switch (pass)
+ {
+ case 0:
+ endFullbrightShiny();
+ break;
+ case 1:
+ endBump(LLRenderPass::PASS_POST_BUMP);
+ break;
+ }
}
void LLDrawPoolBump::renderPostDeferred(S32 pass)
{
- renderFullbrightShiny();
+ switch (pass)
+ {
+ case 0:
+ renderFullbrightShiny();
+ break;
+ case 1:
+ renderBump(LLRenderPass::PASS_POST_BUMP);
+ break;
+ }
}
////////////////////////////////////////////////////////////////
-// List of one-component bump-maps created from other texures.
+// List of bump-maps created from other textures.
//const LLUUID TEST_BUMP_ID("3d33eaf2-459c-6f97-fd76-5fce3fc29447");
@@ -779,24 +829,32 @@ void LLBumpImageList::init()
LLStandardBumpmap::init();
}
-void LLBumpImageList::shutdown()
+void LLBumpImageList::clear()
{
+ llinfos << "Clearing dynamic bumpmaps." << llendl;
+ // these will be re-populated on-demand
mBrightnessEntries.clear();
mDarknessEntries.clear();
+
+ LLStandardBumpmap::clear();
+}
+
+void LLBumpImageList::shutdown()
+{
+ clear();
LLStandardBumpmap::shutdown();
}
void LLBumpImageList::destroyGL()
{
- mBrightnessEntries.clear();
- mDarknessEntries.clear();
+ clear();
LLStandardBumpmap::destroyGL();
}
void LLBumpImageList::restoreGL()
{
- // Images will be recreated as they are needed.
LLStandardBumpmap::restoreGL();
+ // Images will be recreated as they are needed.
}
@@ -812,9 +870,9 @@ LLBumpImageList::~LLBumpImageList()
void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32 virtual_size)
{
bump &= TEM_BUMP_MASK;
- LLViewerImage* bump_image = gStandardBumpmapList[bump].mImage;
+ LLViewerFetchedTexture* bump_image = gStandardBumpmapList[bump].mImage;
if( bump_image )
- {
+ {
bump_image->addTextureStats(virtual_size);
}
}
@@ -822,15 +880,14 @@ void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32
void LLBumpImageList::updateImages()
{
- llpushcallstacks ;
for (bump_image_map_t::iterator iter = mBrightnessEntries.begin(); iter != mBrightnessEntries.end(); )
{
bump_image_map_t::iterator curiter = iter++;
- LLImageGL* image = curiter->second;
+ LLViewerTexture* image = curiter->second;
if( image )
{
BOOL destroy = TRUE;
- if( image->getHasGLTexture())
+ if( image->hasGLTexture())
{
if( image->getBoundRecently() )
{
@@ -849,15 +906,15 @@ void LLBumpImageList::updateImages()
}
}
}
- llpushcallstacks ;
+
for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); )
{
bump_image_map_t::iterator curiter = iter++;
- LLImageGL* image = curiter->second;
+ LLViewerTexture* image = curiter->second;
if( image )
{
BOOL destroy = TRUE;
- if( image->getHasGLTexture())
+ if( image->hasGLTexture())
{
if( image->getBoundRecently() )
{
@@ -876,21 +933,20 @@ void LLBumpImageList::updateImages()
}
}
}
- llpushcallstacks ;
}
// Note: the caller SHOULD NOT keep the pointer that this function returns. It may be updated as more data arrives.
-LLImageGL* LLBumpImageList::getBrightnessDarknessImage(LLViewerImage* src_image, U8 bump_code )
+LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedTexture* src_image, U8 bump_code )
{
llassert( (bump_code == BE_BRIGHTNESS) || (bump_code == BE_DARKNESS) );
- LLImageGL* bump = NULL;
+ LLViewerTexture* bump = NULL;
const F32 BRIGHTNESS_DARKNESS_PIXEL_AREA_THRESHOLD = 1000;
- if( src_image->mMaxVirtualSize > BRIGHTNESS_DARKNESS_PIXEL_AREA_THRESHOLD )
+ if( src_image->getMaxVirtualSize() > BRIGHTNESS_DARKNESS_PIXEL_AREA_THRESHOLD )
{
bump_image_map_t* entries_list = NULL;
- void (*callback_func)( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) = NULL;
+ void (*callback_func)( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) = NULL;
switch( bump_code )
{
@@ -917,17 +973,12 @@ LLImageGL* LLBumpImageList::getBrightnessDarknessImage(LLViewerImage* src_image,
LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,1);
raw->clear(0x77, 0x77, 0x77, 0xFF);
- //------------------------------
- bump = new LLImageGL( raw, TRUE);
- //immediately assign bump to a global smart pointer in case some local smart pointer
- //accidently releases it.
- (*entries_list)[src_image->getID()] = bump;
- //------------------------------
-
- bump->setExplicitFormat(GL_ALPHA8, GL_ALPHA);
+ (*entries_list)[src_image->getID()] = LLViewerTextureManager::getLocalTexture( raw.get(), TRUE);
+ (*entries_list)[src_image->getID()]->setExplicitFormat(GL_ALPHA8, GL_ALPHA);
// Note: this may create an LLImageGL immediately
- src_image->setLoadedCallback( callback_func, 0, TRUE, FALSE, new LLUUID(src_image->getID()) );
+ src_image->setBoostLevel(LLViewerTexture::BOOST_BUMP) ;
+ src_image->setLoadedCallback( callback_func, 0, TRUE, FALSE, new LLUUID(src_image->getID()), NULL );
bump = (*entries_list)[src_image->getID()]; // In case callback was called immediately and replaced the image
// bump_total++;
@@ -940,7 +991,7 @@ LLImageGL* LLBumpImageList::getBrightnessDarknessImage(LLViewerImage* src_image,
// static
-void LLBumpImageList::onSourceBrightnessLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata )
+void LLBumpImageList::onSourceBrightnessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata )
{
LLUUID* source_asset_id = (LLUUID*)userdata;
LLBumpImageList::onSourceLoaded( success, src_vi, src, *source_asset_id, BE_BRIGHTNESS );
@@ -951,7 +1002,7 @@ void LLBumpImageList::onSourceBrightnessLoaded( BOOL success, LLViewerImage *src
}
// static
-void LLBumpImageList::onSourceDarknessLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata )
+void LLBumpImageList::onSourceDarknessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata )
{
LLUUID* source_asset_id = (LLUUID*)userdata;
LLBumpImageList::onSourceLoaded( success, src_vi, src, *source_asset_id, BE_DARKNESS );
@@ -961,14 +1012,14 @@ void LLBumpImageList::onSourceDarknessLoaded( BOOL success, LLViewerImage *src_v
}
}
-void LLBumpImageList::onSourceStandardLoaded( BOOL success, LLViewerImage* src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata)
+void LLBumpImageList::onSourceStandardLoaded( BOOL success, LLViewerFetchedTexture* src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata)
{
if (success && LLPipeline::sRenderDeferred)
{
LLPointer<LLImageRaw> nrm_image = new LLImageRaw(src->getWidth(), src->getHeight(), 4);
generateNormalMapFromAlpha(src, nrm_image);
src_vi->setExplicitFormat(GL_RGBA, GL_RGBA);
- src_vi->createGLTexture(0, nrm_image);
+ src_vi->createGLTexture(src_vi->getDiscardLevel(), nrm_image);
}
}
@@ -1008,8 +1059,8 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr
LLVector3 right = LLVector3(norm_scale, 0, (F32) src_data[(j*resX+rX)*src_cmp+src_cmp-1]-cH);
LLVector3 left = LLVector3(-norm_scale, 0, (F32) src_data[(j*resX+lX)*src_cmp+src_cmp-1]-cH);
- LLVector3 up = LLVector3(0, -norm_scale, (F32) src_data[(rY*resX+i)*src_cmp+src_cmp-1]-cH);
- LLVector3 down = LLVector3(0, norm_scale, (F32) src_data[(lY*resX+i)*src_cmp+src_cmp-1]-cH);
+ LLVector3 up = LLVector3(0, -norm_scale, (F32) src_data[(lY*resX+i)*src_cmp+src_cmp-1]-cH);
+ LLVector3 down = LLVector3(0, norm_scale, (F32) src_data[(rY*resX+i)*src_cmp+src_cmp-1]-cH);
LLVector3 norm = right%down + down%left + left%up + up%right;
@@ -1028,13 +1079,13 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr
}
// static
-void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code )
+void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code )
{
if( success )
{
bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries );
bump_image_map_t::iterator iter = entries_list.find(source_asset_id);
- if (iter != entries_list.end())
+ if (iter != entries_list.end()) // bump not cached yet
{
LLPointer<LLImageRaw> dst_image = new LLImageRaw(src->getWidth(), src->getHeight(), 1);
U8* dst_data = dst_image->getData();
@@ -1119,8 +1170,8 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerImage *src_vi, LLIma
F32 twice_one_over_range = 2.f / (maximum - minimum);
S32 i;
- const F32 ARTIFICIAL_SCALE = 2.f; // Advantage: exagerates the effect in midrange. Disadvantage: clamps at the extremes.
- if( BE_DARKNESS == bump_code )
+ const F32 ARTIFICIAL_SCALE = 2.f; // Advantage: exaggerates the effect in midrange. Disadvantage: clamps at the extremes.
+ if (BE_DARKNESS == bump_code)
{
for( i = minimum; i <= maximum; i++ )
{
@@ -1130,7 +1181,6 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerImage *src_vi, LLIma
}
else
{
- // BE_LIGHTNESS
for( i = minimum; i <= maximum; i++ )
{
F32 minus_one_to_one = F32(i - minimum) * twice_one_over_range - 1.f;
@@ -1145,9 +1195,9 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerImage *src_vi, LLIma
}
//---------------------------------------------------
- //immediately assign bump to a global smart pointer in case some local smart pointer
- //accidently releases it.
- LLPointer<LLImageGL> bump = new LLImageGL( TRUE);
+ // immediately assign bump to a global smart pointer in case some local smart pointer
+ // accidentally releases it.
+ LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE );
if (!LLPipeline::sRenderDeferred)
{
@@ -1156,8 +1206,8 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerImage *src_vi, LLIma
}
else
{
- LLPointer<LLImageRaw> nrm_image = new LLImageRaw(src->getWidth(), src->getHeight(), 4);
- generateNormalMapFromAlpha(src, nrm_image);
+ LLPointer<LLImageRaw> nrm_image = new LLImageRaw(dst_image->getWidth(), dst_image->getHeight(), 4);
+ generateNormalMapFromAlpha(dst_image, nrm_image);
bump->setExplicitFormat(GL_RGBA, GL_RGBA);
bump->createGLTexture(0, nrm_image);
}
@@ -1220,8 +1270,8 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
{
if (params.mTexture.notNull())
{
- gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get());
- params.mTexture->addTextureStats(params.mVSize);
+ gGL.getTexUnit(diffuse_channel)->bind(params.mTexture) ;
+ params.mTexture->addTextureStats(params.mVSize);
}
else
{
@@ -1234,8 +1284,8 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
params.mGroup->rebuildMesh();
}
params.mVertexBuffer->setBuffer(mask);
- params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
- gPipeline.addTrianglesDrawn(params.mCount/3);
+ params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
+ gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
if (params.mTextureMatrix)
{
if (mShiny)
@@ -1255,7 +1305,7 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
void LLDrawPoolInvisible::render(S32 pass)
{ //render invisiprims
- LLFastTimer t(LLFastTimer::FTM_RENDER_INVISIBLE);
+ LLFastTimer t(FTM_RENDER_INVISIBLE);
U32 invisi_mask = LLVertexBuffer::MAP_VERTEX;
glStencilMask(0);
@@ -1284,7 +1334,7 @@ void LLDrawPoolInvisible::endDeferredPass( S32 pass )
void LLDrawPoolInvisible::renderDeferred( S32 pass )
{ //render invisiprims; this doesn't work becaue it also blocks all the post-deferred stuff
- LLFastTimer t(LLFastTimer::FTM_RENDER_INVISIBLE);
+ LLFastTimer t(FTM_RENDER_INVISIBLE);
U32 invisi_mask = LLVertexBuffer::MAP_VERTEX;
glStencilMask(0);