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/gpencil/gpencil_primitive.c
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/gpencil/gpencil_primitive.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index f8cfc130e35..7382aca9a87 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -795,15 +795,16 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
(ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ?
V3D_DEPTH_GPENCIL_ONLY :
V3D_DEPTH_NO_GPENCIL,
- NULL);
+ &tgpi->depths);
depth_arr = MEM_mallocN(sizeof(float) * gps->totpoints, "depth_points");
+ const ViewDepths *depths = tgpi->depths;
tGPspoint *ptc = &points2D[0];
for (int i = 0; i < gps->totpoints; i++, ptc++) {
round_v2i_v2fl(mval_i, &ptc->x);
- if ((ED_view3d_autodist_depth(tgpi->region, mval_i, depth_margin, depth_arr + i) == 0) &&
- (i && (ED_view3d_autodist_depth_seg(
- tgpi->region, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) {
+ if ((ED_view3d_depth_read_cached(depths, mval_i, depth_margin, depth_arr + i) == 0) &&
+ (i && (ED_view3d_depth_read_cached_seg(
+ depths, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) {
interp_depth = true;
}
else {
@@ -1154,6 +1155,11 @@ static void gpencil_primitive_exit(bContext *C, wmOperator *op)
BLI_rng_free(tgpi->rng);
}
+ /* Remove depth buffer in cache. */
+ if (tgpi->depths) {
+ ED_view3d_depths_free(tgpi->depths);
+ }
+
MEM_freeN(tgpi);
}