diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-11 15:41:39 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-11 15:45:13 +0300 |
commit | 8dde1e13e26b78295e112fccac0b2c4dfbd42e3c (patch) | |
tree | 406876386f522888a495cc667ba64d142b91ffba /source/blender/gpu/intern/gpu_buffers.c | |
parent | 7951adfb9c814bfac30549e3d74ef62a2634684e (diff) |
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?
Diffstat (limited to 'source/blender/gpu/intern/gpu_buffers.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 5 |
1 files changed, 4 insertions, 1 deletions
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; } |