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;
|
const CoglAttributeNameState *name_state;
|
||||||
gboolean normalized;
|
gboolean normalized;
|
||||||
|
|
||||||
gboolean is_buffered;
|
CoglAttributeBuffer *attribute_buffer;
|
||||||
|
size_t stride;
|
||||||
union {
|
size_t offset;
|
||||||
struct {
|
int n_components;
|
||||||
CoglAttributeBuffer *attribute_buffer;
|
CoglAttributeType type;
|
||||||
size_t stride;
|
|
||||||
size_t offset;
|
|
||||||
int n_components;
|
|
||||||
CoglAttributeType type;
|
|
||||||
} buffered;
|
|
||||||
struct {
|
|
||||||
CoglContext *context;
|
|
||||||
CoglBoxedValue boxed;
|
|
||||||
} constant;
|
|
||||||
} d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -56,11 +56,7 @@ cogl_attribute_dispose (GObject *object)
|
|||||||
{
|
{
|
||||||
CoglAttribute *attribute = COGL_ATTRIBUTE (object);
|
CoglAttribute *attribute = COGL_ATTRIBUTE (object);
|
||||||
|
|
||||||
if (attribute->is_buffered)
|
g_clear_object (&attribute->attribute_buffer);
|
||||||
g_object_unref (attribute->d.buffered.attribute_buffer);
|
|
||||||
else
|
|
||||||
_cogl_boxed_value_destroy (&attribute->d.constant.boxed);
|
|
||||||
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (cogl_attribute_parent_class)->dispose (object);
|
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);
|
CoglBuffer *buffer = COGL_BUFFER (attribute_buffer);
|
||||||
CoglContext *ctx = buffer->context;
|
CoglContext *ctx = buffer->context;
|
||||||
|
|
||||||
attribute->is_buffered = TRUE;
|
|
||||||
|
|
||||||
attribute->name_state =
|
attribute->name_state =
|
||||||
g_hash_table_lookup (ctx->attribute_name_states_hash, name);
|
g_hash_table_lookup (ctx->attribute_name_states_hash, name);
|
||||||
if (!attribute->name_state)
|
if (!attribute->name_state)
|
||||||
@ -229,11 +223,11 @@ cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
|
|||||||
attribute->name_state = name_state;
|
attribute->name_state = name_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute->d.buffered.attribute_buffer = g_object_ref (attribute_buffer);
|
attribute->attribute_buffer = g_object_ref (attribute_buffer);
|
||||||
attribute->d.buffered.stride = stride;
|
attribute->stride = stride;
|
||||||
attribute->d.buffered.offset = offset;
|
attribute->offset = offset;
|
||||||
attribute->d.buffered.n_components = n_components;
|
attribute->n_components = n_components;
|
||||||
attribute->d.buffered.type = type;
|
attribute->type = type;
|
||||||
|
|
||||||
if (attribute->name_state->name_id != COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
|
if (attribute->name_state->name_id != COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
|
||||||
{
|
{
|
||||||
@ -265,9 +259,8 @@ CoglAttributeBuffer *
|
|||||||
cogl_attribute_get_buffer (CoglAttribute *attribute)
|
cogl_attribute_get_buffer (CoglAttribute *attribute)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (COGL_IS_ATTRIBUTE (attribute), NULL);
|
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
|
static gboolean
|
||||||
@ -388,8 +381,5 @@ _cogl_flush_attributes_state (CoglFramebuffer *framebuffer,
|
|||||||
int
|
int
|
||||||
_cogl_attribute_get_n_components (CoglAttribute *attribute)
|
_cogl_attribute_get_n_components (CoglAttribute *attribute)
|
||||||
{
|
{
|
||||||
if (attribute->is_buffered)
|
return attribute->n_components;
|
||||||
return attribute->d.buffered.n_components;
|
|
||||||
else
|
|
||||||
return attribute->d.constant.boxed.size;
|
|
||||||
}
|
}
|
||||||
|
@ -105,63 +105,15 @@ setup_generic_buffered_attribute (CoglContext *context,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
GE( context, glVertexAttribPointer (attrib_location,
|
GE( context, glVertexAttribPointer (attrib_location,
|
||||||
attribute->d.buffered.n_components,
|
attribute->n_components,
|
||||||
attribute->d.buffered.type,
|
attribute->type,
|
||||||
attribute->normalized,
|
attribute->normalized,
|
||||||
attribute->d.buffered.stride,
|
attribute->stride,
|
||||||
base + attribute->d.buffered.offset) );
|
base + attribute->offset) );
|
||||||
_cogl_bitmask_set (&context->enable_custom_attributes_tmp,
|
_cogl_bitmask_set (&context->enable_custom_attributes_tmp,
|
||||||
attrib_location, TRUE);
|
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
|
static void
|
||||||
apply_attribute_enable_updates (CoglContext *context,
|
apply_attribute_enable_updates (CoglContext *context,
|
||||||
CoglPipeline *pipeline)
|
CoglPipeline *pipeline)
|
||||||
@ -273,29 +225,22 @@ _cogl_gl_flush_attributes_state (CoglDriver *driver,
|
|||||||
CoglBuffer *buffer;
|
CoglBuffer *buffer;
|
||||||
uint8_t *base;
|
uint8_t *base;
|
||||||
|
|
||||||
if (attribute->is_buffered)
|
attribute_buffer = cogl_attribute_get_buffer (attribute);
|
||||||
{
|
buffer = COGL_BUFFER (attribute_buffer);
|
||||||
attribute_buffer = cogl_attribute_get_buffer (attribute);
|
|
||||||
buffer = COGL_BUFFER (attribute_buffer);
|
|
||||||
|
|
||||||
/* Note: we don't try and catch errors with binding buffers
|
/* Note: we don't try and catch errors with binding buffers
|
||||||
* here since OOM errors at this point indicate that nothing
|
* here since OOM errors at this point indicate that nothing
|
||||||
* has yet been uploaded to attribute buffer which we
|
* has yet been uploaded to attribute buffer which we
|
||||||
* consider to be a programmer error.
|
* consider to be a programmer error.
|
||||||
*/
|
*/
|
||||||
base =
|
base =
|
||||||
_cogl_buffer_gl_bind (buffer,
|
_cogl_buffer_gl_bind (buffer,
|
||||||
COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
|
COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
|
setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
|
||||||
|
|
||||||
_cogl_buffer_gl_unbind (buffer);
|
_cogl_buffer_gl_unbind (buffer);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setup_generic_const_attribute (ctx, pipeline, attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_attribute_enable_updates (ctx, pipeline);
|
apply_attribute_enable_updates (ctx, pipeline);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user