Allow passing a format when creating textures or render targets.
Update all callers to pass GL_RGBA8, which is the format we
have always used so far.
gsk_ngl_command_queue_create_render_target (GskNglCommandQueue *self,
int width,
int height,
+ int format,
int min_filter,
int mag_filter,
guint *out_fbo_id,
texture_id = gsk_ngl_command_queue_create_texture (self,
width, height,
+ format,
min_filter, mag_filter);
if (texture_id == -1)
gsk_ngl_command_queue_create_texture (GskNglCommandQueue *self,
int width,
int height,
+ int format,
int min_filter,
int mag_filter)
{
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (gdk_gl_context_get_use_es (self->context))
- glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D (GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
else
- glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D (GL_TEXTURE_2D, 0, format, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
/* Restore the previous texture if it was set */
if (self->attachments->textures[0].id != 0)
height = MAX (height, self->max_texture_size);
}
- texture_id = gsk_ngl_command_queue_create_texture (self, width, height, min_filter, mag_filter);
+ texture_id = gsk_ngl_command_queue_create_texture (self, width, height, GL_RGBA8, min_filter, mag_filter);
if (texture_id == -1)
return texture_id;
int gsk_ngl_command_queue_create_texture (GskNglCommandQueue *self,
int width,
int height,
+ int format,
int min_filter,
int mag_filter);
guint gsk_ngl_command_queue_create_framebuffer (GskNglCommandQueue *self);
gboolean gsk_ngl_command_queue_create_render_target (GskNglCommandQueue *self,
int width,
int height,
+ int format,
int min_filter,
int mag_filter,
guint *out_fbo_id,
atlas->texture_id = gsk_ngl_command_queue_create_texture (self->command_queue,
atlas->width,
atlas->height,
+ GL_RGBA8,
GL_LINEAR,
GL_LINEAR);
guint texture_id;
int height;
int width;
+ int format;
g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), 0);
g_return_val_if_fail (GDK_IS_TEXTURE (texture), 0);
context = self->command_queue->context;
+ format = GL_RGBA8;
+
if (GDK_IS_GL_TEXTURE (texture))
{
GdkGLTexture *gl_texture = (GdkGLTexture *) texture;
mag_filter);
t = gsk_ngl_texture_new (texture_id,
- width, height, min_filter, mag_filter,
+ width, height, format, min_filter, mag_filter,
self->current_frame_id);
g_hash_table_insert (self->textures, GUINT_TO_POINTER (texture_id), t);
* @self: a `GskNglDriver`
* @width: the width of the texture
* @height: the height of the texture
+ * @format: format for the texture
* @min_filter: GL_NEAREST or GL_LINEAR
* @mag_filter: GL_NEAREST or GL_FILTER
*
* to upload data, map to a framebuffer, or other uses which may
* modify the texture immediately.
*
+ * Typical examples for @format are GK_RGBA8, GL_RGBA16F or GL_RGBA32F.
+ *
* Use gsk_ngl_driver_release_texture() to release this texture back into
* the pool so it may be reused later in the pipeline.
*
gsk_ngl_driver_create_texture (GskNglDriver *self,
float width,
float height,
+ int format,
int min_filter,
int mag_filter)
{
texture_id = gsk_ngl_command_queue_create_texture (self->command_queue,
width, height,
+ format,
min_filter, mag_filter);
texture = gsk_ngl_texture_new (texture_id,
width, height,
+ format,
min_filter, mag_filter,
self->current_frame_id);
g_hash_table_insert (self->textures,
* @self: a `GskNglDriver`
* @width: the width for the render target
* @height: the height for the render target
+ * @format: the format to use
* @min_filter: the min filter to use for the texture
* @mag_filter: the mag filter to use for the texture
* @out_render_target: (out): a location for the render target
* bound to that framebuffer of the size @width x @height and using the
* appropriate filters.
*
+ * Typical examples for @format are GK_RGBA8, GL_RGBA16F or GL_RGBA32F.
+ *
* Use gsk_ngl_driver_release_render_target() when you are finished with
* the render target to release it. You may steal the texture from the
* render target when releasing it.
gsk_ngl_driver_create_render_target (GskNglDriver *self,
int width,
int height,
+ int format,
int min_filter,
int mag_filter,
GskNglRenderTarget **out_render_target)
if (gsk_ngl_command_queue_create_render_target (self->command_queue,
width, height,
+ format,
min_filter, mag_filter,
&framebuffer_id, &texture_id))
{
render_target = g_slice_new0 (GskNglRenderTarget);
render_target->min_filter = min_filter;
render_target->mag_filter = mag_filter;
+ render_target->format = format;
render_target->width = width;
render_target->height = height;
render_target->framebuffer_id = framebuffer_id;
texture = gsk_ngl_texture_new (render_target->texture_id,
render_target->width,
render_target->height,
+ render_target->format,
render_target->min_filter,
render_target->mag_filter,
self->current_frame_id);
/* Allocate one Texture for the entire thing. */
t = gsk_ngl_texture_new (0,
tex_width, tex_height,
+ GL_RGBA8,
GL_NEAREST, GL_NEAREST,
self->current_frame_id);
guint texture_id;
int min_filter;
int mag_filter;
+ int format;
int width;
int height;
};
gboolean gsk_ngl_driver_create_render_target (GskNglDriver *self,
int width,
int height,
+ int format,
int min_filter,
int mag_filter,
GskNglRenderTarget **render_target);
GskNglTexture *gsk_ngl_driver_create_texture (GskNglDriver *self,
float width,
float height,
+ int format,
int min_filter,
int mag_filter);
void gsk_ngl_driver_release_texture (GskNglDriver *self,
if (gsk_ngl_driver_create_render_target (self->driver,
width, height,
+ GL_RGBA8,
GL_NEAREST, GL_NEAREST,
&render_target))
{
if (!gsk_ngl_driver_create_render_target (job->driver,
MAX (texture_to_blur_width, 1),
MAX (texture_to_blur_height, 1),
+ GL_RGBA8,
GL_NEAREST, GL_NEAREST,
&pass1))
return 0;
if (!gsk_ngl_driver_create_render_target (job->driver,
texture_to_blur_width,
texture_to_blur_height,
+ GL_RGBA8,
GL_NEAREST, GL_NEAREST,
&pass2))
return gsk_ngl_driver_release_render_target (job->driver, pass1, FALSE);
if (!gsk_ngl_driver_create_render_target (job->driver,
texture_width, texture_height,
+ GL_RGBA8,
GL_NEAREST, GL_NEAREST,
&render_target))
g_assert_not_reached ();
gsk_ngl_driver_create_render_target (job->driver,
texture_width, texture_height,
+ GL_RGBA8,
GL_NEAREST, GL_NEAREST,
&render_target);
if (!gsk_ngl_driver_create_render_target (job->driver,
scaled_width, scaled_height,
+ GL_RGBA8,
filter, filter,
&render_target))
g_assert_not_reached ();
if (!gsk_ngl_command_queue_create_render_target (job->command_queue,
MAX (1, job->viewport.size.width),
MAX (1, job->viewport.size.height),
+ GL_RGBA8,
GL_NEAREST, GL_NEAREST,
&framebuffer_id, &texture_id))
return;
gsk_ngl_texture_new (guint texture_id,
int width,
int height,
+ int format,
int min_filter,
int mag_filter,
gint64 frame_id)
texture->link.data = texture;
texture->min_filter = min_filter;
texture->mag_filter = mag_filter;
+ texture->format = format;
texture->width = width;
texture->height = height;
texture->last_used_in_frame = frame_id;
height = MIN (height, self->driver->command_queue->max_texture_size);
}
- texture = gsk_ngl_driver_create_texture (self->driver, width, height, GL_LINEAR, GL_LINEAR);
+ texture = gsk_ngl_driver_create_texture (self->driver, width, height, GL_RGBA8, GL_LINEAR, GL_LINEAR);
texture->permanent = TRUE;
return texture;
int height;
int min_filter;
int mag_filter;
+ int format;
/* Set when used by an atlas so we don't drop the texture */
guint permanent : 1;
GskNglTexture *gsk_ngl_texture_new (guint texture_id,
int width,
int height,
+ int format,
int min_filter,
int mag_filter,
gint64 frame_id);