diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-04-26 16:33:16 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-04-26 16:33:49 +0300 |
commit | 86914e713347082aed8d77b663a02068c03b6313 (patch) | |
tree | be234ae3f5c15d69e5e3fa872874bc7c743f448f /source/blender/gpu | |
parent | 50d75cd528b904760426ff9bcc31a3794e995edb (diff) |
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.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 7 |
1 files changed, 7 insertions, 0 deletions
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, |