Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-05-13 18:27:35 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-14 11:57:03 +0300
commit20d9cd3a1fbd763dbe002e9baf2e3ba7fbb66f2f (patch)
tree4a3e4e7c8bfbd8d65a92f55cac82420b411fa95a /source/blender/gpu
parente5349f14eb17689316ab5a85a7d4ffbb740ec93c (diff)
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.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_batch.h1
-rw-r--r--source/blender/gpu/GPU_vertex_buffer.h1
-rw-r--r--source/blender/gpu/intern/gpu_batch.c1
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.c11
4 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 856148563f2..783bfb0b1f0 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -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,
diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h
index 6d88460964d..a5a5e3d4296 100644
--- a/source/blender/gpu/GPU_vertex_buffer.h
+++ b/source/blender/gpu/GPU_vertex_buffer.h
@@ -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);
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index f179f9ef22c..010f57bf5f8 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -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)
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c
index f9823c18723..2f854fe03ea 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.c
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.c
@@ -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);
}