From c92cffb56d55f5f8f3d42b9da9ca6885f374c0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 18 Dec 2018 13:08:08 +0100 Subject: DRW: Instance: Makes it possible to have instances of a non-init batch --- source/blender/gpu/GPU_batch.h | 2 +- source/blender/gpu/intern/gpu_batch.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index c77f0707ee5..f4911d15e56 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -100,7 +100,7 @@ enum { GPUBatch *GPU_batch_create_ex(GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag); void GPU_batch_init_ex(GPUBatch *, GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag); -GPUBatch *GPU_batch_duplicate(GPUBatch *batch_src); +void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src); #define GPU_batch_create(prim, verts, elem) \ GPU_batch_create_ex(prim, verts, elem, 0) diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index d70752e9b2f..a2184df229f 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -114,19 +114,22 @@ void GPU_batch_init_ex( } /* This will share the VBOs with the new batch. */ -GPUBatch *GPU_batch_duplicate(GPUBatch *batch_src) +void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src) { - GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); + GPU_batch_init_ex(batch_dst, GPU_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); - batch->gl_prim_type = batch_src->gl_prim_type; + batch_dst->gl_prim_type = batch_src->gl_prim_type; for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; ++v) { - batch->verts[v] = batch_src->verts[v]; + batch_dst->verts[v] = batch_src->verts[v]; } - return batch; } void GPU_batch_clear(GPUBatch *batch) { + if (batch->free_callback) { + batch->free_callback(batch, batch->callback_data); + } + if (batch->owns_flag & GPU_BATCH_OWNS_INDEX) { GPU_indexbuf_discard(batch->elem); } @@ -144,10 +147,6 @@ void GPU_batch_clear(GPUBatch *batch) } } GPU_batch_vao_cache_clear(batch); - - if (batch->free_callback) { - batch->free_callback(batch, batch->callback_data); - } } void GPU_batch_discard(GPUBatch *batch) -- cgit v1.2.3