Blender V5.3
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 /* Bind-state tracking. */
32 int bind_slot_ = -1;
33 MTLContext *bound_ctx_ = nullptr;
34
35 /* SSBO wrapper for bind_as_ssbo support. */
36 MTLStorageBuf *ssbo_wrapper_ = nullptr;
37
38 public:
39 MTLUniformBuf(size_t size, const char *name);
40 ~MTLUniformBuf() override;
41
42 void update(const void *data) override;
43 void bind(int slot) override;
44 void bind_as_ssbo(int slot) override;
45 void unbind() override;
46 void clear_to_zero() override;
47
49 size_t get_size();
50 const char *get_name()
51 {
52 return name_;
53 }
54
55 MEM_CXX_CLASS_ALLOC_FUNCS("MTLUniformBuf");
56};
57
58} // namespace blender::gpu
Read Blender memory allocation and freeing.
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)
BMesh const char void * data