Blender  V3.3
gpu_uniform_buffer_private.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. */
3 
8 #pragma once
9 
10 #include "BLI_sys_types.h"
11 
12 struct GPUUniformBuf;
13 
14 namespace blender {
15 namespace gpu {
16 
17 #ifdef DEBUG
18 # define DEBUG_NAME_LEN 64
19 #else
20 # define DEBUG_NAME_LEN 8
21 #endif
22 
27 class UniformBuf {
28  protected:
32  void *data_ = nullptr;
35 
36  public:
37  UniformBuf(size_t size, const char *name);
38  virtual ~UniformBuf();
39 
40  virtual void update(const void *data) = 0;
41  virtual void bind(int slot) = 0;
42  virtual void unbind() = 0;
43 
47  void attach_data(void *data)
48  {
49  data_ = data;
50  }
51 };
52 
53 /* Syntactic sugar. */
54 static inline GPUUniformBuf *wrap(UniformBuf *vert)
55 {
56  return reinterpret_cast<GPUUniformBuf *>(vert);
57 }
58 static inline UniformBuf *unwrap(GPUUniformBuf *vert)
59 {
60  return reinterpret_cast<UniformBuf *>(vert);
61 }
62 static inline const UniformBuf *unwrap(const GPUUniformBuf *vert)
63 {
64  return reinterpret_cast<const UniformBuf *>(vert);
65 }
66 
67 #undef DEBUG_NAME_LEN
68 
69 } // namespace gpu
70 } // namespace blender
struct GPUUniformBuf GPUUniformBuf
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
virtual void unbind()=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)