Blender V4.3
gpu_uniform_buffer_private.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BLI_sys_types.h"
12
13struct GPUUniformBuf;
14
15namespace blender {
16namespace gpu {
17
18#ifndef NDEBUG
19# define DEBUG_NAME_LEN 64
20#else
21# define DEBUG_NAME_LEN 8
22#endif
23
29 protected:
33 void *data_ = nullptr;
36
37 public:
38 UniformBuf(size_t size, const char *name);
39 virtual ~UniformBuf();
40
41 virtual void update(const void *data) = 0;
42 virtual void clear_to_zero() = 0;
43 virtual void bind(int slot) = 0;
44 virtual void bind_as_ssbo(int slot) = 0;
45 virtual void unbind() = 0;
46
50 void attach_data(void *data)
51 {
52 data_ = data;
53 }
54};
55
56/* Syntactic sugar. */
57static inline GPUUniformBuf *wrap(UniformBuf *vert)
58{
59 return reinterpret_cast<GPUUniformBuf *>(vert);
60}
61static inline UniformBuf *unwrap(GPUUniformBuf *vert)
62{
63 return reinterpret_cast<UniformBuf *>(vert);
64}
65static inline const UniformBuf *unwrap(const GPUUniformBuf *vert)
66{
67 return reinterpret_cast<const UniformBuf *>(vert);
68}
69
70#undef DEBUG_NAME_LEN
71
72} // namespace gpu
73} // namespace blender
virtual void unbind()=0
virtual void update(const void *data)=0
UniformBuf(size_t size, const char *name)
virtual void bind(int slot)=0
virtual void bind_as_ssbo(int slot)=0
virtual void clear_to_zero()=0
#define DEBUG_NAME_LEN
static Context * unwrap(GPUContext *ctx)
static GPUContext * wrap(Context *ctx)