diff --git a/src/ast/function.cc b/src/ast/function.cc index 09a554f2f8..08a286955f 100644 --- a/src/ast/function.cc +++ b/src/ast/function.cc @@ -18,6 +18,7 @@ #include "src/ast/decorated_variable.h" #include "src/ast/stage_decoration.h" +#include "src/ast/type/multisampled_texture_type.h" #include "src/ast/type/texture_type.h" #include "src/ast/workgroup_decoration.h" @@ -315,7 +316,7 @@ Function::ReferencedSampledTextureVariablesImpl(bool multisampled) const { } if ((multisampled && - !unwrapped_type->As()->IsMultisampled()) || + !unwrapped_type->Is()) || (!multisampled && !unwrapped_type->As()->IsSampled())) { continue; diff --git a/src/ast/type/multisampled_texture_type.cc b/src/ast/type/multisampled_texture_type.cc index 7de7dc52e5..bcca076497 100644 --- a/src/ast/type/multisampled_texture_type.cc +++ b/src/ast/type/multisampled_texture_type.cc @@ -32,9 +32,6 @@ MultisampledTextureType::MultisampledTextureType(MultisampledTextureType&&) = MultisampledTextureType::~MultisampledTextureType() = default; -bool MultisampledTextureType::IsMultisampled() const { - return true; -} std::string MultisampledTextureType::type_name() const { std::ostringstream out; diff --git a/src/ast/type/multisampled_texture_type.h b/src/ast/type/multisampled_texture_type.h index 4c68c56853..2cebe1fa79 100644 --- a/src/ast/type/multisampled_texture_type.h +++ b/src/ast/type/multisampled_texture_type.h @@ -35,9 +35,6 @@ class MultisampledTextureType MultisampledTextureType(MultisampledTextureType&&); ~MultisampledTextureType() override; - /// @returns true if the type is a sampled texture type - bool IsMultisampled() const override; - /// @returns the subtype of the sampled texture Type* type() const { return type_; } diff --git a/src/ast/type/multisampled_texture_type_test.cc b/src/ast/type/multisampled_texture_type_test.cc index 108acb2cba..10cf1d2297 100644 --- a/src/ast/type/multisampled_texture_type_test.cc +++ b/src/ast/type/multisampled_texture_type_test.cc @@ -58,7 +58,7 @@ TEST_F(MultisampledTextureTypeTest, IsTextureType) { MultisampledTextureType s(TextureDimension::kCube, &f32); TextureType* ty = &s; EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->IsMultisampled()); + EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->IsSampled()); EXPECT_FALSE(ty->IsStorage()); } diff --git a/src/ast/type/texture_type.cc b/src/ast/type/texture_type.cc index 2e986f4432..18ea61a49e 100644 --- a/src/ast/type/texture_type.cc +++ b/src/ast/type/texture_type.cc @@ -60,9 +60,6 @@ TextureType::TextureType(TextureType&&) = default; TextureType::~TextureType() = default; -bool TextureType::IsMultisampled() const { - return false; -} bool TextureType::IsStorage() const { return false; } @@ -70,11 +67,6 @@ bool TextureType::IsSampled() const { return false; } -const MultisampledTextureType* TextureType::AsMultisampled() const { - assert(IsMultisampled()); - return static_cast(this); -} - const SampledTextureType* TextureType::AsSampled() const { assert(IsSampled()); return static_cast(this); @@ -85,11 +77,6 @@ const StorageTextureType* TextureType::AsStorage() const { return static_cast(this); } -MultisampledTextureType* TextureType::AsMultisampled() { - assert(IsMultisampled()); - return static_cast(this); -} - SampledTextureType* TextureType::AsSampled() { assert(IsSampled()); return static_cast(this); diff --git a/src/ast/type/texture_type.h b/src/ast/type/texture_type.h index b2eba824a7..a2139b8274 100644 --- a/src/ast/type/texture_type.h +++ b/src/ast/type/texture_type.h @@ -24,8 +24,6 @@ namespace tint { namespace ast { namespace type { -class DepthTextureType; -class MultisampledTextureType; class SampledTextureType; class StorageTextureType; @@ -63,22 +61,16 @@ class TextureType : public Castable { /// @returns the texture dimension TextureDimension dim() const { return dim_; } - /// @returns ture if this is a multisampled texture - virtual bool IsMultisampled() const; /// @returns true if this is a storage texture virtual bool IsStorage() const; /// @returns true if this is a sampled texture virtual bool IsSampled() const; - /// @returns the texture as a multisampled texture - const MultisampledTextureType* AsMultisampled() const; /// @returns the texture as a sampled texture const SampledTextureType* AsSampled() const; /// @returns the texture as a storage texture const StorageTextureType* AsStorage() const; - /// @returns the texture as a multisampled texture - MultisampledTextureType* AsMultisampled(); /// @returns the texture as a sampled texture SampledTextureType* AsSampled(); /// @returns the texture as a storage texture diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index 678b1f6c36..5cacc0fa86 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -382,7 +382,9 @@ std::vector Inspector::GetSampledTextureResourceBindingsImpl( ast::type::Type* base_type = nullptr; if (multisampled_only) { - base_type = texture_type->AsMultisampled()->type()->UnwrapIfNeeded(); + base_type = texture_type->As() + ->type() + ->UnwrapIfNeeded(); } else { base_type = texture_type->AsSampled()->type()->UnwrapIfNeeded(); } diff --git a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc index 23869a4e4c..13aab4ff2c 100644 --- a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc +++ b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc @@ -263,9 +263,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->IsMultisampled()); - ASSERT_TRUE(t->As() - ->AsMultisampled() + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As() ->type() ->Is()); EXPECT_EQ(t->As()->dim(), diff --git a/src/type_determiner.cc b/src/type_determiner.cc index 9d75b843b1..5a423ab389 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -672,7 +672,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, } if (!texture->IsStorage() && - !(texture->IsSampled() || texture->IsMultisampled())) { + !(texture->IsSampled() || + texture->Is())) { set_error(expr->source(), "invalid texture for " + ident->name()); return false; } @@ -682,8 +683,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, type = texture->AsStorage()->type(); } else if (texture->IsSampled()) { type = texture->AsSampled()->type(); - } else if (texture->IsMultisampled()) { - type = texture->AsMultisampled()->type(); + } else if (texture->Is()) { + type = texture->As()->type(); } else { set_error(expr->source(), "unknown texture type for texture sampling"); return false; diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 41795e2a68..19de1c05af 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -1874,7 +1874,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) { error_ = "Invalid texture dimensions"; return false; } - if (tex->IsMultisampled()) { + if (tex->Is()) { out_ << "_ms"; } out_ << "<"; @@ -1894,8 +1894,9 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) { error_ = "Invalid access control for storage texture"; return false; } - } else if (tex->IsMultisampled()) { - if (!EmitType(tex->AsMultisampled()->type(), "")) { + } else if (tex->Is()) { + if (!EmitType(tex->As()->type(), + "")) { return false; } out_ << ", access::sample"; diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index f7b28a8510..06020069d6 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -1972,7 +1972,7 @@ void Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident, // TODO(dsinclair): Remove the LOD param from textureLoad on storage // textures when https://github.com/gpuweb/gpuweb/pull/1032 gets merged. if (pidx.level != kNotUsed) { - if (texture_type->IsMultisampled()) { + if (texture_type->Is()) { spirv_operand_mask |= SpvImageOperandsSampleMask; } else { spirv_operand_mask |= SpvImageOperandsLodMask; @@ -2516,7 +2516,7 @@ bool Builder::GenerateTextureType(ast::type::TextureType* texture, } uint32_t ms_literal = 0u; - if (texture->IsMultisampled()) { + if (texture->Is()) { ms_literal = 1u; } @@ -2526,8 +2526,8 @@ bool Builder::GenerateTextureType(ast::type::TextureType* texture, } uint32_t sampled_literal = 2u; - if (texture->IsMultisampled() || texture->IsSampled() || - texture->Is()) { + if (texture->Is() || + texture->IsSampled() || texture->Is()) { sampled_literal = 1u; } @@ -2543,8 +2543,9 @@ bool Builder::GenerateTextureType(ast::type::TextureType* texture, type_id = GenerateTypeIfNeeded(&f32); } else if (texture->IsSampled()) { type_id = GenerateTypeIfNeeded(texture->AsSampled()->type()); - } else if (texture->IsMultisampled()) { - type_id = GenerateTypeIfNeeded(texture->AsMultisampled()->type()); + } else if (texture->Is()) { + type_id = GenerateTypeIfNeeded( + texture->As()->type()); } else if (texture->IsStorage()) { if (texture->AsStorage()->access() == ast::AccessControl::kWriteOnly) { ast::type::VoidType void_type; diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index 7e53242caa..7f0b7d02ed 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -474,7 +474,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) { out_ << "depth_"; } else if (texture->IsSampled()) { /* nothing to emit */ - } else if (texture->IsMultisampled()) { + } else if (texture->Is()) { out_ << "multisampled_"; } else if (texture->IsStorage()) { out_ << "storage_"; @@ -528,8 +528,8 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) { return false; } out_ << ">"; - } else if (texture->IsMultisampled()) { - auto* sampled = texture->AsMultisampled(); + } else if (texture->Is()) { + auto* sampled = texture->As(); out_ << "<"; if (!EmitType(sampled->type())) {