[Bf-blender-cvs] [b138fbe] GPU_data_request: Use our own allocation routines for GPUx module
Antony Riakiotakis
noreply at git.blender.org
Fri Apr 17 16:36:53 CEST 2015
Commit: b138fbe4a158dff8ca4cfd98198f921151c56e31
Author: Antony Riakiotakis
Date: Fri Apr 17 16:34:05 2015 +0200
Branches: GPU_data_request
https://developer.blender.org/rBb138fbe4a158dff8ca4cfd98198f921151c56e31
Use our own allocation routines for GPUx module
===================================================================
M source/blender/gpu/intern/gpux_draw.c
M source/blender/gpu/intern/gpux_element.c
M source/blender/gpu/intern/gpux_vbo.c
===================================================================
diff --git a/source/blender/gpu/intern/gpux_draw.c b/source/blender/gpu/intern/gpux_draw.c
index 0d0662a..80913f4 100644
--- a/source/blender/gpu/intern/gpux_draw.c
+++ b/source/blender/gpu/intern/gpux_draw.c
@@ -1,6 +1,7 @@
#include "GPUx_draw.h"
#include "gpux_element_private.h"
+#include "MEM_guardedalloc.h"
#include <stdlib.h>
//#include <stdio.h> /* TODO: remove */
@@ -143,7 +144,7 @@ void GPUx_draw_primitives(const VertexBuffer *vbo, const ElementList *el, const
GPUxBatch *GPUx_batch_create()
{
// puts(__FUNCTION__);
- GPUxBatch *batch = calloc(1, sizeof(GPUxBatch));
+ GPUxBatch *batch = MEM_callocN(sizeof(GPUxBatch), "GPUxBatch");
batch->prim_type = GL_NONE;
batch->state = default_state;
return batch;
@@ -155,7 +156,7 @@ void GPUx_batch_discard(GPUxBatch *batch)
GPUx_vertex_buffer_discard(batch->buff);
if (batch->elem)
GPUx_element_list_discard(batch->elem);
- free(batch);
+ MEM_freeN(batch);
}
void GPUx_draw_batch(const GPUxBatch *batch)
diff --git a/source/blender/gpu/intern/gpux_element.c b/source/blender/gpu/intern/gpux_element.c
index 527e169..5f8adcf 100644
--- a/source/blender/gpu/intern/gpux_element.c
+++ b/source/blender/gpu/intern/gpux_element.c
@@ -1,5 +1,6 @@
#include "gpux_element_private.h"
+#include "MEM_guardedalloc.h"
#include <stdlib.h>
/* private functions */
@@ -64,7 +65,7 @@ ElementList *GPUx_element_list_create(GLenum prim_type, unsigned prim_ct, unsign
return NULL;
}
- el = calloc(1, sizeof(ElementList));
+ el = MEM_callocN(sizeof(ElementList), "ElementList");
el->prim_type = prim_type;
el->prim_ct = prim_ct;
@@ -88,7 +89,7 @@ ElementList *GPUx_element_list_create(GLenum prim_type, unsigned prim_ct, unsign
el->max_observed_index = 0;
#endif /* TRACK_INDEX_RANGE */
- el->indices = calloc(prim_ct * prim_vertex_ct, index_size);
+ el->indices = MEM_callocN(prim_ct * prim_vertex_ct * index_size, "ElementList.indices");
/* TODO: use only one calloc, not two */
return el;
@@ -101,8 +102,8 @@ void GPUx_element_list_discard(ElementList *el)
glDeleteBuffers(1, &el->vbo_id);
#endif /* USE_ELEM_VBO */
- free(el->indices);
- free(el);
+ MEM_freeN(el->indices);
+ MEM_freeN(el);
}
void GPUx_set_point_vertex(ElementList *el, unsigned prim_idx, unsigned v1)
diff --git a/source/blender/gpu/intern/gpux_vbo.c b/source/blender/gpu/intern/gpux_vbo.c
index 7f80738..b3a1a0e 100644
--- a/source/blender/gpu/intern/gpux_vbo.c
+++ b/source/blender/gpu/intern/gpux_vbo.c
@@ -1,5 +1,6 @@
#include "GPUx_vbo.h"
+#include "MEM_guardedalloc.h"
#include <stdlib.h>
#include <string.h>
@@ -144,13 +145,13 @@ void GPUx_attrib_print(const VertexBuffer *buff, unsigned attrib_num)
VertexBuffer *GPUx_vertex_buffer_create(unsigned a_ct, unsigned v_ct)
{
- VertexBuffer *buff = calloc(1, sizeof(VertexBuffer));
+ VertexBuffer *buff = MEM_callocN(sizeof(VertexBuffer), "VertexBuffer");
#ifdef TRUST_NO_ONE
assert(a_ct >= 1 && a_ct <= 16);
#endif /* TRUST_NO_ONE */
buff->attrib_ct = a_ct;
buff->vertex_ct = v_ct;
- buff->attribs = calloc(a_ct, sizeof(Attrib));
+ buff->attribs = MEM_callocN(a_ct * sizeof(Attrib), "VertexBuffer.attribs");
/* TODO: single allocation instead of 2 */
return buff;
}
@@ -165,16 +166,16 @@ void GPUx_vertex_buffer_discard(VertexBuffer *buff)
glDeleteBuffers(1, &a->vbo_id);
#endif /* USE_VBO */
#ifdef GENERIC_ATTRIB
- free(a->name);
+ MEM_freeN(a->name);
#endif /* GENERIC_ATTRIB */
- free(a->data);
+ MEM_freeN(a->data);
}
#ifdef USE_VAO
if (buff->vao_id)
glDeleteVertexArrays(1, &buff->vao_id);
#endif /* USE_VAO */
- free(buff->attribs);
- free(buff);
+ MEM_freeN(buff->attribs);
+ MEM_freeN(buff);
}
static unsigned attrib_total_size(const VertexBuffer *buff, unsigned attrib_num)
@@ -263,7 +264,7 @@ void GPUx_specify_attrib(VertexBuffer *buff, unsigned attrib_num,
attrib->sz = attrib_sz(attrib);
attrib->stride = attrib_align(attrib);
attrib->fetch_mode = fetch_mode;
- attrib->data = malloc(attrib_total_size(buff, attrib_num));
+ attrib->data = MEM_mallocN(attrib_total_size(buff, attrib_num), "Attrib.data");
#ifdef PRINT
GPUx_attrib_print(buff, attrib_num);
#endif /* PRINT */
More information about the Bf-blender-cvs
mailing list