1
0
Fork 0

cogl: Collapse some COGL_PIPELINE_{VERT,FRAG,PROG}END arrays

There is only GLSL now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/819
This commit is contained in:
Adam Jackson 2019-09-30 12:07:58 -04:00
parent e922c640ef
commit 5aa971b177
9 changed files with 33 additions and 258 deletions

View file

@ -390,14 +390,10 @@ _cogl_pipeline_layer_pre_change_notify (CoglPipeline *required_owner,
* have a single owner and can only be associated with a single
* backend that needs to be notified of the layer change...
*/
if (required_owner->progend != COGL_PIPELINE_PROGEND_UNDEFINED)
{
const CoglPipelineProgend *progend =
_cogl_pipeline_progends[required_owner->progend];
const CoglPipelineFragend *fragend =
_cogl_pipeline_fragends[progend->fragend];
const CoglPipelineVertend *vertend =
_cogl_pipeline_vertends[progend->vertend];
const CoglPipelineProgend *progend = _cogl_pipeline_progend;
const CoglPipelineFragend *fragend = _cogl_pipeline_fragend;
const CoglPipelineVertend *vertend = _cogl_pipeline_vertend;
if (fragend->layer_pre_change_notify)
fragend->layer_pre_change_notify (required_owner, layer, change);

View file

@ -49,25 +49,12 @@
#include <glib.h>
#if defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2)
#define COGL_PIPELINE_PROGEND_GLSL 0
#define COGL_PIPELINE_VERTEND_GLSL 0
#define COGL_PIPELINE_FRAGEND_GLSL 0
#define COGL_PIPELINE_N_PROGENDS 1
#define COGL_PIPELINE_N_VERTENDS 1
#define COGL_PIPELINE_N_FRAGENDS 1
#else /* defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2) */
#if !(defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2))
#error No drivers defined
#endif /* defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2) */
#define COGL_PIPELINE_PROGEND_DEFAULT 0
#define COGL_PIPELINE_PROGEND_UNDEFINED 3
/* XXX: should I rename these as
* COGL_PIPELINE_STATE_INDEX_XYZ... ?
*/
@ -413,12 +400,6 @@ struct _CoglPipeline
* where the pipeline originates from */
unsigned int has_static_breadcrumb:1;
#endif
/* There are multiple fragment and vertex processing backends for
* CoglPipeline, glsl, arbfp and fixed that are bundled under a
* "progend". This identifies the backend being used for the
* pipeline. */
unsigned int progend:3;
};
typedef struct _CoglPipelineFragend
@ -462,8 +443,6 @@ typedef struct _CoglPipelineVertend
typedef struct
{
int vertend;
int fragend;
gboolean (*start) (CoglPipeline *pipeline);
void (*end) (CoglPipeline *pipeline,
unsigned long pipelines_difference);
@ -479,12 +458,9 @@ typedef struct
void (* pre_paint) (CoglPipeline *pipeline, CoglFramebuffer *framebuffer);
} CoglPipelineProgend;
extern const CoglPipelineFragend *
_cogl_pipeline_fragends[COGL_PIPELINE_N_FRAGENDS];
extern const CoglPipelineVertend *
_cogl_pipeline_vertends[COGL_PIPELINE_N_VERTENDS];
extern const CoglPipelineProgend *
_cogl_pipeline_progends[];
extern const CoglPipelineFragend *_cogl_pipeline_fragend;
extern const CoglPipelineVertend *_cogl_pipeline_vertend;
extern const CoglPipelineProgend *_cogl_pipeline_progend;
void
_cogl_pipeline_init_default_pipeline (void);

View file

@ -805,9 +805,6 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
*/
_cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE);
if (program != NULL)
_cogl_pipeline_set_progend (pipeline, COGL_PIPELINE_PROGEND_UNDEFINED);
/* If we are the current authority see if we can revert to one of our
* ancestors being the authority */
if (pipeline == authority &&

View file

@ -58,24 +58,13 @@ static void _cogl_pipeline_free (CoglPipeline *tex);
static void recursively_free_layer_caches (CoglPipeline *pipeline);
static gboolean _cogl_pipeline_is_weak (CoglPipeline *pipeline);
const CoglPipelineFragend *_cogl_pipeline_fragends[COGL_PIPELINE_N_FRAGENDS];
const CoglPipelineVertend *_cogl_pipeline_vertends[COGL_PIPELINE_N_VERTENDS];
/* The 'MAX' here is so that we don't define an empty array when there
are no progends */
const CoglPipelineProgend *
_cogl_pipeline_progends[MAX (COGL_PIPELINE_N_PROGENDS, 1)];
const CoglPipelineFragend *_cogl_pipeline_fragend;
const CoglPipelineVertend *_cogl_pipeline_vertend;
const CoglPipelineProgend *_cogl_pipeline_progend;
#ifdef COGL_PIPELINE_FRAGEND_GLSL
#include "driver/gl/cogl-pipeline-fragend-glsl-private.h"
#endif
#ifdef COGL_PIPELINE_VERTEND_GLSL
#include "driver/gl/cogl-pipeline-vertend-glsl-private.h"
#endif
#ifdef COGL_PIPELINE_PROGEND_GLSL
#include "driver/gl/cogl-pipeline-progend-glsl-private.h"
#endif
COGL_OBJECT_DEFINE (Pipeline, pipeline);
COGL_GTYPE_DEFINE_CLASS (Pipeline, pipeline);
@ -103,25 +92,14 @@ _cogl_pipeline_init_default_pipeline (void)
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* Take this opportunity to setup the backends... */
#ifdef COGL_PIPELINE_FRAGEND_GLSL
_cogl_pipeline_fragends[COGL_PIPELINE_FRAGEND_GLSL] =
&_cogl_pipeline_glsl_fragend;
#endif
#ifdef COGL_PIPELINE_PROGEND_GLSL
_cogl_pipeline_progends[COGL_PIPELINE_PROGEND_GLSL] =
&_cogl_pipeline_glsl_progend;
#endif
#ifdef COGL_PIPELINE_VERTEND_GLSL
_cogl_pipeline_vertends[COGL_PIPELINE_VERTEND_GLSL] =
&_cogl_pipeline_glsl_vertend;
#endif
_cogl_pipeline_fragend = &_cogl_pipeline_glsl_fragend;
_cogl_pipeline_progend = &_cogl_pipeline_glsl_progend;
_cogl_pipeline_vertend = &_cogl_pipeline_glsl_vertend;
_cogl_pipeline_node_init (COGL_NODE (pipeline));
pipeline->is_weak = FALSE;
pipeline->journal_ref_count = 0;
pipeline->progend = COGL_PIPELINE_PROGEND_UNDEFINED;
pipeline->differences = COGL_PIPELINE_STATE_ALL_SPARSE;
pipeline->real_blend_enable = FALSE;
@ -306,8 +284,6 @@ _cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak)
pipeline->deprecated_get_layers_list = NULL;
pipeline->deprecated_get_layers_list_dirty = TRUE;
pipeline->progend = src->progend;
pipeline->has_static_breadcrumb = FALSE;
pipeline->age = 0;
@ -840,12 +816,6 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline,
return FALSE;
}
void
_cogl_pipeline_set_progend (CoglPipeline *pipeline, int progend)
{
pipeline->progend = progend;
}
static void
_cogl_pipeline_copy_differences (CoglPipeline *dest,
CoglPipeline *src,
@ -1179,28 +1149,21 @@ _cogl_pipeline_pre_change_notify (CoglPipeline *pipeline,
*/
if (!from_layer_change)
{
int i;
const CoglPipelineProgend *progend = _cogl_pipeline_progend;
const CoglPipelineVertend *vertend = _cogl_pipeline_vertend;
const CoglPipelineFragend *fragend = _cogl_pipeline_fragend;
for (i = 0; i < COGL_PIPELINE_N_PROGENDS; i++)
{
const CoglPipelineProgend *progend = _cogl_pipeline_progends[i];
const CoglPipelineVertend *vertend =
_cogl_pipeline_vertends[progend->vertend];
const CoglPipelineFragend *fragend =
_cogl_pipeline_fragends[progend->fragend];
if (vertend->pipeline_pre_change_notify)
vertend->pipeline_pre_change_notify (pipeline, change, new_color);
if (vertend->pipeline_pre_change_notify)
vertend->pipeline_pre_change_notify (pipeline, change, new_color);
/* TODO: make the vertend and fragend implementation details
* of the progend */
/* TODO: make the vertend and fragend implementation details
* of the progend */
if (fragend->pipeline_pre_change_notify)
fragend->pipeline_pre_change_notify (pipeline, change, new_color);
if (fragend->pipeline_pre_change_notify)
fragend->pipeline_pre_change_notify (pipeline, change, new_color);
if (progend->pipeline_pre_change_notify)
progend->pipeline_pre_change_notify (pipeline, change, new_color);
}
if (progend->pipeline_pre_change_notify)
progend->pipeline_pre_change_notify (pipeline, change, new_color);
}
/* There may be an arbitrary tree of descendants of this pipeline;

View file

@ -156,8 +156,6 @@ foreach_changed_bit_and_save (CoglContext *context,
_cogl_bitmask_set_bits (current_bits, new_bits);
}
#ifdef COGL_PIPELINE_PROGEND_GLSL
static void
setup_generic_buffered_attribute (CoglContext *context,
CoglPipeline *pipeline,
@ -229,136 +227,6 @@ setup_generic_const_attribute (CoglContext *context,
}
}
#endif /* COGL_PIPELINE_PROGEND_GLSL */
static void
setup_legacy_buffered_attribute (CoglContext *ctx,
CoglPipeline *pipeline,
CoglAttribute *attribute,
uint8_t *base)
{
switch (attribute->name_state->name_id)
{
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
_cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY, TRUE);
GE (ctx, glColorPointer (attribute->d.buffered.n_components,
attribute->d.buffered.type,
attribute->d.buffered.stride,
base + attribute->d.buffered.offset));
break;
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
_cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY, TRUE);
GE (ctx, glNormalPointer (attribute->d.buffered.type,
attribute->d.buffered.stride,
base + attribute->d.buffered.offset));
break;
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
{
int layer_number = attribute->name_state->layer_number;
const CoglPipelineGetLayerFlags flags =
COGL_PIPELINE_GET_LAYER_NO_CREATE;
CoglPipelineLayer *layer =
_cogl_pipeline_get_layer_with_flags (pipeline, layer_number, flags);
if (layer)
{
int unit = _cogl_pipeline_layer_get_unit_index (layer);
_cogl_bitmask_set (&ctx->enable_texcoord_attributes_tmp,
unit,
TRUE);
GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));
GE (ctx, glTexCoordPointer (attribute->d.buffered.n_components,
attribute->d.buffered.type,
attribute->d.buffered.stride,
base + attribute->d.buffered.offset));
}
break;
}
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
_cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY, TRUE);
GE (ctx, glVertexPointer (attribute->d.buffered.n_components,
attribute->d.buffered.type,
attribute->d.buffered.stride,
base + attribute->d.buffered.offset));
break;
case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
#ifdef COGL_PIPELINE_PROGEND_GLSL
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE))
setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
#endif
break;
default:
g_warn_if_reached ();
}
}
static void
setup_legacy_const_attribute (CoglContext *ctx,
CoglPipeline *pipeline,
CoglAttribute *attribute)
{
#ifdef COGL_PIPELINE_PROGEND_GLSL
if (attribute->name_state->name_id == COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
{
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE))
setup_generic_const_attribute (ctx, pipeline, attribute);
}
else
#endif
{
float vector[4] = { 0, 0, 0, 1 };
float *boxed = attribute->d.constant.boxed.v.float_value;
int n_components = attribute->d.constant.boxed.size;
int i;
for (i = 0; i < n_components; i++)
vector[i] = boxed[i];
switch (attribute->name_state->name_id)
{
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
GE (ctx, glColor4f (vector[0], vector[1], vector[2], vector[3]));
break;
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
GE (ctx, glNormal3f (vector[0], vector[1], vector[2]));
break;
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
{
int layer_number = attribute->name_state->layer_number;
const CoglPipelineGetLayerFlags flags =
COGL_PIPELINE_GET_LAYER_NO_CREATE;
CoglPipelineLayer *layer =
_cogl_pipeline_get_layer_with_flags (pipeline,
layer_number,
flags);
if (layer)
{
int unit = _cogl_pipeline_layer_get_unit_index (layer);
GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));
GE (ctx, glMultiTexCoord4f (vector[0],
vector[1],
vector[2],
vector[3]));
}
break;
}
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
GE (ctx, glVertex4f (vector[0], vector[1], vector[2], vector[3]));
break;
default:
g_warn_if_reached ();
}
}
}
static void
apply_attribute_enable_updates (CoglContext *context,
CoglPipeline *pipeline)
@ -502,19 +370,13 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
NULL);
if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL)
setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
else
setup_legacy_buffered_attribute (ctx, pipeline, attribute, base);
setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
_cogl_buffer_gl_unbind (buffer);
}
else
{
if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL)
setup_generic_const_attribute (ctx, pipeline, attribute);
else
setup_legacy_const_attribute (ctx, pipeline, attribute);
setup_generic_const_attribute (ctx, pipeline, attribute);
}
}

