From 8dde1e13e26b78295e112fccac0b2c4dfbd42e3c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 11 Sep 2018 14:41:39 +0200 Subject: 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? --- source/blender/gpu/intern/gpu_buffers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to '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; } -- cgit v1.2.3