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>2018-12-08 20:15:57 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-12-10 21:02:17 +0300
commit33cc3344a26d674c1283c5fd8c007a63f0d8a5fc (patch)
tree0aaa98b8d88a68c7b4186e8df507d6d25cdd3d06 /source/blender/gpu/intern/gpu_vertex_buffer.c
parenta99eb0ca689c8116964032faf8425cfba16759bc (diff)
GPU: Make changes to GPUIndexBuf and GPUVertBuf to allow multithreading
This is a small change. We delay all gl calls at the first use of the GPUIndexBuf / GPUVertBuf in order to be able to create multiple buffers from different threads without having many gl contexts.
Diffstat (limited to 'source/blender/gpu/intern/gpu_vertex_buffer.c')
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c
index b6058a2cb79..a5c560fb17b 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.c
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.c
@@ -119,10 +119,6 @@ void GPU_vertbuf_data_alloc(GPUVertBuf *verts, uint v_len)
/* catch any unnecessary use */
assert(verts->vertex_alloc != v_len || verts->data == NULL);
#endif
- /* only create the buffer the 1st time */
- if (verts->vbo_id == 0) {
- verts->vbo_id = GPU_buf_alloc();
- }
/* discard previous data if any */
if (verts->data) {
MEM_freeN(verts->data);
@@ -260,6 +256,10 @@ static void VertBuffer_upload_data(GPUVertBuf *verts)
void GPU_vertbuf_use(GPUVertBuf *verts)
{
+ /* only create the buffer the 1st time */
+ if (verts->vbo_id == 0) {
+ verts->vbo_id = GPU_buf_alloc();
+ }
glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id);
if (verts->dirty) {
VertBuffer_upload_data(verts);