diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 7099a463f0..76bdd766a6 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -430,11 +430,8 @@ libtint_source_set("libtint_core_all_src") { "sem/call.h", "sem/call_target.h", "sem/constant.h", - "sem/depth_multisampled_texture.h", - "sem/depth_texture.h", "sem/evaluation_stage.h", "sem/expression.h", - "sem/external_texture.h", "sem/f16.h", "sem/f32.h", "sem/for_loop_statement.h", @@ -446,18 +443,15 @@ libtint_source_set("libtint_core_all_src") { "sem/materialize.h", "sem/matrix.h", "sem/module.h", - "sem/multisampled_texture.h", "sem/node.h", "sem/parameter_usage.h", "sem/pipeline_stage_set.h", "sem/pointer.h", "sem/reference.h", - "sem/sampled_texture.h", "sem/sampler.h", "sem/sampler_texture_pair.h", - "sem/storage_texture.h", + "sem/struct.h", "sem/switch_statement.h", - "sem/texture.h", "sem/type_conversion.h", "sem/type_initializer.h", "sem/type_mappings.h", @@ -576,7 +570,14 @@ libtint_source_set("libtint_core_all_src") { "transform/zero_init_workgroup_memory.cc", "transform/zero_init_workgroup_memory.h", "type/array_count.h", + "type/depth_multisampled_texture.h", + "type/depth_texture.h", + "type/external_texture.h", + "type/multisampled_texture.h", "type/node.h", + "type/sampled_texture.h", + "type/storage_texture.h", + "type/texture.h", "type/type.h", "type/type_manager.h", "utils/bitcast.h", @@ -662,15 +663,9 @@ libtint_source_set("libtint_sem_src") { "sem/call_target.h", "sem/constant.cc", "sem/constant.h", - "sem/depth_multisampled_texture.cc", - "sem/depth_multisampled_texture.h", - "sem/depth_texture.cc", - "sem/depth_texture.h", "sem/evaluation_stage.h", "sem/expression.cc", "sem/expression.h", - "sem/external_texture.cc", - "sem/external_texture.h", "sem/f16.cc", "sem/f16.h", "sem/f32.cc", @@ -695,8 +690,6 @@ libtint_source_set("libtint_sem_src") { "sem/member_accessor_expression.cc", "sem/module.cc", "sem/module.h", - "sem/multisampled_texture.cc", - "sem/multisampled_texture.h", "sem/node.cc", "sem/node.h", "sem/parameter_usage.cc", @@ -706,18 +699,13 @@ libtint_source_set("libtint_sem_src") { "sem/pointer.h", "sem/reference.cc", "sem/reference.h", - "sem/sampled_texture.cc", - "sem/sampled_texture.h", "sem/sampler.cc", "sem/sampler.h", "sem/statement.cc", - "sem/storage_texture.cc", - "sem/storage_texture.h", "sem/struct.cc", + "sem/struct.h", "sem/switch_statement.cc", "sem/switch_statement.h", - "sem/texture.cc", - "sem/texture.h", "sem/type_conversion.cc", "sem/type_conversion.h", "sem/type_initializer.cc", @@ -741,8 +729,22 @@ libtint_source_set("libtint_type_src") { sources = [ "type/array_count.cc", "type/array_count.h", + "type/depth_multisampled_texture.cc", + "type/depth_multisampled_texture.h", + "type/depth_texture.cc", + "type/depth_texture.h", + "type/external_texture.cc", + "type/external_texture.h", + "type/multisampled_texture.cc", + "type/multisampled_texture.h", "type/node.cc", "type/node.h", + "type/sampled_texture.cc", + "type/sampled_texture.h", + "type/storage_texture.cc", + "type/storage_texture.h", + "type/texture.cc", + "type/texture.h", "type/type.cc", "type/type.h", "type/type_manager.cc", @@ -1063,8 +1065,6 @@ if (tint_build_unittests) { "ast/case_statement_test.cc", "ast/compound_assignment_statement_test.cc", "ast/continue_statement_test.cc", - "ast/depth_multisampled_texture_test.cc", - "ast/depth_texture_test.cc", "ast/discard_statement_test.cc", "ast/enable_test.cc", "ast/extension_test.cc", @@ -1206,22 +1206,15 @@ if (tint_build_unittests) { "sem/atomic_test.cc", "sem/bool_test.cc", "sem/builtin_test.cc", - "sem/depth_multisampled_texture_test.cc", - "sem/depth_texture_test.cc", "sem/expression_test.cc", - "sem/external_texture_test.cc", "sem/f16_test.cc", "sem/f32_test.cc", "sem/i32_test.cc", "sem/matrix_test.cc", - "sem/multisampled_texture_test.cc", "sem/pointer_test.cc", "sem/reference_test.cc", - "sem/sampled_texture_test.cc", "sem/sampler_test.cc", - "sem/storage_texture_test.cc", "sem/struct_test.cc", - "sem/texture_test.cc", "sem/u32_test.cc", "sem/vector_test.cc", ] @@ -1229,6 +1222,13 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_type_src") { sources = [ + "type/depth_multisampled_texture_test.cc", + "type/depth_texture_test.cc", + "type/external_texture_test.cc", + "type/multisampled_texture_test.cc", + "type/sampled_texture_test.cc", + "type/storage_texture_test.cc", + "type/texture_test.cc", "type/type_manager_test.cc", "type/type_test.cc", ] diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 4d69e28ab7..b7d9988897 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -320,15 +320,9 @@ list(APPEND TINT_LIB_SRCS sem/call.h sem/constant.cc sem/constant.h - sem/depth_multisampled_texture.cc - sem/depth_multisampled_texture.h - sem/depth_texture.cc - sem/depth_texture.h sem/evaluation_stage.h sem/expression.cc sem/expression.h - sem/external_texture.cc - sem/external_texture.h sem/f16.cc sem/f16.h sem/f32.cc @@ -353,8 +347,6 @@ list(APPEND TINT_LIB_SRCS sem/member_accessor_expression.cc sem/module.cc sem/module.h - sem/multisampled_texture.cc - sem/multisampled_texture.h sem/node.cc sem/node.h sem/pipeline_stage_set.h @@ -362,19 +354,13 @@ list(APPEND TINT_LIB_SRCS sem/pointer.h sem/reference.cc sem/reference.h - sem/sampled_texture.cc - sem/sampled_texture.h sem/sampler_texture_pair.h sem/sampler.cc sem/sampler.h sem/statement.cc - sem/storage_texture.cc - sem/storage_texture.h sem/struct.cc sem/switch_statement.cc sem/switch_statement.h - sem/texture.cc - sem/texture.h sem/type_initializer.cc sem/type_initializer.h sem/type_conversion.cc @@ -499,8 +485,22 @@ list(APPEND TINT_LIB_SRCS transform/zero_init_workgroup_memory.h type/array_count.cc type/array_count.h + type/depth_multisampled_texture.cc + type/depth_multisampled_texture.h + type/depth_texture.cc + type/depth_texture.h + type/external_texture.cc + type/external_texture.h + type/multisampled_texture.cc + type/multisampled_texture.h type/node.cc type/node.h + type/sampled_texture.cc + type/sampled_texture.h + type/storage_texture.cc + type/storage_texture.h + type/texture.cc + type/texture.h type/type.cc type/type.h type/type_manager.cc @@ -924,22 +924,15 @@ if(TINT_BUILD_TESTS) sem/atomic.cc sem/bool_test.cc sem/builtin_test.cc - sem/depth_multisampled_texture_test.cc - sem/depth_texture_test.cc sem/expression_test.cc - sem/external_texture_test.cc sem/f16_test.cc sem/f32_test.cc sem/i32_test.cc sem/matrix_test.cc - sem/multisampled_texture_test.cc sem/pointer_test.cc sem/reference_test.cc - sem/sampled_texture_test.cc sem/sampler_test.cc - sem/storage_texture_test.cc sem/struct_test.cc - sem/texture_test.cc sem/u32_test.cc sem/vector_test.cc source_test.cc @@ -949,6 +942,13 @@ if(TINT_BUILD_TESTS) text/unicode_test.cc traits_test.cc transform/transform_test.cc + type/depth_multisampled_texture_test.cc + type/depth_texture_test.cc + type/external_texture_test.cc + type/multisampled_texture_test.cc + type/sampled_texture_test.cc + type/storage_texture_test.cc + type/texture_test.cc type/type_test.cc type/type_manager_test.cc utils/bitcast_test.cc diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc index d2ea48d006..0ea2cedc9b 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc @@ -14,9 +14,9 @@ #include "src/tint/ast/builtin_texture_helper_test.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" using namespace tint::number_suffixes; // NOLINT diff --git a/src/tint/ast/builtin_texture_helper_test.h b/src/tint/ast/builtin_texture_helper_test.h index 2c4515b5c2..744796a010 100644 --- a/src/tint/ast/builtin_texture_helper_test.h +++ b/src/tint/ast/builtin_texture_helper_test.h @@ -19,7 +19,7 @@ #include "src/tint/ast/access.h" #include "src/tint/program_builder.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/storage_texture.h" namespace tint::ast::builtin::test { diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index 303f4b65cf..cbf5c03309 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -31,24 +31,24 @@ #include "src/tint/sem/array.h" #include "src/tint/sem/bool.h" #include "src/tint/sem/call.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" #include "src/tint/sem/f16.h" #include "src/tint/sem/f32.h" #include "src/tint/sem/function.h" #include "src/tint/sem/i32.h" #include "src/tint/sem/matrix.h" #include "src/tint/sem/module.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/statement.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/u32.h" #include "src/tint/sem/variable.h" #include "src/tint/sem/vector.h" #include "src/tint/sem/void.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/utils/math.h" #include "src/tint/utils/string.h" #include "src/tint/utils/unique_vector.h" @@ -513,7 +513,7 @@ std::vector Inspector::GetTextureResourceBindings( entry.bind_group = binding_info.group; entry.binding = binding_info.binding; - auto* tex = var->Type()->UnwrapRef()->As(); + auto* tex = var->Type()->UnwrapRef()->As(); entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(tex->dim()); result.push_back(entry); @@ -524,19 +524,19 @@ std::vector Inspector::GetTextureResourceBindings( std::vector Inspector::GetDepthTextureResourceBindings( const std::string& entry_point) { - return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), + return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), ResourceBinding::ResourceType::kDepthTexture); } std::vector Inspector::GetDepthMultisampledTextureResourceBindings( const std::string& entry_point) { - return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), + return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), ResourceBinding::ResourceType::kDepthMultisampledTexture); } std::vector Inspector::GetExternalTextureResourceBindings( const std::string& entry_point) { - return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), + return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), ResourceBinding::ResourceType::kExternalTexture); } @@ -766,14 +766,14 @@ std::vector Inspector::GetSampledTextureResourceBindingsImpl( entry.bind_group = binding_info.group; entry.binding = binding_info.binding; - auto* texture_type = var->Type()->UnwrapRef()->As(); + auto* texture_type = var->Type()->UnwrapRef()->As(); entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(texture_type->dim()); const type::Type* base_type = nullptr; if (multisampled_only) { - base_type = texture_type->As()->type(); + base_type = texture_type->As()->type(); } else { - base_type = texture_type->As()->type(); + base_type = texture_type->As()->type(); } entry.sampled_kind = BaseTypeToSampledKind(base_type); @@ -792,11 +792,11 @@ std::vector Inspector::GetStorageTextureResourceBindingsImpl( auto* func_sem = program_->Sem().Get(func); std::vector result; - for (auto& ref : func_sem->TransitivelyReferencedVariablesOfType()) { + for (auto& ref : func_sem->TransitivelyReferencedVariablesOfType()) { auto* var = ref.first; auto binding_info = ref.second; - auto* texture_type = var->Type()->UnwrapRef()->As(); + auto* texture_type = var->Type()->UnwrapRef()->As(); ResourceBinding entry; entry.resource_type = ResourceBinding::ResourceType::kWriteOnlyStorageTexture; diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc index 78cfb5afc7..d6c635dc78 100644 --- a/src/tint/inspector/inspector_test.cc +++ b/src/tint/inspector/inspector_test.cc @@ -22,11 +22,11 @@ #include "src/tint/inspector/test_inspector_builder.h" #include "src/tint/inspector/test_inspector_runner.h" #include "src/tint/program_builder.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "tint/tint.h" using namespace tint::number_suffixes; // NOLINT @@ -3227,8 +3227,8 @@ fn main(@location(0) fragUV: vec2, auto result_1 = inspector.GetSamplerTextureUses("main"); ASSERT_FALSE(inspector.has_error()) << inspector.error(); - EXPECT_EQ((utils::Vector(result_0)), - (utils::Vector(result_1))); + EXPECT_EQ((utils::Vector(result_0)), + (utils::Vector(result_1))); } TEST_F(InspectorGetSamplerTextureUsesTest, BothIndirect) { diff --git a/src/tint/inspector/test_inspector_builder.h b/src/tint/inspector/test_inspector_builder.h index fe43c69ea4..8439bd684e 100644 --- a/src/tint/inspector/test_inspector_builder.h +++ b/src/tint/inspector/test_inspector_builder.h @@ -26,11 +26,11 @@ #include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/workgroup_attribute.h" #include "src/tint/program_builder.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "tint/tint.h" namespace tint::inspector { diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index 7f59711660..5f45e2cf47 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -94,20 +94,20 @@ #include "src/tint/sem/array_count.h" #include "src/tint/sem/bool.h" #include "src/tint/sem/constant.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" #include "src/tint/sem/f16.h" #include "src/tint/sem/f32.h" #include "src/tint/sem/i32.h" #include "src/tint/sem/matrix.h" -#include "src/tint/sem/multisampled_texture.h" #include "src/tint/sem/pointer.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/u32.h" #include "src/tint/sem/vector.h" #include "src/tint/sem/void.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #ifdef CURRENTLY_IN_TINT_PUBLIC_HEADER #error "internal tint header being #included from tint.h" diff --git a/src/tint/reader/spirv/enum_converter.h b/src/tint/reader/spirv/enum_converter.h index 0082499700..6b7a88974e 100644 --- a/src/tint/reader/spirv/enum_converter.h +++ b/src/tint/reader/spirv/enum_converter.h @@ -21,7 +21,7 @@ #include "src/tint/ast/builtin_value.h" #include "src/tint/ast/pipeline_stage.h" #include "src/tint/reader/spirv/fail_stream.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/storage_texture.h" namespace tint::reader::spirv { diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index d2edcaf9a4..74d39f9a39 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -33,9 +33,9 @@ #include "src/tint/ast/unary_op_expression.h" #include "src/tint/ast/variable_decl_statement.h" #include "src/tint/sem/builtin_type.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/transform/spirv_atomic.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/utils/hashmap.h" #include "src/tint/utils/hashset.h" diff --git a/src/tint/reader/spirv/parser_impl.cc b/src/tint/reader/spirv/parser_impl.cc index 52bdb12a2e..4fa4b2fbef 100644 --- a/src/tint/reader/spirv/parser_impl.cc +++ b/src/tint/reader/spirv/parser_impl.cc @@ -27,9 +27,9 @@ #include "src/tint/ast/type_name.h" #include "src/tint/ast/unary_op_expression.h" #include "src/tint/reader/spirv/function.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/utils/unique_vector.h" namespace tint::reader::spirv { diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index a04e5484ee..3e03bab6f7 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -39,10 +39,10 @@ #include "src/tint/ast/vector.h" #include "src/tint/ast/workgroup_attribute.h" #include "src/tint/reader/wgsl/lexer.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/utils/reverse.h" #include "src/tint/utils/string.h" diff --git a/src/tint/reader/wgsl/parser_impl.h b/src/tint/reader/wgsl/parser_impl.h index fc91b5cbcd..5f6485395e 100644 --- a/src/tint/reader/wgsl/parser_impl.h +++ b/src/tint/reader/wgsl/parser_impl.h @@ -26,7 +26,7 @@ #include "src/tint/program_builder.h" #include "src/tint/reader/wgsl/parser_impl_detail.h" #include "src/tint/reader/wgsl/token.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/storage_texture.h" namespace tint::ast { class BreakStatement; diff --git a/src/tint/reader/wgsl/parser_impl_depth_texture_test.cc b/src/tint/reader/wgsl/parser_impl_depth_texture_test.cc index 78c4b8dfec..fbd8ffb2ff 100644 --- a/src/tint/reader/wgsl/parser_impl_depth_texture_test.cc +++ b/src/tint/reader/wgsl/parser_impl_depth_texture_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/reader/wgsl/parser_impl_test_helper.h" -#include "src/tint/sem/depth_texture.h" +#include "src/tint/type/depth_texture.h" namespace tint::reader::wgsl { namespace { diff --git a/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc b/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc index a13998ade3..47ea247ed8 100644 --- a/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc +++ b/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "src/tint/reader/wgsl/parser_impl_test_helper.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" namespace tint::reader::wgsl { namespace { diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc index ad8946f57c..c40c2981a4 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc @@ -17,7 +17,7 @@ #include "src/tint/ast/matrix.h" #include "src/tint/ast/sampler.h" #include "src/tint/reader/wgsl/parser_impl_test_helper.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/sampled_texture.h" namespace tint::reader::wgsl { namespace { diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc index e37a347f76..bd96659a6a 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc @@ -17,7 +17,7 @@ #include "src/tint/ast/matrix.h" #include "src/tint/ast/sampler.h" #include "src/tint/reader/wgsl/parser_impl_test_helper.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/sampled_texture.h" namespace tint::reader::wgsl { namespace { diff --git a/src/tint/resolver/assignment_validation_test.cc b/src/tint/resolver/assignment_validation_test.cc index 02a6191b13..ce8b31466a 100644 --- a/src/tint/resolver/assignment_validation_test.cc +++ b/src/tint/resolver/assignment_validation_test.cc @@ -16,7 +16,7 @@ #include "gmock/gmock.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/storage_texture.h" using namespace tint::number_suffixes; // NOLINT diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index c5cd274484..72b428ce09 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -32,9 +32,9 @@ #include "src/tint/sem/call.h" #include "src/tint/sem/function.h" #include "src/tint/sem/member_accessor_expression.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/type/test_helper.h" using ::testing::ElementsAre; diff --git a/src/tint/resolver/compound_assignment_validation_test.cc b/src/tint/resolver/compound_assignment_validation_test.cc index dfb69266fa..941fce22cb 100644 --- a/src/tint/resolver/compound_assignment_validation_test.cc +++ b/src/tint/resolver/compound_assignment_validation_test.cc @@ -16,7 +16,7 @@ #include "gmock/gmock.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/storage_texture.h" using ::testing::HasSubstr; diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index f2fb2ce814..ba46140140 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -24,16 +24,16 @@ #include "src/tint/sem/abstract_int.h" #include "src/tint/sem/abstract_numeric.h" #include "src/tint/sem/atomic.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" #include "src/tint/sem/evaluation_stage.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/multisampled_texture.h" #include "src/tint/sem/pipeline_stage_set.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_initializer.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/utils/hash.h" #include "src/tint/utils/hashmap.h" #include "src/tint/utils/math.h" @@ -611,7 +611,7 @@ bool match_texture(MatchState&, T = ty; return true; } - if (auto* v = ty->As()) { + if (auto* v = ty->As()) { if (v->dim() == dim) { T = v->type(); return true; @@ -622,14 +622,14 @@ bool match_texture(MatchState&, #define JOIN(a, b) a##b -#define DECLARE_SAMPLED_TEXTURE(suffix, dim) \ - bool JOIN(match_texture_, suffix)(MatchState & state, const type::Type* ty, \ - const type::Type*& T) { \ - return match_texture(state, ty, dim, T); \ - } \ - const sem::SampledTexture* JOIN(build_texture_, suffix)(MatchState & state, \ - const type::Type* T) { \ - return state.builder.create(dim, T); \ +#define DECLARE_SAMPLED_TEXTURE(suffix, dim) \ + bool JOIN(match_texture_, suffix)(MatchState & state, const type::Type* ty, \ + const type::Type*& T) { \ + return match_texture(state, ty, dim, T); \ + } \ + const type::SampledTexture* JOIN(build_texture_, suffix)(MatchState & state, \ + const type::Type* T) { \ + return state.builder.create(dim, T); \ } DECLARE_SAMPLED_TEXTURE(1d, ast::TextureDimension::k1d) @@ -648,7 +648,7 @@ bool match_texture_multisampled(MatchState&, T = ty; return true; } - if (auto* v = ty->As()) { + if (auto* v = ty->As()) { if (v->dim() == dim) { T = v->type(); return true; @@ -662,9 +662,9 @@ bool match_texture_multisampled(MatchState&, const type::Type*& T) { \ return match_texture_multisampled(state, ty, dim, T); \ } \ - const sem::MultisampledTexture* JOIN(build_texture_multisampled_, suffix)( \ + const type::MultisampledTexture* JOIN(build_texture_multisampled_, suffix)( \ MatchState & state, const type::Type* T) { \ - return state.builder.create(dim, T); \ + return state.builder.create(dim, T); \ } DECLARE_MULTISAMPLED_TEXTURE(2d, ast::TextureDimension::k2d) @@ -674,15 +674,15 @@ bool match_texture_depth(MatchState&, const type::Type* ty, ast::TextureDimensio if (ty->Is()) { return true; } - return ty->Is([&](const sem::DepthTexture* t) { return t->dim() == dim; }); + return ty->Is([&](const type::DepthTexture* t) { return t->dim() == dim; }); } #define DECLARE_DEPTH_TEXTURE(suffix, dim) \ bool JOIN(match_texture_depth_, suffix)(MatchState & state, const type::Type* ty) { \ return match_texture_depth(state, ty, dim); \ } \ - const sem::DepthTexture* JOIN(build_texture_depth_, suffix)(MatchState & state) { \ - return state.builder.create(dim); \ + const type::DepthTexture* JOIN(build_texture_depth_, suffix)(MatchState & state) { \ + return state.builder.create(dim); \ } DECLARE_DEPTH_TEXTURE(2d, ast::TextureDimension::k2d) @@ -695,13 +695,13 @@ bool match_texture_depth_multisampled_2d(MatchState&, const type::Type* ty) { if (ty->Is()) { return true; } - return ty->Is([&](const sem::DepthMultisampledTexture* t) { + return ty->Is([&](const type::DepthMultisampledTexture* t) { return t->dim() == ast::TextureDimension::k2d; }); } -sem::DepthMultisampledTexture* build_texture_depth_multisampled_2d(MatchState& state) { - return state.builder.create(ast::TextureDimension::k2d); +type::DepthMultisampledTexture* build_texture_depth_multisampled_2d(MatchState& state) { + return state.builder.create(ast::TextureDimension::k2d); } bool match_texture_storage(MatchState&, @@ -714,7 +714,7 @@ bool match_texture_storage(MatchState&, A = Number::any; return true; } - if (auto* v = ty->As()) { + if (auto* v = ty->As()) { if (v->dim() == dim) { F = Number(static_cast(v->texel_format())); A = Number(static_cast(v->access())); @@ -729,12 +729,12 @@ bool match_texture_storage(MatchState&, Number& A) { \ return match_texture_storage(state, ty, dim, F, A); \ } \ - const sem::StorageTexture* JOIN(build_texture_storage_, suffix)(MatchState & state, Number F, \ - Number A) { \ + const type::StorageTexture* JOIN(build_texture_storage_, suffix)(MatchState & state, Number F, \ + Number A) { \ auto format = static_cast(F.Value()); \ auto access = static_cast(A.Value()); \ - auto* T = sem::StorageTexture::SubtypeFor(format, state.builder.Types()); \ - return state.builder.create(dim, format, access, T); \ + auto* T = type::StorageTexture::SubtypeFor(format, state.builder.Types()); \ + return state.builder.create(dim, format, access, T); \ } DECLARE_STORAGE_TEXTURE(1d, ast::TextureDimension::k1d) @@ -744,11 +744,11 @@ DECLARE_STORAGE_TEXTURE(3d, ast::TextureDimension::k3d) #undef DECLARE_STORAGE_TEXTURE bool match_texture_external(MatchState&, const type::Type* ty) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } -const sem::ExternalTexture* build_texture_external(MatchState& state) { - return state.builder.create(); +const type::ExternalTexture* build_texture_external(MatchState& state) { + return state.builder.create(); } // Builtin types starting with a _ prefix cannot be declared in WGSL, so they diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc index d96fcd7606..c3f69adfc5 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -20,15 +20,15 @@ #include "src/tint/program_builder.h" #include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/sem/atomic.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/multisampled_texture.h" #include "src/tint/sem/reference.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_initializer.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/type/test_helper.h" namespace tint::resolver { @@ -97,7 +97,7 @@ TEST_F(IntrinsicTableTest, MatchI32) { auto* f32 = create(); auto* i32 = create(); auto* vec4_f32 = create(f32, 4u); - auto* tex = create(ast::TextureDimension::k1d, f32); + auto* tex = create(ast::TextureDimension::k1d, f32); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, i32, i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -115,7 +115,7 @@ TEST_F(IntrinsicTableTest, MatchI32) { TEST_F(IntrinsicTableTest, MismatchI32) { auto* f32 = create(); - auto* tex = create(ast::TextureDimension::k1d, f32); + auto* tex = create(ast::TextureDimension::k1d, f32); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -279,7 +279,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) { auto* f32 = create(); auto* vec2_f32 = create(f32, 2u); auto* vec4_f32 = create(f32, 4u); - auto* tex = create(ast::TextureDimension::k2d, f32); + auto* tex = create(ast::TextureDimension::k2d, f32); auto* sampler = create(ast::SamplerKind::kSampler); auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, sampler, vec2_f32}, sem::EvaluationStage::kConstant, Source{}); @@ -299,7 +299,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) { TEST_F(IntrinsicTableTest, MismatchSampler) { auto* f32 = create(); auto* vec2_f32 = create(f32, 2u); - auto* tex = create(ast::TextureDimension::k2d, f32); + auto* tex = create(ast::TextureDimension::k2d, f32); auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, f32, vec2_f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -311,7 +311,7 @@ TEST_F(IntrinsicTableTest, MatchSampledTexture) { auto* f32 = create(); auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); - auto* tex = create(ast::TextureDimension::k2d, f32); + auto* tex = create(ast::TextureDimension::k2d, f32); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -332,7 +332,7 @@ TEST_F(IntrinsicTableTest, MatchMultisampledTexture) { auto* f32 = create(); auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); - auto* tex = create(ast::TextureDimension::k2d, f32); + auto* tex = create(ast::TextureDimension::k2d, f32); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -352,7 +352,7 @@ TEST_F(IntrinsicTableTest, MatchDepthTexture) { auto* f32 = create(); auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); - auto* tex = create(ast::TextureDimension::k2d); + auto* tex = create(ast::TextureDimension::k2d); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -372,7 +372,7 @@ TEST_F(IntrinsicTableTest, MatchDepthMultisampledTexture) { auto* f32 = create(); auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); - auto* tex = create(ast::TextureDimension::k2d); + auto* tex = create(ast::TextureDimension::k2d); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -393,7 +393,7 @@ TEST_F(IntrinsicTableTest, MatchExternalTexture) { auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); - auto* tex = create(); + auto* tex = create(); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -412,9 +412,9 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) { auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); - auto* subtype = sem::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types()); - auto* tex = create(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, - ast::Access::kWrite, subtype); + auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types()); + auto* tex = create( + ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite, subtype); auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32}, sem::EvaluationStage::kConstant, Source{}); @@ -628,7 +628,7 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) { } TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) { - auto* tex = create(ast::TextureDimension::k2d); + auto* tex = create(ast::TextureDimension::k2d); auto* bool_ = create(); table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{tex, bool_}, sem::EvaluationStage::kConstant, Source{}); diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index ee4f628d4c..a4cd05751b 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -59,8 +59,6 @@ #include "src/tint/sem/atomic.h" #include "src/tint/sem/break_if_statement.h" #include "src/tint/sem/call.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" #include "src/tint/sem/for_loop_statement.h" #include "src/tint/sem/function.h" #include "src/tint/sem/if_statement.h" @@ -69,19 +67,21 @@ #include "src/tint/sem/materialize.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/module.h" -#include "src/tint/sem/multisampled_texture.h" #include "src/tint/sem/pointer.h" #include "src/tint/sem/reference.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/sampler.h" #include "src/tint/sem/statement.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" #include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_initializer.h" #include "src/tint/sem/variable.h" #include "src/tint/sem/while_statement.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/utils/defer.h" #include "src/tint/utils/math.h" #include "src/tint/utils/reverse.h" @@ -279,9 +279,9 @@ type::Type* Resolver::Type(const ast::Type* ty) { return nullptr; }, [&](const ast::Sampler* t) { return builder_->create(t->kind); }, - [&](const ast::SampledTexture* t) -> sem::SampledTexture* { + [&](const ast::SampledTexture* t) -> type::SampledTexture* { if (auto* el = Type(t->type)) { - auto* sem = builder_->create(t->dim, el); + auto* sem = builder_->create(t->dim, el); if (!validator_.SampledTexture(sem, t->source)) { return nullptr; } @@ -289,9 +289,9 @@ type::Type* Resolver::Type(const ast::Type* ty) { } return nullptr; }, - [&](const ast::MultisampledTexture* t) -> sem::MultisampledTexture* { + [&](const ast::MultisampledTexture* t) -> type::MultisampledTexture* { if (auto* el = Type(t->type)) { - auto* sem = builder_->create(t->dim, el); + auto* sem = builder_->create(t->dim, el); if (!validator_.MultisampledTexture(sem, t->source)) { return nullptr; } @@ -299,20 +299,20 @@ type::Type* Resolver::Type(const ast::Type* ty) { } return nullptr; }, - [&](const ast::DepthTexture* t) { return builder_->create(t->dim); }, + [&](const ast::DepthTexture* t) { return builder_->create(t->dim); }, [&](const ast::DepthMultisampledTexture* t) { - return builder_->create(t->dim); + return builder_->create(t->dim); }, - [&](const ast::StorageTexture* t) -> sem::StorageTexture* { + [&](const ast::StorageTexture* t) -> type::StorageTexture* { if (auto* el = Type(t->type)) { if (!validator_.StorageTexture(t)) { return nullptr; } - return builder_->create(t->dim, t->format, t->access, el); + return builder_->create(t->dim, t->format, t->access, el); } return nullptr; }, - [&](const ast::ExternalTexture*) { return builder_->create(); }, + [&](const ast::ExternalTexture*) { return builder_->create(); }, [&](Default) { auto* resolved = sem_.ResolvedSymbol(ty); return Switch( @@ -2390,7 +2390,7 @@ void Resolver::CollectTextureSamplerPairs(const sem::Builtin* builtin, } if (auto* user = args[static_cast(texture_index)]->As()) { auto* texture = user->Variable(); - if (!texture->Type()->UnwrapRef()->Is()) { + if (!texture->Type()->UnwrapRef()->Is()) { int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler); const sem::Variable* sampler = sampler_index != -1 diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc index 1ac1369a75..73a61a7655 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -40,10 +40,10 @@ #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/module.h" #include "src/tint/sem/reference.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/switch_statement.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/sampled_texture.h" using ::testing::ElementsAre; using ::testing::HasSubstr; diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc index b389fc1c54..9c37b68c01 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -17,8 +17,8 @@ #include "src/tint/ast/stage_attribute.h" #include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "gmock/gmock.h" diff --git a/src/tint/resolver/validation_test.cc b/src/tint/resolver/validation_test.cc index 946bcb9cae..6ccdc7c201 100644 --- a/src/tint/resolver/validation_test.cc +++ b/src/tint/resolver/validation_test.cc @@ -34,9 +34,9 @@ #include "src/tint/sem/call.h" #include "src/tint/sem/function.h" #include "src/tint/sem/member_accessor_expression.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/sampled_texture.h" using ::testing::ElementsAre; using ::testing::HasSubstr; diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index 7d1f94bc65..a442080bdc 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -52,27 +52,27 @@ #include "src/tint/sem/atomic.h" #include "src/tint/sem/break_if_statement.h" #include "src/tint/sem/call.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" #include "src/tint/sem/for_loop_statement.h" #include "src/tint/sem/function.h" #include "src/tint/sem/if_statement.h" #include "src/tint/sem/loop_statement.h" #include "src/tint/sem/materialize.h" #include "src/tint/sem/member_accessor_expression.h" -#include "src/tint/sem/multisampled_texture.h" #include "src/tint/sem/pointer.h" #include "src/tint/sem/reference.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/sampler.h" #include "src/tint/sem/statement.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" #include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_initializer.h" #include "src/tint/sem/variable.h" #include "src/tint/sem/while_statement.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/utils/defer.h" #include "src/tint/utils/map.h" #include "src/tint/utils/math.h" @@ -231,7 +231,7 @@ bool Validator::IsHostShareable(const type::Type* type) const { // https://gpuweb.github.io/gpuweb/wgsl.html#storable-types bool Validator::IsStorable(const type::Type* type) const { - return IsPlain(type) || type->IsAnyOf(); + return IsPlain(type) || type->IsAnyOf(); } const ast::Statement* Validator::ClosestContinuing(bool stop_at_loop, @@ -319,7 +319,7 @@ bool Validator::StorageTexture(const ast::StorageTexture* t) const { return true; } -bool Validator::SampledTexture(const sem::SampledTexture* t, const Source& source) const { +bool Validator::SampledTexture(const type::SampledTexture* t, const Source& source) const { if (!t->type()->UnwrapRef()->IsAnyOf()) { AddError("texture_2d: type must be f32, i32 or u32", source); return false; @@ -328,7 +328,8 @@ bool Validator::SampledTexture(const sem::SampledTexture* t, const Source& sourc return true; } -bool Validator::MultisampledTexture(const sem::MultisampledTexture* t, const Source& source) const { +bool Validator::MultisampledTexture(const type::MultisampledTexture* t, + const Source& source) const { if (t->dim() != ast::TextureDimension::k2d) { AddError("only 2d multisampled textures are supported", source); return false; @@ -831,7 +832,7 @@ bool Validator::Parameter(const ast::Function* func, const sem::Variable* var) c AddError("type of function parameter must be constructible", decl->type->source); return false; } - } else if (!var->Type()->IsAnyOf()) { + } else if (!var->Type()->IsAnyOf()) { AddError("type of function parameter cannot be " + sem_.TypeNameOf(var->Type()), decl->source); return false; @@ -2265,7 +2266,7 @@ bool Validator::Assignment(const ast::Statement* a, const type::Type* rhs_ty) co // https://www.w3.org/TR/WGSL/#phony-assignment-section auto* ty = rhs_ty->UnwrapRef(); if (!ty->IsConstructible() && - !ty->IsAnyOf()) { + !ty->IsAnyOf()) { AddError("cannot assign '" + sem_.TypeNameOf(rhs_ty) + "' to '_'. '_' can only be assigned a constructible, pointer, texture or " "sampler type", diff --git a/src/tint/resolver/validator.h b/src/tint/resolver/validator.h index 99db20183c..d666555a51 100644 --- a/src/tint/resolver/validator.h +++ b/src/tint/resolver/validator.h @@ -361,13 +361,13 @@ class Validator { /// @param t the texture to validate /// @param source the source of the texture /// @returns true on success, false otherwise - bool SampledTexture(const sem::SampledTexture* t, const Source& source) const; + bool SampledTexture(const type::SampledTexture* t, const Source& source) const; /// Validates a multisampled texture /// @param t the texture to validate /// @param source the source of the texture /// @returns true on success, false otherwise - bool MultisampledTexture(const sem::MultisampledTexture* t, const Source& source) const; + bool MultisampledTexture(const type::MultisampledTexture* t, const Source& source) const; /// Validates a structure /// @param str the structure to validate diff --git a/src/tint/sem/array_test.cc b/src/tint/sem/array_test.cc index 05788a5178..e4ecd077b3 100644 --- a/src/tint/sem/array_test.cc +++ b/src/tint/sem/array_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/bool_test.cc b/src/tint/sem/bool_test.cc index bbd7f74901..00c862eecd 100644 --- a/src/tint/sem/bool_test.cc +++ b/src/tint/sem/bool_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/f16_test.cc b/src/tint/sem/f16_test.cc index 28fd0dab6b..6c774f832b 100644 --- a/src/tint/sem/f16_test.cc +++ b/src/tint/sem/f16_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/f32_test.cc b/src/tint/sem/f32_test.cc index de4a3e89f6..1d5a7d13bd 100644 --- a/src/tint/sem/f32_test.cc +++ b/src/tint/sem/f32_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/function.cc b/src/tint/sem/function.cc index 5a7c323c4d..3560a8501a 100644 --- a/src/tint/sem/function.cc +++ b/src/tint/sem/function.cc @@ -15,12 +15,12 @@ #include "src/tint/sem/function.h" #include "src/tint/ast/function.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/utils/transform.h" TINT_INSTANTIATE_TYPEINFO(tint::sem::Function); @@ -172,13 +172,13 @@ Function::VariableBindings Function::TransitivelyReferencedSampledTextureVariabl for (auto* global : TransitivelyReferencedGlobals()) { auto* unwrapped_type = global->Type()->UnwrapRef(); - auto* texture = unwrapped_type->As(); + auto* texture = unwrapped_type->As(); if (texture == nullptr) { continue; } - auto is_multisampled = texture->Is(); - auto is_sampled = texture->Is(); + auto is_multisampled = texture->Is(); + auto is_sampled = texture->Is(); if ((multisampled && !is_multisampled) || (!multisampled && !is_sampled)) { continue; diff --git a/src/tint/sem/i32_test.cc b/src/tint/sem/i32_test.cc index 2ccc92cbf7..632251790c 100644 --- a/src/tint/sem/i32_test.cc +++ b/src/tint/sem/i32_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/matrix_test.cc b/src/tint/sem/matrix_test.cc index a82a2d25df..fb8c850bb9 100644 --- a/src/tint/sem/matrix_test.cc +++ b/src/tint/sem/matrix_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/pointer_test.cc b/src/tint/sem/pointer_test.cc index 4f7533e61d..fb3d6c0f7a 100644 --- a/src/tint/sem/pointer_test.cc +++ b/src/tint/sem/pointer_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/sampler_test.cc b/src/tint/sem/sampler_test.cc index caa61dcc18..65b3882130 100644 --- a/src/tint/sem/sampler_test.cc +++ b/src/tint/sem/sampler_test.cc @@ -14,7 +14,7 @@ #include "src/tint/sem/sampler.h" #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/struct_test.cc b/src/tint/sem/struct_test.cc index 55744d1ebe..2d07f537b7 100644 --- a/src/tint/sem/struct_test.cc +++ b/src/tint/sem/struct_test.cc @@ -14,7 +14,7 @@ #include "src/tint/sem/struct.h" #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/u32_test.cc b/src/tint/sem/u32_test.cc index 1716aa57d6..c3ca0e5119 100644 --- a/src/tint/sem/u32_test.cc +++ b/src/tint/sem/u32_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/sem/vector_test.cc b/src/tint/sem/vector_test.cc index adeca55cf2..e5c3201b2d 100644 --- a/src/tint/sem/vector_test.cc +++ b/src/tint/sem/vector_test.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "src/tint/sem/test_helper.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" namespace tint::sem { namespace { diff --git a/src/tint/transform/builtin_polyfill.cc b/src/tint/transform/builtin_polyfill.cc index c4330f4cae..757f8585f7 100644 --- a/src/tint/transform/builtin_polyfill.cc +++ b/src/tint/transform/builtin_polyfill.cc @@ -894,7 +894,7 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src, if (polyfill.texture_sample_base_clamp_to_edge_2d_f32) { auto& sig = builtin->Signature(); auto* tex = sig.Parameter(sem::ParameterUsage::kTexture); - if (auto* stex = tex->Type()->As()) { + if (auto* stex = tex->Type()->As()) { if (stex->type()->Is()) { fn = builtin_polyfills.GetOrCreate(builtin, [&] { return s.textureSampleBaseClampToEdge_2d_f32(); diff --git a/src/tint/transform/combine_samplers.cc b/src/tint/transform/combine_samplers.cc index a266dc3e57..6ddafb51f7 100644 --- a/src/tint/transform/combine_samplers.cc +++ b/src/tint/transform/combine_samplers.cc @@ -141,7 +141,7 @@ struct CombineSamplers::State { const ast::Type* CreateCombinedASTTypeFor(const sem::Variable* texture, const sem::Variable* sampler) { const type::Type* texture_type = texture->Type()->UnwrapRef(); - const sem::DepthTexture* depth = texture_type->As(); + const type::DepthTexture* depth = texture_type->As(); if (depth && !sampler) { return ctx.dst->create(depth->dim(), ctx.dst->create()); } else { @@ -159,8 +159,8 @@ struct CombineSamplers::State { for (auto* global : ctx.src->AST().GlobalVariables()) { auto* global_sem = sem.Get(global)->As(); auto* type = sem.Get(global->type); - if (tint::IsAnyOf(type) && - !type->Is()) { + if (tint::IsAnyOf(type) && + !type->Is()) { ctx.Remove(ctx.src->AST().GlobalDeclarations(), global); } else if (global->HasBindingPoint()) { auto binding_point = global_sem->BindingPoint(); @@ -208,7 +208,7 @@ struct CombineSamplers::State { // Filter out separate textures and samplers from the original // function signature. for (auto* param : fn->Parameters()) { - if (!param->Type()->IsAnyOf()) { + if (!param->Type()->IsAnyOf()) { params.Push(ctx.Clone(param->Declaration())); } } @@ -244,7 +244,7 @@ struct CombineSamplers::State { call->Arguments()[static_cast(texture_index)]; // We don't want to combine storage textures with anything, since // they never have associated samplers in GLSL. - if (texture->Type()->UnwrapRef()->Is()) { + if (texture->Type()->UnwrapRef()->Is()) { return nullptr; } const sem::Expression* sampler = @@ -256,7 +256,7 @@ struct CombineSamplers::State { sem::VariablePair new_pair(texture_var, sampler_var); for (auto* arg : expr->args) { auto* type = ctx.src->TypeOf(arg)->UnwrapRef(); - if (type->Is()) { + if (type->Is()) { const ast::Variable* var = IsGlobal(new_pair) ? global_combined_texture_samplers_[new_pair] @@ -278,7 +278,7 @@ struct CombineSamplers::State { const ast::Expression* value = ctx.dst->Call(ctx.Clone(expr->target.name), args); if (builtin->Type() == sem::BuiltinType::kTextureLoad && - texture_var->Type()->UnwrapRef()->Is() && + texture_var->Type()->UnwrapRef()->Is() && !call->Stmt()->Declaration()->Is()) { value = ctx.dst->MemberAccessor(value, "x"); } @@ -321,7 +321,7 @@ struct CombineSamplers::State { for (auto* arg : expr->args) { if (!ctx.src->TypeOf(arg) ->UnwrapRef() - ->IsAnyOf()) { + ->IsAnyOf()) { args.Push(ctx.Clone(arg)); } } diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc index 63de1f4e64..faced83bdd 100644 --- a/src/tint/transform/multiplanar_external_texture.cc +++ b/src/tint/transform/multiplanar_external_texture.cc @@ -34,7 +34,7 @@ namespace { bool ShouldRun(const Program* program) { for (auto* node : program->ASTNodes().Objects()) { if (auto* ty = node->As()) { - if (program->Sem().Get(ty)) { + if (program->Sem().Get(ty)) { return true; } } @@ -101,7 +101,7 @@ struct MultiplanarExternalTexture::State { // one uniform buffer for the ExternalTextureParams struct). for (auto* global : ctx.src->AST().GlobalVariables()) { auto* sem_var = sem.Get(global); - if (!sem_var->Type()->UnwrapRef()->Is()) { + if (!sem_var->Type()->UnwrapRef()->Is()) { continue; } @@ -161,7 +161,7 @@ struct MultiplanarExternalTexture::State { for (auto* fn : ctx.src->AST().Functions()) { for (const ast::Variable* param : fn->params) { if (auto* sem_var = sem.Get(param)) { - if (!sem_var->Type()->UnwrapRef()->Is()) { + if (!sem_var->Type()->UnwrapRef()->Is()) { continue; } // If we find a texture_external, we must ensure the ExternalTextureParams @@ -195,7 +195,7 @@ struct MultiplanarExternalTexture::State { auto* builtin = call->Target()->As(); if (builtin && !builtin->Parameters().IsEmpty() && - builtin->Parameters()[0]->Type()->Is() && + builtin->Parameters()[0]->Type()->Is() && builtin->Type() != sem::BuiltinType::kTextureDimensions) { if (auto* var_user = sem.Get(expr->args[0])) { auto it = new_binding_symbols.find(var_user->Variable()); diff --git a/src/tint/transform/promote_side_effects_to_decl.cc b/src/tint/transform/promote_side_effects_to_decl.cc index ea13b0b0bd..639cb63577 100644 --- a/src/tint/transform/promote_side_effects_to_decl.cc +++ b/src/tint/transform/promote_side_effects_to_decl.cc @@ -287,7 +287,7 @@ class DecomposeSideEffects::CollectHoistsState : public StateBase { } // Don't hoist textures / samplers as they can't be placed into a let, nor // can they have side effects. - if (var_user->Variable()->Type()->IsAnyOf()) { + if (var_user->Variable()->Type()->IsAnyOf()) { return false; } return true; diff --git a/src/tint/transform/transform.cc b/src/tint/transform/transform.cc index 5877900277..0b5a7f9bde 100644 --- a/src/tint/transform/transform.cc +++ b/src/tint/transform/transform.cc @@ -20,11 +20,11 @@ #include "src/tint/program_builder.h" #include "src/tint/sem/atomic.h" #include "src/tint/sem/block_statement.h" -#include "src/tint/sem/depth_multisampled_texture.h" #include "src/tint/sem/for_loop_statement.h" #include "src/tint/sem/reference.h" #include "src/tint/sem/sampler.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/depth_multisampled_texture.h" TINT_INSTANTIATE_TYPEINFO(tint::transform::Transform); TINT_INSTANTIATE_TYPEINFO(tint::transform::Data); @@ -145,23 +145,23 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type if (auto* a = ty->As()) { return ctx.dst->create(CreateASTTypeFor(ctx, a->Type())); } - if (auto* t = ty->As()) { + if (auto* t = ty->As()) { return ctx.dst->create(t->dim()); } - if (auto* t = ty->As()) { + if (auto* t = ty->As()) { return ctx.dst->create(t->dim()); } - if (ty->Is()) { + if (ty->Is()) { return ctx.dst->create(); } - if (auto* t = ty->As()) { + if (auto* t = ty->As()) { return ctx.dst->create(t->dim(), CreateASTTypeFor(ctx, t->type())); } - if (auto* t = ty->As()) { + if (auto* t = ty->As()) { return ctx.dst->create(t->dim(), CreateASTTypeFor(ctx, t->type())); } - if (auto* t = ty->As()) { + if (auto* t = ty->As()) { return ctx.dst->create(t->dim(), t->texel_format(), CreateASTTypeFor(ctx, t->type()), t->access()); } diff --git a/src/tint/sem/depth_multisampled_texture.cc b/src/tint/type/depth_multisampled_texture.cc similarity index 85% rename from src/tint/sem/depth_multisampled_texture.cc rename to src/tint/type/depth_multisampled_texture.cc index 77f9cac26b..339839a865 100644 --- a/src/tint/sem/depth_multisampled_texture.cc +++ b/src/tint/type/depth_multisampled_texture.cc @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/depth_multisampled_texture.h" +#include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/program_builder.h" #include "src/tint/utils/hash.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::DepthMultisampledTexture); +TINT_INSTANTIATE_TYPEINFO(tint::type::DepthMultisampledTexture); -namespace tint::sem { +namespace tint::type { namespace { bool IsValidDepthDimension(ast::TextureDimension dim) { @@ -29,7 +29,7 @@ bool IsValidDepthDimension(ast::TextureDimension dim) { } // namespace DepthMultisampledTexture::DepthMultisampledTexture(ast::TextureDimension dim) : Base(dim) { - TINT_ASSERT(Semantic, IsValidDepthDimension(dim)); + TINT_ASSERT(Type, IsValidDepthDimension(dim)); } DepthMultisampledTexture::DepthMultisampledTexture(DepthMultisampledTexture&&) = default; @@ -53,4 +53,4 @@ std::string DepthMultisampledTexture::FriendlyName(const SymbolTable&) const { return out.str(); } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/depth_multisampled_texture.h b/src/tint/type/depth_multisampled_texture.h similarity index 83% rename from src/tint/sem/depth_multisampled_texture.h rename to src/tint/type/depth_multisampled_texture.h index a81954e028..c39a7bf9d4 100644 --- a/src/tint/sem/depth_multisampled_texture.h +++ b/src/tint/type/depth_multisampled_texture.h @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_DEPTH_MULTISAMPLED_TEXTURE_H_ -#define SRC_TINT_SEM_DEPTH_MULTISAMPLED_TEXTURE_H_ +#ifndef SRC_TINT_TYPE_DEPTH_MULTISAMPLED_TEXTURE_H_ +#define SRC_TINT_TYPE_DEPTH_MULTISAMPLED_TEXTURE_H_ #include -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { /// A multisampled depth texture type. class DepthMultisampledTexture final : public Castable { @@ -44,6 +44,6 @@ class DepthMultisampledTexture final : public CastableEquals(*a)); EXPECT_TRUE(a->Equals(*b)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(sem::Void{})); } TEST_F(DepthMultisampledTextureTest, Dim) { @@ -59,4 +58,4 @@ TEST_F(DepthMultisampledTextureTest, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/depth_texture.cc b/src/tint/type/depth_texture.cc similarity index 86% rename from src/tint/sem/depth_texture.cc rename to src/tint/type/depth_texture.cc index 4c8bf9a631..ef80dcd3ba 100644 --- a/src/tint/sem/depth_texture.cc +++ b/src/tint/type/depth_texture.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/depth_texture.h" +#include "src/tint/type/depth_texture.h" #include "src/tint/program_builder.h" #include "src/tint/utils/hash.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::DepthTexture); +TINT_INSTANTIATE_TYPEINFO(tint::type::DepthTexture); -namespace tint::sem { +namespace tint::type { namespace { bool IsValidDepthDimension(ast::TextureDimension dim) { @@ -30,7 +30,7 @@ bool IsValidDepthDimension(ast::TextureDimension dim) { } // namespace DepthTexture::DepthTexture(ast::TextureDimension dim) : Base(dim) { - TINT_ASSERT(Semantic, IsValidDepthDimension(dim)); + TINT_ASSERT(Type, IsValidDepthDimension(dim)); } DepthTexture::DepthTexture(DepthTexture&&) = default; @@ -54,4 +54,4 @@ std::string DepthTexture::FriendlyName(const SymbolTable&) const { return out.str(); } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/depth_texture.h b/src/tint/type/depth_texture.h similarity index 85% rename from src/tint/sem/depth_texture.h rename to src/tint/type/depth_texture.h index 9a2e6d0eda..afa39f4a8f 100644 --- a/src/tint/sem/depth_texture.h +++ b/src/tint/type/depth_texture.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_DEPTH_TEXTURE_H_ -#define SRC_TINT_SEM_DEPTH_TEXTURE_H_ +#ifndef SRC_TINT_TYPE_DEPTH_TEXTURE_H_ +#define SRC_TINT_TYPE_DEPTH_TEXTURE_H_ #include -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { /// A depth texture type. class DepthTexture final : public Castable { @@ -44,6 +44,6 @@ class DepthTexture final : public Castable { std::string FriendlyName(const SymbolTable& symbols) const override; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_DEPTH_TEXTURE_H_ +#endif // SRC_TINT_TYPE_DEPTH_TEXTURE_H_ diff --git a/src/tint/sem/depth_texture_test.cc b/src/tint/type/depth_texture_test.cc similarity index 86% rename from src/tint/sem/depth_texture_test.cc rename to src/tint/type/depth_texture_test.cc index 7a869fb278..f817af8b48 100644 --- a/src/tint/sem/depth_texture_test.cc +++ b/src/tint/type/depth_texture_test.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,15 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/depth_texture.h" +#include "src/tint/type/depth_texture.h" -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" +#include "src/tint/type/test_helper.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/storage_texture.h" - -namespace tint::sem { +namespace tint::type { namespace { using DepthTextureTest = TestHelper; @@ -50,7 +49,7 @@ TEST_F(DepthTextureTest, Equals) { EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(sem::Void{})); } TEST_F(DepthTextureTest, IsTexture) { @@ -73,4 +72,4 @@ TEST_F(DepthTextureTest, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/external_texture.cc b/src/tint/type/external_texture.cc similarity index 85% rename from src/tint/sem/external_texture.cc rename to src/tint/type/external_texture.cc index 05be4a1bd6..8480de89a4 100644 --- a/src/tint/sem/external_texture.cc +++ b/src/tint/type/external_texture.cc @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/external_texture.h" +#include "src/tint/type/external_texture.h" #include "src/tint/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::ExternalTexture); +TINT_INSTANTIATE_TYPEINFO(tint::type::ExternalTexture); -namespace tint::sem { +namespace tint::type { ExternalTexture::ExternalTexture() : Base(ast::TextureDimension::k2d) {} @@ -38,4 +38,4 @@ std::string ExternalTexture::FriendlyName(const SymbolTable&) const { return "texture_external"; } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/external_texture.h b/src/tint/type/external_texture.h similarity index 84% rename from src/tint/sem/external_texture.h rename to src/tint/type/external_texture.h index 3cfbd415fa..9c443c0943 100644 --- a/src/tint/sem/external_texture.h +++ b/src/tint/type/external_texture.h @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_EXTERNAL_TEXTURE_H_ -#define SRC_TINT_SEM_EXTERNAL_TEXTURE_H_ +#ifndef SRC_TINT_TYPE_EXTERNAL_TEXTURE_H_ +#define SRC_TINT_TYPE_EXTERNAL_TEXTURE_H_ #include -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { /// An external texture type class ExternalTexture final : public Castable { @@ -44,6 +44,6 @@ class ExternalTexture final : public Castable { std::string FriendlyName(const SymbolTable& symbols) const override; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_EXTERNAL_TEXTURE_H_ +#endif // SRC_TINT_TYPE_EXTERNAL_TEXTURE_H_ diff --git a/src/tint/sem/external_texture_test.cc b/src/tint/type/external_texture_test.cc similarity index 79% rename from src/tint/sem/external_texture_test.cc rename to src/tint/type/external_texture_test.cc index aecd58ac5d..678b0137ce 100644 --- a/src/tint/sem/external_texture_test.cc +++ b/src/tint/type/external_texture_test.cc @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/external_texture.h" +#include "src/tint/type/external_texture.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/storage_texture.h" -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" +#include "src/tint/type/test_helper.h" -namespace tint::sem { +namespace tint::type { namespace { using ExternalTextureTest = TestHelper; @@ -41,11 +41,11 @@ TEST_F(ExternalTextureTest, Equals) { auto* a = create(); auto* b = create(); EXPECT_TRUE(a->Equals(*b)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(sem::Void{})); } TEST_F(ExternalTextureTest, IsTexture) { - F32 f32; + sem::F32 f32; ExternalTexture s; Texture* ty = &s; EXPECT_FALSE(ty->Is()); @@ -56,7 +56,7 @@ TEST_F(ExternalTextureTest, IsTexture) { } TEST_F(ExternalTextureTest, Dim) { - F32 f32; + sem::F32 f32; ExternalTexture s; EXPECT_EQ(s.dim(), ast::TextureDimension::k2d); } @@ -67,4 +67,4 @@ TEST_F(ExternalTextureTest, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/multisampled_texture.cc b/src/tint/type/multisampled_texture.cc similarity index 86% rename from src/tint/sem/multisampled_texture.cc rename to src/tint/type/multisampled_texture.cc index a735cc83f3..0bb2989e5d 100644 --- a/src/tint/sem/multisampled_texture.cc +++ b/src/tint/type/multisampled_texture.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/multisampled_texture.h" +#include "src/tint/type/multisampled_texture.h" #include "src/tint/program_builder.h" #include "src/tint/utils/hash.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::MultisampledTexture); +TINT_INSTANTIATE_TYPEINFO(tint::type::MultisampledTexture); -namespace tint::sem { +namespace tint::type { MultisampledTexture::MultisampledTexture(ast::TextureDimension dim, const type::Type* type) : Base(dim), type_(type) { - TINT_ASSERT(Semantic, type_); + TINT_ASSERT(Type, type_); } MultisampledTexture::MultisampledTexture(MultisampledTexture&&) = default; @@ -47,4 +47,4 @@ std::string MultisampledTexture::FriendlyName(const SymbolTable& symbols) const return out.str(); } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/multisampled_texture.h b/src/tint/type/multisampled_texture.h similarity index 86% rename from src/tint/sem/multisampled_texture.h rename to src/tint/type/multisampled_texture.h index bfea08f080..d3d4a27111 100644 --- a/src/tint/sem/multisampled_texture.h +++ b/src/tint/type/multisampled_texture.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_MULTISAMPLED_TEXTURE_H_ -#define SRC_TINT_SEM_MULTISAMPLED_TEXTURE_H_ +#ifndef SRC_TINT_TYPE_MULTISAMPLED_TEXTURE_H_ +#define SRC_TINT_TYPE_MULTISAMPLED_TEXTURE_H_ #include -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { /// A multisampled texture type. class MultisampledTexture final : public Castable { @@ -51,6 +51,6 @@ class MultisampledTexture final : public Castable const type::Type* const type_; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_MULTISAMPLED_TEXTURE_H_ +#endif // SRC_TINT_TYPE_MULTISAMPLED_TEXTURE_H_ diff --git a/src/tint/sem/multisampled_texture_test.cc b/src/tint/type/multisampled_texture_test.cc similarity index 77% rename from src/tint/sem/multisampled_texture_test.cc rename to src/tint/type/multisampled_texture_test.cc index 3243a5f0e0..6753136603 100644 --- a/src/tint/sem/multisampled_texture_test.cc +++ b/src/tint/type/multisampled_texture_test.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,52 +12,52 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/multisampled_texture.h" +#include "src/tint/type/multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/storage_texture.h" -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" +#include "src/tint/type/test_helper.h" -namespace tint::sem { +namespace tint::type { namespace { using MultisampledTextureTest = TestHelper; TEST_F(MultisampledTextureTest, Creation) { - auto* a = create(ast::TextureDimension::k2d, create()); - auto* b = create(ast::TextureDimension::k2d, create()); - auto* c = create(ast::TextureDimension::k3d, create()); - auto* d = create(ast::TextureDimension::k2d, create()); + auto* a = create(ast::TextureDimension::k2d, create()); + auto* b = create(ast::TextureDimension::k2d, create()); + auto* c = create(ast::TextureDimension::k3d, create()); + auto* d = create(ast::TextureDimension::k2d, create()); EXPECT_EQ(a, b); EXPECT_NE(a, c); EXPECT_NE(a, d); } TEST_F(MultisampledTextureTest, Hash) { - auto* a = create(ast::TextureDimension::k2d, create()); - auto* b = create(ast::TextureDimension::k2d, create()); - auto* c = create(ast::TextureDimension::k3d, create()); - auto* d = create(ast::TextureDimension::k2d, create()); + auto* a = create(ast::TextureDimension::k2d, create()); + auto* b = create(ast::TextureDimension::k2d, create()); + auto* c = create(ast::TextureDimension::k3d, create()); + auto* d = create(ast::TextureDimension::k2d, create()); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); EXPECT_NE(a->Hash(), d->Hash()); } TEST_F(MultisampledTextureTest, Equals) { - auto* a = create(ast::TextureDimension::k2d, create()); - auto* b = create(ast::TextureDimension::k2d, create()); - auto* c = create(ast::TextureDimension::k3d, create()); - auto* d = create(ast::TextureDimension::k2d, create()); + auto* a = create(ast::TextureDimension::k2d, create()); + auto* b = create(ast::TextureDimension::k2d, create()); + auto* c = create(ast::TextureDimension::k3d, create()); + auto* d = create(ast::TextureDimension::k2d, create()); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(sem::Void{})); } TEST_F(MultisampledTextureTest, IsTexture) { - F32 f32; + sem::F32 f32; MultisampledTexture s(ast::TextureDimension::kCube, &f32); Texture* ty = &s; EXPECT_FALSE(ty->Is()); @@ -68,22 +68,22 @@ TEST_F(MultisampledTextureTest, IsTexture) { } TEST_F(MultisampledTextureTest, Dim) { - F32 f32; + sem::F32 f32; MultisampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.dim(), ast::TextureDimension::k3d); } TEST_F(MultisampledTextureTest, Type) { - F32 f32; + sem::F32 f32; MultisampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.type(), &f32); } TEST_F(MultisampledTextureTest, FriendlyName) { - F32 f32; + sem::F32 f32; MultisampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d"); } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/sampled_texture.cc b/src/tint/type/sampled_texture.cc similarity index 86% rename from src/tint/sem/sampled_texture.cc rename to src/tint/type/sampled_texture.cc index 9481ed4d43..bea18e6710 100644 --- a/src/tint/sem/sampled_texture.cc +++ b/src/tint/type/sampled_texture.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/program_builder.h" #include "src/tint/utils/hash.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::SampledTexture); +TINT_INSTANTIATE_TYPEINFO(tint::type::SampledTexture); -namespace tint::sem { +namespace tint::type { SampledTexture::SampledTexture(ast::TextureDimension dim, const type::Type* type) : Base(dim), type_(type) { - TINT_ASSERT(Semantic, type_); + TINT_ASSERT(Type, type_); } SampledTexture::SampledTexture(SampledTexture&&) = default; @@ -47,4 +47,4 @@ std::string SampledTexture::FriendlyName(const SymbolTable& symbols) const { return out.str(); } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/sampled_texture.h b/src/tint/type/sampled_texture.h similarity index 86% rename from src/tint/sem/sampled_texture.h rename to src/tint/type/sampled_texture.h index 076d063448..7b5f6f8460 100644 --- a/src/tint/sem/sampled_texture.h +++ b/src/tint/type/sampled_texture.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_SAMPLED_TEXTURE_H_ -#define SRC_TINT_SEM_SAMPLED_TEXTURE_H_ +#ifndef SRC_TINT_TYPE_SAMPLED_TEXTURE_H_ +#define SRC_TINT_TYPE_SAMPLED_TEXTURE_H_ #include -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { /// A sampled texture type. class SampledTexture final : public Castable { @@ -51,6 +51,6 @@ class SampledTexture final : public Castable { const type::Type* const type_; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_SAMPLED_TEXTURE_H_ +#endif // SRC_TINT_TYPE_SAMPLED_TEXTURE_H_ diff --git a/src/tint/sem/sampled_texture_test.cc b/src/tint/type/sampled_texture_test.cc similarity index 77% rename from src/tint/sem/sampled_texture_test.cc rename to src/tint/type/sampled_texture_test.cc index 8a3321f524..e45fb7c2de 100644 --- a/src/tint/sem/sampled_texture_test.cc +++ b/src/tint/type/sampled_texture_test.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,25 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/sampled_texture.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/storage_texture.h" -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/storage_texture.h" +#include "src/tint/type/test_helper.h" -namespace tint::sem { +namespace tint::type { namespace { using SampledTextureTest = TestHelper; TEST_F(SampledTextureTest, Creation) { - auto* a = create(ast::TextureDimension::kCube, create()); - auto* b = create(ast::TextureDimension::kCube, create()); - auto* c = create(ast::TextureDimension::k2d, create()); - auto* d = create(ast::TextureDimension::kCube, create()); + auto* a = create(ast::TextureDimension::kCube, create()); + auto* b = create(ast::TextureDimension::kCube, create()); + auto* c = create(ast::TextureDimension::k2d, create()); + auto* d = create(ast::TextureDimension::kCube, create()); - EXPECT_TRUE(a->type()->Is()); + EXPECT_TRUE(a->type()->Is()); EXPECT_EQ(a->dim(), ast::TextureDimension::kCube); EXPECT_EQ(a, b); @@ -39,10 +39,10 @@ TEST_F(SampledTextureTest, Creation) { } TEST_F(SampledTextureTest, Hash) { - auto* a = create(ast::TextureDimension::kCube, create()); - auto* b = create(ast::TextureDimension::kCube, create()); - auto* c = create(ast::TextureDimension::k2d, create()); - auto* d = create(ast::TextureDimension::kCube, create()); + auto* a = create(ast::TextureDimension::kCube, create()); + auto* b = create(ast::TextureDimension::kCube, create()); + auto* c = create(ast::TextureDimension::k2d, create()); + auto* d = create(ast::TextureDimension::kCube, create()); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); @@ -50,19 +50,19 @@ TEST_F(SampledTextureTest, Hash) { } TEST_F(SampledTextureTest, Equals) { - auto* a = create(ast::TextureDimension::kCube, create()); - auto* b = create(ast::TextureDimension::kCube, create()); - auto* c = create(ast::TextureDimension::k2d, create()); - auto* d = create(ast::TextureDimension::kCube, create()); + auto* a = create(ast::TextureDimension::kCube, create()); + auto* b = create(ast::TextureDimension::kCube, create()); + auto* c = create(ast::TextureDimension::k2d, create()); + auto* d = create(ast::TextureDimension::kCube, create()); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(sem::Void{})); } TEST_F(SampledTextureTest, IsTexture) { - F32 f32; + sem::F32 f32; SampledTexture s(ast::TextureDimension::kCube, &f32); Texture* ty = &s; EXPECT_FALSE(ty->Is()); @@ -72,22 +72,22 @@ TEST_F(SampledTextureTest, IsTexture) { } TEST_F(SampledTextureTest, Dim) { - F32 f32; + sem::F32 f32; SampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.dim(), ast::TextureDimension::k3d); } TEST_F(SampledTextureTest, Type) { - F32 f32; + sem::F32 f32; SampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.type(), &f32); } TEST_F(SampledTextureTest, FriendlyName) { - F32 f32; + sem::F32 f32; SampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d"); } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/storage_texture.cc b/src/tint/type/storage_texture.cc similarity index 93% rename from src/tint/sem/storage_texture.cc rename to src/tint/type/storage_texture.cc index ea83a49ec3..b922284ed2 100644 --- a/src/tint/sem/storage_texture.cc +++ b/src/tint/type/storage_texture.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/program_builder.h" #include "src/tint/utils/hash.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::StorageTexture); +TINT_INSTANTIATE_TYPEINFO(tint::type::StorageTexture); -namespace tint::sem { +namespace tint::type { StorageTexture::StorageTexture(ast::TextureDimension dim, ast::TexelFormat format, @@ -82,4 +82,4 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage return nullptr; } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/storage_texture.h b/src/tint/type/storage_texture.h similarity index 91% rename from src/tint/sem/storage_texture.h rename to src/tint/type/storage_texture.h index f86fd1eac9..a540560a17 100644 --- a/src/tint/sem/storage_texture.h +++ b/src/tint/type/storage_texture.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_STORAGE_TEXTURE_H_ -#define SRC_TINT_SEM_STORAGE_TEXTURE_H_ +#ifndef SRC_TINT_TYPE_STORAGE_TEXTURE_H_ +#define SRC_TINT_TYPE_STORAGE_TEXTURE_H_ #include #include "src/tint/ast/access.h" #include "src/tint/ast/storage_texture.h" -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" // Forward declarations namespace tint::type { class TypeManager; } // namespace tint::type -namespace tint::sem { +namespace tint::type { /// A storage texture type. class StorageTexture final : public Castable { @@ -77,6 +77,6 @@ class StorageTexture final : public Castable { type::Type* const subtype_; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_STORAGE_TEXTURE_H_ +#endif // SRC_TINT_TYPE_STORAGE_TEXTURE_H_ diff --git a/src/tint/sem/storage_texture_test.cc b/src/tint/type/storage_texture_test.cc similarity index 86% rename from src/tint/sem/storage_texture_test.cc rename to src/tint/type/storage_texture_test.cc index c93d663063..55becae22c 100644 --- a/src/tint/sem/storage_texture_test.cc +++ b/src/tint/type/storage_texture_test.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors +// Copyright 2022 The Tint Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/storage_texture.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/external_texture.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/external_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/test_helper.h" -namespace tint::sem { +namespace tint::type { namespace { struct StorageTextureTest : public TestHelper { @@ -41,7 +41,7 @@ TEST_F(StorageTextureTest, Creation) { auto* e = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead); - EXPECT_TRUE(a->type()->Is()); + EXPECT_TRUE(a->type()->Is()); EXPECT_EQ(a->dim(), ast::TextureDimension::kCube); EXPECT_EQ(a, b); @@ -84,7 +84,7 @@ TEST_F(StorageTextureTest, Equals) { EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); EXPECT_FALSE(a->Equals(*e)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(sem::Void{})); } TEST_F(StorageTextureTest, Dim) { @@ -114,11 +114,11 @@ TEST_F(StorageTextureTest, F32) { ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); - EXPECT_TRUE(s->As()->type()->Is()); + EXPECT_TRUE(s->As()->type()->Is()); } TEST_F(StorageTextureTest, U32) { - auto* subtype = sem::StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types()); + auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types()); type::Type* s = create(ast::TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint, ast::Access::kReadWrite, subtype); @@ -128,11 +128,11 @@ TEST_F(StorageTextureTest, U32) { ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); - EXPECT_TRUE(s->As()->type()->Is()); + EXPECT_TRUE(s->As()->type()->Is()); } TEST_F(StorageTextureTest, I32) { - auto* subtype = sem::StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types()); + auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types()); type::Type* s = create(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint, ast::Access::kReadWrite, subtype); @@ -142,8 +142,8 @@ TEST_F(StorageTextureTest, I32) { ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); - EXPECT_TRUE(s->As()->type()->Is()); + EXPECT_TRUE(s->As()->type()->Is()); } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/texture.cc b/src/tint/type/texture.cc similarity index 80% rename from src/tint/sem/texture.cc rename to src/tint/type/texture.cc index d14d7a942b..76d6df5c6f 100644 --- a/src/tint/sem/texture.cc +++ b/src/tint/type/texture.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::Texture); +TINT_INSTANTIATE_TYPEINFO(tint::type::Texture); -namespace tint::sem { +namespace tint::type { Texture::Texture(ast::TextureDimension dim) : Base(type::TypeFlags{}), dim_(dim) {} @@ -24,4 +24,4 @@ Texture::Texture(Texture&&) = default; Texture::~Texture() = default; -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/texture.h b/src/tint/type/texture.h similarity index 84% rename from src/tint/sem/texture.h rename to src/tint/type/texture.h index eac8baebb6..dc566fea12 100644 --- a/src/tint/sem/texture.h +++ b/src/tint/type/texture.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_TEXTURE_H_ -#define SRC_TINT_SEM_TEXTURE_H_ +#ifndef SRC_TINT_TYPE_TEXTURE_H_ +#define SRC_TINT_TYPE_TEXTURE_H_ #include "src/tint/ast/texture.h" #include "src/tint/type/type.h" -namespace tint::sem { +namespace tint::type { /// A texture type. class Texture : public Castable { @@ -37,6 +37,6 @@ class Texture : public Castable { ast::TextureDimension const dim_; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_TEXTURE_H_ +#endif // SRC_TINT_TYPE_TEXTURE_H_ diff --git a/src/tint/sem/texture_test.cc b/src/tint/type/texture_test.cc similarity index 86% rename from src/tint/sem/texture_test.cc rename to src/tint/type/texture_test.cc index c948c32e25..1c3abd7128 100644 --- a/src/tint/sem/texture_test.cc +++ b/src/tint/type/texture_test.cc @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/texture.h" +#include "src/tint/type/texture.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/test_helper.h" -namespace tint::sem { +namespace tint::type { namespace { using TextureTypeDimTest = TestParamHelper; TEST_P(TextureTypeDimTest, DimMustMatch) { // Check that the dim() query returns the right dimensionality. - F32 f32; + sem::F32 f32; // TextureType is an abstract class, so use concrete class // SampledTexture in its stead. SampledTexture st(GetParam(), &f32); @@ -41,4 +41,4 @@ INSTANTIATE_TEST_SUITE_P(Dimensions, ast::TextureDimension::kCubeArray)); } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/type/type.cc b/src/tint/type/type.cc index 3f990e9c3a..353570bcaf 100644 --- a/src/tint/type/type.cc +++ b/src/tint/type/type.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,9 +26,9 @@ #include "src/tint/sem/reference.h" #include "src/tint/sem/sampler.h" #include "src/tint/sem/struct.h" -#include "src/tint/sem/texture.h" #include "src/tint/sem/u32.h" #include "src/tint/sem/vector.h" +#include "src/tint/type/texture.h" TINT_INSTANTIATE_TYPEINFO(tint::type::Type); @@ -172,7 +172,7 @@ bool Type::is_numeric_scalar_or_vector() const { } bool Type::is_handle() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::HoldsAbstract() const { diff --git a/src/tint/writer/generate_external_texture_bindings.cc b/src/tint/writer/generate_external_texture_bindings.cc index 6408e0e56e..459d736dd1 100644 --- a/src/tint/writer/generate_external_texture_bindings.cc +++ b/src/tint/writer/generate_external_texture_bindings.cc @@ -21,8 +21,8 @@ #include "src/tint/ast/external_texture.h" #include "src/tint/ast/module.h" #include "src/tint/program.h" -#include "src/tint/sem/external_texture.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/external_texture.h" namespace tint::writer { @@ -40,7 +40,7 @@ transform::MultiplanarExternalTexture::BindingsMap GenerateExternalTextureBindin auto& n = group_to_next_binding_number[bp.group]; n = std::max(n, bp.binding + 1); - if (sem_var->Type()->UnwrapRef()->Is()) { + if (sem_var->Type()->UnwrapRef()->Is()) { ext_tex_bps.emplace_back(bp); } } diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index ec8c9b199b..cb029994eb 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -32,15 +32,10 @@ #include "src/tint/sem/block_statement.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" #include "src/tint/sem/function.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/module.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/statement.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" #include "src/tint/sem/type_conversion.h" @@ -69,6 +64,11 @@ #include "src/tint/transform/std140.h" #include "src/tint/transform/unshadow.h" #include "src/tint/transform/zero_init_workgroup_memory.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/utils/defer.h" #include "src/tint/utils/map.h" #include "src/tint/utils/scoped_assignment.h" @@ -1380,7 +1380,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, return false; } - auto* texture_type = TypeOf(texture)->UnwrapRef()->As(); + auto* texture_type = TypeOf(texture)->UnwrapRef()->As(); auto emit_signed_int_type = [&](const type::Type* ty) { uint32_t width = 0; @@ -1420,7 +1420,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, emit_unsigned_int_type(call->Type()); ScopedParen sp(out); - if (texture_type->Is()) { + if (texture_type->Is()) { out << "imageSize("; } else { out << "textureSize("; @@ -1431,9 +1431,9 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, // The LOD parameter is mandatory on textureSize() for non-multisampled // textures. - if (!texture_type->Is() && - !texture_type->Is() && - !texture_type->Is()) { + if (!texture_type->Is() && + !texture_type->Is() && + !texture_type->Is()) { out << ", "; if (auto* level_arg = arg(Usage::kLevel)) { if (!emit_expr_as_signed(level_arg)) { @@ -1459,7 +1459,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, out << "uint"; ScopedParen sp(out); - if (texture_type->Is()) { + if (texture_type->Is()) { out << "imageSize("; } else { out << "textureSize("; @@ -1471,9 +1471,9 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, } // The LOD parameter is mandatory on textureSize() for non-multisampled // textures. - if (!texture_type->Is() && - !texture_type->Is() && - !texture_type->Is()) { + if (!texture_type->Is() && + !texture_type->Is() && + !texture_type->Is()) { out << ", "; if (auto* level_arg = arg(Usage::kLevel)) { if (!emit_expr_as_signed(level_arg)) { @@ -1520,7 +1520,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, uint32_t glsl_ret_width = 4u; bool append_depth_ref_to_coords = true; - bool is_depth = texture_type->Is(); + bool is_depth = texture_type->Is(); switch (builtin->Type()) { case sem::BuiltinType::kTextureSample: @@ -2069,7 +2069,7 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable* // GLSL ignores Sampler variables. return true; } - if (auto* storage = type->As()) { + if (auto* storage = type->As()) { out << "layout(" << convert_texel_format_to_glsl(storage->texel_format()) << ") "; } if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), name)) { @@ -2897,16 +2897,16 @@ bool GeneratorImpl::EmitType(std::ostream& out, return false; } else if (auto* str = type->As()) { out << StructName(str); - } else if (auto* tex = type->As()) { - if (tex->Is()) { + } else if (auto* tex = type->As()) { + if (tex->Is()) { TINT_ICE(Writer, diagnostics_) << "Multiplanar external texture transform was not run."; return false; } - auto* storage = tex->As(); - auto* ms = tex->As(); - auto* depth_ms = tex->As(); - auto* sampled = tex->As(); + auto* storage = tex->As(); + auto* ms = tex->As(); + auto* depth_ms = tex->As(); + auto* sampled = tex->As(); out << "highp "; @@ -2953,7 +2953,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, << "unexpected TextureDimension " << tex->dim(); return false; } - if (tex->Is()) { + if (tex->Is()) { out << "Shadow"; } } else if (type->Is()) { diff --git a/src/tint/writer/glsl/generator_impl_type_test.cc b/src/tint/writer/glsl/generator_impl_type_test.cc index f5733dba16..6d672be292 100644 --- a/src/tint/writer/glsl/generator_impl_type_test.cc +++ b/src/tint/writer/glsl/generator_impl_type_test.cc @@ -15,11 +15,11 @@ #include "gmock/gmock.h" #include "src/tint/ast/call_statement.h" #include "src/tint/ast/stage_attribute.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/sampler.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/writer/glsl/test_helper.h" using ::testing::HasSubstr; @@ -495,7 +495,7 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Type, TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) { auto* f32 = create(); - auto* s = create(ast::TextureDimension::k2d, f32); + auto* s = create(ast::TextureDimension::k2d, f32); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index 131f9b1f50..f776a3563e 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -33,15 +33,10 @@ #include "src/tint/sem/block_statement.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" #include "src/tint/sem/function.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/module.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/statement.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" #include "src/tint/sem/type_conversion.h" @@ -69,6 +64,11 @@ #include "src/tint/transform/unshadow.h" #include "src/tint/transform/vectorize_scalar_matrix_initializers.h" #include "src/tint/transform/zero_init_workgroup_memory.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/utils/defer.h" #include "src/tint/utils/map.h" #include "src/tint/utils/scoped_assignment.h" @@ -2274,7 +2274,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, return false; } - auto* texture_type = TypeOf(texture)->UnwrapRef()->As(); + auto* texture_type = TypeOf(texture)->UnwrapRef()->As(); switch (builtin->Type()) { case sem::BuiltinType::kTextureDimensions: @@ -2283,7 +2283,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, case sem::BuiltinType::kTextureNumSamples: { // All of these builtins use the GetDimensions() method on the texture bool is_ms = - texture_type->IsAnyOf(); + texture_type->IsAnyOf(); int num_dimensions = 0; std::string swizzle; @@ -2488,7 +2488,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, case sem::BuiltinType::kTextureLoad: out << ".Load("; // Multisampled textures do not support mip-levels. - if (!texture_type->Is()) { + if (!texture_type->Is()) { pack_level_in_coords = true; } break; @@ -3059,9 +3059,9 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable* const char* register_space = nullptr; - if (unwrapped_type->Is()) { + if (unwrapped_type->Is()) { register_space = "t"; - if (unwrapped_type->Is()) { + if (unwrapped_type->Is()) { register_space = "u"; } } else if (unwrapped_type->Is()) { @@ -4011,17 +4011,17 @@ bool GeneratorImpl::EmitType(std::ostream& out, out << StructName(str); return true; }, - [&](const sem::Texture* tex) { - if (tex->Is()) { + [&](const type::Texture* tex) { + if (tex->Is()) { TINT_ICE(Writer, diagnostics_) << "Multiplanar external texture transform was not run."; return false; } - auto* storage = tex->As(); - auto* ms = tex->As(); - auto* depth_ms = tex->As(); - auto* sampled = tex->As(); + auto* storage = tex->As(); + auto* ms = tex->As(); + auto* depth_ms = tex->As(); + auto* sampled = tex->As(); if (storage && storage->access() != ast::Access::kRead) { out << "RW"; diff --git a/src/tint/writer/hlsl/generator_impl_type_test.cc b/src/tint/writer/hlsl/generator_impl_type_test.cc index 7e501804da..6ef0e05a70 100644 --- a/src/tint/writer/hlsl/generator_impl_type_test.cc +++ b/src/tint/writer/hlsl/generator_impl_type_test.cc @@ -15,11 +15,11 @@ #include "gmock/gmock.h" #include "src/tint/ast/call_statement.h" #include "src/tint/ast/stage_attribute.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/sampler.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/writer/hlsl/test_helper.h" using ::testing::HasSubstr; @@ -494,7 +494,7 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Type, TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) { auto* f32 = create(); - auto* s = create(ast::TextureDimension::k2d, f32); + auto* s = create(ast::TextureDimension::k2d, f32); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index 66876940e5..2d91763498 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -36,8 +36,6 @@ #include "src/tint/sem/bool.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" #include "src/tint/sem/f16.h" #include "src/tint/sem/f32.h" #include "src/tint/sem/function.h" @@ -45,11 +43,8 @@ #include "src/tint/sem/matrix.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/module.h" -#include "src/tint/sem/multisampled_texture.h" #include "src/tint/sem/pointer.h" #include "src/tint/sem/reference.h" -#include "src/tint/sem/sampled_texture.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" #include "src/tint/sem/type_conversion.h" @@ -75,6 +70,11 @@ #include "src/tint/transform/unshadow.h" #include "src/tint/transform/vectorize_scalar_matrix_initializers.h" #include "src/tint/transform/zero_init_workgroup_memory.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/utils/defer.h" #include "src/tint/utils/map.h" #include "src/tint/utils/scoped_assignment.h" @@ -997,7 +997,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, return false; } - auto* texture_type = TypeOf(texture)->UnwrapRef()->As(); + auto* texture_type = TypeOf(texture)->UnwrapRef()->As(); // Helper to emit the texture expression, wrapped in parentheses if the // expression includes an operator with lower precedence than the member @@ -2607,14 +2607,14 @@ bool GeneratorImpl::EmitType(std::ostream& out, out << StructName(str); return true; }, - [&](const sem::Texture* tex) { - if (tex->Is()) { + [&](const type::Texture* tex) { + if (tex->Is()) { TINT_ICE(Writer, diagnostics_) << "Multiplanar external texture transform was not run."; return false; } - if (tex->IsAnyOf()) { + if (tex->IsAnyOf()) { out << "depth"; } else { out << "texture"; @@ -2643,7 +2643,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, diagnostics_.add_error(diag::System::Writer, "Invalid texture dimensions"); return false; } - if (tex->IsAnyOf()) { + if (tex->IsAnyOf()) { out << "_ms"; } out << "<"; @@ -2651,15 +2651,15 @@ bool GeneratorImpl::EmitType(std::ostream& out, return Switch( tex, - [&](const sem::DepthTexture*) { + [&](const type::DepthTexture*) { out << "float, access::sample"; return true; }, - [&](const sem::DepthMultisampledTexture*) { + [&](const type::DepthMultisampledTexture*) { out << "float, access::read"; return true; }, - [&](const sem::StorageTexture* storage) { + [&](const type::StorageTexture* storage) { if (!EmitType(out, storage->type(), "")) { return false; } @@ -2676,14 +2676,14 @@ bool GeneratorImpl::EmitType(std::ostream& out, } return true; }, - [&](const sem::MultisampledTexture* ms) { + [&](const type::MultisampledTexture* ms) { if (!EmitType(out, ms->type(), "")) { return false; } out << ", access::read"; return true; }, - [&](const sem::SampledTexture* sampled) { + [&](const type::SampledTexture* sampled) { if (!EmitType(out, sampled->type(), "")) { return false; } diff --git a/src/tint/writer/msl/generator_impl_type_test.cc b/src/tint/writer/msl/generator_impl_type_test.cc index 27de589c24..514897453b 100644 --- a/src/tint/writer/msl/generator_impl_type_test.cc +++ b/src/tint/writer/msl/generator_impl_type_test.cc @@ -16,12 +16,12 @@ #include "gmock/gmock.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/sampler.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/writer/msl/test_helper.h" using ::testing::HasSubstr; @@ -761,7 +761,7 @@ using MslDepthTexturesTest = TestParamHelper; TEST_P(MslDepthTexturesTest, Emit) { auto params = GetParam(); - sem::DepthTexture s(params.dim); + type::DepthTexture s(params.dim); GeneratorImpl& gen = Build(); @@ -782,7 +782,7 @@ INSTANTIATE_TEST_SUITE_P( using MslDepthMultisampledTexturesTest = TestHelper; TEST_F(MslDepthMultisampledTexturesTest, Emit) { - sem::DepthMultisampledTexture s(ast::TextureDimension::k2d); + type::DepthMultisampledTexture s(ast::TextureDimension::k2d); GeneratorImpl& gen = Build(); @@ -804,7 +804,7 @@ TEST_P(MslSampledtexturesTest, Emit) { auto params = GetParam(); auto* f32 = create(); - auto* s = create(params.dim, f32); + auto* s = create(params.dim, f32); GeneratorImpl& gen = Build(); @@ -826,7 +826,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) { auto* u32 = create(); - auto* ms = create(ast::TextureDimension::k2d, u32); + auto* ms = create(ast::TextureDimension::k2d, u32); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index 58698491b7..e03d95d8b5 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -27,15 +27,11 @@ #include "src/tint/sem/builtin.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" -#include "src/tint/sem/depth_multisampled_texture.h" -#include "src/tint/sem/depth_texture.h" #include "src/tint/sem/function.h" #include "src/tint/sem/materialize.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/module.h" -#include "src/tint/sem/multisampled_texture.h" #include "src/tint/sem/reference.h" -#include "src/tint/sem/sampled_texture.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" @@ -44,6 +40,10 @@ #include "src/tint/sem/variable.h" #include "src/tint/sem/vector.h" #include "src/tint/transform/add_block_attribute.h" +#include "src/tint/type/depth_multisampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/utils/defer.h" #include "src/tint/utils/map.h" #include "src/tint/writer/append_vector.h" @@ -779,9 +779,9 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) { if (v->initializer) { ops.push_back(Operand(init_id)); } else { - auto* st = type->As(); + auto* st = type->As(); if (st || type->Is()) { - // type is a sem::Struct or a sem::StorageTexture + // type is a sem::Struct or a type::StorageTexture auto access = st ? st->access() : sem->Access(); switch (access) { case ast::Access::kWrite: @@ -2649,7 +2649,7 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call, TINT_ICE(Writer, builder_.Diagnostics()) << "missing texture argument"; } - auto* texture_type = texture->Type()->UnwrapRef()->As(); + auto* texture_type = texture->Type()->UnwrapRef()->As(); auto op = spv::Op::OpNop; @@ -2685,7 +2685,7 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call, // If the texture is not a depth texture, then this function simply delegates // to calling append_result_type_and_id_to_spirv_params(). auto append_result_type_and_id_to_spirv_params_for_read = [&]() { - if (texture_type->IsAnyOf()) { + if (texture_type->IsAnyOf()) { auto* f32 = builder_.create(); auto* spirv_result_type = builder_.create(f32, 4u); auto spirv_result = result_op(); @@ -2807,9 +2807,9 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call, } spirv_params.emplace_back(gen_arg(Usage::kTexture)); - if (texture_type->IsAnyOf()) { + if (texture_type->IsAnyOf()) { op = spv::Op::OpImageQuerySize; } else if (auto* level = arg(Usage::kLevel)) { op = spv::Op::OpImageQuerySizeLod; @@ -2841,8 +2841,8 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call, spirv_params.emplace_back(gen_arg(Usage::kTexture)); - if (texture_type->Is() || - texture_type->Is()) { + if (texture_type->Is() || + texture_type->Is()) { op = spv::Op::OpImageQuerySize; } else { op = spv::Op::OpImageQuerySizeLod; @@ -2864,8 +2864,8 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call, break; } case BuiltinType::kTextureLoad: { - op = texture_type->Is() ? spv::Op::OpImageRead - : spv::Op::OpImageFetch; + op = texture_type->Is() ? spv::Op::OpImageRead + : spv::Op::OpImageFetch; append_result_type_and_id_to_spirv_params_for_read(); spirv_params.emplace_back(gen_arg(Usage::kTexture)); if (!append_coords_to_spirv_params()) { @@ -3280,9 +3280,9 @@ uint32_t Builder::GenerateSampledImage(const type::Type* texture_type, // The Vulkan spec says: The "Depth" operand of OpTypeImage is ignored. // In SPIRV, 0 means not depth, 1 means depth, and 2 means unknown. // Using anything other than 0 is problematic on various Vulkan drivers. - if (auto* depthTextureType = texture_type->As()) { - texture_type = builder_.create(depthTextureType->dim(), - builder_.create()); + if (auto* depthTextureType = texture_type->As()) { + texture_type = builder_.create(depthTextureType->dim(), + builder_.create()); } uint32_t sampled_image_type_id = @@ -3645,12 +3645,12 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { // The Vulkan spec says: The "Depth" operand of OpTypeImage is ignored. // In SPIRV, 0 means not depth, 1 means depth, and 2 means unknown. // Using anything other than 0 is problematic on various Vulkan drivers. - if (auto* depthTextureType = type->As()) { - type = builder_.create(depthTextureType->dim(), - builder_.create()); - } else if (auto* multisampledDepthTextureType = type->As()) { - type = builder_.create(multisampledDepthTextureType->dim(), - builder_.create()); + if (auto* depthTextureType = type->As()) { + type = builder_.create(depthTextureType->dim(), + builder_.create()); + } else if (auto* multisampledDepthTextureType = type->As()) { + type = builder_.create(multisampledDepthTextureType->dim(), + builder_.create()); } // Pointers and references with differing accesses should not result in a @@ -3715,7 +3715,7 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { push_type(spv::Op::OpTypeVoid, {result}); return true; }, - [&](const sem::StorageTexture* tex) { + [&](const type::StorageTexture* tex) { if (!GenerateTextureType(tex, result)) { return false; } @@ -3723,15 +3723,15 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { // Register all three access types of StorageTexture names. In // SPIR-V, we must output a single type, while the variable is // annotated with the access type. Doing this ensures we de-dupe. - type_to_id_[builder_.create( + type_to_id_[builder_.create( tex->dim(), tex->texel_format(), ast::Access::kRead, tex->type())] = id; - type_to_id_[builder_.create( + type_to_id_[builder_.create( tex->dim(), tex->texel_format(), ast::Access::kWrite, tex->type())] = id; - type_to_id_[builder_.create( + type_to_id_[builder_.create( tex->dim(), tex->texel_format(), ast::Access::kReadWrite, tex->type())] = id; return true; }, - [&](const sem::Texture* tex) { return GenerateTextureType(tex, result); }, + [&](const type::Texture* tex) { return GenerateTextureType(tex, result); }, [&](const sem::Sampler* s) { push_type(spv::Op::OpTypeSampler, {result}); @@ -3758,8 +3758,8 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { }); } -bool Builder::GenerateTextureType(const sem::Texture* texture, const Operand& result) { - if (texture->Is()) { +bool Builder::GenerateTextureType(const type::Texture* texture, const Operand& result) { + if (texture->Is()) { TINT_ICE(Writer, builder_.Diagnostics()) << "Multiplanar external texture transform was not run."; return false; @@ -3774,9 +3774,9 @@ bool Builder::GenerateTextureType(const sem::Texture* texture, const Operand& re uint32_t dim_literal = SpvDim2D; if (dim == ast::TextureDimension::k1d) { dim_literal = SpvDim1D; - if (texture->Is()) { + if (texture->Is()) { push_capability(SpvCapabilitySampled1D); - } else if (texture->Is()) { + } else if (texture->Is()) { push_capability(SpvCapabilityImage1D); } } @@ -3788,7 +3788,7 @@ bool Builder::GenerateTextureType(const sem::Texture* texture, const Operand& re } uint32_t ms_literal = 0u; - if (texture->IsAnyOf()) { + if (texture->IsAnyOf()) { ms_literal = 1u; } @@ -3798,33 +3798,35 @@ bool Builder::GenerateTextureType(const sem::Texture* texture, const Operand& re // Using anything other than 0 is problematic on various Vulkan drivers. uint32_t sampled_literal = 2u; - if (texture->IsAnyOf()) { + if (texture->IsAnyOf()) { sampled_literal = 1u; } if (dim == ast::TextureDimension::kCubeArray) { - if (texture->IsAnyOf()) { + if (texture->IsAnyOf()) { push_capability(SpvCapabilitySampledCubeArray); } } uint32_t type_id = Switch( texture, - [&](const sem::DepthTexture*) { return GenerateTypeIfNeeded(builder_.create()); }, - [&](const sem::DepthMultisampledTexture*) { + [&](const type::DepthTexture*) { return GenerateTypeIfNeeded(builder_.create()); }, - [&](const sem::SampledTexture* t) { return GenerateTypeIfNeeded(t->type()); }, - [&](const sem::MultisampledTexture* t) { return GenerateTypeIfNeeded(t->type()); }, - [&](const sem::StorageTexture* t) { return GenerateTypeIfNeeded(t->type()); }, + [&](const type::DepthMultisampledTexture*) { + return GenerateTypeIfNeeded(builder_.create()); + }, + [&](const type::SampledTexture* t) { return GenerateTypeIfNeeded(t->type()); }, + [&](const type::MultisampledTexture* t) { return GenerateTypeIfNeeded(t->type()); }, + [&](const type::StorageTexture* t) { return GenerateTypeIfNeeded(t->type()); }, [&](Default) { return 0u; }); if (type_id == 0u) { return false; } uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown; - if (auto* t = texture->As()) { + if (auto* t = texture->As()) { format_literal = convert_texel_format_to_spv(t->texel_format()); } diff --git a/src/tint/writer/spirv/builder.h b/src/tint/writer/spirv/builder.h index 91fb628985..21dcf83703 100644 --- a/src/tint/writer/spirv/builder.h +++ b/src/tint/writer/spirv/builder.h @@ -36,7 +36,7 @@ #include "src/tint/program_builder.h" #include "src/tint/scope_stack.h" #include "src/tint/sem/builtin.h" -#include "src/tint/sem/storage_texture.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/writer/spirv/function.h" #include "src/tint/writer/spirv/scalar_constant.h" @@ -473,7 +473,7 @@ class Builder { /// @param texture the texture to generate /// @param result the result operand /// @returns true if the texture was successfully generated - bool GenerateTextureType(const sem::Texture* texture, const Operand& result); + bool GenerateTextureType(const type::Texture* texture, const Operand& result); /// Generates an array type declaration /// @param ary the array to generate /// @param result the result operand diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc index caa7d9c454..9b059805bb 100644 --- a/src/tint/writer/spirv/builder_builtin_test.cc +++ b/src/tint/writer/spirv/builder_builtin_test.cc @@ -14,7 +14,7 @@ #include "src/tint/ast/call_statement.h" #include "src/tint/ast/stage_attribute.h" -#include "src/tint/sem/depth_texture.h" +#include "src/tint/type/depth_texture.h" #include "src/tint/utils/string.h" #include "src/tint/writer/spirv/spv_dump.h" #include "src/tint/writer/spirv/test_helper.h" diff --git a/src/tint/writer/spirv/builder_type_test.cc b/src/tint/writer/spirv/builder_type_test.cc index 4ab8aa0268..5e00675dc3 100644 --- a/src/tint/writer/spirv/builder_type_test.cc +++ b/src/tint/writer/spirv/builder_type_test.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/writer/spirv/spv_dump.h" #include "src/tint/writer/spirv/test_helper.h" @@ -631,7 +631,7 @@ INSTANTIATE_TEST_SUITE_P( PtrData{ast::AddressSpace::kFunction, SpvStorageClassFunction})); TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) { - auto* two_d = create(ast::TextureDimension::k2d); + auto* two_d = create(ast::TextureDimension::k2d); spirv::Builder& b = Build(); @@ -645,7 +645,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) { } TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) { - auto* two_d_array = create(ast::TextureDimension::k2dArray); + auto* two_d_array = create(ast::TextureDimension::k2dArray); spirv::Builder& b = Build(); @@ -659,7 +659,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) { } TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) { - auto* cube = create(ast::TextureDimension::kCube); + auto* cube = create(ast::TextureDimension::kCube); spirv::Builder& b = Build(); @@ -674,7 +674,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) { } TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) { - auto* cube_array = create(ast::TextureDimension::kCubeArray); + auto* cube_array = create(ast::TextureDimension::kCubeArray); spirv::Builder& b = Build(); @@ -692,7 +692,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) { TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) { auto* i32 = create(); - auto* ms = create(ast::TextureDimension::k2d, i32); + auto* ms = create(ast::TextureDimension::k2d, i32); spirv::Builder& b = Build(); @@ -705,7 +705,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) { TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) { auto* u32 = create(); - auto* ms = create(ast::TextureDimension::k2d, u32); + auto* ms = create(ast::TextureDimension::k2d, u32); spirv::Builder& b = Build(); @@ -719,7 +719,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) { TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) { auto* f32 = create(); - auto* ms = create(ast::TextureDimension::k2d, f32); + auto* ms = create(ast::TextureDimension::k2d, f32); spirv::Builder& b = Build(); @@ -732,7 +732,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { - auto* s = create(ast::TextureDimension::k1d, create()); + auto* s = create(ast::TextureDimension::k1d, create()); spirv::Builder& b = Build(); @@ -750,7 +750,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { auto* u32 = create(); - auto* s = create(ast::TextureDimension::k1d, u32); + auto* s = create(ast::TextureDimension::k1d, u32); spirv::Builder& b = Build(); @@ -768,7 +768,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { auto* f32 = create(); - auto* s = create(ast::TextureDimension::k1d, f32); + auto* s = create(ast::TextureDimension::k1d, f32); spirv::Builder& b = Build(); @@ -786,7 +786,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { auto* f32 = create(); - auto* s = create(ast::TextureDimension::k2d, f32); + auto* s = create(ast::TextureDimension::k2d, f32); spirv::Builder& b = Build(); @@ -800,7 +800,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { auto* f32 = create(); - auto* s = create(ast::TextureDimension::k2dArray, f32); + auto* s = create(ast::TextureDimension::k2dArray, f32); spirv::Builder& b = Build(); @@ -814,7 +814,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { auto* f32 = create(); - auto* s = create(ast::TextureDimension::k3d, f32); + auto* s = create(ast::TextureDimension::k3d, f32); spirv::Builder& b = Build(); @@ -828,7 +828,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { auto* f32 = create(); - auto* s = create(ast::TextureDimension::kCube, f32); + auto* s = create(ast::TextureDimension::kCube, f32); spirv::Builder& b = Build(); @@ -843,7 +843,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { auto* f32 = create(); - auto* s = create(ast::TextureDimension::kCubeArray, f32); + auto* s = create(ast::TextureDimension::kCubeArray, f32); spirv::Builder& b = Build(); diff --git a/src/tint/writer/wgsl/generator_impl.h b/src/tint/writer/wgsl/generator_impl.h index 7c76cbd364..71c3bd1651 100644 --- a/src/tint/writer/wgsl/generator_impl.h +++ b/src/tint/writer/wgsl/generator_impl.h @@ -34,8 +34,8 @@ #include "src/tint/ast/switch_statement.h" #include "src/tint/ast/unary_op_expression.h" #include "src/tint/program.h" -#include "src/tint/sem/storage_texture.h" #include "src/tint/sem/struct.h" +#include "src/tint/type/storage_texture.h" #include "src/tint/writer/text_generator.h" namespace tint::writer::wgsl { diff --git a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc index db45e79e8d..939b5b3919 100644 --- a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc +++ b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc @@ -14,7 +14,7 @@ #include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/variable_decl_statement.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/writer/wgsl/test_helper.h" using namespace tint::number_suffixes; // NOLINT diff --git a/src/tint/writer/wgsl/generator_impl_type_test.cc b/src/tint/writer/wgsl/generator_impl_type_test.cc index 50bc7df403..a1c350536d 100644 --- a/src/tint/writer/wgsl/generator_impl_type_test.cc +++ b/src/tint/writer/wgsl/generator_impl_type_test.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/depth_texture.h" -#include "src/tint/sem/multisampled_texture.h" -#include "src/tint/sem/sampled_texture.h" +#include "src/tint/type/depth_texture.h" +#include "src/tint/type/multisampled_texture.h" +#include "src/tint/type/sampled_texture.h" #include "src/tint/writer/wgsl/test_helper.h" using namespace tint::number_suffixes; // NOLINT