Fix buffer read error w/ 2 pass select queries

Also don't do second pass when the first has no hits.
This commit is contained in:
2017-06-14 17:03:49 +10:00
parent f02e04f133
commit 2462320210
4 changed files with 19 additions and 9 deletions

View File

@@ -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;
}
}
}