#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;
usingnamespacetint::core::number_suffixes;
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) { … }
}
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) { … }
struct ClampPartialConstCase { … };
ClampPartialConst;
TEST_P(ClampPartialConst, Scalar) { … }
TEST_P(ClampPartialConst, Vector) { … }
TEST_P(ClampPartialConst, VectorMixedRuntimeConstNotChecked) { … }
std::vector<ClampPartialConstCase> clampCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
struct SmoothstepPartialConstCase { … };
SmoothstepPartialConst;
TEST_P(SmoothstepPartialConst, Scalar) { … }
TEST_P(SmoothstepPartialConst, Vector) { … }
TEST_P(SmoothstepPartialConst, VectorMixedRuntimeConstNotChecked) { … }
std::vector<SmoothstepPartialConstCase> smoothstepCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
struct InsertBitsPartialConstCase { … };
InsertBitsPartialConst;
TEST_P(InsertBitsPartialConst, Scalar) { … }
TEST_P(InsertBitsPartialConst, Vector) { … }
std::vector<InsertBitsPartialConstCase> insertBitsCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
struct ExtractBitsPartialConstCase { … };
ExtractBitsPartialConst;
TEST_P(ExtractBitsPartialConst, Scalar) { … }
TEST_P(ExtractBitsPartialConst, Vector) { … }
std::vector<ExtractBitsPartialConstCase> extractBitsCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
struct LdexpPartialConstCase { … };
LdexpPartialConst;
TEST_P(LdexpPartialConst, Scalar) { … }
TEST_P(LdexpPartialConst, Vector) { … }
std::vector<LdexpPartialConstCase> ldexpCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}