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:
authorGermano Cavalcante <mano-wii>2021-11-02 18:33:28 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-11-03 18:10:37 +0300
commitaa0ac0035a0d3601672a0c732e3f8f932a36fc04 (patch)
tree6eca1da9c1cf3e0e28d17d8e6ed9d3ce8a4e1603 /source/blender/editors/space_view3d
parent8b516d8712024af9380fe3f7559c336042d612f5 (diff)
GPencil and Annotation: Use cached depth to perform depth testing operations
Operations such as erasing with occlusion and drawing on the surface require reading the depth buffer. However, this is being done with minimal efficiency. Currently, to read the depth corresponding to each point of the new stroke, a ReadPixel is called to send a message to the GPU and read the depth of the corresponding pixel in the VRAM. The communication between GPU and CPU is known to be a slow operation so it is good to be avoided. Therefore, save the entire depth buffer in a cache to be read directly from the RAM. (Also the `ED_view3d_autodist_depth` and `ED_view3d_autodist_depth_seg` have been removed since they are no longer used). Reviewed By: antoniov, fclem Differential Revision: https://developer.blender.org/D10894
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index e09453b9957..dab1b55072a 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -1094,17 +1094,10 @@ bool ED_view3d_autodist_simple(ARegion *region,
return ED_view3d_unproject_v3(region, centx, centy, depth, mouse_worldloc);
}
-bool ED_view3d_autodist_depth(ARegion *region, const int mval[2], int margin, float *depth)
-{
- *depth = view_autodist_depth_margin(region, mval, margin);
-
- return (*depth != FLT_MAX);
-}
-
static bool depth_segment_cb(int x, int y, void *userData)
{
struct {
- ARegion *region;
+ const ViewDepths *vd;
int margin;
float depth;
} *data = userData;
@@ -1114,27 +1107,25 @@ static bool depth_segment_cb(int x, int y, void *userData)
mval[0] = x;
mval[1] = y;
- depth = view_autodist_depth_margin(data->region, mval, data->margin);
-
- if (depth != FLT_MAX) {
+ if (ED_view3d_depth_read_cached(data->vd, mval, data->margin, &depth)) {
data->depth = depth;
return false;
}
return true;
}
-bool ED_view3d_autodist_depth_seg(
- ARegion *region, const int mval_sta[2], const int mval_end[2], int margin, float *depth)
+bool ED_view3d_depth_read_cached_seg(
+ const ViewDepths *vd, const int mval_sta[2], const int mval_end[2], int margin, float *depth)
{
struct {
- ARegion *region;
+ const ViewDepths *vd;
int margin;
float depth;
} data = {NULL};
int p1[2];
int p2[2];
- data.region = region;
+ data.vd = vd;
data.margin = margin;
data.depth = FLT_MAX;
@@ -1691,6 +1682,8 @@ bool ED_view3d_depth_read_cached(const ViewDepths *vd,
return true;
}
+ /* GPencil and Anotations also need the returned depth value to be high so that it is invalid. */
+ *r_depth = FLT_MAX;
return false;
}