From f7a4d9fe5987c68f5d611038b2ddbaa75646c83d Mon Sep 17 00:00:00 2001 From: James Price Date: Thu, 11 May 2023 13:03:38 +0000 Subject: [PATCH] [tint] Change ast::builtin::test to ast::test There is no `builtin` subdirectory of `ast`, and this additional `builtin` namespaces causes awkward conflicts in a subsequent patch that moves AST transforms under the `ast` namespace. Change-Id: I54b11f37b686875f1dab7deb9781e978a639d6e9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132422 Reviewed-by: Ben Clayton Commit-Queue: James Price Kokoro: Kokoro --- src/tint/ast/builtin_texture_helper_test.cc | 20 ++++++------- src/tint/ast/builtin_texture_helper_test.h | 4 +-- src/tint/resolver/builtin_test.cc | 30 +++++++++---------- src/tint/resolver/builtin_validation_test.cc | 8 ++--- .../generator_impl_builtin_texture_test.cc | 9 +++--- .../generator_impl_builtin_texture_test.cc | 9 +++--- .../generator_impl_builtin_texture_test.cc | 9 +++--- .../spirv/builder_builtin_texture_test.cc | 8 ++--- 8 files changed, 47 insertions(+), 50 deletions(-) diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc index 658b650e01..3231081a39 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc @@ -22,7 +22,7 @@ using namespace tint::number_suffixes; // NOLINT -namespace tint::ast::builtin::test { +namespace tint::ast::test { namespace { utils::StringStream& operator<<(utils::StringStream& out, const TextureKind& kind) { @@ -142,11 +142,11 @@ std::ostream& operator<<(std::ostream& out, const TextureOverloadCase& data) { Type TextureOverloadCase::BuildResultVectorComponentType(ProgramBuilder* b) const { switch (texture_data_type) { - case builtin::test::TextureDataType::kF32: + case test::TextureDataType::kF32: return b->ty.f32(); - case builtin::test::TextureDataType::kU32: + case test::TextureDataType::kU32: return b->ty.u32(); - case builtin::test::TextureDataType::kI32: + case test::TextureDataType::kI32: return b->ty.i32(); } @@ -160,25 +160,25 @@ const Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) con b->Binding(0_a), }; switch (texture_kind) { - case builtin::test::TextureKind::kRegular: + case test::TextureKind::kRegular: return b->GlobalVar( kTextureName, b->ty.sampled_texture(texture_dimension, BuildResultVectorComponentType(b)), attrs); - case builtin::test::TextureKind::kDepth: + case test::TextureKind::kDepth: return b->GlobalVar(kTextureName, b->ty.depth_texture(texture_dimension), attrs); - case builtin::test::TextureKind::kDepthMultisampled: + case test::TextureKind::kDepthMultisampled: return b->GlobalVar(kTextureName, b->ty.depth_multisampled_texture(texture_dimension), attrs); - case builtin::test::TextureKind::kMultisampled: + case test::TextureKind::kMultisampled: return b->GlobalVar( kTextureName, b->ty.multisampled_texture(texture_dimension, BuildResultVectorComponentType(b)), attrs); - case builtin::test::TextureKind::kStorage: { + case test::TextureKind::kStorage: { auto st = b->ty.storage_texture(texture_dimension, texel_format, access); return b->GlobalVar(kTextureName, st, attrs); } @@ -2554,4 +2554,4 @@ bool ReturnsVoid(ValidTextureOverload texture_overload) { } } -} // namespace tint::ast::builtin::test +} // namespace tint::ast::test diff --git a/src/tint/ast/builtin_texture_helper_test.h b/src/tint/ast/builtin_texture_helper_test.h index 2f941bb09c..2a448a516c 100644 --- a/src/tint/ast/builtin_texture_helper_test.h +++ b/src/tint/ast/builtin_texture_helper_test.h @@ -23,7 +23,7 @@ #include "src/tint/type/storage_texture.h" #include "src/tint/type/texture_dimension.h" -namespace tint::ast::builtin::test { +namespace tint::ast::test { /// The name of the texture global variable used by the tests. static constexpr const char* kTextureName = "Texture"; @@ -268,6 +268,6 @@ struct TextureOverloadCase { std::ostream& operator<<(std::ostream& out, const TextureOverloadCase& data); -} // namespace tint::ast::builtin::test +} // namespace tint::ast::test #endif // SRC_TINT_AST_BUILTIN_TEXTURE_HELPER_TEST_H_ diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 60c01f77b0..5a233548db 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -2182,11 +2182,11 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest, TextureTestParams{type::TextureDimension::k2dArray}, TextureTestParams{type::TextureDimension::k3d})); -using ResolverBuiltinTest_Texture = ResolverTestWithParam; +using ResolverBuiltinTest_Texture = ResolverTestWithParam; INSTANTIATE_TEST_SUITE_P(ResolverTest, ResolverBuiltinTest_Texture, - testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); + testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases())); static std::string to_str(const std::string& function, utils::VectorRef params) { @@ -2204,8 +2204,8 @@ static std::string to_str(const std::string& function, return out.str(); } -static const char* expected_texture_overload(ast::builtin::test::ValidTextureOverload overload) { - using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; +static const char* expected_texture_overload(ast::test::ValidTextureOverload overload) { + using ValidTextureOverload = ast::test::ValidTextureOverload; switch (overload) { case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensions2d: @@ -2491,13 +2491,13 @@ TEST_P(ResolverBuiltinTest_Texture, Call) { ASSERT_NE(vec, nullptr); EXPECT_EQ(vec->Width(), 4u); switch (param.texture_data_type) { - case ast::builtin::test::TextureDataType::kF32: + case ast::test::TextureDataType::kF32: EXPECT_TRUE(vec->type()->Is()); break; - case ast::builtin::test::TextureDataType::kU32: + case ast::test::TextureDataType::kU32: EXPECT_TRUE(vec->type()->Is()); break; - case ast::builtin::test::TextureDataType::kI32: + case ast::test::TextureDataType::kI32: EXPECT_TRUE(vec->type()->Is()); break; } @@ -2508,26 +2508,26 @@ TEST_P(ResolverBuiltinTest_Texture, Call) { EXPECT_TRUE(vec->type()->Is()); } else { switch (param.texture_kind) { - case ast::builtin::test::TextureKind::kRegular: - case ast::builtin::test::TextureKind::kMultisampled: - case ast::builtin::test::TextureKind::kStorage: { + case ast::test::TextureKind::kRegular: + case ast::test::TextureKind::kMultisampled: + case ast::test::TextureKind::kStorage: { auto* vec = TypeOf(call)->As(); ASSERT_NE(vec, nullptr); switch (param.texture_data_type) { - case ast::builtin::test::TextureDataType::kF32: + case ast::test::TextureDataType::kF32: EXPECT_TRUE(vec->type()->Is()); break; - case ast::builtin::test::TextureDataType::kU32: + case ast::test::TextureDataType::kU32: EXPECT_TRUE(vec->type()->Is()); break; - case ast::builtin::test::TextureDataType::kI32: + case ast::test::TextureDataType::kI32: EXPECT_TRUE(vec->type()->Is()); break; } break; } - case ast::builtin::test::TextureKind::kDepth: - case ast::builtin::test::TextureKind::kDepthMultisampled: { + case ast::test::TextureKind::kDepth: + case ast::test::TextureKind::kDepthMultisampled: { EXPECT_TRUE(TypeOf(call)->Is()); break; } diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc index d0747032ab..fbe5a5f7bf 100644 --- a/src/tint/resolver/builtin_validation_test.cc +++ b/src/tint/resolver/builtin_validation_test.cc @@ -196,10 +196,10 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsStructUsedAsType) { namespace texture_constexpr_args { -using TextureOverloadCase = ast::builtin::test::TextureOverloadCase; -using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; -using TextureKind = ast::builtin::test::TextureKind; -using TextureDataType = ast::builtin::test::TextureDataType; +using TextureOverloadCase = ast::test::TextureOverloadCase; +using ValidTextureOverload = ast::test::ValidTextureOverload; +using TextureKind = ast::test::TextureKind; +using TextureDataType = ast::test::TextureDataType; static std::vector TextureCases( std::unordered_set overloads) { diff --git a/src/tint/writer/glsl/generator_impl_builtin_texture_test.cc b/src/tint/writer/glsl/generator_impl_builtin_texture_test.cc index ca8abe4143..fbfb8ec3ab 100644 --- a/src/tint/writer/glsl/generator_impl_builtin_texture_test.cc +++ b/src/tint/writer/glsl/generator_impl_builtin_texture_test.cc @@ -30,8 +30,8 @@ struct ExpectedResult { std::string out; }; -ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverload overload) { - using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; +ExpectedResult expected_texture_overload(ast::test::ValidTextureOverload overload) { + using ValidTextureOverload = ast::test::ValidTextureOverload; switch (overload) { case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensions2d: @@ -271,8 +271,7 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa return ""; } // NOLINT - Ignore the length of this function -class GlslGeneratorBuiltinTextureTest - : public TestParamHelper {}; +class GlslGeneratorBuiltinTextureTest : public TestParamHelper {}; TEST_P(GlslGeneratorBuiltinTextureTest, Call) { auto param = GetParam(); @@ -300,7 +299,7 @@ TEST_P(GlslGeneratorBuiltinTextureTest, Call) { INSTANTIATE_TEST_SUITE_P(GlslGeneratorBuiltinTextureTest, GlslGeneratorBuiltinTextureTest, - testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); + testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases())); } // namespace } // namespace tint::writer::glsl diff --git a/src/tint/writer/hlsl/generator_impl_builtin_texture_test.cc b/src/tint/writer/hlsl/generator_impl_builtin_texture_test.cc index 174c66c99d..8ddcc1c6a6 100644 --- a/src/tint/writer/hlsl/generator_impl_builtin_texture_test.cc +++ b/src/tint/writer/hlsl/generator_impl_builtin_texture_test.cc @@ -31,8 +31,8 @@ struct ExpectedResult { std::string out; }; -ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverload overload) { - using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; +ExpectedResult expected_texture_overload(ast::test::ValidTextureOverload overload) { + using ValidTextureOverload = ast::test::ValidTextureOverload; switch (overload) { case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensionsStorageWO1d: @@ -363,8 +363,7 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa return ""; } // NOLINT - Ignore the length of this function -class HlslGeneratorBuiltinTextureTest - : public TestParamHelper {}; +class HlslGeneratorBuiltinTextureTest : public TestParamHelper {}; TEST_P(HlslGeneratorBuiltinTextureTest, Call) { auto param = GetParam(); @@ -391,7 +390,7 @@ TEST_P(HlslGeneratorBuiltinTextureTest, Call) { INSTANTIATE_TEST_SUITE_P(HlslGeneratorBuiltinTextureTest, HlslGeneratorBuiltinTextureTest, - testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); + testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases())); } // namespace } // namespace tint::writer::hlsl diff --git a/src/tint/writer/msl/generator_impl_builtin_texture_test.cc b/src/tint/writer/msl/generator_impl_builtin_texture_test.cc index f6b9635874..54f01135db 100644 --- a/src/tint/writer/msl/generator_impl_builtin_texture_test.cc +++ b/src/tint/writer/msl/generator_impl_builtin_texture_test.cc @@ -20,8 +20,8 @@ namespace tint::writer::msl { namespace { -std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload overload) { - using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; +std::string expected_texture_overload(ast::test::ValidTextureOverload overload) { + using ValidTextureOverload = ast::test::ValidTextureOverload; switch (overload) { case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensionsStorageWO1d: @@ -268,8 +268,7 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o return ""; } // NOLINT - Ignore the length of this function -class MslGeneratorBuiltinTextureTest - : public TestParamHelper {}; +class MslGeneratorBuiltinTextureTest : public TestParamHelper {}; TEST_P(MslGeneratorBuiltinTextureTest, Call) { auto param = GetParam(); @@ -295,7 +294,7 @@ TEST_P(MslGeneratorBuiltinTextureTest, Call) { INSTANTIATE_TEST_SUITE_P(MslGeneratorBuiltinTextureTest, MslGeneratorBuiltinTextureTest, - testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); + testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases())); } // namespace } // namespace tint::writer::msl diff --git a/src/tint/writer/spirv/builder_builtin_texture_test.cc b/src/tint/writer/spirv/builder_builtin_texture_test.cc index cd17ec1a6c..9d4551935a 100644 --- a/src/tint/writer/spirv/builder_builtin_texture_test.cc +++ b/src/tint/writer/spirv/builder_builtin_texture_test.cc @@ -29,8 +29,8 @@ struct expected_texture_overload_spirv { }; expected_texture_overload_spirv expected_texture_overload( - ast::builtin::test::ValidTextureOverload overload) { - using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; + ast::test::ValidTextureOverload overload) { + using ValidTextureOverload = ast::test::ValidTextureOverload; switch (overload) { case ValidTextureOverload::kDimensions1d: return { @@ -3704,11 +3704,11 @@ OpImageWrite %10 %16 %22 ""}; } // NOLINT - Ignore the length of this function -using BuiltinTextureTest = TestParamHelper; +using BuiltinTextureTest = TestParamHelper; INSTANTIATE_TEST_SUITE_P(BuiltinTextureTest, BuiltinTextureTest, - testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); + testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases())); TEST_P(BuiltinTextureTest, Call) { auto param = GetParam();