[gtk/wip/chergert/glproto: 849/920] decode uniform data when dumping batch info
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 849/920] decode uniform data when dumping batch info
- Date: Mon, 8 Feb 2021 19:15:46 +0000 (UTC)
commit 4e60b7b1d94f7eaab49b6e0bf2b3174a3e697c10
Author: Christian Hergert <chergert redhat com>
Date: Mon Feb 1 22:09:42 2021 -0800
decode uniform data when dumping batch info
This lets us get information like the following if you print the batch
details.
Batch {
Kind: Draw
Viewport: 1200x1000
Framebuffer: 0
Program: 30
Uniform[00]:
matrix<0.0016670.0000000.0000000.0000000.000000-0.0020000.0000000.0000000.0000000.000000-0.0001000.000000-1.0000001.0000000.0000001.000000>
Uniform[01]:
matrix<2.0000000.0000000.0000000.0000000.0000002.0000000.0000000.0000000.0000000.0000001.0000000.0000000.0000000.0000000.0000001.000000>
Uniform[02]: 1f<1.000000>
Uniform[03]: rgb(213,208,204)
Uniform[04]: 1f<1.000000>
Uniform[05]: 2f<0.000000,0.000000>
Uniform[06]: GskRoundedRect 0x231e920: Bounds: (345.000000, 29.000000, 134.000000, 34.000000) Corners:
(0.000000, 0.000000) (5.000000, 5.000000) (5.000000, 5.000000) (0.000000, 0.000000)
Uniform[09]: 4f<0.000000,0.000000,1200.000000,1000.000000>
Uniform[10]: GskRoundedRect 0x231e8c0: Bounds: (52.000000, 46.000000, 1012.000000, 772.000000) Corners:
(16.000000, 16.000000) (16.000000, 16.000000) (0.000000, 0.000000) (0.000000, 0.000000)
}
gsk/next/gskglcommandqueue.c | 107 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 105 insertions(+), 2 deletions(-)
---
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index e04c6037ee..2db4a5d0ef 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -26,6 +26,7 @@
#include <gdk/gdkglcontextprivate.h>
#include <gdk/gdkmemorytextureprivate.h>
#include <gsk/gskdebugprivate.h>
+#include <gsk/gskroundedrectprivate.h>
#include <epoxy/gl.h>
#include <string.h>
@@ -165,6 +166,105 @@ G_STATIC_ASSERT (sizeof (GskGLCommandBatch) == 32);
G_DEFINE_TYPE (GskGLCommandQueue, gsk_gl_command_queue, G_TYPE_OBJECT)
+static inline void
+print_uniform (GskGLUniformFormat format,
+ guint array_count,
+ gconstpointer valueptr)
+{
+ const union {
+ graphene_matrix_t matrix[0];
+ GskRoundedRect rounded_rect[0];
+ float fval[0];
+ int ival[0];
+ guint uval[0];
+ } *data = valueptr;
+
+ switch (format)
+ {
+ case GSK_GL_UNIFORM_FORMAT_1F:
+ g_print ("1f<%f>", data->fval[0]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_2F:
+ g_print ("2f<%f,%f>", data->fval[0], data->fval[1]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_3F:
+ g_print ("3f<%f,%f,%f>", data->fval[0], data->fval[1], data->fval[2]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_4F:
+ g_print ("4f<%f,%f,%f,%f>", data->fval[0], data->fval[1], data->fval[2], data->fval[3]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_1I:
+ case GSK_GL_UNIFORM_FORMAT_TEXTURE:
+ g_print ("1i<%d>", data->ival[0]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_1UI:
+ g_print ("1ui<%u>", data->uval[0]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_COLOR: {
+ char *str = gdk_rgba_to_string (valueptr);
+ g_print ("%s", str);
+ g_free (str);
+ break;
+ }
+
+ case GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT: {
+ char *str = gsk_rounded_rect_to_string (valueptr);
+ g_print ("%s", str);
+ g_free (str);
+ break;
+ }
+
+ case GSK_GL_UNIFORM_FORMAT_MATRIX: {
+ float mat[16];
+ graphene_matrix_to_float (&data->matrix[0], mat);
+ g_print ("matrix<");
+ for (guint i = 0; i < G_N_ELEMENTS (mat)-1; i++)
+ g_print ("%f", mat[i]);
+ g_print ("%f>", mat[G_N_ELEMENTS (mat)-1]);
+ break;
+ }
+
+ case GSK_GL_UNIFORM_FORMAT_1FV:
+ case GSK_GL_UNIFORM_FORMAT_2FV:
+ case GSK_GL_UNIFORM_FORMAT_3FV:
+ case GSK_GL_UNIFORM_FORMAT_4FV:
+ /* non-V variants are -4 from V variants */
+ format -= 4;
+ g_print ("[");
+ for (guint i = 0; i < array_count; i++)
+ {
+ print_uniform (format, 0, valueptr);
+ if (i + 1 != array_count)
+ g_print (",");
+ valueptr = ((guint8*)valueptr + gsk_gl_uniform_format_size (format));
+ }
+ g_print ("]");
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_2I:
+ g_print ("2i<%d,%d>", data->ival[0], data->ival[1]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_3I:
+ g_print ("3i<%d,%d,%d>", data->ival[0], data->ival[1], data->ival[2]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_4I:
+ g_print ("3i<%d,%d,%d,%d>", data->ival[0], data->ival[1], data->ival[2], data->ival[3]);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_LAST:
+ default:
+ g_assert_not_reached ();
+ }
+}
+
static inline void
gsk_gl_command_queue_print_batch (GskGLCommandQueue *self,
const GskGLCommandBatch *batch)
@@ -199,9 +299,12 @@ gsk_gl_command_queue_print_batch (GskGLCommandQueue *self,
for (guint i = 0; i < batch->draw.uniform_count; i++)
{
- /* TODO: We could decode the format to print them too */
const GskGLCommandUniform *uniform = &g_array_index (self->batch_uniforms, GskGLCommandUniform,
batch->draw.uniform_offset + i);
- g_print (" Uniform[%02d]: \n", uniform->location);
+ g_print (" Uniform[%02d]: ", uniform->location);
+ print_uniform (uniform->info.format,
+ uniform->info.array_count,
+ gsk_gl_uniform_state_get_uniform_data (self->uniforms, uniform->info.offset));
+ g_print ("\n");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]