chromium/third_party/dawn/src/tint/lang/wgsl/resolver/builtins_validation_test.cc

// 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 <functional>
#include "src/tint/lang/core/builtin_value.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/extension.h"
#include "src/tint/lang/wgsl/resolver/resolver_helper_test.h"
#include "src/tint/utils/text/string_stream.h"

namespace tint::resolver {
namespace {

usingnamespacetint::core::fluent_types;     // NOLINT
usingnamespacetint::core::number_suffixes;  // NOLINT

DataType;
class ResolverBuiltinsValidationTest : public resolver::TestHelper, public testing::Test {};
namespace StageTest {
struct Params {};

template <typename T>
constexpr Params ParamsFor(core::BuiltinValue builtin, ast::PipelineStage stage, bool is_valid) {}
static constexpr Params cases[] =;

ResolverBuiltinsStageTest;
TEST_P(ResolverBuiltinsStageTest, All_input) {}
INSTANTIATE_TEST_SUITE_P();

TEST_F(ResolverBuiltinsValidationTest, FragDepthIsInput_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, FragDepthIsInputStruct_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, StructBuiltinInsideEntryPoint_Ignored) {}

}  // namespace StageTest

TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_Struct_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_ReturnType_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, PositionIsVec4h_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, FragDepthNotF32_Struct_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_Struct_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_ReturnType_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, SampleMaskIsNotU32_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, SampleIndexIsNotU32_Struct_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, SampleIndexIsNotU32_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, PositionIsNotF32_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, FragDepthIsNotF32_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, VertexIndexIsNotU32_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, InstanceIndexIsNotU32) {}

TEST_F(ResolverBuiltinsValidationTest, FragmentBuiltin_Pass) {}

TEST_F(ResolverBuiltinsValidationTest, VertexBuiltin_Pass) {}

TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_Pass) {}

TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_WorkGroupIdNotVec3U32) {}

TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_NumWorkgroupsNotVec3U32) {}

TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_GlobalInvocationNotVec3U32) {}

TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_LocalInvocationIndexNotU32) {}

TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_LocalInvocationNotVec3U32) {}

TEST_F(ResolverBuiltinsValidationTest, FragmentBuiltinStruct_Pass) {}

TEST_F(ResolverBuiltinsValidationTest, FrontFacingParamIsNotBool_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, FrontFacingMemberIsNotBool_Fail) {}

TEST_F(ResolverBuiltinsValidationTest, Length_Float_Scalar) {}

TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec2) {}

TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec3) {}

TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec4) {}

TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Scalar) {}

TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec2) {}

TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec3) {}

TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec4) {}

TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat2x2) {}

TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat3x3) {}

TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat4x4) {}

TEST_F(ResolverBuiltinsValidationTest, Frexp_Scalar) {}

TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {}

TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {}

TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {}

TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {}

TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {}

TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {}

TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {}

TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) {}

TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec2) {}

TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec3) {}

TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec4) {}

TEST_F(ResolverBuiltinsValidationTest, Select_Float_Scalar) {}

TEST_F(ResolverBuiltinsValidationTest, Select_Integer_Scalar) {}

TEST_F(ResolverBuiltinsValidationTest, Select_Boolean_Scalar) {}

TEST_F(ResolverBuiltinsValidationTest, Select_Float_Vec2) {}

TEST_F(ResolverBuiltinsValidationTest, Select_Integer_Vec2) {}

TEST_F(ResolverBuiltinsValidationTest, Select_Boolean_Vec2) {}

template <typename T>
class ResolverBuiltinsValidationTestWithParams : public resolver::TestHelper,
                                                 public testing::TestWithParam<T> {};

FloatAllMatching;

TEST_P(FloatAllMatching, Scalar) {}

TEST_P(FloatAllMatching, Vec2) {}

TEST_P(FloatAllMatching, Vec3) {}

