diff options
author | simon@lindenlab.com <simon@lindenlab.com> | 2011-06-21 09:36:31 -0700 |
---|---|---|
committer | simon@lindenlab.com <simon@lindenlab.com> | 2011-06-21 09:36:31 -0700 |
commit | d11cabc4898a7a1995ed7c89d2cdac46dfcf24ec (patch) | |
tree | 9f8e5e57d4ed074e148227c56556bcace90e2e3a /indra/newview/lldrawpoolalpha.cpp | |
parent | c0c0a2b9a5f41fc06619330a81c34955a39ddfe2 (diff) | |
parent | ede3b577d8cebd5065514bb485e2cbd93dd5b05a (diff) |
Merge with latest lindenlab/viewer-development
Diffstat (limited to 'indra/newview/lldrawpoolalpha.cpp')
-rw-r--r-- | indra/newview/lldrawpoolalpha.cpp | 158 |
1 files changed, 75 insertions, 83 deletions
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 8b5a2ce781..8d46133912 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -124,7 +124,10 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) if (pass == 0) { simple_shader = &gDeferredAlphaProgram; - fullbright_shader = &gDeferredFullbrightProgram; + fullbright_shader = &gObjectFullbrightProgram; + + //prime simple shader (loads shadow relevant uniforms) + gPipeline.bindDeferredShader(*simple_shader); } else { @@ -228,13 +231,13 @@ void LLDrawPoolAlpha::render(S32 pass) if (!LLPipeline::sRenderDeferred) { simple_shader->bind(); - pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); + pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } if (fullbright_shader) { fullbright_shader->bind(); } - pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); + pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); LLGLSLShader::bindNoShader(); } else @@ -273,7 +276,14 @@ void LLDrawPoolAlpha::render(S32 pass) } } - renderAlpha(getVertexDataMask()); + if (mVertexShaderLevel > 0) + { + renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX); + } + else + { + renderAlpha(getVertexDataMask()); + } gGL.setColorMask(true, false); @@ -283,11 +293,6 @@ void LLDrawPoolAlpha::render(S32 pass) gGL.setSceneBlendType(LLRender::BT_ALPHA); } - if (deferred_render && current_shader != NULL) - { - gPipeline.unbindDeferredShader(*current_shader); - } - if (sShowDebugAlpha) { if(gPipeline.canUseWindLightShaders()) @@ -339,12 +344,9 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) { BOOL initialized_lighting = FALSE; BOOL light_enabled = TRUE; - S32 diffuse_channel = 0; - - BOOL use_shaders = (LLPipeline::sUnderWaterRender && gPipeline.canUseVertexShaders()) - || gPipeline.canUseWindLightShadersOnObjects(); - + BOOL use_shaders = gPipeline.canUseVertexShaders(); + for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i) { LLSpatialGroup* group = *i; @@ -368,92 +370,89 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) LLRenderPass::applyModelMatrix(params); + + if (params.mFullbright) { - if (params.mFullbright) - { - // Turn off lighting if it hasn't already been so. - if (light_enabled || !initialized_lighting) - { - initialized_lighting = TRUE; - if (use_shaders) - { - target_shader = fullbright_shader; - } - else - { - gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); - } - light_enabled = FALSE; - } - } - // Turn on lighting if it isn't already. - else if (!light_enabled || !initialized_lighting) + // Turn off lighting if it hasn't already been so. + if (light_enabled || !initialized_lighting) { initialized_lighting = TRUE; if (use_shaders) { - target_shader = simple_shader; + target_shader = fullbright_shader; } else { - gPipeline.enableLightsDynamic(); + gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); } - light_enabled = TRUE; + light_enabled = FALSE; } - - // If we need shaders, and we're not ALREADY using the proper shader, then bind it - // (this way we won't rebind shaders unnecessarily). - if(use_shaders && (current_shader != target_shader)) + } + // Turn on lighting if it isn't already. + else if (!light_enabled || !initialized_lighting) + { + initialized_lighting = TRUE; + if (use_shaders) { - llassert(target_shader != NULL); - if (deferred_render && current_shader != NULL) - { - gPipeline.unbindDeferredShader(*current_shader); - diffuse_channel = 0; - } - current_shader = target_shader; - if (deferred_render) - { - gPipeline.bindDeferredShader(*current_shader); - diffuse_channel = current_shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - } - else - { - current_shader->bind(); - } + target_shader = simple_shader; } - else if (!use_shaders && current_shader != NULL) + else { - if (deferred_render) - { - gPipeline.unbindDeferredShader(*current_shader); - diffuse_channel = 0; - } - LLGLSLShader::bindNoShader(); - current_shader = NULL; + gPipeline.enableLightsDynamic(); } + light_enabled = TRUE; + } - if (params.mGroup) - { - params.mGroup->rebuildMesh(); - } + // If we need shaders, and we're not ALREADY using the proper shader, then bind it + // (this way we won't rebind shaders unnecessarily). + if(use_shaders && (current_shader != target_shader)) + { + llassert(target_shader != NULL); + current_shader = target_shader; + current_shader->bind(); + } + else if (!use_shaders && current_shader != NULL) + { + LLGLSLShader::bindNoShader(); + current_shader = NULL; + } - - if (params.mTexture.notNull()) + if (params.mGroup) + { + params.mGroup->rebuildMesh(); + } + + bool tex_setup = false; + + if (use_shaders && params.mTextureList.size() > 1) + { + for (U32 i = 0; i < params.mTextureList.size(); ++i) { - gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get()); - if(params.mTexture.notNull()) + if (params.mTextureList[i].notNull()) { - params.mTexture->addTextureStats(params.mVSize); + gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE); } + } + } + else + { //not batching textures or batch has only 1 texture -- might need a texture matrix + if (params.mTexture.notNull()) + { + params.mTexture->addTextureStats(params.mVSize); + gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ; if (params.mTextureMatrix) { + tex_setup = true; gGL.getTexUnit(0)->activate(); glMatrixMode(GL_TEXTURE); glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); gPipeline.mTextureMatrixOps++; } } + else + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } } params.mVertexBuffer->setBuffer(mask); @@ -480,7 +479,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); } - if (params.mTextureMatrix && params.mTexture.notNull()) + if (tex_setup) { gGL.getTexUnit(0)->activate(); glLoadIdentity(); @@ -490,15 +489,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) } } - if (deferred_render && current_shader != NULL) - { - gPipeline.unbindDeferredShader(*current_shader); - LLVertexBuffer::unbind(); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); - } - + LLVertexBuffer::unbind(); + if (!light_enabled) { gPipeline.enableLightsDynamic(); |