tint/ast: Remove ast::DepthTexture and ast::DepthMultisampledTexture

Instead use ast::TypeName.

Bug: tint:1810
Change-Id: Id9fe641d193967cb27cea97e9c25b75c5fe2f1a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119122
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton 2023-02-10 02:34:21 +00:00 committed by Dawn LUCI CQ
parent 63b777b552
commit a5fec206c9
24 changed files with 274 additions and 482 deletions

View File

@ -260,8 +260,6 @@ libtint_source_set("libtint_syntax_tree_src") {
"ast/const.h",
"ast/const_assert.h",
"ast/continue_statement.h",
"ast/depth_multisampled_texture.h",
"ast/depth_texture.h",
"ast/diagnostic_attribute.h",
"ast/diagnostic_control.h",
"ast/diagnostic_directive.h",
@ -586,10 +584,6 @@ libtint_source_set("libtint_ast_src") {
"ast/const_assert.h",
"ast/continue_statement.cc",
"ast/continue_statement.h",
"ast/depth_multisampled_texture.cc",
"ast/depth_multisampled_texture.h",
"ast/depth_texture.cc",
"ast/depth_texture.h",
"ast/diagnostic_attribute.cc",
"ast/diagnostic_attribute.h",
"ast/diagnostic_control.cc",

View File

@ -124,10 +124,6 @@ list(APPEND TINT_LIB_SRCS
ast/const_assert.h
ast/continue_statement.cc
ast/continue_statement.h
ast/depth_multisampled_texture.cc
ast/depth_multisampled_texture.h
ast/depth_texture.cc
ast/depth_texture.h
ast/diagnostic_attribute.cc
ast/diagnostic_attribute.h
ast/diagnostic_control.cc
@ -832,8 +828,6 @@ if(TINT_BUILD_TESTS)
ast/compound_assignment_statement_test.cc
ast/const_assert_test.cc
ast/continue_statement_test.cc
ast/depth_multisampled_texture_test.cc
ast/depth_texture_test.cc
ast/diagnostic_attribute_test.cc
ast/diagnostic_control_test.cc
ast/diagnostic_directive_test.cc

View File

@ -1,53 +0,0 @@
// Copyright 2021 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/ast/depth_multisampled_texture.h"
#include "src/tint/program_builder.h"
TINT_INSTANTIATE_TYPEINFO(tint::ast::DepthMultisampledTexture);
namespace tint::ast {
namespace {
bool IsValidDepthDimension(type::TextureDimension dim) {
return dim == type::TextureDimension::k2d;
}
} // namespace
DepthMultisampledTexture::DepthMultisampledTexture(ProgramID pid,
NodeID nid,
const Source& src,
type::TextureDimension d)
: Base(pid, nid, src, d) {
TINT_ASSERT(AST, IsValidDepthDimension(dim));
}
DepthMultisampledTexture::DepthMultisampledTexture(DepthMultisampledTexture&&) = default;
DepthMultisampledTexture::~DepthMultisampledTexture() = default;
std::string DepthMultisampledTexture::FriendlyName(const SymbolTable&) const {
std::ostringstream out;
out << "texture_depth_multisampled_" << dim;
return out.str();
}
const DepthMultisampledTexture* DepthMultisampledTexture::Clone(CloneContext* ctx) const {
auto src = ctx->Clone(source);
return ctx->dst->create<DepthMultisampledTexture>(src, dim);
}
} // namespace tint::ast

View File

@ -1,54 +0,0 @@
// Copyright 2021 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_TINT_AST_DEPTH_MULTISAMPLED_TEXTURE_H_
#define SRC_TINT_AST_DEPTH_MULTISAMPLED_TEXTURE_H_
#include <string>
#include "src/tint/ast/texture.h"
#include "src/tint/type/texture_dimension.h"
namespace tint::ast {
/// A multisampled depth texture type.
class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture, Texture> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param dim the dimensionality of the texture
DepthMultisampledTexture(ProgramID pid,
NodeID nid,
const Source& src,
type::TextureDimension dim);
/// Move constructor
DepthMultisampledTexture(DepthMultisampledTexture&&);
~DepthMultisampledTexture() override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
const DepthMultisampledTexture* Clone(CloneContext* ctx) const override;
};
} // namespace tint::ast
#endif // SRC_TINT_AST_DEPTH_MULTISAMPLED_TEXTURE_H_

View File

@ -1,35 +0,0 @@
// Copyright 2021 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/ast/depth_multisampled_texture.h"
#include "src/tint/ast/test_helper.h"
namespace tint::ast {
namespace {
using AstDepthMultisampledTextureTest = TestHelper;
TEST_F(AstDepthMultisampledTextureTest, Dim) {
auto* d = create<DepthMultisampledTexture>(type::TextureDimension::k2d);
EXPECT_EQ(d->dim, type::TextureDimension::k2d);
}
TEST_F(AstDepthMultisampledTextureTest, FriendlyName) {
auto* d = create<DepthMultisampledTexture>(type::TextureDimension::k2d);
EXPECT_EQ(d->FriendlyName(Symbols()), "texture_depth_multisampled_2d");
}
} // namespace
} // namespace tint::ast

View File

@ -1,51 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/ast/depth_texture.h"
#include "src/tint/program_builder.h"
TINT_INSTANTIATE_TYPEINFO(tint::ast::DepthTexture);
namespace tint::ast {
namespace {
bool IsValidDepthDimension(type::TextureDimension dim) {
return dim == type::TextureDimension::k2d || dim == type::TextureDimension::k2dArray ||
dim == type::TextureDimension::kCube || dim == type::TextureDimension::kCubeArray;
}
} // namespace
DepthTexture::DepthTexture(ProgramID pid, NodeID nid, const Source& src, type::TextureDimension d)
: Base(pid, nid, src, d) {
TINT_ASSERT(AST, IsValidDepthDimension(dim));
}
DepthTexture::DepthTexture(DepthTexture&&) = default;
DepthTexture::~DepthTexture() = default;
std::string DepthTexture::FriendlyName(const SymbolTable&) const {
std::ostringstream out;
out << "texture_depth_" << dim;
return out.str();
}
const DepthTexture* DepthTexture::Clone(CloneContext* ctx) const {
auto src = ctx->Clone(source);
return ctx->dst->create<DepthTexture>(src, dim);
}
} // namespace tint::ast

View File

@ -1,51 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_TINT_AST_DEPTH_TEXTURE_H_
#define SRC_TINT_AST_DEPTH_TEXTURE_H_
#include <string>
#include "src/tint/ast/texture.h"
#include "src/tint/type/texture_dimension.h"
namespace tint::ast {
/// A depth texture type.
class DepthTexture final : public Castable<DepthTexture, Texture> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param dim the dimensionality of the texture
DepthTexture(ProgramID pid, NodeID nid, const Source& src, type::TextureDimension dim);
/// Move constructor
DepthTexture(DepthTexture&&);
~DepthTexture() override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
const DepthTexture* Clone(CloneContext* ctx) const override;
};
} // namespace tint::ast
#endif // SRC_TINT_AST_DEPTH_TEXTURE_H_

View File

@ -1,42 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/ast/depth_texture.h"
#include "src/tint/ast/test_helper.h"
namespace tint::ast {
namespace {
using AstDepthTextureTest = TestHelper;
TEST_F(AstDepthTextureTest, IsTexture) {
Texture* ty = create<DepthTexture>(type::TextureDimension::kCube);
EXPECT_TRUE(ty->Is<DepthTexture>());
EXPECT_FALSE(ty->Is<SampledTexture>());
EXPECT_FALSE(ty->Is<StorageTexture>());
}
TEST_F(AstDepthTextureTest, Dim) {
auto* d = create<DepthTexture>(type::TextureDimension::kCube);
EXPECT_EQ(d->dim, type::TextureDimension::kCube);
}
TEST_F(AstDepthTextureTest, FriendlyName) {
auto* d = create<DepthTexture>(type::TextureDimension::kCube);
EXPECT_EQ(d->FriendlyName(Symbols()), "texture_depth_cube");
}
} // namespace
} // namespace tint::ast

View File

@ -16,7 +16,6 @@
#include "src/tint/ast/alias.h"
#include "src/tint/ast/array.h"
#include "src/tint/ast/depth_texture.h"
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/sampled_texture.h"
@ -34,7 +33,6 @@ using AstMultisampledTextureTest = TestHelper;
TEST_F(AstMultisampledTextureTest, IsTexture) {
Texture* t = create<MultisampledTexture>(type::TextureDimension::kCube, ty.f32());
EXPECT_FALSE(t->Is<DepthTexture>());
EXPECT_TRUE(t->Is<MultisampledTexture>());
EXPECT_FALSE(t->Is<SampledTexture>());
EXPECT_FALSE(t->Is<StorageTexture>());

View File

@ -23,7 +23,6 @@ using AstSampledTextureTest = TestHelper;
TEST_F(AstSampledTextureTest, IsTexture) {
Texture* t = create<SampledTexture>(type::TextureDimension::kCube, ty.f32());
EXPECT_FALSE(t->Is<DepthTexture>());
EXPECT_TRUE(t->Is<SampledTexture>());
EXPECT_FALSE(t->Is<StorageTexture>());
}

View File

@ -26,7 +26,6 @@ TEST_F(AstStorageTextureTest, IsTexture) {
Texture* ty =
create<StorageTexture>(type::TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
subtype, type::Access::kRead);
EXPECT_FALSE(ty->Is<DepthTexture>());
EXPECT_FALSE(ty->Is<SampledTexture>());
EXPECT_TRUE(ty->Is<StorageTexture>());
}

View File

@ -170,6 +170,12 @@ enum builtin_type {
// https://www.w3.org/TR/WGSL/#sampler-type
sampler
sampler_comparison
// https://www.w3.org/TR/WGSL/#texture-depth
texture_depth_2d
texture_depth_2d_array
texture_depth_cube
texture_depth_cube_array
texture_depth_multisampled_2d
// https://www.w3.org/TR/WGSL/#external-texture-type
texture_external
}

View File

@ -38,8 +38,6 @@
#include "src/tint/ast/const.h"
#include "src/tint/ast/const_assert.h"
#include "src/tint/ast/continue_statement.h"
#include "src/tint/ast/depth_multisampled_texture.h"
#include "src/tint/ast/depth_texture.h"
#include "src/tint/ast/diagnostic_attribute.h"
#include "src/tint/ast/diagnostic_control.h"
#include "src/tint/ast/diagnostic_directive.h"
@ -980,33 +978,50 @@ class ProgramBuilder {
}
/// @param dims the dimensionality of the texture
/// @returns the depth texture
const ast::DepthTexture* depth_texture(type::TextureDimension dims) const {
return builder->create<ast::DepthTexture>(dims);
/// @returns the depth texture typename
const ast::TypeName* depth_texture(type::TextureDimension dims) const {
return depth_texture(builder->source_, dims);
}
/// @param source the Source of the node
/// @param dims the dimensionality of the texture
/// @returns the depth texture
const ast::DepthTexture* depth_texture(const Source& source,
/// @returns the depth texture typename
const ast::TypeName* depth_texture(const Source& source,
type::TextureDimension dims) const {
return builder->create<ast::DepthTexture>(source, dims);
switch (dims) {
case type::TextureDimension::k2d:
return (*this)(source, "texture_depth_2d");
case type::TextureDimension::k2dArray:
return (*this)(source, "texture_depth_2d_array");
case type::TextureDimension::kCube:
return (*this)(source, "texture_depth_cube");
case type::TextureDimension::kCubeArray:
return (*this)(source, "texture_depth_cube_array");
default:
break;
}
TINT_ICE(ProgramBuilder, builder->Diagnostics())
<< "invalid depth_texture dimensions: " << dims;
return nullptr;
}
/// @param dims the dimensionality of the texture
/// @returns the multisampled depth texture
const ast::DepthMultisampledTexture* depth_multisampled_texture(
type::TextureDimension dims) const {
return builder->create<ast::DepthMultisampledTexture>(dims);
/// @returns the multisampled depth texture typename
const ast::TypeName* depth_multisampled_texture(type::TextureDimension dims) const {
return depth_multisampled_texture(builder->source_, dims);
}
/// @param source the Source of the node
/// @param dims the dimensionality of the texture
/// @returns the multisampled depth texture
const ast::DepthMultisampledTexture* depth_multisampled_texture(
const Source& source,
/// @returns the multisampled depth texture typename
const ast::TypeName* depth_multisampled_texture(const Source& source,
type::TextureDimension dims) const {
return builder->create<ast::DepthMultisampledTexture>(source, dims);
if (dims == type::TextureDimension::k2d) {
return (*this)(source, "texture_depth_multisampled_2d");
}
TINT_ICE(ProgramBuilder, builder->Diagnostics())
<< "invalid depth_multisampled_texture dimensions: " << dims;
return nullptr;
}
/// @param dims the dimensionality of the texture

View File

@ -33,9 +33,8 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Texture>());
ASSERT_TRUE(t->Is<ast::DepthTexture>());
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"texture_depth_2d");
EXPECT_FALSE(p->has_error());
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 17u}}));
}
@ -46,9 +45,8 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Texture>());
ASSERT_TRUE(t->Is<ast::DepthTexture>());
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2dArray);
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"texture_depth_2d_array");
EXPECT_FALSE(p->has_error());
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 23u}}));
}
@ -59,9 +57,8 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Texture>());
ASSERT_TRUE(t->Is<ast::DepthTexture>());
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::kCube);
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"texture_depth_cube");
EXPECT_FALSE(p->has_error());
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 19u}}));
}
@ -72,9 +69,8 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Texture>());
ASSERT_TRUE(t->Is<ast::DepthTexture>());
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::kCubeArray);
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"texture_depth_cube_array");
EXPECT_FALSE(p->has_error());
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 25u}}));
}
@ -85,9 +81,8 @@ TEST_F(ParserImplTest, DepthTextureType_Multisampled2d) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Texture>());
ASSERT_TRUE(t->Is<ast::DepthMultisampledTexture>());
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"texture_depth_multisampled_2d");
EXPECT_FALSE(p->has_error());
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 30u}}));
}

