Blender  V3.3
mtl_uniform_buffer.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include "MEM_guardedalloc.h"
11 
12 #include "mtl_context.hh"
13 
14 namespace blender::gpu {
15 
19 class MTLUniformBuf : public UniformBuf {
20  private:
21  /* Allocation Handle. */
22  gpu::MTLBuffer *metal_buffer_ = nullptr;
23 
24  /* Whether buffer has contents, if false, no GPU buffer will
25  * have yet been allocated. */
26  bool has_data_ = false;
27 
28  /* Bind-state tracking. */
29  int bind_slot_ = -1;
30  MTLContext *bound_ctx_ = nullptr;
31 
32  public:
33  MTLUniformBuf(size_t size, const char *name);
35 
36  void update(const void *data) override;
37  void bind(int slot) override;
38  void unbind() override;
39 
40  id<MTLBuffer> get_metal_buffer(int *r_offset);
41  int get_size();
42  const char *get_name()
43  {
44  return name_;
45  }
46 
47  MEM_CXX_CLASS_ALLOC_FUNCS("MTLUniformBuf");
48 };
49 
50 } // namespace blender::gpu
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
MEM_CXX_CLASS_ALLOC_FUNCS("MTLUniformBuf")
MTLUniformBuf(size_t size, const char *name)
void bind(int slot) override
void update(const void *data) override
id< MTLBuffer > get_metal_buffer(int *r_offset)