[Bf-blender-cvs] [e442f5af76] temp-select-pick: Cleanup, minor fixes
Campbell Barton
noreply at git.blender.org
Tue Mar 7 16:51:30 CET 2017
Commit: e442f5af765ca5a6aa05e59899b9d3cfaada0de4
Author: Campbell Barton
Date: Wed Mar 8 02:54:13 2017 +1100
Branches: temp-select-pick
https://developer.blender.org/rBe442f5af765ca5a6aa05e59899b9d3cfaada0de4
Cleanup, minor fixes
===================================================================
M source/blender/gpu/intern/gpu_select.c
M source/blender/gpu/intern/gpu_select_pick.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index 4334f0b30f..f47ba4dcde 100644
--- a/source/blender/gpu/intern/gpu_select.c
+++ b/source/blender/gpu/intern/gpu_select.c
@@ -156,6 +156,7 @@ bool GPU_select_query_check_active(void)
void GPU_select_cache_begin(void)
{
/* validate on GPU_select_begin, clear if not supported */
+ BLI_assert(g_select_state.use_cache == false);
g_select_state.use_cache = true;
}
@@ -174,6 +175,8 @@ void GPU_select_cache_load_id(void)
void GPU_select_cache_end(void)
{
+ BLI_assert(g_select_state.use_cache == true);
+
if (!g_select_state.use_gpu_select) {
/* pass */
}
@@ -183,6 +186,7 @@ void GPU_select_cache_end(void)
else {
/* pass */
}
+ g_select_state.use_cache = false;
}
bool GPU_select_is_cached(void)
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 0282c745af..c41c85c912 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -136,9 +136,6 @@ typedef struct GPUPickState {
/* mode of operation */
char mode;
- unsigned int prev_id;
- bool is_init;
-
/* OpenGL drawing, (use_cached == false). */
struct {
DepthBufCache *rect_depth;
@@ -147,6 +144,9 @@ typedef struct GPUPickState {
/* Pass to glReadPixels (x,y,w,h) */
int clip_readpixels[4];
+
+ bool is_init;
+ unsigned int prev_id;
} gl;
/* Data stored in 'cache' and 'gl' */
@@ -228,6 +228,9 @@ void gpu_select_pick_begin(
ps->gl.rect_depth_test = depth_buf_malloc(rect_len);
ps->gl.rect_depth = depth_buf_malloc(rect_len);
+ ps->gl.is_init = false;
+ ps->gl.prev_id = 0;
+
/* TODO, find exact value this will be and write into it (clip-far?) */
glReadPixels(UNPACK4(ps->gl.clip_readpixels), GL_DEPTH_COMPONENT, GL_FLOAT, ps->gl.rect_depth->buf);
@@ -245,12 +248,10 @@ void gpu_select_pick_begin(
else {
/* src.clip_rect -> dst.clip_rect */
rect_subregion_stride_calc(&ps->src.clip_rect, &ps->dst.clip_rect, &ps->cache.sub_rect);
+ BLI_assert(ps->gl.rect_depth == NULL);
+ BLI_assert(ps->gl.rect_depth_test == NULL);
}
- /* generate cache */
- ps->prev_id = 0;
- ps->is_init = false;
-
if (mode == GPU_SELECT_PICK_SORT_ALL) {
ps->all.hits = MEM_mallocN(sizeof(*ps->all.hits) * ALLOC_DEPTHS, __func__);
ps->all.hits_len = 0;
@@ -357,12 +358,12 @@ static void gpu_select_load_id_pass(
bool gpu_select_pick_load_id(unsigned int id)
{
GPUPickState *ps = &g_pick_state;
- if (ps->is_init) {
+ if (ps->gl.is_init) {
const unsigned int rect_len = ps->src.rect_len;
glReadPixels(UNPACK4(ps->gl.clip_readpixels), GL_DEPTH_COMPONENT, GL_FLOAT, ps->gl.rect_depth_test);
/* perform initial memcmp since most cases the array remains unchanged */
if (memcmp(ps->gl.rect_depth->buf, ps->gl.rect_depth_test->buf, rect_len * sizeof(float)) != 0) {
- ps->gl.rect_depth_test->id = ps->prev_id;
+ ps->gl.rect_depth_test->id = ps->gl.prev_id;
gpu_select_load_id_pass(ps->gl.rect_depth, ps->gl.rect_depth_test);
@@ -375,8 +376,9 @@ bool gpu_select_pick_load_id(unsigned int id)
SWAP(DepthBufCache *, ps->gl.rect_depth_test, ps->gl.rect_depth);
}
}
- ps->prev_id = id;
- ps->is_init = true;
+
+ ps->gl.is_init = true;
+ ps->gl.prev_id = id;
return true;
}
@@ -386,9 +388,9 @@ unsigned int gpu_select_pick_end(void)
GPUPickState *ps = &g_pick_state;
if (ps->is_cached == false) {
- if (ps->is_init) {
+ if (ps->gl.is_init) {
/* force finishing last pass */
- gpu_select_pick_load_id(ps->prev_id);
+ gpu_select_pick_load_id(ps->gl.prev_id);
}
glPopAttrib();
More information about the Bf-blender-cvs
mailing list