diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-28 05:11:17 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-28 05:11:17 +0300 |
commit | c0d6627dc5fd069ec31c116e98e1817a0fe20ebb (patch) | |
tree | 3917fd81f0d7924da0e9099984f0558ff06bc788 | |
parent | c9a292793011cc813f20bcae0225a13cc82bdea4 (diff) | |
parent | 8a7eb6c4c1677cca8349ac250cd8f3c8ccdbd385 (diff) |
Merge branch 'master' into blender2.8
-rw-r--r-- | extern/cuew/src/cuew.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 12 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 111 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_sample_query.c | 26 |
6 files changed, 82 insertions, 78 deletions
diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c index 329dfbad3aa..ad216e66452 100644 --- a/extern/cuew/src/cuew.c +++ b/extern/cuew/src/cuew.c @@ -338,7 +338,7 @@ static int cuewCudaInit(void) { /* Default installation path. */ const char *cuda_paths[] = {"/usr/local/cuda/lib/libcuda.dylib", NULL}; #else - const char *cuda_paths[] = {"libcuda.so", NULL}; + const char *cuda_paths[] = {"libcuda.so", "libcuda.so.1", NULL}; #endif static int initialized = 0; static int result = 0; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 47778623561..45284c1805a 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2094,7 +2094,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event) viewzoom_apply( vod, &event->x, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0, - (use_mouse_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS)) ? vod->prev.event_xy : NULL); + (use_mouse_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS))); if (ED_screen_animation_playing(CTX_wm_manager(C))) { use_autokey = true; } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 2862ebd9b2f..2e6ffb63b78 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1101,7 +1101,7 @@ static Base *object_mouse_select_menu( } } -static bool selectbuffer_has_bones(const unsigned int *buffer, const unsigned int hits) +static bool selectbuffer_has_bones(const uint *buffer, const uint hits) { unsigned int i; for (i = 0; i < hits; i++) { @@ -1222,8 +1222,9 @@ finally: } /* returns basact */ -static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, - Base *startbase, bool has_bones, bool do_nearest) +static Base *mouse_select_eval_buffer( + ViewContext *vc, const uint *buffer, int hits, + Base *startbase, bool has_bones, bool do_nearest) { ViewLayer *view_layer = vc->view_layer; Base *base, *basact = NULL; diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 3240688d24b..42d152cc7de 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -73,7 +73,7 @@ static GPUSelectState g_select_state = {0}; /** * initialize and provide buffer for results */ -void GPU_select_begin(unsigned int *buffer, unsigned int bufsize, const rcti *input, char mode, int oldhits) +void GPU_select_begin(uint *buffer, uint bufsize, const rcti *input, char mode, int oldhits) { if (mode == GPU_SELECT_NEAREST_SECOND_PASS) { /* In the case hits was '-1', don't start the second pass since it's not going to give useful results. @@ -108,12 +108,12 @@ void GPU_select_begin(unsigned int *buffer, unsigned int bufsize, const rcti *in case ALGO_GL_QUERY: { g_select_state.use_cache = false; - gpu_select_query_begin((unsigned int (*)[4])buffer, bufsize / 4, input, mode, oldhits); + gpu_select_query_begin((uint (*)[4])buffer, bufsize / 4, input, mode, oldhits); break; } default: /* ALGO_GL_PICK */ { - gpu_select_pick_begin((unsigned int (*)[4])buffer, bufsize / 4, input, mode); + gpu_select_pick_begin((uint (*)[4])buffer, bufsize / 4, input, mode); break; } } @@ -126,7 +126,7 @@ void GPU_select_begin(unsigned int *buffer, unsigned int bufsize, const rcti *in * * \warning We rely on the order of object rendering on passes to be the same for this to work. */ -bool GPU_select_load_id(unsigned int id) +bool GPU_select_load_id(uint id) { /* if no selection mode active, ignore */ if (!g_select_state.select_is_active) @@ -177,9 +177,9 @@ void GPU_select_finalize(void) * Return number of hits and hits in buffer. * if \a dopass is true, we will do a second pass with occlusion queries to get the closest hit. */ -unsigned int GPU_select_end(void) +uint GPU_select_end(void) { - unsigned int hits = 0; + uint hits = 0; switch (g_select_state.algorithm) { case ALGO_GL_LEGACY: diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 8c102a307ea..9aff708d32a 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -62,14 +62,14 @@ /* For looping over a sub-region of a rect, could be moved into 'rct.c'*/ typedef struct SubRectStride { - unsigned int start; /* start here */ - unsigned int span; /* read these */ - unsigned int span_len; /* len times (read span 'len' times). */ - unsigned int skip; /* skip those */ + uint start; /* start here */ + uint span; /* read these */ + uint span_len; /* len times (read span 'len' times). */ + uint skip; /* skip those */ } SubRectStride; /* we may want to change back to float if uint isn't well supported */ -typedef unsigned int depth_t; +typedef uint depth_t; /** * Calculate values needed for looping over a sub-region (smaller buffer within a larger buffer). @@ -89,10 +89,10 @@ static void rect_subregion_stride_calc(const rcti *src, const rcti *dst, SubRect src->ymax >= dst->ymax && src->ymax >= dst->ymax); BLI_assert(x >= 0 && y >= 0); - r_sub->start = (unsigned int)((src_x * y) + x); - r_sub->span = (unsigned int)dst_x; - r_sub->span_len = (unsigned int)dst_y; - r_sub->skip = (unsigned int)(src_x - dst_x); + r_sub->start = (uint)((src_x * y) + x); + r_sub->span = (uint)dst_x; + r_sub->span_len = (uint)dst_y; + r_sub->skip = (uint)(src_x - dst_x); } /** @@ -114,11 +114,11 @@ BLI_INLINE bool depth_is_filled(const depth_t *prev, const depth_t *curr) /* store result of glReadPixels */ typedef struct DepthBufCache { struct DepthBufCache *next, *prev; - unsigned int id; + uint id; depth_t buf[0]; } DepthBufCache; -static DepthBufCache *depth_buf_malloc(unsigned int rect_len) +static DepthBufCache *depth_buf_malloc(uint rect_len) { DepthBufCache *rect = MEM_mallocN(sizeof(DepthBufCache) + sizeof(depth_t) * rect_len, __func__); rect->id = SELECT_ID_NONE; @@ -127,10 +127,10 @@ static DepthBufCache *depth_buf_malloc(unsigned int rect_len) static bool depth_buf_rect_depth_any( const DepthBufCache *rect_depth, - unsigned int rect_len) + uint rect_len) { const depth_t *curr = rect_depth->buf; - for (unsigned int i = 0; i < rect_len; i++, curr++) { + for (uint i = 0; i < rect_len; i++, curr++) { if (*curr != DEPTH_MAX) { return true; } @@ -143,7 +143,7 @@ static bool depth_buf_subrect_depth_any( const SubRectStride *sub_rect) { const depth_t *curr = rect_depth->buf + sub_rect->start; - for (unsigned int i = 0; i < sub_rect->span_len; i++) { + for (uint i = 0; i < sub_rect->span_len; i++) { const depth_t *curr_end = curr + sub_rect->span; for (; curr < curr_end; curr++, curr++) { if (*curr != DEPTH_MAX) { @@ -157,14 +157,14 @@ static bool depth_buf_subrect_depth_any( static bool depth_buf_rect_depth_any_filled( const DepthBufCache *rect_prev, const DepthBufCache *rect_curr, - unsigned int rect_len) + uint rect_len) { #if 0 return memcmp(rect_depth_a->buf, rect_depth_b->buf, rect_len * sizeof(depth_t)) != 0; #else const depth_t *prev = rect_prev->buf; const depth_t *curr = rect_curr->buf; - for (unsigned int i = 0; i < rect_len; i++, curr++, prev++) { + for (uint i = 0; i < rect_len; i++, curr++, prev++) { if (depth_is_filled(prev, curr)) { return true; } @@ -183,7 +183,7 @@ static bool depth_buf_subrect_depth_any_filled( /* same as above but different rect sizes */ const depth_t *prev = rect_src->buf + sub_rect->start; const depth_t *curr = rect_dst->buf + sub_rect->start; - for (unsigned int i = 0; i < sub_rect->span_len; i++) { + for (uint i = 0; i < sub_rect->span_len; i++) { const depth_t *curr_end = curr + sub_rect->span; for (; curr < curr_end; prev++, curr++) { if (depth_is_filled(prev, curr)) { @@ -203,7 +203,7 @@ static bool depth_buf_subrect_depth_any_filled( */ typedef struct DepthID { - unsigned int id; + uint id; depth_t depth; } DepthID; @@ -238,10 +238,10 @@ static int depth_cmp(const void *v1, const void *v2) /* depth sorting */ typedef struct GPUPickState { /* cache on initialization */ - unsigned int (*buffer)[4]; + uint (*buffer)[4]; /* buffer size (stores number of integers, for actual size multiply by sizeof integer)*/ - unsigned int bufsize; + uint bufsize; /* mode of operation */ char mode; @@ -258,14 +258,14 @@ typedef struct GPUPickState { /* Set after first draw */ bool is_init; bool is_finalized; - unsigned int prev_id; + uint prev_id; } gl; /* src: data stored in 'cache' and 'gl', * dst: use when cached region is smaller (where src -> dst isn't 1:1) */ struct { rcti clip_rect; - unsigned int rect_len; + uint rect_len; } src, dst; /* Store cache between `GPU_select_cache_begin/end` */ @@ -285,13 +285,13 @@ typedef struct GPUPickState { /* GPU_SELECT_PICK_ALL */ struct { DepthID *hits; - unsigned int hits_len; - unsigned int hits_len_alloc; + uint hits_len; + uint hits_len_alloc; } all; /* GPU_SELECT_PICK_NEAREST */ struct { - unsigned int *rect_id; + uint *rect_id; } nearest; }; } GPUPickState; @@ -300,7 +300,7 @@ typedef struct GPUPickState { static GPUPickState g_pick_state = {0}; void gpu_select_pick_begin( - unsigned int (*buffer)[4], unsigned int bufsize, + uint (*buffer)[4], uint bufsize, const rcti *input, char mode) { GPUPickState *ps = &g_pick_state; @@ -313,7 +313,7 @@ void gpu_select_pick_begin( ps->buffer = buffer; ps->mode = mode; - const unsigned int rect_len = (unsigned int)(BLI_rcti_size_x(input) * BLI_rcti_size_y(input)); + const uint rect_len = (uint)(BLI_rcti_size_x(input) * BLI_rcti_size_y(input)); ps->dst.clip_rect = *input; ps->dst.rect_len = rect_len; @@ -328,6 +328,9 @@ void gpu_select_pick_begin( glDepthMask(GL_TRUE); if (mode == GPU_SELECT_PICK_ALL) { + /* Note that other depth settings (such as #GL_LEQUAL) work too, + * since the depth is always cleared. + * Noting this for cases when depth picking is used where drawing calls change depth settings. */ glDepthFunc(GL_ALWAYS); } else { @@ -359,7 +362,7 @@ void gpu_select_pick_begin( #if 0 glReadPixels(UNPACK4(ps->gl.clip_readpixels), GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, ps->gl.rect_depth->buf); #else - for (unsigned int i = 0; i < rect_len; i++) { + for (uint i = 0; i < rect_len; i++) { ps->gl.rect_depth->buf[i] = DEPTH_MAX; } #endif @@ -383,8 +386,8 @@ void gpu_select_pick_begin( } else { /* Set to 0xff for SELECT_ID_NONE */ - ps->nearest.rect_id = MEM_mallocN(sizeof(unsigned int) * ps->dst.rect_len, __func__); - memset(ps->nearest.rect_id, 0xff, sizeof(unsigned int) * ps->dst.rect_len); + ps->nearest.rect_id = MEM_mallocN(sizeof(uint) * ps->dst.rect_len, __func__); + memset(ps->nearest.rect_id, 0xff, sizeof(uint) * ps->dst.rect_len); } } @@ -395,7 +398,7 @@ void gpu_select_pick_begin( static void gpu_select_load_id_pass_all(const DepthBufCache *rect_curr) { GPUPickState *ps = &g_pick_state; - const unsigned int id = rect_curr->id; + const uint id = rect_curr->id; /* find the best depth for this pass and store in 'all.hits' */ depth_t depth_best = DEPTH_MAX; @@ -407,15 +410,15 @@ static void gpu_select_load_id_pass_all(const DepthBufCache *rect_curr) if (ps->is_cached == false) { const depth_t *curr = rect_curr->buf; BLI_assert(ps->src.rect_len == ps->dst.rect_len); - const unsigned int rect_len = ps->src.rect_len; - for (unsigned int i = 0; i < rect_len; i++, curr++) { + const uint rect_len = ps->src.rect_len; + for (uint i = 0; i < rect_len; i++, curr++) { EVAL_TEST(); } } else { /* same as above but different rect sizes */ const depth_t *curr = rect_curr->buf + ps->cache.sub_rect.start; - for (unsigned int i = 0; i < ps->cache.sub_rect.span_len; i++) { + for (uint i = 0; i < ps->cache.sub_rect.span_len; i++) { const depth_t *curr_end = curr + ps->cache.sub_rect.span; for (; curr < curr_end; curr++) { EVAL_TEST(); @@ -439,10 +442,10 @@ 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) { GPUPickState *ps = &g_pick_state; - const unsigned int id = rect_curr->id; + const uint id = rect_curr->id; /* keep track each pixels ID in 'nearest.rect_id' */ if (id != SELECT_ID_NONE) { - unsigned int *id_ptr = ps->nearest.rect_id; + uint *id_ptr = ps->nearest.rect_id; /* Check against DEPTH_MAX because XRAY will clear the buffer, * so previously set values will become unset. @@ -456,8 +459,8 @@ static void gpu_select_load_id_pass_nearest(const DepthBufCache *rect_prev, cons const depth_t *prev = rect_prev->buf; const depth_t *curr = rect_curr->buf; BLI_assert(ps->src.rect_len == ps->dst.rect_len); - const unsigned int rect_len = ps->src.rect_len; - for (unsigned int i = 0; i < rect_len; i++, curr++, prev++, id_ptr++) { + const uint rect_len = ps->src.rect_len; + for (uint i = 0; i < rect_len; i++, curr++, prev++, id_ptr++) { EVAL_TEST(); } } @@ -465,7 +468,7 @@ static void gpu_select_load_id_pass_nearest(const DepthBufCache *rect_prev, cons /* same as above but different rect sizes */ const depth_t *prev = rect_prev->buf + ps->cache.sub_rect.start; const depth_t *curr = rect_curr->buf + ps->cache.sub_rect.start; - for (unsigned int i = 0; i < ps->cache.sub_rect.span_len; i++) { + for (uint i = 0; i < ps->cache.sub_rect.span_len; i++) { const depth_t *curr_end = curr + ps->cache.sub_rect.span; for (; curr < curr_end; prev++, curr++, id_ptr++) { EVAL_TEST(); @@ -480,11 +483,11 @@ static void gpu_select_load_id_pass_nearest(const DepthBufCache *rect_prev, cons } -bool gpu_select_pick_load_id(unsigned int id) +bool gpu_select_pick_load_id(uint id) { GPUPickState *ps = &g_pick_state; if (ps->gl.is_init) { - const unsigned int rect_len = ps->src.rect_len; + const uint rect_len = ps->src.rect_len; glReadPixels(UNPACK4(ps->gl.clip_readpixels), GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, ps->gl.rect_depth_test->buf); /* perform initial check since most cases the array remains unchanged */ @@ -540,7 +543,7 @@ void gpu_select_pick_finalize(void) ps->gl.is_finalized = true; } -unsigned int gpu_select_pick_end(void) +uint gpu_select_pick_end(void) { GPUPickState *ps = &g_pick_state; @@ -574,9 +577,9 @@ unsigned int gpu_select_pick_end(void) rect_depth_final = ps->gl.rect_depth; } - unsigned int maxhits = g_pick_state.bufsize; + uint maxhits = g_pick_state.bufsize; DepthID *depth_data; - unsigned int depth_data_len = 0; + uint depth_data_len = 0; if (g_pick_state.mode == GPU_SELECT_PICK_ALL) { depth_data = ps->all.hits; @@ -590,7 +593,7 @@ unsigned int gpu_select_pick_end(void) /* GPU_SELECT_PICK_NEAREST */ /* Over alloc (unlikely we have as many depths as pixels) */ - unsigned int depth_data_len_first_pass = 0; + uint depth_data_len_first_pass = 0; depth_data = MEM_mallocN(ps->dst.rect_len * sizeof(*depth_data), __func__); /* Partially de-duplicating copy, @@ -599,7 +602,7 @@ unsigned int gpu_select_pick_end(void) #define EVAL_TEST(i_src, i_dst) \ { \ - const unsigned int id = ps->nearest.rect_id[i_dst]; \ + 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) { \ @@ -616,15 +619,15 @@ unsigned int gpu_select_pick_end(void) { DepthID *depth_last = NULL; if (ps->is_cached == false) { - for (unsigned int i = 0; i < ps->src.rect_len; i++) { + for (uint i = 0; i < ps->src.rect_len; i++) { EVAL_TEST(i, i); } } else { /* 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.span_len; j++) { - const unsigned int i_src_end = i_src + ps->cache.sub_rect.span; + uint i_src = ps->cache.sub_rect.start, i_dst = 0; + for (uint j = 0; j < ps->cache.sub_rect.span_len; j++) { + const uint 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); } @@ -641,7 +644,7 @@ unsigned int gpu_select_pick_end(void) depth_data_len = 0; { DepthID *depth_last = NULL; - for (unsigned int i = 0; i < depth_data_len_first_pass; i++) { + for (uint i = 0; i < depth_data_len_first_pass; i++) { if (depth_last == NULL || depth_last->id != depth_data[i].id) { depth_last = &depth_data[depth_data_len++]; *depth_last = depth_data[i]; @@ -655,16 +658,16 @@ unsigned int gpu_select_pick_end(void) /* Finally sort each unique (id, depth) pair by depth * so the final hit-list is sorted by depth (nearest first) */ - unsigned int hits = 0; + uint hits = 0; if (depth_data_len > maxhits) { - hits = (unsigned int)-1; + hits = (uint)-1; } else { /* leave sorting up to the caller */ qsort(depth_data, depth_data_len, sizeof(DepthID), depth_cmp); - for (unsigned int i = 0; i < depth_data_len; i++) { + for (uint i = 0; i < depth_data_len; i++) { #ifdef DEBUG_PRINT printf(" hit: %u: depth %u\n", depth_data[i].id, depth_data[i].depth); #endif diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c index e3bd20f3776..b8c3e164055 100644 --- a/source/blender/gpu/intern/gpu_select_sample_query.c +++ b/source/blender/gpu/intern/gpu_select_sample_query.c @@ -54,20 +54,20 @@ typedef struct GPUQueryState { /* Tracks whether a query has been issued so that gpu_load_id can end the previous one */ bool query_issued; /* array holding the OpenGL query identifiers */ - unsigned int *queries; + uint *queries; /* array holding the id corresponding to each query */ - unsigned int *id; + uint *id; /* number of queries in *queries and *id */ - unsigned int num_of_queries; + uint num_of_queries; /* index to the next query to start */ - unsigned int active_query; + uint active_query; /* cache on initialization */ - unsigned int (*buffer)[4]; + uint (*buffer)[4]; /* buffer size (stores number of integers, for actual size multiply by sizeof integer)*/ - unsigned int bufsize; + uint bufsize; /* mode of operation */ char mode; - unsigned int index; + uint index; int oldhits; } GPUQueryState; @@ -75,7 +75,7 @@ static GPUQueryState g_query_state = {0}; void gpu_select_query_begin( - unsigned int (*buffer)[4], unsigned int bufsize, + uint (*buffer)[4], uint bufsize, const rcti *input, char mode, int oldhits) { @@ -126,7 +126,7 @@ void gpu_select_query_begin( } } -bool gpu_select_query_load_id(unsigned int id) +bool gpu_select_query_load_id(uint id) { if (g_query_state.query_issued) { glEndQuery(GL_SAMPLES_PASSED); @@ -161,19 +161,19 @@ bool gpu_select_query_load_id(unsigned int id) return true; } -unsigned int gpu_select_query_end(void) +uint gpu_select_query_end(void) { int i; - unsigned int hits = 0; - const unsigned int maxhits = g_query_state.bufsize; + uint hits = 0; + const uint maxhits = g_query_state.bufsize; if (g_query_state.query_issued) { glEndQuery(GL_SAMPLES_PASSED); } for (i = 0; i < g_query_state.active_query; i++) { - unsigned int result; + uint result; glGetQueryObjectuiv(g_query_state.queries[i], GL_QUERY_RESULT, &result); if (result > 0) { if (g_query_state.mode != GPU_SELECT_NEAREST_SECOND_PASS) { |