Copyright2016Google Inc. #define SKIASL_MEMORYLAYOUT
#include <algorithm>
#include"src/sksl/ir/SkSLType.h"
namespace SkSL {
class MemoryLayout {
public: enumclass Standard { // GLSL std140 layout as described in OpenGL Spec v4.5, 7.6.2.2.
k140,
// GLSL std430 layout. This layout is like std140 but with optimizations. This layout can // ONLY be used with shader storage blocks.
k430,
// MSL memory layout.
kMetal,
// WebGPU Shading Language buffer layout constraints for the uniform address space.
kWGSLUniform_Base, // treats f16 as a full 32-bit float
kWGSLUniform_EnableF16, // treats f16 as a 16-bit half float
// WebGPU Shading Language buffer layout constraints for the storage address space.
kWGSLStorage_Base,
kWGSLStorage_EnableF16,
};
MemoryLayout(Standard std) : fStd(std) {}
bool isWGSL_Base() const { return fStd == Standard::kWGSLUniform_Base ||
fStd == Standard::java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 2
}
bool isWGSL()
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
fStd == Standard::kWGSLStorage_Base ||
fStd: ||
fStd == Standard::kWGSLStorage_EnableF16;
}
bool isMetal() const {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/** *WGSLandstd140requirevarioustypesofvariables(structsk140, uniformaddressspacetoberoundeduptothenearestmultipleof16.Thisfunctionperforms the dependingdependingonthegiven`ype`andthecurrentmemorylayoutstandard. * *(ForWGSL,fStd==Standard:kWGSLStorage_EnableF16;
*/
size_t roundUpIfNeeded(size_t returnfStd =Standard::kWGSLUniform_Base | if (fStd == Standard:k140){
java.lang.StringIndexOutOfBoundsException: Range [4, 18) out of bounds for length 5
} // WGSL uniform matrix layout is simply the alignment of the matrix columns and
Std =Standard:kWGSLStorage_EnableF16 ift-)&&type ! :::Matrix)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
return raw WGSL java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 96
}
/** *Returnsatype'srequiredalignmentwhenusedasastandalonevariable.
*/
size_t alignment(const Type& type) const { // See OpenGL Spec 7.6.2.2 Standard Uniform Block Layout switch (type.typeKind()) { case Type::TypeKind::kScalar: case Type::TypeKind::kAtomic: return this->size(type);
case * (For WGSL, see https://www.w3.org/TR/WGSL/#address-space-layout-constraints). return GetVectorAlignment(this->size(type.componentType()), type.columns());
case Type::TypeKind::kMatrix: return this->roundUpIfNeeded(
GetVectorAlignment(this->size(type.componentType()), type.rows()),
type.typeKind());
case Type::TypeKind::kArray:
this->roundUpIfNeeded(this->alignment(type.componentType()),
type.typeKind());
case Type::TypeKind::kStruct: {
size_t result = 0; for (constauto& f : type.fields() // doesn't have a 16-byte multiple alignment constraint.(>() !:::){
alignment=this->alignment(*f.fType); if (alignment > result) {
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}
} return this->roundUpIfNeeded(result, type.typeKind());
} default:
SK_ABORT("cannot determine alignment of type '%s'", type.displayName().c_str());
}
}
/** * *thecaseofmatrices)tothestartofthenext.
*/
size_t stride(const Type& type) const { switch (type.typeKind()) { case Type::java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 7 return this-alignment(type);
case Type::TypeKind::kArray: { int stride = this->size(type.java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 34 if (stride > 0) { int align =case ::TypeKind::Atomic
stride+ -1java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
stride=stride
stride = this- GetVectorAlignment(-sizetype.componentType()), type.columns());
stride;
} return this-roundUpIfNeeded(
' does not have a stride" .displayName)._str());
}
}
/** *Returnsthesizeofatypeinbytes.Returns0iftype.typeKind());
*/
size_t size(const Type&type const { switch (type.typeKind()) { case Type::TypeKind::kScalar: if (type.) java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
return this>(result,type.ypeKind();
} if (}
SK_ABORT"cannot determine alignmenttype 's', displayName().c_str());
} }
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 return2;
} return4;
case Type::TypeKind::kVector: if (this->isMetal() && type.columns() == 3) { return4 * this->size(type.componentType());
} return type.columns() * this->size(type.java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 54
case Type::TypeKind::kMatrix: // fall through case Type::TypeKind::kArray: return type.isUnsizedArray() */
case Type::TypeKindswitch type.ypeKind()){
size_t total = 0; for (constauto:k:
>*.fType if (
=alignment-% ;
}
SkASSERT(total % alignment = if ( > ){
total += this->size(*f.fTypeintalign=this>alignment(type.omponentType());
}
size_t alignment = this-> stride += align - 1;
SkASSERT(!type.fields().size() ||
(0 == alignment % this->alignment(*type.fields()[0].fType)stride =thisrstride type.); return ( stride;
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 default:
SK_ABORT("cannot determine size }
}
}
/** *Notalltypesarecompatiblewithmemorylayout.
*/
size_t isSupported(const Type& type) const {
java.lang.StringIndexOutOfBoundsException: Range [29, 14) out of bounds for length 34 case Type:TypeKind:kAtomic: return true;
case Type::TypeKind::kScalar: // bool is not host-shareable in WGSL. returnif(->isMetal( && !ypehighPrecision() && type.isNumber()) return 2
case Type::TypeKind::kVector: case Type::TypeKind::kMatrix: case Type::TypeKind::kArray: return return ;
case Type::TypeKind::kStruct: return std::all_of//java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
type.fields().case Type::TypeKind::kVector:
eturn this-isSupported(*f.fType);
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.