Blender
V4.3
source
blender
gpu
opengl
gl_query.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2020 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
9
#include "
gl_query.hh
"
10
11
namespace
blender::gpu
{
12
13
#define QUERY_CHUNCK_LEN 256
14
15
GLQueryPool::~GLQueryPool
()
16
{
17
glDeleteQueries(query_ids_.
size
(), query_ids_.
data
());
18
}
19
20
void
GLQueryPool::init
(
GPUQueryType
type)
21
{
22
BLI_assert
(initialized_ ==
false
);
23
initialized_ =
true
;
24
type_ = type;
25
gl_type_ =
to_gl
(type);
26
query_issued_ = 0;
27
}
28
29
#if 0
/* TODO: to avoid realloc of permanent query pool. */
30
void
GLQueryPool::reset(
GPUQueryType
type)
31
{
32
initialized_ =
false
;
33
}
34
#endif
35
36
void
GLQueryPool::begin_query
()
37
{
38
/* TODO: add assert about expected usage. */
39
while
(query_issued_ >= query_ids_.
size
()) {
40
int64_t
prev_size = query_ids_.
size
();
41
int64_t
chunk_size = prev_size == 0 ? query_ids_.
capacity
() :
QUERY_CHUNCK_LEN
;
42
query_ids_.
resize
(prev_size + chunk_size);
43
glGenQueries(chunk_size, &query_ids_[prev_size]);
44
}
45
glBeginQuery(gl_type_, query_ids_[query_issued_++]);
46
}
47
48
void
GLQueryPool::end_query
()
49
{
50
/* TODO: add assert about expected usage. */
51
glEndQuery(gl_type_);
52
}
53
54
void
GLQueryPool::get_occlusion_result
(
MutableSpan<uint32_t>
r_values)
55
{
56
BLI_assert
(r_values.
size
() == query_issued_);
57
58
for
(
int
i = 0; i < query_issued_; i++) {
59
/* NOTE: This is a sync point. */
60
glGetQueryObjectuiv(query_ids_[i], GL_QUERY_RESULT, &r_values[i]);
61
}
62
}
63
64
}
// namespace blender::gpu
BLI_assert
#define BLI_assert(a)
Definition
BLI_assert.h:50
blender::MutableSpan
Definition
BLI_span.hh:444
blender::MutableSpan::size
constexpr int64_t size() const
Definition
BLI_span.hh:494
blender::Vector::size
int64_t size() const
Definition
BLI_vector.hh:691
blender::Vector::resize
void resize(const int64_t new_size)
Definition
BLI_vector.hh:350
blender::Vector::data
T * data()
Definition
BLI_vector.hh:865
blender::Vector::capacity
int64_t capacity() const
Definition
BLI_vector.hh:918
blender::gpu::GLQueryPool::get_occlusion_result
void get_occlusion_result(MutableSpan< uint32_t > r_values) override
Definition
gl_query.cc:54
blender::gpu::GLQueryPool::end_query
void end_query() override
Definition
gl_query.cc:48
blender::gpu::GLQueryPool::begin_query
void begin_query() override
Definition
gl_query.cc:36
blender::gpu::GLQueryPool::~GLQueryPool
~GLQueryPool()
Definition
gl_query.cc:15
blender::gpu::GLQueryPool::init
void init(GPUQueryType type) override
Definition
gl_query.cc:20
QUERY_CHUNCK_LEN
#define QUERY_CHUNCK_LEN
Definition
gl_query.cc:13
gl_query.hh
blender::gpu
Definition
blf_internal_types.hh:23
blender::gpu::GPUQueryType
GPUQueryType
Definition
gpu_query.hh:17
blender::gpu::to_gl
static GLenum to_gl(const GPUAttachmentType type)
Definition
gl_framebuffer.hh:120
int64_t
__int64 int64_t
Definition
stdint.h:89
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0