Blender V5.3
mtl_push_constant.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
12
13namespace blender::gpu {
14
15/* Metal Shader Uniform data store.
16 * This blocks is used to store current shader push_constant
17 * data before it is submitted to the GPU. This is currently
18 * stored per shader instance, though depending on GPU module
19 * functionality, this could potentially be a global data store.
20 * This data is associated with the PushConstantBlock. */
22 private:
23 uint8_t *data_ = nullptr;
24 /* Offset inside buffer for allocating push constants. */
25 size_t offset_ = 0;
26 /* Size of the allocated buffer in `data_`. */
27 size_t size_ = 0;
28 /* True if the data has been touched and must be resent to GPU. */
29 bool is_dirty_ = true;
30
31 public:
34
35 /* Append uniform description to the buffer and return the location inside the buffer. */
37
39 {
40 return data_;
41 }
42
43 const uint8_t *data() const
44 {
45 return data_;
46 }
47
48 size_t size() const
49 {
50 return size_;
51 }
52
53 bool is_dirty() const
54 {
55 return is_dirty_;
56 }
57
58 void tag_dirty()
59 {
60 is_dirty_ = true;
61 }
62
64 {
65 is_dirty_ = false;
66 }
67};
68
69} // namespace blender::gpu
MTLPushConstantBuf(const shader::ShaderCreateInfo &info)
int append(shader::ShaderCreateInfo::PushConst push_constant)
#define push_constant
unsigned char uint8_t
Definition BKE_text.h:79
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...