[gtk/wip/chergert/glproto: 428/493] make get_uniform() inline and remove fallbacks
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 428/493] make get_uniform() inline and remove fallbacks
- Date: Fri, 19 Feb 2021 02:25:22 +0000 (UTC)
commit 531c784c410f06a2b92bd219344b1e8363f5f215
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 9 15:01:05 2021 -0800
make get_uniform() inline and remove fallbacks
push those out into the slow path
gsk/next/gskgluniformstate.c | 40 ++++++++++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/gsk/next/gskgluniformstate.c b/gsk/next/gskgluniformstate.c
index 6961bd36f1..9a7686f9b5 100644
--- a/gsk/next/gskgluniformstate.c
+++ b/gsk/next/gskgluniformstate.c
@@ -221,12 +221,12 @@ alloc_uniform_data (GskGLUniformState *state,
}
static gpointer
-get_uniform (GskGLUniformState *state,
- guint program,
- GskGLUniformFormat format,
- guint array_count,
- guint location,
- GskGLUniformInfo **infoptr)
+create_uniform (GskGLUniformState *state,
+ guint program,
+ GskGLUniformFormat format,
+ guint array_count,
+ guint location,
+ GskGLUniformInfo **infoptr)
{
GskGLUniformProgram *program_info;
GskGLUniformInfo *info;
@@ -345,6 +345,34 @@ setup_info:
return state->values_buf + offset;
}
+static inline gpointer
+get_uniform (GskGLUniformState *state,
+ guint program,
+ GskGLUniformFormat format,
+ guint array_count,
+ guint location,
+ GskGLUniformInfo **infoptr)
+{
+ /* Fast path for common case (state already initialized) */
+ if G_LIKELY (program < state->program_info->len)
+ {
+ const GskGLUniformProgram *program_info = &g_array_index (state->program_info, GskGLUniformProgram,
program);
+
+ if G_LIKELY (location < program_info->uniform_info_len)
+ {
+ GskGLUniformInfo *info = &program_info->uniform_info[location];
+
+ if G_LIKELY (format == info->format && array_count <= info->array_count)
+ {
+ *infoptr = info;
+ return state->values_buf + info->offset;
+ }
+ }
+ }
+
+ return create_uniform (state, program, format, array_count, location, infoptr);
+}
+
void
gsk_gl_uniform_state_set1f (GskGLUniformState *state,
guint program,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]