cogl/attribute: Drop constant attributes support
As it is never used, detected through codecoverage. Fixes adf0acbe0d5d378ecb862811e818107a0c420687 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4179>
This commit is contained in:
parent
fc0a8d343f
commit
c9fffb73f7
@ -63,21 +63,11 @@ struct _CoglAttribute
|
||||
const CoglAttributeNameState *name_state;
|
||||
gboolean normalized;
|
||||
|
||||
gboolean is_buffered;
|
||||
|
||||
union {
|
||||
struct {
|
||||
CoglAttributeBuffer *attribute_buffer;
|
||||
size_t stride;
|
||||
size_t offset;
|
||||
int n_components;
|
||||
CoglAttributeType type;
|
||||
} buffered;
|
||||
struct {
|
||||
CoglContext *context;
|
||||
CoglBoxedValue boxed;
|
||||
} constant;
|
||||
} d;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
|
@ -56,11 +56,7 @@ cogl_attribute_dispose (GObject *object)
|
||||
{
|
||||
CoglAttribute *attribute = COGL_ATTRIBUTE (object);
|
||||
|
||||
if (attribute->is_buffered)
|
||||
g_object_unref (attribute->d.buffered.attribute_buffer);
|
||||
else
|
||||
_cogl_boxed_value_destroy (&attribute->d.constant.boxed);
|
||||
|
||||
g_clear_object (&attribute->attribute_buffer);
|
||||
|
||||
G_OBJECT_CLASS (cogl_attribute_parent_class)->dispose (object);
|
||||
}
|
||||
@ -216,8 +212,6 @@ cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
|
||||
CoglBuffer *buffer = COGL_BUFFER (attribute_buffer);
|
||||
CoglContext *ctx = buffer->context;
|
||||
|
||||
attribute->is_buffered = TRUE;
|
||||
|
||||
attribute->name_state =
|
||||
g_hash_table_lookup (ctx->attribute_name_states_hash, name);
|
||||
if (!attribute->name_state)
|
||||
@ -229,11 +223,11 @@ cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
|
||||
attribute->name_state = name_state;
|
||||
}
|
||||
|
||||
attribute->d.buffered.attribute_buffer = g_object_ref (attribute_buffer);
|
||||
attribute->d.buffered.stride = stride;
|
||||
attribute->d.buffered.offset = offset;
|
||||
attribute->d.buffered.n_components = n_components;
|
||||
attribute->d.buffered.type = type;
|
||||
attribute->attribute_buffer = g_object_ref (attribute_buffer);
|
||||
attribute->stride = stride;
|
||||
attribute->offset = offset;
|
||||
attribute->n_components = n_components;
|
||||
attribute->type = type;
|
||||
|
||||
if (attribute->name_state->name_id != COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
|
||||
{
|
||||
@ -265,9 +259,8 @@ CoglAttributeBuffer *
|
||||
cogl_attribute_get_buffer (CoglAttribute *attribute)
|
||||
{
|
||||
g_return_val_if_fail (COGL_IS_ATTRIBUTE (attribute), NULL);
|
||||
g_return_val_if_fail (attribute->is_buffered, NULL);
|
||||
|
||||
return attribute->d.buffered.attribute_buffer;
|
||||
return attribute->attribute_buffer;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -388,8 +381,5 @@ _cogl_flush_attributes_state (CoglFramebuffer *framebuffer,
|
||||
int
|
||||
_cogl_attribute_get_n_components (CoglAttribute *attribute)
|
||||
{
|
||||
if (attribute->is_buffered)
|
||||
return attribute->d.buffered.n_components;
|
||||
else
|
||||
return attribute->d.constant.boxed.size;
|
||||
return attribute->n_components;
|
||||
}
|
||||
|
@ -105,63 +105,15 @@ setup_generic_buffered_attribute (CoglContext *context,
|
||||
return;
|
||||
|
||||
GE( context, glVertexAttribPointer (attrib_location,
|
||||
attribute->d.buffered.n_components,
|
||||
attribute->d.buffered.type,
|
||||
attribute->n_components,
|
||||
attribute->type,
|
||||
attribute->normalized,
|
||||
attribute->d.buffered.stride,
|
||||
base + attribute->d.buffered.offset) );
|
||||
attribute->stride,
|
||||
base + attribute->offset) );
|
||||
_cogl_bitmask_set (&context->enable_custom_attributes_tmp,
|
||||
attrib_location, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_generic_const_attribute (CoglContext *context,
|
||||
CoglPipeline *pipeline,
|
||||
CoglAttribute *attribute)
|
||||
{
|
||||
int name_index = attribute->name_state->name_index;
|
||||
int attrib_location =
|
||||
_cogl_pipeline_progend_glsl_get_attrib_location (pipeline, name_index);
|
||||
int columns;
|
||||
int i;
|
||||
|
||||
if (attrib_location == -1)
|
||||
return;
|
||||
|
||||
if (attribute->d.constant.boxed.type == COGL_BOXED_MATRIX)
|
||||
columns = attribute->d.constant.boxed.size;
|
||||
else
|
||||
columns = 1;
|
||||
|
||||
/* Note: it's ok to access a COGL_BOXED_FLOAT as a matrix with only
|
||||
* one column... */
|
||||
|
||||
switch (attribute->d.constant.boxed.size)
|
||||
{
|
||||
case 1:
|
||||
GE( context, glVertexAttrib1fv (attrib_location,
|
||||
attribute->d.constant.boxed.v.matrix));
|
||||
break;
|
||||
case 2:
|
||||
for (i = 0; i < columns; i++)
|
||||
GE( context, glVertexAttrib2fv (attrib_location + i,
|
||||
attribute->d.constant.boxed.v.matrix));
|
||||
break;
|
||||
case 3:
|
||||
for (i = 0; i < columns; i++)
|
||||
GE( context, glVertexAttrib3fv (attrib_location + i,
|
||||
attribute->d.constant.boxed.v.matrix));
|
||||
break;
|
||||
case 4:
|
||||
for (i = 0; i < columns; i++)
|
||||
GE( context, glVertexAttrib4fv (attrib_location + i,
|
||||
attribute->d.constant.boxed.v.matrix));
|
||||
break;
|
||||
default:
|
||||
g_warn_if_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
apply_attribute_enable_updates (CoglContext *context,
|
||||
CoglPipeline *pipeline)
|
||||
@ -273,8 +225,6 @@ _cogl_gl_flush_attributes_state (CoglDriver *driver,
|
||||
CoglBuffer *buffer;
|
||||
uint8_t *base;
|
||||
|
||||
if (attribute->is_buffered)
|
||||
{
|
||||
attribute_buffer = cogl_attribute_get_buffer (attribute);
|
||||
buffer = COGL_BUFFER (attribute_buffer);
|
||||
|
||||
@ -292,11 +242,6 @@ _cogl_gl_flush_attributes_state (CoglDriver *driver,
|
||||
|
||||
_cogl_buffer_gl_unbind (buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
setup_generic_const_attribute (ctx, pipeline, attribute);
|
||||
}
|
||||
}
|
||||
|
||||
apply_attribute_enable_updates (ctx, pipeline);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user