[gtk/wip/chergert/glproto: 316/493] try a bit harder to keep command queue current




commit b8599230e2d221a745eeb1b9de6f07b56e5beec6
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jan 29 15:38:17 2021 -0800

    try a bit harder to keep command queue current

 gsk/next/gskglcommandqueue.c | 2 ++
 gsk/next/gskgldriver.c       | 9 +--------
 gsk/next/gskglrenderjob.c    | 6 +++++-
 3 files changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index 62cc056036..2b373cb34c 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -740,6 +740,8 @@ gsk_gl_command_queue_execute (GskGLCommandQueue    *self,
   if (self->batches->len == 0)
     return;
 
+  gsk_gl_command_queue_make_current (self);
+
   glEnable (GL_DEPTH_TEST);
   glDepthFunc (GL_LEQUAL);
 
diff --git a/gsk/next/gskgldriver.c b/gsk/next/gskgldriver.c
index c5b5619946..c800ecce94 100644
--- a/gsk/next/gskgldriver.c
+++ b/gsk/next/gskgldriver.c
@@ -529,8 +529,7 @@ gsk_next_driver_end_frame (GskNextDriver *self)
   g_return_if_fail (GSK_IS_NEXT_DRIVER (self));
   g_return_if_fail (self->in_frame == TRUE);
 
-  gdk_gl_context_make_current (self->command_queue->context);
-
+  gsk_gl_command_queue_make_current (self->command_queue);
   gsk_gl_command_queue_end_frame (self->command_queue);
 
   gsk_gl_texture_library_end_frame (GSK_GL_TEXTURE_LIBRARY (self->icons));
@@ -678,7 +677,6 @@ gsk_next_driver_load_texture (GskNextDriver   *self,
                               int              min_filter,
                               int              mag_filter)
 {
-  GdkGLContext *previous_context = NULL;
   GdkGLContext *context;
   GdkTexture *downloaded_texture = NULL;
   GdkTexture *source_texture;
@@ -710,8 +708,6 @@ gsk_next_driver_load_texture (GskNextDriver   *self,
         {
           cairo_surface_t *surface;
 
-          previous_context = gdk_gl_context_get_current ();
-
           /* In this case, we have to temporarily make the texture's
            * context the current one, download its data into our context
            * and then create a texture from it. */
@@ -763,9 +759,6 @@ gsk_next_driver_load_texture (GskNextDriver   *self,
 
   g_clear_object (&downloaded_texture);
 
-  if (previous_context)
-    gdk_gl_context_make_current (previous_context);
-
   return texture_id;
 }
 
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index f97c2192e2..1361298e02 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -3139,6 +3139,8 @@ gsk_gl_render_job_upload_texture (GskGLRenderJob       *job,
       offscreen->texture_id = gsk_next_driver_load_texture (job->driver, texture, GL_LINEAR, GL_LINEAR);
       init_full_texture_region (offscreen);
     }
+
+  gsk_gl_command_queue_make_current (job->command_queue);
 }
 
 static void
@@ -3701,6 +3703,8 @@ gsk_gl_render_job_render (GskGLRenderJob *job,
   scale_factor = MAX (job->scale_x, job->scale_y);
   surface_height = job->viewport.size.height;
 
+  gsk_gl_command_queue_make_current (job->command_queue);
+
   /* Build the command queue using the shared GL context for all renderers
    * on the same display.
    */
@@ -3722,7 +3726,7 @@ gsk_gl_render_job_render (GskGLRenderJob *job,
    * that was provided to us when creating the render job as framebuffer 0
    * is bound to that context.
    */
-  gdk_gl_context_make_current (job->command_queue->context);
+  gsk_gl_command_queue_make_current (job->command_queue);
   gdk_gl_context_push_debug_group (job->command_queue->context, "Executing command queue");
   gsk_gl_command_queue_execute (job->command_queue, surface_height, scale_factor, job->region);
   gdk_gl_context_pop_debug_group (job->command_queue->context);


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