Replaced some opengl fixed functions with shaders. Temporary ShyotlUseLegacyRenderPath setting to debug if this change actually improves framerate at all (setting not tied to callbacks. Have to toggle shaders to have stuff pick up the setting change)
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "llvertexbuffer.h"
|
||||
#include "llcubemap.h"
|
||||
#include "llglslshader.h"
|
||||
#include "llimagegl.h"
|
||||
#include "llrendertarget.h"
|
||||
#include "lltexture.h"
|
||||
@@ -49,6 +50,7 @@ F64 gGLLastProjection[16];
|
||||
F64 gGLProjection[16];
|
||||
S32 gGLViewport[4];
|
||||
|
||||
U32 LLTexUnit::sWhiteTexture = 0;
|
||||
|
||||
static const U32 LL_NUM_TEXTURE_LAYERS = 32;
|
||||
static const U32 LL_NUM_LIGHT_UNITS = 8;
|
||||
@@ -58,6 +60,7 @@ static GLenum sGLTextureType[] =
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE_RECTANGLE_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_ARB
|
||||
//,GL_TEXTURE_2D_MULTISAMPLE Don't use.
|
||||
};
|
||||
|
||||
static GLint sGLAddressMode[] =
|
||||
@@ -128,7 +131,8 @@ void LLTexUnit::refreshState(void)
|
||||
// Per apple spec, don't call glEnable/glDisable when index exceeds max texture units
|
||||
// http://www.mailinglistarchive.com/html/mac-opengl@lists.apple.com/2008-07/msg00653.html
|
||||
//
|
||||
bool enableDisable = (mIndex < gGLManager.mNumTextureUnits);
|
||||
bool enableDisable = !LLGLSLShader::sNoFixedFunction &&
|
||||
(mIndex < gGLManager.mNumTextureUnits) /*&& mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE*/;
|
||||
|
||||
if (mCurrTexType != TT_NONE)
|
||||
{
|
||||
@@ -184,8 +188,11 @@ void LLTexUnit::enable(eTextureType type)
|
||||
disable(); // Force a disable of a previous texture type if it's enabled.
|
||||
}
|
||||
mCurrTexType = type;
|
||||
|
||||
gGL.flush();
|
||||
if (mIndex < gGLManager.mNumTextureUnits)
|
||||
if (!LLGLSLShader::sNoFixedFunction &&
|
||||
//type != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
|
||||
mIndex < gGLManager.mNumTextureUnits)
|
||||
{
|
||||
glEnable(sGLTextureType[type]);
|
||||
}
|
||||
@@ -201,7 +208,9 @@ void LLTexUnit::disable(void)
|
||||
activate();
|
||||
unbind(mCurrTexType);
|
||||
gGL.flush();
|
||||
if (mIndex < gGLManager.mNumTextureUnits)
|
||||
if (!LLGLSLShader::sNoFixedFunction &&
|
||||
//mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
|
||||
mIndex < gGLManager.mNumTextureUnits)
|
||||
{
|
||||
glDisable(sGLTextureType[mCurrTexType]);
|
||||
}
|
||||
@@ -405,7 +414,15 @@ void LLTexUnit::unbind(eTextureType type)
|
||||
|
||||
activate();
|
||||
mCurrTexture = 0;
|
||||
glBindTexture(sGLTextureType[type], 0);
|
||||
if (LLGLSLShader::sNoFixedFunction && type == LLTexUnit::TT_TEXTURE)
|
||||
{
|
||||
glBindTexture(sGLTextureType[type], sWhiteTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(sGLTextureType[type], 0);
|
||||
}
|
||||
stop_glerror();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +444,7 @@ void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode)
|
||||
|
||||
void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions option)
|
||||
{
|
||||
if (mIndex < 0 || mCurrTexture == 0) return;
|
||||
if (mIndex < 0 || mCurrTexture == 0 /*|| mCurrTexType == LLTexUnit::TT_MULTISAMPLE_TEXTURE*/) return;
|
||||
|
||||
gGL.flush();
|
||||
|
||||
@@ -475,6 +492,11 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio
|
||||
|
||||
void LLTexUnit::setTextureBlendType(eTextureBlendType type)
|
||||
{
|
||||
if (LLGLSLShader::sNoFixedFunction)
|
||||
{ //texture blend type means nothing when using shaders
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIndex < 0) return;
|
||||
|
||||
// Do nothing if it's already correctly set.
|
||||
@@ -595,6 +617,11 @@ GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha)
|
||||
|
||||
void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2, bool isAlpha)
|
||||
{
|
||||
if (LLGLSLShader::sNoFixedFunction)
|
||||
{ //register combiners do nothing when not using fixed function
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIndex < 0) return;
|
||||
|
||||
activate();
|
||||
|
||||
Reference in New Issue
Block a user