Blender  V3.3
Classes | Macros
gpu_select_pick.c File Reference
#include <float.h>
#include <stdlib.h>
#include <string.h>
#include "GPU_debug.h"
#include "GPU_framebuffer.h"
#include "GPU_select.h"
#include "GPU_state.h"
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "gpu_select_private.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Classes

struct  SubRectStride
 
struct  DepthBufCache
 
struct  DepthID
 
struct  GPUPickState
 

Macros

#define ALLOC_DEPTHS   200
 
#define DEPTH_MAX   0xffffffff
 
#define EVAL_TEST()
 
#define EVAL_TEST()
 
#define EVAL_TEST(i_src, i_dst)
 

Functions

Caching

Support multiple begin/end's reusing depth buffers.

void gpu_select_pick_cache_begin (void)
 
void gpu_select_pick_cache_end (void)
 
bool gpu_select_pick_is_cached (void)
 
void gpu_select_pick_cache_load_id (void)
 

#SubRectStride

typedef struct SubRectStride SubRectStride
 
typedef uint depth_t
 
static void rect_subregion_stride_calc (const rcti *src, const rcti *dst, SubRectStride *r_sub)
 
BLI_INLINE bool depth_is_filled (const depth_t *prev, const depth_t *curr)
 

#DepthBufCache

Result of reading GPU_framebuffer_read_depth, use for both cache and non-cached storage.

typedef struct DepthBufCache DepthBufCache
 
static DepthBufCachedepth_buf_malloc (uint rect_len)
 
static bool depth_buf_rect_depth_any (const DepthBufCache *rect_depth, uint rect_len)
 
static bool depth_buf_subrect_depth_any (const DepthBufCache *rect_depth, const SubRectStride *sub_rect)
 
static bool depth_buf_rect_depth_any_filled (const DepthBufCache *rect_prev, const DepthBufCache *rect_curr, uint rect_len)
 
static bool depth_buf_subrect_depth_any_filled (const DepthBufCache *rect_src, const DepthBufCache *rect_dst, const SubRectStride *sub_rect)
 

#DepthID

Internal structure for storing hits.

typedef struct DepthID DepthID
 
static int depth_id_cmp (const void *v1, const void *v2)
 
static int depth_cmp (const void *v1, const void *v2)
 

Main Selection Begin/End/Load API

typedef struct GPUPickState GPUPickState
 
static GPUPickState g_pick_state = {0}
 
void gpu_select_pick_begin (GPUSelectResult *buffer, const uint buffer_len, const rcti *input, eGPUSelectMode mode)
 
static void gpu_select_load_id_pass_all (const DepthBufCache *rect_curr)
 
static void gpu_select_load_id_pass_nearest (const DepthBufCache *rect_prev, const DepthBufCache *rect_curr)
 
bool gpu_select_pick_load_id (uint id, bool end)
 
uint gpu_select_pick_end (void)
 

Detailed Description

Custom select code for picking small regions (not efficient for large regions). gpu_select_pick_* API.

Definition in file gpu_select_pick.c.

Macro Definition Documentation

◆ ALLOC_DEPTHS

#define ALLOC_DEPTHS   200

Definition at line 32 of file gpu_select_pick.c.

◆ DEPTH_MAX

#define DEPTH_MAX   0xffffffff

Definition at line 35 of file gpu_select_pick.c.

◆ EVAL_TEST [1/3]

#define EVAL_TEST ( )
Value:
if (depth_best > *curr) { \
depth_best = *curr; \
} \
((void)0)
SyclQueue void void size_t num_bytes void

◆ EVAL_TEST [2/3]

#define EVAL_TEST ( )
Value:
if (depth_is_filled(prev, curr)) { \
*id_ptr = id; \
} \
((void)0)
BLI_INLINE bool depth_is_filled(const depth_t *prev, const depth_t *curr)
SymEdge< T > * prev(const SymEdge< T > *se)
Definition: delaunay_2d.cc:105

◆ EVAL_TEST [3/3]

#define EVAL_TEST (   i_src,
  i_dst 
)
Value:
{ \
const uint id = ps->nearest.rect_id[i_dst]; \
if (id != SELECT_ID_NONE) { \
const depth_t depth = rect_depth_final->buf[i_src]; \
if (depth_last == NULL || depth_last->id != id) { \
DepthID *d = &depth_data[depth_data_len_first_pass++]; \
d->id = id; \
d->depth = depth; \
} \
else if (depth_last->depth > depth) { \
depth_last->depth = depth; \
} \
} \
} \
((void)0)
unsigned int uint
Definition: BLI_sys_types.h:67
uint depth_t
#define SELECT_ID_NONE

Typedef Documentation

◆ depth_t

typedef uint depth_t

We may want to change back to float if uint isn't well supported.

Definition at line 54 of file gpu_select_pick.c.

◆ DepthBufCache

typedef struct DepthBufCache DepthBufCache

Store result of GPU_framebuffer_read_depth.

