GPUBatch: Add GPU_batch_clear to clear batches without freeing

This commit is contained in:
Clément Foucault 2018-12-14 00:07:59 +01:00
parent 0ee0f0ebf6
commit c09913e9dd
2 changed files with 7 additions and 1 deletions

View File

@ -107,6 +107,7 @@ GPUBatch *GPU_batch_duplicate(GPUBatch *batch_src);
#define GPU_batch_init(batch, prim, verts, elem) \
GPU_batch_init_ex(batch, prim, verts, elem, 0)
void GPU_batch_clear(GPUBatch *); /* Same as discard but does not free. */
void GPU_batch_discard(GPUBatch *); /* verts & elem are not discarded */
void GPU_batch_vao_cache_clear(GPUBatch *);

View File

@ -125,7 +125,7 @@ GPUBatch *GPU_batch_duplicate(GPUBatch *batch_src)
return batch;
}
void GPU_batch_discard(GPUBatch *batch)
void GPU_batch_clear(GPUBatch *batch)
{
if (batch->owns_flag & GPU_BATCH_OWNS_INDEX) {
GPU_indexbuf_discard(batch->elem);
@ -148,6 +148,11 @@ void GPU_batch_discard(GPUBatch *batch)
if (batch->free_callback) {
batch->free_callback(batch, batch->callback_data);
}
}
void GPU_batch_discard(GPUBatch *batch)
{
GPU_batch_clear(batch);
MEM_freeN(batch);
}