Map/unmap vertices once per layer order update
Multiple memory map/unmap operations cause a significant delay on GPUs that fetch vertices from RAM. Fixes: lp:1701936 * https://bugs.launchpad.net/kicad/+bug/1701936
This commit is contained in:
parent
a20cce0753
commit
b5db6a7d5d
|
@ -183,6 +183,7 @@ void GPU_CACHED_MANAGER::EndDrawing()
|
|||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
|
||||
cached->ClearDirty();
|
||||
|
||||
// Deactivate vertex array
|
||||
glDisableClientState( GL_COLOR_ARRAY );
|
||||
|
|
|
@ -717,25 +717,6 @@ struct VIEW::changeItemsDepth
|
|||
};
|
||||
|
||||
|
||||
void VIEW::ChangeLayerDepth( int aLayer, int aDepth )
|
||||
{
|
||||
// There is no point in updating non-cached layers
|
||||
if( !IsCached( aLayer ) )
|
||||
return;
|
||||
|
||||
BOX2I r;
|
||||
|
||||
r.SetMaximum();
|
||||
|
||||
m_gal->BeginUpdate();
|
||||
changeItemsDepth visitor( aLayer, aDepth, m_gal );
|
||||
m_layers[aLayer].items->Query( r, visitor );
|
||||
m_gal->EndUpdate();
|
||||
|
||||
MarkTargetDirty( m_layers[aLayer].target );
|
||||
}
|
||||
|
||||
|
||||
int VIEW::GetTopLayer() const
|
||||
{
|
||||
if( m_topLayers.size() == 0 )
|
||||
|
@ -814,13 +795,20 @@ void VIEW::ClearTopLayers()
|
|||
|
||||
void VIEW::UpdateAllLayersOrder()
|
||||
{
|
||||
BOX2I r;
|
||||
r.SetMaximum();
|
||||
|
||||
sortLayers();
|
||||
m_gal->BeginUpdate();
|
||||
|
||||
for( LAYER_MAP::value_type& l : m_layers )
|
||||
{
|
||||
ChangeLayerDepth( l.first, l.second.renderingOrder );
|
||||
int layer = l.first;
|
||||
changeItemsDepth visitor( layer, l.second.renderingOrder, m_gal );
|
||||
m_layers[layer].items->Query( r, visitor );
|
||||
}
|
||||
|
||||
m_gal->EndUpdate();
|
||||
MarkDirty();
|
||||
}
|
||||
|
||||
|
|
|
@ -157,6 +157,14 @@ public:
|
|||
m_dirty = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the dirty flag to prevent reuploading vertices to the GPU memory.
|
||||
*/
|
||||
void ClearDirty()
|
||||
{
|
||||
m_dirty = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
VERTEX_CONTAINER( unsigned int aSize = DEFAULT_SIZE );
|
||||
|
||||
|
|
|
@ -469,14 +469,6 @@ public:
|
|||
*/
|
||||
void UpdateAllLayersColor();
|
||||
|
||||
/**
|
||||
* Function ChangeLayerDepth()
|
||||
* Changes the depth of items on the given layer.
|
||||
* @param aLayer is a number of the layer to be updated.
|
||||
* @param aDepth is the new depth.
|
||||
*/
|
||||
void ChangeLayerDepth( int aLayer, int aDepth );
|
||||
|
||||
/**
|
||||
* Function SetTopLayer()
|
||||
* Sets given layer to be displayed on the top or sets back the default order of layers.
|
||||
|
|
Loading…
Reference in New Issue