From 7a493f151dc5b77a0d97aaea60afb1af6c104c73 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 28 Jun 2021 14:50:58 -0400 Subject: [PATCH 1/2] Revert "gsk: Respect max element vertices limitation" This reverts commit f58fc6b22e143e43b45f297795959f217a26d95f. --- gsk/ngl/gsknglcommandqueue.c | 6 +----- gsk/ngl/gsknglcommandqueueprivate.h | 6 ------ 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/gsk/ngl/gsknglcommandqueue.c b/gsk/ngl/gsknglcommandqueue.c index 25eb37f53b..6d61dbaad6 100644 --- a/gsk/ngl/gsknglcommandqueue.c +++ b/gsk/ngl/gsknglcommandqueue.c @@ -444,12 +444,9 @@ gsk_ngl_command_queue_new (GdkGLContext *context, else self->uniforms = gsk_ngl_uniform_state_new (); - /* Determine max texture size and other limitations immediately - * and restore context - */ + /* Determine max texture size immediately and restore context */ gdk_gl_context_make_current (context); glGetIntegerv (GL_MAX_TEXTURE_SIZE, &self->max_texture_size); - glGetIntegerv (GL_MAX_ELEMENTS_VERTICES, &self->max_elements_vertices); return g_steal_pointer (&self); } @@ -620,7 +617,6 @@ gsk_ngl_command_queue_end_draw (GskNglCommandQueue *self) last_batch->any.viewport.height == batch->any.viewport.height && last_batch->draw.framebuffer == batch->draw.framebuffer && last_batch->draw.vbo_offset + last_batch->draw.vbo_count == batch->draw.vbo_offset && - last_batch->draw.vbo_count + batch->draw.vbo_count <= self->max_elements_vertices && snapshots_equal (self, last_batch, batch)) { last_batch->draw.vbo_count += batch->draw.vbo_count; diff --git a/gsk/ngl/gsknglcommandqueueprivate.h b/gsk/ngl/gsknglcommandqueueprivate.h index 3ed52021bc..a2f50c485d 100644 --- a/gsk/ngl/gsknglcommandqueueprivate.h +++ b/gsk/ngl/gsknglcommandqueueprivate.h @@ -231,12 +231,6 @@ struct _GskNglCommandQueue */ int max_texture_size; - /* Discovered max element count. We must not create batches that contain - * more vertices than this number. - */ - - int max_elements_vertices; - /* The index of the last batch in @batches, which may not be the element * at the end of the array, as batches can be reordered. This is used to * update the "next" index when adding a new batch. From bd5e5beee00293e68c2b3f3c281b023958694880 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 28 Jun 2021 15:00:41 -0400 Subject: [PATCH 2/2] gsk: Don't overflow vbo_count We use 16 bits to store vbo_count, so we can't create batches that have more than 65535 vertices. Pay attention to that limit when merging batches. --- gsk/ngl/gsknglcommandqueue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gsk/ngl/gsknglcommandqueue.c b/gsk/ngl/gsknglcommandqueue.c index 6d61dbaad6..5449fde9af 100644 --- a/gsk/ngl/gsknglcommandqueue.c +++ b/gsk/ngl/gsknglcommandqueue.c @@ -617,6 +617,7 @@ gsk_ngl_command_queue_end_draw (GskNglCommandQueue *self) last_batch->any.viewport.height == batch->any.viewport.height && last_batch->draw.framebuffer == batch->draw.framebuffer && last_batch->draw.vbo_offset + last_batch->draw.vbo_count == batch->draw.vbo_offset && + last_batch->draw.vbo_count + batch->draw.vbo_count < G_MAXINT16 && snapshots_equal (self, last_batch, batch)) { last_batch->draw.vbo_count += batch->draw.vbo_count;