diff options
author | Dave Parks <davep@lindenlab.com> | 2011-08-27 00:38:53 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-08-27 00:38:53 -0500 |
commit | 7821ff23baafff4e7712a126c17c3947e7b4989e (patch) | |
tree | 06702d7c7787c5003c1d50953dd08b07a899210d /indra | |
parent | bf0d36bf889bb913fbc2a53c5a1b9818acb11ee6 (diff) |
SH-2242 Physics shape display works again, added asserts to flush out areas where state being consumed by a shader does not match state being provided by vertex buffers.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llrender/llrender.cpp | 54 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 50 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl | 4 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/interface/highlightF.glsl | 4 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/objects/bumpV.glsl | 2 | ||||
-rw-r--r-- | indra/newview/lldrawpoolalpha.cpp | 3 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llselectmgr.cpp | 12 | ||||
-rw-r--r-- | indra/newview/llspatialpartition.cpp | 19 | ||||
-rw-r--r-- | indra/newview/llviewerdisplay.cpp | 12 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 2 |
11 files changed, 89 insertions, 77 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 03a45c35dc..ea398c61de 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1583,15 +1583,11 @@ void LLRender::color3fv(const GLfloat* c) void LLRender::diffuseColor3f(F32 r, F32 g, F32 b) { LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; - S32 loc = -1; - if (shader) - { - loc = shader->getUniformLocation("color"); - } + llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL); - if (loc >= 0) + if (shader) { - shader->uniform4f(loc, r,g,b,1.f); + shader->uniform4f("color", r,g,b,1.f); } else { @@ -1602,15 +1598,11 @@ void LLRender::diffuseColor3f(F32 r, F32 g, F32 b) void LLRender::diffuseColor3fv(const F32* c) { LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; - S32 loc = -1; - if (shader) - { - loc = shader->getUniformLocation("color"); - } + llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL); - if (loc >= 0) + if (shader) { - shader->uniform4f(loc, c[0], c[1], c[2], 1.f); + shader->uniform4f("color", c[0], c[1], c[2], 1.f); } else { @@ -1621,35 +1613,26 @@ void LLRender::diffuseColor3fv(const F32* c) void LLRender::diffuseColor4f(F32 r, F32 g, F32 b, F32 a) { LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; - S32 loc = -1; - if (shader) - { - loc = shader->getUniformLocation("color"); - } + llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL); - if (loc >= 0) + if (shader) { - shader->uniform4f(loc, r,g,b,a); + shader->uniform4f("color", r,g,b,a); } else { glColor4f(r,g,b,a); } - } void LLRender::diffuseColor4fv(const F32* c) { LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; - S32 loc = -1; - if (shader) - { - loc = shader->getUniformLocation("color"); - } + llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL); - if (loc >= 0) + if (shader) { - shader->uniform4fv(loc, 1, c); + shader->uniform4fv("color", 1, c); } else { @@ -1660,15 +1643,11 @@ void LLRender::diffuseColor4fv(const F32* c) void LLRender::diffuseColor4ubv(const U8* c) { LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; - S32 loc = -1; - if (shader) - { - loc = shader->getUniformLocation("color"); - } + llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL); - if (loc >= 0) + if (shader) { - shader->uniform4f(loc, c[0]/255.f, c[1]/255.f, c[2]/255.f, c[3]/255.f); + shader->uniform4f("color", c[0]/255.f, c[1]/255.f, c[2]/255.f, c[3]/255.f); } else { @@ -1676,9 +1655,6 @@ void LLRender::diffuseColor4ubv(const U8* c) } } - - - void LLRender::debugTexUnits(void) { LL_INFOS("TextureUnit") << "Active TexUnit: " << mCurrTextureUnitIndex << LL_ENDL; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 5d19168842..86352215ff 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -364,8 +364,26 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, con setupClientArrays(MAP_VERTEX | MAP_NORMAL); - glVertexPointer(3, GL_FLOAT, 0, pos[0].mV); - glNormalPointer(GL_FLOAT, 0, norm[0].mV); + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + + if (shader) + { + S32 loc = shader->getAttribLocation(LLVertexBuffer::TYPE_VERTEX); + if (loc > -1) + { + glVertexAttribPointerARB(loc, 3, GL_FLOAT, GL_FALSE, 0, pos[0].mV); + } + loc = shader->getAttribLocation(LLVertexBuffer::TYPE_NORMAL); + if (loc > -1) + { + glVertexAttribPointerARB(loc, 3, GL_FLOAT, GL_FALSE, 0, norm[0].mV); + } + } + else + { + glVertexPointer(3, GL_FLOAT, 0, pos[0].mV); + glNormalPointer(GL_FLOAT, 0, norm[0].mV); + } glDrawArrays(sGLMode[mode], 0, count); } @@ -1730,6 +1748,34 @@ void LLVertexBuffer::setBuffer(U32 data_mask, S32 type) //set up pointers if the data mask is different ... BOOL setup = (sLastMask != data_mask); + if (gDebugGL && data_mask != 0) + { + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + if (shader) + { + U32 required_mask = 0; + for (U32 i = 0; i < LLVertexBuffer::TYPE_MAX; ++i) + { + if (shader->getAttribLocation(i) > -1) + { + U32 required = 1 << i; + if ((data_mask & required) == 0) + { + llwarns << "Missing attribute: " << i << llendl; + } + + required_mask |= required; + + } + } + + if ((data_mask & required_mask) != required_mask) + { + llerrs << "Shader consumption mismatches data provision." << llendl; + } + } + } + if (useVBOs()) { if (mGLBuffer && (mGLBuffer != sGLRenderBuffer || !sVBOActive)) diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl index 99ddeaf0b9..b724def93d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl @@ -27,7 +27,7 @@ attribute vec3 position; attribute vec4 diffuse_color; attribute vec3 normal; attribute vec2 texcoord0; -attribute vec2 texcoord2; +attribute vec3 binormal; varying vec3 vary_mat0; varying vec3 vary_mat1; @@ -40,7 +40,7 @@ void main() gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); vec3 n = normalize(gl_NormalMatrix * normal); - vec3 b = normalize(gl_NormalMatrix * vec4(texcoord2,0,1).xyz); + vec3 b = normalize(gl_NormalMatrix * binormal); vec3 t = cross(b, n); vary_mat0 = vec3(t.x, b.x, n.x); diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl index 4c0455502f..3a48205101 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl @@ -24,10 +24,10 @@ */ -uniform vec4 highlight_color; +uniform vec4 color; uniform sampler2D diffuseMap; void main() { - gl_FragColor = highlight_color*texture2D(diffuseMap, gl_TexCoord[0].xy); + gl_FragColor = color*texture2D(diffuseMap, gl_TexCoord[0].xy); } diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl index bb6f0aa5e8..7d38e07d65 100644 --- a/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl @@ -25,7 +25,6 @@ attribute vec3 position; -attribute vec4 diffuse_color; attribute vec2 texcoord0; attribute vec2 texcoord1; @@ -35,5 +34,4 @@ void main() gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0); gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1); gl_TexCoord[1] = gl_TextureMatrix[1] * vec4(texcoord1,0,1); - gl_FrontColor = diffuse_color; } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index a3f8eb377a..1e04cd9c17 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -322,13 +322,12 @@ void LLDrawPoolAlpha::render(S32 pass) if(shaders) { gHighlightProgram.bind(); - gHighlightProgram.uniform4f("highlight_color", 1,0,0,1); } else { gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); - gGL.diffuseColor4f(1,0,0,1); } + gGL.diffuseColor4f(1,0,0,1); LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sSmokeImagep, TRUE) ; diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index e4de92490e..852de39781 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -269,7 +269,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() { if (gPipeline.canUseVertexShaders()) { - gUIProgram.bind(); + gHighlightProgram.bind(); } // *NOTE: even though we already bound this texture above for the // stars register combiners, we bind again here for defensive reasons, @@ -289,7 +289,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() if (gPipeline.canUseVertexShaders()) { - gUIProgram.unbind(); + gHighlightProgram.unbind(); } } } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 568c967a9a..48cccc12ef 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -5637,7 +5637,7 @@ void LLSelectNode::renderOneWireframe(const LLColor4& color) LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL); if (shader) { - gHighlightProgram.uniform4f("highlight_color", color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f); + gGL.diffuseColor4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f); pushWireframe(drawable); } else @@ -5661,14 +5661,8 @@ void LLSelectNode::renderOneWireframe(const LLColor4& color) gGL.flush(); gGL.setSceneBlendType(LLRender::BT_ALPHA); - if (shader) - { - gHighlightProgram.uniform4f("highlight_color", color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2); - } - else - { - gGL.diffuseColor4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2); - } + gGL.diffuseColor4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2); + LLGLEnable offset(GL_POLYGON_OFFSET_LINE); glPolygonOffset(3.f, 3.f); glLineWidth(3.f); diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 78b2db2bde..e0c3b43110 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2944,7 +2944,7 @@ void renderMeshBaseHull(LLVOVolume* volume, U32 data_mask, LLColor4& color, LLCo else { gMeshRepo.buildPhysicsMesh(*decomp); - gGL.color3f(0,1,1); + gGL.diffuseColor4f(0,1,1,1); drawBoxOutline(center, size); } @@ -3078,7 +3078,6 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) { renderMeshBaseHull(volume, data_mask, color, line_color); } -#if LL_WINDOWS else { LLVolumeParams volume_params = volume->getVolume()->getParams(); @@ -3190,13 +3189,12 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) } else { - gGL.color3f(1,0,1); + gGL.diffuseColor4f(1,0,1,1); drawBoxOutline(center, size); } LLPrimitive::sVolumeManager->unrefVolume(phys_volume); } -#endif //LL_WINDOWS } else if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::BOX) { @@ -3210,7 +3208,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) } else if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::SPHERE) { - LLVolumeParams volume_params; + /*LLVolumeParams volume_params; volume_params.setType( LL_PCODE_PROFILE_CIRCLE_HALF, LL_PCODE_PATH_CIRCLE ); volume_params.setBeginAndEndS( 0.f, 1.f ); volume_params.setBeginAndEndT( 0.f, 1.f ); @@ -3220,7 +3218,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) gGL.diffuseColor4fv(color.mV); pushVerts(sphere); - LLPrimitive::sVolumeManager->unrefVolume(sphere); + LLPrimitive::sVolumeManager->unrefVolume(sphere);*/ } else if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::CYLINDER) { @@ -3290,15 +3288,6 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) } gGL.popMatrix(); - - /*{ //analytical shape, just push visual rep. - gGL.diffuseColor3fv(color.mV); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - pushVerts(drawable, data_mask); - gGL.diffuseColor4fv(color.mV); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - pushVerts(drawable, data_mask); - }*/ } void renderPhysicsShapes(LLSpatialGroup* group) diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 39053fe9e4..eeb33ea5d2 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -719,6 +719,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); gPipeline.generateHighlight(*LLViewerCamera::getInstance()); + gPipeline.renderPhysicsDisplay(); } LLGLState::checkStates(); @@ -1454,6 +1455,11 @@ void render_ui_2d() void render_disconnected_background() { + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + gGL.color4f(1,1,1,1); if (!gDisconnectedImagep && gDisconnected) { @@ -1523,6 +1529,12 @@ void render_disconnected_background() glPopMatrix(); } gGL.flush(); + + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } + } void display_cleanup() diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 27672a05cb..8d5bc22e6f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4480,8 +4480,6 @@ void LLPipeline::renderDebug() { gUIProgram.unbind(); } - - gPipeline.renderPhysicsDisplay(); } void LLPipeline::rebuildPools() |