Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-03-28 20:17:00 +0300
committermano-wii <germano.costa@ig.com.br>2019-03-28 20:19:21 +0300
commitd5cb425b874561816ee52826d71c6f5e2229aa4d (patch)
treed9292c9467577a6423db82ed170eca5e376a7c4e /source/blender/draw/intern
parentdfa470ec336976eeca309909ee7ae19261431130 (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/draw/intern')
-rw-r--r--source/blender/draw/intern/draw_manager.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 9dd6d08afcc..8a532ecdb7d 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -59,6 +59,7 @@
#include "GPU_uniformbuffer.h"
#include "GPU_viewport.h"
#include "GPU_matrix.h"
+#include "GPU_select.h"
#include "IMB_colormanagement.h"
@@ -2547,8 +2548,23 @@ void DRW_framebuffer_select_id_release(ARegion *ar)
/* Read a block of pixels from the select frame buffer. */
void DRW_framebuffer_select_id_read(const rcti *rect, uint *r_buf)
{
+ /* clamp rect by texture */
+ rcti r = {
+ .xmin = 0,
+ .xmax = GPU_texture_width(g_select_buffer.texture_u32),
+ .ymin = 0,
+ .ymax = GPU_texture_height(g_select_buffer.texture_u32),
+ };
+
+ rcti rect_clamp = *rect;
+ BLI_rcti_isect(&r, rect, &rect_clamp);
+
GPU_texture_read_rect(
- g_select_buffer.texture_u32, GPU_DATA_UNSIGNED_INT, rect, r_buf);
+ g_select_buffer.texture_u32, GPU_DATA_UNSIGNED_INT, &rect_clamp, r_buf);
+
+ if (!BLI_rcti_compare(rect, &rect_clamp)) {
+ GPU_select_buffer_stride_realign(rect, &rect_clamp, r_buf);
+ }
}
/** \} */