Mesh Batch Cache: Speedup: Only alloc gpu_attrs if needed and don't clear
authorClément Foucault <foucault.clem@gmail.com>
Wed, 8 May 2019 10:00:50 +0000 (12:00 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Wed, 8 May 2019 15:52:48 +0000 (17:52 +0200)
No need to clear since GPU_material_vertex_attrs is overriding

source/blender/draw/intern/draw_cache_impl_mesh.c

index 02ebe16..f3db146 100644 (file)
@@ -423,13 +423,13 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Mesh *me,
   const CustomData *cd_ldata = (me->edit_mesh) ? &me->edit_mesh->bm->ldata : &me->ldata;
 
   /* See: DM_vertex_attributes_from_gpu for similar logic */
-  GPUVertAttrLayers gpu_attrs = {{{0}}};
   DRW_MeshCDMask cd_used;
   mesh_cd_layers_type_clear(&cd_used);
 
   for (int i = 0; i < gpumat_array_len; i++) {
     GPUMaterial *gpumat = gpumat_array[i];
     if (gpumat) {
+      GPUVertAttrLayers gpu_attrs;
       GPU_material_vertex_attrs(gpumat, &gpu_attrs);
       for (int j = 0; j < gpu_attrs.totlayer; j++) {
         const char *name = gpu_attrs.layer[j].name;