GLES2 has no idea what 16bit textures even are, let alone floating point.
static gboolean
gdk_gl_texture_find_format (gboolean use_es,
+ guint gl_major,
+ guint gl_minor,
GLint gl_format,
GLint gl_type,
GdkMemoryFormat *out_format)
{
GLenum q_internal_format, q_format, q_type;
- if (!gdk_memory_format_gl_format (format, use_es, &q_internal_format, &q_format, &q_type))
+ if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type))
continue;
if (q_format != gl_format || q_type != gl_type)
gsize expected_stride;
Download *download = download_;
GLenum gl_internal_format, gl_format, gl_type;
+ int major, minor;
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
+ gdk_gl_context_get_version (context, &major, &minor);
if (download->stride == expected_stride &&
!gdk_gl_context_get_use_es (context) &&
- gdk_memory_format_gl_format (download->format, TRUE, &gl_internal_format, &gl_format, &gl_type))
+ gdk_memory_format_gl_format (download->format, TRUE, major, minor, &gl_internal_format, &gl_format, &gl_type))
{
glGetTexImage (GL_TEXTURE_2D,
0,
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
if (gdk_gl_context_check_version (context, 4, 3, 3, 1))
{
+ gdk_gl_context_get_version (context, &major, &minor);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
- if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), gl_read_format, gl_read_type, &actual_format))
+ if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), major, minor, gl_read_format, gl_read_type, &actual_format))
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
}
else
gsize bytes_per_pixel;
gsize alignment;
gboolean prefers_high_depth;
- gboolean supports_gles;
+ struct {
+ guint gl_major;
+ guint gl_minor;
+ guint gles_major;
+ guint gles_minor;
+ } min_gl_version;
struct {
guint internal_format;
guint format;
4,
G_ALIGNOF (guchar),
FALSE,
- FALSE,
+ { 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
b8g8r8a8_premultiplied_to_float,
b8g8r8a8_premultiplied_from_float,
4,
G_ALIGNOF (guchar),
FALSE,
- FALSE,
+ { 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8r8g8b8_premultiplied_to_float,
a8r8g8b8_premultiplied_from_float,
4,
G_ALIGNOF (guchar),
FALSE,
- TRUE,
+ { 0, 0, 0, 0 },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
r8g8b8a8_premultiplied_to_float,
r8g8b8a8_premultiplied_from_float,
4,
G_ALIGNOF (guchar),
FALSE,
- FALSE,
+ { 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
b8g8r8a8_to_float,
b8g8r8a8_from_float,
4,
G_ALIGNOF (guchar),
FALSE,
- FALSE,
+ { 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8r8g8b8_to_float,
a8r8g8b8_from_float,
4,
G_ALIGNOF (guchar),
FALSE,
- TRUE,
+ { 0, 0, 0, 0 },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
r8g8b8a8_to_float,
r8g8b8a8_from_float,
4,
G_ALIGNOF (guchar),
FALSE,
- FALSE,
+ { 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8b8g8r8_to_float,
a8b8g8r8_from_float,
3,
G_ALIGNOF (guchar),
FALSE,
- TRUE,
+ { 0, 0, 0, 0 },
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE },
r8g8b8_to_float,
r8g8b8_from_float,
3,
G_ALIGNOF (guchar),
FALSE,
- FALSE,
+ { 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE },
b8g8r8_to_float,
b8g8r8_from_float,
6,
G_ALIGNOF (guint16),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT },
r16g16b16_to_float,
r16g16b16_from_float,
8,
G_ALIGNOF (guint16),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
r16g16b16a16_to_float,
r16g16b16a16_from_float,
8,
G_ALIGNOF (guint16),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
r16g16b16a16_to_float,
r16g16b16a16_from_float,
6,
G_ALIGNOF (guint16),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT },
r16g16b16_float_to_float,
r16g16b16_float_from_float,
8,
G_ALIGNOF (guint16),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
r16g16b16a16_float_to_float,
r16g16b16a16_float_from_float,
8,
G_ALIGNOF (guint16),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
r16g16b16a16_float_to_float,
r16g16b16a16_float_from_float,
12,
G_ALIGNOF (float),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGB32F, GL_RGB, GL_FLOAT },
r32g32b32_float_to_float,
r32g32b32_float_from_float,
16,
G_ALIGNOF (float),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
r32g32b32a32_float_to_float,
r32g32b32a32_float_from_float,
16,
G_ALIGNOF (float),
TRUE,
- TRUE,
+ { 0, 0, 3, 0 },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
r32g32b32a32_float_to_float,
r32g32b32a32_float_from_float,
gboolean
gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
+ guint gl_major,
+ guint gl_minor,
guint *out_internal_format,
guint *out_format,
guint *out_type)
if (memory_formats[format].alpha == GDK_MEMORY_ALPHA_STRAIGHT)
return FALSE;
- if (gles && !memory_formats[format].supports_gles)
- return FALSE;
+ if (gles)
+ {
+ if (memory_formats[format].min_gl_version.gles_major > gl_major ||
+ (memory_formats[format].min_gl_version.gles_major == gl_major &&
+ memory_formats[format].min_gl_version.gles_minor > gl_minor))
+ return FALSE;
+ }
+ else
+ {
+ if (memory_formats[format].min_gl_version.gl_major > gl_major ||
+ (memory_formats[format].min_gl_version.gl_major == gl_major &&
+ memory_formats[format].min_gl_version.gl_minor > gl_minor))
+ return FALSE;
+ }
return TRUE;
}
gboolean gdk_memory_format_prefers_high_depth(GdkMemoryFormat format) G_GNUC_CONST;
gboolean gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
+ guint gl_major,
+ guint gl_minor,
guint *out_internal_format,
guint *out_format,
guint *out_type);
static GdkMemoryFormat
memory_format_gl_format (GdkMemoryFormat data_format,
gboolean use_es,
+ guint major,
+ guint minor,
guint *gl_internalformat,
guint *gl_format,
guint *gl_type)
{
+ if (gdk_memory_format_gl_format (data_format,
+ use_es,
+ major,
+ minor,
+ gl_internalformat,
+ gl_format,
+ gl_type))
+ return data_format;
+
+ if (gdk_memory_format_prefers_high_depth (data_format))
+ {
+ data_format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
+ if (gdk_memory_format_gl_format (data_format,
+ use_es,
+ major,
+ minor,
+ gl_internalformat,
+ gl_format,
+ gl_type))
+ return data_format;
+ }
+
+ data_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
if (!gdk_memory_format_gl_format (data_format,
use_es,
+ major,
+ minor,
gl_internalformat,
gl_format,
gl_type))
{
- if (gdk_memory_format_prefers_high_depth (data_format))
- data_format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
- else
- data_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
- if (!gdk_memory_format_gl_format (data_format,
- use_es,
- gl_internalformat,
- gl_format,
- gl_type))
- {
- g_assert_not_reached ();
- }
+ g_assert_not_reached ();
}
return data_format;
int x,
int y)
{
- GdkGLContext *context;
const guchar *data;
gsize stride;
GBytes *bytes;
GLenum gl_type;
gsize bpp;
gboolean use_es;
+ int major, minor;
- context = gdk_gl_context_get_current ();
- use_es = gdk_gl_context_get_use_es (context);
+ use_es = gdk_gl_context_get_use_es (self->context);
+ gdk_gl_context_get_version (self->context, &major, &minor);
data_format = gdk_texture_get_format (texture);
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
data_format = memory_format_gl_format (data_format,
use_es,
+ major,
+ minor,
&gl_internalformat,
&gl_format,
&gl_type);
glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, width, height, gl_format, gl_type, data);
}
else if (stride % bpp == 0 &&
- (gdk_gl_context_check_version (context, 0, 0, 3, 0) || gdk_gl_context_has_unpack_subimage (context)))
+ (gdk_gl_context_check_version (self->context, 0, 0, 3, 0) || gdk_gl_context_has_unpack_subimage (self->context)))
{
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / bpp);
GLenum gl_type;
gboolean use_es;
int texture_id;
+ int major, minor;
g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
glBindTexture (GL_TEXTURE_2D, texture_id);
/* Initialize the texture */
- use_es = gdk_gl_context_get_use_es (gdk_gl_context_get_current ());
+ use_es = gdk_gl_context_get_use_es (self->context);
+ gdk_gl_context_get_version (self->context, &major, &minor);
data_format = gdk_texture_get_format (chunks[0].texture);
memory_format_gl_format (data_format,
use_es,
+ major,
+ minor,
&gl_internalformat,
&gl_format,
&gl_type);