TEST_P(FloatAllMatching, Vec4) {}

INSTANTIATE_TEST_SUITE_P();

IntegerAllMatching;

TEST_P(IntegerAllMatching, ScalarUnsigned) {}

TEST_P(IntegerAllMatching, Vec2Unsigned) {}

TEST_P(IntegerAllMatching, Vec3Unsigned) {}

TEST_P(IntegerAllMatching, Vec4Unsigned) {}

TEST_P(IntegerAllMatching, ScalarSigned) {}

TEST_P(IntegerAllMatching, Vec2Signed) {}

TEST_P(IntegerAllMatching, Vec3Signed) {}

TEST_P(IntegerAllMatching, Vec4Signed) {}

INSTANTIATE_TEST_SUITE_P();

BooleanVectorInput;

TEST_P(BooleanVectorInput, Vec2) {}

TEST_P(BooleanVectorInput, Vec3) {}

TEST_P(BooleanVectorInput, Vec4) {}

INSTANTIATE_TEST_SUITE_P();

DataPacking4x8;

TEST_P(DataPacking4x8, Float_Vec4) {}

INSTANTIATE_TEST_SUITE_P();

DataPacking2x16;

TEST_P(DataPacking2x16, Float_Vec2) {}

INSTANTIATE_TEST_SUITE_P();

ExprMaker;
template <typename T>
ExprMaker Mk(core::Number<T> v) {}

// We''ll construct cases like this:
// fn foo() {
//   var s: STYPE;
//   _ = clamp(s, LOW, HIGH);
// }
struct ClampPartialConstCase {};

ClampPartialConst;

TEST_P(ClampPartialConst, Scalar) {}

TEST_P(ClampPartialConst, Vector) {}

TEST_P(ClampPartialConst, VectorMixedRuntimeConstNotChecked) {}

std::vector<ClampPartialConstCase> clampCases() {}

INSTANTIATE_TEST_SUITE_P();

// We''ll construct cases like this:
// fn foo() {
//   var s: STYPE;
//   _ = smoothstep(LOW, HIGH, s);
// }
struct SmoothstepPartialConstCase {};

SmoothstepPartialConst;

TEST_P(SmoothstepPartialConst, Scalar) {}

TEST_P(SmoothstepPartialConst, Vector) {}

TEST_P(SmoothstepPartialConst, VectorMixedRuntimeConstNotChecked) {}

std::vector<SmoothstepPartialConstCase> smoothstepCases() {}

INSTANTIATE_TEST_SUITE_P();

// We'll construct cases like this:
// fn foo() {
//   var e: ETYPE;
//   _ = insertBits(e, e, COUNT, OFFSET);
// }

struct InsertBitsPartialConstCase {};

InsertBitsPartialConst;

TEST_P(InsertBitsPartialConst, Scalar) {}

TEST_P(InsertBitsPartialConst, Vector) {}

std::vector<InsertBitsPartialConstCase> insertBitsCases() {}

INSTANTIATE_TEST_SUITE_P();

// We'll construct cases like this:
// fn foo() {
//   var e: ETYPE;
//   _ = extractBits(e, COUNT, OFFSET);
// }

struct ExtractBitsPartialConstCase {};

ExtractBitsPartialConst;

TEST_P(ExtractBitsPartialConst, Scalar) {}

TEST_P(ExtractBitsPartialConst, Vector) {}

std::vector<ExtractBitsPartialConstCase> extractBitsCases() {}

INSTANTIATE_TEST_SUITE_P();

// We'll construct cases like this:
// fn foo() {
//   var x: XTYPE;
//   _ = ldexp(x, EXPONENT);
// }

struct LdexpPartialConstCase {};

LdexpPartialConst;

TEST_P(LdexpPartialConst, Scalar) {}

TEST_P(LdexpPartialConst, Vector) {}

std::vector<LdexpPartialConstCase> ldexpCases() {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace
}  // namespace tint::resolver