summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-07-25 03:16:15 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-07-25 03:16:15 +0000
commit85a434072645c13b50e9486e54c9b7854a33c989 (patch)
tree6ecbc10de6f3e3f026405d6868786eb1141df735 /Graphics/GraphicsEngine
parentFixed another potential issue in ~DeviceContextVkImpl() (diff)
downloadDiligentCore-85a434072645c13b50e9486e54c9b7854a33c989.tar.gz
DiligentCore-85a434072645c13b50e9486e54c9b7854a33c989.zip
Fixed performance issue with resetting unchanged vertex buffers
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h
index d84956b1..aae0ef1f 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.h
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h
@@ -215,8 +215,13 @@ inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSl
if ( Flags & SET_VERTEX_BUFFERS_FLAG_RESET )
{
- for(Uint32 s=0; s < m_NumVertexStreams; ++s)
- m_VertexStreams[s] = VertexStreamInfo();
+ // Reset only these buffer slots that are not being set.
+ // It is very important to not reset buffers that stay unchanged
+ // as AddRef()/Release() are not free
+ for (Uint32 s = 0; s < StartSlot; ++s)
+ m_VertexStreams[s] = VertexStreamInfo{};
+ for (Uint32 s = StartSlot + NumBuffersSet; s < m_NumVertexStreams; ++s)
+ m_VertexStreams[s] = VertexStreamInfo{};
m_NumVertexStreams = 0;
}
m_NumVertexStreams = std::max(m_NumVertexStreams, StartSlot + NumBuffersSet );
@@ -224,7 +229,7 @@ inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSl
for( Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff )
{
auto &CurrStream = m_VertexStreams[StartSlot + Buff];
- CurrStream.pBuffer = RefCntAutoPtr<IBuffer>( ppBuffers ? ppBuffers[Buff] : nullptr );
+ CurrStream.pBuffer = ppBuffers ? ppBuffers[Buff] : nullptr;
CurrStream.Offset = pOffsets ? pOffsets[Buff] : 0;
#ifdef DEVELOPMENT
if ( CurrStream.pBuffer )
@@ -239,7 +244,7 @@ inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSl
}
// Remove null buffers from the end of the array
while(m_NumVertexStreams > 0 && !m_VertexStreams[m_NumVertexStreams-1].pBuffer)
- m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo();
+ m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo{};
}
template<typename BaseInterface>