diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-02-24 19:19:07 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-02-24 19:19:07 +0300 |
commit | 50e9868abe11bd2ed0173b7a51cf129d77e4389e (patch) | |
tree | 318fe9a4f753569cebee011a93575b6b6ac4ebd4 /source/blender/gpu/intern/gpu_select.c | |
parent | 340b76b42c53816ddac1b4cecdff3d8d2010a9cc (diff) |
Fix T43785 crash with border select.
Naming here is slightly misleading. We have:
* Number of elements (objects) that can be picked
* Buffer size
* Number of integers in buffer.
Interestingly enough, bufsize in OpenGL (as far as I could find in
examples on the web) and in most of the code refers to the latter and
actual buffer size is only used whenever we do allocations on the heap.
Added an extra defines here to make things a bit clearer:
* MAXPICKELEMS refers to the number of objects that can be picked
* MAXPICKBUF refers to the number of integers in the selection buffer
Also made all buffers use MAXPICKBUF where some used MAXPICKBUF * 4.
That means that some parts of blender will use less space for selection
now. MAXPICKBUF is set to 10000 for 2500 object selection, which can be
changed at any time, but I think 10000 integers on the stack touches the
borders of uglyland anyway.
Diffstat (limited to 'source/blender/gpu/intern/gpu_select.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 35a39b2d7a1..4978229a350 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -59,6 +59,7 @@ typedef struct GPUQueryState { bool use_gpu_select; /* cache on initialization */ unsigned int *buffer; + /* buffer size (stores number of integers, for actual size multiply by sizeof integer)*/ unsigned int bufsize; /* mode of operation */ char mode; @@ -191,7 +192,9 @@ unsigned int GPU_select_end(void) glGetQueryObjectuivARB(g_query_state.queries[i], GL_QUERY_RESULT_ARB, &result); if (result > 0) { if (g_query_state.mode != GPU_SELECT_NEAREST_SECOND_PASS) { - if (hits < g_query_state.bufsize) { + int maxhits = g_query_state.bufsize / 4; + + if (hits < maxhits) { g_query_state.buffer[hits * 4] = 1; g_query_state.buffer[hits * 4 + 1] = 0xFFFF; g_query_state.buffer[hits * 4 + 2] = 0xFFFF; |