[gtk/wip/chergert/glproto: 477/493] add very simple snapshot comparison code
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 477/493] add very simple snapshot comparison code
- Date: Fri, 19 Feb 2021 02:25:24 +0000 (UTC)
commit dbe10e9c1bd91d1130cfd78fb830ea9c35b9b7bb
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 16 17:52:52 2021 -0800
add very simple snapshot comparison code
this just does about the simplest, non-interesting implementation of
comparing snapshots.
gsk/next/gskglcommandqueue.c | 87 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
---
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index 0d029006a7..3b6c2861cb 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -279,6 +279,93 @@ snapshot_uniforms (GskGLUniformState *state,
return count;
}
+static inline gboolean
+snapshots_equal (GskGLCommandQueue *self,
+ GskGLCommandBatch *first,
+ GskGLCommandBatch *second)
+{
+ if (first->draw.bind_count != second->draw.bind_count ||
+ first->draw.uniform_count != second->draw.uniform_count)
+ return FALSE;
+
+ for (guint i = 0; i < first->draw.bind_count; i++)
+ {
+ const GskGLCommandBind *fb = &self->batch_binds.elements[first->draw.bind_offset+i];
+ const GskGLCommandBind *sb = &self->batch_binds.elements[second->draw.bind_offset+i];
+
+ if (fb->id != sb->id || fb->texture != sb->texture)
+ return FALSE;
+ }
+
+ for (guint i = 0; i < first->draw.uniform_count; i++)
+ {
+ const GskGLCommandUniform *fu = &self->batch_uniforms.elements[first->draw.uniform_offset+i];
+ const GskGLCommandUniform *su = &self->batch_uniforms.elements[second->draw.uniform_offset+i];
+ gconstpointer fdata;
+ gconstpointer sdata;
+ gsize len;
+
+ if (fu->info.format != su->info.format ||
+ fu->info.array_count != su->info.array_count)
+ return FALSE;
+
+ fdata = gsk_gl_uniform_state_get_uniform_data (self->uniforms, fu->info.offset);
+ sdata = gsk_gl_uniform_state_get_uniform_data (self->uniforms, su->info.offset);
+
+ switch (fu->info.format)
+ {
+ case GSK_GL_UNIFORM_FORMAT_1F:
+ case GSK_GL_UNIFORM_FORMAT_1FV:
+ case GSK_GL_UNIFORM_FORMAT_1I:
+ case GSK_GL_UNIFORM_FORMAT_TEXTURE:
+ case GSK_GL_UNIFORM_FORMAT_1UI:
+ len = 4;
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_2F:
+ case GSK_GL_UNIFORM_FORMAT_2FV:
+ case GSK_GL_UNIFORM_FORMAT_2I:
+ len = 8;
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_3F:
+ case GSK_GL_UNIFORM_FORMAT_3FV:
+ case GSK_GL_UNIFORM_FORMAT_3I:
+ len = 12;
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_4F:
+ case GSK_GL_UNIFORM_FORMAT_4FV:
+ case GSK_GL_UNIFORM_FORMAT_4I:
+ len = 16;
+ break;
+
+
+ case GSK_GL_UNIFORM_FORMAT_MATRIX:
+ len = sizeof (float) * 16;
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT:
+ len = sizeof (float) * 12;
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_COLOR:
+ len = sizeof (float) * 4;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ len *= fu->info.array_count;
+
+ if (memcmp (fdata, sdata, len) != 0)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
gsk_gl_command_queue_dispose (GObject *object)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]