chromium/third_party/dawn/src/tint/lang/wgsl/ast/transform/robustness_test.cc

// Copyright 2020 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/wgsl/ast/transform/robustness.h"

#include "src/tint/lang/wgsl/ast/transform/helper_test.h"

namespace tint::ast::transform {

static std::ostream& operator<<(std::ostream& out, Robustness::Action action) {}

namespace {

DataMap Config(Robustness::Action action, bool disable_runtime_sized_array_index_clamping = false) {}

const char* Expect(Robustness::Action action,
                   const char* expect_ignore,
                   const char* expect_clamp,
                   const char* expect_predicate) {}

RobustnessTest;

////////////////////////////////////////////////////////////////////////////////
// Constant sized array
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, Read_ConstantSizedArrayVal_IndexWithLiteral) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayVal_IndexWithConst) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayVal_IndexWithLet) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayVal_IndexWithRuntimeArrayIndex) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayVal_IndexWithRuntimeExpression) {}

TEST_P(RobustnessTest, Read_NestedConstantSizedArraysVal_IndexWithRuntimeExpressions) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayVal_IndexWithOverride) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayRef_IndexWithLiteral) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayRef_IndexWithConst) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayRef_IndexWithLet) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayRef_IndexWithRuntimeArrayIndex) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayRef_IndexWithRuntimeArrayIndexViaPointerIndex) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayRef_IndexWithRuntimeExpression) {}

TEST_P(RobustnessTest, Read_NestedConstantSizedArraysRef_IndexWithRuntimeExpressions) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayRef_IndexWithOverride) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayPtr_IndexWithLet) {}

TEST_P(RobustnessTest, Read_ConstantSizedArrayPtr_IndexWithRuntimeArrayIndex) {}

TEST_P(RobustnessTest, Read_NestedConstantSizedArraysPtr_IndexWithRuntimeExpressions) {}

TEST_P(RobustnessTest, Read_NestedConstantSizedArrays_MixedAccess) {}

TEST_P(RobustnessTest, Assign_ConstantSizedArray_IndexWithLet) {}

TEST_P(RobustnessTest, Assign_ConstantSizedArrayPtr_IndexWithLet) {}

TEST_P(RobustnessTest, Assign_ConstantSizedArrayPtr_IndexWithRuntimeArrayIndex) {}

TEST_P(RobustnessTest, Assign_NestedConstantSizedArraysPtr_IndexWithRuntimeExpressions) {}

TEST_P(RobustnessTest, Assign_NestedConstantSizedArrays_MixedAccess) {}

TEST_P(RobustnessTest, CompoundAssign_ConstantSizedArray_IndexWithLet) {}

TEST_P(RobustnessTest, Increment_ConstantSizedArray_IndexWithLet) {}

////////////////////////////////////////////////////////////////////////////////
// Runtime sized array
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, Read_RuntimeArray_IndexWithLiteral) {}

////////////////////////////////////////////////////////////////////////////////
// Vector
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, Read_Vector_IndexWithLiteral) {}

TEST_P(RobustnessTest, Read_Vector_IndexWithConst) {}

TEST_P(RobustnessTest, Read_Vector_IndexWithLet) {}

TEST_P(RobustnessTest, Read_Vector_IndexWithRuntimeExpression) {}

TEST_P(RobustnessTest, Read_Vector_IndexWithRuntimeExpression_ViaPointerIndex) {}

TEST_P(RobustnessTest, Read_Vector_SwizzleIndexWithGlobalVar) {}

TEST_P(RobustnessTest, Read_Vector_SwizzleIndexWithRuntimeExpression) {}

TEST_P(RobustnessTest, Read_Vector_SwizzleIndexWithRuntimeExpression_ViaPointerDot) {}

TEST_P(RobustnessTest, Read_Vector_IndexWithOverride) {}

////////////////////////////////////////////////////////////////////////////////
// Matrix
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, Read_MatrixRef_IndexingWithLiterals) {}

TEST_P(RobustnessTest, Read_MatrixRef_IndexWithRuntimeExpressionThenLiteral) {}

TEST_P(RobustnessTest, Read_MatrixRef_IndexWithLiteralThenRuntimeExpression) {}

TEST_P(RobustnessTest, Read_MatrixRef_IndexWithOverrideThenLiteral) {}

TEST_P(RobustnessTest, Read_MatrixRef_IndexWithLetThenSwizzle) {}

TEST_P(RobustnessTest, Read_MatrixRef_IndexWithLiteralThenOverride) {}

TEST_P(RobustnessTest, Assign_Matrix_IndexWithLet) {}

TEST_P(RobustnessTest, CompoundAssign_Matrix_IndexWithLet) {}

////////////////////////////////////////////////////////////////////////////////
// Texture builtin calls.
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, TextureDimensions) {}

TEST_P(RobustnessTest, TextureDimensions_Level) {}

TEST_P(RobustnessTest, TextureGather) {}

TEST_P(RobustnessTest, TextureGather_Array) {}

TEST_P(RobustnessTest, TextureGatherCompare) {}

TEST_P(RobustnessTest, TextureGatherCompare_Array) {}

TEST_P(RobustnessTest, TextureLoad_1D) {}

TEST_P(RobustnessTest, TextureLoad_2D) {}

TEST_P(RobustnessTest, TextureLoad_2DArray) {}

TEST_P(RobustnessTest, TextureLoad_3D) {}

TEST_P(RobustnessTest, TextureLoad_Multisampled2D) {}

TEST_P(RobustnessTest, TextureLoad_Depth2D) {}

