diff options
author | mano-wii <germano.costa@ig.com.br> | 2019-03-28 20:17:00 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2019-03-28 20:19:21 +0300 |
commit | d5cb425b874561816ee52826d71c6f5e2229aa4d (patch) | |
tree | d9292c9467577a6423db82ed170eca5e376a7c4e /source/blender/gpu/intern/gpu_select_pick.c | |
parent | dfa470ec336976eeca309909ee7ae19261431130 (diff) |
Possible fix for T62999: Crash when select in edit mode.
Apparently some drivers don't allow `glReadPixel` read out pixels of texture boundaries.
Intersect `rect` to avoid such cases.
Diffstat (limited to 'source/blender/gpu/intern/gpu_select_pick.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 22388deccdb..bfd2f3c1ee7 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -90,6 +90,30 @@ static void rect_subregion_stride_calc(const rcti *src, const rcti *dst, SubRect r_sub->skip = (uint)(src_x - dst_x); } +void GPU_select_buffer_stride_realign( + const rcti *src, const rcti *dst, uint *r_buf) +{ + SubRectStride sub; + rect_subregion_stride_calc(src, dst, &sub); + + int last_px_written = sub.span * sub.span_len - 1; + int last_px_id = sub.start + last_px_written + (sub.span_len - 1) * sub.skip; + + while (sub.span_len--) { + int i; + for (i = sub.span; i--;) { + r_buf[last_px_id--] = r_buf[last_px_written--]; + } + if (last_px_written < 0) { + break; + } + for (i = sub.skip; i--;) { + r_buf[last_px_id--] = 0u; + } + } + memset(r_buf, 0, (last_px_id + 1) * sizeof(*r_buf)); +} + /** * Ignore depth clearing as a change, * only check if its been changed _and_ filled in (ignore clearing since XRAY does this). |