chromium/third_party/dawn/src/tint/lang/msl/writer/type_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 "gmock/gmock.h"

#include "src/tint/lang/core/type/array.h"
#include "src/tint/lang/core/type/depth_multisampled_texture.h"
#include "src/tint/lang/core/type/depth_texture.h"
#include "src/tint/lang/core/type/matrix.h"
#include "src/tint/lang/core/type/multisampled_texture.h"
#include "src/tint/lang/core/type/sampled_texture.h"
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/struct.h"
#include "src/tint/lang/msl/writer/helper_test.h"
#include "src/tint/utils/text/string.h"

namespace tint::msl::writer {
namespace {

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

TEST_F(MslWriterTest, EmitType_Array) {}

TEST_F(MslWriterTest, EmitType_ArrayOfArray) {}

TEST_F(MslWriterTest, EmitType_ArrayOfArrayOfArray) {}

TEST_F(MslWriterTest, EmitType_RuntimeArray) {}

TEST_F(MslWriterTest, EmitType_Bool) {}

TEST_F(MslWriterTest, EmitType_F32) {}

TEST_F(MslWriterTest, EmitType_F16) {}

TEST_F(MslWriterTest, EmitType_I32) {}

TEST_F(MslWriterTest, EmitType_Matrix_F32) {}

TEST_F(MslWriterTest, EmitType_Matrix_F16) {}
TEST_F(MslWriterTest, EmitType_U32) {}

TEST_F(MslWriterTest, EmitType_Atomic_U32) {}

TEST_F(MslWriterTest, EmitType_Atomic_I32) {}

TEST_F(MslWriterTest, EmitType_Vector) {}

TEST_F(MslWriterTest, EmitType_VectorPacked) {}

TEST_F(MslWriterTest, EmitType_Void) {}

// TODO(dsinclair): How do we create a pointer type ... ?
TEST_F(MslWriterTest, DISABLED_EmitType_Pointer_Workgroup) {}

// TODO(dsinclair): How do we create a pointer type ... ?
TEST_F(MslWriterTest, DISABLED_EmitType_Pointer_Const) {}

TEST_F(MslWriterTest, EmitType_Struct) {}

TEST_F(MslWriterTest, EmitType_Struct_Dedup) {}

void FormatMSLField(StringStream& out,
                    const char* addr,
                    const char* type,
                    size_t array_count,
                    const char* name) {}

#define CHECK_TYPE_SIZE_AND_ALIGN(TYPE, SIZE, ALIGN)

// Declare C++ types that match the size and alignment of the types of the same
// name in MSL.
#define DECLARE_TYPE(NAME, SIZE, ALIGN)

// Size and alignments taken from the MSL spec:
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
DECLARE_TYPE();
uint;

struct MemberData {};
core::type::Struct* MkStruct(core::ir::Module& mod,
                             core::type::Manager& ty,
                             std::string_view name,
                             VectorRef<MemberData> data) {}

TEST_F(MslWriterTest, EmitType_Struct_Layout_NumericTypes) {}

TEST_F(MslWriterTest, EmitType_Struct_Layout_Structures) {}

TEST_F(MslWriterTest, EmitType_Struct_Layout_ArrayDefaultStride) {}

TEST_F(MslWriterTest, EmitType_Struct_Layout_Vec3) {}

TEST_F(MslWriterTest, AttemptTintPadSymbolCollision) {}

TEST_F(MslWriterTest, EmitType_Sampler) {}

TEST_F(MslWriterTest, EmitType_SamplerComparison) {}

struct MslDepthTextureData {};
inline std::ostream& operator<<(std::ostream& out, MslDepthTextureData data) {}
MslWriterDepthTexturesTest;
TEST_P(MslWriterDepthTexturesTest, Emit) {}
INSTANTIATE_TEST_SUITE_P();

TEST_F(MslWriterTest, EmitType_DepthMultisampledTexture) {}

struct MslTextureData {};
inline std::ostream& operator<<(std::ostream& out, MslTextureData data) {}
MslWriterSampledtexturesTest;
TEST_P(MslWriterSampledtexturesTest, Emit) {}
INSTANTIATE_TEST_SUITE_P();

TEST_F(MslWriterTest, EmitType_MultisampledTexture) {}

struct MslStorageTextureData {};
inline std::ostream& operator<<(std::ostream& out, MslStorageTextureData data) {}
MslWriterStorageTexturesTest;
TEST_P(MslWriterStorageTexturesTest, Emit) {}
INSTANTIATE_TEST_SUITE_P();

// Metal only supports f{16, 32} at (8x8). Bfloat is also supported but isn't in WGSL.
TEST_F(MslWriterTest, EmitType_SubgroupMatrixLeft) {}

// Metal only supports f{16, 32} at (8x8). Bfloat is also supported but isn't in WGSL.
TEST_F(MslWriterTest, EmitType_SubgroupMatrixRight) {}

// Metal only supports f{16, 32} at (8x8). Bfloat is also supported but isn't in WGSL.
TEST_F(MslWriterTest, EmitType_SubgroupMatrixResult) {}

}  // namespace
}  // namespace tint::msl::writer