Merge branch 'mipmap-fixes' into 'main'

Mipmap handling fixes

Closes #6298

See merge request GNOME/gtk!6704
This commit is contained in:
Matthias Clasen 2024-01-03 18:06:23 +00:00
commit 603de8361c
5 changed files with 24 additions and 12 deletions

View File

@ -946,7 +946,10 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
t->has_mipmap = TRUE;
}
return t->texture_id;
if (!ensure_mipmap || t->has_mipmap)
return t->texture_id;
gdk_texture_clear_render_data (texture);
}
if (GDK_IS_DMABUF_TEXTURE (texture) && !ensure_mipmap)

View File

@ -202,6 +202,7 @@ gsk_gl_driver_get_texture_by_id (GskGLDriver *self,
* gsk_gl_driver_lookup_texture:
* @self: a `GskGLDriver`
* @key: the key for the texture
* @has_mipmap: (out): Return location for whether the texture has a mipmap
*
* Looks up a texture in the texture cache by @key.
*
@ -211,7 +212,8 @@ gsk_gl_driver_get_texture_by_id (GskGLDriver *self,
*/
static inline guint
gsk_gl_driver_lookup_texture (GskGLDriver *self,
const GskTextureKey *key)
const GskTextureKey *key,
gboolean *has_mipmap)
{
gpointer id;
@ -222,6 +224,9 @@ gsk_gl_driver_lookup_texture (GskGLDriver *self,
if (texture != NULL)
texture->last_used_in_frame = self->current_frame_id;
if (has_mipmap)
*has_mipmap = texture ? texture->has_mipmap : FALSE;
return GPOINTER_TO_UINT (id);
}

View File

@ -1190,7 +1190,7 @@ gsk_gl_render_job_visit_as_fallback (GskGLRenderJob *job,
key.scale_x = scale_x;
key.scale_y = scale_y;
texture_id = gsk_gl_driver_lookup_texture (job->driver, &key);
texture_id = gsk_gl_driver_lookup_texture (job->driver, &key, NULL);
if (texture_id != 0)
goto done;
@ -2216,7 +2216,7 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
key.scale_x = scale_x;
key.scale_y = scale_y;
blurred_texture_id = gsk_gl_driver_lookup_texture (job->driver, &key);
blurred_texture_id = gsk_gl_driver_lookup_texture (job->driver, &key, NULL);
if (blurred_texture_id == 0)
{
@ -3216,7 +3216,7 @@ gsk_gl_render_job_visit_blur_node (GskGLRenderJob *job,
key.scale_x = job->scale_x;
key.scale_y = job->scale_y;
offscreen.texture_id = gsk_gl_driver_lookup_texture (job->driver, &key);
offscreen.texture_id = gsk_gl_driver_lookup_texture (job->driver, &key, NULL);
cache_texture = offscreen.texture_id == 0;
blur_node (job,
@ -3771,6 +3771,8 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
float u0, u1, v0, v1;
GskTextureKey key;
guint texture_id;
gboolean need_mipmap;
gboolean has_mipmap;
gsk_gl_render_job_untransform_bounds (job, &job->current_clip->rect.bounds, &clip_rect);
@ -3783,9 +3785,11 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
key.scale_x = 1.;
key.scale_y = 1.;
texture_id = gsk_gl_driver_lookup_texture (job->driver, &key);
need_mipmap = (filter == GSK_SCALING_FILTER_TRILINEAR);
if (texture_id != 0)
texture_id = gsk_gl_driver_lookup_texture (job->driver, &key, &has_mipmap);
if (texture_id != 0 && (!need_mipmap || has_mipmap))
goto render_texture;
viewport = GRAPHENE_RECT_INIT (0, 0,
@ -3816,7 +3820,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
{
gpointer sync;
texture_id = gsk_gl_driver_load_texture (job->driver, texture, filter == GSK_SCALING_FILTER_TRILINEAR);
texture_id = gsk_gl_driver_load_texture (job->driver, texture, need_mipmap);
if (GDK_IS_GL_TEXTURE (texture) && texture_id == gdk_gl_texture_get_id (GDK_GL_TEXTURE (texture)))
sync = gdk_gl_texture_get_sync (GDK_GL_TEXTURE (texture));
@ -3853,7 +3857,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
GskGLTextureSlice *slices = NULL;
guint n_slices = 0;
gsk_gl_driver_slice_texture (job->driver, texture, filter == GSK_SCALING_FILTER_TRILINEAR, &slices, &n_slices);
gsk_gl_driver_slice_texture (job->driver, texture, need_mipmap, &slices, &n_slices);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
@ -4352,7 +4356,7 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
}
/* Check if we've already cached the drawn texture. */
cached_id = gsk_gl_driver_lookup_texture (job->driver, &key);
cached_id = gsk_gl_driver_lookup_texture (job->driver, &key, NULL);
if (cached_id != 0)
{

View File

@ -681,7 +681,7 @@ typedef enum {
GtkOrdering gtk_ordering_from_cmpfunc (int cmpfunc_result);
#else
/**
* gtk_ordering_from_cmpfunc:
* gtk_ordering_from_cmpfunc: (skip)
* @cmpfunc_result: Result of a comparison function
*
* Converts the result of a `GCompareFunc` like strcmp() to a

View File

@ -372,7 +372,7 @@ gtk_sorter_changed_with_keys (GtkSorter *self,
*/
#ifdef __GI_SCANNER__
/**
* gtk_ordering_from_cmpfunc:
* gtk_ordering_from_cmpfunc: (skip)
* @cmpfunc_result: Result of a comparison function
*
* Converts the result of a `GCompareFunc` like strcmp() to a