Blender  V2.93
Classes | Macros | Typedefs | Functions | Variables
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_immediate.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)
 

Typedefs

typedef struct SubRectStride SubRectStride
 
typedef uint depth_t
 
typedef struct DepthBufCache DepthBufCache
 
typedef struct DepthID DepthID
 
typedef struct GPUPickState GPUPickState
 

Functions

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)
 
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)
 
static int depth_id_cmp (const void *v1, const void *v2)
 
static int depth_cmp (const void *v1, const void *v2)
 
void gpu_select_pick_begin (uint(*buffer)[4], uint bufsize, const rcti *input, char 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)
 
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)
 

Variables

static GPUPickState g_pick_state = {0}
 

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 49 of file gpu_select_pick.c.

◆ DEPTH_MAX

#define DEPTH_MAX   0xffffffff

Definition at line 52 of file gpu_select_pick.c.

◆ EVAL_TEST [1/3]

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

◆ 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)

◆ 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:83
uint depth_t
#define SELECT_ID_NONE

Typedef Documentation

◆ depth_t

typedef uint depth_t

Definition at line 67 of file gpu_select_pick.c.

◆ DepthBufCache

typedef struct DepthBufCache DepthBufCache

◆ DepthID

typedef struct DepthID DepthID

◆ GPUPickState

typedef struct GPUPickState GPUPickState

◆ SubRectStride

typedef struct SubRectStride SubRectStride

Function Documentation

◆ depth_buf_malloc()

static DepthBufCache* depth_buf_malloc ( uint  rect_len)
static

Definition at line 116 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 123 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

Definition at line 150 of file gpu_select_pick.c.

References DepthBufCache::buf, depth_is_filled(), and DepthBufCache::prev.

Referenced by gpu_select_pick_load_id().

◆ 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 171 of file gpu_select_pick.c.

References DepthBufCache::buf, depth_is_filled(), DepthBufCache::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 215 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 202 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 97 of file gpu_select_pick.c.

References DEPTH_MAX.

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 ( uint(*)  buffer[4],
uint  bufsize,
const rcti input,
char  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  )

Definition at line 722 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 74 of file gpu_select_pick.c.

References BLI_assert, BLI_rcti_size_x(), BLI_rcti_size_y(), SubRectStride::skip, SubRectStride::span, SubRectStride::span_len, 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