diff options
author | Dave Parks <davep@lindenlab.com> | 2023-01-09 13:05:32 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2023-01-09 13:05:32 -0600 |
commit | b3fc82ff1da0c869f0b1dd841647a120a1ae56af (patch) | |
tree | 165ef606a17cb1263bc7aaa61065ed5e39b4f3b6 /indra/newview | |
parent | 9add99b31aabf00af78cb4b999c3cbbff1a36847 (diff) |
SL-18869 Optimizations -- decruftify LLVertexBuffer and make an optimal "renderShadowSimple" utility function for pushing vertex buffers only.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/pipeline.cpp | 73 | ||||
-rw-r--r-- | indra/newview/pipeline.h | 2 |
2 files changed, 70 insertions, 5 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4edc092271..10c271cddc 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7396,6 +7396,49 @@ void LLPipeline::renderObjects(U32 type, U32 mask, bool texture, bool batch_text gGLLastMatrix = NULL; } +void LLPipeline::renderShadowSimple(U32 type) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + assertInitialized(); + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; + + LLVertexBuffer* last_vb = nullptr; + + LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); + LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); + + for (LLCullResult::drawinfo_iterator i = begin; i != end; ) + { + LLDrawInfo& params = **i; + + ++i; + + if (i != end) + { + _mm_prefetch((char*) (*i)->mVertexBuffer.get(), _MM_HINT_NTA); + + auto* ni = i + 1; + if (ni != end) + { + _mm_prefetch((char*)*ni, _MM_HINT_NTA); + } + } + + LLVertexBuffer* vb = params.mVertexBuffer; + if (vb != last_vb) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("push shadow simple"); + mSimplePool->applyModelMatrix(params); + vb->setBufferFast(LLVertexBuffer::MAP_VERTEX); + vb->drawRangeFast(LLRender::TRIANGLES, 0, vb->getNumVerts()-1, vb->getNumIndices(), 0); + vb = last_vb; + } + } + gGL.loadMatrix(gGLModelView); + gGLLastMatrix = NULL; +} + void LLPipeline::renderAlphaObjects(U32 mask, bool texture, bool batch_texture, bool rigged) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -9561,8 +9604,16 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLEnvironment& environment = LLEnvironment::instance(); - LLVertexBuffer::unbind(); + struct CompareVertexBuffer + { + bool operator()(const LLDrawInfo* const& lhs, const LLDrawInfo* const& rhs) + { + return lhs->mVertexBuffer > rhs->mVertexBuffer; + } + }; + + LLVertexBuffer::unbind(); for (int j = 0; j < 2; ++j) // 0 -- static, 1 -- rigged { bool rigged = j == 1; @@ -9589,17 +9640,29 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow simple"); //LL_RECORD_BLOCK_TIME(FTM_SHADOW_SIMPLE); LL_PROFILE_GPU_ZONE("shadow simple"); gGL.getTexUnit(0)->disable(); - for (U32 i = 0; i < sizeof(types) / sizeof(U32); ++i) + + for (U32 type : types) { - renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE, FALSE, rigged); + if (rigged) + { + renderObjects(type, LLVertexBuffer::MAP_VERTEX, FALSE, FALSE, rigged); + } + else + { + //{ sort should not be necessary because each entry in sCull should already + // be sorted by vertex buffer + // LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("sort shadow simple"); + // std::sort(sCull->beginRenderMap(type), sCull->endRenderMap(type), CompareVertexBuffer()); + //} + renderShadowSimple(type); + } } + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); if (!use_shader) { gOcclusionProgram.unbind(); } - - } if (use_shader) diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index bac68cfff0..c698374c8b 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -272,6 +272,8 @@ public: void forAllVisibleDrawables(void (*func)(LLDrawable*)); void renderObjects(U32 type, U32 mask, bool texture = true, bool batch_texture = false, bool rigged = false); + void renderShadowSimple(U32 type); + void renderAlphaObjects(U32 mask, bool texture = true, bool batch_texture = false, bool rigged = false); void renderMaskedObjects(U32 type, U32 mask, bool texture = true, bool batch_texture = false, bool rigged = false); void renderFullbrightMaskedObjects(U32 type, U32 mask, bool texture = true, bool batch_texture = false, bool rigged = false); |