Commit: f84342d7e19f34bb445423cc8bf8267c1675a643 Author: Clément Foucault Date: Tue Jul 28 02:15:22 2020 +0200 Branches: master https://developer.blender.org/rBf84342d7e19f34bb445423cc8bf8267c1675a643
GPU: Move gpu_vertex_buffer.c to C++ =================================================================== M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_vertex_buffer.h R093 source/blender/gpu/intern/gpu_vertex_buffer.c source/blender/gpu/intern/gpu_vertex_buffer.cc =================================================================== diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 8c55de8a18c..fd04f56bd13 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -82,7 +82,7 @@ set(SRC intern/gpu_texture_image.cc intern/gpu_texture_smoke.cc intern/gpu_uniformbuffer.c - intern/gpu_vertex_buffer.c + intern/gpu_vertex_buffer.cc intern/gpu_vertex_format.cc intern/gpu_viewport.c diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h index f9bdf726930..d1693852c1a 100644 --- a/source/blender/gpu/GPU_vertex_buffer.h +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -59,10 +59,10 @@ typedef struct GPUVertBuf { /** 0 indicates not yet allocated. */ uint32_t vbo_id; /** Usage hint for GL optimisation. */ - uint usage : 2; + GPUUsageType usage; /** Data has been touched and need to be reuploaded to GPU. */ - uint dirty : 1; - unsigned char *data; /* NULL indicates data in VRAM (unmapped) */ + bool dirty; + uchar *data; /* NULL indicates data in VRAM (unmapped) */ } GPUVertBuf; GPUVertBuf *GPU_vertbuf_create(GPUUsageType); diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.cc similarity index 93% rename from source/blender/gpu/intern/gpu_vertex_buffer.c rename to source/blender/gpu/intern/gpu_vertex_buffer.cc index 3b4d469542c..eda6d1c7300 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.c +++ b/source/blender/gpu/intern/gpu_vertex_buffer.cc @@ -39,17 +39,22 @@ static uint vbo_memory_usage; static GLenum convert_usage_type_to_gl(GPUUsageType type) { - static const GLenum table[] = { - [GPU_USAGE_STREAM] = GL_STREAM_DRAW, - [GPU_USAGE_STATIC] = GL_STATIC_DRAW, - [GPU_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW, - }; - return table[type]; + switch (type) { + case GPU_USAGE_STREAM: + return GL_STREAM_DRAW; + case GPU_USAGE_DYNAMIC: + return GL_DYNAMIC_DRAW; + case GPU_USAGE_STATIC: + return GL_STATIC_DRAW; + default: + BLI_assert(0); + return GL_STATIC_DRAW; + } } GPUVertBuf *GPU_vertbuf_create(GPUUsageType usage) { - GPUVertBuf *verts = MEM_mallocN(sizeof(GPUVertBuf), "GPUVertBuf"); + GPUVertBuf *verts = (GPUVertBuf *)MEM_mallocN(sizeof(GPUVertBuf), "GPUVertBuf"); GPU_vertbuf_init(verts, usage); return verts; } @@ -109,7 +114,7 @@ GPUVertBuf *GPU_vertbuf_duplicate(GPUVertBuf *verts) } if (verts->data) { - verts_dst->data = MEM_dupallocN(verts->data); + verts_dst->data = (uchar *)MEM_dupallocN(verts->data); } return verts_dst; } @@ -161,7 +166,7 @@ void GPU_vertbuf_data_alloc(GPUVertBuf *verts, uint v_len) #endif verts->dirty = true; verts->vertex_len = verts->vertex_alloc = v_len; - verts->data = MEM_mallocN(sizeof(GLubyte) * GPU_vertbuf_size_get(verts), "GPUVertBuf data"); + verts->data = (uchar *)MEM_mallocN(sizeof(GLubyte) * GPU_vertbuf_size_get(verts), __func__); } /* resize buffer keeping existing data */ @@ -178,7 +183,7 @@ void GPU_vertbuf_data_resize(GPUVertBuf *verts, uint v_len) #endif verts->dirty = true; verts->vertex_len = verts->vertex_alloc = v_len; - verts->data = MEM_reallocN(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts)); + verts->data = (uchar *)MEM_reallocN(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts)); } /* Set vertex count but does not change allocation. _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs