Blender
V3.3
|
#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 DepthBufCache * | depth_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 | |
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) |
Custom select code for picking small regions (not efficient for large regions). gpu_select_pick_*
API.
Definition in file gpu_select_pick.c.
#define ALLOC_DEPTHS 200 |
Definition at line 32 of file gpu_select_pick.c.
#define DEPTH_MAX 0xffffffff |
Definition at line 35 of file gpu_select_pick.c.
#define EVAL_TEST | ( | ) |
#define EVAL_TEST | ( | i_src, | |
i_dst | |||
) |
We may want to change back to float if uint
isn't well supported.
Definition at line 54 of file gpu_select_pick.c.
typedef struct DepthBufCache DepthBufCache |
Store result of GPU_framebuffer_read_depth.
typedef struct GPUPickState GPUPickState |
Depth sorting.
typedef struct SubRectStride SubRectStride |
|
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().
|
static |
Definition at line 112 of file gpu_select_pick.c.
References DepthBufCache::buf, and DEPTH_MAX.
Referenced by gpu_select_pick_load_id().
|
static |
Definition at line 139 of file gpu_select_pick.c.
References DepthBufCache::buf, depth_is_filled(), and blender::meshintersect::prev().
Referenced by gpu_select_pick_load_id().
|
static |
Definition at line 123 of file gpu_select_pick.c.
References DepthBufCache::buf, DEPTH_MAX, SubRectStride::skip, SubRectStride::span, SubRectStride::span_len, and SubRectStride::start.
Referenced by gpu_select_pick_cache_load_id().
|
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().
Definition at line 206 of file gpu_select_pick.c.
References DepthID::depth, v1, and v2.
Referenced by gpu_select_pick_end().
Definition at line 193 of file gpu_select_pick.c.
References DepthID::id, v1, and v2.
Referenced by gpu_select_pick_end().
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().
|
static |
Given 2x depths, we know are different - update the depth information use for both cached/uncached depth buffers.
Definition at line 388 of file gpu_select_pick.c.
References GPUPickState::all, ALLOC_DEPTHS, BLI_assert, DepthBufCache::buf, GPUPickState::cache, DEPTH_MAX, GPUPickState::dst, EVAL_TEST, g_pick_state, id, DepthBufCache::id, GPUPickState::is_cached, MEM_reallocN, GPUPickState::rect_len, SubRectStride::skip, SubRectStride::span, SubRectStride::span_len, GPUPickState::src, SubRectStride::start, GPUPickState::sub_rect, and UNLIKELY.
Referenced by gpu_select_pick_cache_load_id(), and gpu_select_pick_load_id().
|
static |
Definition at line 433 of file gpu_select_pick.c.
References BLI_assert, DepthBufCache::buf, GPUPickState::cache, GPUPickState::dst, EVAL_TEST, g_pick_state, DepthBufCache::id, GPUPickState::is_cached, GPUPickState::nearest, blender::meshintersect::prev(), GPUPickState::rect_len, SELECT_ID_NONE, SubRectStride::skip, SubRectStride::span, SubRectStride::span_len, GPUPickState::src, SubRectStride::start, and GPUPickState::sub_rect.
Referenced by gpu_select_pick_cache_load_id(), and gpu_select_pick_load_id().
void gpu_select_pick_begin | ( | GPUSelectResult * | buffer, |
const uint | buffer_len, | ||
const rcti * | input, | ||
eGPUSelectMode | mode | ||
) |
Definition at line 295 of file gpu_select_pick.c.
References GPUPickState::all, ALLOC_DEPTHS, BLI_assert, BLI_rcti_size_x(), BLI_rcti_size_y(), DepthBufCache::buf, buffer, GPUPickState::buffer, GPUPickState::buffer_len, GPUPickState::cache, GPUPickState::clip_readpixels, GPUPickState::clip_rect, depth_buf_malloc(), DEPTH_MAX, GPUPickState::depth_test, GPUPickState::dst, g_pick_state, GPUPickState::gpu, GPU_clear_depth(), GPU_color_mask(), GPU_debug_group_begin(), GPU_DEPTH_LESS_EQUAL, GPU_depth_mask(), GPU_depth_test(), GPU_depth_test_get(), GPU_scissor_get(), GPU_SELECT_PICK_ALL, GPU_viewport(), GPU_viewport_size_get_f(), GPU_write_mask_get(), input, GPUPickState::is_cached, GPUPickState::is_init, MEM_mallocN, GPUPickState::mode, GPUPickState::nearest, NULL, GPUPickState::prev_id, GPUPickState::rect_depth, GPUPickState::rect_depth_test, GPUPickState::rect_len, rect_subregion_stride_calc(), GPUPickState::scissor, GPUPickState::src, GPUPickState::sub_rect, UNPACK4, GPUPickState::use_cache, and GPUPickState::write_mask.
Referenced by GPU_select_begin().
Definition at line 705 of file gpu_select_pick.c.
References BLI_assert, g_pick_state, GPUPickState::is_cached, and GPUPickState::use_cache.
Referenced by GPU_select_begin().
Definition at line 715 of file gpu_select_pick.c.
References BLI_freelistN(), BLI_listbase_count(), GPUPickState::bufs, GPUPickState::cache, g_pick_state, GPUPickState::is_cached, and GPUPickState::use_cache.
Referenced by GPU_select_cache_end().
Definition at line 731 of file gpu_select_pick.c.
References BLI_assert, GPUPickState::bufs, GPUPickState::cache, depth_buf_subrect_depth_any(), depth_buf_subrect_depth_any_filled(), g_pick_state, gpu_select_load_id_pass_all(), gpu_select_load_id_pass_nearest(), GPU_SELECT_PICK_ALL, GPUPickState::is_cached, LISTBASE_FOREACH, GPUPickState::mode, NULL, and GPUPickState::sub_rect.
Referenced by GPU_select_cache_load_id().
Definition at line 538 of file gpu_select_pick.c.
References GPUPickState::all, BLI_addtail(), BLI_assert, GPUPickState::buffer, GPUPickState::buffer_len, GPUPickState::bufs, GPUPickState::cache, GPUSelectResult::depth, DepthID::depth, depth_cmp(), depth_id_cmp(), GPUPickState::depth_test, GPUPickState::dst, EVAL_TEST, g_pick_state, GPUPickState::gpu, GPU_debug_group_end(), GPU_depth_test(), GPU_SELECT_PICK_ALL, gpu_select_pick_load_id(), GPU_viewport(), GPU_write_mask(), GPUSelectResult::id, DepthID::id, GPUPickState::is_cached, GPUPickState::is_init, ListBase::last, MEM_freeN, MEM_mallocN, MEM_SAFE_FREE, GPUPickState::mode, GPUPickState::nearest, NULL, GPUPickState::prev_id, GPUPickState::rect_depth, GPUPickState::rect_depth_test, GPUPickState::rect_len, SubRectStride::skip, SubRectStride::span, SubRectStride::span_len, GPUPickState::src, SubRectStride::start, GPUPickState::sub_rect, UNPACK4, GPUPickState::use_cache, GPUPickState::viewport, and GPUPickState::write_mask.
Referenced by GPU_select_end().
Definition at line 726 of file gpu_select_pick.c.
References g_pick_state, and GPUPickState::is_cached.
Referenced by GPU_select_is_cached().
Definition at line 478 of file gpu_select_pick.c.
References BLI_addtail(), DepthBufCache::buf, GPUPickState::bufs, GPUPickState::cache, GPUPickState::clip_readpixels, depth_buf_malloc(), depth_buf_rect_depth_any(), depth_buf_rect_depth_any_filled(), fb(), g_pick_state, GPUPickState::gpu, GPU_clear_depth(), GPU_DATA_UINT, GPU_depth_mask(), GPU_depth_mask_get(), GPU_framebuffer_active_get(), GPU_framebuffer_read_depth(), gpu_select_load_id_pass_all(), gpu_select_load_id_pass_nearest(), GPU_SELECT_PICK_ALL, id, DepthBufCache::id, GPUPickState::is_init, GPUPickState::mode, GPUPickState::prev_id, GPUPickState::rect_depth, GPUPickState::rect_depth_test, GPUPickState::rect_len, GPUPickState::src, SWAP, UNPACK4, and GPUPickState::use_cache.
Referenced by GPU_select_load_id(), and gpu_select_pick_end().
|
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().
|
static |
Definition at line 293 of file gpu_select_pick.c.
Referenced by gpu_select_load_id_pass_all(), gpu_select_load_id_pass_nearest(), gpu_select_pick_begin(), gpu_select_pick_cache_begin(), gpu_select_pick_cache_end(), gpu_select_pick_cache_load_id(), gpu_select_pick_end(), gpu_select_pick_is_cached(), and gpu_select_pick_load_id().