From 2462320210fa6b625ebbcd0ddde770fc2d4e2155 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jun 2017 17:03:49 +1000 Subject: Fix buffer read error w/ 2 pass select queries Also don't do second pass when the first has no hits. --- source/blender/gpu/intern/gpu_select.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/gpu/intern/gpu_select.c') diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 9496ff137dc..632b0cfee1b 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -75,6 +75,12 @@ static GPUSelectState g_select_state = {0}; */ void GPU_select_begin(unsigned int *buffer, unsigned int bufsize, const rcti *input, char mode, int oldhits) { + if (mode == GPU_SELECT_NEAREST_SECOND_PASS) { + /* In the case hits was '-1', don't start the second pass since it's not going to give useful results. + * As well as buffer overflow in 'gpu_select_query_load_id'. */ + BLI_assert(oldhits != -1); + } + g_select_state.select_is_active = true; g_select_state.use_gpu_select = GPU_select_query_check_active(); g_select_state.mode = mode; -- cgit v1.2.3