Blender  V2.93
gl_backend.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 "gpu_backend.hh"
27 
28 #include "BLI_vector.hh"
29 
30 #include "gl_batch.hh"
31 #include "gl_context.hh"
32 #include "gl_drawlist.hh"
33 #include "gl_framebuffer.hh"
34 #include "gl_index_buffer.hh"
35 #include "gl_query.hh"
36 #include "gl_shader.hh"
37 #include "gl_texture.hh"
38 #include "gl_uniform_buffer.hh"
39 #include "gl_vertex_buffer.hh"
40 
41 namespace blender {
42 namespace gpu {
43 
44 class GLBackend : public GPUBackend {
45  private:
46  GLSharedOrphanLists shared_orphan_list_;
47 
48  public:
50  {
51  /* platform_init needs to go first. */
52  GLBackend::platform_init();
53 
54  GLBackend::capabilities_init();
56  }
58  {
60 
61  GLBackend::platform_exit();
62  }
63 
64  static GLBackend *get(void)
65  {
66  return static_cast<GLBackend *>(GPUBackend::get());
67  }
68 
69  void samplers_update(void) override
70  {
72  };
73 
74  Context *context_alloc(void *ghost_window) override
75  {
76  return new GLContext(ghost_window, shared_orphan_list_);
77  };
78 
79  Batch *batch_alloc(void) override
80  {
81  return new GLBatch();
82  };
83 
84  DrawList *drawlist_alloc(int list_length) override
85  {
86  return new GLDrawList(list_length);
87  };
88 
89  FrameBuffer *framebuffer_alloc(const char *name) override
90  {
91  return new GLFrameBuffer(name);
92  };
93 
94  IndexBuf *indexbuf_alloc(void) override
95  {
96  return new GLIndexBuf();
97  };
98 
99  QueryPool *querypool_alloc(void) override
100  {
101  return new GLQueryPool();
102  };
103 
104  Shader *shader_alloc(const char *name) override
105  {
106  return new GLShader(name);
107  };
108 
109  Texture *texture_alloc(const char *name) override
110  {
111  return new GLTexture(name);
112  };
113 
114  UniformBuf *uniformbuf_alloc(int size, const char *name) override
115  {
116  return new GLUniformBuf(size, name);
117  };
118 
119  VertBuf *vertbuf_alloc(void) override
120  {
121  return new GLVertBuf();
122  };
123 
125  {
126  return shared_orphan_list_;
127  };
128 
129  private:
130  static void platform_init(void);
131  static void platform_exit(void);
132 
133  static void capabilities_init(void);
134 };
135 
136 } // namespace gpu
137 } // namespace blender
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
DrawList * drawlist_alloc(int list_length) override
Definition: gl_backend.hh:84
void samplers_update(void) override
Definition: gl_backend.hh:69
Shader * shader_alloc(const char *name) override
Definition: gl_backend.hh:104
Batch * batch_alloc(void) override
Definition: gl_backend.hh:79
UniformBuf * uniformbuf_alloc(int size, const char *name) override
Definition: gl_backend.hh:114
QueryPool * querypool_alloc(void) override
Definition: gl_backend.hh:99
VertBuf * vertbuf_alloc(void) override
Definition: gl_backend.hh:119
static GLBackend * get(void)
Definition: gl_backend.hh:64
Texture * texture_alloc(const char *name) override
Definition: gl_backend.hh:109
Context * context_alloc(void *ghost_window) override
Definition: gl_backend.hh:74
GLSharedOrphanLists & shared_orphan_list_get(void)
Definition: gl_backend.hh:124
FrameBuffer * framebuffer_alloc(const char *name) override
Definition: gl_backend.hh:89
IndexBuf * indexbuf_alloc(void) override
Definition: gl_backend.hh:94
static void samplers_free(void)
Definition: gl_texture.cc:560
static void samplers_update(void)
Definition: gl_texture.cc:541
static void samplers_init(void)
Definition: gl_texture.cc:485
static GPUBackend * get(void)
Definition: gpu_context.cc:191