[gtk/wip/chergert/glproto] make bitfield go a bit further
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto] make bitfield go a bit further
- Date: Wed, 17 Feb 2021 04:49:24 +0000 (UTC)
commit c3154df7a747802e0a24ccb971a1a29c39919edf
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 16 20:49:09 2021 -0800
make bitfield go a bit further
two more bits out of nowhere!
gsk/next/gskgluniformstate.c | 5 +++--
gsk/next/gskgluniformstateprivate.h | 15 +++++++++------
2 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gsk/next/gskgluniformstate.c b/gsk/next/gskgluniformstate.c
index 8bda3acf48..4422b05552 100644
--- a/gsk/next/gskgluniformstate.c
+++ b/gsk/next/gskgluniformstate.c
@@ -101,7 +101,7 @@ gsk_gl_uniform_state_init_value (GskGLUniformState *state,
guint offset;
g_assert (state != NULL);
- g_assert (array_count < 256);
+ g_assert (array_count < 64);
g_assert ((int)format >= 0 && format < GSK_GL_UNIFORM_FORMAT_LAST);
g_assert (format > 0);
g_assert (program != NULL);
@@ -197,7 +197,8 @@ gsk_gl_uniform_state_end_frame (GskGLUniformState *state)
/* Adjust alignment for value */
allocator += gsk_gl_uniform_state_align (allocator, size);
- info->info.offset = allocator;
+ /* Offset is in slots of 4 bytes */
+ info->info.offset = allocator / 4;
info->info.initial = TRUE;
info->stamp = 0;
diff --git a/gsk/next/gskgluniformstateprivate.h b/gsk/next/gskgluniformstateprivate.h
index 6c4f7dbd2c..db670a224f 100644
--- a/gsk/next/gskgluniformstateprivate.h
+++ b/gsk/next/gskgluniformstateprivate.h
@@ -139,7 +139,7 @@ gpointer gsk_gl_uniform_state_init_value (GskGLUniformState
GskGLUniformInfoElement **infoptr);
#define gsk_gl_uniform_state_get_uniform_data(state,offset) \
- ((gconstpointer)(state->values_buf + offset))
+ ((gconstpointer)(state->values_buf + (offset*4)))
#define gsk_gl_uniform_state_snapshot(state, program_info, callback, user_data) \
G_STMT_START { \
@@ -151,7 +151,7 @@ gpointer gsk_gl_uniform_state_init_value (GskGLUniformState
g_assert (location < GL_MAX_UNIFORM_LOCATIONS); \
g_assert (location < program_info->n_uniforms); \
\
- if (info->info.format > 0) \
+ if (info->info.format > 0) \
callback (&info->info, location, user_data); \
} \
} G_STMT_END
@@ -182,7 +182,7 @@ gsk_gl_uniform_state_get_value (GskGLUniformState *state,
if G_LIKELY (format == info->info.format && array_count <= info->info.array_count)
{
*infoptr = info;
- return state->values_buf + info->info.offset;
+ return state->values_buf + (info->info.offset*4);
}
return gsk_gl_uniform_state_init_value (state, program, format, array_count, location, infoptr);
@@ -215,22 +215,25 @@ gsk_gl_uniform_state_realloc (GskGLUniformState *state,
state->values_buf = g_realloc (state->values_buf, state->values_len);
}
- *offset = state->values_pos + padding;
+ /* offsets are in slots of 4 to use fewer bits */
+ g_assert ((state->values_pos + padding) % 4 == 0);
+ *offset = (state->values_pos + padding) / 4;
state->values_pos += padding + size;
- return state->values_buf + *offset;
+ return state->values_buf + (*offset * 4);
}
#define GSK_GL_UNIFORM_STATE_REPLACE(info, u, type, count) \
G_STMT_START { \
if ((info)->info.initial && count == (info)->info.array_count) \
{ \
- u = (gpointer)(state->values_buf + (info)->info.offset); \
+ u = (gpointer)(state->values_buf + ((info)->info.offset*4)); \
} \
else \
{ \
guint offset; \
u = gsk_gl_uniform_state_realloc (state, sizeof(type) * MAX (1, count), &offset); \
+ g_assert (offset < (1 << 20)); \
(info)->info.offset = offset; \
/* We might have increased array length */ \
(info)->info.array_count = count; \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]