Vulkan: Fix crash where a potentially deleted buffer is referenced

This happened when the geometry shader was disabled, and the uniform
buffer was grown to a larger size. The update would be skipped, leaving
the old buffer to be included in the descriptor set.
This commit is contained in:
Stenzek 2016-12-19 22:00:42 +10:00
parent 989cdc0929
commit 9290bf5844
1 changed files with 13 additions and 3 deletions

View File

@ -384,12 +384,22 @@ void StateTracker::UpdateVertexShaderConstants()
void StateTracker::UpdateGeometryShaderConstants() void StateTracker::UpdateGeometryShaderConstants()
{ {
// Skip updating geometry shader constants if it's not in use. // Skip updating geometry shader constants if it's not in use.
if (m_pipeline_state.gs == VK_NULL_HANDLE || !GeometryShaderManager::dirty || if (m_pipeline_state.gs == VK_NULL_HANDLE)
!ReserveConstantStorage())
{ {
return; // However, if the buffer has changed, we can't skip the update, because then we'll
// try to include the now non-existant buffer in the descriptor set.
if (m_uniform_stream_buffer->GetBuffer() ==
m_bindings.uniform_buffer_bindings[UBO_DESCRIPTOR_SET_BINDING_GS].buffer)
{
return;
}
GeometryShaderManager::dirty = true;
} }
if (!GeometryShaderManager::dirty || !ReserveConstantStorage())
return;
// Buffer allocation changed? // Buffer allocation changed?
if (m_uniform_stream_buffer->GetBuffer() != if (m_uniform_stream_buffer->GetBuffer() !=
m_bindings.uniform_buffer_bindings[UBO_DESCRIPTOR_SET_BINDING_GS].buffer) m_bindings.uniform_buffer_bindings[UBO_DESCRIPTOR_SET_BINDING_GS].buffer)