View file

@ -44,8 +44,6 @@
#include "cogl-list.h"
#include "driver/gl/cogl-util-gl-private.h"
#ifdef COGL_PIPELINE_FRAGEND_GLSL
#include "cogl-context-private.h"
#include "cogl-object-private.h"
#include "cogl-pipeline-cache.h"
@ -1123,6 +1121,3 @@ const CoglPipelineFragend _cogl_pipeline_glsl_fragend =
_cogl_pipeline_fragend_glsl_pre_change_notify,
_cogl_pipeline_fragend_glsl_layer_pre_change_notify
};
#endif /* COGL_PIPELINE_FRAGEND_GLSL */

View file

@ -998,7 +998,6 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx,
unsigned long pipelines_difference;
int n_layers;
unsigned long *layer_differences;
int i;
CoglTextureUnit *unit1;
const CoglPipelineProgend *progend;
@ -1113,23 +1112,19 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx,
* with the given progend so we will simply use that to avoid
* fallback code paths.
*/
if (pipeline->progend == COGL_PIPELINE_PROGEND_UNDEFINED)
_cogl_pipeline_set_progend (pipeline, COGL_PIPELINE_PROGEND_DEFAULT);
for (i = pipeline->progend;
i < COGL_PIPELINE_N_PROGENDS;
i++, _cogl_pipeline_set_progend (pipeline, i))
do
{
const CoglPipelineVertend *vertend;
const CoglPipelineFragend *fragend;
CoglPipelineAddLayerState state;
progend = _cogl_pipeline_progends[i];
progend = _cogl_pipeline_progend;
if (G_UNLIKELY (!progend->start (pipeline)))
continue;
vertend = _cogl_pipeline_vertends[progend->vertend];
vertend = _cogl_pipeline_vertend;
vertend->start (pipeline,
n_layers,
@ -1159,7 +1154,7 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx,
* ctx->codegen_source_buffer as a scratch buffer.
*/
fragend = _cogl_pipeline_fragends[progend->fragend];
fragend = _cogl_pipeline_fragend;
state.fragend = fragend;
fragend->start (pipeline,
@ -1180,6 +1175,7 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx,
progend->end (pipeline, pipelines_difference);
break;
}
while (0);
/* FIXME: This reference is actually resulting in lots of
* copy-on-write reparenting because one-shot pipelines end up
@ -1200,13 +1196,13 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx,
done:
progend = _cogl_pipeline_progends[pipeline->progend];
progend = _cogl_pipeline_progend;
/* We can't assume the color will be retained between flushes when
* using the glsl progend because the generic attribute values are
* not stored as part of the program object so they could be
* overridden by any attribute changes in another program */
if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL && !with_color_attrib)
if (!with_color_attrib)
{
int attribute;
CoglPipeline *authority =

View file

@ -42,8 +42,6 @@
#include "driver/gl/cogl-util-gl-private.h"
#include "driver/gl/cogl-pipeline-opengl-private.h"
#ifdef COGL_PIPELINE_PROGEND_GLSL
#include "cogl-context-private.h"
#include "cogl-object-private.h"
#include "cogl-pipeline-cache.h"
@ -1056,13 +1054,9 @@ update_float_uniform (CoglPipeline *pipeline,
const CoglPipelineProgend _cogl_pipeline_glsl_progend =
{
COGL_PIPELINE_VERTEND_GLSL,
COGL_PIPELINE_FRAGEND_GLSL,
_cogl_pipeline_progend_glsl_start,
_cogl_pipeline_progend_glsl_end,
_cogl_pipeline_progend_glsl_pre_change_notify,
_cogl_pipeline_progend_glsl_layer_pre_change_notify,
_cogl_pipeline_progend_glsl_pre_paint
};
#endif /* COGL_PIPELINE_PROGEND_GLSL */

View file

@ -42,8 +42,6 @@
#include "driver/gl/cogl-util-gl-private.h"
#include "driver/gl/cogl-pipeline-opengl-private.h"
#ifdef COGL_PIPELINE_VERTEND_GLSL
#include "cogl-context-private.h"
#include "cogl-object-private.h"
#include "cogl-pipeline-state-private.h"
@ -668,5 +666,3 @@ UNIT_TEST (check_point_size_shader,
/* The fourth pipeline should be exactly the same as the first */
g_assert (shader_states[0] == shader_states[3]);
}
#endif /* COGL_PIPELINE_VERTEND_GLSL */