◆ DepthID

typedef struct DepthID DepthID

◆ GPUPickState

typedef struct GPUPickState GPUPickState

Depth sorting.

◆ SubRectStride

typedef struct SubRectStride SubRectStride

For looping over a sub-region of a rcti, could be moved into 'rct.c'.

Function Documentation

◆ depth_buf_malloc()

static DepthBufCache* depth_buf_malloc ( uint  rect_len)
static

Definition at line 105 of file gpu_select_pick.c.

References DepthBufCache::id, MEM_mallocN, and SELECT_ID_NONE.

Referenced by gpu_select_pick_begin(), and gpu_select_pick_load_id().

◆ depth_buf_rect_depth_any()

static bool depth_buf_rect_depth_any ( const DepthBufCache rect_depth,
uint  rect_len 
)
static

Definition at line 112 of file gpu_select_pick.c.

References DepthBufCache::buf, and DEPTH_MAX.

Referenced by gpu_select_pick_load_id().

◆ depth_buf_rect_depth_any_filled()

static bool depth_buf_rect_depth_any_filled ( const DepthBufCache rect_prev,
const DepthBufCache rect_curr,
uint  rect_len 
)
static

◆ depth_buf_subrect_depth_any()

static bool depth_buf_subrect_depth_any ( const DepthBufCache rect_depth,
const SubRectStride sub_rect 
)
static

◆ depth_buf_subrect_depth_any_filled()

static bool depth_buf_subrect_depth_any_filled ( const DepthBufCache rect_src,
const DepthBufCache rect_dst,
const SubRectStride sub_rect 
)
static

Both buffers are the same size, just check if the sub-rect contains any differences.

Definition at line 160 of file gpu_select_pick.c.

References DepthBufCache::buf, depth_is_filled(), blender::meshintersect::prev(), SubRectStride::skip, SubRectStride::span, SubRectStride::span_len, and SubRectStride::start.

Referenced by gpu_select_pick_cache_load_id().

◆ depth_cmp()

static int depth_cmp ( const void v1,
const void v2 
)
static

Definition at line 206 of file gpu_select_pick.c.

References DepthID::depth, v1, and v2.

Referenced by gpu_select_pick_end().

◆ depth_id_cmp()

static int depth_id_cmp ( const void v1,
const void v2 
)
static

Definition at line 193 of file gpu_select_pick.c.

References DepthID::id, v1, and v2.

Referenced by gpu_select_pick_end().

◆ depth_is_filled()

BLI_INLINE bool depth_is_filled ( const depth_t prev,
const depth_t curr 
)

Ignore depth clearing as a change, only check if its been changed and filled in (ignore clearing since XRAY does this).

Definition at line 84 of file gpu_select_pick.c.

References DEPTH_MAX, and blender::meshintersect::prev().

Referenced by depth_buf_rect_depth_any_filled(), and depth_buf_subrect_depth_any_filled().

◆ gpu_select_load_id_pass_all()

static void gpu_select_load_id_pass_all ( const DepthBufCache rect_curr)
static

◆ gpu_select_load_id_pass_nearest()

static void gpu_select_load_id_pass_nearest ( const DepthBufCache rect_prev,
const DepthBufCache rect_curr 
)
static

◆ gpu_select_pick_begin()

void gpu_select_pick_begin ( GPUSelectResult buffer,
const uint  buffer_len,
const rcti input,
eGPUSelectMode  mode 
)

◆ gpu_select_pick_cache_begin()

void gpu_select_pick_cache_begin ( void  )

◆ gpu_select_pick_cache_end()

void gpu_select_pick_cache_end ( void  )

◆ gpu_select_pick_cache_load_id()

void gpu_select_pick_cache_load_id ( void  )

◆ gpu_select_pick_end()

uint gpu_select_pick_end ( void  )

◆ gpu_select_pick_is_cached()

bool gpu_select_pick_is_cached ( void  )
Returns
true if drawing is not needed.

Definition at line 726 of file gpu_select_pick.c.

References g_pick_state, and GPUPickState::is_cached.

Referenced by GPU_select_is_cached().

◆ gpu_select_pick_load_id()

bool gpu_select_pick_load_id ( uint  id,
bool  end 
)

◆ rect_subregion_stride_calc()

static void rect_subregion_stride_calc ( const rcti src,
const rcti dst,
SubRectStride r_sub 
)
static

Calculate values needed for looping over a sub-region (smaller buffer within a larger buffer).

'src' must be bigger than 'dst'.

Definition at line 61 of file gpu_select_pick.c.

References BLI_assert, BLI_rcti_size_x(), BLI_rcti_size_y(), SubRectStride::skip, SubRectStride::span, SubRectStride::span_len, src, SubRectStride::start, x, rcti::xmax, rcti::xmin, y, rcti::ymax, and rcti::ymin.

Referenced by gpu_select_pick_begin().

Variable Documentation

◆ g_pick_state

GPUPickState g_pick_state = {0}
static