chromium/third_party/dawn/src/tint/lang/core/ir/transform/robustness_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/core/ir/transform/robustness.h"

#include <utility>

#include "src/tint/lang/core/ir/transform/helper_test.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/external_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/pointer.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/core/type/vector.h"

namespace tint::core::ir::transform {
namespace {

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

// Tests for non-binding variables
IR_RobustnessTest;

// Tests for binding variables
struct BindingVariableCase {};
inline std::ostream& operator<<(std::ostream& out, BindingVariableCase c) {}
IR_BindingVariableRobustnessTest;

////////////////////////////////////////////////////////////////
// These tests use the function address space.
// Test clamping of vectors, matrices, and fixed-size arrays.
// Test indices that are const, const-via-let, and dynamic.
// Test signed vs unsigned indices.
////////////////////////////////////////////////////////////////

TEST_P(IR_RobustnessTest, VectorLoad_ConstIndex) {}

TEST_P(IR_RobustnessTest, VectorLoad_ConstIndexViaLet) {}

TEST_P(IR_RobustnessTest, VectorLoad_DynamicIndex) {}

TEST_P(IR_RobustnessTest, VectorLoad_DynamicIndex_Signed) {}

TEST_P(IR_RobustnessTest, VectorStore_ConstIndex) {}

TEST_P(IR_RobustnessTest, VectorStore_ConstIndexViaLet) {}

TEST_P(IR_RobustnessTest, VectorStore_DynamicIndex) {}

TEST_P(IR_RobustnessTest, VectorStore_DynamicIndex_Signed) {}

TEST_P(IR_RobustnessTest, Matrix_ConstIndex) {}

TEST_P(IR_RobustnessTest, Matrix_ConstIndexViaLet) {}

TEST_P(IR_RobustnessTest, Matrix_DynamicIndex) {}

TEST_P(IR_RobustnessTest, Matrix_DynamicIndex_Signed) {}

TEST_P(IR_RobustnessTest, Array_ConstSize_ConstIndex) {}

TEST_P(IR_RobustnessTest, Array_ConstSize_ConstIndexViaLet) {}

TEST_P(IR_RobustnessTest, Array_ConstSize_DynamicIndex) {}

TEST_P(IR_RobustnessTest, Array_ConstSize_DynamicIndex_Signed) {}

TEST_P(IR_RobustnessTest, NestedArrays) {}

TEST_P(IR_RobustnessTest, NestedMixedTypes) {}

////////////////////////////////////////////////////////////////
// Test the clamp toggles for every other address space.
////////////////////////////////////////////////////////////////

TEST_P(IR_RobustnessTest, Private_LoadVectorElement) {}

TEST_P(IR_RobustnessTest, Private_StoreVectorElement) {}

TEST_P(IR_RobustnessTest, Private_Access) {}

TEST_P(IR_RobustnessTest, PushConstant_LoadVectorElement) {}

TEST_P(IR_RobustnessTest, PushConstant_StoreVectorElement) {}

TEST_P(IR_RobustnessTest, PushConstant_Access) {}

TEST_P(IR_BindingVariableRobustnessTest, Storage_LoadVectorElement) {}

TEST_P(IR_BindingVariableRobustnessTest, Storage_StoreVectorElement) {}

TEST_P(IR_BindingVariableRobustnessTest, Storage_Access) {}

TEST_P(IR_BindingVariableRobustnessTest, Unifom_LoadVectorElement) {}

TEST_P(IR_BindingVariableRobustnessTest, Unifom_StoreVectorElement) {}

TEST_P(IR_BindingVariableRobustnessTest, Uniform_Access) {}

TEST_P(IR_RobustnessTest, Workgroup_LoadVectorElement) {}

TEST_P(IR_RobustnessTest, Workgroup_StoreVectorElement) {}

TEST_P(IR_RobustnessTest, Workgroup_Access) {}

////////////////////////////////////////////////////////////////
// Test clamping non-pointer values.
////////////////////////////////////////////////////////////////

TEST_P(IR_RobustnessTest, ConstantVector_DynamicIndex) {}

TEST_P(IR_RobustnessTest, ConstantArray_DynamicIndex) {}

TEST_P(IR_RobustnessTest, ParamValueArray_DynamicIndex) {}

////////////////////////////////////////////////////////////////
// Test clamping runtime-sized arrays.
////////////////////////////////////////////////////////////////

TEST_P(IR_BindingVariableRobustnessTest, RuntimeSizedArray_ConstIndex) {}

TEST_P(IR_BindingVariableRobustnessTest, RuntimeSizedArray_DynamicIndex) {}

TEST_P(IR_BindingVariableRobustnessTest, RuntimeSizedArray_InStruct_ConstIndex) {}

TEST_P(IR_BindingVariableRobustnessTest, RuntimeSizedArray_InStruct_DynamicIndex) {}

TEST_P(IR_BindingVariableRobustnessTest, RuntimeSizedArray_DisableClamping) {}

////////////////////////////////////////////////////////////////
// Test clamping texture builtin calls.
////////////////////////////////////////////////////////////////

TEST_P(IR_BindingVariableRobustnessTest, TextureDimensions) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureDimensions_WithLevel) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Sampled1D) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Sampled2D) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Sampled2DArray) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Sampled3D) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Multisampled2D) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Depth2D) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Depth2DArray) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_DepthMultisampled2D) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_External) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Storage1D) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Storage2D) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Storage2DArray) {}

TEST_P(IR_BindingVariableRobustnessTest, TextureLoad_Storage3D) {}

////////////////////////////////////////////////////////////////
// Test things that should not be clamped.
////////////////////////////////////////////////////////////////

TEST_P(IR_BindingVariableRobustnessTest, NoModify_TextureStore) {}

// Test that ignoring a subset of bindings works
TEST_P(IR_RobustnessTest, BindingsIgnored_Subset) {}

// Test that bindings_ignored works via lets
TEST_P(IR_RobustnessTest, BindingsIgnored_ViaLets) {}

INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();
}  // namespace
}  // namespace tint::core::ir::transform