GPU: Add GPU_vertbuf_discard and GPU_BATCH_UNUSED
GPU_vertbuf_discard to clear buffer containers in place. GPU_BATCH_UNUSED to tag batch that are cleared and not immediatly usable.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "GPU_shader.h"
|
||||
|
||||
typedef enum {
|
||||
GPU_BATCH_UNUSED,
|
||||
GPU_BATCH_READY_TO_FORMAT,
|
||||
GPU_BATCH_READY_TO_BUILD,
|
||||
GPU_BATCH_BUILDING,
|
||||
|
||||
@@ -62,6 +62,7 @@ GPUVertBuf *GPU_vertbuf_create_with_format_ex(const GPUVertFormat *, GPUUsageTyp
|
||||
#define GPU_vertbuf_create_with_format(format) \
|
||||
GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_STATIC)
|
||||
|
||||
void GPU_vertbuf_clear(GPUVertBuf *verts);
|
||||
void GPU_vertbuf_discard(GPUVertBuf *);
|
||||
|
||||
void GPU_vertbuf_init(GPUVertBuf *, GPUUsageType);
|
||||
|
||||
@@ -139,6 +139,7 @@ void GPU_batch_clear(GPUBatch *batch)
|
||||
}
|
||||
}
|
||||
GPU_batch_vao_cache_clear(batch);
|
||||
batch->phase = GPU_BATCH_UNUSED;
|
||||
}
|
||||
|
||||
void GPU_batch_discard(GPUBatch *batch)
|
||||
|
||||
@@ -85,17 +85,24 @@ void GPU_vertbuf_init_with_format_ex(GPUVertBuf *verts,
|
||||
}
|
||||
}
|
||||
|
||||
void GPU_vertbuf_discard(GPUVertBuf *verts)
|
||||
/** Same as discard but does not free. */
|
||||
void GPU_vertbuf_clear(GPUVertBuf *verts)
|
||||
{
|
||||
if (verts->vbo_id) {
|
||||
GPU_buf_free(verts->vbo_id);
|
||||
verts->vbo_id = 0;
|
||||
#if VRAM_USAGE
|
||||
vbo_memory_usage -= GPU_vertbuf_size_get(verts);
|
||||
#endif
|
||||
}
|
||||
if (verts->data) {
|
||||
MEM_freeN(verts->data);
|
||||
MEM_SAFE_FREE(verts->data);
|
||||
}
|
||||
}
|
||||
|
||||
void GPU_vertbuf_discard(GPUVertBuf *verts)
|
||||
{
|
||||
GPU_vertbuf_clear(verts);
|
||||
MEM_freeN(verts);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user