#include <SkSLMemoryLayout.h>
Definition at line 17 of file SkSLMemoryLayout.h.
◆ Standard
Enumerator |
---|
k140 | |
k430 | |
kMetal | |
kWGSLUniform_Base | |
kWGSLUniform_EnableF16 | |
kWGSLStorage_Base | |
kWGSLStorage_EnableF16 | |
Definition at line 19 of file SkSLMemoryLayout.h.
19 {
20
22
23
24
25 k430,
26
27
29
30
31 kWGSLUniform_Base,
32 kWGSLUniform_EnableF16,
33
34
35 kWGSLStorage_Base,
36 kWGSLStorage_EnableF16,
37 };
◆ MemoryLayout()
SkSL::MemoryLayout::MemoryLayout |
( |
Standard |
std | ) |
|
|
inline |
◆ alignment()
size_t SkSL::MemoryLayout::alignment |
( |
const Type & |
type | ) |
const |
|
inline |
Returns a type's required alignment when used as a standalone variable.
Definition at line 94 of file SkSLMemoryLayout.h.
94 {
95
96 switch (
type.typeKind()) {
100
102 return GetVectorAlignment(this->
size(
type.componentType()),
type.columns());
103
106 GetVectorAlignment(this->
size(
type.componentType()),
type.rows()),
108
112
115 for (
const auto&
f :
type.fields()) {
119 }
120 }
122 }
123 default:
124 SK_ABORT(
"cannot determine alignment of type '%s'",
type.displayName().c_str());
125 }
126 }
#define SK_ABORT(message,...)
size_t size(const Type &type) const
size_t roundUpIfNeeded(size_t raw, Type::TypeKind type) const
size_t alignment(const Type &type) const
◆ isMetal()
bool SkSL::MemoryLayout::isMetal |
( |
| ) |
const |
|
inline |
◆ isSupported()
size_t SkSL::MemoryLayout::isSupported |
( |
const Type & |
type | ) |
const |
|
inline |
Not all types are compatible with memory layout.
Definition at line 206 of file SkSLMemoryLayout.h.
206 {
207 switch (
type.typeKind()) {
209 return true;
210
212
213 return this->
isWGSL() ? !
type.isBoolean() :
true;
214
219
221 return std::all_of(
222 type.fields().begin(),
type.fields().end(), [
this](
const Field&
f) {
223 return this->isSupported(*f.fType);
224 });
225
226 default:
227 return false;
228 }
229 }
size_t isSupported(const Type &type) const
◆ isWGSL()
bool SkSL::MemoryLayout::isWGSL |
( |
| ) |
const |
|
inline |
◆ isWGSL_Base()
bool SkSL::MemoryLayout::isWGSL_Base |
( |
| ) |
const |
|
inline |
◆ isWGSL_F16()
bool SkSL::MemoryLayout::isWGSL_F16 |
( |
| ) |
const |
|
inline |
◆ isWGSL_Uniform()
bool SkSL::MemoryLayout::isWGSL_Uniform |
( |
| ) |
const |
|
inline |
◆ roundUp16()
size_t SkSL::MemoryLayout::roundUp16 |
( |
size_t |
n | ) |
const |
|
inline |
Rounds up the integer n
to the smallest multiple of 16 greater than n
.
Definition at line 89 of file SkSLMemoryLayout.h.
89{ return (n + 15) & ~15; }
◆ roundUpIfNeeded()
size_t SkSL::MemoryLayout::roundUpIfNeeded |
( |
size_t |
raw, |
|
|
Type::TypeKind |
type |
|
) |
| const |
|
inline |
WGSL and std140 require various types of variables (structs, arrays, and matrices) in the uniform address space to be rounded up to the nearest multiple of 16. This function performs the rounding depending on the given type
and the current memory layout standard.
(For WGSL, see https://www.w3.org/TR/WGSL/#address-space-layout-constraints).
Definition at line 74 of file SkSLMemoryLayout.h.
74 {
77 }
78
79
82 }
83 return raw;
84 }
bool isWGSL_Uniform() const
size_t roundUp16(size_t n) const
◆ size()
size_t SkSL::MemoryLayout::size |
( |
const Type & |
type | ) |
const |
|
inline |
Returns the size of a type in bytes. Returns 0 if the given type is not supported.
Definition at line 155 of file SkSLMemoryLayout.h.
155 {
156 switch (
type.typeKind()) {
158 if (
type.isBoolean()) {
159 return this->
isWGSL() ? 0 : 1;
160 }
162 return 2;
163 }
165 return 2;
166 }
167 return 4;
168
170
171 return 4;
172
175 return 4 * this->
size(
type.componentType());
176 }
177 return type.columns() * this->
size(
type.componentType());
178
182
184 size_t total = 0;
185 for (
const auto&
f :
type.fields()) {
189 }
191 total += this->
size(*
f.fType);
192 }
195 (0 == alignment % this->alignment(*
type.fields()[0].fType)));
197 }
198 default:
199 SK_ABORT(
"cannot determine size of type '%s'",
type.displayName().c_str());
200 }
201 }
size_t stride(const Type &type) const
◆ stride()
size_t SkSL::MemoryLayout::stride |
( |
const Type & |
type | ) |
const |
|
inline |
For matrices and arrays, returns the number of bytes from the start of one entry (row, in the case of matrices) to the start of the next.
Definition at line 132 of file SkSLMemoryLayout.h.
132 {
133 switch (
type.typeKind()) {
136
139 if (stride > 0) {
141 stride += align - 1;
144 }
146 }
147 default:
148 SK_ABORT(
"type '%s' does not have a stride",
type.displayName().c_str());
149 }
150 }
The documentation for this class was generated from the following file: