summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llcubemap.cpp12
-rw-r--r--indra/llrender/llgl.cpp23
-rw-r--r--indra/llrender/llglslshader.cpp3
-rw-r--r--indra/llrender/llglslshader.h1
-rw-r--r--indra/llrender/llimagegl.cpp12
-rw-r--r--indra/llrender/llrender.cpp29
-rw-r--r--indra/llrender/llrender.h2
-rw-r--r--indra/llrender/llvertexbuffer.cpp14
8 files changed, 69 insertions, 27 deletions
diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp
index fb22d7f1f5..1b10354c22 100644
--- a/indra/llrender/llcubemap.cpp
+++ b/indra/llrender/llcubemap.cpp
@@ -259,7 +259,7 @@ void LLCubeMap::setMatrix(S32 stage)
if (mMatrixStage < 0) return;
- if (stage > 0)
+ //if (stage > 0)
{
gGL.getTexUnit(stage)->activate();
}
@@ -278,17 +278,17 @@ void LLCubeMap::setMatrix(S32 stage)
glLoadMatrixf((F32 *)trans.mMatrix);
glMatrixMode(GL_MODELVIEW);
- if (stage > 0)
+ /*if (stage > 0)
{
gGL.getTexUnit(0)->activate();
- }
+ }*/
}
void LLCubeMap::restoreMatrix()
{
if (mMatrixStage < 0) return;
- if (mMatrixStage > 0)
+ //if (mMatrixStage > 0)
{
gGL.getTexUnit(mMatrixStage)->activate();
}
@@ -296,10 +296,10 @@ void LLCubeMap::restoreMatrix()
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
- if (mMatrixStage > 0)
+ /*if (mMatrixStage > 0)
{
gGL.getTexUnit(0)->activate();
- }
+ }*/
}
void LLCubeMap::setReflection (void)
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index e07ff0015c..8937726209 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -986,12 +986,12 @@ void LLGLManager::initExtensions()
}
if (mHasSync)
{
- glFenceSync = (PFNGLFENCESYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glFenceSync");
- glIsSync = (PFNGLISSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glIsSync");
- glDeleteSync = (PFNGLDELETESYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteSync");
- glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glClientWaitSync");
- glWaitSync = (PFNGLWAITSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glWaitSync");
- glGetInteger64v = (PFNGLGETINTEGER64VPROC) GLH_EXT_GET_PROC_ADDRESS("glGetInteger64v");
+ glFenceSync = (PFNGLFENCESYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glFenceSync");
+ glIsSync = (PFNGLISSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glIsSync");
+ glDeleteSync = (PFNGLDELETESYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteSync");
+ glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glClientWaitSync");
+ glWaitSync = (PFNGLWAITSYNCPROC) GLH_EXT_GET_PROC_ADDRESS("glWaitSync");
+ glGetInteger64v = (PFNGLGETINTEGER64VPROC) GLH_EXT_GET_PROC_ADDRESS("glGetInteger64v");
glGetSynciv = (PFNGLGETSYNCIVPROC) GLH_EXT_GET_PROC_ADDRESS("glGetSynciv");
}
if (mHasMapBufferRange)
@@ -1379,6 +1379,8 @@ void LLGLState::checkStates(const std::string& msg)
glGetIntegerv(GL_BLEND_SRC, &src);
glGetIntegerv(GL_BLEND_DST, &dst);
+ stop_glerror();
+
BOOL error = FALSE;
if (src != GL_SRC_ALPHA || dst != GL_ONE_MINUS_SRC_ALPHA)
@@ -1399,7 +1401,9 @@ void LLGLState::checkStates(const std::string& msg)
{
LLGLenum state = iter->first;
LLGLboolean cur_state = iter->second;
+ stop_glerror();
LLGLboolean gl_state = glIsEnabled(state);
+ stop_glerror();
if(cur_state != gl_state)
{
dumpStates();
@@ -1424,11 +1428,11 @@ void LLGLState::checkStates(const std::string& msg)
void LLGLState::checkTextureChannels(const std::string& msg)
{
+#if 0
if (!gDebugGL)
{
return;
}
-
stop_glerror();
GLint activeTexture;
@@ -1594,6 +1598,7 @@ void LLGLState::checkTextureChannels(const std::string& msg)
LL_GL_ERRS << "GL texture state corruption detected. " << msg << LL_ENDL;
}
}
+#endif
}
void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask)
@@ -1710,7 +1715,7 @@ void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask)
}
}
- if (glIsEnabled(GL_TEXTURE_2D))
+ /*if (glIsEnabled(GL_TEXTURE_2D))
{
if (!(data_mask & 0x0008))
{
@@ -1733,7 +1738,7 @@ void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask)
gFailLog << "GL does not have GL_TEXTURE_2D enabled on channel 1." << std::endl;
}
}
- }
+ }*/
glClientActiveTextureARB(GL_TEXTURE0_ARB);
gGL.getTexUnit(0)->activate();
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index ad2c662dfc..c582858413 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -49,6 +49,7 @@ using std::make_pair;
using std::string;
GLhandleARB LLGLSLShader::sCurBoundShader = 0;
+bool LLGLSLShader::sNoFixedFunction = false;
BOOL shouldChange(const LLVector4& v1, const LLVector4& v2)
{
@@ -376,6 +377,7 @@ BOOL LLGLSLShader::link(BOOL suppress_errors)
void LLGLSLShader::bind()
{
+ gGL.flush();
if (gGLManager.mHasShaderObjects)
{
glUseProgramObjectARB(mProgramObject);
@@ -390,6 +392,7 @@ void LLGLSLShader::bind()
void LLGLSLShader::unbind()
{
+ gGL.flush();
if (gGLManager.mHasShaderObjects)
{
stop_glerror();
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 4922eb6d67..24562c3c42 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -67,6 +67,7 @@ public:
LLGLSLShader();
static GLhandleARB sCurBoundShader;
+ static bool sNoFixedFunction;
void unload();
BOOL createShader(std::vector<std::string> * attributes,
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 60a5962234..9ca3a23d52 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1414,6 +1414,8 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
void LLImageGL::deleteDeadTextures()
{
+ bool reset = false;
+
while (!sDeadTextureList.empty())
{
GLuint tex = sDeadTextureList.front();
@@ -1426,12 +1428,22 @@ void LLImageGL::deleteDeadTextures()
{
tex_unit->unbind(tex_unit->getCurrType());
stop_glerror();
+
+ if (i > 0)
+ {
+ reset = true;
+ }
}
}
glDeleteTextures(1, &tex);
stop_glerror();
}
+
+ if (reset)
+ {
+ gGL.getTexUnit(0)->activate();
+ }
}
void LLImageGL::destroyGLTexture()
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 1d82dda30f..70df1dd1d1 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -46,6 +46,7 @@ S32 gGLViewport[4];
U32 LLRender::sUICalls = 0;
U32 LLRender::sUIVerts = 0;
+U32 LLTexUnit::sWhiteTexture = 0;
static const U32 LL_NUM_TEXTURE_LAYERS = 32;
static const U32 LL_NUM_LIGHT_UNITS = 8;
@@ -126,7 +127,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) && mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE;
+ bool enableDisable = !LLGLSLShader::sNoFixedFunction &&
+ (mIndex < gGLManager.mNumTextureUnits) && mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE;
if (mCurrTexType != TT_NONE)
{
@@ -184,7 +186,8 @@ void LLTexUnit::enable(eTextureType type)
mCurrTexType = type;
gGL.flush();
- if (type != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
+ if (!LLGLSLShader::sNoFixedFunction &&
+ type != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
mIndex < gGLManager.mNumTextureUnits)
{
glEnable(sGLTextureType[type]);
@@ -201,7 +204,8 @@ void LLTexUnit::disable(void)
activate();
unbind(mCurrTexType);
gGL.flush();
- if (mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
+ if (!LLGLSLShader::sNoFixedFunction &&
+ mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
mIndex < gGLManager.mNumTextureUnits)
{
glDisable(sGLTextureType[mCurrTexType]);
@@ -403,7 +407,14 @@ 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();
}
}
@@ -474,6 +485,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.
@@ -594,6 +610,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();
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 41e7b35341..9eedebe2ce 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -52,6 +52,8 @@ class LLTexUnit
{
friend class LLRender;
public:
+ static U32 sWhiteTexture;
+
typedef enum
{
TT_TEXTURE = 0, // Standard 2D Texture
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 82c5efe0ac..1180afa631 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -35,6 +35,8 @@
#include "llmemtype.h"
#include "llrender.h"
#include "llvector4a.h"
+#include "llglslshader.h"
+
//============================================================================
@@ -1113,8 +1115,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran
src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER_ARB, offset, length,
GL_MAP_WRITE_BIT |
GL_MAP_FLUSH_EXPLICIT_BIT |
- GL_MAP_INVALIDATE_RANGE_BIT |
- GL_MAP_UNSYNCHRONIZED_BIT);
+ GL_MAP_INVALIDATE_RANGE_BIT);
#endif
}
else
@@ -1122,8 +1123,7 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran
#ifdef GL_ARB_map_buffer_range
src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER_ARB, 0, mSize,
GL_MAP_WRITE_BIT |
- GL_MAP_FLUSH_EXPLICIT_BIT |
- GL_MAP_UNSYNCHRONIZED_BIT);
+ GL_MAP_FLUSH_EXPLICIT_BIT);
#endif
}
}
@@ -1280,8 +1280,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range)
src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length,
GL_MAP_WRITE_BIT |
GL_MAP_FLUSH_EXPLICIT_BIT |
- GL_MAP_INVALIDATE_RANGE_BIT |
- GL_MAP_UNSYNCHRONIZED_BIT);
+ GL_MAP_INVALIDATE_RANGE_BIT);
#endif
}
else
@@ -1289,8 +1288,7 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range)
#ifdef GL_ARB_map_buffer_range
src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, sizeof(U16)*mNumIndices,
GL_MAP_WRITE_BIT |
- GL_MAP_FLUSH_EXPLICIT_BIT |
- GL_MAP_UNSYNCHRONIZED_BIT);
+ GL_MAP_FLUSH_EXPLICIT_BIT);
#endif
}
}