2014-07-23 15:24:07 +02:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2014 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup gpu
|
2014-07-23 15:24:07 +02:00
|
|
|
*/
|
|
|
|
|
2015-03-16 11:46:20 +11:00
|
|
|
#pragma once
|
2014-07-23 15:24:07 +02:00
|
|
|
|
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
|
2020-03-02 15:28:47 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-03-08 23:22:42 +11:00
|
|
|
struct rcti;
|
2017-03-02 02:14:02 +11:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/** Flags for mode of operation. */
|
2022-01-31 13:01:27 +11:00
|
|
|
typedef enum eGPUSelectMode {
|
2014-07-23 15:24:07 +02:00
|
|
|
GPU_SELECT_ALL = 1,
|
2017-03-09 05:17:55 +11:00
|
|
|
/* gpu_select_query */
|
2014-07-23 15:24:07 +02:00
|
|
|
GPU_SELECT_NEAREST_FIRST_PASS = 2,
|
|
|
|
GPU_SELECT_NEAREST_SECOND_PASS = 3,
|
2017-03-09 05:17:55 +11:00
|
|
|
/* gpu_select_pick */
|
|
|
|
GPU_SELECT_PICK_ALL = 4,
|
|
|
|
GPU_SELECT_PICK_NEAREST = 5,
|
2022-01-31 13:01:27 +11:00
|
|
|
} eGPUSelectMode;
|
2014-07-23 15:24:07 +02:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
* Initialize and provide buffer for results.
|
|
|
|
*/
|
2022-01-31 13:01:27 +11:00
|
|
|
void GPU_select_begin(unsigned int *buffer,
|
|
|
|
unsigned int bufsize,
|
|
|
|
const struct rcti *input,
|
|
|
|
eGPUSelectMode mode,
|
|
|
|
int oldhits);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
* Loads a new selection id and ends previous query, if any.
|
|
|
|
* In second pass of selection it also returns
|
|
|
|
* if id has been hit on the first pass already.
|
|
|
|
* Thus we can skip drawing un-hit objects.
|
|
|
|
*
|
|
|
|
* \warning We rely on the order of object rendering on passes to be the same for this to work.
|
|
|
|
*/
|
2014-07-23 15:24:07 +02:00
|
|
|
bool GPU_select_load_id(unsigned int id);
|
2018-02-27 20:16:53 +11:00
|
|
|
void GPU_select_finalize(void);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
* Cleanup and flush selection results to buffer.
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-07-23 15:24:07 +02:00
|
|
|
unsigned int GPU_select_end(void);
|
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/* Cache selection region. */
|
|
|
|
|
2017-03-09 05:17:55 +11:00
|
|
|
bool GPU_select_is_cached(void);
|
|
|
|
void GPU_select_cache_begin(void);
|
|
|
|
void GPU_select_cache_load_id(void);
|
|
|
|
void GPU_select_cache_end(void);
|
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/* Utilities. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function, nothing special but avoids doing inline since hits aren't sorted by depth
|
|
|
|
* and purpose of 4x buffer indices isn't so clear.
|
|
|
|
*
|
|
|
|
* Note that comparing depth as uint is fine.
|
|
|
|
*/
|
2017-07-19 20:12:24 +10:00
|
|
|
const uint *GPU_select_buffer_near(const uint *buffer, int hits);
|
2020-06-10 17:50:11 +10:00
|
|
|
uint GPU_select_buffer_remove_by_id(uint *buffer, int hits, uint select_id);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
* Part of the solution copied from `rect_subregion_stride_calc`.
|
|
|
|
*/
|
2019-03-28 14:17:00 -03:00
|
|
|
void GPU_select_buffer_stride_realign(const struct rcti *src, const struct rcti *dst, uint *r_buf);
|
2017-07-19 20:12:24 +10:00
|
|
|
|
2020-03-02 15:28:47 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|