summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunitai Linden <davep@lindenlab.com>2021-12-17 09:26:44 -0600
committerRunitai Linden <davep@lindenlab.com>2021-12-17 09:26:44 -0600
commitdd032467357a4aaf69c752c13e53122aff6c4755 (patch)
treeaf822bcc384efeb554d7de96f70f189e332f2fe7
parent828e58432981e7c256618bd293f77906abaae699 (diff)
SL-16478 Fix for octree and render batch debug display not working with rigged meshes.
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/debugSkinnedV.glsl41
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/debugV.glsl13
-rw-r--r--indra/newview/lldrawpool.cpp8
-rw-r--r--indra/newview/lldrawpool.h3
-rw-r--r--indra/newview/llspatialpartition.cpp41
-rw-r--r--indra/newview/llviewershadermgr.cpp14
-rw-r--r--indra/newview/llviewerwindow.cpp1
7 files changed, 64 insertions, 57 deletions
diff --git a/indra/newview/app_settings/shaders/class1/interface/debugSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/interface/debugSkinnedV.glsl
deleted file mode 100644
index 74f22aec4f..0000000000
--- a/indra/newview/app_settings/shaders/class1/interface/debugSkinnedV.glsl
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * @file debugSkinnedV.glsl
- *
- * $LicenseInfo:firstyear=2021&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2011, Linden Research, Inc.
- *
- * 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.
- *
- * 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.
- *
- * 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$
- */
-
-uniform mat4 projection_matrix;
-uniform mat4 modelview_matrix;
-
-mat4 getObjectSkinnedTransform();
-
-ATTRIBUTE vec3 position;
-
-void main()
-{
- mat4 mat = getObjectSkinnedTransform();
- mat = modelview_matrix * mat;
- vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
-
- gl_Position = projection_matrix*vec4(pos, 1.0);
-}
-
diff --git a/indra/newview/app_settings/shaders/class1/interface/debugV.glsl b/indra/newview/app_settings/shaders/class1/interface/debugV.glsl
index f4d704577a..153998f1d5 100644
--- a/indra/newview/app_settings/shaders/class1/interface/debugV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/debugV.glsl
@@ -27,8 +27,21 @@ uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
+#ifdef HAS_SKIN
+mat4 getObjectSkinnedTransform();
+uniform mat4 projection_matrix;
+uniform mat4 modelview_matrix;
+#endif
+
void main()
{
+#ifdef HAS_SKIN
+ mat4 mat = getObjectSkinnedTransform();
+ mat = modelview_matrix * mat;
+ vec4 pos = mat * vec4(position.xyz,1.0);
+ gl_Position = projection_matrix * pos;
+#else
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+#endif
}
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index bad0c66fb1..503ee6d08d 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -590,7 +590,13 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba
bool LLRenderPass::uploadMatrixPalette(LLDrawInfo& params)
{
// upload matrix palette to shader
- const LLVOAvatar::MatrixPaletteCache& mpc = params.mAvatar->updateSkinInfoMatrixPalette(params.mSkinInfo);
+ return uploadMatrixPalette(params.mAvatar, params.mSkinInfo);
+}
+
+//static
+bool LLRenderPass::uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo)
+{
+ const LLVOAvatar::MatrixPaletteCache& mpc = avatar->updateSkinInfoMatrixPalette(skinInfo);
U32 count = mpc.mMatrixPalette.size();
if (count == 0)
diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index 6d49b0254b..d4f30fc51a 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -37,6 +37,8 @@ class LLViewerTexture;
class LLViewerFetchedTexture;
class LLSpatialGroup;
class LLDrawInfo;
+class LLVOAvatar;
+class LLMeshSkinInfo;
class LLDrawPool
{
@@ -204,6 +206,7 @@ public:
virtual void pushRiggedMaskBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE);
virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE);
static bool uploadMatrixPalette(LLDrawInfo& params);
+ static bool uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo);
virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE);
virtual void renderRiggedGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE);
};
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 48e9f3726f..c802e62e40 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1593,10 +1593,14 @@ void renderOctree(LLSpatialGroup* group)
gGL.flush();
glLineWidth(1.f);
gGL.flush();
+
+ LLVOAvatar* lastAvatar = nullptr;
+ U64 lastMeshId = 0;
+
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
{
LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
- if(!drawable)
+ if(!drawable || drawable->getNumFaces() == 0)
{
continue;
}
@@ -1607,6 +1611,27 @@ void renderOctree(LLSpatialGroup* group)
gGL.translatef(trans.mV[0], trans.mV[1], trans.mV[2]);
}
+ LLFace* face = drawable->getFace(0);
+ bool rigged = face->isState(LLFace::RIGGED);
+ gDebugProgram.bind(rigged);
+
+ gGL.diffuseColor4f(1, 0, 0, 1);
+
+ if (rigged)
+ {
+ gGL.pushMatrix();
+ gGL.loadMatrix(gGLModelView);
+ if (lastAvatar != face->mAvatar ||
+ lastMeshId != face->mSkinInfo->mHash)
+ {
+ if (!LLRenderPass::uploadMatrixPalette(face->mAvatar, face->mSkinInfo))
+ {
+ continue;
+ }
+ lastAvatar = face->mAvatar;
+ lastMeshId = face->mSkinInfo->mHash;
+ }
+ }
for (S32 j = 0; j < drawable->getNumFaces(); j++)
{
LLFace* face = drawable->getFace(j);
@@ -1625,19 +1650,25 @@ void renderOctree(LLSpatialGroup* group)
continue;
}
- face->getVertexBuffer()->setBuffer(LLVertexBuffer::MAP_VERTEX);
+ face->getVertexBuffer()->setBuffer(LLVertexBuffer::MAP_VERTEX | (rigged ? LLVertexBuffer::MAP_WEIGHT4 : 0));
//drawBox((face->mExtents[0] + face->mExtents[1])*0.5f,
// (face->mExtents[1]-face->mExtents[0])*0.5f);
face->getVertexBuffer()->draw(LLRender::TRIANGLES, face->getIndicesCount(), face->getIndicesStart());
}
}
+ if (rigged)
+ {
+ gGL.popMatrix();
+ }
+
if (!group->getSpatialPartition()->isBridge())
{
gGL.popMatrix();
}
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ gDebugProgram.bind(); // make sure non-rigged variant is bound
gGL.diffuseColor4f(1,1,1,1);
}
}
@@ -2778,6 +2809,8 @@ void renderBatchSize(LLDrawInfo* params)
bool bind = false;
if (params->mAvatar)
{
+ gGL.pushMatrix();
+ gGL.loadMatrix(gGLModelView);
bind = true;
old_shader->mRiggedVariant->bind();
LLRenderPass::uploadMatrixPalette(*params);
@@ -2789,6 +2822,7 @@ void renderBatchSize(LLDrawInfo* params)
if (bind)
{
+ gGL.popMatrix();
old_shader->bind();
}
}
@@ -3941,7 +3975,8 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset,
{
mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset);
- mDebugColor = (rand() << 16) + rand();
+ mDebugColor = (rand() << 16) + rand();
+ ((U8*)&mDebugColor)[3] = 200;
}
LLDrawInfo::~LLDrawInfo()
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index d37e86fa5e..829e7f8add 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -3664,20 +3664,10 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
gDebugProgram.mShaderFiles.push_back(make_pair("interface/debugF.glsl", GL_FRAGMENT_SHADER_ARB));
gDebugProgram.mRiggedVariant = &gSkinnedDebugProgram;
gDebugProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE];
- success = gDebugProgram.createShader(NULL, NULL);
+ success = make_rigged_variant(gDebugProgram, gSkinnedDebugProgram);
+ success = success && gDebugProgram.createShader(NULL, NULL);
}
- if (success)
- {
- gSkinnedDebugProgram.mName = "Skinned Debug Shader";
- gSkinnedDebugProgram.mFeatures.hasObjectSkinning = true;
- gSkinnedDebugProgram.mShaderFiles.clear();
- gSkinnedDebugProgram.mShaderFiles.push_back(make_pair("interface/debugSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
- gSkinnedDebugProgram.mShaderFiles.push_back(make_pair("interface/debugF.glsl", GL_FRAGMENT_SHADER_ARB));
- gSkinnedDebugProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE];
- success = gSkinnedDebugProgram.createShader(NULL, NULL);
- }
-
if (success)
{
gClipProgram.mName = "Clip Shader";
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 46204bc642..dbb1a1eea0 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1767,6 +1767,7 @@ void LLViewerWindow::handleDataCopy(LLWindow *window, S32 data_type, void *data)
BOOL LLViewerWindow::handleTimerEvent(LLWindow *window)
{
+ //TODO: just call this every frame from gatherInput instead of using a convoluted 30fps timer callback
if (LLViewerJoystick::getInstance()->getOverrideCamera())
{
LLViewerJoystick::getInstance()->updateStatus();