8#ifndef SKIASL_MEMORYLAYOUT
9#define SKIASL_MEMORYLAYOUT
32 kWGSLUniform_EnableF16,
36 kWGSLStorage_EnableF16,
89 size_t roundUp16(
size_t n)
const {
return (n + 15) & ~15; }
96 switch (
type.typeKind()) {
99 return this->
size(type);
115 for (
const auto&
f :
type.fields()) {
124 SK_ABORT(
"cannot determine alignment of type '%s'",
type.displayName().c_str());
133 switch (
type.typeKind()) {
148 SK_ABORT(
"type '%s' does not have a stride",
type.displayName().c_str());
156 switch (
type.typeKind()) {
158 if (
type.isBoolean()) {
159 return this->
isWGSL() ? 0 : 1;
181 return type.isUnsizedArray() ? 0 : (
type.columns() * this->
stride(type));
185 for (
const auto&
f :
type.fields()) {
191 total += this->
size(*
f.fType);
195 (0 ==
alignment % this->alignment(*
type.fields()[0].fType)));
199 SK_ABORT(
"cannot determine size of type '%s'",
type.displayName().c_str());
207 switch (
type.typeKind()) {
222 type.fields().begin(),
type.fields().end(), [
this](
const Field&
f) {
223 return this->isSupported(*f.fType);
232 static size_t GetVectorAlignment(
size_t componentSize,
int columns) {
233 return componentSize * (columns + columns % 2);
#define SK_ABORT(message,...)
size_t size(const Type &type) const
size_t stride(const Type &type) const
MemoryLayout(Standard std)
size_t roundUpIfNeeded(size_t raw, Type::TypeKind type) const
bool isWGSL_Uniform() const
size_t roundUp16(size_t n) const
size_t isSupported(const Type &type) const
size_t alignment(const Type &type) const
bool highPrecision() const
virtual const Type & componentType() const
virtual int columns() const