chromium/third_party/dawn/src/tint/lang/spirv/writer/builtin_test.cc

// Copyright 2023 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 "src/tint/lang/spirv/writer/common/helper_test.h"

#include "src/tint/lang/core/builtin_fn.h"
#include "src/tint/lang/core/type/builtin_structs.h"

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

namespace tint::spirv::writer {
namespace {

/// A parameterized builtin function test case.
struct BuiltinTestCase {};

// Tests for builtins with the signature: T = func(T)
Builtin_1arg;
TEST_P(Builtin_1arg, Scalar) {}
TEST_P(Builtin_1arg, Vector) {}
INSTANTIATE_TEST_SUITE_P();

// Test that abs of an unsigned value just folds away.
TEST_F(SpirvWriterTest, Builtin_Abs_u32) {}

TEST_F(SpirvWriterTest, Builtin_Abs_vec2u) {}

// Test that all of a scalar just folds away.
TEST_F(SpirvWriterTest, Builtin_All_Scalar) {}

TEST_F(SpirvWriterTest, Builtin_All_Vector) {}

// Test that any of a scalar just folds away.
TEST_F(SpirvWriterTest, Builtin_Any_Scalar) {}

TEST_F(SpirvWriterTest, Builtin_Any_Vector) {}

TEST_F(SpirvWriterTest, Builtin_Determinant_Mat4x4f) {}

TEST_F(SpirvWriterTest, Builtin_Determinant_Mat3x3h) {}

TEST_F(SpirvWriterTest, Builtin_Frexp_F32) {}

TEST_F(SpirvWriterTest, Builtin_Frexp_F16) {}

TEST_F(SpirvWriterTest, Builtin_Frexp_Vec2f) {}

TEST_F(SpirvWriterTest, Builtin_Frexp_Vec3h) {}

TEST_F(SpirvWriterTest, Builtin_Length_vec4f) {}

TEST_F(SpirvWriterTest, Builtin_Modf_F32) {}

TEST_F(SpirvWriterTest, Builtin_Modf_F16) {}

TEST_F(SpirvWriterTest, Builtin_Modf_Vec2f) {}

TEST_F(SpirvWriterTest, Builtin_Modf_Vec3h) {}

TEST_F(SpirvWriterTest, Builtin_Normalize_vec4f) {}

TEST_F(SpirvWriterTest, Builtin_Transpose_Mat2x3f) {}

TEST_F(SpirvWriterTest, Builtin_Transpose_Mat4x4f) {}

TEST_F(SpirvWriterTest, Builtin_Transpose_Mat4x3h) {}

TEST_F(SpirvWriterTest, Builtin_Transpose_Mat2x2h) {}

TEST_F(SpirvWriterTest, Builtin_Pack2X16Float) {}

TEST_F(SpirvWriterTest, Builtin_Pack2X16Snorm) {}

TEST_F(SpirvWriterTest, Builtin_Pack2X16Unorm) {}

TEST_F(SpirvWriterTest, Builtin_Pack4X8Snorm) {}

TEST_F(SpirvWriterTest, Builtin_Pack4X8Unorm) {}

TEST_F(SpirvWriterTest, Builtin_Unpack2X16Float) {}

TEST_F(SpirvWriterTest, Builtin_Unpack2X16Snorm) {}

TEST_F(SpirvWriterTest, Builtin_Unpack2X16Unorm) {}

TEST_F(SpirvWriterTest, Builtin_Unpack4X8Snorm) {}

TEST_F(SpirvWriterTest, Builtin_Unpack4X8Unorm) {}

TEST_F(SpirvWriterTest, Builtin_CountLeadingZeros_U32) {}

TEST_F(SpirvWriterTest, Builtin_CountLeadingZeros_I32) {}

TEST_F(SpirvWriterTest, Builtin_CountLeadingZeros_Vec2U32) {}

TEST_F(SpirvWriterTest, Builtin_CountTrailingZeros_U32) {}

TEST_F(SpirvWriterTest, Builtin_CountTrailingZeros_I32) {}

TEST_F(SpirvWriterTest, Builtin_CountTrailingZeros_Vec2U32) {}

TEST_F(SpirvWriterTest, Builtin_FirstLeadingBit_U32) {}

TEST_F(SpirvWriterTest, Builtin_FirstLeadingBit_I32) {}

TEST_F(SpirvWriterTest, Builtin_FirstLeadingBit_Vec2U32) {}

TEST_F(SpirvWriterTest, Builtin_FirstTrailingBit_U32) {}

TEST_F(SpirvWriterTest, Builtin_FirstTrailingBit_I32) {}

TEST_F(SpirvWriterTest, Builtin_FirstTrailingBit_Vec2U32) {}

TEST_F(SpirvWriterTest, Builtin_Saturate_F32) {}

TEST_F(SpirvWriterTest, Builtin_Saturate_Vec4h) {}

// Tests for builtins with the signature: T = func(T, T)
Builtin_2arg;
TEST_P(Builtin_2arg, Scalar) {}
TEST_P(Builtin_2arg, Vector) {}
INSTANTIATE_TEST_SUITE_P();

TEST_F(SpirvWriterTest, Builtin_Cross_vec3f) {}

TEST_F(SpirvWriterTest, Builtin_Distance_vec2f) {}

TEST_F(SpirvWriterTest, Builtin_Distance_vec3h) {}

TEST_F(SpirvWriterTest, Builtin_Dot_vec4f) {}

TEST_F(SpirvWriterTest, Builtin_Dot_vec2i) {}

TEST_F(SpirvWriterTest, Builtin_Dot_vec4u) {}

TEST_F(SpirvWriterTest, Builtin_Ldexp_F32) {}

TEST_F(SpirvWriterTest, Builtin_Ldexp_F16) {}

TEST_F(SpirvWriterTest, Builtin_Ldexp_Vec2_F32) {}

TEST_F(SpirvWriterTest, Builtin_Ldexp_Vec3_F16) {}

TEST_F(SpirvWriterTest, Builtin_Reflect_F32) {}

TEST_F(SpirvWriterTest, Builtin_Reflect_F16) {}

// Tests for builtins with the signature: T = func(T, T, T)
Builtin_3arg;
TEST_P(Builtin_3arg, Scalar) {}
TEST_P(Builtin_3arg, Vector) {}
INSTANTIATE_TEST_SUITE_P();

TEST_F(SpirvWriterTest, Builtin_Clamp_Scalar_I32) {}

TEST_F(SpirvWriterTest, Builtin_Clamp_Scalar_U32) {}

TEST_F(SpirvWriterTest, Builtin_Clamp_Vector_I32) {}

TEST_F(SpirvWriterTest, Builtin_Clamp_Vector_U32) {}

TEST_F(SpirvWriterTest, Builtin_ExtractBits_Scalar_I32) {}

TEST_F(SpirvWriterTest, Builtin_ExtractBits_Scalar_U32) {}

TEST_F(SpirvWriterTest, Builtin_ExtractBits_Vector_I32) {}

TEST_F(SpirvWriterTest, Builtin_ExtractBits_Vector_U32) {}

TEST_F(SpirvWriterTest, Builtin_InsertBits_Scalar_I32) {}

TEST_F(SpirvWriterTest, Builtin_InsertBits_Scalar_U32) {}

TEST_F(SpirvWriterTest, Builtin_InsertBits_Vector_I32) {}

TEST_F(SpirvWriterTest, Builtin_InsertBits_Vector_U32) {}

TEST_F(SpirvWriterTest, Builtin_FaceForward_F32) {}

TEST_F(SpirvWriterTest, Builtin_FaceForward_F16) {}

TEST_F(SpirvWriterTest, Builtin_Mix_VectorOperands_ScalarFactor) {}

TEST_F(SpirvWriterTest, Builtin_Mix_VectorOperands_VectorFactor) {}

TEST_F(SpirvWriterTest, Builtin_Refract_F32) {}

TEST_F(SpirvWriterTest, Builtin_Refract_F16) {}

TEST_F(SpirvWriterTest, Builtin_Select_ScalarCondition_ScalarOperands) {}

TEST_F(SpirvWriterTest, Builtin_Select_VectorCondition_VectorOperands) {}

TEST_F(SpirvWriterTest, Builtin_Select_ScalarCondition_VectorOperands) {}

TEST_F(SpirvWriterTest, Builtin_StorageBarrier) {}

TEST_F(SpirvWriterTest, Builtin_StorageBarrier_VulkanMemoryModel) {}

TEST_F(SpirvWriterTest, Builtin_TextureBarrier) {}

TEST_F(SpirvWriterTest, Builtin_TextureBarrier_Vulkan) {}

TEST_F(SpirvWriterTest, Builtin_WorkgroupBarrier) {}

TEST_F(SpirvWriterTest, Builtin_WorkgroupBarrier_VulkanMemoryModel) {}

TEST_F(SpirvWriterTest, Builtin_SubgroupBallot) {}

TEST_F(SpirvWriterTest, Builtin_SubgroupBroadcastValueF32) {}

TEST_F(SpirvWriterTest, Builtin_SubgroupBroadcastValueI32) {}

TEST_F(SpirvWriterTest, Builtin_SubgroupBroadcastValueU32) {}

TEST_F(SpirvWriterTest, Builtin_ArrayLength) {}

TEST_F(SpirvWriterTest, Builtin_ArrayLength_WithStruct) {}

////////////////////////////////////////////////////////////////////////////////
// DP4A builtins
////////////////////////////////////////////////////////////////////////////////

TEST_F(SpirvWriterTest, Builtin_Dot4I8Packed) {}

TEST_F(SpirvWriterTest, Builtin_Dot4U8Packed) {}

}  // namespace
}  // namespace tint::spirv::writer