diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-06-14 10:17:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-06-14 10:17:00 +0300 |
commit | 26efc7bbd1d15bfea9c1bd0538a27d13c9620f3b (patch) | |
tree | 735af15bb380cf8dcc85b609cc5cc46ea8c9f9dc /source/blender/gpu | |
parent | a394d681775cc9f5e83a28fb12c0d6aba1a6681c (diff) | |
parent | 2462320210fa6b625ebbcd0ddde770fc2d4e2155 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_sample_query.c | 18 |
2 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index c384fa01fc6..162a605ef3d 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; diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c index a7374604379..e3bd20f3776 100644 --- a/source/blender/gpu/intern/gpu_select_sample_query.c +++ b/source/blender/gpu/intern/gpu_select_sample_query.c @@ -144,13 +144,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; + } } } |