Blender  V2.93
gl_query.hh
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2020, Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "BLI_vector.hh"
27 
28 #include "gpu_query.hh"
29 
30 #include "glew-mx.h"
31 
32 namespace blender::gpu {
33 
34 class GLQueryPool : public QueryPool {
35  private:
37  Vector<GLuint> query_ids_;
39  GPUQueryType type_;
41  GLenum gl_type_;
44  uint32_t query_issued_;
46  bool initialized_ = false;
47 
48  public:
49  ~GLQueryPool();
50 
51  void init(GPUQueryType type) override;
52 
53  void begin_query(void) override;
54  void end_query(void) override;
55 
56  void get_occlusion_result(MutableSpan<uint32_t> r_values) override;
57 };
58 
59 static inline GLenum to_gl(GPUQueryType type)
60 {
61  if (type == GPU_QUERY_OCCLUSION) {
62  /* TODO(fclem): try with GL_ANY_SAMPLES_PASSED​. */
63  return GL_SAMPLES_PASSED;
64  }
65  BLI_assert(0);
66  return GL_SAMPLES_PASSED;
67 }
68 
69 } // namespace blender::gpu
#define BLI_assert(a)
Definition: BLI_assert.h:58
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void get_occlusion_result(MutableSpan< uint32_t > r_values) override
Definition: gl_query.cc:68
void end_query(void) override
Definition: gl_query.cc:62
void init(GPUQueryType type) override
Definition: gl_query.cc:35
void begin_query(void) override
Definition: gl_query.cc:51
@ GPU_QUERY_OCCLUSION
Definition: gpu_query.hh:31
static GLenum to_gl(const GPUAttachmentType type)
unsigned int uint32_t
Definition: stdint.h:83