mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
glcontext: Only swizzle when we can
Don't use the recently added swizzle optimization if we're using a GL version that is too old to support swizzling (GLES 2).
This commit is contained in:
parent
393ee574b6
commit
cf4b0a27f8
@ -499,6 +499,7 @@ gsk_gl_command_queue_new (GdkGLContext *context,
|
||||
}
|
||||
|
||||
self->has_samplers = gdk_gl_context_check_version (context, "3.3", "3.0");
|
||||
self->can_swizzle = gdk_gl_context_check_version (context, "3.0", "3.0");
|
||||
|
||||
/* create the samplers */
|
||||
if (self->has_samplers)
|
||||
@ -1473,14 +1474,13 @@ gsk_gl_command_queue_create_framebuffer (GskGLCommandQueue *self)
|
||||
return fbo_id;
|
||||
}
|
||||
|
||||
|
||||
static GdkMemoryFormat
|
||||
memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
GdkGLContext *context,
|
||||
guint *gl_internalformat,
|
||||
guint *gl_format,
|
||||
guint *gl_type,
|
||||
GLint gl_swizzle[4])
|
||||
memory_format_gl_format (GskGLCommandQueue *self,
|
||||
GdkMemoryFormat data_format,
|
||||
guint *gl_internalformat,
|
||||
guint *gl_format,
|
||||
guint *gl_type,
|
||||
GLint gl_swizzle[4])
|
||||
{
|
||||
GdkGLMemoryFlags flags;
|
||||
GdkMemoryFormat alt_format;
|
||||
@ -1492,7 +1492,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
data_format = gdk_memory_format_get_premultiplied (data_format);
|
||||
|
||||
/* First, try the format itself */
|
||||
flags = gdk_gl_context_get_format_flags (context, data_format);
|
||||
flags = gdk_gl_context_get_format_flags (self->context, data_format);
|
||||
if ((flags & (GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE)) == (GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE))
|
||||
{
|
||||
gdk_memory_format_gl_format (data_format,
|
||||
@ -1511,17 +1511,27 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
gl_type,
|
||||
gl_swizzle))
|
||||
{
|
||||
flags = gdk_gl_context_get_format_flags (context, alt_format);
|
||||
if (((flags & (GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE)) == (GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE)) &&
|
||||
gdk_memory_format_alpha (alt_format) != GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
return data_format;
|
||||
flags = gdk_gl_context_get_format_flags (self->context, alt_format);
|
||||
if ((flags & (GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE)) == (GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE))
|
||||
{
|
||||
if (self->can_swizzle)
|
||||
return data_format;
|
||||
|
||||
gdk_memory_format_gl_format (alt_format,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle);
|
||||
|
||||
return alt_format;
|
||||
}
|
||||
}
|
||||
|
||||
/* Next, try the fallbacks */
|
||||
fallbacks = gdk_memory_format_get_fallbacks (data_format);
|
||||
for (i = 0; fallbacks[i] != -1; i++)
|
||||
{
|
||||
flags = gdk_gl_context_get_format_flags (context, fallbacks[i]);
|
||||
flags = gdk_gl_context_get_format_flags (self->context, fallbacks[i]);
|
||||
if (((flags & (GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE)) == (GDK_GL_FORMAT_USABLE | GDK_GL_FORMAT_FILTERABLE)))
|
||||
{
|
||||
gdk_memory_format_gl_format (fallbacks[i],
|
||||
@ -1561,8 +1571,8 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
|
||||
width = gdk_texture_get_width (texture);
|
||||
height = gdk_texture_get_height (texture);
|
||||
|
||||
data_format = memory_format_gl_format (data_format,
|
||||
self->context,
|
||||
data_format = memory_format_gl_format (self,
|
||||
data_format,
|
||||
&gl_internalformat,
|
||||
&gl_format,
|
||||
&gl_type,
|
||||
@ -1687,8 +1697,8 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
|
||||
|
||||
/* Initialize the texture */
|
||||
data_format = gdk_texture_get_format (chunks[0].texture);
|
||||
data_format = memory_format_gl_format (data_format,
|
||||
self->context,
|
||||
data_format = memory_format_gl_format (self,
|
||||
data_format,
|
||||
&gl_internalformat,
|
||||
&gl_format,
|
||||
&gl_type,
|
||||
|
@ -286,6 +286,9 @@ struct _GskGLCommandQueue
|
||||
/* If the GL context is new enough for sampler support */
|
||||
guint has_samplers : 1;
|
||||
|
||||
/* If the GL context is new enough to support swizzling (ie is not GLES2) */
|
||||
guint can_swizzle : 1;
|
||||
|
||||
/* If we're inside a begin/end_frame pair */
|
||||
guint in_frame : 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user