Blender  V2.93
gl_immediate.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  * The Original Code is Copyright (C) 2016 by Mike Erwin.
17  * All rights reserved.
18  */
19 
26 #pragma once
27 
28 #include "MEM_guardedalloc.h"
29 
30 #include "glew-mx.h"
31 
32 #include "gpu_immediate_private.hh"
33 
34 namespace blender::gpu {
35 
36 /* size of internal buffer */
37 #define DEFAULT_INTERNAL_BUFFER_SIZE (4 * 1024 * 1024)
38 
39 class GLImmediate : public Immediate {
40  private:
41  /* Use two buffers for strict and unstrict vertex count to
42  * avoid some huge driver slowdown (see T70922).
43  * Use accessor functions to get / modify. */
44  struct {
46  GLuint vbo_id = 0;
48  size_t buffer_offset = 0;
50  size_t buffer_size = 0;
51  } buffer, buffer_strict;
53  size_t bytes_mapped_ = 0;
55  GLuint vao_id_ = 0;
56 
57  public:
58  GLImmediate();
59  ~GLImmediate();
60 
61  uchar *begin(void) override;
62  void end(void) override;
63 
64  private:
65  GLuint &vbo_id(void)
66  {
67  return strict_vertex_len ? buffer_strict.vbo_id : buffer.vbo_id;
68  };
69 
70  size_t &buffer_offset(void)
71  {
72  return strict_vertex_len ? buffer_strict.buffer_offset : buffer.buffer_offset;
73  };
74 
75  size_t &buffer_size(void)
76  {
77  return strict_vertex_len ? buffer_strict.buffer_size : buffer.buffer_size;
78  };
79 };
80 
81 } // namespace blender::gpu
unsigned char uchar
Definition: BLI_sys_types.h:86
Read Guarded memory(de)allocation.
void end(void) override
uchar * begin(void) override
Definition: gl_immediate.cc:82