DRW: InstanceData: Remove hacks of batch freeing callback

We instead use a handle reference counter on the GPUVertBufs used by
the instancing batches. This make sure that if an update happens on the
GPUVertBuf used to contruct the batch, they will never have the same
memory address than the previously allocated ones (since they are still
pending deletion thanks to the refcounter).

This avoid the linear search to update the GPUBatch in the case a
batch is deleted (which was even a bad option since they could be only
cleared)
This commit is contained in:
2020-08-10 01:43:50 +02:00
parent 157f2a20e6
commit e0f5f95e66
3 changed files with 76 additions and 87 deletions

View File

@@ -89,11 +89,6 @@ typedef struct GPUBatch {
uint32_t *vao_ids;
} dynamic_vaos;
};
/* XXX This is the only solution if we want to have some data structure using
* batches as key to identify nodes. We must destroy these nodes with this callback. */
void (*free_callback)(struct GPUBatch *, void *);
void *callback_data;
} GPUBatch;
enum {
@@ -118,8 +113,6 @@ void GPU_batch_discard(GPUBatch *); /* verts & elem are not discarded */
void GPU_batch_vao_cache_clear(GPUBatch *);
void GPU_batch_callback_free_set(GPUBatch *, void (*callback)(GPUBatch *, void *), void *);
void GPU_batch_instbuf_set(GPUBatch *, GPUVertBuf *, bool own_vbo); /* Instancing */
void GPU_batch_elembuf_set(GPUBatch *batch, GPUIndexBuf *elem, bool own_ibo);