[Bf-blender-cvs] [fe573ce914d] soc-2019-npr: LANPR: GPU mode prevent overflow.
YimingWu
noreply at git.blender.org
Thu Jul 4 06:50:15 CEST 2019
Commit: fe573ce914dae230ad2f9725337c3b14ac90f3fc
Author: YimingWu
Date: Thu Jul 4 12:47:31 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rBfe573ce914dae230ad2f9725337c3b14ac90f3fc
LANPR: GPU mode prevent overflow.
===================================================================
M source/blender/draw/engines/lanpr/lanpr_dpix.c
===================================================================
diff --git a/source/blender/draw/engines/lanpr/lanpr_dpix.c b/source/blender/draw/engines/lanpr/lanpr_dpix.c
index 022e3684600..4e209868f6e 100644
--- a/source/blender/draw/engines/lanpr/lanpr_dpix.c
+++ b/source/blender/draw/engines/lanpr/lanpr_dpix.c
@@ -171,6 +171,13 @@ int lanpr_feed_atlas_data_obj(void *vedata,
int vert_count = me->totvert, edge_count = me->totedge, face_count = me->totface;
int i, idx;
+ int cache_total = lanpr_share.texture_size * lanpr_share.texture_size;
+
+ /* Don't overflow the cache. */
+ if ((edge_count + begin_index + cache_total) < (cache_total - 1)) {
+ return begin_index;
+ }
+
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me);
bm = BM_mesh_create(&allocsize,
&((struct BMeshCreateParams){
@@ -280,6 +287,13 @@ int lanpr_feed_atlas_data_intersection_cache(void *vedata,
return 0;
}
+ int cache_total = lanpr_share.texture_size * lanpr_share.texture_size;
+
+ /* Don't overflow the cache. */
+ if ((rb->intersection_count + begin_index + cache_total) < (cache_total - 1)) {
+ return 0;
+ }
+
for (lip = rb->intersection_lines.first; lip; lip = lip->next) {
rl = lip->data;
@@ -338,6 +352,13 @@ int lanpr_feed_atlas_trigger_preview_obj(void *vedata, Object *ob, int begin_ind
int i;
float co[2];
+ int cache_total = lanpr_share.texture_size * lanpr_share.texture_size;
+
+ /* Don't overflow the cache. */
+ if ((edge_count + begin_index + cache_total) < (cache_total - 1)) {
+ return begin_index;
+ }
+
static GPUVertFormat format = {0};
static struct {
uint pos, uvs;
@@ -403,6 +424,13 @@ void lanpr_create_atlas_intersection_preview(void *vedata, int begin_index)
return;
}
+ int cache_total = lanpr_share.texture_size * lanpr_share.texture_size;
+
+ /* Don't overflow the cache. */
+ if ((rb->intersection_count + begin_index + cache_total) < (cache_total - 1)) {
+ return 0;
+ }
+
static GPUVertFormat format = {0};
static struct {
uint pos, uvs;
More information about the Bf-blender-cvs
mailing list