[gtk/wip/chergert/glproto: 309/526] check for valid uniform format
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 309/526] check for valid uniform format
- Date: Tue, 16 Feb 2021 01:14:33 +0000 (UTC)
commit c63090acfc84de7d203f6521cfa8a51a8247a353
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]