From 54dd30cc426e16aa99b4f7eea080bbeae0656843 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 15 Apr 2010 00:04:17 -0500 Subject: More rigged attachments work. --- indra/llrender/llshadermgr.cpp | 33 +++++++++++++++++++++------------ indra/llrender/llvertexbuffer.cpp | 21 +++++++++++++++++++++ indra/newview/lldrawpoolavatar.cpp | 3 ++- indra/newview/llvoavatar.cpp | 12 +++++++++--- 4 files changed, 53 insertions(+), 16 deletions(-) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 23b76351eb..8fc7163b83 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -322,10 +322,13 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns) GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type) { GLenum error; - error = glGetError(); - if (error != GL_NO_ERROR) + if (gDebugGL) { - LL_WARNS("ShaderLoading") << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL; + error = glGetError(); + if (error != GL_NO_ERROR) + { + LL_WARNS("ShaderLoading") << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL; + } } LL_DEBUGS("ShaderLoading") << "Loading shader file: " << filename << " class " << shader_level << LL_ENDL; @@ -380,10 +383,13 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade //create shader object GLhandleARB ret = glCreateShaderObjectARB(type); - error = glGetError(); - if (error != GL_NO_ERROR) + if (gDebugGL) { - LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << LL_ENDL; + error = glGetError(); + if (error != GL_NO_ERROR) + { + LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << LL_ENDL; + } } else { @@ -415,13 +421,16 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade //check for errors GLint success = GL_TRUE; glGetObjectParameterivARB(ret, GL_OBJECT_COMPILE_STATUS_ARB, &success); - error = glGetError(); - if (error != GL_NO_ERROR || success == GL_FALSE) + if (gDebugGL) { - //an error occured, print log - LL_WARNS("ShaderLoading") << "GLSL Compilation Error: (" << error << ") in " << filename << LL_ENDL; - dumpObjectLog(ret); - ret = 0; + error = glGetError(); + if (error != GL_NO_ERROR || success == GL_FALSE) + { + //an error occured, print log + LL_WARNS("ShaderLoading") << "GLSL Compilation Error: (" << error << ") in " << filename << LL_ENDL; + dumpObjectLog(ret); + ret = 0; + } } } else diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index d5b00f27a7..668e9e55f9 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -212,6 +212,27 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) glClientActiveTextureARB(GL_TEXTURE0_ARB); } + if (sLastMask & MAP_WEIGHT4) + { + if (sWeight4Loc < 0) + { + llerrs << "Weighting disabled but vertex buffer still bound!" << llendl; + } + + if (!(data_mask & MAP_WEIGHT4)) + { //disable 4-component skin weight + glDisableVertexAttribArrayARB(sWeight4Loc); + } + } + else if (data_mask & MAP_WEIGHT4) + { + if (sWeight4Loc >= 0) + { //enable 4-component skin weight + glEnableVertexAttribArrayARB(sWeight4Loc); + } + } + + sLastMask = data_mask; } } diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index de9b71a9b8..1a2558ac5f 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -325,7 +325,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass) S32 LLDrawPoolAvatar::getNumPasses() { - return LLPipeline::sImpostorRender ? 1 : 3; + return LLPipeline::sImpostorRender ? 1 : 4; } void LLDrawPoolAvatar::render(S32 pass) @@ -588,6 +588,7 @@ void LLDrawPoolAvatar::beginRigged() void LLDrawPoolAvatar::endRigged() { sVertexProgram = NULL; + LLVertexBuffer::unbind(); gSkinnedObjectSimpleProgram.unbind(); LLVertexBuffer::sWeight4Loc = -1; } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 201c4ce1d5..8bf4c0ab96 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3728,8 +3728,8 @@ U32 LLVOAvatar::renderSkinnedAttachments() LLJoint* joint = getJoint(skin->mJointNames[i]); if (joint) { - mat[i] = skin->mInvBindMatrix[i]; - mat[i] *= joint->getWorldMatrix(); + mat[i*2+0] = skin->mInvBindMatrix[i]; + mat[i*2+1] = joint->getWorldMatrix(); } } @@ -3737,6 +3737,10 @@ U32 LLVOAvatar::renderSkinnedAttachments() skin->mJointNames.size(), FALSE, (GLfloat*) mat[0].mMatrix); + gSkinnedObjectSimpleProgram.uniformMatrix4fv("matrixPalette[0]", + skin->mJointNames.size(), + FALSE, + (GLfloat*) mat[0].mMatrix); buff->setBuffer(data_mask); @@ -3745,7 +3749,9 @@ U32 LLVOAvatar::renderSkinnedAttachments() S32 offset = face->getIndicesStart(); U32 count = face->getIndicesCount(); - buff->drawRange(LLRender::TRIANGLES, start, end, count, offset); + glPointSize(8.f); + buff->drawRange(LLRender::POINTS, start, end, count, offset); + glPointSize(1.f); } } } -- cgit v1.2.3 From b0554832e2cffac344590bf49897119e72d142cb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 15 Apr 2010 00:06:53 -0500 Subject: Quick port of fix for avatar mesh rebuilding bug from viewer-hotfix. --- indra/newview/llvoavatarself.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index c15dbeb8c6..8b87254f81 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -697,15 +697,6 @@ BOOL LLVOAvatarSelf::setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL /*virtual*/ void LLVOAvatarSelf::updateVisualParams() { - for (U32 type = 0; type < WT_COUNT; type++) - { - LLWearable *wearable = gAgentWearables.getTopWearable((EWearableType)type); - if (wearable) - { - wearable->writeToAvatar(); - } - } - LLVOAvatar::updateVisualParams(); } @@ -716,7 +707,14 @@ void LLVOAvatarSelf::idleUpdateAppearanceAnimation() gAgentWearables.animateAllWearableParams(calcMorphAmount(), FALSE); // apply wearable visual params to avatar - updateVisualParams(); + for (U32 type = 0; type < WT_COUNT; type++) + { + LLWearable *wearable = gAgentWearables.getTopWearable((EWearableType)type); + if (wearable) + { + wearable->writeToAvatar(); + } + } //allow avatar to process updates LLVOAvatar::idleUpdateAppearanceAnimation(); -- cgit v1.2.3 From 71b0a63c8df29d5d69b777306dcf6280fd98886a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 16 Apr 2010 13:00:01 -0500 Subject: Optimize LLViewerJointMesh::updateFaceData --- indra/llcommon/llstrider.h | 2 +- indra/newview/lldrawpoolavatar.cpp | 2 +- indra/newview/llviewerjointmesh.cpp | 88 +++++++++++++++++++++++++++++-------- 3 files changed, 71 insertions(+), 21 deletions(-) diff --git a/indra/llcommon/llstrider.h b/indra/llcommon/llstrider.h index 369b06b48a..44ea80a36b 100644 --- a/indra/llcommon/llstrider.h +++ b/indra/llcommon/llstrider.h @@ -51,7 +51,7 @@ public: void setStride (S32 skipBytes) { mSkip = (skipBytes ? skipBytes : sizeof(Object));} void skip(const U32 index) { mBytep += mSkip*index;} - + U32 getSkip() const { return mSkip; } Object* get() { return mObjectp; } Object* operator->() { return mObjectp; } Object& operator *() { return *mObjectp; } diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 7ab85ae3e4..b509b363b7 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -123,7 +123,7 @@ void LLDrawPoolAvatar::prerender() if (sShaderLevel > 0) { - sBufferUsage = GL_STATIC_DRAW_ARB; + sBufferUsage = GL_DYNAMIC_DRAW_ARB; } else { diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 92029d10f6..90a5a29bb4 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -661,6 +661,8 @@ void LLViewerJointMesh::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 //----------------------------------------------------------------------------- // updateFaceData() //----------------------------------------------------------------------------- +static LLFastTimer::DeclareTimer FTM_AVATAR_FACE("Avatar Face"); + void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind) { mFace = face; @@ -670,6 +672,8 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w return; } + LLFastTimer t(FTM_AVATAR_FACE); + LLStrider verticesp; LLStrider normalsp; LLStrider tex_coordsp; @@ -688,30 +692,76 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w face->mVertexBuffer->getIndexStrider(indicesp); stop_glerror(); - for (U16 i = 0; i < mMesh->getNumVertices(); i++) + verticesp += mMesh->mFaceVertexOffset; + tex_coordsp += mMesh->mFaceVertexOffset; + normalsp += mMesh->mFaceVertexOffset; + vertex_weightsp += mMesh->mFaceVertexOffset; + clothing_weightsp += mMesh->mFaceVertexOffset; + + U32* __restrict v = (U32*) verticesp.get(); + const U32 vert_skip = verticesp.getSkip()/sizeof(U32); + + U32* __restrict tc = (U32*) tex_coordsp.get(); + const U32 tc_skip = tex_coordsp.getSkip()/sizeof(U32); + + U32* __restrict n = (U32*) normalsp.get(); + const U32 n_skip = normalsp.getSkip()/sizeof(U32); + + U32* __restrict vw = (U32*) vertex_weightsp.get(); + const U32 vw_skip = vertex_weightsp.getSkip()/sizeof(U32); + + + U32* __restrict cw = (U32*) clothing_weightsp.get(); + const U32 cw_skip = vertex_weightsp.getSkip()/sizeof(U32); + + const U32* __restrict coords = (U32*) mMesh->getCoords(); + const U32* __restrict tex_coords = (U32*) mMesh->getTexCoords(); + const U32* __restrict normals = (U32*) mMesh->getNormals(); + const U32* __restrict weights = (U32*) mMesh->getWeights(); + const U32* __restrict cloth_weights = (U32*) mMesh->getClothingWeights(); + + const U32 num_verts = mMesh->getNumVertices(); + + U32 i = 0; + do { - verticesp[mMesh->mFaceVertexOffset + i] = *(mMesh->getCoords() + i); - tex_coordsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getTexCoords() + i); - normalsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getNormals() + i); - vertex_weightsp[mMesh->mFaceVertexOffset + i] = *(mMesh->getWeights() + i); - if (damp_wind) - { - clothing_weightsp[mMesh->mFaceVertexOffset + i] = LLVector4(0,0,0,0); - } - else - { - clothing_weightsp[mMesh->mFaceVertexOffset + i] = (*(mMesh->getClothingWeights() + i)); - } + v[0] = *(coords++); + v[1] = *(coords++); + v[2] = *(coords++); + v += vert_skip; + + tc[0] = *(tex_coords++); + tc[1] = *(tex_coords++); + tc += tc_skip; + + n[0] = *(normals++); + n[1] = *(normals++); + n[2] = *(normals++); + n += n_skip; + + vw[0] = *(weights++); + vw += vw_skip; + + cw[0] = *(cloth_weights++); + cw[1] = *(cloth_weights++); + cw[2] = *(cloth_weights++); + cw[3] = *(cloth_weights++); + cw += cw_skip; } + while (++i < num_verts); + + const U32 idx_count = mMesh->getNumFaces()*3; - for (S32 i = 0; i < mMesh->getNumFaces(); i++) + U16* __restrict idx = indicesp.get(); + S32* __restrict src_idx = (S32*) mMesh->getFaces(); + + i = 0; + + do { - for (U32 j = 0; j < 3; j++) - { - U32 k = i*3+j+mMesh->mFaceIndexOffset; - indicesp[k] = mMesh->getFaces()[i][j] + mMesh->mFaceVertexOffset; - } + *(idx++) = *(src_idx++); } + while (++i < idx_count); } } } -- cgit v1.2.3