Blender  V2.93
gpu_uniform_buffer_private.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  */
18 
23 #pragma once
24 
25 #include "BLI_sys_types.h"
26 
27 struct GPUUniformBuf;
28 
29 namespace blender {
30 namespace gpu {
31 
32 #ifdef DEBUG
33 # define DEBUG_NAME_LEN 64
34 #else
35 # define DEBUG_NAME_LEN 8
36 #endif
37 
42 class UniformBuf {
43  protected:
47  void *data_ = NULL;
50 
51  public:
52  UniformBuf(size_t size, const char *name);
53  virtual ~UniformBuf();
54 
55  virtual void update(const void *data) = 0;
56  virtual void bind(int slot) = 0;
57  virtual void unbind(void) = 0;
58 
62  void attach_data(void *data)
63  {
64  data_ = data;
65  }
66 };
67 
68 /* Syntactic sugar. */
69 static inline GPUUniformBuf *wrap(UniformBuf *vert)
70 {
71  return reinterpret_cast<GPUUniformBuf *>(vert);
72 }
73 static inline UniformBuf *unwrap(GPUUniformBuf *vert)
74 {
75  return reinterpret_cast<UniformBuf *>(vert);
76 }
77 static inline const UniformBuf *unwrap(const GPUUniformBuf *vert)
78 {
79  return reinterpret_cast<const UniformBuf *>(vert);
80 }
81 
82 #undef DEBUG_NAME_LEN
83 
84 } // namespace gpu
85 } // namespace blender
struct GPUUniformBuf GPUUniformBuf
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
virtual void unbind(void)=0
virtual void update(const void *data)=0
UniformBuf(size_t size, const char *name)
virtual void bind(int slot)=0
#define DEBUG_NAME_LEN
static GPUContext * wrap(Context *ctx)
static Context * unwrap(GPUContext *ctx)