[gtk/wip/baedert/for-master] gl renderer: Proper state tracking for color matrix ops
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master] gl renderer: Proper state tracking for color matrix ops
- Date: Fri, 18 Dec 2020 17:38:07 +0000 (UTC)
commit f69205823ce6515154e94875d5fec0f92f23f3f9
Author: Timm Bäder <mail baedert org>
Date: Fri Dec 18 18:28:17 2020 +0100
gl renderer: Proper state tracking for color matrix ops
gsk/gl/gskglrenderer.c | 13 +++++++++----
gsk/gl/gskglrenderops.c | 28 ++++++++++++++--------------
gsk/gl/opbuffer.h | 3 ++-
3 files changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index a1b9fbed2c..1591b45f1e 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -2856,10 +2856,15 @@ static inline void
apply_color_matrix_op (const Program *program,
const OpColorMatrix *op)
{
- float mat[16];
- OP_PRINT (" -> Color Matrix");
- graphene_matrix_to_float (op->matrix, mat);
- glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat);
+ OP_PRINT (" -> Color matrix. Send matrix: %d. Send offset: %d.",
+ op->matrix.send, op->offset.send);
+
+ if (op->matrix.send)
+ {
+ float mat[16];
+ graphene_matrix_to_float (op->matrix.value, mat);
+ glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat);
+ }
if (op->offset.send)
{
diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c
index be7eff6fba..d7639162ad 100644
--- a/gsk/gl/gskglrenderops.c
+++ b/gsk/gl/gskglrenderops.c
@@ -533,30 +533,30 @@ ops_set_color_matrix (RenderOpBuilder *builder,
const graphene_vec4_t *offset)
{
ProgramState *current_program_state = get_current_program_state (builder);
+ const bool offset_equal = graphene_vec4_equal (offset, ¤t_program_state->color_matrix.offset);
+ const bool matrix_equal = graphene_matrix_equal_fast (matrix,
+ ¤t_program_state->color_matrix.matrix);
OpColorMatrix *op;
- bool offset_equal;
- offset_equal = memcmp (offset,
- ¤t_program_state->color_matrix.offset,
- sizeof (graphene_vec4_t)) == 0;
-
- if (memcmp (matrix,
- ¤t_program_state->color_matrix.matrix,
- sizeof (graphene_matrix_t)) == 0 &&
- offset_equal)
+ if (offset_equal && matrix_equal)
return;
- current_program_state->color_matrix.matrix = *matrix;
-
op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX);
- op->matrix = matrix;
+
+ if (!matrix_equal)
+ {
+ current_program_state->color_matrix.matrix = *matrix;
+ op->matrix.value = matrix;
+ op->matrix.send = TRUE;
+ }
+ else
+ op->matrix.send = FALSE;
if (!offset_equal)
{
+ current_program_state->color_matrix.offset = *offset;
op->offset.value = offset;
op->offset.send = TRUE;
-
- current_program_state->color_matrix.offset = *offset;
}
else
op->offset.send = FALSE;
diff --git a/gsk/gl/opbuffer.h b/gsk/gl/opbuffer.h
index 08f48b7c5f..db9b5c9425 100644
--- a/gsk/gl/opbuffer.h
+++ b/gsk/gl/opbuffer.h
@@ -53,6 +53,7 @@ typedef struct { GskRoundedRect value; guint send: 1; guint send_corners: 1; } R
typedef struct { const GdkRGBA *value; guint send: 1; } RGBAUniformValue;
typedef struct { const graphene_vec4_t *value; guint send: 1; } Vec4UniformValue;
typedef struct { const GskColorStop *value; guint send: 1; } ColorStopUniformValue;
+typedef struct { const graphene_matrix_t *value; guint send: 1; } MatrixUniformValue;
/* OpNode are allocated within OpBuffer.pos, but we keep
* a secondary index into the locations of that buffer
@@ -167,7 +168,7 @@ typedef struct
typedef struct
{
- const graphene_matrix_t *matrix;
+ MatrixUniformValue matrix;
Vec4UniformValue offset;
} OpColorMatrix;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]