Use a shorter/simpler license convention, stops the header taking so much space. Follow the SPDX license specification: https://spdx.org/licenses - C/C++/objc/objc++ - Python - Shell Scripts - CMake, GNUmakefile While most of the source tree has been included - `./extern/` was left out. - `./intern/cycles` & `./intern/atomic` are also excluded because they use different header conventions. doc/license/SPDX-license-identifiers.txt has been added to list SPDX all used identifiers. See P2788 for the script that automated these edits. Reviewed By: brecht, mont29, sergey Ref D14069
63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2020 Blender Foundation. All rights reserved. */
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*/
|
|
|
|
#include "gl_query.hh"
|
|
|
|
namespace blender::gpu {
|
|
|
|
#define QUERY_CHUNCK_LEN 256
|
|
|
|
GLQueryPool::~GLQueryPool()
|
|
{
|
|
glDeleteQueries(query_ids_.size(), query_ids_.data());
|
|
}
|
|
|
|
void GLQueryPool::init(GPUQueryType type)
|
|
{
|
|
BLI_assert(initialized_ == false);
|
|
initialized_ = true;
|
|
type_ = type;
|
|
gl_type_ = to_gl(type);
|
|
query_issued_ = 0;
|
|
}
|
|
|
|
#if 0 /* TODO: to avoid realloc of permanent query pool. */
|
|
void GLQueryPool::reset(GPUQueryType type)
|
|
{
|
|
initialized_ = false;
|
|
}
|
|
#endif
|
|
|
|
void GLQueryPool::begin_query()
|
|
{
|
|
/* TODO: add assert about expected usage. */
|
|
while (query_issued_ >= query_ids_.size()) {
|
|
int64_t prev_size = query_ids_.size();
|
|
query_ids_.resize(prev_size + QUERY_CHUNCK_LEN);
|
|
glGenQueries(QUERY_CHUNCK_LEN, &query_ids_[prev_size]);
|
|
}
|
|
glBeginQuery(gl_type_, query_ids_[query_issued_++]);
|
|
}
|
|
|
|
void GLQueryPool::end_query()
|
|
{
|
|
/* TODO: add assert about expected usage. */
|
|
glEndQuery(gl_type_);
|
|
}
|
|
|
|
void GLQueryPool::get_occlusion_result(MutableSpan<uint32_t> r_values)
|
|
{
|
|
BLI_assert(r_values.size() == query_issued_);
|
|
|
|
for (int i = 0; i < query_issued_; i++) {
|
|
/* NOTE: This is a sync point. */
|
|
glGetQueryObjectuiv(query_ids_[i], GL_QUERY_RESULT, &r_values[i]);
|
|
}
|
|
}
|
|
|
|
} // namespace blender::gpu
|