mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
d739892a5c
We've started seeing cases where we want to allocate lots of one-shot primitives per-frame and the cost of allocating primitives becomes important in this case since it can start being noticeable in profiles. The main cost for allocating primitives was the GArray allocation and appending the attributes to the array. This updates the code to simply over allocate the primitive storage so we can embed the list of attributes directly in that allocation. If the user later sets new attributes and there isn't enough embedded space then a separate slice allocation for the new attributes is made but still this should be far less costly than using a GArray as before. Most of the time we would expect when setting new attributes there will still be the same number of attributes, so the embedded space can simple be reused. Reviewed-by: Neil Roberts <neil@linux.intel.com>
60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
/*
|
|
* Cogl
|
|
*
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
*
|
|
* Copyright (C) 2010 Intel Corporation.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library. If not, see
|
|
* <http://www.gnu.org/licenses/>.
|
|
*
|
|
*
|
|
*
|
|
* Authors:
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
*/
|
|
|
|
#ifndef __COGL_PRIMITIVE_PRIVATE_H
|
|
#define __COGL_PRIMITIVE_PRIVATE_H
|
|
|
|
#include "cogl-object-private.h"
|
|
#include "cogl-attribute-buffer-private.h"
|
|
|
|
struct _CoglPrimitive
|
|
{
|
|
CoglObject _parent;
|
|
|
|
CoglVerticesMode mode;
|
|
int first_vertex;
|
|
int n_vertices;
|
|
CoglIndices *indices;
|
|
|
|
int immutable_ref;
|
|
|
|
CoglAttribute **attributes;
|
|
int n_attributes;
|
|
|
|
int n_embedded_attributes;
|
|
CoglAttribute *embedded_attribute;
|
|
};
|
|
|
|
CoglPrimitive *
|
|
_cogl_primitive_immutable_ref (CoglPrimitive *primitive);
|
|
|
|
void
|
|
_cogl_primitive_immutable_unref (CoglPrimitive *primitive);
|
|
|
|
#endif /* __COGL_PRIMITIVE_PRIVATE_H */
|
|
|