From 14f6bbadef2c39e58a3b54c0c6212949acf50e45 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 8 Aug 2011 15:29:23 -0500 Subject: SH-2242 Work in progress migrating to glVertexAttrib everywhere --- indra/newview/llfloatermodelpreview.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index ab6753b4be..9f9bbee4b5 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -4826,7 +4826,7 @@ BOOL LLModelPreview::render() if (textures) { - glColor4fv(instance.mMaterial[i].mDiffuseColor.mV); + gGL.diffuseColor4fv(instance.mMaterial[i].mDiffuseColor.mV); if (i < instance.mMaterial.size() && instance.mMaterial[i].mDiffuseMap.notNull()) { if (instance.mMaterial[i].mDiffuseMap->getDiscardLevel() > -1) @@ -4838,12 +4838,12 @@ BOOL LLModelPreview::render() } else { - glColor4f(1,1,1,1); + gGL.diffuseColor4f(1,1,1,1); } buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - glColor3f(0.4f, 0.4f, 0.4f); + gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); if (edges) { @@ -4945,11 +4945,11 @@ BOOL LLModelPreview::render() buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - glColor4f(0.4f, 0.4f, 0.0f, 0.4f); + gGL.diffuseColor4f(0.4f, 0.4f, 0.0f, 0.4f); buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); - glColor3f(1.f, 1.f, 0.f); + gGL.diffuseColor3f(1.f, 1.f, 0.f); glLineWidth(2.f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -4969,7 +4969,7 @@ BOOL LLModelPreview::render() //show degenerate triangles LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); LLGLDisable cull(GL_CULL_FACE); - glColor4f(1.f,0.f,0.f,1.f); + gGL.diffuseColor4f(1.f,0.f,0.f,1.f); const LLVector4a scale(0.5f); for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) @@ -5133,10 +5133,10 @@ BOOL LLModelPreview::render() } buffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0); - glColor4fv(instance.mMaterial[i].mDiffuseColor.mV); + gGL.diffuseColor4fv(instance.mMaterial[i].mDiffuseColor.mV); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); - glColor3f(0.4f, 0.4f, 0.4f); + gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); if (edges) { -- cgit v1.2.3 From 2ee815478043c4d5845f094f744a055707dba0e0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 10 Aug 2011 13:01:14 -0500 Subject: SH-2238, SH-2223, SH-SH-2242 glVertexAttrib throughout main render pipeline complete, preview renders and debug displays still pending. Also fixed a render glitch and a crash (JIRAs listed). --- indra/newview/llfloatermodelpreview.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 3286408f21..b9838f7da2 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3623,6 +3623,15 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim LLVertexBuffer::unbind(); + bool no_ff = LLGLSLShader::sNoFixedFunction; + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + LLGLSLShader::sNoFixedFunction = false; + + if (shader) + { + shader->unbind(); + } + stop_gloderror(); static U32 cur_name = 1; @@ -4003,6 +4012,13 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim mResourceCost = calcResourceCost(); + LLVertexBuffer::unbind(); + LLGLSLShader::sNoFixedFunction = no_ff; + if (shader) + { + shader->bind(); + } + /*if (which_lod == -1 && mScene[LLModel::LOD_PHYSICS].empty()) { //build physics scene mScene[LLModel::LOD_PHYSICS] = mScene[LLModel::LOD_LOW]; @@ -4950,7 +4966,7 @@ BOOL LLModelPreview::render() llassert(binding == model->mMaterialList[i]); - gGL.diffuseColor4fv(instance.mMaterial[i].mDiffuseColor.mV); + gGL.diffuseColor4fv(material.mDiffuseColor.mV); if (material.mDiffuseMap.notNull()) { @@ -5261,7 +5277,7 @@ BOOL LLModelPreview::render() const LLImportMaterial& material = instance.mMaterial[binding]; buffer->setBuffer(type_mask & buffer->getTypeMask()); - gGL.diffuseColor4fv(instance.mMaterial[i].mDiffuseColor.mV); + gGL.diffuseColor4fv(material.mDiffuseColor.mV); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); -- cgit v1.2.3 From 7c95af74f195c9ec4ebc0fc0264d98cd4a85be49 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 14 Sep 2011 16:30:45 -0500 Subject: SH-2243 work in progress -- application side matrix stack management --- indra/newview/llfloatermodelpreview.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 6817f1e2c8..6412a573f5 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -4746,23 +4746,23 @@ BOOL LLModelPreview::render() { //clear background to blue - glMatrixMode(GL_PROJECTION); + gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); - glLoadIdentity(); - glOrtho(0.0f, width, 0.0f, height, -1.0f, 1.0f); + gGL.loadIdentity(); + gGL.ortho(0.0f, width, 0.0f, height, -1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - glLoadIdentity(); + gGL.loadIdentity(); gGL.color4f(0.169f, 0.169f, 0.169f, 1.f); gl_rect_2d_simple( width, height ); - glMatrixMode(GL_PROJECTION); + gGL.matrixMode(LLRender::MM_PROJECTION); gGL.popMatrix(); - glMatrixMode(GL_MODELVIEW); + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); } @@ -4872,7 +4872,7 @@ BOOL LLModelPreview::render() refresh(); } - glLoadIdentity(); + gGL.loadIdentity(); gPipeline.enableLightsPreview(); LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * @@ -4951,7 +4951,7 @@ BOOL LLModelPreview::render() gGL.pushMatrix(); LLMatrix4 mat = instance.mTransform; - glMultMatrixf((GLfloat*) mat.mMatrix); + gGL.multMatrix((GLfloat*) mat.mMatrix); for (U32 i = 0; i < mVertexBuffer[mPreviewLOD][model].size(); ++i) { @@ -5018,7 +5018,7 @@ BOOL LLModelPreview::render() gGL.pushMatrix(); LLMatrix4 mat = instance.mTransform; - glMultMatrixf((GLfloat*) mat.mMatrix); + gGL.multMatrix((GLfloat*) mat.mMatrix); bool render_mesh = true; @@ -5127,7 +5127,7 @@ BOOL LLModelPreview::render() gGL.pushMatrix(); LLMatrix4 mat = instance.mTransform; - glMultMatrixf((GLfloat*) mat.mMatrix); + gGL.multMatrix((GLfloat*) mat.mMatrix); LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; -- cgit v1.2.3 From 9ea41c8094695365bc7ea10165ffd54cda204e88 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 20 Sep 2011 00:54:37 -0500 Subject: SH-2243 No deprecated calls for the whole session. --- indra/newview/llfloatermodelpreview.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 6412a573f5..4e06fb434a 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -102,6 +102,7 @@ #include "llviewerobjectlist.h" #include "llanimationstates.h" #include "llviewernetwork.h" +#include "llviewershadermgr.h" #include "glod/glod.h" #include @@ -4729,6 +4730,8 @@ BOOL LLModelPreview::render() LLMutexLock lock(this); mNeedsUpdate = FALSE; + bool use_shaders = LLGLSLShader::sNoFixedFunction; + bool edges = mViewOption["show_edges"]; bool joint_positions = mViewOption["show_joint_positions"]; bool skin_weight = mViewOption["show_skin_weight"]; @@ -4745,6 +4748,10 @@ BOOL LLModelPreview::render() LLGLDisable fog(GL_FOG); { + if (use_shaders) + { + gUIProgram.bind(); + } //clear background to blue gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); @@ -4764,6 +4771,10 @@ BOOL LLModelPreview::render() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); + if (use_shaders) + { + gUIProgram.unbind(); + } } LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance; @@ -4895,6 +4906,11 @@ BOOL LLModelPreview::render() const U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; + if (use_shaders) + { + gObjectPreviewProgram.bind(); + } + LLGLEnable normalize(GL_NORMALIZE); if (!mBaseModel.empty() && mVertexBuffer[5].empty()) @@ -5297,6 +5313,11 @@ BOOL LLModelPreview::render() } } + if (use_shaders) + { + gObjectPreviewProgram.unbind(); + } + gGL.popMatrix(); return TRUE; -- cgit v1.2.3 From cffcb414f57bcdc7de862d791f8f9c1fea91a7fb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Oct 2011 17:44:57 -0500 Subject: SH-2488 Fix for shiny and alpha not interacting well on rigged attachments (and fix for assertion when rendering model import preview) --- indra/newview/llfloatermodelpreview.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 2a834ea11f..d9ce72a2c2 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -5409,7 +5409,16 @@ BOOL LLModelPreview::render() if (joint_positions) { + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + if (shader) + { + gDebugProgram.bind(); + } getPreviewAvatar()->renderCollisionVolumes(); + if (shader) + { + shader->bind(); + } } for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter) -- cgit v1.2.3 From 7b6723d1e0158d5dc326266a0332e87f634f9755 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 13 Oct 2011 01:19:45 -0500 Subject: SH-1650 Mitigate memory fragmentation by holding onto and reusing VBOs --- indra/newview/llfloatermodelpreview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index d9ce72a2c2..8f6013f2d9 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -5457,7 +5457,7 @@ BOOL LLModelPreview::render() } } - for (U32 j = 0; j < buffer->getRequestedVerts(); ++j) + for (U32 j = 0; j < buffer->getNumVerts(); ++j) { LLMatrix4 final_mat; final_mat.mMatrix[0][0] = final_mat.mMatrix[1][1] = final_mat.mMatrix[2][2] = final_mat.mMatrix[3][3] = 0.f; -- cgit v1.2.3