[Bf-blender-cvs] [ed5ba4111d] temp-select-pick: Extra prints for debugging
Campbell Barton
noreply at git.blender.org
Wed Mar 8 12:01:18 CET 2017
Commit: ed5ba4111db0ac9e44ee45050d6cec025c2bac28
Author: Campbell Barton
Date: Wed Mar 8 18:43:38 2017 +1100
Branches: temp-select-pick
https://developer.blender.org/rBed5ba4111db0ac9e44ee45050d6cec025c2bac28
Extra prints for debugging
===================================================================
M 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 ad6d119bd6..0e060d4071 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -47,11 +47,14 @@
#include "gpu_select_private.h"
-/* #define DEBUG_PRINT */
+#define DEBUG_PRINT
/* Alloc number for depths */
#define ALLOC_DEPTHS 200
+/* Z-depth of cleared depth buffer */
+#define DEPTH_MAX 1.0
+
/* For looping over a sub-region of a rect, could be moved into 'rct.c'*/
typedef struct SubRectStride {
unsigned int start; /* start here */
@@ -143,6 +146,7 @@ typedef struct GPUPickState {
/* OpenGL drawing, never use when (is_cached == true). */
struct {
+ /* The current depth, accumulated as we draw */
DepthBufCache *rect_depth;
/* Scratch buffer, avoid allocs every time (when not caching) */
DepthBufCache *rect_depth_test;
@@ -243,7 +247,7 @@ void gpu_select_pick_begin(
#if 0
glReadPixels(UNPACK4(ps->gl.clip_readpixels), GL_DEPTH_COMPONENT, GL_FLOAT, ps->gl.rect_depth->buf);
#else
- copy_vn_fl(ps->gl.rect_depth->buf, rect_len, 1.0);
+ copy_vn_fl(ps->gl.rect_depth->buf, rect_len, DEPTH_MAX);
#endif
ps->gl.is_init = false;
@@ -290,7 +294,7 @@ static void gpu_select_load_id_pass(const DepthBufCache *rect_depth, const Depth
const unsigned int prev_id = rect_depth_test->id;
if (g_pick_state.mode == GPU_SELECT_PICK_SORT_ALL) {
/* find the best depth for this pass and store in 'all.hits' */
- float depth_best = FLT_MAX;
+ float depth_best = DEPTH_MAX;
#define EVAL_TEST() \
if (*curr != *prev) { \
@@ -313,8 +317,8 @@ static void gpu_select_load_id_pass(const DepthBufCache *rect_depth, const Depth
const float *prev = rect_depth->buf + ps->cache.sub_rect.start;
const float *curr = rect_depth_test->buf + ps->cache.sub_rect.start;
for (unsigned int i = 0; i < ps->cache.sub_rect.len; i++) {
- const float *prev_final = prev + ps->cache.sub_rect.span;
- for (; prev < prev_final; prev++, curr++) {
+ const float *prev_end = prev + ps->cache.sub_rect.span;
+ for (; prev < prev_end; prev++, curr++) {
EVAL_TEST();
}
prev += ps->cache.sub_rect.skip;
@@ -357,8 +361,8 @@ static void gpu_select_load_id_pass(const DepthBufCache *rect_depth, const Depth
const float *prev = rect_depth->buf + ps->cache.sub_rect.start;
const float *curr = rect_depth_test->buf + ps->cache.sub_rect.start;
for (unsigned int i = 0; i < ps->cache.sub_rect.len; i++) {
- const float *prev_final = prev + ps->cache.sub_rect.span;
- for (; prev < prev_final; prev++, curr++, id_ptr++) {
+ const float *prev_end = prev + ps->cache.sub_rect.span;
+ for (; prev < prev_end; prev++, curr++, id_ptr++) {
EVAL_TEST();
}
prev += ps->cache.sub_rect.skip;
@@ -390,7 +394,7 @@ bool gpu_select_pick_load_id(unsigned int id)
ps->gl.rect_depth = depth_buf_malloc(ps->src.rect_len);
}
- SWAP(DepthBufCache *, ps->gl.rect_depth_test, ps->gl.rect_depth);
+ SWAP(DepthBufCache *, ps->gl.rect_depth, ps->gl.rect_depth_test);
}
}
@@ -404,6 +408,10 @@ unsigned int gpu_select_pick_end(void)
{
GPUPickState *ps = &g_pick_state;
+#ifdef DEBUG_PRINT
+ printf("%s\n", __func__);
+#endif
+
if (ps->is_cached == false) {
if (ps->gl.is_init) {
/* force finishing last pass */
@@ -481,8 +489,8 @@ unsigned int gpu_select_pick_end(void)
/* same as above but different rect sizes */
unsigned int i_src = ps->cache.sub_rect.start, i_dst = 0;
for (unsigned int j = 0; j < ps->cache.sub_rect.len; j++) {
- const unsigned int i_src_final = i_src + ps->cache.sub_rect.span;
- for (; i_src < i_src_final; i_src++, i_dst++) {
+ const unsigned int i_src_end = i_src + ps->cache.sub_rect.span;
+ for (; i_src < i_src_end; i_src++, i_dst++) {
EVAL_TEST(i_src, i_dst);
}
i_src += ps->cache.sub_rect.skip;
@@ -521,6 +529,9 @@ unsigned int gpu_select_pick_end(void)
qsort(depth_data, depth_data_len, sizeof(DepthID), depth_cmp);
for (unsigned int i = 0; i < depth_data_len; i++) {
+#ifdef DEBUG_PRINT
+ printf(" hit: %d: depth %.15f\n", depth_data[i].id, depth_data[i].depth);
+#endif
/* first 3 are dummy values */
g_pick_state.buffer[hits][0] = 1;
g_pick_state.buffer[hits][1] = 0x0;
@@ -588,11 +599,11 @@ void gpu_select_pick_cache_load_id(void)
{
BLI_assert(g_pick_state.is_cached == true);
GPUPickState *ps = &g_pick_state;
- for (DepthBufCache *rect_depth = ps->cache.bufs.first; rect_depth; rect_depth = rect_depth->next) {
- if (rect_depth->next != NULL) {
#ifdef DEBUG_PRINT
- printf("%s: using cached depth buffer\n", __func__);
+ printf("%s (building depth from cache)\n", __func__);
#endif
+ for (DepthBufCache *rect_depth = ps->cache.bufs.first; rect_depth; rect_depth = rect_depth->next) {
+ if (rect_depth->next != NULL) {
gpu_select_load_id_pass(rect_depth, rect_depth->next);
}
}
More information about the Bf-blender-cvs
mailing list