Fixed transient vertex buffer when vertex layout allocation fails.

This commit is contained in:
Бранимир Караџић
2021-09-16 18:32:58 -07:00
parent 1a001a67db
commit 227ea05dee
2 changed files with 38 additions and 37 deletions

View File

@@ -4236,7 +4236,14 @@ namespace bgfx
BX_ASSERT(0 < _num, "Requesting 0 vertices.");
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
s_ctx->allocTransientVertexBuffer(_tvb, _num, _layout);
VertexLayoutHandle layoutHandle;
{
BGFX_MUTEX_SCOPE(s_ctx->m_resourceApiLock);
layoutHandle = s_ctx->findOrCreateVertexLayout(_layout, true);
}
BX_ASSERT(isValid(layoutHandle), "Failed to allocate vertex layout handle (BGFX_CONFIG_MAX_VERTEX_LAYOUTS, max: %d).", BGFX_CONFIG_MAX_VERTEX_LAYOUTS);
s_ctx->allocTransientVertexBuffer(_tvb, _num, layoutHandle, _layout.m_stride);
BX_ASSERT(_num == _tvb->size / _layout.m_stride
, "Failed to allocate transient vertex buffer (requested %d, available %d). "