Blender V4.3
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
9#include "vk_memory_layout.hh"
10
11namespace blender::gpu {
12
13/* -------------------------------------------------------------------- */
18{
19 return 4;
20}
21
22uint32_t Std430::element_alignment(const shader::Type type, const bool is_array)
23{
24 if (is_array) {
25 return 16;
26 }
27 switch (type) {
32 return 4;
36 return 8;
45 return 16;
46 default:
47 BLI_assert_msg(false, "Type not supported in dynamic structs.");
48 }
49 return 0;
50}
51
53{
54 switch (type) {
59 return 1;
63 return 2;
67 return 3;
71 return 4;
73 return 12;
75 return 16;
76 default:
77 BLI_assert_msg(false, "Type not supported in dynamic structs.");
78 }
79 return 0;
80}
81
83{
84 switch (type) {
89 return 1;
93 return 2;
100 return 4;
102 return 12;
104 return 16;
105 default:
106 BLI_assert_msg(false, "Type not supported in dynamic structs.");
107 }
108 return 0;
109}
110
112{
113 return type == shader::Type::MAT3 ? 3 : 0;
114}
115
118/* -------------------------------------------------------------------- */
123{
124 return 4;
125}
126
127uint32_t Std140::element_alignment(const shader::Type type, const bool is_array)
128{
129 if (is_array) {
130 return 16;
131 }
132 switch (type) {
137 return 4;
141 return 8;
150 return 16;
151 default:
152 BLI_assert_msg(false, "Type not supported in dynamic structs.");
153 }
154 return 0;
155}
156
158{
159 switch (type) {
164 return 1;
168 return 2;
172 return 3;
176 return 4;
178 return 12;
180 return 16;
181 default:
182 BLI_assert_msg(false, "Type not supported in dynamic structs.");
183 }
184 return 0;
185}
186
188{
189 switch (type) {
203 return 4;
205 return 12;
207 return 16;
208 default:
209 BLI_assert_msg(false, "Type not supported in dynamic structs.");
210 }
211 return 0;
212}
213
215{
216 return 0;
217}
218
221} // namespace blender::gpu
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
unsigned int uint32_t
Definition stdint.h:80
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)