[Bf-blender-cvs] [7b4a21077ab] master: GPU: Move gpu_batch.c to C++

Clément Foucault noreply at git.blender.org
Sun Jul 26 17:30:02 CEST 2020


Commit: 7b4a21077ab1f08a9109c167359946822ead32b6
Author: Clément Foucault
Date:   Sat Jul 25 18:29:41 2020 +0200
Branches: master
https://developer.blender.org/rB7b4a21077ab1f08a9109c167359946822ead32b6

GPU: Move gpu_batch.c to C++

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

M	source/blender/gpu/CMakeLists.txt
R097	source/blender/gpu/intern/gpu_batch.c	source/blender/gpu/intern/gpu_batch.cc

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

diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 51e484d65bf..eef1346405d 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -52,8 +52,8 @@ set(INC_SYS
 )
 
 set(SRC
-  intern/gpu_batch.c
   intern/gpu_attr_binding.cc
+  intern/gpu_batch.cc
   intern/gpu_batch_presets.c
   intern/gpu_batch_utils.c
   intern/gpu_buffers.c
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.cc
similarity index 97%
rename from source/blender/gpu/intern/gpu_batch.c
rename to source/blender/gpu/intern/gpu_batch.cc
index 5f77f13c135..43a8d000547 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.cc
@@ -89,7 +89,7 @@ GPUBatch *GPU_batch_create_ex(GPUPrimType prim_type,
                               GPUIndexBuf *elem,
                               uint owns_flag)
 {
-  GPUBatch *batch = MEM_callocN(sizeof(GPUBatch), "GPUBatch");
+  GPUBatch *batch = (GPUBatch *)MEM_callocN(sizeof(GPUBatch), "GPUBatch");
   GPU_batch_init_ex(batch, prim_type, verts, elem, owns_flag);
   return batch;
 }
@@ -327,10 +327,10 @@ static GLuint batch_vao_get(GPUBatch *batch)
       }
       /* Init dynamic arrays and let the branch below set the values. */
       batch->dynamic_vaos.count = GPU_BATCH_VAO_DYN_ALLOC_COUNT;
-      batch->dynamic_vaos.interfaces = MEM_callocN(
+      batch->dynamic_vaos.interfaces = (const GPUShaderInterface **)MEM_callocN(
           batch->dynamic_vaos.count * sizeof(GPUShaderInterface *), "dyn vaos interfaces");
-      batch->dynamic_vaos.vao_ids = MEM_callocN(batch->dynamic_vaos.count * sizeof(GLuint),
-                                                "dyn vaos ids");
+      batch->dynamic_vaos.vao_ids = (GLuint *)MEM_callocN(
+          batch->dynamic_vaos.count * sizeof(GLuint), "dyn vaos ids");
     }
   }
 
@@ -346,11 +346,11 @@ static GLuint batch_vao_get(GPUBatch *batch)
       /* Not enough place, realloc the array. */
       i = batch->dynamic_vaos.count;
       batch->dynamic_vaos.count += GPU_BATCH_VAO_DYN_ALLOC_COUNT;
-      batch->dynamic_vaos.interfaces = MEM_recallocN((void *)batch->dynamic_vaos.interfaces,
-                                                     sizeof(GPUShaderInterface *) *
-                                                         batch->dynamic_vaos.count);
-      batch->dynamic_vaos.vao_ids = MEM_recallocN(batch->dynamic_vaos.vao_ids,
-                                                  sizeof(GLuint) * batch->dynamic_vaos.count);
+      batch->dynamic_vaos.interfaces = (const GPUShaderInterface **)MEM_recallocN(
+          (void *)batch->dynamic_vaos.interfaces,
+          sizeof(GPUShaderInterface *) * batch->dynamic_vaos.count);
+      batch->dynamic_vaos.vao_ids = (GLuint *)MEM_recallocN(
+          batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count);
     }
     batch->dynamic_vaos.interfaces[i] = batch->interface;
     batch->dynamic_vaos.vao_ids[i] = new_vao = GPU_vao_alloc();
@@ -839,7 +839,7 @@ struct GPUDrawList {
 
 GPUDrawList *GPU_draw_list_create(int length)
 {
-  GPUDrawList *list = MEM_callocN(sizeof(GPUDrawList), "GPUDrawList");
+  GPUDrawList *list = (GPUDrawList *)MEM_callocN(sizeof(GPUDrawList), "GPUDrawList");
   /* Alloc the biggest possible command list which is indexed. */
   list->buffer_size = sizeof(GPUDrawCommandIndexed) * length;
   if (USE_MULTI_DRAW_INDIRECT) {
@@ -848,7 +848,7 @@ GPUDrawList *GPU_draw_list_create(int length)
     glBufferData(GL_DRAW_INDIRECT_BUFFER, list->buffer_size, NULL, GL_DYNAMIC_DRAW);
   }
   else {
-    list->commands = MEM_mallocN(list->buffer_size, "GPUDrawList data");
+    list->commands = (GPUDrawCommand *)MEM_mallocN(list->buffer_size, "GPUDrawList data");
   }
   return list;
 }
@@ -880,7 +880,7 @@ void GPU_draw_list_init(GPUDrawList *list, GPUBatch *batch)
         list->cmd_offset = 0;
       }
       GLenum flags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
-      list->commands = glMapBufferRange(
+      list->commands = (GPUDrawCommand *)glMapBufferRange(
           GL_DRAW_INDIRECT_BUFFER, list->cmd_offset, list->buffer_size - list->cmd_offset, flags);
     }
   }



More information about the Bf-blender-cvs mailing list