summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-02-21 16:03:46 -0800
committerGraham Linden <graham@lindenlab.com>2019-02-21 16:03:46 -0800
commit788a108384a27abf343a1e9ebf5f2437a75552a2 (patch)
tree652beb9742c62c75cebada1ee4404013a23d6645 /indra
parent5ff4580cbb950b82cdcec6574b3292ea3d67ac21 (diff)
SL-10501
Fix broken matrix management code causing modelview mats to be used as tex anim mats (do not depend on default matrix mode already being set). Give the deferred terrain shader a name. Make LLRender use the eMatrixMode enum instead of ints.
Diffstat (limited to 'indra')
-rw-r--r--indra/llrender/llgl.cpp4
-rw-r--r--indra/llrender/llrender.cpp20
-rw-r--r--indra/llrender/llrender.h6
-rw-r--r--indra/newview/lldrawpool.cpp1
-rw-r--r--indra/newview/lldrawpoolavatar.cpp14
-rw-r--r--indra/newview/llviewershadermgr.cpp2
-rw-r--r--indra/newview/pipeline.cpp1
7 files changed, 23 insertions, 25 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 490e1a8c2f..b6300578e6 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -2507,7 +2507,7 @@ void LLGLSquashToFarClip::setProjectionMatrix(glh::matrix4f& projection, U32 lay
projection.element(2, i) = projection.element(3, i) * depth;
}
- U32 last_matrix_mode = gGL.getMatrixMode();
+ LLRender::eMatrixMode last_matrix_mode = gGL.getMatrixMode();
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
@@ -2518,7 +2518,7 @@ void LLGLSquashToFarClip::setProjectionMatrix(glh::matrix4f& projection, U32 lay
LLGLSquashToFarClip::~LLGLSquashToFarClip()
{
- U32 last_matrix_mode = gGL.getMatrixMode();
+ LLRender::eMatrixMode last_matrix_mode = gGL.getMatrixMode();
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.popMatrix();
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index dc9affb596..e3bb9298cb 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1338,7 +1338,7 @@ void LLRender::syncMatrices()
GL_TEXTURE,
};
- for (U32 i = 0; i < 2; ++i)
+ for (U32 i = 0; i < MM_TEXTURE0; ++i)
{
if (mMatHash[i] != mCurMatHash[i])
{
@@ -1348,11 +1348,11 @@ void LLRender::syncMatrices()
}
}
- for (U32 i = 2; i < NUM_MATRIX_MODES; ++i)
+ for (U32 i = MM_TEXTURE0; i < NUM_MATRIX_MODES; ++i)
{
if (mMatHash[i] != mCurMatHash[i])
{
- gGL.getTexUnit(i-2)->activate();
+ gGL.getTexUnit(i-MM_TEXTURE0)->activate();
glMatrixMode(mode[i]);
glLoadMatrixf(mMatrix[i][mMatIdx[i]].m);
mCurMatHash[i] = mMatHash[i];
@@ -1484,25 +1484,21 @@ void LLRender::multMatrix(const GLfloat* m)
}
}
-void LLRender::matrixMode(U32 mode)
+void LLRender::matrixMode(eMatrixMode mode)
{
if (mode == MM_TEXTURE)
{
U32 tex_index = gGL.getCurrentTexUnitIndex();
- // the shaders don't actually reference anything beyond texture_matrix0/1
- if (tex_index > 3)
- {
- LL_WARNS_ONCE("render") << "Cannot use texture matrix with texture unit " << tex_index << " forcing texture matrix 3!" << LL_ENDL;
- tex_index = 3;
- }
- mode = MM_TEXTURE0 + gGL.getCurrentTexUnitIndex();
+ // the shaders don't actually reference anything beyond texture_matrix0/1 outside of terrain rendering
+ llassert_always(tex_index <= 3);
+ mode = eMatrixMode(MM_TEXTURE0 + gGL.getCurrentTexUnitIndex());
}
llassert(mode < NUM_MATRIX_MODES);
mMatrixMode = mode;
}
-U32 LLRender::getMatrixMode()
+LLRender::eMatrixMode LLRender::getMatrixMode()
{
if (mMatrixMode >= MM_TEXTURE0 && mMatrixMode <= MM_TEXTURE3)
{ //always return MM_TEXTURE if current matrix mode points at any texture matrix
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 012a8da4ce..3f2d5eb35d 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -364,8 +364,8 @@ public:
void loadMatrix(const GLfloat* m);
void loadIdentity();
void multMatrix(const GLfloat* m);
- void matrixMode(U32 mode);
- U32 getMatrixMode();
+ void matrixMode(eMatrixMode mode);
+ eMatrixMode getMatrixMode();
const glh::matrix4f& getModelviewMatrix();
const glh::matrix4f& getProjectionMatrix();
@@ -454,7 +454,7 @@ public:
private:
friend class LLLightState;
- U32 mMatrixMode;
+ eMatrixMode mMatrixMode;
U32 mMatIdx[NUM_MATRIX_MODES];
U32 mMatHash[NUM_MATRIX_MODES];
glh::matrix4f mMatrix[NUM_MATRIX_MODES][LL_MATRIX_STACK_DEPTH];
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index b7504b16bf..9c072bb0aa 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -515,6 +515,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba
if (tex_setup)
{
+ gGL.matrixMode(LLRender::MM_TEXTURE0);
gGL.loadIdentity();
gGL.matrixMode(LLRender::MM_MODELVIEW);
}
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 3e1d78e6df..e96e7cbe6c 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -2000,23 +2000,23 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
if (face->mTextureMatrix && vobj->mTexAnimMode)
{
U32 tex_index = gGL.getCurrentTexUnitIndex();
+
if (tex_index <= 1)
{
- gGL.matrixMode(LLRender::MM_TEXTURE);
+ gGL.matrixMode(LLRender::eMatrixMode(LLRender::MM_TEXTURE0 + tex_index));
+ gGL.pushMatrix();
gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix);
}
- else
- {
- LL_WARNS_ONCE("render") << "Cannot use tex anim of tex index " << tex_index << " ignoring!" << LL_ENDL;
- }
buff->setBuffer(data_mask);
buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);
if (tex_index <= 1)
{
- gGL.loadIdentity();
- }
+ gGL.matrixMode(LLRender::eMatrixMode(LLRender::MM_TEXTURE0 + tex_index));
+ gGL.popMatrix();
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
+ }
}
else
{
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 2a712d68e4..8a69376fe1 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -2194,7 +2194,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
- gTerrainProgram.mName = "Deferred Terrain Shader";
+ gDeferredTerrainProgram.mName = "Deferred Terrain Shader";
gDeferredTerrainProgram.mFeatures.encodesNormal = true;
gDeferredTerrainProgram.mShaderFiles.clear();
gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainV.glsl", GL_VERTEX_SHADER_ARB));
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 9f80f85750..490738d304 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4746,6 +4746,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion)
LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLRENDER);
gGLLastMatrix = NULL;
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.loadMatrix(gGLModelView);
for( S32 i = 0; i < poolp->getNumPostDeferredPasses(); i++ )