aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2020-04-05 15:36:32 +0200
committerAndre Weissflog <floooh@gmail.com>2020-04-05 15:41:43 +0200
commite5ca86fd18ad2548ebc3687791016bbdebba297f (patch)
treed52437940a8080973a95b8163be458a2ecc3074a /util
parenta662517e772d30b0889d68d83e7ec7cb395d89be (diff)
sokol_gl.h: fix subtle bug in the "merge draw call optimization"
The bug might have happened when no vertices were recorded between an sgl_begin/sgl_end pair. This could lead to the following draw call being rendered with the wrong uniform data.
Diffstat (limited to 'util')
-rw-r--r--util/sokol_gl.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/util/sokol_gl.h b/util/sokol_gl.h
index 2a306c4b..6b3e1cbf 100644
--- a/util/sokol_gl.h
+++ b/util/sokol_gl.h
@@ -2030,10 +2030,8 @@ SOKOL_API_IMPL void sgl_begin_quads(void) {
SOKOL_API_IMPL void sgl_end(void) {
SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
SOKOL_ASSERT(_sgl.in_begin);
+ SOKOL_ASSERT(_sgl.cur_vertex >= _sgl.base_vertex);
_sgl.in_begin = false;
- if (_sgl.base_vertex == _sgl.cur_vertex) {
- return;
- }
bool matrix_dirty = _sgl.matrix_dirty;
if (matrix_dirty) {
_sgl.matrix_dirty = false;
@@ -2360,7 +2358,9 @@ SOKOL_API_IMPL void sgl_draw(void) {
cur_uniform_index = args->uniform_index;
}
/* FIXME: what if number of vertices doesn't match the primitive type? */
- sg_draw(args->base_vertex, args->num_vertices, 1);
+ if (args->num_vertices > 0) {
+ sg_draw(args->base_vertex, args->num_vertices, 1);
+ }
}
break;
}