From 73a3b880a6bd45bd4dbcd58b18a46f4dd6a43ba7 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Wed, 12 Jun 2024 16:04:44 +0300 Subject: [PATCH] Slightly optimize GPU_CACHED_MANAGER::DrawIndices. --- common/gal/opengl/gpu_manager.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/common/gal/opengl/gpu_manager.cpp b/common/gal/opengl/gpu_manager.cpp index 32e112bb56..1078c75b30 100644 --- a/common/gal/opengl/gpu_manager.cpp +++ b/common/gal/opengl/gpu_manager.cpp @@ -113,26 +113,30 @@ void GPU_CACHED_MANAGER::BeginDrawing() } -void GPU_CACHED_MANAGER::DrawIndices( const VERTEX_ITEM *aItem ) +void GPU_CACHED_MANAGER::DrawIndices( const VERTEX_ITEM* aItem ) { - wxASSERT( m_isDrawing ); + // Hot path: don't use wxASSERT + assert( m_isDrawing ); unsigned int offset = aItem->GetOffset(); unsigned int size = aItem->GetSize(); - if( size > 1000 ) + if( size == 0 ) + return; + + if( size <= 1000 ) + { + m_totalNormal += size; + m_vranges.emplace_back( offset, offset + size - 1, false ); + m_curVrangeSize += size; + } + else { m_totalHuge += size; m_vranges.emplace_back( offset, offset + size - 1, true ); m_indexBufSize = std::max( m_curVrangeSize, m_indexBufSize ); m_curVrangeSize = 0; } - else if ( size > 0 ) - { - m_totalNormal += size; - m_vranges.emplace_back( offset, offset + size - 1, false ); - m_curVrangeSize += size; - } }