[Bf-blender-cvs] [6addaf73931] master: Cleanup: use 'uint' for GPU_select
Campbell Barton
noreply at git.blender.org
Wed Feb 28 01:43:40 CET 2018
Commit: 6addaf73931b72b674fc2074de4ab9c9f1f49f1e
Author: Campbell Barton
Date: Wed Feb 28 11:37:39 2018 +1100
Branches: master
https://developer.blender.org/rB6addaf73931b72b674fc2074de4ab9c9f1f49f1e
Cleanup: use 'uint' for GPU_select
===================================================================
M source/blender/gpu/intern/gpu_select.c
M source/blender/gpu/intern/gpu_select_pick.c
M source/blender/gpu/intern/gpu_select_sample_query.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index e2837d96b0f..ff377ac703a 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 bd6b43ee42f..7657d329b8a 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -60,14 +60,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).
@@ -87,10 +87,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);
}
/**
@@ -112,11 +112,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;
@@ -125,10 +125,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;
}
@@ -141,7 +141,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) {
@@ -155,14 +155,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;
}
@@ -181,7 +181,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)) {
@@ -201,7 +201,7 @@ static bool depth_buf_subrect_depth_any_filled(
*/
typedef struct DepthID {
- unsigned int id;
+ uint id;
depth_t depth;
} DepthID;
@@ -236,10 +236,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;
@@ -256,14 +256,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` */
@@ -283,13 +283,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;
@@ -298,7 +298,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;
@@ -311,7 +311,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;
@@ -361,7 +361,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
@@ -385,8 +385,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);
}
}
@@ -397,7 +397,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;
@@ -409,15 +409,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();
@@ -441,10 +441,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) {
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list