[gtk/avoid-gl-texture-download] gsk: Avoid downloading GL textures when possible
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/avoid-gl-texture-download] gsk: Avoid downloading GL textures when possible
- Date: Sun, 27 Sep 2020 01:58:32 +0000 (UTC)
commit 9ca9f42452700b29ccbe40449127018d7077fc7c
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 26 21:55:28 2020 -0400
gsk: Avoid downloading GL textures when possible
I found that the gears demo was spending 40% cpu
downloading a GL texture every frame, only to
upload it again to another context.
While the GSK rendering and the GtkGLArea use different
GL contexts, they are (usually) connected by sharing data
with the same global context, so we can just use the
texture without the download/upload dance. This brings
gears down to < 10% cpu.
gsk/gl/gskgldriver.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c
index a383344eae..b1f8d6ea0e 100644
--- a/gsk/gl/gskgldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -521,8 +521,15 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *self,
if (GDK_IS_GL_TEXTURE (texture))
{
GdkGLContext *texture_context = gdk_gl_texture_get_context ((GdkGLTexture *)texture);
+ GdkGLContext *shared_context = gdk_gl_context_get_shared_context (self->gl_context);
- if (texture_context != self->gl_context)
+ if (texture_context == self->gl_context ||
+ (gdk_gl_context_get_shared_context (texture_context) == shared_context && shared_context != NULL))
+ {
+ /* A GL texture from the same GL context is a simple task... */
+ return gdk_gl_texture_get_id ((GdkGLTexture *)texture);
+ }
+ else
{
cairo_surface_t *surface;
@@ -539,11 +546,6 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *self,
source_texture = downloaded_texture;
}
- else
- {
- /* A GL texture from the same GL context is a simple task... */
- return gdk_gl_texture_get_id ((GdkGLTexture *)texture);
- }
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]