diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-06-14 10:03:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-06-14 10:10:24 +0300 |
commit | 2462320210fa6b625ebbcd0ddde770fc2d4e2155 (patch) | |
tree | d237ce9d8f26c7c83f05b03defab7a7fbcb12263 /source/blender/gpu/intern/gpu_select_sample_query.c | |
parent | f02e04f1338a84ed1a02734854c83244b9fd0002 (diff) |
Fix buffer read error w/ 2 pass select queries
Also don't do second pass when the first has no hits.
Diffstat (limited to 'source/blender/gpu/intern/gpu_select_sample_query.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_select_sample_query.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c index ba5fefc5227..3d589986281 100644 --- a/source/blender/gpu/intern/gpu_select_sample_query.c +++ b/source/blender/gpu/intern/gpu_select_sample_query.c @@ -142,13 +142,17 @@ bool gpu_select_query_load_id(unsigned int id) g_query_state.active_query++; g_query_state.query_issued = true; - if (g_query_state.mode == GPU_SELECT_NEAREST_SECOND_PASS && g_query_state.index < g_query_state.oldhits) { - if (g_query_state.buffer[g_query_state.index][3] == id) { - g_query_state.index++; - return true; - } - else { - return false; + if (g_query_state.mode == GPU_SELECT_NEAREST_SECOND_PASS) { + /* Second pass should never run if first pass fails, can read past 'bufsize' in this case. */ + BLI_assert(g_query_state.oldhits != -1); + if (g_query_state.index < g_query_state.oldhits) { + if (g_query_state.buffer[g_query_state.index][3] == id) { + g_query_state.index++; + return true; + } + else { + return false; + } } } |