From 1d86dcd846ed5ea7734df507d15adf057cb2ebd0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 8 Jul 2019 10:10:22 -0700 Subject: SL-10625 another shot across the bow Move dynamic texture update (which does local back readback work) to just before swap which may keep the Intel driver from tripping on its own shoelaces and is also subjectively faster for bakes. --- indra/llappearance/lltexlayer.cpp | 9 +++++---- indra/newview/lldrawpool.cpp | 9 +++++++-- indra/newview/lldrawpool.h | 2 +- indra/newview/lldynamictexture.cpp | 6 ++++-- indra/newview/llviewerdisplay.cpp | 38 +++++++++++++++++--------------------- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/indra/llappearance/lltexlayer.cpp b/indra/llappearance/lltexlayer.cpp index 645274a990..239fa95a6f 100644 --- a/indra/llappearance/lltexlayer.cpp +++ b/indra/llappearance/lltexlayer.cpp @@ -1579,9 +1579,10 @@ void LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC // GPUs tend to be very uptight about memory alignment as the DMA used to convey // said data to the card works better when well-aligned so plain old default-aligned heap mem is a no-no //new U8[width * height]; - size_t mem_size = (width * height); - size_t rem = (mem_size & 0x3F); - mem_size += rem > 0 ? (mem_size + (32 - rem)) : 0; + size_t bytes_per_pixel = 1; // unsigned byte alpha channel only... + size_t row_size = (width + 3) & ~0x3; // OpenGL 4-byte row align (even for things < 4 bpp...) + size_t pixels = (row_size * height); + size_t mem_size = pixels * bytes_per_pixel; alpha_data = (U8*)ll_aligned_malloc_32(mem_size); @@ -1590,7 +1591,7 @@ void LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC bool skip_readback = LLRender::sNsightDebugSupport; // nSight doesn't support use of glReadPixels // SL-10625 and neither does Intel in many cases - skip_readback = skip_readback || gGLManager.mIsIntel; + skip_readback = skip_readback;// || gGLManager.mIsIntel; if (!skip_readback) { diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 9c072bb0aa..b110a6a810 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -406,9 +406,9 @@ void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL t } } -void LLRenderPass::renderTexture(U32 type, U32 mask) +void LLRenderPass::renderTexture(U32 type, U32 mask, BOOL batch_textures) { - pushBatches(type, mask, TRUE); + pushBatches(type, mask, batch_textures); } void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) @@ -461,6 +461,11 @@ void LLRenderPass::applyModelMatrix(const LLDrawInfo& params) void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures) { + if (!params.mCount) + { + return; + } + applyModelMatrix(params); bool tex_setup = false; diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index df86d78a89..4eb9a4151d 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -174,7 +174,7 @@ public: virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE); virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE); virtual void renderGroups(U32 type, U32 mask, BOOL texture = TRUE); - virtual void renderTexture(U32 type, U32 mask); + virtual void renderTexture(U32 type, U32 mask, BOOL batch_textures = TRUE); }; diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index fa9a0712fa..5e283f7cd0 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -213,7 +213,7 @@ BOOL LLViewerDynamicTexture::updateAllInstances() sNumRenders = 0; if (gGLManager.mIsDisabled || LLPipeline::sMemAllocationThrottled) { - return TRUE; + return FALSE; } bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete() && !gGLManager.mIsATI; @@ -248,7 +248,7 @@ BOOL LLViewerDynamicTexture::updateAllInstances() result = TRUE; sNumRenders++; } - gGL.flush(); + //gGL.flush(); LLVertexBuffer::unbind(); dynamicTexture->postRender(result); @@ -261,6 +261,8 @@ BOOL LLViewerDynamicTexture::updateAllInstances() gPipeline.mWaterDis.flush(); } + gGL.flush(); + return ret; } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 736626debd..7101f6fbb0 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -130,9 +130,6 @@ void display_startup() gPipeline.updateGL(); - // Update images? - //gImageList.updateImages(0.01f); - // Written as branch to appease GCC which doesn't like different // pointer types across ternary ops // @@ -149,11 +146,6 @@ void display_startup() LLGLState::checkStates(); LLGLState::checkTextureChannels(); - if (frame_count++ > 1) // make sure we have rendered a frame first - { - LLViewerDynamicTexture::updateAllInstances(); - } - LLGLState::checkStates(); LLGLState::checkTextureChannels(); @@ -595,18 +587,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // Actually push all of our triangles to the screen. // - // do render-to-texture stuff here - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) - { - LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures"); - LL_RECORD_BLOCK_TIME(FTM_UPDATE_DYNAMIC_TEXTURES); - if (LLViewerDynamicTexture::updateAllInstances()) - { - gGL.setColorMask(true, true); - glClear(GL_DEPTH_BUFFER_BIT); - } - } - gViewerWindow->setup3DViewport(); gPipeline.resetFrameStats(); // Reset per-frame statistics. @@ -1037,10 +1017,26 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (!for_snapshot) { render_ui(); + } + + // do render-to-texture stuff here + if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) + { + LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures"); + LL_RECORD_BLOCK_TIME(FTM_UPDATE_DYNAMIC_TEXTURES); + if (LLViewerDynamicTexture::updateAllInstances()) + { + gGL.setColorMask(true, true); + glClear(GL_DEPTH_BUFFER_BIT); + } + } + + LLAppViewer::instance()->pingMainloopTimeout("Display:RenderUI"); + if (!for_snapshot) + { swap(); } - LLSpatialGroup::sNoDelete = FALSE; gPipeline.clearReferences(); -- cgit v1.2.3