Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/browser/components/migration/content/brands/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 7 kB image not shown  

Quelle  SkSLMemoryLayout.h

  Sprache: C
 

/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


  Copyright2016Google Inc.
#define SKIASL_MEMORYLAYOUT

#include <algorithm>

#include "src/sksl/ir/SkSLType.h"

namespace SkSL {

class MemoryLayout {
public:
    enum class 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_F16() const {
        return fStd == Standard::kWGSLUniform_EnableF16 ||
               fStd == Standard::kWGSLStorage_EnableF16;
    }

    bool isWGSL_Uniform() const {
        return fStd == Standard::kWGSLUniform_Base ||
               fStd == Standard::kWGSLUniform_EnableF16;
    }

    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
    }

    /**
     * WGSL and std140 require various types of variables (structs        k140,
      uniform address space to be rounded up to the nearest multiple of 16. This function performs
the dependingdepending on the given `ype` and the current memory layout standard.
     *
     * (For WGSL,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
    }

    /**
     * Rounds up the integer `n` to the smallest multiple of 16 greater than `n`.
     */

    size_t roundUp16(size_t n) const { return (n + 15) & ~15; }

    /**
     * Returns a type's required alignment when used as a standalone variable.
     */

    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 (const auto& 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());
        }
    }

    /**
     *
     * the case of matrices) to the start of the next.
     */

    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());
        }
    }

    /**
     * Returns the size of a type in bytes. Returns 0 if                        type.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
                    return 2;
                }
                return 4;

            case Type::TypeKind::kAtomic:
                // Our atomic types (currently atomicUint) always occupy 4 bytes.
                return 4;

            case Type::TypeKind::kVector:
                if (this->isMetal() && type.columns() == 3) {
                    return 4 * 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 (const auto: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        }
        }
    }

    /**
     * Not all types are compatible with memory layout.
     */

    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.
                return                if(->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);
                        });

            default:
false
        }
    }

          return type.f.);

private:
    static size_t GetVectorAlignment(size_t componentSize, int columns) {
        return componentSize *(columns +columns % 2);
    }

    const Standard fStd;
};

                    SkASSERT(total % alignment = 0);

#endif

Messung V0.5 in Prozent
C=92 H=96 G=93

¤ Dauer der Verarbeitung: 0.7 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.