[Bf-blender-cvs] [d268a43b25f] master: Cleanup: GPUVertBuf: Replace GPU_vertbuf_create by GPU_vertbuf_calloc

Clément Foucault noreply at git.blender.org
Sun Sep 6 22:15:36 CEST 2020


Commit: d268a43b25f7655db385fd3664301810bdef0c14
Author: Clément Foucault
Date:   Sun Sep 6 22:09:51 2020 +0200
Branches: master
https://developer.blender.org/rBd268a43b25f7655db385fd3664301810bdef0c14

Cleanup: GPUVertBuf: Replace GPU_vertbuf_create by GPU_vertbuf_calloc

This is a simple cleanup to make naming consistent with the rest of the
module.

===================================================================

M	source/blender/draw/intern/draw_cache_impl_metaball.c
M	source/blender/draw/intern/draw_cache_impl_volume.c
M	source/blender/draw/intern/draw_cache_inline.h
M	source/blender/draw/intern/draw_instance_data.c
M	source/blender/gpu/GPU_vertex_buffer.h

===================================================================

diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 5f0af06931e..53c31ac3de8 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -155,7 +155,7 @@ static GPUVertBuf *mball_batch_cache_get_pos_and_normals(Object *ob, MetaBallBat
 {
   if (cache->pos_nor_in_order == NULL) {
     ListBase *lb = &ob->runtime.curve_cache->disp;
-    cache->pos_nor_in_order = GPU_vertbuf_create(GPU_USAGE_STATIC);
+    cache->pos_nor_in_order = GPU_vertbuf_calloc();
     DRW_displist_vertbuf_create_pos_and_nor(lb, cache->pos_nor_in_order);
   }
   return cache->pos_nor_in_order;
@@ -234,7 +234,7 @@ GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(Object *ob)
   if (cache->face_wire.batch == NULL) {
     ListBase *lb = &ob->runtime.curve_cache->disp;
 
-    GPUVertBuf *vbo_wiredata = GPU_vertbuf_create(GPU_USAGE_STATIC);
+    GPUVertBuf *vbo_wiredata = GPU_vertbuf_calloc();
     DRW_displist_vertbuf_create_wiredata(lb, vbo_wiredata);
 
     GPUIndexBuf *ibo = GPU_indexbuf_calloc();
diff --git a/source/blender/draw/intern/draw_cache_impl_volume.c b/source/blender/draw/intern/draw_cache_impl_volume.c
index 3b9c127abc3..10b9623175c 100644
--- a/source/blender/draw/intern/draw_cache_impl_volume.c
+++ b/source/blender/draw/intern/draw_cache_impl_volume.c
@@ -163,7 +163,7 @@ static void drw_volume_wireframe_cb(
   GPU_vertbuf_attr_fill_stride(cache->face_wire.pos_nor_in_order, nor_id, 0, &packed_normal);
 
   /* Create wiredata. */
-  GPUVertBuf *vbo_wiredata = GPU_vertbuf_create(GPU_USAGE_STATIC);
+  GPUVertBuf *vbo_wiredata = GPU_vertbuf_calloc();
   DRW_vertbuf_create_wiredata(vbo_wiredata, totvert);
 
   if (volume->display.wireframe_type == VOLUME_WIREFRAME_POINTS) {
diff --git a/source/blender/draw/intern/draw_cache_inline.h b/source/blender/draw/intern/draw_cache_inline.h
index 120e547bbe2..ebe97b4e7c4 100644
--- a/source/blender/draw/intern/draw_cache_inline.h
+++ b/source/blender/draw/intern/draw_cache_inline.h
@@ -86,7 +86,7 @@ BLI_INLINE bool DRW_ibo_requested(GPUIndexBuf *ibo)
 BLI_INLINE void DRW_vbo_request(GPUBatch *batch, GPUVertBuf **vbo)
 {
   if (*vbo == NULL) {
-    *vbo = GPU_vertbuf_create(GPU_USAGE_STATIC);
+    *vbo = GPU_vertbuf_calloc();
   }
   if (batch != NULL) {
     /* HACK we set vbos that may not yet be valid. */
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 7a6f357cb9c..32060ca02a1 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -122,7 +122,7 @@ GPUVertBuf *DRW_temp_buffer_request(DRWInstanceDataList *idatalist,
     handle->format = format;
     GPU_VERTBUF_DISCARD_SAFE(handle->buf);
 
-    GPUVertBuf *vert = GPU_vertbuf_create(GPU_USAGE_DYNAMIC);
+    GPUVertBuf *vert = GPU_vertbuf_calloc();
     GPU_vertbuf_init_with_format_ex(vert, format, GPU_USAGE_DYNAMIC);
     GPU_vertbuf_data_alloc(vert, DRW_BUFFER_VERTS_CHUNK);
 
diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h
index 070c93df412..efed2725e27 100644
--- a/source/blender/gpu/GPU_vertex_buffer.h
+++ b/source/blender/gpu/GPU_vertex_buffer.h
@@ -49,7 +49,7 @@ extern "C" {
 #define VRAM_USAGE 1
 /**
  * How to create a #GPUVertBuf:
- * 1) verts = GPU_vertbuf_create() or GPU_vertbuf_init(verts)
+ * 1) verts = GPU_vertbuf_calloc()
  * 2) GPU_vertformat_attr_add(verts->format, ...)
  * 3) GPU_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format
  * 4) GPU_vertbuf_attr_fill(verts, pos, application_pos_buffer)
@@ -64,6 +64,8 @@ typedef enum {
 
 typedef struct GPUVertBuf GPUVertBuf;
 
+#define GPU_vertbuf_calloc() GPU_vertbuf_create(GPU_USAGE_STATIC);
+
 GPUVertBuf *GPU_vertbuf_create(GPUUsageType);
 GPUVertBuf *GPU_vertbuf_create_with_format_ex(const GPUVertFormat *, GPUUsageType);



More information about the Bf-blender-cvs mailing list