Blender V5.0
mtl_uniform_buffer.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "MEM_guardedalloc.h"
12
14
15#include "mtl_context.hh"
16
17namespace blender::gpu {
18
19class MTLStorageBuf;
20
24class MTLUniformBuf : public UniformBuf {
25 friend class MTLStorageBuf; /* For bind as SSBO resource access. */
26
27 private:
28 /* Allocation Handle. */
29 gpu::MTLBuffer *metal_buffer_ = nullptr;
30
31 /* Whether buffer has contents, if false, no GPU buffer will
32 * have yet been allocated. */
33 bool has_data_ = false;
34
35 /* Bind-state tracking. */
36 int bind_slot_ = -1;
37 MTLContext *bound_ctx_ = nullptr;
38
39 /* SSBO wrapper for bind_as_ssbo support. */
40 MTLStorageBuf *ssbo_wrapper_ = nullptr;
41
42 public:
43 MTLUniformBuf(size_t size, const char *name);
44 ~MTLUniformBuf() override;
45
46 void update(const void *data) override;
47 void bind(int slot) override;
48 void bind_as_ssbo(int slot) override;
49 void unbind() override;
50 void clear_to_zero() override;
51
52 id<MTLBuffer> get_metal_buffer();
53 size_t get_size();
54 const char *get_name()
55 {
56 return name_;
57 }
58
59 MEM_CXX_CLASS_ALLOC_FUNCS("MTLUniformBuf");
60};
61
62} // namespace blender::gpu
Read Guarded memory(de)allocation.
BMesh const char void * data
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 bind_as_ssbo(int slot) override
void update(const void *data) override
UniformBuf(size_t size, const char *name)
const char * name