[gtk/wip/chergert/glproto] tweak order we check things
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto] tweak order we check things
- Date: Thu, 4 Feb 2021 05:28:47 +0000 (UTC)
commit 747d66e29cae1f24609c1bef342f59e35cd8c191
Author: Christian Hergert <chergert redhat com>
Date: Wed Feb 3 21:36:34 2021 -0800
tweak order we check things
also avoid the second matrix compare
we are mostly dealing with things that will memcmp equal, so just use the fast
version here.
gsk/next/gskgluniformstate.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/gsk/next/gskgluniformstate.c b/gsk/next/gskgluniformstate.c
index 1682ebdabe..6a5951cc88 100644
--- a/gsk/next/gskgluniformstate.c
+++ b/gsk/next/gskgluniformstate.c
@@ -236,7 +236,7 @@ get_uniform (GskGLUniformState *state,
g_assert (location < GL_MAX_UNIFORM_LOCATIONS || location == (guint)-1);
/* Handle unused uniforms gracefully */
- if (location == (guint)-1)
+ if G_UNLIKELY (location == (guint)-1)
return NULL;
/* Fast path for common case (state already initialized) */
@@ -247,9 +247,6 @@ get_uniform (GskGLUniformState *state,
{
info = &g_array_index (program_info->uniform_info, GskGLUniformInfo, location);
- if (info->format == 0)
- goto setup_info;
-
if G_LIKELY (format == info->format)
{
if G_LIKELY (array_count <= info->array_count)
@@ -268,6 +265,10 @@ get_uniform (GskGLUniformState *state,
*/
goto setup_info;
}
+ else if (info->format == 0)
+ {
+ goto setup_info;
+ }
else
{
g_critical ("Attempt to access uniform with different type of value "
@@ -606,12 +607,8 @@ gsk_gl_uniform_state_set_matrix (GskGLUniformState *state,
if ((u = get_uniform (state, program, GSK_GL_UNIFORM_FORMAT_MATRIX, 1, location, &info)))
{
- if (!info->initial)
- {
- if (graphene_matrix_equal_fast (u, matrix) ||
- graphene_matrix_equal (u, matrix))
- return;
- }
+ if (!info->initial && graphene_matrix_equal_fast (u, matrix))
+ return;
REPLACE_UNIFORM (info, u, GSK_GL_UNIFORM_FORMAT_MATRIX, 1);
memcpy (u, matrix, sizeof *matrix);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]