[gtk/wip/chergert/glproto: 386/493] perform cleanup before frame instead of after




commit 07cc6c8bb170adebdc826fc80066fda363892b85
Author: Christian Hergert <chergert redhat com>
Date:   Wed Feb 3 22:26:50 2021 -0800

    perform cleanup before frame instead of after
    
    there seems to be a bit of a speedup here by deferring until
    later to do this.

 gsk/next/gskgldriver.c        | 13 ++++++-------
 gsk/next/gskgldriverprivate.h |  2 +-
 gsk/next/gskglrenderer.c      |  8 ++++----
 3 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/gsk/next/gskgldriver.c b/gsk/next/gskgldriver.c
index 0be5863f76..851e659cb9 100644
--- a/gsk/next/gskgldriver.c
+++ b/gsk/next/gskgldriver.c
@@ -279,6 +279,8 @@ gsk_next_driver_dispose (GObject *object)
       self->autorelease_framebuffers->len = 0;
     }
 
+  gsk_gl_texture_pool_clear (&self->texture_pool);
+
   g_assert (!self->textures || g_hash_table_size (self->textures) == 0);
   g_assert (!self->texture_id_to_key || g_hash_table_size (self->texture_id_to_key) == 0);
   g_assert (!self->key_to_texture_id|| g_hash_table_size (self->key_to_texture_id) == 0);
@@ -565,19 +567,16 @@ gsk_next_driver_end_frame (GskNextDriver *self)
 }
 
 /**
- * gsk_next_driver_after_frame:
+ * gsk_next_driver_before_frame:
  * @self: a #GskNextDriver
  *
  * This function does post-frame cleanup operations.
  *
- * It differs from gsk_next_driver_end_frame() in that you should call it
- * after you have requested the GL buffers swapped using
- * gdk_draw_context_end_frame() on the target surface's context. This helps
- * ensure that we do not block on destroying resources when we really just
- * want to get the frame delivered.
+ * To reduce the chances of blocking on the driver it is performed
+ * at the beginning of the following frame.
  */
 void
-gsk_next_driver_after_frame (GskNextDriver *self)
+gsk_next_driver_before_frame (GskNextDriver *self)
 {
   g_return_if_fail (GSK_IS_NEXT_DRIVER (self));
   g_return_if_fail (self->in_frame == FALSE);
diff --git a/gsk/next/gskgldriverprivate.h b/gsk/next/gskgldriverprivate.h
index f09b42e69f..644b9ee178 100644
--- a/gsk/next/gskgldriverprivate.h
+++ b/gsk/next/gskgldriverprivate.h
@@ -139,7 +139,7 @@ guint              gsk_next_driver_release_render_target (GskNextDriver        *
 void               gsk_next_driver_begin_frame           (GskNextDriver        *self,
                                                           GskGLCommandQueue    *command_queue);
 void               gsk_next_driver_end_frame             (GskNextDriver        *self);
-void               gsk_next_driver_after_frame           (GskNextDriver        *self);
+void               gsk_next_driver_before_frame          (GskNextDriver        *self);
 GdkTexture        *gsk_next_driver_create_gdk_texture    (GskNextDriver        *self,
                                                           guint                 texture_id);
 void               gsk_next_driver_cache_texture         (GskNextDriver        *self,
diff --git a/gsk/next/gskglrenderer.c b/gsk/next/gskglrenderer.c
index 7ffa221d62..804accc83b 100644
--- a/gsk/next/gskglrenderer.c
+++ b/gsk/next/gskglrenderer.c
@@ -195,6 +195,8 @@ gsk_next_renderer_render (GskRenderer          *renderer,
   g_assert (GSK_IS_NEXT_RENDERER (renderer));
   g_assert (root != NULL);
 
+  gsk_next_driver_before_frame (self->driver);
+
   surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self->context));
   scale_factor = gdk_surface_get_scale_factor (surface);
   render_region = get_render_region (surface, self->context);
@@ -221,8 +223,6 @@ gsk_next_renderer_render (GskRenderer          *renderer,
   gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->context));
 
   cairo_region_destroy (render_region);
-
-  gsk_next_driver_after_frame (self->driver);
 }
 
 static GdkTexture *
@@ -244,6 +244,8 @@ gsk_next_renderer_render_texture (GskRenderer           *renderer,
   width = ceilf (viewport->size.width);
   height = ceilf (viewport->size.height);
 
+  gsk_next_driver_before_frame (self->driver);
+
   if (gsk_next_driver_create_render_target (self->driver,
                                             width, height,
                                             GL_NEAREST, GL_NEAREST,
@@ -260,8 +262,6 @@ gsk_next_renderer_render_texture (GskRenderer           *renderer,
       texture = gsk_next_driver_create_gdk_texture (self->driver, texture_id);
       gsk_next_driver_end_frame (self->driver);
       gsk_gl_render_job_free (job);
-
-      gsk_next_driver_after_frame (self->driver);
     }
 
   return g_steal_pointer (&texture);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]