[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 <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
James Price 2023-05-11 13:03:38 +00:00 committed by Dawn LUCI CQ
parent fd60f17236
commit f7a4d9fe59
8 changed files with 47 additions and 50 deletions

View File

@ -22,7 +22,7 @@
using namespace tint::number_suffixes; // NOLINT using namespace tint::number_suffixes; // NOLINT
namespace tint::ast::builtin::test { namespace tint::ast::test {
namespace { namespace {
utils::StringStream& operator<<(utils::StringStream& out, const TextureKind& kind) { 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 { Type TextureOverloadCase::BuildResultVectorComponentType(ProgramBuilder* b) const {
switch (texture_data_type) { switch (texture_data_type) {
case builtin::test::TextureDataType::kF32: case test::TextureDataType::kF32:
return b->ty.f32(); return b->ty.f32();
case builtin::test::TextureDataType::kU32: case test::TextureDataType::kU32:
return b->ty.u32(); return b->ty.u32();
case builtin::test::TextureDataType::kI32: case test::TextureDataType::kI32:
return b->ty.i32(); return b->ty.i32();
} }
@ -160,25 +160,25 @@ const Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) con
b->Binding(0_a), b->Binding(0_a),
}; };
switch (texture_kind) { switch (texture_kind) {
case builtin::test::TextureKind::kRegular: case test::TextureKind::kRegular:
return b->GlobalVar( return b->GlobalVar(
kTextureName, kTextureName,
b->ty.sampled_texture(texture_dimension, BuildResultVectorComponentType(b)), attrs); 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); 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), return b->GlobalVar(kTextureName, b->ty.depth_multisampled_texture(texture_dimension),
attrs); attrs);
case builtin::test::TextureKind::kMultisampled: case test::TextureKind::kMultisampled:
return b->GlobalVar( return b->GlobalVar(
kTextureName, kTextureName,
b->ty.multisampled_texture(texture_dimension, BuildResultVectorComponentType(b)), b->ty.multisampled_texture(texture_dimension, BuildResultVectorComponentType(b)),
attrs); attrs);
case builtin::test::TextureKind::kStorage: { case test::TextureKind::kStorage: {
auto st = b->ty.storage_texture(texture_dimension, texel_format, access); auto st = b->ty.storage_texture(texture_dimension, texel_format, access);
return b->GlobalVar(kTextureName, st, attrs); return b->GlobalVar(kTextureName, st, attrs);
} }
@ -2554,4 +2554,4 @@ bool ReturnsVoid(ValidTextureOverload texture_overload) {
} }
} }
} // namespace tint::ast::builtin::test } // namespace tint::ast::test

View File

@ -23,7 +23,7 @@
#include "src/tint/type/storage_texture.h" #include "src/tint/type/storage_texture.h"
#include "src/tint/type/texture_dimension.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. /// The name of the texture global variable used by the tests.
static constexpr const char* kTextureName = "Texture"; static constexpr const char* kTextureName = "Texture";
@ -268,6 +268,6 @@ struct TextureOverloadCase {
std::ostream& operator<<(std::ostream& out, const TextureOverloadCase& data); 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_ #endif // SRC_TINT_AST_BUILTIN_TEXTURE_HELPER_TEST_H_

View File

@ -2182,11 +2182,11 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest,
TextureTestParams{type::TextureDimension::k2dArray}, TextureTestParams{type::TextureDimension::k2dArray},
TextureTestParams{type::TextureDimension::k3d})); TextureTestParams{type::TextureDimension::k3d}));
using ResolverBuiltinTest_Texture = ResolverTestWithParam<ast::builtin::test::TextureOverloadCase>; using ResolverBuiltinTest_Texture = ResolverTestWithParam<ast::test::TextureOverloadCase>;
INSTANTIATE_TEST_SUITE_P(ResolverTest, INSTANTIATE_TEST_SUITE_P(ResolverTest,
ResolverBuiltinTest_Texture, ResolverBuiltinTest_Texture,
testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases()));
static std::string to_str(const std::string& function, static std::string to_str(const std::string& function,
utils::VectorRef<const sem::Parameter*> params) { utils::VectorRef<const sem::Parameter*> params) {
@ -2204,8 +2204,8 @@ static std::string to_str(const std::string& function,
return out.str(); return out.str();
} }
static const char* expected_texture_overload(ast::builtin::test::ValidTextureOverload overload) { static const char* expected_texture_overload(ast::test::ValidTextureOverload overload) {
using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; using ValidTextureOverload = ast::test::ValidTextureOverload;
switch (overload) { switch (overload) {
case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensions1d:
case ValidTextureOverload::kDimensions2d: case ValidTextureOverload::kDimensions2d:
@ -2491,13 +2491,13 @@ TEST_P(ResolverBuiltinTest_Texture, Call) {
ASSERT_NE(vec, nullptr); ASSERT_NE(vec, nullptr);
EXPECT_EQ(vec->Width(), 4u); EXPECT_EQ(vec->Width(), 4u);
switch (param.texture_data_type) { switch (param.texture_data_type) {
case ast::builtin::test::TextureDataType::kF32: case ast::test::TextureDataType::kF32:
EXPECT_TRUE(vec->type()->Is<type::F32>()); EXPECT_TRUE(vec->type()->Is<type::F32>());
break; break;
case ast::builtin::test::TextureDataType::kU32: case ast::test::TextureDataType::kU32:
EXPECT_TRUE(vec->type()->Is<type::U32>()); EXPECT_TRUE(vec->type()->Is<type::U32>());
break; break;
case ast::builtin::test::TextureDataType::kI32: case ast::test::TextureDataType::kI32:
EXPECT_TRUE(vec->type()->Is<type::I32>()); EXPECT_TRUE(vec->type()->Is<type::I32>());
break; break;
} }
@ -2508,26 +2508,26 @@ TEST_P(ResolverBuiltinTest_Texture, Call) {
EXPECT_TRUE(vec->type()->Is<type::F32>()); EXPECT_TRUE(vec->type()->Is<type::F32>());
} else { } else {
switch (param.texture_kind) { switch (param.texture_kind) {
case ast::builtin::test::TextureKind::kRegular: case ast::test::TextureKind::kRegular:
case ast::builtin::test::TextureKind::kMultisampled: case ast::test::TextureKind::kMultisampled:
case ast::builtin::test::TextureKind::kStorage: { case ast::test::TextureKind::kStorage: {
auto* vec = TypeOf(call)->As<type::Vector>(); auto* vec = TypeOf(call)->As<type::Vector>();
ASSERT_NE(vec, nullptr); ASSERT_NE(vec, nullptr);
switch (param.texture_data_type) { switch (param.texture_data_type) {
case ast::builtin::test::TextureDataType::kF32: case ast::test::TextureDataType::kF32:
EXPECT_TRUE(vec->type()->Is<type::F32>()); EXPECT_TRUE(vec->type()->Is<type::F32>());
break; break;
case ast::builtin::test::TextureDataType::kU32: case ast::test::TextureDataType::kU32:
EXPECT_TRUE(vec->type()->Is<type::U32>()); EXPECT_TRUE(vec->type()->Is<type::U32>());
break; break;
case ast::builtin::test::TextureDataType::kI32: case ast::test::TextureDataType::kI32:
EXPECT_TRUE(vec->type()->Is<type::I32>()); EXPECT_TRUE(vec->type()->Is<type::I32>());
break; break;
} }
break; break;
} }
case ast::builtin::test::TextureKind::kDepth: case ast::test::TextureKind::kDepth:
case ast::builtin::test::TextureKind::kDepthMultisampled: { case ast::test::TextureKind::kDepthMultisampled: {
EXPECT_TRUE(TypeOf(call)->Is<type::F32>()); EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
break; break;
} }

View File

@ -196,10 +196,10 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsStructUsedAsType) {
namespace texture_constexpr_args { namespace texture_constexpr_args {
using TextureOverloadCase = ast::builtin::test::TextureOverloadCase; using TextureOverloadCase = ast::test::TextureOverloadCase;
using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; using ValidTextureOverload = ast::test::ValidTextureOverload;
using TextureKind = ast::builtin::test::TextureKind; using TextureKind = ast::test::TextureKind;
using TextureDataType = ast::builtin::test::TextureDataType; using TextureDataType = ast::test::TextureDataType;
static std::vector<TextureOverloadCase> TextureCases( static std::vector<TextureOverloadCase> TextureCases(
std::unordered_set<ValidTextureOverload> overloads) { std::unordered_set<ValidTextureOverload> overloads) {

View File

@ -30,8 +30,8 @@ struct ExpectedResult {
std::string out; std::string out;
}; };
ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverload overload) { ExpectedResult expected_texture_overload(ast::test::ValidTextureOverload overload) {
using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; using ValidTextureOverload = ast::test::ValidTextureOverload;
switch (overload) { switch (overload) {
case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensions1d:
case ValidTextureOverload::kDimensions2d: case ValidTextureOverload::kDimensions2d:
@ -271,8 +271,7 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa
return "<unmatched texture overload>"; return "<unmatched texture overload>";
} // NOLINT - Ignore the length of this function } // NOLINT - Ignore the length of this function
class GlslGeneratorBuiltinTextureTest class GlslGeneratorBuiltinTextureTest : public TestParamHelper<ast::test::TextureOverloadCase> {};
: public TestParamHelper<ast::builtin::test::TextureOverloadCase> {};
TEST_P(GlslGeneratorBuiltinTextureTest, Call) { TEST_P(GlslGeneratorBuiltinTextureTest, Call) {
auto param = GetParam(); auto param = GetParam();
@ -300,7 +299,7 @@ TEST_P(GlslGeneratorBuiltinTextureTest, Call) {
INSTANTIATE_TEST_SUITE_P(GlslGeneratorBuiltinTextureTest, INSTANTIATE_TEST_SUITE_P(GlslGeneratorBuiltinTextureTest,
GlslGeneratorBuiltinTextureTest, GlslGeneratorBuiltinTextureTest,
testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases()));
} // namespace } // namespace
} // namespace tint::writer::glsl } // namespace tint::writer::glsl

View File

@ -31,8 +31,8 @@ struct ExpectedResult {
std::string out; std::string out;
}; };
ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverload overload) { ExpectedResult expected_texture_overload(ast::test::ValidTextureOverload overload) {
using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; using ValidTextureOverload = ast::test::ValidTextureOverload;
switch (overload) { switch (overload) {
case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensions1d:
case ValidTextureOverload::kDimensionsStorageWO1d: case ValidTextureOverload::kDimensionsStorageWO1d:
@ -363,8 +363,7 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa
return "<unmatched texture overload>"; return "<unmatched texture overload>";
} // NOLINT - Ignore the length of this function } // NOLINT - Ignore the length of this function
class HlslGeneratorBuiltinTextureTest class HlslGeneratorBuiltinTextureTest : public TestParamHelper<ast::test::TextureOverloadCase> {};
: public TestParamHelper<ast::builtin::test::TextureOverloadCase> {};
TEST_P(HlslGeneratorBuiltinTextureTest, Call) { TEST_P(HlslGeneratorBuiltinTextureTest, Call) {
auto param = GetParam(); auto param = GetParam();
@ -391,7 +390,7 @@ TEST_P(HlslGeneratorBuiltinTextureTest, Call) {
INSTANTIATE_TEST_SUITE_P(HlslGeneratorBuiltinTextureTest, INSTANTIATE_TEST_SUITE_P(HlslGeneratorBuiltinTextureTest,
HlslGeneratorBuiltinTextureTest, HlslGeneratorBuiltinTextureTest,
testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases()));
} // namespace } // namespace
} // namespace tint::writer::hlsl } // namespace tint::writer::hlsl

View File

@ -20,8 +20,8 @@
namespace tint::writer::msl { namespace tint::writer::msl {
namespace { namespace {
std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload overload) { std::string expected_texture_overload(ast::test::ValidTextureOverload overload) {
using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; using ValidTextureOverload = ast::test::ValidTextureOverload;
switch (overload) { switch (overload) {
case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensions1d:
case ValidTextureOverload::kDimensionsStorageWO1d: case ValidTextureOverload::kDimensionsStorageWO1d:
@ -268,8 +268,7 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o
return "<unmatched texture overload>"; return "<unmatched texture overload>";
} // NOLINT - Ignore the length of this function } // NOLINT - Ignore the length of this function
class MslGeneratorBuiltinTextureTest class MslGeneratorBuiltinTextureTest : public TestParamHelper<ast::test::TextureOverloadCase> {};
: public TestParamHelper<ast::builtin::test::TextureOverloadCase> {};
TEST_P(MslGeneratorBuiltinTextureTest, Call) { TEST_P(MslGeneratorBuiltinTextureTest, Call) {
auto param = GetParam(); auto param = GetParam();
@ -295,7 +294,7 @@ TEST_P(MslGeneratorBuiltinTextureTest, Call) {
INSTANTIATE_TEST_SUITE_P(MslGeneratorBuiltinTextureTest, INSTANTIATE_TEST_SUITE_P(MslGeneratorBuiltinTextureTest,
MslGeneratorBuiltinTextureTest, MslGeneratorBuiltinTextureTest,
testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases()));
} // namespace } // namespace
} // namespace tint::writer::msl } // namespace tint::writer::msl

View File

@ -29,8 +29,8 @@ struct expected_texture_overload_spirv {
}; };
expected_texture_overload_spirv expected_texture_overload( expected_texture_overload_spirv expected_texture_overload(
ast::builtin::test::ValidTextureOverload overload) { ast::test::ValidTextureOverload overload) {
using ValidTextureOverload = ast::builtin::test::ValidTextureOverload; using ValidTextureOverload = ast::test::ValidTextureOverload;
switch (overload) { switch (overload) {
case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensions1d:
return { return {
@ -3704,11 +3704,11 @@ OpImageWrite %10 %16 %22
"<unmatched texture overload>"}; "<unmatched texture overload>"};
} // NOLINT - Ignore the length of this function } // NOLINT - Ignore the length of this function
using BuiltinTextureTest = TestParamHelper<ast::builtin::test::TextureOverloadCase>; using BuiltinTextureTest = TestParamHelper<ast::test::TextureOverloadCase>;
INSTANTIATE_TEST_SUITE_P(BuiltinTextureTest, INSTANTIATE_TEST_SUITE_P(BuiltinTextureTest,
BuiltinTextureTest, BuiltinTextureTest,
testing::ValuesIn(ast::builtin::test::TextureOverloadCase::ValidCases())); testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases()));
TEST_P(BuiltinTextureTest, Call) { TEST_P(BuiltinTextureTest, Call) {
auto param = GetParam(); auto param = GetParam();