[Bf-blender-cvs] [8dde1e13e26] blender2.8: FIx/workaround wrong number of primitives in PBVG grid buffers

Sergey Sharybin noreply at git.blender.org
Tue Sep 11 14:47:10 CEST 2018


Commit: 8dde1e13e26b78295e112fccac0b2c4dfbd42e3c
Author: Sergey Sharybin
Date:   Tue Sep 11 14:41:39 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB8dde1e13e26b78295e112fccac0b2c4dfbd42e3c

FIx/workaround wrong number of primitives in PBVG grid buffers

Nodes can have different number of grids, so can not so simply
re-use index buffer across nodes. For now allow re-using buffer
if number of grids matches.

The issue is, number of grids is probably almost never matches,
so in order to have this optimization working need more tricks.
Maybe we can "instance" index buffers?

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

M	source/blender/gpu/intern/gpu_buffers.c

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

diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 6584836d32d..f970717c2c9 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -64,6 +64,7 @@ static ThreadMutex buffer_mutex = BLI_MUTEX_INITIALIZER;
 typedef struct GridCommonGPUBuffer {
 	GPUIndexBuf *mres_buffer;
 	int mres_prev_gridsize;
+	int mres_prev_totgrid;
 	unsigned mres_prev_totquad;
 } GridCommonGPUBuffer;
 
@@ -499,10 +500,11 @@ static GPUIndexBuf *gpu_get_grid_buffer(
 		gridbuff->mres_buffer = NULL;
 		gridbuff->mres_prev_gridsize = -1;
 		gridbuff->mres_prev_totquad = 0;
+		gridbuff->mres_prev_totgrid = 0;
 	}
 
 	/* VBO is already built */
-	if (gridbuff->mres_buffer && gridbuff->mres_prev_gridsize == gridsize) {
+	if (gridbuff->mres_buffer && gridbuff->mres_prev_gridsize == gridsize && gridbuff->mres_prev_totgrid == totgrid) {
 		*totquad = gridbuff->mres_prev_totquad;
 		return gridbuff->mres_buffer;
 	}
@@ -520,6 +522,7 @@ static GPUIndexBuf *gpu_get_grid_buffer(
 
 	gridbuff->mres_prev_gridsize = gridsize;
 	gridbuff->mres_prev_totquad = *totquad;
+	gridbuff->mres_prev_totgrid = totgrid;
 	return gridbuff->mres_buffer;
 }



More information about the Bf-blender-cvs mailing list