[gtk/wip/chergert/glproto: 759/920] check for valid uniform format




commit 793dc4f4757d9abf701649cd6251503caa0e5309
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jan 26 13:37:41 2021 -0800

    check for valid uniform format
    
    these might be invalid for locations that are skipped by the linker.

 gsk/next/gskgluniformstate.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/gsk/next/gskgluniformstate.c b/gsk/next/gskgluniformstate.c
index c5f9e7133c..086e1bc8f5 100644
--- a/gsk/next/gskgluniformstate.c
+++ b/gsk/next/gskgluniformstate.c
@@ -761,7 +761,14 @@ gsk_gl_uniform_state_snapshot (GskGLUniformState         *state,
     {
       GskGLUniformInfo *info = &g_array_index (program_info->uniform_info, GskGLUniformInfo, i);
 
-      if (!info->changed)
+#if G_ENABLE_DEBUG
+      {
+        guint size = uniform_sizes[info->format] * MAX (1, info->array_count);
+        g_assert (info->format == 0 || info->offset + size <= state->uniform_data->len);
+      }
+#endif
+
+      if (info->format == 0 || !info->changed)
         continue;
 
       callback (info, i, user_data);
@@ -799,9 +806,15 @@ gsk_gl_uniform_state_end_frame (GskGLUniformState *state)
       for (guint j = 0; j < program_info->uniform_info->len; j++)
         {
           GskGLUniformInfo *info = &g_array_index (program_info->uniform_info, GskGLUniformInfo, j);
-          guint size = uniform_sizes[info->format] * MAX (1, info->array_count);
+          guint size;
           guint offset;
 
+          if (info->format == 0)
+            continue;
+
+          /* Calculate how much size is needed for the uniform, including arrays */
+          size = uniform_sizes[info->format] * MAX (1, info->array_count);
+
           g_assert (info->offset + size <= state->uniform_data->len);
 
           alloc_uniform_data (buffer, size, &offset);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]