Move texture types to type/ folder.

This CL moves the texture types into the type folder and namespace.

Bug: tint:1718
Change-Id: I3088e4f8174855043313f4497b384b3947dc6aaf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113282
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair 2022-12-08 14:14:10 +00:00 committed by Dawn LUCI CQ
parent c9949ac59e
commit 4595fb7989
81 changed files with 568 additions and 567 deletions

View File

@ -430,11 +430,8 @@ libtint_source_set("libtint_core_all_src") {
"sem/call.h", "sem/call.h",
"sem/call_target.h", "sem/call_target.h",
"sem/constant.h", "sem/constant.h",
"sem/depth_multisampled_texture.h",
"sem/depth_texture.h",
"sem/evaluation_stage.h", "sem/evaluation_stage.h",
"sem/expression.h", "sem/expression.h",
"sem/external_texture.h",
"sem/f16.h", "sem/f16.h",
"sem/f32.h", "sem/f32.h",
"sem/for_loop_statement.h", "sem/for_loop_statement.h",
@ -446,18 +443,15 @@ libtint_source_set("libtint_core_all_src") {
"sem/materialize.h", "sem/materialize.h",
"sem/matrix.h", "sem/matrix.h",
"sem/module.h", "sem/module.h",
"sem/multisampled_texture.h",
"sem/node.h", "sem/node.h",
"sem/parameter_usage.h", "sem/parameter_usage.h",
"sem/pipeline_stage_set.h", "sem/pipeline_stage_set.h",
"sem/pointer.h", "sem/pointer.h",
"sem/reference.h", "sem/reference.h",
"sem/sampled_texture.h",
"sem/sampler.h", "sem/sampler.h",
"sem/sampler_texture_pair.h", "sem/sampler_texture_pair.h",
"sem/storage_texture.h", "sem/struct.h",
"sem/switch_statement.h", "sem/switch_statement.h",
"sem/texture.h",
"sem/type_conversion.h", "sem/type_conversion.h",
"sem/type_initializer.h", "sem/type_initializer.h",
"sem/type_mappings.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.cc",
"transform/zero_init_workgroup_memory.h", "transform/zero_init_workgroup_memory.h",
"type/array_count.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/node.h",
"type/sampled_texture.h",
"type/storage_texture.h",
"type/texture.h",
"type/type.h", "type/type.h",
"type/type_manager.h", "type/type_manager.h",
"utils/bitcast.h", "utils/bitcast.h",
@ -662,15 +663,9 @@ libtint_source_set("libtint_sem_src") {
"sem/call_target.h", "sem/call_target.h",
"sem/constant.cc", "sem/constant.cc",
"sem/constant.h", "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/evaluation_stage.h",
"sem/expression.cc", "sem/expression.cc",
"sem/expression.h", "sem/expression.h",
"sem/external_texture.cc",
"sem/external_texture.h",
"sem/f16.cc", "sem/f16.cc",
"sem/f16.h", "sem/f16.h",
"sem/f32.cc", "sem/f32.cc",
@ -695,8 +690,6 @@ libtint_source_set("libtint_sem_src") {
"sem/member_accessor_expression.cc", "sem/member_accessor_expression.cc",
"sem/module.cc", "sem/module.cc",
"sem/module.h", "sem/module.h",
"sem/multisampled_texture.cc",
"sem/multisampled_texture.h",
"sem/node.cc", "sem/node.cc",
"sem/node.h", "sem/node.h",
"sem/parameter_usage.cc", "sem/parameter_usage.cc",
@ -706,18 +699,13 @@ libtint_source_set("libtint_sem_src") {
"sem/pointer.h", "sem/pointer.h",
"sem/reference.cc", "sem/reference.cc",
"sem/reference.h", "sem/reference.h",
"sem/sampled_texture.cc",
"sem/sampled_texture.h",
"sem/sampler.cc", "sem/sampler.cc",
"sem/sampler.h", "sem/sampler.h",
"sem/statement.cc", "sem/statement.cc",
"sem/storage_texture.cc",
"sem/storage_texture.h",
"sem/struct.cc", "sem/struct.cc",
"sem/struct.h",
"sem/switch_statement.cc", "sem/switch_statement.cc",
"sem/switch_statement.h", "sem/switch_statement.h",
"sem/texture.cc",
"sem/texture.h",
"sem/type_conversion.cc", "sem/type_conversion.cc",
"sem/type_conversion.h", "sem/type_conversion.h",
"sem/type_initializer.cc", "sem/type_initializer.cc",
@ -741,8 +729,22 @@ libtint_source_set("libtint_type_src") {
sources = [ sources = [
"type/array_count.cc", "type/array_count.cc",
"type/array_count.h", "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.cc",
"type/node.h", "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.cc",
"type/type.h", "type/type.h",
"type/type_manager.cc", "type/type_manager.cc",
@ -1063,8 +1065,6 @@ if (tint_build_unittests) {
"ast/case_statement_test.cc", "ast/case_statement_test.cc",
"ast/compound_assignment_statement_test.cc", "ast/compound_assignment_statement_test.cc",
"ast/continue_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/discard_statement_test.cc",
"ast/enable_test.cc", "ast/enable_test.cc",
"ast/extension_test.cc", "ast/extension_test.cc",
@ -1206,22 +1206,15 @@ if (tint_build_unittests) {
"sem/atomic_test.cc", "sem/atomic_test.cc",
"sem/bool_test.cc", "sem/bool_test.cc",
"sem/builtin_test.cc", "sem/builtin_test.cc",
"sem/depth_multisampled_texture_test.cc",
"sem/depth_texture_test.cc",
"sem/expression_test.cc", "sem/expression_test.cc",
"sem/external_texture_test.cc",
"sem/f16_test.cc", "sem/f16_test.cc",
"sem/f32_test.cc", "sem/f32_test.cc",
"sem/i32_test.cc", "sem/i32_test.cc",
"sem/matrix_test.cc", "sem/matrix_test.cc",
"sem/multisampled_texture_test.cc",
"sem/pointer_test.cc", "sem/pointer_test.cc",
"sem/reference_test.cc", "sem/reference_test.cc",
"sem/sampled_texture_test.cc",
"sem/sampler_test.cc", "sem/sampler_test.cc",
"sem/storage_texture_test.cc",
"sem/struct_test.cc", "sem/struct_test.cc",
"sem/texture_test.cc",
"sem/u32_test.cc", "sem/u32_test.cc",
"sem/vector_test.cc", "sem/vector_test.cc",
] ]
@ -1229,6 +1222,13 @@ if (tint_build_unittests) {
tint_unittests_source_set("tint_unittests_type_src") { tint_unittests_source_set("tint_unittests_type_src") {
sources = [ 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_manager_test.cc",
"type/type_test.cc", "type/type_test.cc",
] ]

View File

@ -320,15 +320,9 @@ list(APPEND TINT_LIB_SRCS
sem/call.h sem/call.h
sem/constant.cc sem/constant.cc
sem/constant.h 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/evaluation_stage.h
sem/expression.cc sem/expression.cc
sem/expression.h sem/expression.h
sem/external_texture.cc
sem/external_texture.h
sem/f16.cc sem/f16.cc
sem/f16.h sem/f16.h
sem/f32.cc sem/f32.cc
@ -353,8 +347,6 @@ list(APPEND TINT_LIB_SRCS
sem/member_accessor_expression.cc sem/member_accessor_expression.cc
sem/module.cc sem/module.cc
sem/module.h sem/module.h
sem/multisampled_texture.cc
sem/multisampled_texture.h
sem/node.cc sem/node.cc
sem/node.h sem/node.h
sem/pipeline_stage_set.h sem/pipeline_stage_set.h
@ -362,19 +354,13 @@ list(APPEND TINT_LIB_SRCS
sem/pointer.h sem/pointer.h
sem/reference.cc sem/reference.cc
sem/reference.h sem/reference.h
sem/sampled_texture.cc
sem/sampled_texture.h
sem/sampler_texture_pair.h sem/sampler_texture_pair.h
sem/sampler.cc sem/sampler.cc
sem/sampler.h sem/sampler.h
sem/statement.cc sem/statement.cc
sem/storage_texture.cc
sem/storage_texture.h
sem/struct.cc sem/struct.cc
sem/switch_statement.cc sem/switch_statement.cc
sem/switch_statement.h sem/switch_statement.h
sem/texture.cc
sem/texture.h
sem/type_initializer.cc sem/type_initializer.cc
sem/type_initializer.h sem/type_initializer.h
sem/type_conversion.cc sem/type_conversion.cc
@ -499,8 +485,22 @@ list(APPEND TINT_LIB_SRCS
transform/zero_init_workgroup_memory.h transform/zero_init_workgroup_memory.h
type/array_count.cc type/array_count.cc
type/array_count.h 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.cc
type/node.h 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.cc
type/type.h type/type.h
type/type_manager.cc type/type_manager.cc
@ -924,22 +924,15 @@ if(TINT_BUILD_TESTS)
sem/atomic.cc sem/atomic.cc
sem/bool_test.cc sem/bool_test.cc
sem/builtin_test.cc sem/builtin_test.cc
sem/depth_multisampled_texture_test.cc
sem/depth_texture_test.cc
sem/expression_test.cc sem/expression_test.cc
sem/external_texture_test.cc
sem/f16_test.cc sem/f16_test.cc
sem/f32_test.cc sem/f32_test.cc
sem/i32_test.cc sem/i32_test.cc
sem/matrix_test.cc sem/matrix_test.cc
sem/multisampled_texture_test.cc
sem/pointer_test.cc sem/pointer_test.cc
sem/reference_test.cc sem/reference_test.cc
sem/sampled_texture_test.cc
sem/sampler_test.cc sem/sampler_test.cc
sem/storage_texture_test.cc
sem/struct_test.cc sem/struct_test.cc
sem/texture_test.cc
sem/u32_test.cc sem/u32_test.cc
sem/vector_test.cc sem/vector_test.cc
source_test.cc source_test.cc
@ -949,6 +942,13 @@ if(TINT_BUILD_TESTS)
text/unicode_test.cc text/unicode_test.cc
traits_test.cc traits_test.cc
transform/transform_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_test.cc
type/type_manager_test.cc type/type_manager_test.cc
utils/bitcast_test.cc utils/bitcast_test.cc

View File

@ -14,9 +14,9 @@
#include "src/tint/ast/builtin_texture_helper_test.h" #include "src/tint/ast/builtin_texture_helper_test.h"
#include "src/tint/sem/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/sem/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
using namespace tint::number_suffixes; // NOLINT using namespace tint::number_suffixes; // NOLINT

View File

@ -19,7 +19,7 @@
#include "src/tint/ast/access.h" #include "src/tint/ast/access.h"
#include "src/tint/program_builder.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 { namespace tint::ast::builtin::test {

View File

@ -31,24 +31,24 @@
#include "src/tint/sem/array.h" #include "src/tint/sem/array.h"
#include "src/tint/sem/bool.h" #include "src/tint/sem/bool.h"
#include "src/tint/sem/call.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/f16.h"
#include "src/tint/sem/f32.h" #include "src/tint/sem/f32.h"
#include "src/tint/sem/function.h" #include "src/tint/sem/function.h"
#include "src/tint/sem/i32.h" #include "src/tint/sem/i32.h"
#include "src/tint/sem/matrix.h" #include "src/tint/sem/matrix.h"
#include "src/tint/sem/module.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/statement.h"
#include "src/tint/sem/storage_texture.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/u32.h" #include "src/tint/sem/u32.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/sem/vector.h" #include "src/tint/sem/vector.h"
#include "src/tint/sem/void.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/math.h"
#include "src/tint/utils/string.h" #include "src/tint/utils/string.h"
#include "src/tint/utils/unique_vector.h" #include "src/tint/utils/unique_vector.h"
@ -513,7 +513,7 @@ std::vector<ResourceBinding> Inspector::GetTextureResourceBindings(
entry.bind_group = binding_info.group; entry.bind_group = binding_info.group;
entry.binding = binding_info.binding; entry.binding = binding_info.binding;
auto* tex = var->Type()->UnwrapRef()->As<sem::Texture>(); auto* tex = var->Type()->UnwrapRef()->As<type::Texture>();
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(tex->dim()); entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(tex->dim());
result.push_back(entry); result.push_back(entry);
@ -524,19 +524,19 @@ std::vector<ResourceBinding> Inspector::GetTextureResourceBindings(
std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings( std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings(
const std::string& entry_point) { const std::string& entry_point) {
return GetTextureResourceBindings(entry_point, &TypeInfo::Of<sem::DepthTexture>(), return GetTextureResourceBindings(entry_point, &TypeInfo::Of<type::DepthTexture>(),
ResourceBinding::ResourceType::kDepthTexture); ResourceBinding::ResourceType::kDepthTexture);
} }
std::vector<ResourceBinding> Inspector::GetDepthMultisampledTextureResourceBindings( std::vector<ResourceBinding> Inspector::GetDepthMultisampledTextureResourceBindings(
const std::string& entry_point) { const std::string& entry_point) {
return GetTextureResourceBindings(entry_point, &TypeInfo::Of<sem::DepthMultisampledTexture>(), return GetTextureResourceBindings(entry_point, &TypeInfo::Of<type::DepthMultisampledTexture>(),
ResourceBinding::ResourceType::kDepthMultisampledTexture); ResourceBinding::ResourceType::kDepthMultisampledTexture);
} }
std::vector<ResourceBinding> Inspector::GetExternalTextureResourceBindings( std::vector<ResourceBinding> Inspector::GetExternalTextureResourceBindings(
const std::string& entry_point) { const std::string& entry_point) {
return GetTextureResourceBindings(entry_point, &TypeInfo::Of<sem::ExternalTexture>(), return GetTextureResourceBindings(entry_point, &TypeInfo::Of<type::ExternalTexture>(),
ResourceBinding::ResourceType::kExternalTexture); ResourceBinding::ResourceType::kExternalTexture);
} }
@ -766,14 +766,14 @@ std::vector<ResourceBinding> Inspector::GetSampledTextureResourceBindingsImpl(
entry.bind_group = binding_info.group; entry.bind_group = binding_info.group;
entry.binding = binding_info.binding; entry.binding = binding_info.binding;
auto* texture_type = var->Type()->UnwrapRef()->As<sem::Texture>(); auto* texture_type = var->Type()->UnwrapRef()->As<type::Texture>();
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(texture_type->dim()); entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(texture_type->dim());
const type::Type* base_type = nullptr; const type::Type* base_type = nullptr;
if (multisampled_only) { if (multisampled_only) {
base_type = texture_type->As<sem::MultisampledTexture>()->type(); base_type = texture_type->As<type::MultisampledTexture>()->type();
} else { } else {
base_type = texture_type->As<sem::SampledTexture>()->type(); base_type = texture_type->As<type::SampledTexture>()->type();
} }
entry.sampled_kind = BaseTypeToSampledKind(base_type); entry.sampled_kind = BaseTypeToSampledKind(base_type);
@ -792,11 +792,11 @@ std::vector<ResourceBinding> Inspector::GetStorageTextureResourceBindingsImpl(
auto* func_sem = program_->Sem().Get(func); auto* func_sem = program_->Sem().Get(func);
std::vector<ResourceBinding> result; std::vector<ResourceBinding> result;
for (auto& ref : func_sem->TransitivelyReferencedVariablesOfType<sem::StorageTexture>()) { for (auto& ref : func_sem->TransitivelyReferencedVariablesOfType<type::StorageTexture>()) {
auto* var = ref.first; auto* var = ref.first;
auto binding_info = ref.second; auto binding_info = ref.second;
auto* texture_type = var->Type()->UnwrapRef()->As<sem::StorageTexture>(); auto* texture_type = var->Type()->UnwrapRef()->As<type::StorageTexture>();
ResourceBinding entry; ResourceBinding entry;
entry.resource_type = ResourceBinding::ResourceType::kWriteOnlyStorageTexture; entry.resource_type = ResourceBinding::ResourceType::kWriteOnlyStorageTexture;

View File

@ -22,11 +22,11 @@
#include "src/tint/inspector/test_inspector_builder.h" #include "src/tint/inspector/test_inspector_builder.h"
#include "src/tint/inspector/test_inspector_runner.h" #include "src/tint/inspector/test_inspector_runner.h"
#include "src/tint/program_builder.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/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" #include "tint/tint.h"
using namespace tint::number_suffixes; // NOLINT using namespace tint::number_suffixes; // NOLINT
@ -3227,8 +3227,8 @@ fn main(@location(0) fragUV: vec2<f32>,
auto result_1 = inspector.GetSamplerTextureUses("main"); auto result_1 = inspector.GetSamplerTextureUses("main");
ASSERT_FALSE(inspector.has_error()) << inspector.error(); ASSERT_FALSE(inspector.has_error()) << inspector.error();
EXPECT_EQ((utils::Vector<tint::sem::SamplerTexturePair, 4>(result_0)), EXPECT_EQ((utils::Vector<sem::SamplerTexturePair, 4>(result_0)),
(utils::Vector<tint::sem::SamplerTexturePair, 4>(result_1))); (utils::Vector<sem::SamplerTexturePair, 4>(result_1)));
} }
TEST_F(InspectorGetSamplerTextureUsesTest, BothIndirect) { TEST_F(InspectorGetSamplerTextureUsesTest, BothIndirect) {

View File

@ -26,11 +26,11 @@
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/workgroup_attribute.h" #include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/program_builder.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/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" #include "tint/tint.h"
namespace tint::inspector { namespace tint::inspector {

View File

@ -94,20 +94,20 @@
#include "src/tint/sem/array_count.h" #include "src/tint/sem/array_count.h"
#include "src/tint/sem/bool.h" #include "src/tint/sem/bool.h"
#include "src/tint/sem/constant.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/f16.h"
#include "src/tint/sem/f32.h" #include "src/tint/sem/f32.h"
#include "src/tint/sem/i32.h" #include "src/tint/sem/i32.h"
#include "src/tint/sem/matrix.h" #include "src/tint/sem/matrix.h"
#include "src/tint/sem/multisampled_texture.h"
#include "src/tint/sem/pointer.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/struct.h"
#include "src/tint/sem/u32.h" #include "src/tint/sem/u32.h"
#include "src/tint/sem/vector.h" #include "src/tint/sem/vector.h"
#include "src/tint/sem/void.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 #ifdef CURRENTLY_IN_TINT_PUBLIC_HEADER
#error "internal tint header being #included from tint.h" #error "internal tint header being #included from tint.h"

View File

@ -21,7 +21,7 @@
#include "src/tint/ast/builtin_value.h" #include "src/tint/ast/builtin_value.h"
#include "src/tint/ast/pipeline_stage.h" #include "src/tint/ast/pipeline_stage.h"
#include "src/tint/reader/spirv/fail_stream.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 { namespace tint::reader::spirv {

View File

@ -33,9 +33,9 @@
#include "src/tint/ast/unary_op_expression.h" #include "src/tint/ast/unary_op_expression.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/sem/builtin_type.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/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/hashmap.h"
#include "src/tint/utils/hashset.h" #include "src/tint/utils/hashset.h"

View File

@ -27,9 +27,9 @@
#include "src/tint/ast/type_name.h" #include "src/tint/ast/type_name.h"
#include "src/tint/ast/unary_op_expression.h" #include "src/tint/ast/unary_op_expression.h"
#include "src/tint/reader/spirv/function.h" #include "src/tint/reader/spirv/function.h"
#include "src/tint/sem/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/sem/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
#include "src/tint/utils/unique_vector.h" #include "src/tint/utils/unique_vector.h"
namespace tint::reader::spirv { namespace tint::reader::spirv {

View File

@ -39,10 +39,10 @@
#include "src/tint/ast/vector.h" #include "src/tint/ast/vector.h"
#include "src/tint/ast/workgroup_attribute.h" #include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/reader/wgsl/lexer.h" #include "src/tint/reader/wgsl/lexer.h"
#include "src/tint/sem/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/sem/external_texture.h" #include "src/tint/type/external_texture.h"
#include "src/tint/sem/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
#include "src/tint/utils/reverse.h" #include "src/tint/utils/reverse.h"
#include "src/tint/utils/string.h" #include "src/tint/utils/string.h"

View File

@ -26,7 +26,7 @@
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/reader/wgsl/parser_impl_detail.h" #include "src/tint/reader/wgsl/parser_impl_detail.h"
#include "src/tint/reader/wgsl/token.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 { namespace tint::ast {
class BreakStatement; class BreakStatement;

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/reader/wgsl/parser_impl_test_helper.h" #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 tint::reader::wgsl {
namespace { namespace {

View File

@ -13,9 +13,9 @@
// limitations under the License. // limitations under the License.
#include "src/tint/reader/wgsl/parser_impl_test_helper.h" #include "src/tint/reader/wgsl/parser_impl_test_helper.h"
#include "src/tint/sem/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/sem/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
namespace tint::reader::wgsl { namespace tint::reader::wgsl {
namespace { namespace {

View File

@ -17,7 +17,7 @@
#include "src/tint/ast/matrix.h" #include "src/tint/ast/matrix.h"
#include "src/tint/ast/sampler.h" #include "src/tint/ast/sampler.h"
#include "src/tint/reader/wgsl/parser_impl_test_helper.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 tint::reader::wgsl {
namespace { namespace {

View File

@ -17,7 +17,7 @@
#include "src/tint/ast/matrix.h" #include "src/tint/ast/matrix.h"
#include "src/tint/ast/sampler.h" #include "src/tint/ast/sampler.h"
#include "src/tint/reader/wgsl/parser_impl_test_helper.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 tint::reader::wgsl {
namespace { namespace {

View File

@ -16,7 +16,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/resolver/resolver_test_helper.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 using namespace tint::number_suffixes; // NOLINT

View File

@ -32,9 +32,9 @@
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/function.h" #include "src/tint/sem/function.h"
#include "src/tint/sem/member_accessor_expression.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/statement.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/type/sampled_texture.h"
#include "src/tint/type/test_helper.h" #include "src/tint/type/test_helper.h"
using ::testing::ElementsAre; using ::testing::ElementsAre;

View File

@ -16,7 +16,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/resolver/resolver_test_helper.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; using ::testing::HasSubstr;

View File

@ -24,16 +24,16 @@
#include "src/tint/sem/abstract_int.h" #include "src/tint/sem/abstract_int.h"
#include "src/tint/sem/abstract_numeric.h" #include "src/tint/sem/abstract_numeric.h"
#include "src/tint/sem/atomic.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/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/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_conversion.h"
#include "src/tint/sem/type_initializer.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/hash.h"
#include "src/tint/utils/hashmap.h" #include "src/tint/utils/hashmap.h"
#include "src/tint/utils/math.h" #include "src/tint/utils/math.h"
@ -611,7 +611,7 @@ bool match_texture(MatchState&,
T = ty; T = ty;
return true; return true;
} }
if (auto* v = ty->As<sem::SampledTexture>()) { if (auto* v = ty->As<type::SampledTexture>()) {
if (v->dim() == dim) { if (v->dim() == dim) {
T = v->type(); T = v->type();
return true; return true;
@ -627,9 +627,9 @@ bool match_texture(MatchState&,
const type::Type*& T) { \ const type::Type*& T) { \
return match_texture(state, ty, dim, T); \ return match_texture(state, ty, dim, T); \
} \ } \
const sem::SampledTexture* JOIN(build_texture_, suffix)(MatchState & state, \ const type::SampledTexture* JOIN(build_texture_, suffix)(MatchState & state, \
const type::Type* T) { \ const type::Type* T) { \
return state.builder.create<sem::SampledTexture>(dim, T); \ return state.builder.create<type::SampledTexture>(dim, T); \
} }
DECLARE_SAMPLED_TEXTURE(1d, ast::TextureDimension::k1d) DECLARE_SAMPLED_TEXTURE(1d, ast::TextureDimension::k1d)
@ -648,7 +648,7 @@ bool match_texture_multisampled(MatchState&,
T = ty; T = ty;
return true; return true;
} }
if (auto* v = ty->As<sem::MultisampledTexture>()) { if (auto* v = ty->As<type::MultisampledTexture>()) {
if (v->dim() == dim) { if (v->dim() == dim) {
T = v->type(); T = v->type();
return true; return true;
@ -662,9 +662,9 @@ bool match_texture_multisampled(MatchState&,
const type::Type*& T) { \ const type::Type*& T) { \
return match_texture_multisampled(state, ty, dim, 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) { \ MatchState & state, const type::Type* T) { \
return state.builder.create<sem::MultisampledTexture>(dim, T); \ return state.builder.create<type::MultisampledTexture>(dim, T); \
} }
DECLARE_MULTISAMPLED_TEXTURE(2d, ast::TextureDimension::k2d) 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<Any>()) { if (ty->Is<Any>()) {
return true; 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) \ #define DECLARE_DEPTH_TEXTURE(suffix, dim) \
bool JOIN(match_texture_depth_, suffix)(MatchState & state, const type::Type* ty) { \ bool JOIN(match_texture_depth_, suffix)(MatchState & state, const type::Type* ty) { \
return match_texture_depth(state, ty, dim); \ return match_texture_depth(state, ty, dim); \
} \ } \
const sem::DepthTexture* JOIN(build_texture_depth_, suffix)(MatchState & state) { \ const type::DepthTexture* JOIN(build_texture_depth_, suffix)(MatchState & state) { \
return state.builder.create<sem::DepthTexture>(dim); \ return state.builder.create<type::DepthTexture>(dim); \
} }
DECLARE_DEPTH_TEXTURE(2d, ast::TextureDimension::k2d) 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<Any>()) { if (ty->Is<Any>()) {
return true; return true;
} }
return ty->Is([&](const sem::DepthMultisampledTexture* t) { return ty->Is([&](const type::DepthMultisampledTexture* t) {
return t->dim() == ast::TextureDimension::k2d; return t->dim() == ast::TextureDimension::k2d;
}); });
} }
sem::DepthMultisampledTexture* build_texture_depth_multisampled_2d(MatchState& state) { type::DepthMultisampledTexture* build_texture_depth_multisampled_2d(MatchState& state) {
return state.builder.create<sem::DepthMultisampledTexture>(ast::TextureDimension::k2d); return state.builder.create<type::DepthMultisampledTexture>(ast::TextureDimension::k2d);
} }
bool match_texture_storage(MatchState&, bool match_texture_storage(MatchState&,
@ -714,7 +714,7 @@ bool match_texture_storage(MatchState&,
A = Number::any; A = Number::any;
return true; return true;
} }
if (auto* v = ty->As<sem::StorageTexture>()) { if (auto* v = ty->As<type::StorageTexture>()) {
if (v->dim() == dim) { if (v->dim() == dim) {
F = Number(static_cast<uint32_t>(v->texel_format())); F = Number(static_cast<uint32_t>(v->texel_format()));
A = Number(static_cast<uint32_t>(v->access())); A = Number(static_cast<uint32_t>(v->access()));
@ -729,12 +729,12 @@ bool match_texture_storage(MatchState&,
Number& A) { \ Number& A) { \
return match_texture_storage(state, ty, dim, F, A); \ return match_texture_storage(state, ty, dim, F, A); \
} \ } \
const sem::StorageTexture* JOIN(build_texture_storage_, suffix)(MatchState & state, Number F, \ const type::StorageTexture* JOIN(build_texture_storage_, suffix)(MatchState & state, Number F, \
Number A) { \ Number A) { \
auto format = static_cast<TexelFormat>(F.Value()); \ auto format = static_cast<TexelFormat>(F.Value()); \
auto access = static_cast<Access>(A.Value()); \ auto access = static_cast<Access>(A.Value()); \
auto* T = sem::StorageTexture::SubtypeFor(format, state.builder.Types()); \ auto* T = type::StorageTexture::SubtypeFor(format, state.builder.Types()); \
return state.builder.create<sem::StorageTexture>(dim, format, access, T); \ return state.builder.create<type::StorageTexture>(dim, format, access, T); \
} }
DECLARE_STORAGE_TEXTURE(1d, ast::TextureDimension::k1d) DECLARE_STORAGE_TEXTURE(1d, ast::TextureDimension::k1d)
@ -744,11 +744,11 @@ DECLARE_STORAGE_TEXTURE(3d, ast::TextureDimension::k3d)
#undef DECLARE_STORAGE_TEXTURE #undef DECLARE_STORAGE_TEXTURE
bool match_texture_external(MatchState&, const type::Type* ty) { bool match_texture_external(MatchState&, const type::Type* ty) {
return ty->IsAnyOf<Any, sem::ExternalTexture>(); return ty->IsAnyOf<Any, type::ExternalTexture>();
} }
const sem::ExternalTexture* build_texture_external(MatchState& state) { const type::ExternalTexture* build_texture_external(MatchState& state) {
return state.builder.create<sem::ExternalTexture>(); return state.builder.create<type::ExternalTexture>();
} }
// Builtin types starting with a _ prefix cannot be declared in WGSL, so they // Builtin types starting with a _ prefix cannot be declared in WGSL, so they

View File

@ -20,15 +20,15 @@
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/atomic.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/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_conversion.h"
#include "src/tint/sem/type_initializer.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" #include "src/tint/type/test_helper.h"
namespace tint::resolver { namespace tint::resolver {
@ -97,7 +97,7 @@ TEST_F(IntrinsicTableTest, MatchI32) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* i32 = create<sem::I32>(); auto* i32 = create<sem::I32>();
auto* vec4_f32 = create<sem::Vector>(f32, 4u); auto* vec4_f32 = create<sem::Vector>(f32, 4u);
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k1d, f32); auto* tex = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, i32, i32}, auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, i32, i32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -115,7 +115,7 @@ TEST_F(IntrinsicTableTest, MatchI32) {
TEST_F(IntrinsicTableTest, MismatchI32) { TEST_F(IntrinsicTableTest, MismatchI32) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k1d, f32); auto* tex = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, f32}, auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, f32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
ASSERT_EQ(result.sem, nullptr); ASSERT_EQ(result.sem, nullptr);
@ -279,7 +279,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* vec2_f32 = create<sem::Vector>(f32, 2u); auto* vec2_f32 = create<sem::Vector>(f32, 2u);
auto* vec4_f32 = create<sem::Vector>(f32, 4u); auto* vec4_f32 = create<sem::Vector>(f32, 4u);
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k2d, f32); auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
auto* sampler = create<sem::Sampler>(ast::SamplerKind::kSampler); auto* sampler = create<sem::Sampler>(ast::SamplerKind::kSampler);
auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, sampler, vec2_f32}, auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, sampler, vec2_f32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
@ -299,7 +299,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) {
TEST_F(IntrinsicTableTest, MismatchSampler) { TEST_F(IntrinsicTableTest, MismatchSampler) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* vec2_f32 = create<sem::Vector>(f32, 2u); auto* vec2_f32 = create<sem::Vector>(f32, 2u);
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k2d, f32); auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, f32, vec2_f32}, auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, f32, vec2_f32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
ASSERT_EQ(result.sem, nullptr); ASSERT_EQ(result.sem, nullptr);
@ -311,7 +311,7 @@ TEST_F(IntrinsicTableTest, MatchSampledTexture) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* vec2_i32 = create<sem::Vector>(i32, 2u); auto* vec2_i32 = create<sem::Vector>(i32, 2u);
auto* vec4_f32 = create<sem::Vector>(f32, 4u); auto* vec4_f32 = create<sem::Vector>(f32, 4u);
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k2d, f32); auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -332,7 +332,7 @@ TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* vec2_i32 = create<sem::Vector>(i32, 2u); auto* vec2_i32 = create<sem::Vector>(i32, 2u);
auto* vec4_f32 = create<sem::Vector>(f32, 4u); auto* vec4_f32 = create<sem::Vector>(f32, 4u);
auto* tex = create<sem::MultisampledTexture>(ast::TextureDimension::k2d, f32); auto* tex = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -352,7 +352,7 @@ TEST_F(IntrinsicTableTest, MatchDepthTexture) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* i32 = create<sem::I32>(); auto* i32 = create<sem::I32>();
auto* vec2_i32 = create<sem::Vector>(i32, 2u); auto* vec2_i32 = create<sem::Vector>(i32, 2u);
auto* tex = create<sem::DepthTexture>(ast::TextureDimension::k2d); auto* tex = create<type::DepthTexture>(ast::TextureDimension::k2d);
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -372,7 +372,7 @@ TEST_F(IntrinsicTableTest, MatchDepthMultisampledTexture) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* i32 = create<sem::I32>(); auto* i32 = create<sem::I32>();
auto* vec2_i32 = create<sem::Vector>(i32, 2u); auto* vec2_i32 = create<sem::Vector>(i32, 2u);
auto* tex = create<sem::DepthMultisampledTexture>(ast::TextureDimension::k2d); auto* tex = create<type::DepthMultisampledTexture>(ast::TextureDimension::k2d);
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -393,7 +393,7 @@ TEST_F(IntrinsicTableTest, MatchExternalTexture) {
auto* i32 = create<sem::I32>(); auto* i32 = create<sem::I32>();
auto* vec2_i32 = create<sem::Vector>(i32, 2u); auto* vec2_i32 = create<sem::Vector>(i32, 2u);
auto* vec4_f32 = create<sem::Vector>(f32, 4u); auto* vec4_f32 = create<sem::Vector>(f32, 4u);
auto* tex = create<sem::ExternalTexture>(); auto* tex = create<type::ExternalTexture>();
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32}, auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -412,9 +412,9 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
auto* i32 = create<sem::I32>(); auto* i32 = create<sem::I32>();
auto* vec2_i32 = create<sem::Vector>(i32, 2u); auto* vec2_i32 = create<sem::Vector>(i32, 2u);
auto* vec4_f32 = create<sem::Vector>(f32, 4u); auto* vec4_f32 = create<sem::Vector>(f32, 4u);
auto* subtype = sem::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types()); auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types());
auto* tex = create<sem::StorageTexture>(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, auto* tex = create<type::StorageTexture>(
ast::Access::kWrite, subtype); ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite, subtype);
auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32}, auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
@ -628,7 +628,7 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) {
} }
TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) { TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
auto* tex = create<sem::DepthTexture>(ast::TextureDimension::k2d); auto* tex = create<type::DepthTexture>(ast::TextureDimension::k2d);
auto* bool_ = create<sem::Bool>(); auto* bool_ = create<sem::Bool>();
table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{tex, bool_}, table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{tex, bool_},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});

View File

@ -59,8 +59,6 @@
#include "src/tint/sem/atomic.h" #include "src/tint/sem/atomic.h"
#include "src/tint/sem/break_if_statement.h" #include "src/tint/sem/break_if_statement.h"
#include "src/tint/sem/call.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/for_loop_statement.h"
#include "src/tint/sem/function.h" #include "src/tint/sem/function.h"
#include "src/tint/sem/if_statement.h" #include "src/tint/sem/if_statement.h"
@ -69,19 +67,21 @@
#include "src/tint/sem/materialize.h" #include "src/tint/sem/materialize.h"
#include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/member_accessor_expression.h"
#include "src/tint/sem/module.h" #include "src/tint/sem/module.h"
#include "src/tint/sem/multisampled_texture.h"
#include "src/tint/sem/pointer.h" #include "src/tint/sem/pointer.h"
#include "src/tint/sem/reference.h" #include "src/tint/sem/reference.h"
#include "src/tint/sem/sampled_texture.h"
#include "src/tint/sem/sampler.h" #include "src/tint/sem/sampler.h"
#include "src/tint/sem/statement.h" #include "src/tint/sem/statement.h"
#include "src/tint/sem/storage_texture.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/switch_statement.h" #include "src/tint/sem/switch_statement.h"
#include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_conversion.h"
#include "src/tint/sem/type_initializer.h" #include "src/tint/sem/type_initializer.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/sem/while_statement.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/defer.h"
#include "src/tint/utils/math.h" #include "src/tint/utils/math.h"
#include "src/tint/utils/reverse.h" #include "src/tint/utils/reverse.h"
@ -279,9 +279,9 @@ type::Type* Resolver::Type(const ast::Type* ty) {
return nullptr; return nullptr;
}, },
[&](const ast::Sampler* t) { return builder_->create<sem::Sampler>(t->kind); }, [&](const ast::Sampler* t) { return builder_->create<sem::Sampler>(t->kind); },
[&](const ast::SampledTexture* t) -> sem::SampledTexture* { [&](const ast::SampledTexture* t) -> type::SampledTexture* {
if (auto* el = Type(t->type)) { if (auto* el = Type(t->type)) {
auto* sem = builder_->create<sem::SampledTexture>(t->dim, el); auto* sem = builder_->create<type::SampledTexture>(t->dim, el);
if (!validator_.SampledTexture(sem, t->source)) { if (!validator_.SampledTexture(sem, t->source)) {
return nullptr; return nullptr;
} }
@ -289,9 +289,9 @@ type::Type* Resolver::Type(const ast::Type* ty) {
} }
return nullptr; return nullptr;
}, },
[&](const ast::MultisampledTexture* t) -> sem::MultisampledTexture* { [&](const ast::MultisampledTexture* t) -> type::MultisampledTexture* {
if (auto* el = Type(t->type)) { if (auto* el = Type(t->type)) {
auto* sem = builder_->create<sem::MultisampledTexture>(t->dim, el); auto* sem = builder_->create<type::MultisampledTexture>(t->dim, el);
if (!validator_.MultisampledTexture(sem, t->source)) { if (!validator_.MultisampledTexture(sem, t->source)) {
return nullptr; return nullptr;
} }
@ -299,20 +299,20 @@ type::Type* Resolver::Type(const ast::Type* ty) {
} }
return nullptr; return nullptr;
}, },
[&](const ast::DepthTexture* t) { return builder_->create<sem::DepthTexture>(t->dim); }, [&](const ast::DepthTexture* t) { return builder_->create<type::DepthTexture>(t->dim); },
[&](const ast::DepthMultisampledTexture* t) { [&](const ast::DepthMultisampledTexture* t) {
return builder_->create<sem::DepthMultisampledTexture>(t->dim); return builder_->create<type::DepthMultisampledTexture>(t->dim);
}, },
[&](const ast::StorageTexture* t) -> sem::StorageTexture* { [&](const ast::StorageTexture* t) -> type::StorageTexture* {
if (auto* el = Type(t->type)) { if (auto* el = Type(t->type)) {
if (!validator_.StorageTexture(t)) { if (!validator_.StorageTexture(t)) {
return nullptr; return nullptr;
} }
return builder_->create<sem::StorageTexture>(t->dim, t->format, t->access, el); return builder_->create<type::StorageTexture>(t->dim, t->format, t->access, el);
} }
return nullptr; return nullptr;
}, },
[&](const ast::ExternalTexture*) { return builder_->create<sem::ExternalTexture>(); }, [&](const ast::ExternalTexture*) { return builder_->create<type::ExternalTexture>(); },
[&](Default) { [&](Default) {
auto* resolved = sem_.ResolvedSymbol(ty); auto* resolved = sem_.ResolvedSymbol(ty);
return Switch( return Switch(
@ -2390,7 +2390,7 @@ void Resolver::CollectTextureSamplerPairs(const sem::Builtin* builtin,
} }
if (auto* user = args[static_cast<size_t>(texture_index)]->As<sem::VariableUser>()) { if (auto* user = args[static_cast<size_t>(texture_index)]->As<sem::VariableUser>()) {
auto* texture = user->Variable(); auto* texture = user->Variable();
if (!texture->Type()->UnwrapRef()->Is<sem::StorageTexture>()) { if (!texture->Type()->UnwrapRef()->Is<type::StorageTexture>()) {
int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler); int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler);
const sem::Variable* sampler = const sem::Variable* sampler =
sampler_index != -1 sampler_index != -1

View File

@ -40,10 +40,10 @@
#include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/member_accessor_expression.h"
#include "src/tint/sem/module.h" #include "src/tint/sem/module.h"
#include "src/tint/sem/reference.h" #include "src/tint/sem/reference.h"
#include "src/tint/sem/sampled_texture.h"
#include "src/tint/sem/statement.h" #include "src/tint/sem/statement.h"
#include "src/tint/sem/switch_statement.h" #include "src/tint/sem/switch_statement.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/type/sampled_texture.h"
using ::testing::ElementsAre; using ::testing::ElementsAre;
using ::testing::HasSubstr; using ::testing::HasSubstr;

View File

@ -17,8 +17,8 @@
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
#include "src/tint/sem/storage_texture.h" #include "src/tint/type/storage_texture.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"

View File

@ -34,9 +34,9 @@
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/function.h" #include "src/tint/sem/function.h"
#include "src/tint/sem/member_accessor_expression.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/statement.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/type/sampled_texture.h"
using ::testing::ElementsAre; using ::testing::ElementsAre;
using ::testing::HasSubstr; using ::testing::HasSubstr;

View File

@ -52,27 +52,27 @@
#include "src/tint/sem/atomic.h" #include "src/tint/sem/atomic.h"
#include "src/tint/sem/break_if_statement.h" #include "src/tint/sem/break_if_statement.h"
#include "src/tint/sem/call.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/for_loop_statement.h"
#include "src/tint/sem/function.h" #include "src/tint/sem/function.h"
#include "src/tint/sem/if_statement.h" #include "src/tint/sem/if_statement.h"
#include "src/tint/sem/loop_statement.h" #include "src/tint/sem/loop_statement.h"
#include "src/tint/sem/materialize.h" #include "src/tint/sem/materialize.h"
#include "src/tint/sem/member_accessor_expression.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/pointer.h"
#include "src/tint/sem/reference.h" #include "src/tint/sem/reference.h"
#include "src/tint/sem/sampled_texture.h"
#include "src/tint/sem/sampler.h" #include "src/tint/sem/sampler.h"
#include "src/tint/sem/statement.h" #include "src/tint/sem/statement.h"
#include "src/tint/sem/storage_texture.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/switch_statement.h" #include "src/tint/sem/switch_statement.h"
#include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_conversion.h"
#include "src/tint/sem/type_initializer.h" #include "src/tint/sem/type_initializer.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/sem/while_statement.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/defer.h"
#include "src/tint/utils/map.h" #include "src/tint/utils/map.h"
#include "src/tint/utils/math.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 // https://gpuweb.github.io/gpuweb/wgsl.html#storable-types
bool Validator::IsStorable(const type::Type* type) const { bool Validator::IsStorable(const type::Type* type) const {
return IsPlain(type) || type->IsAnyOf<sem::Texture, sem::Sampler>(); return IsPlain(type) || type->IsAnyOf<type::Texture, sem::Sampler>();
} }
const ast::Statement* Validator::ClosestContinuing(bool stop_at_loop, const ast::Statement* Validator::ClosestContinuing(bool stop_at_loop,
@ -319,7 +319,7 @@ bool Validator::StorageTexture(const ast::StorageTexture* t) const {
return true; 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<sem::F32, sem::I32, sem::U32>()) { if (!t->type()->UnwrapRef()->IsAnyOf<sem::F32, sem::I32, sem::U32>()) {
AddError("texture_2d<type>: type must be f32, i32 or u32", source); AddError("texture_2d<type>: type must be f32, i32 or u32", source);
return false; return false;
@ -328,7 +328,8 @@ bool Validator::SampledTexture(const sem::SampledTexture* t, const Source& sourc
return true; 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) { if (t->dim() != ast::TextureDimension::k2d) {
AddError("only 2d multisampled textures are supported", source); AddError("only 2d multisampled textures are supported", source);
return false; 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); AddError("type of function parameter must be constructible", decl->type->source);
return false; return false;
} }
} else if (!var->Type()->IsAnyOf<sem::Texture, sem::Sampler, sem::Pointer>()) { } else if (!var->Type()->IsAnyOf<type::Texture, sem::Sampler, sem::Pointer>()) {
AddError("type of function parameter cannot be " + sem_.TypeNameOf(var->Type()), AddError("type of function parameter cannot be " + sem_.TypeNameOf(var->Type()),
decl->source); decl->source);
return false; 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 // https://www.w3.org/TR/WGSL/#phony-assignment-section
auto* ty = rhs_ty->UnwrapRef(); auto* ty = rhs_ty->UnwrapRef();
if (!ty->IsConstructible() && if (!ty->IsConstructible() &&
!ty->IsAnyOf<sem::Pointer, sem::Texture, sem::Sampler, sem::AbstractNumeric>()) { !ty->IsAnyOf<sem::Pointer, type::Texture, sem::Sampler, sem::AbstractNumeric>()) {
AddError("cannot assign '" + sem_.TypeNameOf(rhs_ty) + AddError("cannot assign '" + sem_.TypeNameOf(rhs_ty) +
"' to '_'. '_' can only be assigned a constructible, pointer, texture or " "' to '_'. '_' can only be assigned a constructible, pointer, texture or "
"sampler type", "sampler type",

View File

@ -361,13 +361,13 @@ class Validator {
/// @param t the texture to validate /// @param t the texture to validate
/// @param source the source of the texture /// @param source the source of the texture
/// @returns true on success, false otherwise /// @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 /// Validates a multisampled texture
/// @param t the texture to validate /// @param t the texture to validate
/// @param source the source of the texture /// @param source the source of the texture
/// @returns true on success, false otherwise /// @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 /// Validates a structure
/// @param str the structure to validate /// @param str the structure to validate

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -15,12 +15,12 @@
#include "src/tint/sem/function.h" #include "src/tint/sem/function.h"
#include "src/tint/ast/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/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" #include "src/tint/utils/transform.h"
TINT_INSTANTIATE_TYPEINFO(tint::sem::Function); TINT_INSTANTIATE_TYPEINFO(tint::sem::Function);
@ -172,13 +172,13 @@ Function::VariableBindings Function::TransitivelyReferencedSampledTextureVariabl
for (auto* global : TransitivelyReferencedGlobals()) { for (auto* global : TransitivelyReferencedGlobals()) {
auto* unwrapped_type = global->Type()->UnwrapRef(); auto* unwrapped_type = global->Type()->UnwrapRef();
auto* texture = unwrapped_type->As<sem::Texture>(); auto* texture = unwrapped_type->As<type::Texture>();
if (texture == nullptr) { if (texture == nullptr) {
continue; continue;
} }
auto is_multisampled = texture->Is<sem::MultisampledTexture>(); auto is_multisampled = texture->Is<type::MultisampledTexture>();
auto is_sampled = texture->Is<sem::SampledTexture>(); auto is_sampled = texture->Is<type::SampledTexture>();
if ((multisampled && !is_multisampled) || (!multisampled && !is_sampled)) { if ((multisampled && !is_multisampled) || (!multisampled && !is_sampled)) {
continue; continue;

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -14,7 +14,7 @@
#include "src/tint/sem/sampler.h" #include "src/tint/sem/sampler.h"
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -14,7 +14,7 @@
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "src/tint/sem/test_helper.h" #include "src/tint/sem/test_helper.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::sem {
namespace { namespace {

View File

@ -894,7 +894,7 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src,
if (polyfill.texture_sample_base_clamp_to_edge_2d_f32) { if (polyfill.texture_sample_base_clamp_to_edge_2d_f32) {
auto& sig = builtin->Signature(); auto& sig = builtin->Signature();
auto* tex = sig.Parameter(sem::ParameterUsage::kTexture); auto* tex = sig.Parameter(sem::ParameterUsage::kTexture);
if (auto* stex = tex->Type()->As<sem::SampledTexture>()) { if (auto* stex = tex->Type()->As<type::SampledTexture>()) {
if (stex->type()->Is<sem::F32>()) { if (stex->type()->Is<sem::F32>()) {
fn = builtin_polyfills.GetOrCreate(builtin, [&] { fn = builtin_polyfills.GetOrCreate(builtin, [&] {
return s.textureSampleBaseClampToEdge_2d_f32(); return s.textureSampleBaseClampToEdge_2d_f32();

View File

@ -141,7 +141,7 @@ struct CombineSamplers::State {
const ast::Type* CreateCombinedASTTypeFor(const sem::Variable* texture, const ast::Type* CreateCombinedASTTypeFor(const sem::Variable* texture,
const sem::Variable* sampler) { const sem::Variable* sampler) {
const type::Type* texture_type = texture->Type()->UnwrapRef(); const type::Type* texture_type = texture->Type()->UnwrapRef();
const sem::DepthTexture* depth = texture_type->As<sem::DepthTexture>(); const type::DepthTexture* depth = texture_type->As<type::DepthTexture>();
if (depth && !sampler) { if (depth && !sampler) {
return ctx.dst->create<ast::SampledTexture>(depth->dim(), ctx.dst->create<ast::F32>()); return ctx.dst->create<ast::SampledTexture>(depth->dim(), ctx.dst->create<ast::F32>());
} else { } else {
@ -159,8 +159,8 @@ struct CombineSamplers::State {
for (auto* global : ctx.src->AST().GlobalVariables()) { for (auto* global : ctx.src->AST().GlobalVariables()) {
auto* global_sem = sem.Get(global)->As<sem::GlobalVariable>(); auto* global_sem = sem.Get(global)->As<sem::GlobalVariable>();
auto* type = sem.Get(global->type); auto* type = sem.Get(global->type);
if (tint::IsAnyOf<sem::Texture, sem::Sampler>(type) && if (tint::IsAnyOf<type::Texture, sem::Sampler>(type) &&
!type->Is<sem::StorageTexture>()) { !type->Is<type::StorageTexture>()) {
ctx.Remove(ctx.src->AST().GlobalDeclarations(), global); ctx.Remove(ctx.src->AST().GlobalDeclarations(), global);
} else if (global->HasBindingPoint()) { } else if (global->HasBindingPoint()) {
auto binding_point = global_sem->BindingPoint(); auto binding_point = global_sem->BindingPoint();
@ -208,7 +208,7 @@ struct CombineSamplers::State {
// Filter out separate textures and samplers from the original // Filter out separate textures and samplers from the original
// function signature. // function signature.
for (auto* param : fn->Parameters()) { for (auto* param : fn->Parameters()) {
if (!param->Type()->IsAnyOf<sem::Texture, sem::Sampler>()) { if (!param->Type()->IsAnyOf<type::Texture, sem::Sampler>()) {
params.Push(ctx.Clone(param->Declaration())); params.Push(ctx.Clone(param->Declaration()));
} }
} }
@ -244,7 +244,7 @@ struct CombineSamplers::State {
call->Arguments()[static_cast<size_t>(texture_index)]; call->Arguments()[static_cast<size_t>(texture_index)];
// We don't want to combine storage textures with anything, since // We don't want to combine storage textures with anything, since
// they never have associated samplers in GLSL. // they never have associated samplers in GLSL.
if (texture->Type()->UnwrapRef()->Is<sem::StorageTexture>()) { if (texture->Type()->UnwrapRef()->Is<type::StorageTexture>()) {
return nullptr; return nullptr;
} }
const sem::Expression* sampler = const sem::Expression* sampler =
@ -256,7 +256,7 @@ struct CombineSamplers::State {
sem::VariablePair new_pair(texture_var, sampler_var); sem::VariablePair new_pair(texture_var, sampler_var);
for (auto* arg : expr->args) { for (auto* arg : expr->args) {
auto* type = ctx.src->TypeOf(arg)->UnwrapRef(); auto* type = ctx.src->TypeOf(arg)->UnwrapRef();
if (type->Is<sem::Texture>()) { if (type->Is<type::Texture>()) {
const ast::Variable* var = const ast::Variable* var =
IsGlobal(new_pair) IsGlobal(new_pair)
? global_combined_texture_samplers_[new_pair] ? global_combined_texture_samplers_[new_pair]
@ -278,7 +278,7 @@ struct CombineSamplers::State {
const ast::Expression* value = const ast::Expression* value =
ctx.dst->Call(ctx.Clone(expr->target.name), args); ctx.dst->Call(ctx.Clone(expr->target.name), args);
if (builtin->Type() == sem::BuiltinType::kTextureLoad && if (builtin->Type() == sem::BuiltinType::kTextureLoad &&
texture_var->Type()->UnwrapRef()->Is<sem::DepthTexture>() && texture_var->Type()->UnwrapRef()->Is<type::DepthTexture>() &&
!call->Stmt()->Declaration()->Is<ast::CallStatement>()) { !call->Stmt()->Declaration()->Is<ast::CallStatement>()) {
value = ctx.dst->MemberAccessor(value, "x"); value = ctx.dst->MemberAccessor(value, "x");
} }
@ -321,7 +321,7 @@ struct CombineSamplers::State {
for (auto* arg : expr->args) { for (auto* arg : expr->args) {
if (!ctx.src->TypeOf(arg) if (!ctx.src->TypeOf(arg)
->UnwrapRef() ->UnwrapRef()
->IsAnyOf<sem::Texture, sem::Sampler>()) { ->IsAnyOf<type::Texture, sem::Sampler>()) {
args.Push(ctx.Clone(arg)); args.Push(ctx.Clone(arg));
} }
} }

View File

@ -34,7 +34,7 @@ namespace {
bool ShouldRun(const Program* program) { bool ShouldRun(const Program* program) {
for (auto* node : program->ASTNodes().Objects()) { for (auto* node : program->ASTNodes().Objects()) {
if (auto* ty = node->As<ast::Type>()) { if (auto* ty = node->As<ast::Type>()) {
if (program->Sem().Get<sem::ExternalTexture>(ty)) { if (program->Sem().Get<type::ExternalTexture>(ty)) {
return true; return true;
} }
} }
@ -101,7 +101,7 @@ struct MultiplanarExternalTexture::State {
// one uniform buffer for the ExternalTextureParams struct). // one uniform buffer for the ExternalTextureParams struct).
for (auto* global : ctx.src->AST().GlobalVariables()) { for (auto* global : ctx.src->AST().GlobalVariables()) {
auto* sem_var = sem.Get<sem::GlobalVariable>(global); auto* sem_var = sem.Get<sem::GlobalVariable>(global);
if (!sem_var->Type()->UnwrapRef()->Is<sem::ExternalTexture>()) { if (!sem_var->Type()->UnwrapRef()->Is<type::ExternalTexture>()) {
continue; continue;
} }
@ -161,7 +161,7 @@ struct MultiplanarExternalTexture::State {
for (auto* fn : ctx.src->AST().Functions()) { for (auto* fn : ctx.src->AST().Functions()) {
for (const ast::Variable* param : fn->params) { for (const ast::Variable* param : fn->params) {
if (auto* sem_var = sem.Get(param)) { if (auto* sem_var = sem.Get(param)) {
if (!sem_var->Type()->UnwrapRef()->Is<sem::ExternalTexture>()) { if (!sem_var->Type()->UnwrapRef()->Is<type::ExternalTexture>()) {
continue; continue;
} }
// If we find a texture_external, we must ensure the ExternalTextureParams // If we find a texture_external, we must ensure the ExternalTextureParams
@ -195,7 +195,7 @@ struct MultiplanarExternalTexture::State {
auto* builtin = call->Target()->As<sem::Builtin>(); auto* builtin = call->Target()->As<sem::Builtin>();
if (builtin && !builtin->Parameters().IsEmpty() && if (builtin && !builtin->Parameters().IsEmpty() &&
builtin->Parameters()[0]->Type()->Is<sem::ExternalTexture>() && builtin->Parameters()[0]->Type()->Is<type::ExternalTexture>() &&
builtin->Type() != sem::BuiltinType::kTextureDimensions) { builtin->Type() != sem::BuiltinType::kTextureDimensions) {
if (auto* var_user = sem.Get<sem::VariableUser>(expr->args[0])) { if (auto* var_user = sem.Get<sem::VariableUser>(expr->args[0])) {
auto it = new_binding_symbols.find(var_user->Variable()); auto it = new_binding_symbols.find(var_user->Variable());

View File

@ -287,7 +287,7 @@ class DecomposeSideEffects::CollectHoistsState : public StateBase {
} }
// Don't hoist textures / samplers as they can't be placed into a let, nor // Don't hoist textures / samplers as they can't be placed into a let, nor
// can they have side effects. // can they have side effects.
if (var_user->Variable()->Type()->IsAnyOf<sem::Texture, sem::Sampler>()) { if (var_user->Variable()->Type()->IsAnyOf<type::Texture, sem::Sampler>()) {
return false; return false;
} }
return true; return true;

View File

@ -20,11 +20,11 @@
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/sem/atomic.h" #include "src/tint/sem/atomic.h"
#include "src/tint/sem/block_statement.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/for_loop_statement.h"
#include "src/tint/sem/reference.h" #include "src/tint/sem/reference.h"
#include "src/tint/sem/sampler.h" #include "src/tint/sem/sampler.h"
#include "src/tint/sem/variable.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::Transform);
TINT_INSTANTIATE_TYPEINFO(tint::transform::Data); 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<sem::Atomic>()) { if (auto* a = ty->As<sem::Atomic>()) {
return ctx.dst->create<ast::Atomic>(CreateASTTypeFor(ctx, a->Type())); return ctx.dst->create<ast::Atomic>(CreateASTTypeFor(ctx, a->Type()));
} }
if (auto* t = ty->As<sem::DepthTexture>()) { if (auto* t = ty->As<type::DepthTexture>()) {
return ctx.dst->create<ast::DepthTexture>(t->dim()); return ctx.dst->create<ast::DepthTexture>(t->dim());
} }
if (auto* t = ty->As<sem::DepthMultisampledTexture>()) { if (auto* t = ty->As<type::DepthMultisampledTexture>()) {
return ctx.dst->create<ast::DepthMultisampledTexture>(t->dim()); return ctx.dst->create<ast::DepthMultisampledTexture>(t->dim());
} }
if (ty->Is<sem::ExternalTexture>()) { if (ty->Is<type::ExternalTexture>()) {
return ctx.dst->create<ast::ExternalTexture>(); return ctx.dst->create<ast::ExternalTexture>();
} }
if (auto* t = ty->As<sem::MultisampledTexture>()) { if (auto* t = ty->As<type::MultisampledTexture>()) {
return ctx.dst->create<ast::MultisampledTexture>(t->dim(), return ctx.dst->create<ast::MultisampledTexture>(t->dim(),
CreateASTTypeFor(ctx, t->type())); CreateASTTypeFor(ctx, t->type()));
} }
if (auto* t = ty->As<sem::SampledTexture>()) { if (auto* t = ty->As<type::SampledTexture>()) {
return ctx.dst->create<ast::SampledTexture>(t->dim(), CreateASTTypeFor(ctx, t->type())); return ctx.dst->create<ast::SampledTexture>(t->dim(), CreateASTTypeFor(ctx, t->type()));
} }
if (auto* t = ty->As<sem::StorageTexture>()) { if (auto* t = ty->As<type::StorageTexture>()) {
return ctx.dst->create<ast::StorageTexture>(t->dim(), t->texel_format(), return ctx.dst->create<ast::StorageTexture>(t->dim(), t->texel_format(),
CreateASTTypeFor(ctx, t->type()), t->access()); CreateASTTypeFor(ctx, t->type()), t->access());
} }

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/program_builder.h"
#include "src/tint/utils/hash.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 { namespace {
bool IsValidDepthDimension(ast::TextureDimension dim) { bool IsValidDepthDimension(ast::TextureDimension dim) {
@ -29,7 +29,7 @@ bool IsValidDepthDimension(ast::TextureDimension dim) {
} // namespace } // namespace
DepthMultisampledTexture::DepthMultisampledTexture(ast::TextureDimension dim) : Base(dim) { DepthMultisampledTexture::DepthMultisampledTexture(ast::TextureDimension dim) : Base(dim) {
TINT_ASSERT(Semantic, IsValidDepthDimension(dim)); TINT_ASSERT(Type, IsValidDepthDimension(dim));
} }
DepthMultisampledTexture::DepthMultisampledTexture(DepthMultisampledTexture&&) = default; DepthMultisampledTexture::DepthMultisampledTexture(DepthMultisampledTexture&&) = default;
@ -53,4 +53,4 @@ std::string DepthMultisampledTexture::FriendlyName(const SymbolTable&) const {
return out.str(); return out.str();
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_DEPTH_MULTISAMPLED_TEXTURE_H_ #ifndef SRC_TINT_TYPE_DEPTH_MULTISAMPLED_TEXTURE_H_
#define SRC_TINT_SEM_DEPTH_MULTISAMPLED_TEXTURE_H_ #define SRC_TINT_TYPE_DEPTH_MULTISAMPLED_TEXTURE_H_
#include <string> #include <string>
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::type {
/// A multisampled depth texture type. /// A multisampled depth texture type.
class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture, Texture> { class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture, Texture> {
@ -44,6 +44,6 @@ class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture,
std::string FriendlyName(const SymbolTable& symbols) const override; std::string FriendlyName(const SymbolTable& symbols) const override;
}; };
} // namespace tint::sem } // namespace tint::type
#endif // SRC_TINT_SEM_DEPTH_MULTISAMPLED_TEXTURE_H_ #endif // SRC_TINT_TYPE_DEPTH_MULTISAMPLED_TEXTURE_H_

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/sem/depth_multisampled_texture.h" #include "src/tint/type/depth_multisampled_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" namespace tint::type {
#include "src/tint/sem/sampled_texture.h"
#include "src/tint/sem/storage_texture.h"
namespace tint::sem {
namespace { namespace {
using DepthMultisampledTextureTest = TestHelper; using DepthMultisampledTextureTest = TestHelper;
@ -45,7 +44,7 @@ TEST_F(DepthMultisampledTextureTest, Equals) {
EXPECT_TRUE(a->Equals(*a)); EXPECT_TRUE(a->Equals(*a));
EXPECT_TRUE(a->Equals(*b)); EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(Void{})); EXPECT_FALSE(a->Equals(sem::Void{}));
} }
TEST_F(DepthMultisampledTextureTest, Dim) { TEST_F(DepthMultisampledTextureTest, Dim) {
@ -59,4 +58,4 @@ TEST_F(DepthMultisampledTextureTest, FriendlyName) {
} }
} // namespace } // namespace
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/program_builder.h"
#include "src/tint/utils/hash.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 { namespace {
bool IsValidDepthDimension(ast::TextureDimension dim) { bool IsValidDepthDimension(ast::TextureDimension dim) {
@ -30,7 +30,7 @@ bool IsValidDepthDimension(ast::TextureDimension dim) {
} // namespace } // namespace
DepthTexture::DepthTexture(ast::TextureDimension dim) : Base(dim) { DepthTexture::DepthTexture(ast::TextureDimension dim) : Base(dim) {
TINT_ASSERT(Semantic, IsValidDepthDimension(dim)); TINT_ASSERT(Type, IsValidDepthDimension(dim));
} }
DepthTexture::DepthTexture(DepthTexture&&) = default; DepthTexture::DepthTexture(DepthTexture&&) = default;
@ -54,4 +54,4 @@ std::string DepthTexture::FriendlyName(const SymbolTable&) const {
return out.str(); return out.str();
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_DEPTH_TEXTURE_H_ #ifndef SRC_TINT_TYPE_DEPTH_TEXTURE_H_
#define SRC_TINT_SEM_DEPTH_TEXTURE_H_ #define SRC_TINT_TYPE_DEPTH_TEXTURE_H_
#include <string> #include <string>
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::type {
/// A depth texture type. /// A depth texture type.
class DepthTexture final : public Castable<DepthTexture, Texture> { class DepthTexture final : public Castable<DepthTexture, Texture> {
@ -44,6 +44,6 @@ class DepthTexture final : public Castable<DepthTexture, Texture> {
std::string FriendlyName(const SymbolTable& symbols) const override; 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_

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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" namespace tint::type {
#include "src/tint/sem/sampled_texture.h"
#include "src/tint/sem/storage_texture.h"
namespace tint::sem {
namespace { namespace {
using DepthTextureTest = TestHelper; using DepthTextureTest = TestHelper;
@ -50,7 +49,7 @@ TEST_F(DepthTextureTest, Equals) {
EXPECT_TRUE(a->Equals(*b)); EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(Void{})); EXPECT_FALSE(a->Equals(sem::Void{}));
} }
TEST_F(DepthTextureTest, IsTexture) { TEST_F(DepthTextureTest, IsTexture) {
@ -73,4 +72,4 @@ TEST_F(DepthTextureTest, FriendlyName) {
} }
} // namespace } // namespace
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/sem/external_texture.h" #include "src/tint/type/external_texture.h"
#include "src/tint/program_builder.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) {} ExternalTexture::ExternalTexture() : Base(ast::TextureDimension::k2d) {}
@ -38,4 +38,4 @@ std::string ExternalTexture::FriendlyName(const SymbolTable&) const {
return "texture_external"; return "texture_external";
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_EXTERNAL_TEXTURE_H_ #ifndef SRC_TINT_TYPE_EXTERNAL_TEXTURE_H_
#define SRC_TINT_SEM_EXTERNAL_TEXTURE_H_ #define SRC_TINT_TYPE_EXTERNAL_TEXTURE_H_
#include <string> #include <string>
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::type {
/// An external texture type /// An external texture type
class ExternalTexture final : public Castable<ExternalTexture, Texture> { class ExternalTexture final : public Castable<ExternalTexture, Texture> {
@ -44,6 +44,6 @@ class ExternalTexture final : public Castable<ExternalTexture, Texture> {
std::string FriendlyName(const SymbolTable& symbols) const override; 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_

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/type/depth_texture.h"
#include "src/tint/sem/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
#include "src/tint/sem/storage_texture.h" #include "src/tint/type/storage_texture.h"
#include "src/tint/sem/test_helper.h" #include "src/tint/type/test_helper.h"
namespace tint::sem { namespace tint::type {
namespace { namespace {
using ExternalTextureTest = TestHelper; using ExternalTextureTest = TestHelper;
@ -41,11 +41,11 @@ TEST_F(ExternalTextureTest, Equals) {
auto* a = create<ExternalTexture>(); auto* a = create<ExternalTexture>();
auto* b = create<ExternalTexture>(); auto* b = create<ExternalTexture>();
EXPECT_TRUE(a->Equals(*b)); EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(Void{})); EXPECT_FALSE(a->Equals(sem::Void{}));
} }
TEST_F(ExternalTextureTest, IsTexture) { TEST_F(ExternalTextureTest, IsTexture) {
F32 f32; sem::F32 f32;
ExternalTexture s; ExternalTexture s;
Texture* ty = &s; Texture* ty = &s;
EXPECT_FALSE(ty->Is<DepthTexture>()); EXPECT_FALSE(ty->Is<DepthTexture>());
@ -56,7 +56,7 @@ TEST_F(ExternalTextureTest, IsTexture) {
} }
TEST_F(ExternalTextureTest, Dim) { TEST_F(ExternalTextureTest, Dim) {
F32 f32; sem::F32 f32;
ExternalTexture s; ExternalTexture s;
EXPECT_EQ(s.dim(), ast::TextureDimension::k2d); EXPECT_EQ(s.dim(), ast::TextureDimension::k2d);
} }
@ -67,4 +67,4 @@ TEST_F(ExternalTextureTest, FriendlyName) {
} }
} // namespace } // namespace
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/program_builder.h"
#include "src/tint/utils/hash.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) MultisampledTexture::MultisampledTexture(ast::TextureDimension dim, const type::Type* type)
: Base(dim), type_(type) { : Base(dim), type_(type) {
TINT_ASSERT(Semantic, type_); TINT_ASSERT(Type, type_);
} }
MultisampledTexture::MultisampledTexture(MultisampledTexture&&) = default; MultisampledTexture::MultisampledTexture(MultisampledTexture&&) = default;
@ -47,4 +47,4 @@ std::string MultisampledTexture::FriendlyName(const SymbolTable& symbols) const
return out.str(); return out.str();
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_MULTISAMPLED_TEXTURE_H_ #ifndef SRC_TINT_TYPE_MULTISAMPLED_TEXTURE_H_
#define SRC_TINT_SEM_MULTISAMPLED_TEXTURE_H_ #define SRC_TINT_TYPE_MULTISAMPLED_TEXTURE_H_
#include <string> #include <string>
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::type {
/// A multisampled texture type. /// A multisampled texture type.
class MultisampledTexture final : public Castable<MultisampledTexture, Texture> { class MultisampledTexture final : public Castable<MultisampledTexture, Texture> {
@ -51,6 +51,6 @@ class MultisampledTexture final : public Castable<MultisampledTexture, Texture>
const type::Type* const type_; 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_

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/type/depth_texture.h"
#include "src/tint/sem/external_texture.h" #include "src/tint/type/external_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
#include "src/tint/sem/storage_texture.h" #include "src/tint/type/storage_texture.h"
#include "src/tint/sem/test_helper.h" #include "src/tint/type/test_helper.h"
namespace tint::sem { namespace tint::type {
namespace { namespace {
using MultisampledTextureTest = TestHelper; using MultisampledTextureTest = TestHelper;
TEST_F(MultisampledTextureTest, Creation) { TEST_F(MultisampledTextureTest, Creation) {
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<F32>()); auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<sem::F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<I32>()); auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::I32>());
EXPECT_EQ(a, b); EXPECT_EQ(a, b);
EXPECT_NE(a, c); EXPECT_NE(a, c);
EXPECT_NE(a, d); EXPECT_NE(a, d);
} }
TEST_F(MultisampledTextureTest, Hash) { TEST_F(MultisampledTextureTest, Hash) {
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<F32>()); auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<sem::F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<I32>()); auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::I32>());
EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash()); EXPECT_NE(a->Hash(), c->Hash());
EXPECT_NE(a->Hash(), d->Hash()); EXPECT_NE(a->Hash(), d->Hash());
} }
TEST_F(MultisampledTextureTest, Equals) { TEST_F(MultisampledTextureTest, Equals) {
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<F32>()); auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<sem::F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<I32>()); auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::I32>());
EXPECT_TRUE(a->Equals(*b)); EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d)); EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(Void{})); EXPECT_FALSE(a->Equals(sem::Void{}));
} }
TEST_F(MultisampledTextureTest, IsTexture) { TEST_F(MultisampledTextureTest, IsTexture) {
F32 f32; sem::F32 f32;
MultisampledTexture s(ast::TextureDimension::kCube, &f32); MultisampledTexture s(ast::TextureDimension::kCube, &f32);
Texture* ty = &s; Texture* ty = &s;
EXPECT_FALSE(ty->Is<DepthTexture>()); EXPECT_FALSE(ty->Is<DepthTexture>());
@ -68,22 +68,22 @@ TEST_F(MultisampledTextureTest, IsTexture) {
} }
TEST_F(MultisampledTextureTest, Dim) { TEST_F(MultisampledTextureTest, Dim) {
F32 f32; sem::F32 f32;
MultisampledTexture s(ast::TextureDimension::k3d, &f32); MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d); EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
} }
TEST_F(MultisampledTextureTest, Type) { TEST_F(MultisampledTextureTest, Type) {
F32 f32; sem::F32 f32;
MultisampledTexture s(ast::TextureDimension::k3d, &f32); MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.type(), &f32); EXPECT_EQ(s.type(), &f32);
} }
TEST_F(MultisampledTextureTest, FriendlyName) { TEST_F(MultisampledTextureTest, FriendlyName) {
F32 f32; sem::F32 f32;
MultisampledTexture s(ast::TextureDimension::k3d, &f32); MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>"); EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
} }
} // namespace } // namespace
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/program_builder.h"
#include "src/tint/utils/hash.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) SampledTexture::SampledTexture(ast::TextureDimension dim, const type::Type* type)
: Base(dim), type_(type) { : Base(dim), type_(type) {
TINT_ASSERT(Semantic, type_); TINT_ASSERT(Type, type_);
} }
SampledTexture::SampledTexture(SampledTexture&&) = default; SampledTexture::SampledTexture(SampledTexture&&) = default;
@ -47,4 +47,4 @@ std::string SampledTexture::FriendlyName(const SymbolTable& symbols) const {
return out.str(); return out.str();
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_SAMPLED_TEXTURE_H_ #ifndef SRC_TINT_TYPE_SAMPLED_TEXTURE_H_
#define SRC_TINT_SEM_SAMPLED_TEXTURE_H_ #define SRC_TINT_TYPE_SAMPLED_TEXTURE_H_
#include <string> #include <string>
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
namespace tint::sem { namespace tint::type {
/// A sampled texture type. /// A sampled texture type.
class SampledTexture final : public Castable<SampledTexture, Texture> { class SampledTexture final : public Castable<SampledTexture, Texture> {
@ -51,6 +51,6 @@ class SampledTexture final : public Castable<SampledTexture, Texture> {
const type::Type* const type_; 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_

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/type/depth_texture.h"
#include "src/tint/sem/external_texture.h" #include "src/tint/type/external_texture.h"
#include "src/tint/sem/storage_texture.h" #include "src/tint/type/storage_texture.h"
#include "src/tint/sem/test_helper.h" #include "src/tint/type/test_helper.h"
namespace tint::sem { namespace tint::type {
namespace { namespace {
using SampledTextureTest = TestHelper; using SampledTextureTest = TestHelper;
TEST_F(SampledTextureTest, Creation) { TEST_F(SampledTextureTest, Creation) {
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>()); auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>()); auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<I32>()); auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::I32>());
EXPECT_TRUE(a->type()->Is<F32>()); EXPECT_TRUE(a->type()->Is<sem::F32>());
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube); EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
EXPECT_EQ(a, b); EXPECT_EQ(a, b);
@ -39,10 +39,10 @@ TEST_F(SampledTextureTest, Creation) {
} }
TEST_F(SampledTextureTest, Hash) { TEST_F(SampledTextureTest, Hash) {
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>()); auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>()); auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<I32>()); auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::I32>());
EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash()); EXPECT_NE(a->Hash(), c->Hash());
@ -50,19 +50,19 @@ TEST_F(SampledTextureTest, Hash) {
} }
TEST_F(SampledTextureTest, Equals) { TEST_F(SampledTextureTest, Equals) {
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>()); auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>()); auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<F32>()); auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<I32>()); auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::I32>());
EXPECT_TRUE(a->Equals(*b)); EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d)); EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(Void{})); EXPECT_FALSE(a->Equals(sem::Void{}));
} }
TEST_F(SampledTextureTest, IsTexture) { TEST_F(SampledTextureTest, IsTexture) {
F32 f32; sem::F32 f32;
SampledTexture s(ast::TextureDimension::kCube, &f32); SampledTexture s(ast::TextureDimension::kCube, &f32);
Texture* ty = &s; Texture* ty = &s;
EXPECT_FALSE(ty->Is<DepthTexture>()); EXPECT_FALSE(ty->Is<DepthTexture>());
@ -72,22 +72,22 @@ TEST_F(SampledTextureTest, IsTexture) {
} }
TEST_F(SampledTextureTest, Dim) { TEST_F(SampledTextureTest, Dim) {
F32 f32; sem::F32 f32;
SampledTexture s(ast::TextureDimension::k3d, &f32); SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d); EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
} }
TEST_F(SampledTextureTest, Type) { TEST_F(SampledTextureTest, Type) {
F32 f32; sem::F32 f32;
SampledTexture s(ast::TextureDimension::k3d, &f32); SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.type(), &f32); EXPECT_EQ(s.type(), &f32);
} }
TEST_F(SampledTextureTest, FriendlyName) { TEST_F(SampledTextureTest, FriendlyName) {
F32 f32; sem::F32 f32;
SampledTexture s(ast::TextureDimension::k3d, &f32); SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>"); EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>");
} }
} // namespace } // namespace
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/program_builder.h"
#include "src/tint/utils/hash.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, StorageTexture::StorageTexture(ast::TextureDimension dim,
ast::TexelFormat format, ast::TexelFormat format,
@ -82,4 +82,4 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage
return nullptr; return nullptr;
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_STORAGE_TEXTURE_H_ #ifndef SRC_TINT_TYPE_STORAGE_TEXTURE_H_
#define SRC_TINT_SEM_STORAGE_TEXTURE_H_ #define SRC_TINT_TYPE_STORAGE_TEXTURE_H_
#include <string> #include <string>
#include "src/tint/ast/access.h" #include "src/tint/ast/access.h"
#include "src/tint/ast/storage_texture.h" #include "src/tint/ast/storage_texture.h"
#include "src/tint/sem/texture.h" #include "src/tint/type/texture.h"
// Forward declarations // Forward declarations
namespace tint::type { namespace tint::type {
class TypeManager; class TypeManager;
} // namespace tint::type } // namespace tint::type
namespace tint::sem { namespace tint::type {
/// A storage texture type. /// A storage texture type.
class StorageTexture final : public Castable<StorageTexture, Texture> { class StorageTexture final : public Castable<StorageTexture, Texture> {
@ -77,6 +77,6 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
type::Type* const subtype_; type::Type* const subtype_;
}; };
} // namespace tint::sem } // namespace tint::type
#endif // SRC_TINT_SEM_STORAGE_TEXTURE_H_ #endif // SRC_TINT_TYPE_STORAGE_TEXTURE_H_

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors // Copyright 2022 The Tint Authors
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/type/depth_texture.h"
#include "src/tint/sem/external_texture.h" #include "src/tint/type/external_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
#include "src/tint/sem/test_helper.h" #include "src/tint/type/test_helper.h"
namespace tint::sem { namespace tint::type {
namespace { namespace {
struct StorageTextureTest : public TestHelper { struct StorageTextureTest : public TestHelper {
@ -41,7 +41,7 @@ TEST_F(StorageTextureTest, Creation) {
auto* e = auto* e =
Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead); Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
EXPECT_TRUE(a->type()->Is<F32>()); EXPECT_TRUE(a->type()->Is<sem::F32>());
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube); EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
EXPECT_EQ(a, b); EXPECT_EQ(a, b);
@ -84,7 +84,7 @@ TEST_F(StorageTextureTest, Equals) {
EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d)); EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(*e)); EXPECT_FALSE(a->Equals(*e));
EXPECT_FALSE(a->Equals(Void{})); EXPECT_FALSE(a->Equals(sem::Void{}));
} }
TEST_F(StorageTextureTest, Dim) { TEST_F(StorageTextureTest, Dim) {
@ -114,11 +114,11 @@ TEST_F(StorageTextureTest, F32) {
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
ASSERT_TRUE(s->Is<Texture>()); ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>()); ASSERT_TRUE(s->Is<StorageTexture>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<F32>()); EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<sem::F32>());
} }
TEST_F(StorageTextureTest, U32) { 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 = type::Type* s =
create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint, create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint,
ast::Access::kReadWrite, subtype); ast::Access::kReadWrite, subtype);
@ -128,11 +128,11 @@ TEST_F(StorageTextureTest, U32) {
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
ASSERT_TRUE(s->Is<Texture>()); ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>()); ASSERT_TRUE(s->Is<StorageTexture>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<U32>()); EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<sem::U32>());
} }
TEST_F(StorageTextureTest, I32) { 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 = type::Type* s =
create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint, create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint,
ast::Access::kReadWrite, subtype); ast::Access::kReadWrite, subtype);
@ -142,8 +142,8 @@ TEST_F(StorageTextureTest, I32) {
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
ASSERT_TRUE(s->Is<Texture>()); ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>()); ASSERT_TRUE(s->Is<StorageTexture>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<I32>()); EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<sem::I32>());
} }
} // namespace } // namespace
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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) {} Texture::Texture(ast::TextureDimension dim) : Base(type::TypeFlags{}), dim_(dim) {}
@ -24,4 +24,4 @@ Texture::Texture(Texture&&) = default;
Texture::~Texture() = default; Texture::~Texture() = default;
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_TEXTURE_H_ #ifndef SRC_TINT_TYPE_TEXTURE_H_
#define SRC_TINT_SEM_TEXTURE_H_ #define SRC_TINT_TYPE_TEXTURE_H_
#include "src/tint/ast/texture.h" #include "src/tint/ast/texture.h"
#include "src/tint/type/type.h" #include "src/tint/type/type.h"
namespace tint::sem { namespace tint::type {
/// A texture type. /// A texture type.
class Texture : public Castable<Texture, type::Type> { class Texture : public Castable<Texture, type::Type> {
@ -37,6 +37,6 @@ class Texture : public Castable<Texture, type::Type> {
ast::TextureDimension const dim_; ast::TextureDimension const dim_;
}; };
} // namespace tint::sem } // namespace tint::type
#endif // SRC_TINT_SEM_TEXTURE_H_ #endif // SRC_TINT_TYPE_TEXTURE_H_

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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/type/sampled_texture.h"
#include "src/tint/sem/test_helper.h" #include "src/tint/type/test_helper.h"
namespace tint::sem { namespace tint::type {
namespace { namespace {
using TextureTypeDimTest = TestParamHelper<ast::TextureDimension>; using TextureTypeDimTest = TestParamHelper<ast::TextureDimension>;
TEST_P(TextureTypeDimTest, DimMustMatch) { TEST_P(TextureTypeDimTest, DimMustMatch) {
// Check that the dim() query returns the right dimensionality. // Check that the dim() query returns the right dimensionality.
F32 f32; sem::F32 f32;
// TextureType is an abstract class, so use concrete class // TextureType is an abstract class, so use concrete class
// SampledTexture in its stead. // SampledTexture in its stead.
SampledTexture st(GetParam(), &f32); SampledTexture st(GetParam(), &f32);
@ -41,4 +41,4 @@ INSTANTIATE_TEST_SUITE_P(Dimensions,
ast::TextureDimension::kCubeArray)); ast::TextureDimension::kCubeArray));
} // namespace } // namespace
} // namespace tint::sem } // namespace tint::type

View File

@ -1,4 +1,4 @@
// Copyright 2020 The Tint Authors. // Copyright 2022 The Tint Authors.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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/reference.h"
#include "src/tint/sem/sampler.h" #include "src/tint/sem/sampler.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/texture.h"
#include "src/tint/sem/u32.h" #include "src/tint/sem/u32.h"
#include "src/tint/sem/vector.h" #include "src/tint/sem/vector.h"
#include "src/tint/type/texture.h"
TINT_INSTANTIATE_TYPEINFO(tint::type::Type); TINT_INSTANTIATE_TYPEINFO(tint::type::Type);
@ -172,7 +172,7 @@ bool Type::is_numeric_scalar_or_vector() const {
} }
bool Type::is_handle() const { bool Type::is_handle() const {
return IsAnyOf<sem::Sampler, sem::Texture>(); return IsAnyOf<sem::Sampler, type::Texture>();
} }
bool Type::HoldsAbstract() const { bool Type::HoldsAbstract() const {

View File

@ -21,8 +21,8 @@
#include "src/tint/ast/external_texture.h" #include "src/tint/ast/external_texture.h"
#include "src/tint/ast/module.h" #include "src/tint/ast/module.h"
#include "src/tint/program.h" #include "src/tint/program.h"
#include "src/tint/sem/external_texture.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/type/external_texture.h"
namespace tint::writer { namespace tint::writer {
@ -40,7 +40,7 @@ transform::MultiplanarExternalTexture::BindingsMap GenerateExternalTextureBindin
auto& n = group_to_next_binding_number[bp.group]; auto& n = group_to_next_binding_number[bp.group];
n = std::max(n, bp.binding + 1); n = std::max(n, bp.binding + 1);
if (sem_var->Type()->UnwrapRef()->Is<sem::ExternalTexture>()) { if (sem_var->Type()->UnwrapRef()->Is<type::ExternalTexture>()) {
ext_tex_bps.emplace_back(bp); ext_tex_bps.emplace_back(bp);
} }
} }

View File

@ -32,15 +32,10 @@
#include "src/tint/sem/block_statement.h" #include "src/tint/sem/block_statement.h"
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/constant.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/function.h"
#include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/member_accessor_expression.h"
#include "src/tint/sem/module.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/statement.h"
#include "src/tint/sem/storage_texture.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/switch_statement.h" #include "src/tint/sem/switch_statement.h"
#include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_conversion.h"
@ -69,6 +64,11 @@
#include "src/tint/transform/std140.h" #include "src/tint/transform/std140.h"
#include "src/tint/transform/unshadow.h" #include "src/tint/transform/unshadow.h"
#include "src/tint/transform/zero_init_workgroup_memory.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/defer.h"
#include "src/tint/utils/map.h" #include "src/tint/utils/map.h"
#include "src/tint/utils/scoped_assignment.h" #include "src/tint/utils/scoped_assignment.h"
@ -1380,7 +1380,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
return false; return false;
} }
auto* texture_type = TypeOf(texture)->UnwrapRef()->As<sem::Texture>(); auto* texture_type = TypeOf(texture)->UnwrapRef()->As<type::Texture>();
auto emit_signed_int_type = [&](const type::Type* ty) { auto emit_signed_int_type = [&](const type::Type* ty) {
uint32_t width = 0; uint32_t width = 0;
@ -1420,7 +1420,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
emit_unsigned_int_type(call->Type()); emit_unsigned_int_type(call->Type());
ScopedParen sp(out); ScopedParen sp(out);
if (texture_type->Is<sem::StorageTexture>()) { if (texture_type->Is<type::StorageTexture>()) {
out << "imageSize("; out << "imageSize(";
} else { } else {
out << "textureSize("; out << "textureSize(";
@ -1431,9 +1431,9 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
// The LOD parameter is mandatory on textureSize() for non-multisampled // The LOD parameter is mandatory on textureSize() for non-multisampled
// textures. // textures.
if (!texture_type->Is<sem::StorageTexture>() && if (!texture_type->Is<type::StorageTexture>() &&
!texture_type->Is<sem::MultisampledTexture>() && !texture_type->Is<type::MultisampledTexture>() &&
!texture_type->Is<sem::DepthMultisampledTexture>()) { !texture_type->Is<type::DepthMultisampledTexture>()) {
out << ", "; out << ", ";
if (auto* level_arg = arg(Usage::kLevel)) { if (auto* level_arg = arg(Usage::kLevel)) {
if (!emit_expr_as_signed(level_arg)) { if (!emit_expr_as_signed(level_arg)) {
@ -1459,7 +1459,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
out << "uint"; out << "uint";
ScopedParen sp(out); ScopedParen sp(out);
if (texture_type->Is<sem::StorageTexture>()) { if (texture_type->Is<type::StorageTexture>()) {
out << "imageSize("; out << "imageSize(";
} else { } else {
out << "textureSize("; out << "textureSize(";
@ -1471,9 +1471,9 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
} }
// The LOD parameter is mandatory on textureSize() for non-multisampled // The LOD parameter is mandatory on textureSize() for non-multisampled
// textures. // textures.
if (!texture_type->Is<sem::StorageTexture>() && if (!texture_type->Is<type::StorageTexture>() &&
!texture_type->Is<sem::MultisampledTexture>() && !texture_type->Is<type::MultisampledTexture>() &&
!texture_type->Is<sem::DepthMultisampledTexture>()) { !texture_type->Is<type::DepthMultisampledTexture>()) {
out << ", "; out << ", ";
if (auto* level_arg = arg(Usage::kLevel)) { if (auto* level_arg = arg(Usage::kLevel)) {
if (!emit_expr_as_signed(level_arg)) { if (!emit_expr_as_signed(level_arg)) {
@ -1520,7 +1520,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
uint32_t glsl_ret_width = 4u; uint32_t glsl_ret_width = 4u;
bool append_depth_ref_to_coords = true; bool append_depth_ref_to_coords = true;
bool is_depth = texture_type->Is<sem::DepthTexture>(); bool is_depth = texture_type->Is<type::DepthTexture>();
switch (builtin->Type()) { switch (builtin->Type()) {
case sem::BuiltinType::kTextureSample: case sem::BuiltinType::kTextureSample:
@ -2069,7 +2069,7 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable*
// GLSL ignores Sampler variables. // GLSL ignores Sampler variables.
return true; return true;
} }
if (auto* storage = type->As<sem::StorageTexture>()) { if (auto* storage = type->As<type::StorageTexture>()) {
out << "layout(" << convert_texel_format_to_glsl(storage->texel_format()) << ") "; out << "layout(" << convert_texel_format_to_glsl(storage->texel_format()) << ") ";
} }
if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), name)) { if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), name)) {
@ -2897,16 +2897,16 @@ bool GeneratorImpl::EmitType(std::ostream& out,
return false; return false;
} else if (auto* str = type->As<sem::Struct>()) { } else if (auto* str = type->As<sem::Struct>()) {
out << StructName(str); out << StructName(str);
} else if (auto* tex = type->As<sem::Texture>()) { } else if (auto* tex = type->As<type::Texture>()) {
if (tex->Is<sem::ExternalTexture>()) { if (tex->Is<type::ExternalTexture>()) {
TINT_ICE(Writer, diagnostics_) << "Multiplanar external texture transform was not run."; TINT_ICE(Writer, diagnostics_) << "Multiplanar external texture transform was not run.";
return false; return false;
} }
auto* storage = tex->As<sem::StorageTexture>(); auto* storage = tex->As<type::StorageTexture>();
auto* ms = tex->As<sem::MultisampledTexture>(); auto* ms = tex->As<type::MultisampledTexture>();
auto* depth_ms = tex->As<sem::DepthMultisampledTexture>(); auto* depth_ms = tex->As<type::DepthMultisampledTexture>();
auto* sampled = tex->As<sem::SampledTexture>(); auto* sampled = tex->As<type::SampledTexture>();
out << "highp "; out << "highp ";
@ -2953,7 +2953,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
<< "unexpected TextureDimension " << tex->dim(); << "unexpected TextureDimension " << tex->dim();
return false; return false;
} }
if (tex->Is<sem::DepthTexture>()) { if (tex->Is<type::DepthTexture>()) {
out << "Shadow"; out << "Shadow";
} }
} else if (type->Is<sem::U32>()) { } else if (type->Is<sem::U32>()) {

View File

@ -15,11 +15,11 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.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/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" #include "src/tint/writer/glsl/test_helper.h"
using ::testing::HasSubstr; using ::testing::HasSubstr;
@ -495,7 +495,7 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Type,
TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) { TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::MultisampledTexture>(ast::TextureDimension::k2d, f32); auto* s = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -33,15 +33,10 @@
#include "src/tint/sem/block_statement.h" #include "src/tint/sem/block_statement.h"
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/constant.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/function.h"
#include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/member_accessor_expression.h"
#include "src/tint/sem/module.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/statement.h"
#include "src/tint/sem/storage_texture.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/switch_statement.h" #include "src/tint/sem/switch_statement.h"
#include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_conversion.h"
@ -69,6 +64,11 @@
#include "src/tint/transform/unshadow.h" #include "src/tint/transform/unshadow.h"
#include "src/tint/transform/vectorize_scalar_matrix_initializers.h" #include "src/tint/transform/vectorize_scalar_matrix_initializers.h"
#include "src/tint/transform/zero_init_workgroup_memory.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/defer.h"
#include "src/tint/utils/map.h" #include "src/tint/utils/map.h"
#include "src/tint/utils/scoped_assignment.h" #include "src/tint/utils/scoped_assignment.h"
@ -2274,7 +2274,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
return false; return false;
} }
auto* texture_type = TypeOf(texture)->UnwrapRef()->As<sem::Texture>(); auto* texture_type = TypeOf(texture)->UnwrapRef()->As<type::Texture>();
switch (builtin->Type()) { switch (builtin->Type()) {
case sem::BuiltinType::kTextureDimensions: case sem::BuiltinType::kTextureDimensions:
@ -2283,7 +2283,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
case sem::BuiltinType::kTextureNumSamples: { case sem::BuiltinType::kTextureNumSamples: {
// All of these builtins use the GetDimensions() method on the texture // All of these builtins use the GetDimensions() method on the texture
bool is_ms = bool is_ms =
texture_type->IsAnyOf<sem::MultisampledTexture, sem::DepthMultisampledTexture>(); texture_type->IsAnyOf<type::MultisampledTexture, type::DepthMultisampledTexture>();
int num_dimensions = 0; int num_dimensions = 0;
std::string swizzle; std::string swizzle;
@ -2488,7 +2488,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
case sem::BuiltinType::kTextureLoad: case sem::BuiltinType::kTextureLoad:
out << ".Load("; out << ".Load(";
// Multisampled textures do not support mip-levels. // Multisampled textures do not support mip-levels.
if (!texture_type->Is<sem::MultisampledTexture>()) { if (!texture_type->Is<type::MultisampledTexture>()) {
pack_level_in_coords = true; pack_level_in_coords = true;
} }
break; break;
@ -3059,9 +3059,9 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable*
const char* register_space = nullptr; const char* register_space = nullptr;
if (unwrapped_type->Is<sem::Texture>()) { if (unwrapped_type->Is<type::Texture>()) {
register_space = "t"; register_space = "t";
if (unwrapped_type->Is<sem::StorageTexture>()) { if (unwrapped_type->Is<type::StorageTexture>()) {
register_space = "u"; register_space = "u";
} }
} else if (unwrapped_type->Is<sem::Sampler>()) { } else if (unwrapped_type->Is<sem::Sampler>()) {
@ -4011,17 +4011,17 @@ bool GeneratorImpl::EmitType(std::ostream& out,
out << StructName(str); out << StructName(str);
return true; return true;
}, },
[&](const sem::Texture* tex) { [&](const type::Texture* tex) {
if (tex->Is<sem::ExternalTexture>()) { if (tex->Is<type::ExternalTexture>()) {
TINT_ICE(Writer, diagnostics_) TINT_ICE(Writer, diagnostics_)
<< "Multiplanar external texture transform was not run."; << "Multiplanar external texture transform was not run.";
return false; return false;
} }
auto* storage = tex->As<sem::StorageTexture>(); auto* storage = tex->As<type::StorageTexture>();
auto* ms = tex->As<sem::MultisampledTexture>(); auto* ms = tex->As<type::MultisampledTexture>();
auto* depth_ms = tex->As<sem::DepthMultisampledTexture>(); auto* depth_ms = tex->As<type::DepthMultisampledTexture>();
auto* sampled = tex->As<sem::SampledTexture>(); auto* sampled = tex->As<type::SampledTexture>();
if (storage && storage->access() != ast::Access::kRead) { if (storage && storage->access() != ast::Access::kRead) {
out << "RW"; out << "RW";

View File

@ -15,11 +15,11 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.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/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" #include "src/tint/writer/hlsl/test_helper.h"
using ::testing::HasSubstr; using ::testing::HasSubstr;
@ -494,7 +494,7 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Type,
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) { TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::MultisampledTexture>(ast::TextureDimension::k2d, f32); auto* s = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -36,8 +36,6 @@
#include "src/tint/sem/bool.h" #include "src/tint/sem/bool.h"
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/constant.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/f16.h"
#include "src/tint/sem/f32.h" #include "src/tint/sem/f32.h"
#include "src/tint/sem/function.h" #include "src/tint/sem/function.h"
@ -45,11 +43,8 @@
#include "src/tint/sem/matrix.h" #include "src/tint/sem/matrix.h"
#include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/member_accessor_expression.h"
#include "src/tint/sem/module.h" #include "src/tint/sem/module.h"
#include "src/tint/sem/multisampled_texture.h"
#include "src/tint/sem/pointer.h" #include "src/tint/sem/pointer.h"
#include "src/tint/sem/reference.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/struct.h"
#include "src/tint/sem/switch_statement.h" #include "src/tint/sem/switch_statement.h"
#include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_conversion.h"
@ -75,6 +70,11 @@
#include "src/tint/transform/unshadow.h" #include "src/tint/transform/unshadow.h"
#include "src/tint/transform/vectorize_scalar_matrix_initializers.h" #include "src/tint/transform/vectorize_scalar_matrix_initializers.h"
#include "src/tint/transform/zero_init_workgroup_memory.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/defer.h"
#include "src/tint/utils/map.h" #include "src/tint/utils/map.h"
#include "src/tint/utils/scoped_assignment.h" #include "src/tint/utils/scoped_assignment.h"
@ -997,7 +997,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
return false; return false;
} }
auto* texture_type = TypeOf(texture)->UnwrapRef()->As<sem::Texture>(); auto* texture_type = TypeOf(texture)->UnwrapRef()->As<type::Texture>();
// Helper to emit the texture expression, wrapped in parentheses if the // Helper to emit the texture expression, wrapped in parentheses if the
// expression includes an operator with lower precedence than the member // expression includes an operator with lower precedence than the member
@ -2607,14 +2607,14 @@ bool GeneratorImpl::EmitType(std::ostream& out,
out << StructName(str); out << StructName(str);
return true; return true;
}, },
[&](const sem::Texture* tex) { [&](const type::Texture* tex) {
if (tex->Is<sem::ExternalTexture>()) { if (tex->Is<type::ExternalTexture>()) {
TINT_ICE(Writer, diagnostics_) TINT_ICE(Writer, diagnostics_)
<< "Multiplanar external texture transform was not run."; << "Multiplanar external texture transform was not run.";
return false; return false;
} }
if (tex->IsAnyOf<sem::DepthTexture, sem::DepthMultisampledTexture>()) { if (tex->IsAnyOf<type::DepthTexture, type::DepthMultisampledTexture>()) {
out << "depth"; out << "depth";
} else { } else {
out << "texture"; out << "texture";
@ -2643,7 +2643,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
diagnostics_.add_error(diag::System::Writer, "Invalid texture dimensions"); diagnostics_.add_error(diag::System::Writer, "Invalid texture dimensions");
return false; return false;
} }
if (tex->IsAnyOf<sem::MultisampledTexture, sem::DepthMultisampledTexture>()) { if (tex->IsAnyOf<type::MultisampledTexture, type::DepthMultisampledTexture>()) {
out << "_ms"; out << "_ms";
} }
out << "<"; out << "<";
@ -2651,15 +2651,15 @@ bool GeneratorImpl::EmitType(std::ostream& out,
return Switch( return Switch(
tex, tex,
[&](const sem::DepthTexture*) { [&](const type::DepthTexture*) {
out << "float, access::sample"; out << "float, access::sample";
return true; return true;
}, },
[&](const sem::DepthMultisampledTexture*) { [&](const type::DepthMultisampledTexture*) {
out << "float, access::read"; out << "float, access::read";
return true; return true;
}, },
[&](const sem::StorageTexture* storage) { [&](const type::StorageTexture* storage) {
if (!EmitType(out, storage->type(), "")) { if (!EmitType(out, storage->type(), "")) {
return false; return false;
} }
@ -2676,14 +2676,14 @@ bool GeneratorImpl::EmitType(std::ostream& out,
} }
return true; return true;
}, },
[&](const sem::MultisampledTexture* ms) { [&](const type::MultisampledTexture* ms) {
if (!EmitType(out, ms->type(), "")) { if (!EmitType(out, ms->type(), "")) {
return false; return false;
} }
out << ", access::read"; out << ", access::read";
return true; return true;
}, },
[&](const sem::SampledTexture* sampled) { [&](const type::SampledTexture* sampled) {
if (!EmitType(out, sampled->type(), "")) { if (!EmitType(out, sampled->type(), "")) {
return false; return false;
} }

View File

@ -16,12 +16,12 @@
#include "gmock/gmock.h" #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/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" #include "src/tint/writer/msl/test_helper.h"
using ::testing::HasSubstr; using ::testing::HasSubstr;
@ -761,7 +761,7 @@ using MslDepthTexturesTest = TestParamHelper<MslDepthTextureData>;
TEST_P(MslDepthTexturesTest, Emit) { TEST_P(MslDepthTexturesTest, Emit) {
auto params = GetParam(); auto params = GetParam();
sem::DepthTexture s(params.dim); type::DepthTexture s(params.dim);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -782,7 +782,7 @@ INSTANTIATE_TEST_SUITE_P(
using MslDepthMultisampledTexturesTest = TestHelper; using MslDepthMultisampledTexturesTest = TestHelper;
TEST_F(MslDepthMultisampledTexturesTest, Emit) { TEST_F(MslDepthMultisampledTexturesTest, Emit) {
sem::DepthMultisampledTexture s(ast::TextureDimension::k2d); type::DepthMultisampledTexture s(ast::TextureDimension::k2d);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -804,7 +804,7 @@ TEST_P(MslSampledtexturesTest, Emit) {
auto params = GetParam(); auto params = GetParam();
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::SampledTexture>(params.dim, f32); auto* s = create<type::SampledTexture>(params.dim, f32);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -826,7 +826,7 @@ INSTANTIATE_TEST_SUITE_P(
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) { TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
auto* u32 = create<sem::U32>(); auto* u32 = create<sem::U32>();
auto* ms = create<sem::MultisampledTexture>(ast::TextureDimension::k2d, u32); auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, u32);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -27,15 +27,11 @@
#include "src/tint/sem/builtin.h" #include "src/tint/sem/builtin.h"
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/constant.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/function.h"
#include "src/tint/sem/materialize.h" #include "src/tint/sem/materialize.h"
#include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/member_accessor_expression.h"
#include "src/tint/sem/module.h" #include "src/tint/sem/module.h"
#include "src/tint/sem/multisampled_texture.h"
#include "src/tint/sem/reference.h" #include "src/tint/sem/reference.h"
#include "src/tint/sem/sampled_texture.h"
#include "src/tint/sem/statement.h" #include "src/tint/sem/statement.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/switch_statement.h" #include "src/tint/sem/switch_statement.h"
@ -44,6 +40,10 @@
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/sem/vector.h" #include "src/tint/sem/vector.h"
#include "src/tint/transform/add_block_attribute.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/defer.h"
#include "src/tint/utils/map.h" #include "src/tint/utils/map.h"
#include "src/tint/writer/append_vector.h" #include "src/tint/writer/append_vector.h"
@ -779,9 +779,9 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) {
if (v->initializer) { if (v->initializer) {
ops.push_back(Operand(init_id)); ops.push_back(Operand(init_id));
} else { } else {
auto* st = type->As<sem::StorageTexture>(); auto* st = type->As<type::StorageTexture>();
if (st || type->Is<sem::Struct>()) { if (st || type->Is<sem::Struct>()) {
// 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(); auto access = st ? st->access() : sem->Access();
switch (access) { switch (access) {
case ast::Access::kWrite: case ast::Access::kWrite:
@ -2649,7 +2649,7 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
TINT_ICE(Writer, builder_.Diagnostics()) << "missing texture argument"; TINT_ICE(Writer, builder_.Diagnostics()) << "missing texture argument";
} }
auto* texture_type = texture->Type()->UnwrapRef()->As<sem::Texture>(); auto* texture_type = texture->Type()->UnwrapRef()->As<type::Texture>();
auto op = spv::Op::OpNop; 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 // If the texture is not a depth texture, then this function simply delegates
// to calling append_result_type_and_id_to_spirv_params(). // to calling append_result_type_and_id_to_spirv_params().
auto append_result_type_and_id_to_spirv_params_for_read = [&]() { auto append_result_type_and_id_to_spirv_params_for_read = [&]() {
if (texture_type->IsAnyOf<sem::DepthTexture, sem::DepthMultisampledTexture>()) { if (texture_type->IsAnyOf<type::DepthTexture, type::DepthMultisampledTexture>()) {
auto* f32 = builder_.create<sem::F32>(); auto* f32 = builder_.create<sem::F32>();
auto* spirv_result_type = builder_.create<sem::Vector>(f32, 4u); auto* spirv_result_type = builder_.create<sem::Vector>(f32, 4u);
auto spirv_result = result_op(); auto spirv_result = result_op();
@ -2807,9 +2807,9 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
} }
spirv_params.emplace_back(gen_arg(Usage::kTexture)); spirv_params.emplace_back(gen_arg(Usage::kTexture));
if (texture_type->IsAnyOf<sem::MultisampledTexture, // if (texture_type->IsAnyOf<type::MultisampledTexture, //
sem::DepthMultisampledTexture, // type::DepthMultisampledTexture, //
sem::StorageTexture>()) { type::StorageTexture>()) {
op = spv::Op::OpImageQuerySize; op = spv::Op::OpImageQuerySize;
} else if (auto* level = arg(Usage::kLevel)) { } else if (auto* level = arg(Usage::kLevel)) {
op = spv::Op::OpImageQuerySizeLod; op = spv::Op::OpImageQuerySizeLod;
@ -2841,8 +2841,8 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
spirv_params.emplace_back(gen_arg(Usage::kTexture)); spirv_params.emplace_back(gen_arg(Usage::kTexture));
if (texture_type->Is<sem::MultisampledTexture>() || if (texture_type->Is<type::MultisampledTexture>() ||
texture_type->Is<sem::StorageTexture>()) { texture_type->Is<type::StorageTexture>()) {
op = spv::Op::OpImageQuerySize; op = spv::Op::OpImageQuerySize;
} else { } else {
op = spv::Op::OpImageQuerySizeLod; op = spv::Op::OpImageQuerySizeLod;
@ -2864,7 +2864,7 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
break; break;
} }
case BuiltinType::kTextureLoad: { case BuiltinType::kTextureLoad: {
op = texture_type->Is<sem::StorageTexture>() ? spv::Op::OpImageRead op = texture_type->Is<type::StorageTexture>() ? spv::Op::OpImageRead
: spv::Op::OpImageFetch; : spv::Op::OpImageFetch;
append_result_type_and_id_to_spirv_params_for_read(); append_result_type_and_id_to_spirv_params_for_read();
spirv_params.emplace_back(gen_arg(Usage::kTexture)); spirv_params.emplace_back(gen_arg(Usage::kTexture));
@ -3280,8 +3280,8 @@ uint32_t Builder::GenerateSampledImage(const type::Type* texture_type,
// The Vulkan spec says: The "Depth" operand of OpTypeImage is ignored. // The Vulkan spec says: The "Depth" operand of OpTypeImage is ignored.
// In SPIRV, 0 means not depth, 1 means depth, and 2 means unknown. // In SPIRV, 0 means not depth, 1 means depth, and 2 means unknown.
// Using anything other than 0 is problematic on various Vulkan drivers. // Using anything other than 0 is problematic on various Vulkan drivers.
if (auto* depthTextureType = texture_type->As<sem::DepthTexture>()) { if (auto* depthTextureType = texture_type->As<type::DepthTexture>()) {
texture_type = builder_.create<sem::SampledTexture>(depthTextureType->dim(), texture_type = builder_.create<type::SampledTexture>(depthTextureType->dim(),
builder_.create<sem::F32>()); builder_.create<sem::F32>());
} }
@ -3645,11 +3645,11 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) {
// The Vulkan spec says: The "Depth" operand of OpTypeImage is ignored. // The Vulkan spec says: The "Depth" operand of OpTypeImage is ignored.
// In SPIRV, 0 means not depth, 1 means depth, and 2 means unknown. // In SPIRV, 0 means not depth, 1 means depth, and 2 means unknown.
// Using anything other than 0 is problematic on various Vulkan drivers. // Using anything other than 0 is problematic on various Vulkan drivers.
if (auto* depthTextureType = type->As<sem::DepthTexture>()) { if (auto* depthTextureType = type->As<type::DepthTexture>()) {
type = builder_.create<sem::SampledTexture>(depthTextureType->dim(), type = builder_.create<type::SampledTexture>(depthTextureType->dim(),
builder_.create<sem::F32>()); builder_.create<sem::F32>());
} else if (auto* multisampledDepthTextureType = type->As<sem::DepthMultisampledTexture>()) { } else if (auto* multisampledDepthTextureType = type->As<type::DepthMultisampledTexture>()) {
type = builder_.create<sem::MultisampledTexture>(multisampledDepthTextureType->dim(), type = builder_.create<type::MultisampledTexture>(multisampledDepthTextureType->dim(),
builder_.create<sem::F32>()); builder_.create<sem::F32>());
} }
@ -3715,7 +3715,7 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) {
push_type(spv::Op::OpTypeVoid, {result}); push_type(spv::Op::OpTypeVoid, {result});
return true; return true;
}, },
[&](const sem::StorageTexture* tex) { [&](const type::StorageTexture* tex) {
if (!GenerateTextureType(tex, result)) { if (!GenerateTextureType(tex, result)) {
return false; return false;
} }
@ -3723,15 +3723,15 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) {
// Register all three access types of StorageTexture names. In // Register all three access types of StorageTexture names. In
// SPIR-V, we must output a single type, while the variable is // SPIR-V, we must output a single type, while the variable is
// annotated with the access type. Doing this ensures we de-dupe. // annotated with the access type. Doing this ensures we de-dupe.
type_to_id_[builder_.create<sem::StorageTexture>( type_to_id_[builder_.create<type::StorageTexture>(
tex->dim(), tex->texel_format(), ast::Access::kRead, tex->type())] = id; tex->dim(), tex->texel_format(), ast::Access::kRead, tex->type())] = id;
type_to_id_[builder_.create<sem::StorageTexture>( type_to_id_[builder_.create<type::StorageTexture>(
tex->dim(), tex->texel_format(), ast::Access::kWrite, tex->type())] = id; tex->dim(), tex->texel_format(), ast::Access::kWrite, tex->type())] = id;
type_to_id_[builder_.create<sem::StorageTexture>( type_to_id_[builder_.create<type::StorageTexture>(
tex->dim(), tex->texel_format(), ast::Access::kReadWrite, tex->type())] = id; tex->dim(), tex->texel_format(), ast::Access::kReadWrite, tex->type())] = id;
return true; return true;
}, },
[&](const sem::Texture* tex) { return GenerateTextureType(tex, result); }, [&](const type::Texture* tex) { return GenerateTextureType(tex, result); },
[&](const sem::Sampler* s) { [&](const sem::Sampler* s) {
push_type(spv::Op::OpTypeSampler, {result}); 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) { bool Builder::GenerateTextureType(const type::Texture* texture, const Operand& result) {
if (texture->Is<sem::ExternalTexture>()) { if (texture->Is<type::ExternalTexture>()) {
TINT_ICE(Writer, builder_.Diagnostics()) TINT_ICE(Writer, builder_.Diagnostics())
<< "Multiplanar external texture transform was not run."; << "Multiplanar external texture transform was not run.";
return false; return false;
@ -3774,9 +3774,9 @@ bool Builder::GenerateTextureType(const sem::Texture* texture, const Operand& re
uint32_t dim_literal = SpvDim2D; uint32_t dim_literal = SpvDim2D;
if (dim == ast::TextureDimension::k1d) { if (dim == ast::TextureDimension::k1d) {
dim_literal = SpvDim1D; dim_literal = SpvDim1D;
if (texture->Is<sem::SampledTexture>()) { if (texture->Is<type::SampledTexture>()) {
push_capability(SpvCapabilitySampled1D); push_capability(SpvCapabilitySampled1D);
} else if (texture->Is<sem::StorageTexture>()) { } else if (texture->Is<type::StorageTexture>()) {
push_capability(SpvCapabilityImage1D); push_capability(SpvCapabilityImage1D);
} }
} }
@ -3788,7 +3788,7 @@ bool Builder::GenerateTextureType(const sem::Texture* texture, const Operand& re
} }
uint32_t ms_literal = 0u; uint32_t ms_literal = 0u;
if (texture->IsAnyOf<sem::MultisampledTexture, sem::DepthMultisampledTexture>()) { if (texture->IsAnyOf<type::MultisampledTexture, type::DepthMultisampledTexture>()) {
ms_literal = 1u; 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. // Using anything other than 0 is problematic on various Vulkan drivers.
uint32_t sampled_literal = 2u; uint32_t sampled_literal = 2u;
if (texture->IsAnyOf<sem::MultisampledTexture, sem::SampledTexture, sem::DepthTexture, if (texture->IsAnyOf<type::MultisampledTexture, type::SampledTexture, type::DepthTexture,
sem::DepthMultisampledTexture>()) { type::DepthMultisampledTexture>()) {
sampled_literal = 1u; sampled_literal = 1u;
} }
if (dim == ast::TextureDimension::kCubeArray) { if (dim == ast::TextureDimension::kCubeArray) {
if (texture->IsAnyOf<sem::SampledTexture, sem::DepthTexture>()) { if (texture->IsAnyOf<type::SampledTexture, type::DepthTexture>()) {
push_capability(SpvCapabilitySampledCubeArray); push_capability(SpvCapabilitySampledCubeArray);
} }
} }
uint32_t type_id = Switch( uint32_t type_id = Switch(
texture, texture,
[&](const sem::DepthTexture*) { return GenerateTypeIfNeeded(builder_.create<sem::F32>()); }, [&](const type::DepthTexture*) {
[&](const sem::DepthMultisampledTexture*) {
return GenerateTypeIfNeeded(builder_.create<sem::F32>()); return GenerateTypeIfNeeded(builder_.create<sem::F32>());
}, },
[&](const sem::SampledTexture* t) { return GenerateTypeIfNeeded(t->type()); }, [&](const type::DepthMultisampledTexture*) {
[&](const sem::MultisampledTexture* t) { return GenerateTypeIfNeeded(t->type()); }, return GenerateTypeIfNeeded(builder_.create<sem::F32>());
[&](const sem::StorageTexture* t) { return GenerateTypeIfNeeded(t->type()); }, },
[&](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; }); [&](Default) { return 0u; });
if (type_id == 0u) { if (type_id == 0u) {
return false; return false;
} }
uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown; uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown;
if (auto* t = texture->As<sem::StorageTexture>()) { if (auto* t = texture->As<type::StorageTexture>()) {
format_literal = convert_texel_format_to_spv(t->texel_format()); format_literal = convert_texel_format_to_spv(t->texel_format());
} }

View File

@ -36,7 +36,7 @@
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/scope_stack.h" #include "src/tint/scope_stack.h"
#include "src/tint/sem/builtin.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/function.h"
#include "src/tint/writer/spirv/scalar_constant.h" #include "src/tint/writer/spirv/scalar_constant.h"
@ -473,7 +473,7 @@ class Builder {
/// @param texture the texture to generate /// @param texture the texture to generate
/// @param result the result operand /// @param result the result operand
/// @returns true if the texture was successfully generated /// @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 /// Generates an array type declaration
/// @param ary the array to generate /// @param ary the array to generate
/// @param result the result operand /// @param result the result operand

View File

@ -14,7 +14,7 @@
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.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/utils/string.h"
#include "src/tint/writer/spirv/spv_dump.h" #include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h" #include "src/tint/writer/spirv/test_helper.h"

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/sem/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/sem/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
#include "src/tint/writer/spirv/spv_dump.h" #include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h" #include "src/tint/writer/spirv/test_helper.h"
@ -631,7 +631,7 @@ INSTANTIATE_TEST_SUITE_P(
PtrData{ast::AddressSpace::kFunction, SpvStorageClassFunction})); PtrData{ast::AddressSpace::kFunction, SpvStorageClassFunction}));
TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) { TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
auto* two_d = create<sem::DepthTexture>(ast::TextureDimension::k2d); auto* two_d = create<type::DepthTexture>(ast::TextureDimension::k2d);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -645,7 +645,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
} }
TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) { TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
auto* two_d_array = create<sem::DepthTexture>(ast::TextureDimension::k2dArray); auto* two_d_array = create<type::DepthTexture>(ast::TextureDimension::k2dArray);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -659,7 +659,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
} }
TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) { TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
auto* cube = create<sem::DepthTexture>(ast::TextureDimension::kCube); auto* cube = create<type::DepthTexture>(ast::TextureDimension::kCube);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -674,7 +674,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
} }
TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) { TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
auto* cube_array = create<sem::DepthTexture>(ast::TextureDimension::kCubeArray); auto* cube_array = create<type::DepthTexture>(ast::TextureDimension::kCubeArray);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -692,7 +692,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) { TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
auto* i32 = create<sem::I32>(); auto* i32 = create<sem::I32>();
auto* ms = create<sem::MultisampledTexture>(ast::TextureDimension::k2d, i32); auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, i32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -705,7 +705,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) { TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
auto* u32 = create<sem::U32>(); auto* u32 = create<sem::U32>();
auto* ms = create<sem::MultisampledTexture>(ast::TextureDimension::k2d, u32); auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, u32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -719,7 +719,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) { TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* ms = create<sem::MultisampledTexture>(ast::TextureDimension::k2d, f32); auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -732,7 +732,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
} }
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k1d, create<sem::I32>()); auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, create<sem::I32>());
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -750,7 +750,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
auto* u32 = create<sem::U32>(); auto* u32 = create<sem::U32>();
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k1d, u32); auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, u32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -768,7 +768,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k1d, f32); auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -786,7 +786,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k2d, f32); auto* s = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -800,7 +800,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k2dArray, f32); auto* s = create<type::SampledTexture>(ast::TextureDimension::k2dArray, f32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -814,7 +814,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k3d, f32); auto* s = create<type::SampledTexture>(ast::TextureDimension::k3d, f32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -828,7 +828,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::SampledTexture>(ast::TextureDimension::kCube, f32); auto* s = create<type::SampledTexture>(ast::TextureDimension::kCube, f32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -843,7 +843,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* s = create<sem::SampledTexture>(ast::TextureDimension::kCubeArray, f32); auto* s = create<type::SampledTexture>(ast::TextureDimension::kCubeArray, f32);
spirv::Builder& b = Build(); spirv::Builder& b = Build();

View File

@ -34,8 +34,8 @@
#include "src/tint/ast/switch_statement.h" #include "src/tint/ast/switch_statement.h"
#include "src/tint/ast/unary_op_expression.h" #include "src/tint/ast/unary_op_expression.h"
#include "src/tint/program.h" #include "src/tint/program.h"
#include "src/tint/sem/storage_texture.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/type/storage_texture.h"
#include "src/tint/writer/text_generator.h" #include "src/tint/writer/text_generator.h"
namespace tint::writer::wgsl { namespace tint::writer::wgsl {

View File

@ -14,7 +14,7 @@
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/variable_decl_statement.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" #include "src/tint/writer/wgsl/test_helper.h"
using namespace tint::number_suffixes; // NOLINT using namespace tint::number_suffixes; // NOLINT

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/sem/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/sem/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
#include "src/tint/sem/sampled_texture.h" #include "src/tint/type/sampled_texture.h"
#include "src/tint/writer/wgsl/test_helper.h" #include "src/tint/writer/wgsl/test_helper.h"
using namespace tint::number_suffixes; // NOLINT using namespace tint::number_suffixes; // NOLINT