[gtk/wip/chergert/glproto: 397/493] try to iterate fewer attachment slots
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 397/493] try to iterate fewer attachment slots
- Date: Fri, 19 Feb 2021 02:25:18 +0000 (UTC)
commit dbae4d78536f24a0a270e0e107c156302f622a25
Author: Christian Hergert <chergert redhat com>
Date: Thu Feb 4 14:51:16 2021 -0800
try to iterate fewer attachment slots
gsk/next/gskglattachmentstate.c | 9 +++++++--
gsk/next/gskglattachmentstateprivate.h | 3 +--
gsk/next/gskglcommandqueue.c | 33 ++++++++++++++++++++-------------
3 files changed, 28 insertions(+), 17 deletions(-)
---
diff --git a/gsk/next/gskglattachmentstate.c b/gsk/next/gskglattachmentstate.c
index 37d0c347fb..b05cc975a1 100644
--- a/gsk/next/gskglattachmentstate.c
+++ b/gsk/next/gskglattachmentstate.c
@@ -31,6 +31,7 @@ gsk_gl_attachment_state_new (void)
self->fbo.changed = FALSE;
self->fbo.id = 0;
+ self->n_changed = 0;
/* Initialize textures, assume we are 2D by default since it
* doesn't really matter until we bind something other than
@@ -81,9 +82,13 @@ gsk_gl_attachment_state_bind_texture (GskGLAttachmentState *self,
attach->target = target;
attach->texture = texture;
attach->id = id;
- attach->changed = TRUE;
attach->initial = FALSE;
- self->has_texture_change = TRUE;
+
+ if (attach->changed == FALSE)
+ {
+ attach->changed = TRUE;
+ self->n_changed++;
+ }
}
}
diff --git a/gsk/next/gskglattachmentstateprivate.h b/gsk/next/gskglattachmentstateprivate.h
index ef45119893..3144371ce9 100644
--- a/gsk/next/gskglattachmentstateprivate.h
+++ b/gsk/next/gskglattachmentstateprivate.h
@@ -52,13 +52,12 @@ struct _GskGLAttachmentState
{
GskGLBindFramebuffer fbo;
GskGLBindTexture textures[8];
- guint has_texture_change : 1;
+ guint n_changed;
};
GskGLAttachmentState *gsk_gl_attachment_state_new (void);
GskGLAttachmentState *gsk_gl_attachment_state_ref (GskGLAttachmentState *self);
void gsk_gl_attachment_state_unref (GskGLAttachmentState *self);
-void gsk_gl_attachment_state_free (GskGLAttachmentState *self);
void gsk_gl_attachment_state_bind_texture (GskGLAttachmentState *self,
GLenum target,
GLenum texture,
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index a9684633fd..d28e08b475 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -442,24 +442,31 @@ gsk_gl_command_queue_end_draw (GskGLCommandQueue *self)
}
/* Track the bind attachments that changed */
- batch->draw.bind_offset = self->batch_binds->len;
- batch->draw.bind_count = 0;
- for (guint i = 0; i < G_N_ELEMENTS (self->attachments->textures); i++)
+ if (self->attachments->n_changed > 0)
{
- GskGLBindTexture *texture = &self->attachments->textures[i];
-
- if (texture->changed && texture->id > 0)
- {
- GskGLCommandBind bind;
+ GskGLCommandBind *bind;
- texture->changed = FALSE;
+ batch->draw.bind_offset = self->batch_binds->len;
+ batch->draw.bind_count = self->attachments->n_changed;
- bind.texture = texture->texture;
- bind.id = texture->id;
+ g_array_set_size (self->batch_binds, self->batch_binds->len + batch->draw.bind_count);
+ bind = &g_array_index (self->batch_binds, GskGLCommandBind, self->batch_binds->len -
batch->draw.bind_count);
- g_array_append_val (self->batch_binds, bind);
+ for (guint i = 0;
+ (self->attachments->n_changed > 0 &&
+ i < G_N_ELEMENTS (self->attachments->textures));
+ i++)
+ {
+ GskGLBindTexture *texture = &self->attachments->textures[i];
- batch->draw.bind_count++;
+ if (texture->changed)
+ {
+ texture->changed = FALSE;
+ bind->texture = texture->texture;
+ bind->id = texture->id;
+ bind++;
+ self->attachments->n_changed--;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]