TEST_P(RobustnessTest, TextureLoad_Depth2DArray) {}

TEST_P(RobustnessTest, TextureLoad_External) {}

TEST_P(RobustnessTest, TextureNumLayers) {}

TEST_P(RobustnessTest, TextureNumLevels) {}

TEST_P(RobustnessTest, TextureNumSamples) {}

TEST_P(RobustnessTest, TextureSample) {}

TEST_P(RobustnessTest, TextureSample_Offset) {}

TEST_P(RobustnessTest, TextureSample_ArrayIndex) {}

TEST_P(RobustnessTest, TextureSampleBias) {}

TEST_P(RobustnessTest, TextureSampleBias_Offset) {}

TEST_P(RobustnessTest, TextureSampleBias_ArrayIndex) {}

TEST_P(RobustnessTest, TextureSampleCompare) {}

TEST_P(RobustnessTest, TextureSampleCompare_Offset) {}

TEST_P(RobustnessTest, TextureSampleCompare_ArrayIndex) {}

TEST_P(RobustnessTest, TextureSampleCompareLevel) {}

TEST_P(RobustnessTest, TextureSampleCompareLevel_Offset) {}

TEST_P(RobustnessTest, TextureSampleCompareLevel_ArrayIndex) {}

TEST_P(RobustnessTest, TextureSampleGrad) {}

TEST_P(RobustnessTest, TextureSampleGrad_Offset) {}

TEST_P(RobustnessTest, TextureSampleGrad_ArrayIndex) {}

TEST_P(RobustnessTest, TextureSampleLevel) {}

TEST_P(RobustnessTest, TextureSampleLevel_Offset) {}

TEST_P(RobustnessTest, TextureSampleLevel_ArrayIndex) {}

TEST_P(RobustnessTest, TextureSampleBaseClampToEdge) {}

////////////////////////////////////////////////////////////////////////////////
// Other
////////////////////////////////////////////////////////////////////////////////
TEST_P(RobustnessTest, ShadowedVariable) {}

// Check that existing use of min() and arrayLength() do not get renamed.
TEST_P(RobustnessTest, DontRenameSymbols) {}

TEST_P(RobustnessTest, WorkgroupOverrideCount) {}

////////////////////////////////////////////////////////////////////////////////
// atomic predication
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, AtomicLoad) {}

TEST_P(RobustnessTest, AtomicAnd) {}

////////////////////////////////////////////////////////////////////////////////
// workgroupUniformLoad
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, WorkgroupUniformLoad) {}

////////////////////////////////////////////////////////////////////////////////
// Usage in loops
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, ArrayVal_ForLoopInit) {}

TEST_P(RobustnessTest, ArrayVal_ForLoopCond) {}

TEST_P(RobustnessTest, ArrayVal_ForLoopCont) {}

TEST_P(RobustnessTest, TextureLoad_ForLoopInit) {}

TEST_P(RobustnessTest, TextureLoad_ForLoopCond) {}

TEST_P(RobustnessTest, TextureLoad_ForLoopCont) {}

TEST_P(RobustnessTest, AtomicXor_ForLoopInit) {}

TEST_P(RobustnessTest, AtomicXor_ForLoopCond) {}

TEST_P(RobustnessTest, AtomicXor_ForLoopCont) {}

////////////////////////////////////////////////////////////////////////////////
// User pointer parameters
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, Read_PrivatePointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Read_WorkgroupPointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Read_UniformPointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Read_StoragePointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Read_FunctionPointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Read_PrivatePointerParameter_IndexWithLet) {}

TEST_P(RobustnessTest, Read_WorkgroupPointerParameter_IndexWithLet) {}

TEST_P(RobustnessTest, Read_UniformPointerParameter_IndexWithLet) {}

TEST_P(RobustnessTest, Read_StoragePointerParameter_IndexWithLet) {}

TEST_P(RobustnessTest, Read_FunctionPointerParameter_IndexWithLet) {}

TEST_P(RobustnessTest, Write_PrivatePointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Write_WorkgroupPointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Write_StoragePointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Write_FunctionPointerParameter_IndexWithConstant) {}

TEST_P(RobustnessTest, Write_PrivatePointerParameter_IndexWithLet) {}

TEST_P(RobustnessTest, Write_WorkgroupPointerParameter_IndexWithLet) {}

TEST_P(RobustnessTest, Write_StoragePointerParameter_IndexWithLet) {}

TEST_P(RobustnessTest, Write_FunctionPointerParameter_IndexWithLet) {}

////////////////////////////////////////////////////////////////////////////////
// disable_runtime_sized_array_index_clamping == true
////////////////////////////////////////////////////////////////////////////////

TEST_P(RobustnessTest, Read_disable_unsized_array_index_clamping_i32) {}

TEST_P(RobustnessTest, Read_disable_unsized_array_index_clamping_u32) {}

TEST_P(RobustnessTest, Read_disable_unsized_array_index_clamping_abstract_int) {}

TEST_P(RobustnessTest, Read_disable_unsized_array_index_clamping_abstract_int_ViaPointerIndex) {}

TEST_P(RobustnessTest, Assign_disable_unsized_array_index_clamping_i32) {}

TEST_P(RobustnessTest, Assign_disable_unsized_array_index_clamping_u32) {}

TEST_P(RobustnessTest, Assign_disable_unsized_array_index_clamping_abstract_int) {}

TEST_P(RobustnessTest, Assign_disable_unsized_array_index_clamping_abstract_int_ViaPointerIndex) {}

INSTANTIATE_TEST_SUITE_P();
}  // namespace
}  // namespace tint::ast::transform