Update nanovg_bgfx.cpp (#2823)

Fix the transient vertex buffer's overflow assert being fired. Now if the tvb is overflowed a warning is emitted and the draw is skipped
This commit is contained in:
SnapperTT 2022-06-20 21:37:59 +10:00 committed by GitHub
parent 6d65944eda
commit 498d0b6e54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -762,12 +762,21 @@ namespace
if (gl->ncalls > 0)
{
int avail = bgfx::getAvailTransientVertexBuffer(gl->nverts, s_nvgLayout);
if (avail < gl->nverts)
{
gl->nverts = avail;
BX_WARN(true, "Vertex number truncated due to transient vertex buffer overflow");
if (gl->nverts < 2)
goto _cleanup;
}
bgfx::allocTransientVertexBuffer(&gl->tvb, gl->nverts, s_nvgLayout);
int allocated = gl->tvb.size/gl->tvb.stride;
if (allocated < gl->nverts)
{
// this branch should never be taken as we've already checked the transient vertex buffer size
gl->nverts = allocated;
BX_WARN(true, "Vertex number truncated due to transient vertex buffer overflow");
}
@ -806,6 +815,7 @@ namespace
}
// Reset calls
_cleanup:
gl->nverts = 0;
gl->npaths = 0;
gl->ncalls = 0;