33#define ALLOC_DEPTHS 200
36#define DEPTH_MAX 0xffffffff
87 return (*prev != *curr) && (*curr !=
DEPTH_MAX);
117 for (
uint i = 0;
i < rect_len;
i++, curr++) {
131 for (; curr < curr_end; curr++, curr++) {
136 curr += sub_rect->
skip;
146 return memcmp(rect_depth_a->buf, rect_depth_b->buf, rect_len *
sizeof(
depth_t)) != 0;
150 for (
uint i = 0;
i < rect_len;
i++, curr++, prev++) {
171 for (; curr < curr_end; prev++, curr++) {
176 prev += sub_rect->
skip;
177 curr += sub_rect->
skip;
198 if (d1->
id < d2->id) {
201 if (d1->
id > d2->id) {
211 if (d1->
depth < d2->depth) {
214 if (d1->
depth > d2->depth) {
301 printf(
"%s: mode=%d, use_cache=%d, is_cache=%d\n",
354 for (
uint i = 0;
i < rect_len;
i++) {
389 const uint id = rect_curr->
id;
394 if (depth_best > *curr) { \
395 depth_best = *curr; \
403 for (
uint i = 0;
i < rect_len;
i++, curr++) {
412 for (; curr < curr_end; curr++) {
429 d->
depth = depth_best;
436 const uint id = rect_curr->
id;
445 if (depth_is_filled(prev, curr)) { \
455 for (
uint i = 0;
i < rect_len;
i++, curr++, prev++, id_ptr++) {
465 for (; curr < curr_end; prev++, curr++, id_ptr++) {
494 bool do_pass =
false;
575 uint depth_data_len = 0;
589 uint depth_data_len_first_pass = 0;
590 depth_data =
static_cast<DepthID *
>(
597#define EVAL_TEST(i_src, i_dst) \
599 const uint id = ps->nearest.rect_id[i_dst]; \
600 if (id != SELECT_ID_NONE) { \
601 const depth_t depth = rect_depth_final->buf[i_src]; \
602 if (depth_last == nullptr || depth_last->id != id) { \
603 DepthID *d = &depth_data[depth_data_len_first_pass++]; \
607 else if (depth_last->depth > depth) { \
608 depth_last->depth = depth; \
626 for (; i_src < i_src_end; i_src++, i_dst++) {
642 for (
uint i = 0;
i < depth_data_len_first_pass;
i++) {
643 if (depth_last ==
nullptr || depth_last->
id != depth_data[
i].
id) {
644 depth_last = &depth_data[depth_data_len++];
645 *depth_last = depth_data[
i];
647 else if (depth_last->
depth > depth_data[
i].
depth) {
662 for (
uint i = 0;
i < depth_data_len;
i++) {
664 printf(
" hit: %u: depth %u\n", depth_data[
i].
id, depth_data[
i].depth);
667 hit_result.
id = depth_data[
i].
id;
669 g_pick_state.buffer->storage.append_unchecked(hit_result);
732 printf(
"%s (building depth from cache)\n", __func__);
735 if (rect_depth->next !=
nullptr) {
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void GPU_debug_group_end()
void GPU_debug_group_begin(const char *name)
void GPU_clear_depth(float depth)
void GPU_framebuffer_read_depth(blender::gpu::FrameBuffer *fb, int x, int y, int width, int height, eGPUDataFormat data_format, void *r_data)
blender::gpu::FrameBuffer * GPU_framebuffer_active_get()
void GPU_depth_mask(bool depth)
void GPU_depth_test(GPUDepthTest test)
void GPU_color_mask(bool r, bool g, bool b, bool a)
GPUDepthTest GPU_depth_test_get()
void GPU_viewport(int x, int y, int width, int height)
void GPU_write_mask(GPUWriteMask mask)
GPUWriteMask GPU_write_mask_get()
void GPU_viewport_size_get_f(float coords[4])
bool GPU_depth_mask_get()
void GPU_scissor_get(int coords[4])
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
bool gpu_select_pick_load_id(uint id, bool end)
void gpu_select_pick_begin(GPUSelectBuffer *buffer, const rcti *input, GPUSelectMode mode)
static DepthBufCache * depth_buf_malloc(uint rect_len)
static bool depth_buf_subrect_depth_any(const DepthBufCache *rect_depth, const SubRectStride *sub_rect)
static int depth_cmp(const void *v1, const void *v2)
uint gpu_select_pick_end()
void gpu_select_pick_cache_begin()
BLI_INLINE bool depth_is_filled(const depth_t *prev, const depth_t *curr)
static bool depth_buf_subrect_depth_any_filled(const DepthBufCache *rect_src, const DepthBufCache *rect_dst, const SubRectStride *sub_rect)
static void rect_subregion_stride_calc(const rcti *src, const rcti *dst, SubRectStride *r_sub)
bool gpu_select_pick_is_cached()
static int depth_id_cmp(const void *v1, const void *v2)
void gpu_select_pick_cache_load_id()
static GPUPickState g_pick_state
static void gpu_select_load_id_pass_all(const DepthBufCache *rect_curr)
static bool depth_buf_rect_depth_any_filled(const DepthBufCache *rect_prev, const DepthBufCache *rect_curr, uint rect_len)
static void gpu_select_load_id_pass_nearest(const DepthBufCache *rect_prev, const DepthBufCache *rect_curr)
void gpu_select_pick_cache_end()
static bool depth_buf_rect_depth_any(const DepthBufCache *rect_depth, uint rect_len)
bool all(VecOp< bool, D >) RET
BLI_INLINE float fb(float length, float L)
void * MEM_mallocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
DepthBufCache * rect_depth
struct GPUPickState::@165256152023044360216152151233240056157011130047 dst
struct GPUPickState::@277056311340227302307104132302102101063115033051 cache
struct GPUPickState::@165256152023044360216152151233240056157011130047 src
struct GPUPickState::@360224015057162344327242036171332311344074073365::@313131235225103262053006161310024255225003066302 all
struct GPUPickState::@306061261262327106340214205126063074306041315030 gpu
struct GPUPickState::@360224015057162344327242036171332311344074073365::@165357267111104347001116107022334107201367020210 nearest
DepthBufCache * rect_depth_test