From 86914e713347082aed8d77b663a02068c03b6313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 26 Apr 2019 15:33:16 +0200 Subject: GPUSelect: Don't read depth on every draw If the draw uses the same id as the previous draw, there is no need to read the depth buffer at this point, avoiding a CPU-GPU sync bubble. Fixes T62511 Selection is significantly slower in production scenes. With this patch glReadPixels is not the bottleneck. Regular drawing Is still very slow so I would suggest fixing the regular drawing first before trying to improve the selection algorithm. --- source/blender/gpu/intern/gpu_select_pick.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/blender/gpu/intern/gpu_select_pick.c') diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 6c3e05912b0..ffd4cd6efbc 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -479,7 +479,14 @@ static void gpu_select_load_id_pass_nearest(const DepthBufCache *rect_prev, bool gpu_select_pick_load_id(uint id) { GPUPickState *ps = &g_pick_state; + if (ps->gl.is_init) { + if (id == ps->gl.prev_id) { + /* No need to read if we are still drawing for the same id since + * all these depths will be merged / deduplicated in the end. */ + return true; + } + const uint rect_len = ps->src.rect_len; glReadPixels(UNPACK4(ps->gl.clip_readpixels), GL_DEPTH_COMPONENT, -- cgit v1.2.3