Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/intern/gpu_select_sample_query.cc')
-rw-r--r--source/blender/gpu/intern/gpu_select_sample_query.cc49
1 files changed, 25 insertions, 24 deletions
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.cc b/source/blender/gpu/intern/gpu_select_sample_query.cc
index a430d4a9d62..7559358aaca 100644
--- a/source/blender/gpu/intern/gpu_select_sample_query.cc
+++ b/source/blender/gpu/intern/gpu_select_sample_query.cc
@@ -48,22 +48,22 @@ using namespace blender;
using namespace blender::gpu;
struct GPUSelectQueryState {
- /* Tracks whether a query has been issued so that gpu_load_id can end the previous one. */
+ /** Tracks whether a query has been issued so that gpu_load_id can end the previous one. */
bool query_issued;
- /* GPU queries abstraction. Contains an array of queries. */
+ /** GPU queries abstraction. Contains an array of queries. */
QueryPool *queries;
- /* Array holding the id corresponding id to each query. */
+ /** Array holding the id corresponding id to each query. */
Vector<uint> *ids;
- /* Cache on initialization. */
- uint (*buffer)[4];
- /* Buffer size (stores number of integers, for actual size multiply by `sizeof(int)`). */
- uint bufsize;
- /* Mode of operation. */
- char mode;
+ /** Cache on initialization. */
+ GPUSelectResult *buffer;
+ /** The capacity of the `buffer` array. */
+ uint buffer_len;
+ /** Mode of operation. */
+ eGPUSelectMode mode;
uint index;
int oldhits;
- /* Previous state to restore after drawing. */
+ /** Previous state to restore after drawing. */
int viewport[4];
int scissor[4];
eGPUWriteMask write_mask;
@@ -72,14 +72,17 @@ 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)
+void gpu_select_query_begin(GPUSelectResult *buffer,
+ uint buffer_len,
+ const rcti *input,
+ const eGPUSelectMode mode,
+ int oldhits)
{
GPU_debug_group_begin("Selection Queries");
g_query_state.query_issued = false;
- g_query_state.bufsize = bufsize;
g_query_state.buffer = buffer;
+ g_query_state.buffer_len = buffer_len;
g_query_state.mode = mode;
g_query_state.index = 0;
g_query_state.oldhits = oldhits;
@@ -111,7 +114,7 @@ void gpu_select_query_begin(
/* occlusion queries operates on fragments that pass tests and since we are interested on all
* objects in the view frustum independently of their order, we need to disable the depth test */
if (mode == GPU_SELECT_ALL) {
- /* glQueries on Windows+Intel drivers only works with depth testing turned on.
+ /* #glQueries on Windows+Intel drivers only works with depth testing turned on.
* See T62947 for details */
GPU_depth_test(GPU_DEPTH_ALWAYS);
GPU_depth_mask(true);
@@ -138,10 +141,11 @@ bool gpu_select_query_load_id(uint id)
g_query_state.query_issued = true;
if (g_query_state.mode == GPU_SELECT_NEAREST_SECOND_PASS) {
- /* Second pass should never run if first pass fails, can read past 'bufsize' in this case. */
+ /* Second pass should never run if first pass fails,
+ * can read past `buffer_len` in this case. */
BLI_assert(g_query_state.oldhits != -1);
if (g_query_state.index < g_query_state.oldhits) {
- if (g_query_state.buffer[g_query_state.index][3] == id) {
+ if (g_query_state.buffer[g_query_state.index].id == id) {
g_query_state.index++;
return true;
}
@@ -154,7 +158,7 @@ bool gpu_select_query_load_id(uint id)
uint gpu_select_query_end()
{
uint hits = 0;
- const uint maxhits = g_query_state.bufsize;
+ const uint maxhits = g_query_state.buffer_len;
if (g_query_state.query_issued) {
g_query_state.queries->end_query();
@@ -168,10 +172,8 @@ uint gpu_select_query_end()
if (result[i] != 0) {
if (g_query_state.mode != GPU_SELECT_NEAREST_SECOND_PASS) {
if (hits < maxhits) {
- g_query_state.buffer[hits][0] = 1;
- g_query_state.buffer[hits][1] = 0xFFFF;
- g_query_state.buffer[hits][2] = 0xFFFF;
- g_query_state.buffer[hits][3] = ids[i];
+ g_query_state.buffer[hits].depth = 0xFFFF;
+ g_query_state.buffer[hits].id = ids[i];
hits++;
}
else {
@@ -183,9 +185,8 @@ uint gpu_select_query_end()
int j;
/* search in buffer and make selected object first */
for (j = 0; j < g_query_state.oldhits; j++) {
- if (g_query_state.buffer[j][3] == ids[i]) {
- g_query_state.buffer[j][1] = 0;
- g_query_state.buffer[j][2] = 0;
+ if (g_query_state.buffer[j].id == ids[i]) {
+ g_query_state.buffer[j].depth = 0;
}
}
break;