Blender V5.0
vk_memory_layout.cc
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#include "vk_memory_layout.hh"
10
11namespace blender::gpu {
12
13/* -------------------------------------------------------------------- */
16
18{
19 return 4;
20}
21
22uint32_t Std430::element_alignment(const shader::Type type, const bool /*is_array*/)
23{
24 switch (type) {
29 return 4;
33 return 8;
42 return 16;
43 default:
44 BLI_assert_msg(false, "Type not supported in dynamic structs.");
45 }
46 return 0;
47}
48
50{
51 switch (type) {
56 return 1;
60 return 2;
64 return 3;
68 return 4;
70 return 12;
72 return 16;
73 default:
74 BLI_assert_msg(false, "Type not supported in dynamic structs.");
75 }
76 return 0;
77}
78
80{
81 switch (type) {
86 return 1;
90 return 2;
97 return 4;
99 return 12;
101 return 16;
102 default:
103 BLI_assert_msg(false, "Type not supported in dynamic structs.");
104 }
105 return 0;
106}
107
109{
110 return type == shader::Type::float3x3_t ? 3 : 0;
111}
112
114
115/* -------------------------------------------------------------------- */
118
120{
121 return 4;
122}
123
124uint32_t Std140::element_alignment(const shader::Type type, const bool is_array)
125{
126 if (is_array) {
127 return 16;
128 }
129 switch (type) {
134 return 4;
138 return 8;
147 return 16;
148 default:
149 BLI_assert_msg(false, "Type not supported in dynamic structs.");
150 }
151 return 0;
152}
153
155{
156 switch (type) {
161 return 1;
165 return 2;
169 return 3;
173 return 4;
175 return 12;
177 return 16;
178 default:
179 BLI_assert_msg(false, "Type not supported in dynamic structs.");
180 }
181 return 0;
182}
183
185{
186 switch (type) {
200 return 4;
202 return 12;
204 return 16;
205 default:
206 BLI_assert_msg(false, "Type not supported in dynamic structs.");
207 }
208 return 0;
209}
210
212{
213 return 0;
214}
215
217
218} // namespace blender::gpu
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:53
static uint32_t array_components_len(const shader::Type type)
static uint32_t inner_row_padding(const shader::Type type)
static uint32_t element_components_len(const shader::Type type)
static uint32_t component_mem_size(const shader::Type type)
static uint32_t element_alignment(const shader::Type type, bool is_array)
static uint32_t element_alignment(const shader::Type type, bool is_array)
static uint32_t array_components_len(const shader::Type type)
static uint32_t element_components_len(const shader::Type type)
static uint32_t component_mem_size(const shader::Type type)
static uint32_t inner_row_padding(const shader::Type type)