View File

@ -61,9 +61,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Texture>());
ASSERT_TRUE(t->Is<ast::DepthTexture>());
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"texture_depth_2d");
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 17u}}));
}

View File

@ -29,8 +29,6 @@
#include "src/tint/ast/compound_assignment_statement.h"
#include "src/tint/ast/const.h"
#include "src/tint/ast/continue_statement.h"
#include "src/tint/ast/depth_multisampled_texture.h"
#include "src/tint/ast/depth_texture.h"
#include "src/tint/ast/diagnostic_attribute.h"
#include "src/tint/ast/discard_statement.h"
#include "src/tint/ast/for_loop_statement.h"
@ -403,11 +401,7 @@ class DependencyScanner {
[&](const ast::StorageTexture* tex) { //
TraverseType(tex->type);
},
[&](Default) {
if (!ty->IsAnyOf<ast::DepthTexture, ast::DepthMultisampledTexture>()) {
UnhandledNode(diagnostics_, ty);
}
});
[&](Default) { UnhandledNode(diagnostics_, ty); });
}
/// Traverses the attribute list, performing symbol resolution and

View File

@ -28,7 +28,6 @@
#include "src/tint/ast/break_statement.h"
#include "src/tint/ast/call_statement.h"
#include "src/tint/ast/continue_statement.h"
#include "src/tint/ast/depth_texture.h"
#include "src/tint/ast/disable_validation_attribute.h"
#include "src/tint/ast/discard_statement.h"
#include "src/tint/ast/for_loop_statement.h"
@ -309,10 +308,6 @@ type::Type* Resolver::Type(const ast::Type* ty) {
}
return nullptr;
},
[&](const ast::DepthTexture* t) { return builder_->create<type::DepthTexture>(t->dim); },
[&](const ast::DepthMultisampledTexture* t) {
return builder_->create<type::DepthMultisampledTexture>(t->dim);
},
[&](const ast::StorageTexture* t) -> type::StorageTexture* {
if (auto* el = Type(t->type)) {
if (!validator_.StorageTexture(t)) {
@ -2527,6 +2522,16 @@ type::Type* Resolver::BuiltinType(type::Builtin builtin_ty, const ast::Identifie
return builder_->create<type::Sampler>(type::SamplerKind::kSampler);
case type::Builtin::kSamplerComparison:
return builder_->create<type::Sampler>(type::SamplerKind::kComparisonSampler);
case type::Builtin::kTextureDepth2D:
return builder_->create<type::DepthTexture>(type::TextureDimension::k2d);
case type::Builtin::kTextureDepth2DArray:
return builder_->create<type::DepthTexture>(type::TextureDimension::k2dArray);
case type::Builtin::kTextureDepthCube:
return builder_->create<type::DepthTexture>(type::TextureDimension::kCube);
case type::Builtin::kTextureDepthCubeArray:
return builder_->create<type::DepthTexture>(type::TextureDimension::kCubeArray);
case type::Builtin::kTextureDepthMultisampled2D:
return builder_->create<type::DepthMultisampledTexture>(type::TextureDimension::k2d);
case type::Builtin::kTextureExternal:
return builder_->create<type::ExternalTexture>();
case type::Builtin::kUndefined:

View File

@ -25,7 +25,6 @@
#include "src/tint/ast/break_statement.h"
#include "src/tint/ast/call_statement.h"
#include "src/tint/ast/continue_statement.h"
#include "src/tint/ast/depth_texture.h"
#include "src/tint/ast/disable_validation_attribute.h"
#include "src/tint/ast/discard_statement.h"
#include "src/tint/ast/for_loop_statement.h"

View File

@ -147,10 +147,10 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type
return ctx.dst->create<ast::Atomic>(CreateASTTypeFor(ctx, a->Type()));
}
if (auto* t = ty->As<type::DepthTexture>()) {
return ctx.dst->create<ast::DepthTexture>(t->dim());
return ctx.dst->ty.depth_texture(t->dim());
}
if (auto* t = ty->As<type::DepthMultisampledTexture>()) {
return ctx.dst->create<ast::DepthMultisampledTexture>(t->dim());
return ctx.dst->ty.depth_multisampled_texture(t->dim());
}
if (ty->Is<type::ExternalTexture>()) {
return ctx.dst->ty.external_texture();

View File

@ -100,6 +100,21 @@ Builtin ParseBuiltin(std::string_view str) {
if (str == "sampler_comparison") {
return Builtin::kSamplerComparison;
}
if (str == "texture_depth_2d") {
return Builtin::kTextureDepth2D;
}
if (str == "texture_depth_2d_array") {
return Builtin::kTextureDepth2DArray;
}
if (str == "texture_depth_cube") {
return Builtin::kTextureDepthCube;
}
if (str == "texture_depth_cube_array") {
return Builtin::kTextureDepthCubeArray;
}
if (str == "texture_depth_multisampled_2d") {
return Builtin::kTextureDepthMultisampled2D;
}
if (str == "texture_external") {
return Builtin::kTextureExternal;
}
@ -197,6 +212,16 @@ std::ostream& operator<<(std::ostream& out, Builtin value) {
return out << "sampler";
case Builtin::kSamplerComparison:
return out << "sampler_comparison";
case Builtin::kTextureDepth2D:
return out << "texture_depth_2d";
case Builtin::kTextureDepth2DArray:
return out << "texture_depth_2d_array";
case Builtin::kTextureDepthCube:
return out << "texture_depth_cube";
case Builtin::kTextureDepthCubeArray:
return out << "texture_depth_cube_array";
case Builtin::kTextureDepthMultisampled2D:
return out << "texture_depth_multisampled_2d";
case Builtin::kTextureExternal:
return out << "texture_external";
case Builtin::kU32:

View File

@ -54,6 +54,11 @@ enum class Builtin {
kMat4X4H,
kSampler,
kSamplerComparison,
kTextureDepth2D,
kTextureDepth2DArray,
kTextureDepthCube,
kTextureDepthCubeArray,
kTextureDepthMultisampled2D,
kTextureExternal,
kU32,
kVec2F,
@ -105,6 +110,11 @@ constexpr const char* kBuiltinStrings[] = {
"mat4x4h",
"sampler",
"sampler_comparison",
"texture_depth_2d",
"texture_depth_2d_array",
"texture_depth_cube",
"texture_depth_cube_array",
"texture_depth_multisampled_2d",
"texture_external",
"u32",
"vec2f",

View File

@ -199,104 +199,139 @@ void BuiltinParser(::benchmark::State& state) {
"samplpLL_comparisI",
"smplerfomparison",
"sYmpURDr_comprison",
"texturh_external",
"teqtureuIIextnal",
"texture_externaH",
"texturh_depth_2d",
"teqtureuIIdep_2d",
"texture_depth_2H",
"texture_depth_2d",
"texre_depth_2Qvv",
"te66ue_depeh_2d",
"textue_d7pOh_2d",
"textureDDde0th_255_array",
"texture_IIepth_Hd_array",
"txture_depth_2d_array",
"texture_depth_2d_array",
"txture_depth_2r_array",
"tlxture_depth_2d_array",
"ttexturGdeth_2d_arrJJy",
"yexture_depth_cbe",
"texturedepth_cube",
"texture_IIeptBB_cube",
"texture_depth_cube",
"textKre_depth_c83TTe",
"texSnnYUUure_depth_cube",
"textuxe_5eptCCdZube",
"texturekkdepth_cube_arraq",
"exture_dppt00iicube5array",
"texIIurenndepth_cube_array",
"texture_depth_cube_array",
"ccextue_depth_cube_aKWa",
"texture_epth_cube_raKK",
"texture_depth_cube_a66ray",
"textEPPeKKdept_multisampled_2",
"texture_depth_mutisampledxx2d",
"texture_depth_qultisampled_2d",
"texture_depth_multisampled_2d",
"textureyydMMptr_mutisampleSS_2d",
"txture_depth_muluisampled2d",
"texSure_ept_mutisampled_2d",
"textu5e_externFFl",
"text44rrr_exterzal",
"texue_eWWtenal",
"texture_external",
"texre_externaQvv",
"te66ue_external",
"textue_e7tOrnal",
"550DD",
"II3H",
"u3",
"textuXe_ZZxtJJrnal",
"textuPPe_eternal",
"texturc_external",
"ull62",
"93yy",
"u3KK",
"u32",
"r2",
"u3l",
"uGt",
"ey2f",
"x_",
"K",
"kVz",
"veKSf",
"vc2f",
"IIeBB2f",
"ec2VV",
"vec2f",
"TTec338",
"veUUSS2nnd",
"vZx5CC",
"kkec2q",
"v005ih",
"vnIIc2h",
"vec2h",
"cceW",
"cKK",
"vec66h",
"vePPK",
"vexxi",
"qec2i",
"vec2i",
"veSyMMr",
"v2u",
"ec",
"5eFF2u",
"rrecz44",
"vWW",
"vec2u",
"XJecCZZ",
"vePP2",
"vec2c",
"ve6ll3f",
"vcyy99",
"Jec3KK",
"vec3f",
"_ex3",
"Ky3",
"zek3f",
"veKSh",
"vc3h",
"ec3VV",
"vec3h",
"IAAc3h",
"IAAc2f",
"jbR",
"veY4",
"ec3i",
"ec2h",
"vc911",
"mmcci",
"vec3i",
"vJJci",
"mmcch",
"vec2h",
"vJJch",
"lDDcUfC",
"vec3g",
"vec2g",
"CCe",
"ec3u",
"vIc__u",
"vec3u",
"ec2i",
"vIc__i",
"vec2i",
"ePPtt",
"v3dc3u",
"vcyyu",
"u4",
"v03nnf",
"v3dc2i",
"vcyyi",
"u2",
"v03nnu",
"Cuuecnv",
"vec4f",
"vX4ll",
"vocppf",
"vwwc4",
"vec2u",
"vX2ll",
"vocppu",
"vwwc2",
"veuug",
"vaac",
"TRZccch",
"vec4h",
"vTc4O8",
"vem04h",
"meBB4h",
"Mpp4",
"OOe4i",
"veG4G",
"vec4i",
"11eHH4i",
"TRZcccf",
"vec3f",
"vTc3O8",
"vem03f",
"meBB3f",
"Mpp3",
"OOe3h",
"veG3G",
"vec3h",
"11eHH3h",
"veFFe6",
"ve4",
"vKii4l",
"ec4u",
"v994IIv",
"ve3",
"vKii3l",
"ec3i",
"v993IIv",
"vec3i",
"veci",
"vechi",
"vczllPi",
"u",
"vffqq3",
"vJdd3u",
"vec3u",
"vecXX",
"ve32",
"Nyyc3u",
"vO4",
"PEruZ",
"vlc2edd",
"vec4f",
"ec9f",
"ve1II",
"veb4f",
"vi7",
"oec4ii",
"ec4",
"vec4h",
"veci",
"22ec",
"vGc4C",
"ffec48",
"c4i",
"JJecSSi",
"vec4i",
"94i",
"vbbJJ4TT",
"e66i",
"u664u",
"vW4u",
"v4u",
"vec4u",
"vecu",
"vechu",
"vczllPu",
"rec4u",
"2ec4B",
};
for (auto _ : state) {
for (auto* str : kStrings) {

View File

@ -67,6 +67,11 @@ static constexpr Case kValidCases[] = {
{"mat4x4h", Builtin::kMat4X4H},
{"sampler", Builtin::kSampler},
{"sampler_comparison", Builtin::kSamplerComparison},
{"texture_depth_2d", Builtin::kTextureDepth2D},
{"texture_depth_2d_array", Builtin::kTextureDepth2DArray},
{"texture_depth_cube", Builtin::kTextureDepthCube},
{"texture_depth_cube_array", Builtin::kTextureDepthCubeArray},
{"texture_depth_multisampled_2d", Builtin::kTextureDepthMultisampled2D},
{"texture_external", Builtin::kTextureExternal},
{"u32", Builtin::kU32},
{"vec2f", Builtin::kVec2F},
@ -156,48 +161,63 @@ static constexpr Case kInvalidCases[] = {
{"sWWpleq_compari44on", Builtin::kUndefined},
{"sampler_compaisoOO", Builtin::kUndefined},
{"smpeoo_coYparison", Builtin::kUndefined},
{"eture_eternal", Builtin::kUndefined},
{"texture_exeFnal", Builtin::kUndefined},
{"textureewternal", Builtin::kUndefined},
{"Gf", Builtin::kUndefined},
{"KK3q", Builtin::kUndefined},
{"umm2", Builtin::kUndefined},
{"vecf", Builtin::kUndefined},
{"qc2f", Builtin::kUndefined},
{"vecbb", Builtin::kUndefined},
{"iic2", Builtin::kUndefined},
{"vqOOh", Builtin::kUndefined},
{"vevvTTh", Builtin::kUndefined},
{"veFF2i", Builtin::kUndefined},
{"00PfQ", Builtin::kUndefined},
{"vec2P", Builtin::kUndefined},
{"vec77s", Builtin::kUndefined},
{"vecbbCu", Builtin::kUndefined},
{"vecXXu", Builtin::kUndefined},
{"CCOOec3", Builtin::kUndefined},
{"vs3u", Builtin::kUndefined},
{"Xec3f", Builtin::kUndefined},
{"ve3h", Builtin::kUndefined},
{"qq3", Builtin::kUndefined},
{"vec322", Builtin::kUndefined},
{"eture_dpth_2d", Builtin::kUndefined},
{"texture_detF_2d", Builtin::kUndefined},
{"texturedwpth_2d", Builtin::kUndefined},
{"teKuffe_Gepth_2d_arry", Builtin::kUndefined},
{"texture_dKKptq_2d_array", Builtin::kUndefined},
{"texture_depmmh32d_arraF", Builtin::kUndefined},
{"textur_depth_cube", Builtin::kUndefined},
{"texure_depqh_cube", Builtin::kUndefined},
{"texture_debth_cube", Builtin::kUndefined},
{"txture_deptii_cube_arry", Builtin::kUndefined},
{"textureqdepth_OOube_arry", Builtin::kUndefined},
{"texture_deTvvth_cube_array", Builtin::kUndefined},
{"texture_depth_multiFFampled_2d", Builtin::kUndefined},
{"textue_depthPmfl00isampled_Qd", Builtin::kUndefined},
{"textuPe_depth_multisampled_2d", Builtin::kUndefined},
{"texture_exernss77", Builtin::kUndefined},
{"texture_bbxternRRl", Builtin::kUndefined},
{"textureXXexternal", Builtin::kUndefined},
{"qOOO2", Builtin::kUndefined},
{"us", Builtin::kUndefined},
{"u3X", Builtin::kUndefined},
{"ve2f", Builtin::kUndefined},
{"qq2", Builtin::kUndefined},
{"vec222", Builtin::kUndefined},
{"vezzXy", Builtin::kUndefined},
{"ieVVP", Builtin::kUndefined},
{"venCi", Builtin::kUndefined},
{"vHc3Aq", Builtin::kUndefined},
{"ve3u", Builtin::kUndefined},
{"venCh", Builtin::kUndefined},
{"vHc2Aq", Builtin::kUndefined},
{"ve2i", Builtin::kUndefined},
{"vefK", Builtin::kUndefined},
{"vgg4", Builtin::kUndefined},
{"vecf", Builtin::kUndefined},
{"4TNc4f", Builtin::kUndefined},
{"vgg2", Builtin::kUndefined},
{"vecu", Builtin::kUndefined},
{"4TNc2u", Builtin::kUndefined},
{"ppec7l", Builtin::kUndefined},
{"zNe4h", Builtin::kUndefined},
{"uXXb4h", Builtin::kUndefined},
{"vec4", Builtin::kUndefined},
{"884K", Builtin::kUndefined},
{"vq9i", Builtin::kUndefined},
{"vec411", Builtin::kUndefined},
{"22ciiu", Builtin::kUndefined},
{"ec77u", Builtin::kUndefined},
{"zNe3f", Builtin::kUndefined},
{"uXXb3f", Builtin::kUndefined},
{"vec3", Builtin::kUndefined},
{"883K", Builtin::kUndefined},
{"vq9h", Builtin::kUndefined},
{"vec311", Builtin::kUndefined},
{"22ciii", Builtin::kUndefined},
{"ec77i", Builtin::kUndefined},
{"NN23u", Builtin::kUndefined},
{"vVVc3u", Builtin::kUndefined},
{"WW11w3u", Builtin::kUndefined},
{"vcwwf", Builtin::kUndefined},
{"vDc4f", Builtin::kUndefined},
{"vecK", Builtin::kUndefined},
{"f11r4PP", Builtin::kUndefined},
{"ve4h", Builtin::kUndefined},
{"vec4YY", Builtin::kUndefined},
{"vkktHH", Builtin::kUndefined},
{"rrec4i", Builtin::kUndefined},
{"vWWssi", Builtin::kUndefined},
{"veYu", Builtin::kUndefined},
{"eq4f", Builtin::kUndefined},
{"u22ec4u", Builtin::kUndefined},
};
using BuiltinParseTest = testing::TestWithParam<Case>;

View File

@ -21,7 +21,6 @@
#include "src/tint/ast/atomic.h"
#include "src/tint/ast/bool_literal_expression.h"
#include "src/tint/ast/call_statement.h"
#include "src/tint/ast/depth_texture.h"
#include "src/tint/ast/float_literal_expression.h"
#include "src/tint/ast/id_attribute.h"
#include "src/tint/ast/internal_attribute.h"
@ -455,14 +454,6 @@ bool GeneratorImpl::EmitType(std::ostream& out, const ast::Type* ty) {
out << "texture_";
bool ok = Switch(
texture,
[&](const ast::DepthTexture*) { //
out << "depth_";
return true;
},
[&](const ast::DepthMultisampledTexture*) { //
out << "depth_multisampled_";
return true;
},
[&](const ast::SampledTexture*) { //
/* nothing to emit */
return true;