diff options
author | Campbell Barton <campbell@blender.org> | 2022-01-31 05:01:27 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-01-31 05:06:56 +0300 |
commit | 9ccdad8a2173e14848fbfa5401210d8ffb074352 (patch) | |
tree | 6a5f8d56d35340d80ac7287ce2e89a46332f17b5 /source/blender/gpu/intern | |
parent | 57f6aa4d832cc24cc85ebc530dc6c8c51453120d (diff) |
Cleanup: use enum type for selection mode & internal algorithm enum
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 11 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 10 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_private.h | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_sample_query.cc | 4 |
4 files changed, 20 insertions, 12 deletions
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 958aab65b57..741df05799f 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -43,22 +43,22 @@ * \{ */ /* Internal algorithm used */ -enum { +typedef enum eGPUSelectAlgo { /** glBegin/EndQuery(GL_SAMPLES_PASSED... ), `gpu_select_query.c` * Only sets 4th component (ID) correctly. */ ALGO_GL_QUERY = 1, /** Read depth buffer for every drawing pass and extract depths, `gpu_select_pick.c` * Only sets 4th component (ID) correctly. */ ALGO_GL_PICK = 2, -}; +} eGPUSelectAlgo; typedef struct GPUSelectState { /* To ignore selection id calls when not initialized */ bool select_is_active; /* mode of operation */ - char mode; + eGPUSelectMode mode; /* internal algorithm for selection */ - char algorithm; + eGPUSelectAlgo algorithm; /* allow GPU_select_begin/end without drawing */ bool use_cache; /** @@ -80,7 +80,8 @@ static GPUSelectState g_select_state = {0}; /** \name Public API * \{ */ -void GPU_select_begin(uint *buffer, uint bufsize, const rcti *input, char mode, int oldhits) +void GPU_select_begin( + uint *buffer, uint bufsize, const rcti *input, eGPUSelectMode mode, int oldhits) { if (mode == GPU_SELECT_NEAREST_SECOND_PASS) { /* In the case hits was '-1', diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index ddd3dfc6879..ee509a076c9 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -243,7 +243,7 @@ typedef struct GPUPickState { /* Buffer size (stores number of integers, for actual size multiply by sizeof integer). */ uint bufsize; /* mode of operation */ - char mode; + eGPUSelectMode mode; /* OpenGL drawing, never use when (is_cached == true). */ struct { @@ -303,12 +303,16 @@ typedef struct GPUPickState { static GPUPickState g_pick_state = {0}; -void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, char mode) +void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, eGPUSelectMode mode) { GPUPickState *ps = &g_pick_state; #ifdef DEBUG_PRINT - printf("%s: mode=%d, use_cache=%d, is_cache=%d\n", __func__, mode, ps->use_cache, ps->is_cached); + printf("%s: mode=%d, use_cache=%d, is_cache=%d\n", + __func__, + (int)mode, + ps->use_cache, + ps->is_cached); #endif GPU_debug_group_begin("Selection Pick"); diff --git a/source/blender/gpu/intern/gpu_select_private.h b/source/blender/gpu/intern/gpu_select_private.h index e5a84a037a6..940cb0bb9e2 100644 --- a/source/blender/gpu/intern/gpu_select_private.h +++ b/source/blender/gpu/intern/gpu_select_private.h @@ -31,7 +31,10 @@ extern "C" { /* gpu_select_pick */ -void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, char mode); +void gpu_select_pick_begin(uint (*buffer)[4], + uint bufsize, + const rcti *input, + eGPUSelectMode mode); bool gpu_select_pick_load_id(uint id, bool end); uint gpu_select_pick_end(void); @@ -46,7 +49,7 @@ void gpu_select_pick_cache_load_id(void); /* gpu_select_sample_query */ void gpu_select_query_begin( - uint (*buffer)[4], uint bufsize, const rcti *input, char mode, int oldhits); + uint (*buffer)[4], uint bufsize, const rcti *input, eGPUSelectMode mode, int oldhits); bool gpu_select_query_load_id(uint id); uint gpu_select_query_end(void); diff --git a/source/blender/gpu/intern/gpu_select_sample_query.cc b/source/blender/gpu/intern/gpu_select_sample_query.cc index a430d4a9d62..3d0b8518f98 100644 --- a/source/blender/gpu/intern/gpu_select_sample_query.cc +++ b/source/blender/gpu/intern/gpu_select_sample_query.cc @@ -59,7 +59,7 @@ struct GPUSelectQueryState { /* Buffer size (stores number of integers, for actual size multiply by `sizeof(int)`). */ uint bufsize; /* Mode of operation. */ - char mode; + eGPUSelectMode mode; uint index; int oldhits; @@ -73,7 +73,7 @@ struct GPUSelectQueryState { static GPUSelectQueryState g_query_state = {false}; void gpu_select_query_begin( - uint (*buffer)[4], uint bufsize, const rcti *input, char mode, int oldhits) + uint (*buffer)[4], uint bufsize, const rcti *input, const eGPUSelectMode mode, int oldhits) { GPU_debug_group_begin("Selection Queries"); |