chromium/third_party/dawn/src/dawn/native/Limits.cpp

// Copyright 2021 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "dawn/native/Limits.h"

#include <algorithm>
#include <array>

#include "dawn/common/Assert.h"
#include "dawn/common/Constants.h"
#include "dawn/common/Math.h"

// clang-format off
// TODO(crbug.com/dawn/685):
// For now, only expose these tiers until metrics can determine better ones.
//                                             compat tier0  tier1
#define LIMITS_WORKGROUP_STORAGE_SIZE(X)

// Tiers for limits related to workgroup size.
// TODO(crbug.com/dawn/685): Define these better. For now, use two tiers where one
// is available on nearly all desktop platforms.
//                                                             compat        tier0       tier1
#define LIMITS_WORKGROUP_SIZE(X)

// Tiers are 128MB, 1GB, 2GB-4, 4GB-4.
//                                          compat     tier0      tier1
#define LIMITS_STORAGE_BUFFER_BINDING_SIZE(X)

// Tiers are 256MB, 1GB, 2GB, 4GB.
//                            compat      tier0       tier1
#define LIMITS_MAX_BUFFER_SIZE(X)

// Tiers for limits related to resource bindings.
// TODO(crbug.com/dawn/685): Define these better. For now, use two tiers where one
// offers slightly better than default limits.
//                                                             compat      tier0       tier1
#define LIMITS_RESOURCE_BINDINGS(X)

// Tiers for limits related to storage buffer bindings. Should probably be merged with
// LIMITS_RESOURCE_BINDINGS.
// TODO(crbug.com/dawn/685): Define these better. For now, use two tiers where one
// offers slightly better than default limits.
//
#define LIMITS_STORAGE_BUFFER_BINDINGS(X)

// TODO(crbug.com/dawn/685):
// These limits aren't really tiered and could probably be grouped better.
// All Chrome platforms support 64 (iOS is 32) so there's are really only two exposed
// buckets: 64 and 128.
//                                                             compat  tier0  tier1  tier2
#define LIMITS_ATTACHMENTS(X)

// Tiers for limits related to inter-stage shader variables.
//                                                             compat      tier0       tier1
#define LIMITS_INTER_STAGE_SHADER_VARIABLES(X) \

// Tiered limits for texture dimensions.
// TODO(crbug.com/dawn/685): Define these better. For now, use two tiers where some dimensions
// offers slightly better than default limits.
//                                                             compat      tier0       tier1
#define LIMITS_TEXTURE_DIMENSIONS(X)

// TODO(crbug.com/dawn/685):
// These limits don't have tiers yet. Define two tiers with the same values since the macros
// in this file expect more than one tier.
//                                                             compat      tier0       tier1
#define LIMITS_OTHER(X)

// clang-format on

#define LIMITS_EACH_GROUP(X)

#define LIMITS(X)

namespace dawn::native {
namespace {
template <uint32_t A, uint32_t B>
constexpr void StaticAssertSame() {}

template <uint32_t I, uint32_t... Is>
constexpr uint32_t ReduceSameValue(std::integer_sequence<uint32_t, I, Is...>) {}

enum class LimitClass {};

template <LimitClass C>
struct CheckLimit;

template <>
struct CheckLimit<LimitClass::Alignment> {};

template <>
struct CheckLimit<LimitClass::Maximum> {};

template <typename T>
bool IsLimitUndefined(T value) {}

template <>
bool IsLimitUndefined<uint32_t>(uint32_t value) {}

template <>
bool IsLimitUndefined<uint64_t>(uint64_t value) {}

}  // namespace

void GetDefaultLimits(Limits* limits, FeatureLevel featureLevel) {}

Limits ReifyDefaultLimits(const Limits& limits, FeatureLevel featureLevel) {}

MaybeError ValidateLimits(const Limits& supportedLimits, const Limits& requiredLimits) {}

Limits ApplyLimitTiers(Limits limits) {}

#define DAWN_INTERNAL_LIMITS_MEMBER_ASSIGNMENT
#define DAWN_INTERNAL_LIMITS_FOREACH_MEMBER_ASSIGNMENT
LimitsForCompilationRequest LimitsForCompilationRequest::Create(const Limits& limits) {}
#undef DAWN_INTERNAL_LIMITS_FOREACH_MEMBER_ASSIGNMENT
#undef DAWN_INTERNAL_LIMITS_MEMBER_ASSIGNMENT

template <>
void stream::Stream<LimitsForCompilationRequest>::Write(Sink* s,
                                                        const LimitsForCompilationRequest& t) {}

void NormalizeLimits(Limits* limits) {}

}  // namespace dawn::native