Innitial commit of experimental v2 texture system port work. Compiles and runs on windows, at least. Fixing bugs as they come.
Need to test: localassetbrowser preview related floaters hgfloatertexteditor maps media textures! Currently very hacky web browser alpha masks on avatars bumpmaps Are all sky components appearing? LLViewerDynamicTexture (texture baking, browser, animated textures, anim previews, etc) Snapshot related features Customize avatar vfs floater UI textures in general Texture priority issues
This commit is contained in:
@@ -35,6 +35,7 @@ set(llrender_SOURCE_FILES
|
||||
llpostprocess.cpp
|
||||
llrendersphere.cpp
|
||||
llshadermgr.cpp
|
||||
lltexture.cpp
|
||||
llvertexbuffer.cpp
|
||||
)
|
||||
|
||||
@@ -57,6 +58,7 @@ set(llrender_HEADER_FILES
|
||||
llrender.h
|
||||
llrendersphere.h
|
||||
llshadermgr.h
|
||||
lltexture.h
|
||||
llvertexbuffer.h
|
||||
)
|
||||
|
||||
|
||||
@@ -1079,15 +1079,15 @@ void LLFontGL::clearEmbeddedChars()
|
||||
mEmbeddedChars.clear();
|
||||
}
|
||||
|
||||
void LLFontGL::addEmbeddedChar( llwchar wc, LLImageGL* image, const std::string& label ) const
|
||||
void LLFontGL::addEmbeddedChar( llwchar wc, LLTexture* image, const std::string& label ) const
|
||||
{
|
||||
LLWString wlabel = utf8str_to_wstring(label);
|
||||
addEmbeddedChar(wc, image, wlabel);
|
||||
}
|
||||
|
||||
void LLFontGL::addEmbeddedChar( llwchar wc, LLImageGL* image, const LLWString& wlabel ) const
|
||||
void LLFontGL::addEmbeddedChar( llwchar wc, LLTexture* image, const LLWString& wlabel ) const
|
||||
{
|
||||
embedded_data_t* ext_data = new embedded_data_t(image, wlabel);
|
||||
embedded_data_t* ext_data = new embedded_data_t(image->getGLTexture(), wlabel);
|
||||
mEmbeddedChars[wc] = ext_data;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#define LL_LLFONTGL_H
|
||||
|
||||
#include "llfont.h"
|
||||
#include "llimagegl.h"
|
||||
#include "lltexture.h"
|
||||
#include "v2math.h"
|
||||
#include "llcoord.h"
|
||||
#include "llrect.h"
|
||||
@@ -194,10 +194,10 @@ public:
|
||||
BOOL round = TRUE, BOOL use_embedded = FALSE) const;
|
||||
|
||||
|
||||
LLImageGL *getImageGL() const;
|
||||
LLTexture *getTexture() const;
|
||||
|
||||
void addEmbeddedChar( llwchar wc, LLImageGL* image, const std::string& label) const;
|
||||
void addEmbeddedChar( llwchar wc, LLImageGL* image, const LLWString& label) const;
|
||||
void addEmbeddedChar( llwchar wc, LLTexture* image, const std::string& label) const;
|
||||
void addEmbeddedChar( llwchar wc, LLTexture* image, const LLWString& label) const;
|
||||
void removeEmbeddedChar( llwchar wc ) const;
|
||||
|
||||
static std::string nameFromFont(const LLFontGL* fontp);
|
||||
|
||||
@@ -61,6 +61,7 @@ std::list<U32> LLImageGL::sDeadTextureList;
|
||||
BOOL LLImageGL::sGlobalUseAnisotropic = FALSE;
|
||||
F32 LLImageGL::sLastFrameTime = 0.f;
|
||||
BOOL LLImageGL::sAllowReadBackRaw = FALSE ;
|
||||
LLImageGL* LLImageGL::sDefaultGLTexture = NULL ;
|
||||
|
||||
std::set<LLImageGL*> LLImageGL::sImageList;
|
||||
|
||||
@@ -105,9 +106,9 @@ void check_all_images()
|
||||
}
|
||||
}
|
||||
|
||||
void LLImageGL::checkTexSize() const
|
||||
void LLImageGL::checkTexSize(bool forced) const
|
||||
{
|
||||
if (gDebugGL && mTarget == GL_TEXTURE_2D)
|
||||
if ((forced || gDebugGL) && mTarget == GL_TEXTURE_2D)
|
||||
{
|
||||
GLint texname;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &texname);
|
||||
@@ -186,7 +187,6 @@ void LLImageGL::setHighlightTexture(S32 category)
|
||||
}
|
||||
}
|
||||
sHighlightTexturep->createGLTexture(0, image_raw, 0, TRUE, category);
|
||||
sHighlightTexturep->dontDiscard();
|
||||
image_raw = NULL;
|
||||
}
|
||||
|
||||
@@ -272,27 +272,15 @@ void LLImageGL::updateStats(F32 current_time)
|
||||
}
|
||||
|
||||
//static
|
||||
S32 LLImageGL::updateBoundTexMemStatic(const S32 delta, const S32 size, S32 category)
|
||||
S32 LLImageGL::updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category)
|
||||
{
|
||||
if(gAuditTexture)
|
||||
if(gAuditTexture && ncomponents > 0 && category > -1)
|
||||
{
|
||||
sTextureCurBoundCounter[getTextureCounterIndex(size)]++ ;
|
||||
sTextureCurMemByCategoryBound[category] += delta ;
|
||||
sTextureCurBoundCounter[getTextureCounterIndex(mem / ncomponents)]++ ;
|
||||
sTextureCurMemByCategoryBound[category] += mem ;
|
||||
}
|
||||
|
||||
LLImageGL::sCurBoundTextureMemory += delta ;
|
||||
return LLImageGL::sCurBoundTextureMemory;
|
||||
}
|
||||
|
||||
S32 LLImageGL::updateBoundTexMem()const
|
||||
{
|
||||
if(gAuditTexture)
|
||||
{
|
||||
sTextureCurBoundCounter[getTextureCounterIndex(mTextureMemory / mComponents)]++ ;
|
||||
sTextureCurMemByCategoryBound[mCategory] += mTextureMemory ;
|
||||
}
|
||||
|
||||
LLImageGL::sCurBoundTextureMemory += mTextureMemory ;
|
||||
LLImageGL::sCurBoundTextureMemory += mem ;
|
||||
return LLImageGL::sCurBoundTextureMemory;
|
||||
}
|
||||
|
||||
@@ -478,11 +466,7 @@ void LLImageGL::init(BOOL usemipmaps)
|
||||
mMissed = FALSE;
|
||||
#endif
|
||||
|
||||
mCategory = -1 ;
|
||||
|
||||
//LLTexture stuff
|
||||
mDontDiscard = FALSE;
|
||||
mTextureState = NO_DELETE ;
|
||||
mCategory = -1;
|
||||
}
|
||||
|
||||
void LLImageGL::cleanup()
|
||||
@@ -592,7 +576,7 @@ void LLImageGL::forceUpdateBindStats(void) const
|
||||
mLastBindTime = sLastFrameTime;
|
||||
}
|
||||
|
||||
BOOL LLImageGL::updateBindStats() const
|
||||
BOOL LLImageGL::updateBindStats(S32 tex_mem) const
|
||||
{
|
||||
if (mTexName != 0)
|
||||
{
|
||||
@@ -604,32 +588,18 @@ BOOL LLImageGL::updateBindStats() const
|
||||
{
|
||||
// we haven't accounted for this texture yet this frame
|
||||
sUniqueCount++;
|
||||
|
||||
updateBoundTexMem();
|
||||
updateBoundTexMem(tex_mem, mComponents, mCategory);
|
||||
mLastBindTime = sLastFrameTime;
|
||||
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//virtual
|
||||
bool LLImageGL::bindError(const S32 stage) const
|
||||
F32 LLImageGL::getTimePassedSinceLastBound()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//virtual
|
||||
bool LLImageGL::bindDefaultImage(const S32 stage)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLImageGL::forceImmediateUpdate()
|
||||
{
|
||||
return ;
|
||||
return sLastFrameTime - mLastBindTime ;
|
||||
}
|
||||
|
||||
void LLImageGL::setExplicitFormat( LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes )
|
||||
@@ -1184,7 +1154,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
|
||||
|
||||
if(gAuditTexture)
|
||||
{
|
||||
decTextureCounter() ;
|
||||
decTextureCounter(mTextureMemory, mComponents, mCategory) ;
|
||||
}
|
||||
|
||||
LLImageGL::deleteTextures(1, &old_name);
|
||||
@@ -1194,11 +1164,10 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
|
||||
|
||||
mTextureMemory = getMipBytes(discard_level);
|
||||
sGlobalTextureMemoryInBytes += mTextureMemory;
|
||||
setActive() ;
|
||||
|
||||
if(gAuditTexture)
|
||||
{
|
||||
incTextureCounter() ;
|
||||
incTextureCounter(mTextureMemory, mComponents, mCategory) ;
|
||||
}
|
||||
// mark this as bound at this point, so we don't throw it out immediately
|
||||
mLastBindTime = sLastFrameTime;
|
||||
@@ -1398,20 +1367,21 @@ void LLImageGL::destroyGLTexture()
|
||||
{
|
||||
if(gAuditTexture)
|
||||
{
|
||||
decTextureCounter() ;
|
||||
decTextureCounter(mTextureMemory, mComponents, mCategory) ;
|
||||
}
|
||||
sGlobalTextureMemoryInBytes -= mTextureMemory;
|
||||
mTextureMemory = 0;
|
||||
}
|
||||
|
||||
LLImageGL::deleteTextures(1, &mTexName);
|
||||
mTextureState = DELETED ;
|
||||
LLImageGL::deleteTextures(1, &mTexName);
|
||||
mTexName = 0;
|
||||
mCurrentDiscardLevel = -1 ; //invalidate mCurrentDiscardLevel.
|
||||
mGLTextureCreated = FALSE ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void LLImageGL::setAddressMode(LLTexUnit::eTextureAddressMode mode)
|
||||
@@ -1724,59 +1694,6 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLImageGL::isDeleted()
|
||||
{
|
||||
return mTextureState == DELETED ;
|
||||
}
|
||||
|
||||
BOOL LLImageGL::isInactive()
|
||||
{
|
||||
return mTextureState == INACTIVE ;
|
||||
}
|
||||
|
||||
BOOL LLImageGL::isDeletionCandidate()
|
||||
{
|
||||
return mTextureState == DELETION_CANDIDATE ;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void LLImageGL::setDeletionCandidate()
|
||||
{
|
||||
if(mTexName && (mTextureState == INACTIVE))
|
||||
{
|
||||
mTextureState = DELETION_CANDIDATE ;
|
||||
}
|
||||
}
|
||||
|
||||
void LLImageGL::forceActive()
|
||||
{
|
||||
mTextureState = ACTIVE ;
|
||||
}
|
||||
|
||||
void LLImageGL::setActive()
|
||||
{
|
||||
if(mTextureState != NO_DELETE)
|
||||
{
|
||||
mTextureState = ACTIVE ;
|
||||
}
|
||||
}
|
||||
|
||||
//set the texture inactive
|
||||
void LLImageGL::setInactive()
|
||||
{
|
||||
if(mTexName && (mTextureState == ACTIVE) && !getBoundRecently())
|
||||
{
|
||||
mTextureState = INACTIVE ;
|
||||
}
|
||||
}
|
||||
|
||||
//set the texture to stay in memory
|
||||
void LLImageGL::setNoDelete()
|
||||
{
|
||||
mTextureState = NO_DELETE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in)
|
||||
{
|
||||
@@ -1928,26 +1845,21 @@ S32 LLImageGL::getTextureCounterIndex(U32 val)
|
||||
return ret ;
|
||||
}
|
||||
}
|
||||
void LLImageGL::incTextureCounterStatic(U32 val, S32 ncomponents, S32 category)
|
||||
|
||||
//static
|
||||
void LLImageGL::incTextureCounter(U32 val, S32 ncomponents, S32 category)
|
||||
{
|
||||
sTextureLoadedCounter[getTextureCounterIndex(val)]++ ;
|
||||
sTextureMemByCategory[category] += (S32)val * ncomponents ;
|
||||
}
|
||||
void LLImageGL::decTextureCounterStatic(U32 val, S32 ncomponents, S32 category)
|
||||
|
||||
//static
|
||||
void LLImageGL::decTextureCounter(U32 val, S32 ncomponents, S32 category)
|
||||
{
|
||||
sTextureLoadedCounter[getTextureCounterIndex(val)]-- ;
|
||||
sTextureMemByCategory[category] += (S32)val * ncomponents ;
|
||||
}
|
||||
void LLImageGL::incTextureCounter()
|
||||
{
|
||||
sTextureLoadedCounter[getTextureCounterIndex(mTextureMemory / mComponents)]++ ;
|
||||
sTextureMemByCategory[mCategory] += mTextureMemory ;
|
||||
}
|
||||
void LLImageGL::decTextureCounter()
|
||||
{
|
||||
sTextureLoadedCounter[getTextureCounterIndex(mTextureMemory / mComponents)]-- ;
|
||||
sTextureMemByCategory[mCategory] -= mTextureMemory ;
|
||||
}
|
||||
|
||||
void LLImageGL::setCurTexSizebar(S32 index, BOOL set_pick_size)
|
||||
{
|
||||
sCurTexSizeBar = index ;
|
||||
|
||||
@@ -59,7 +59,8 @@ public:
|
||||
static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height);
|
||||
static S32 dataFormatComponents(S32 dataformat);
|
||||
|
||||
BOOL updateBindStats(void) const;
|
||||
BOOL updateBindStats(S32 tex_mem) const ;
|
||||
F32 getTimePassedSinceLastBound();
|
||||
void forceUpdateBindStats(void) const;
|
||||
|
||||
// needs to be called every frame
|
||||
@@ -71,8 +72,7 @@ public:
|
||||
static void dirtyTexOptions();
|
||||
|
||||
// Sometimes called externally for textures not using LLImageGL (should go away...)
|
||||
static S32 updateBoundTexMemStatic(const S32 delta, const S32 size, S32 category) ;
|
||||
S32 updateBoundTexMem()const;
|
||||
static S32 updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) ;
|
||||
|
||||
static bool checkSize(S32 width, S32 height);
|
||||
|
||||
@@ -95,11 +95,9 @@ protected:
|
||||
|
||||
public:
|
||||
virtual void dump(); // debugging info to llinfos
|
||||
virtual bool bindError(const S32 stage = 0) const;
|
||||
virtual bool bindDefaultImage(const S32 stage = 0) ;
|
||||
virtual void forceImmediateUpdate() ;
|
||||
|
||||
|
||||
void setSize(S32 width, S32 height, S32 ncomponents);
|
||||
void setComponents(S32 ncomponents) { mComponents = (S8)ncomponents ;}
|
||||
|
||||
// These 3 functions currently wrap glGenTextures(), glDeleteTextures(), and glTexImage2D()
|
||||
// for tracking purposes and will be deprecated in the future
|
||||
@@ -122,7 +120,6 @@ public:
|
||||
void destroyGLTexture();
|
||||
|
||||
void setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE);
|
||||
void dontDiscard() { mDontDiscard = 1; mTextureState = NO_DELETE; }
|
||||
void setComponents(S8 ncomponents) { mComponents = ncomponents; }
|
||||
|
||||
S32 getDiscardLevel() const { return mCurrentDiscardLevel; }
|
||||
@@ -154,14 +151,12 @@ public:
|
||||
void setGLTextureCreated (bool initialized) { mGLTextureCreated = initialized; }
|
||||
|
||||
BOOL getUseMipMaps() const { return mUseMipMaps; }
|
||||
void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; }
|
||||
BOOL getUseDiscard() const { return mUseMipMaps && !mDontDiscard; }
|
||||
BOOL getDontDiscard() const { return mDontDiscard; }
|
||||
void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; }
|
||||
|
||||
void updatePickMask(S32 width, S32 height, const U8* data_in);
|
||||
BOOL getMask(const LLVector2 &tc);
|
||||
|
||||
void checkTexSize() const ;
|
||||
void checkTexSize(bool forced = false) const ;
|
||||
|
||||
// Sets the addressing mode used to sample the texture
|
||||
// (such as wrapping, mirrored wrapping, and clamp)
|
||||
@@ -175,17 +170,7 @@ public:
|
||||
void setFilteringOption(LLTexUnit::eTextureFilterOptions option);
|
||||
LLTexUnit::eTextureFilterOptions getFilteringOption(void) const { return mFilterOption; }
|
||||
|
||||
BOOL isDeleted() ;
|
||||
BOOL isInactive() ;
|
||||
BOOL isDeletionCandidate();
|
||||
void setDeletionCandidate() ;
|
||||
void setInactive() ;
|
||||
void setActive() ;
|
||||
void forceActive() ;
|
||||
void setNoDelete() ;
|
||||
|
||||
void setTextureSize(S32 size) {mTextureMemory = size;}
|
||||
protected:
|
||||
LLGLenum getTexTarget()const { return mTarget ;}
|
||||
void init(BOOL usemipmaps);
|
||||
virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors
|
||||
|
||||
@@ -224,8 +209,7 @@ protected:
|
||||
|
||||
S8 mComponents;
|
||||
S8 mMaxDiscardLevel;
|
||||
S8 mDontDiscard; // Keep full res version of this image (for UI, etc)
|
||||
|
||||
|
||||
bool mTexOptionsDirty;
|
||||
LLTexUnit::eTextureAddressMode mAddressMode; // Defaults to TAM_WRAP
|
||||
LLTexUnit::eTextureFilterOptions mFilterOption; // Defaults to TFO_TRILINEAR
|
||||
@@ -235,17 +219,6 @@ protected:
|
||||
LLGLenum mFormatPrimary; // = GL format (pixel data format)
|
||||
LLGLenum mFormatType;
|
||||
BOOL mFormatSwapBytes;// if true, use glPixelStorei(GL_UNPACK_SWAP_BYTES, 1)
|
||||
|
||||
protected:
|
||||
typedef enum
|
||||
{
|
||||
DELETED = 0, //removed from memory
|
||||
DELETION_CANDIDATE, //ready to be removed from memory
|
||||
INACTIVE, //not be used for the last certain period (i.e., 30 seconds).
|
||||
ACTIVE, //just being used, can become inactive if not being used for a certain time (10 seconds).
|
||||
NO_DELETE = 99 //stay in memory, can not be removed.
|
||||
} LLGLTexureState;
|
||||
LLGLTexureState mTextureState ;
|
||||
|
||||
// STATICS
|
||||
public:
|
||||
@@ -263,6 +236,8 @@ public:
|
||||
static U32 sBindCount; // Tracks number of texture binds for current frame
|
||||
static U32 sUniqueCount; // Tracks number of unique texture binds for current frame
|
||||
static BOOL sGlobalUseAnisotropic;
|
||||
static LLImageGL* sDefaultGLTexture ;
|
||||
|
||||
#if DEBUG_MISS
|
||||
BOOL mMissed; // Missed on last bind?
|
||||
BOOL getMissed() const { return mMissed; };
|
||||
@@ -300,13 +275,10 @@ public:
|
||||
|
||||
static void setHighlightTexture(S32 category) ;
|
||||
static S32 getTextureCounterIndex(U32 val) ;
|
||||
static void incTextureCounterStatic(U32 val, S32 ncomponents, S32 category) ;
|
||||
static void decTextureCounterStatic(U32 val, S32 ncomponents, S32 category) ;
|
||||
static void incTextureCounter(U32 val, S32 ncomponents, S32 category) ;
|
||||
static void decTextureCounter(U32 val, S32 ncomponents, S32 category) ;
|
||||
static void setCurTexSizebar(S32 index, BOOL set_pick_size = TRUE) ;
|
||||
static void resetCurTexSizebar();
|
||||
|
||||
void incTextureCounter() ;
|
||||
void decTextureCounter() ;
|
||||
//----------------------------------------
|
||||
|
||||
//for debug use: show texture category distribution
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "llcubemap.h"
|
||||
#include "llimagegl.h"
|
||||
#include "llrendertarget.h"
|
||||
#include "lltexture.h"
|
||||
|
||||
LLRender gGL;
|
||||
|
||||
@@ -179,50 +180,86 @@ void LLTexUnit::disable(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind)
|
||||
bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind)
|
||||
{
|
||||
stop_glerror();
|
||||
if (mIndex < 0) return false;
|
||||
|
||||
gGL.flush();
|
||||
|
||||
if (texture == NULL)
|
||||
LLImageGL* gl_tex = NULL ;
|
||||
if (texture == NULL || !(gl_tex = texture->getGLTexture()))
|
||||
{
|
||||
llwarns << "NULL LLTexUnit::bind texture" << llendl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!texture->getTexName()) //if texture does not exist
|
||||
{
|
||||
if (texture->isDeleted())
|
||||
{
|
||||
// This will re-generate the texture immediately.
|
||||
texture->forceImmediateUpdate() ;
|
||||
}
|
||||
|
||||
texture->forceUpdateBindStats() ;
|
||||
if (!gl_tex->getTexName()) //if texture does not exist
|
||||
{
|
||||
//if deleted, will re-generate it immediately
|
||||
texture->forceImmediateUpdate() ;
|
||||
|
||||
gl_tex->forceUpdateBindStats() ;
|
||||
return texture->bindDefaultImage(mIndex);
|
||||
}
|
||||
|
||||
//in audit, replace the selected texture by the default one.
|
||||
if(gAuditTexture && for_rendering && LLImageGL::sCurTexPickSize > 0)
|
||||
{
|
||||
if(texture->getWidth() * texture->getHeight() == LLImageGL::sCurTexPickSize)
|
||||
{
|
||||
texture->updateBindStats();
|
||||
gl_tex->updateBindStats(gl_tex->mTextureMemory);
|
||||
return bind(LLImageGL::sHighlightTexturep.get());
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind)
|
||||
{
|
||||
stop_glerror();
|
||||
if (mIndex < 0) return false;
|
||||
|
||||
if(!texture)
|
||||
{
|
||||
llwarns << "NULL LLTexUnit::bind texture" << llendl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!texture->getTexName())
|
||||
{
|
||||
if(LLImageGL::sDefaultGLTexture && LLImageGL::sDefaultGLTexture->getTexName())
|
||||
{
|
||||
return bind(LLImageGL::sDefaultGLTexture) ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
if ((mCurrTexture != texture->getTexName()) || forceBind)
|
||||
{
|
||||
activate();
|
||||
enable(texture->getTarget());
|
||||
mCurrTexture = texture->getTexName();
|
||||
glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture);
|
||||
if(texture->updateBindStats())
|
||||
{
|
||||
texture->setActive() ;
|
||||
}
|
||||
texture->updateBindStats(texture->mTextureMemory);
|
||||
mHasMipMaps = texture->mHasMipMaps;
|
||||
if (texture->mTexOptionsDirty)
|
||||
{
|
||||
@@ -255,7 +292,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap)
|
||||
mCurrTexture = cubeMap->mImages[0]->getTexName();
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture);
|
||||
mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps;
|
||||
cubeMap->mImages[0]->updateBindStats();
|
||||
cubeMap->mImages[0]->updateBindStats(cubeMap->mImages[0]->mTextureMemory);
|
||||
if (cubeMap->mImages[0]->mTexOptionsDirty)
|
||||
{
|
||||
cubeMap->mImages[0]->mTexOptionsDirty = false;
|
||||
|
||||
@@ -51,6 +51,7 @@ class LLVertexBuffer;
|
||||
class LLCubeMap;
|
||||
class LLImageGL;
|
||||
class LLRenderTarget;
|
||||
class LLTexture ;
|
||||
|
||||
class LLTexUnit
|
||||
{
|
||||
@@ -149,6 +150,7 @@ public:
|
||||
// Binds the LLImageGL to this texture unit
|
||||
// (automatically enables the unit for the LLImageGL's texture type)
|
||||
bool bind(LLImageGL* texture, bool for_rendering = false, bool forceBind = false);
|
||||
bool bind(LLTexture* texture, bool for_rendering = false, bool forceBind = false);
|
||||
|
||||
// Binds a cubemap to this texture unit
|
||||
// (automatically enables the texture unit for cubemaps)
|
||||
|
||||
38
indra/llrender/lltexture.cpp
Normal file
38
indra/llrender/lltexture.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file lltexture.cpp
|
||||
*
|
||||
* $LicenseInfo:firstyear=2000&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2000-2010, Linden Research, Inc.
|
||||
*
|
||||
* 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://secondlife.com/developers/opensource/gplv2
|
||||
*
|
||||
* 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://secondlife.com/developers/opensource/flossexception
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*
|
||||
*/
|
||||
#include "linden_common.h"
|
||||
#include "lltexture.h"
|
||||
|
||||
//virtual
|
||||
LLTexture::~LLTexture()
|
||||
{
|
||||
}
|
||||
80
indra/llrender/lltexture.h
Normal file
80
indra/llrender/lltexture.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @file lltexture.h
|
||||
* @brief LLTexture definition
|
||||
*
|
||||
* This class acts as a wrapper for OpenGL calls.
|
||||
* The goal of this class is to minimize the number of api calls due to legacy rendering
|
||||
* code, to define an interface for a multiple rendering API abstraction of the UI
|
||||
* rendering, and to abstract out direct rendering calls in a way that is cleaner and easier to maintain.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2010, Linden Research, Inc.
|
||||
*
|
||||
* 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://secondlife.com/developers/opensource/gplv2
|
||||
*
|
||||
* 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://secondlife.com/developers/opensource/flossexception
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LL_TEXTURE_H
|
||||
#define LL_TEXTURE_H
|
||||
|
||||
#include "llmemory.h"
|
||||
class LLImageGL ;
|
||||
class LLTexUnit ;
|
||||
class LLFontGL ;
|
||||
|
||||
//
|
||||
//this is an abstract class as the parent for the class LLViewerTexture
|
||||
//through the following virtual functions, the class LLViewerTexture can be reached from /llrender.
|
||||
//
|
||||
class LLTexture : public LLRefCount
|
||||
{
|
||||
friend class LLTexUnit ;
|
||||
friend class LLFontGL ;
|
||||
|
||||
protected:
|
||||
virtual ~LLTexture();
|
||||
|
||||
public:
|
||||
LLTexture(){}
|
||||
|
||||
//
|
||||
//interfaces to access LLViewerTexture
|
||||
//
|
||||
virtual S8 getType() const = 0 ;
|
||||
virtual void setKnownDrawSize(S32 width, S32 height) = 0 ;
|
||||
virtual bool bindDefaultImage(const S32 stage = 0) = 0 ;
|
||||
virtual void forceImmediateUpdate() = 0 ;
|
||||
virtual void setActive() = 0 ;
|
||||
virtual S32 getWidth(S32 discard_level = -1) const = 0 ;
|
||||
virtual S32 getHeight(S32 discard_level = -1) const = 0 ;
|
||||
|
||||
private:
|
||||
//note: do not make this function public.
|
||||
virtual LLImageGL* getGLTexture() const = 0 ;
|
||||
|
||||
virtual void updateBindStatsForTester() = 0 ;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user