Commit: f35df9a25adec35a384ba45c5b2b2d5767e7e87d
Author: Dalai Felinto
Date:   Fri Jun 9 15:19:48 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBf35df9a25adec35a384ba45c5b2b2d5767e7e87d

Draw Manager: stop using stack memory!

We still do it a few times, but that helps already. Related to T51718.

Note that it also reinforces the idea that any geometry datablock will
have a generated copy-on-write Mesh provided by Depsgraph.

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

M       source/blender/draw/engines/clay/clay_engine.c
M       source/blender/draw/intern/draw_manager.c

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

diff --git a/source/blender/draw/engines/clay/clay_engine.c 
b/source/blender/draw/engines/clay/clay_engine.c
index 845e946c454..e2e3fa3efbc 100644
--- a/source/blender/draw/engines/clay/clay_engine.c
+++ b/source/blender/draw/engines/clay/clay_engine.c
@@ -790,7 +790,7 @@ static void CLAY_cache_populate(void *vedata, Object *ob)
                                DRW_shgroup_call_sculpt_add(depth_shgrp, ob, 
ob->obmat);
                        }
                        else {
-                               DRW_shgroup_call_add(depth_shgrp, geom, 
ob->obmat);
+                               DRW_shgroup_call_object_add(depth_shgrp, geom, 
ob);
                        }
                }
 
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index 40991a5e707..3b4c65fb54b 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -33,6 +33,7 @@
 #include "BIF_glutil.h"
 
 #include "BKE_global.h"
+#include "BKE_mesh.h"
 #include "BKE_object.h"
 #include "BKE_pbvh.h"
 #include "BKE_paint.h"
@@ -210,6 +211,7 @@ typedef struct DRWCall {
        float obmat[4][4];
        Batch *geometry;
 
+       Mesh *mesh; /* Optional. */
        Object *ob; /* Optionnal */
 } DRWCall;
 
@@ -876,7 +878,7 @@ void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, 
Batch *geom, Object *
 
        copy_m4_m4(call->obmat, ob->obmat);
        call->geometry = geom;
-       call->ob = ob;
+       call->mesh = ob->data;
 
        BLI_addtail(&shgroup->calls, call);
 }
@@ -1647,13 +1649,13 @@ static void draw_geometry_execute(DRWShadingGroup 
*shgroup, Batch *geom)
        }
 }
 
-static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float 
(*obmat)[4], Object *ob)
+static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float 
(*obmat)[4], Mesh *me)
 {
        float *texcoloc = NULL;
        float *texcosize = NULL;
 
-       if (ob != NULL) {
-               BKE_object_obdata_texspace_get(ob, NULL, &texcoloc, &texcosize, 
NULL);
+       if (me != NULL) {
+               BKE_mesh_texspace_get_reference(me, NULL, &texcoloc, NULL, 
&texcosize);
        }
 
        draw_geometry_prepare(shgroup, obmat, texcoloc, texcosize);
@@ -1790,7 +1792,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, 
DRWState pass_state)
                        GPU_SELECT_LOAD_IF_PICKSEL(call);
 
                        if (call->head.type == DRW_CALL_SINGLE) {
-                               draw_geometry(shgroup, call->geometry, 
call->obmat, call->ob);
+                               draw_geometry(shgroup, call->geometry, 
call->obmat, call->mesh);
                        }
                        else {
                                BLI_assert(call->head.type == 
DRW_CALL_GENERATE);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to