tint/ast: Remove ast::Sampler

Instead use ast::TypeName.

Bug: tint:1810
Change-Id: Ia2641d661cab70d110c975d5f0d0e76628816cb0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119120
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton 2023-02-09 23:56:42 +00:00 committed by Dawn LUCI CQ
parent c9aa57d039
commit ed3389faee
43 changed files with 969 additions and 799 deletions

View File

@ -302,7 +302,6 @@ libtint_source_set("libtint_syntax_tree_src") {
"ast/pointer.h",
"ast/return_statement.h",
"ast/sampled_texture.h",
"ast/sampler.h",
"ast/stage_attribute.h",
"ast/statement.h",
"ast/storage_texture.h",
@ -671,8 +670,6 @@ libtint_source_set("libtint_ast_src") {
"ast/return_statement.h",
"ast/sampled_texture.cc",
"ast/sampled_texture.h",
"ast/sampler.cc",
"ast/sampler.h",
"ast/stage_attribute.cc",
"ast/stage_attribute.h",
"ast/statement.cc",
@ -1345,7 +1342,6 @@ if (tint_build_unittests) {
"ast/pointer_test.cc",
"ast/return_statement_test.cc",
"ast/sampled_texture_test.cc",
"ast/sampler_test.cc",
"ast/stage_attribute_test.cc",
"ast/storage_texture_test.cc",
"ast/stride_attribute_test.cc",

View File

@ -203,8 +203,6 @@ list(APPEND TINT_LIB_SRCS
ast/return_statement.h
ast/sampled_texture.cc
ast/sampled_texture.h
ast/sampler.cc
ast/sampler.h
ast/stage_attribute.cc
ast/stage_attribute.h
ast/statement.cc
@ -866,7 +864,6 @@ if(TINT_BUILD_TESTS)
ast/pointer_test.cc
ast/return_statement_test.cc
ast/sampled_texture_test.cc
ast/sampler_test.cc
ast/stage_attribute_test.cc
ast/storage_texture_test.cc
ast/stride_attribute_test.cc

View File

@ -16,7 +16,6 @@
#include "src/tint/ast/array.h"
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/struct.h"
#include "src/tint/ast/test_helper.h"
#include "src/tint/ast/texture.h"

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,12 @@
namespace tint::ast::builtin::test {
/// The name of the texture global variable used by the tests.
static constexpr const char* kTextureName = "Texture";
/// The name of the sampler global variable used by the tests.
static constexpr const char* kSamplerName = "Sampler";
enum class TextureKind { kRegular, kDepth, kDepthMultisampled, kMultisampled, kStorage };
enum class TextureDataType { kF32, kU32, kI32 };

View File

@ -30,7 +30,7 @@ namespace tint::ast {
namespace {
void BuiltinValueParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"fragdeccth",
"flaget3",
"fVag_depth",
@ -117,7 +117,7 @@ void BuiltinValueParser(::benchmark::State& state) {
"hrkgYooup_d",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseBuiltinValue(str);
benchmark::DoNotOptimize(result);
}

View File

@ -30,14 +30,14 @@ namespace tint::ast {
namespace {
void DiagnosticSeverityParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"erccr", "3o", "eVror", "error", "erro1", "qqrJr", "errll7r",
"ppqnfH", "c", "iGf", "info", "invii", "inWWo", "Mxxo",
"ogg", "X", "3ff", "off", "oEf", "oPTT", "dxxf",
"w44rning", "waSSniVVg", "RarR22g", "warning", "wFni9g", "waring", "VOORRHng",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseDiagnosticSeverity(str);
benchmark::DoNotOptimize(result);
}
@ -47,7 +47,7 @@ void DiagnosticSeverityParser(::benchmark::State& state) {
BENCHMARK(DiagnosticSeverityParser);
void DiagnosticRuleParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"hromium_unyeachable_code", "chrorrillmGunnreachable_c77de", "chromium_unreachable4cod00",
"chromium_unreachable_code", "chromium_unracaboo_code", "chromium_unrzzchabl_code",
"ciipp11ium_unreachable_cod", "derivXXtive_uniformity", "55erivativeIIunifonn99ity",
@ -55,7 +55,7 @@ void DiagnosticRuleParser(::benchmark::State& state) {
"jerivaive_uniforRgty", "derivatbve_unformiy",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseDiagnosticRule(str);
benchmark::DoNotOptimize(result);
}

View File

@ -30,7 +30,7 @@ namespace tint::ast {
namespace {
void ExtensionParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"chromium_disableuniformiccy_analysis",
"chromil3_disable_unifority_analss",
"chromium_disable_Vniformity_analysis",
@ -68,7 +68,7 @@ void ExtensionParser(::benchmark::State& state) {
"f",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseExtension(str);
benchmark::DoNotOptimize(result);
}

View File

@ -30,7 +30,7 @@ namespace tint::ast {
namespace {
void InterpolationTypeParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"ccat", "3", "fVat", "flat", "1lat",
"fqaJ", "flla77", "lippeHHr", "cin", "lbGea",
"linear", "liveaii", "liWWe8r", "xxiner", "perggpctXve",
@ -38,7 +38,7 @@ void InterpolationTypeParser(::benchmark::State& state) {
"pxxdrspectve",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseInterpolationType(str);
benchmark::DoNotOptimize(result);
}
@ -48,13 +48,13 @@ void InterpolationTypeParser(::benchmark::State& state) {
BENCHMARK(InterpolationTypeParser);
void InterpolationSamplingParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"44enter", "cSSVVter", "centRr", "center", "ent9r", "cente", "VentORr",
"cenyroi", "77errtrllnid", "04entroid", "centroid", "enooid", "centzzd", "ceiippr1i",
"saXXple", "55IImpnn99", "aHHrrmplSS", "sample", "kkle", "jagRR", "smbe",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseInterpolationSampling(str);
benchmark::DoNotOptimize(result);
}

View File

@ -16,7 +16,6 @@
#include "src/tint/ast/alias.h"
#include "src/tint/ast/array.h"
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/struct.h"
#include "src/tint/ast/test_helper.h"
#include "src/tint/ast/texture.h"

View File

@ -20,7 +20,6 @@
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/sampled_texture.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/storage_texture.h"
#include "src/tint/ast/struct.h"
#include "src/tint/ast/test_helper.h"

View File

@ -1,39 +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/sampler.h"
#include "src/tint/program_builder.h"
TINT_INSTANTIATE_TYPEINFO(tint::ast::Sampler);
namespace tint::ast {
Sampler::Sampler(ProgramID pid, NodeID nid, const Source& src, type::SamplerKind k)
: Base(pid, nid, src), kind(k) {}
Sampler::Sampler(Sampler&&) = default;
Sampler::~Sampler() = default;
std::string Sampler::FriendlyName(const SymbolTable&) const {
return kind == type::SamplerKind::kSampler ? "sampler" : "sampler_comparison";
}
const Sampler* Sampler::Clone(CloneContext* ctx) const {
auto src = ctx->Clone(source);
return ctx->dst->create<Sampler>(src, kind);
}
} // namespace tint::ast

View File

@ -1,57 +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_SAMPLER_H_
#define SRC_TINT_AST_SAMPLER_H_
#include <string>
#include "src/tint/ast/type.h"
#include "src/tint/type/sampler_kind.h"
namespace tint::ast {
/// A sampler type.
class Sampler final : public Castable<Sampler, Type> {
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 kind the kind of sampler
Sampler(ProgramID pid, NodeID nid, const Source& src, type::SamplerKind kind);
/// Move constructor
Sampler(Sampler&&);
~Sampler() override;
/// @returns true if this is a comparison sampler
bool IsComparison() const { return kind == type::SamplerKind::kComparisonSampler; }
/// @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 Sampler* Clone(CloneContext* ctx) const override;
/// The sampler type
const type::SamplerKind kind;
};
} // namespace tint::ast
#endif // SRC_TINT_AST_SAMPLER_H_

View File

@ -1,46 +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/sampler.h"
#include "src/tint/ast/test_helper.h"
namespace tint::ast {
namespace {
using AstSamplerTest = TestHelper;
TEST_F(AstSamplerTest, Creation) {
auto* s = create<Sampler>(type::SamplerKind::kSampler);
EXPECT_EQ(s->kind, type::SamplerKind::kSampler);
}
TEST_F(AstSamplerTest, Creation_ComparisonSampler) {
auto* s = create<Sampler>(type::SamplerKind::kComparisonSampler);
EXPECT_EQ(s->kind, type::SamplerKind::kComparisonSampler);
EXPECT_TRUE(s->IsComparison());
}
TEST_F(AstSamplerTest, FriendlyNameSampler) {
auto* s = create<Sampler>(type::SamplerKind::kSampler);
EXPECT_EQ(s->FriendlyName(Symbols()), "sampler");
}
TEST_F(AstSamplerTest, FriendlyNameComparisonSampler) {
auto* s = create<Sampler>(type::SamplerKind::kComparisonSampler);
EXPECT_EQ(s->FriendlyName(Symbols()), "sampler_comparison");
}
} // namespace
} // namespace tint::ast

View File

@ -18,7 +18,6 @@
#include "src/tint/ast/array.h"
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/test_helper.h"
#include "src/tint/ast/texture.h"
#include "src/tint/ast/vector.h"

View File

@ -18,7 +18,6 @@
#include "src/tint/ast/array.h"
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/struct.h"
#include "src/tint/ast/test_helper.h"
#include "src/tint/ast/vector.h"

View File

@ -17,7 +17,6 @@
#include "src/tint/ast/alias.h"
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/texture.h"
#include "src/tint/ast/vector.h"
#include "src/tint/symbol_table.h"

View File

@ -171,13 +171,15 @@ void InspectorBuilder::MakeStructVariableReferenceBodyFunction(
}
void InspectorBuilder::AddSampler(const std::string& name, uint32_t group, uint32_t binding) {
GlobalVar(name, sampler_type(), Binding(AInt(binding)), Group(AInt(group)));
GlobalVar(name, ty.sampler(type::SamplerKind::kSampler), Binding(AInt(binding)),
Group(AInt(group)));
}
void InspectorBuilder::AddComparisonSampler(const std::string& name,
uint32_t group,
uint32_t binding) {
GlobalVar(name, comparison_sampler_type(), Binding(AInt(binding)), Group(AInt(group)));
GlobalVar(name, ty.sampler(type::SamplerKind::kComparisonSampler), Binding(AInt(binding)),
Group(AInt(group)));
}
void InspectorBuilder::AddResource(const std::string& name,

View File

@ -332,14 +332,6 @@ class InspectorBuilder : public ProgramBuilder {
/// @returns a reference to the Inspector for the built Program.
Inspector& Build();
/// @returns the type for a SamplerKind::kSampler
const ast::Sampler* sampler_type() { return ty.sampler(type::SamplerKind::kSampler); }
/// @returns the type for a SamplerKind::kComparison
const ast::Sampler* comparison_sampler_type() {
return ty.sampler(type::SamplerKind::kComparisonSampler);
}
protected:
/// Program built by this builder.
std::unique_ptr<Program> program_;

View File

@ -167,6 +167,9 @@ enum builtin_type {
vec4h
vec4i
vec4u
// https://www.w3.org/TR/WGSL/#sampler-type
sampler
sampler_comparison
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -70,7 +70,6 @@
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/return_statement.h"
#include "src/tint/ast/sampled_texture.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/storage_texture.h"
#include "src/tint/ast/stride_attribute.h"
@ -105,6 +104,7 @@
#include "src/tint/type/multisampled_texture.h"
#include "src/tint/type/pointer.h"
#include "src/tint/type/sampled_texture.h"
#include "src/tint/type/sampler_kind.h"
#include "src/tint/type/storage_texture.h"
#include "src/tint/type/texture_dimension.h"
#include "src/tint/type/u32.h"
@ -961,16 +961,23 @@ class ProgramBuilder {
}
/// @param kind the kind of sampler
/// @returns the sampler
const ast::Sampler* sampler(type::SamplerKind kind) const {
return builder->create<ast::Sampler>(kind);
/// @returns the sampler typename
const ast::TypeName* sampler(type::SamplerKind kind) const {
return sampler(builder->source_, kind);
}
/// @param source the Source of the node
/// @param kind the kind of sampler
/// @returns the sampler
const ast::Sampler* sampler(const Source& source, type::SamplerKind kind) const {
return builder->create<ast::Sampler>(source, kind);
/// @returns the sampler typename
const ast::TypeName* sampler(const Source& source, type::SamplerKind kind) const {
switch (kind) {
case type::SamplerKind::kSampler:
return (*this)(source, "sampler");
case type::SamplerKind::kComparisonSampler:
return (*this)(source, "sampler_comparison");
}
TINT_ICE(ProgramBuilder, builder->Diagnostics()) << "invalid sampler kind " << kind;
return nullptr;
}
/// @param dims the dimensionality of the texture

View File

@ -19,11 +19,11 @@
#include <string>
#include <vector>
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/storage_texture.h"
#include "src/tint/castable.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/sampler_kind.h"
#include "src/tint/type/texture_dimension.h"
#include "src/tint/utils/block_allocator.h"

View File

@ -32,8 +32,8 @@ TEST_F(ParserImplTest, SamplerType_Sampler) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Sampler>());
EXPECT_FALSE(t->As<ast::Sampler>()->IsComparison());
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"sampler");
EXPECT_FALSE(p->has_error());
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}}));
}
@ -44,8 +44,8 @@ TEST_F(ParserImplTest, SamplerType_ComparisonSampler) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Sampler>());
EXPECT_TRUE(t->As<ast::Sampler>()->IsComparison());
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"sampler_comparison");
EXPECT_FALSE(p->has_error());
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 19u}}));
}

View File

@ -37,8 +37,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Sampler>());
ASSERT_FALSE(t->As<ast::Sampler>()->IsComparison());
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"sampler");
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}}));
}
@ -49,8 +49,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::Sampler>());
ASSERT_TRUE(t->As<ast::Sampler>()->IsComparison());
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"sampler_comparison");
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 19u}}));
}

View File

@ -15,7 +15,6 @@
#include "src/tint/ast/alias.h"
#include "src/tint/ast/array.h"
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
#include "src/tint/type/sampled_texture.h"
@ -689,8 +688,8 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_TRUE(t.value->Is<ast::Sampler>());
ASSERT_FALSE(t.value->As<ast::Sampler>()->IsComparison());
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"sampler");
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}}));
}

View File

@ -15,7 +15,6 @@
#include "src/tint/ast/alias.h"
#include "src/tint/ast/array.h"
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
#include "src/tint/type/sampled_texture.h"
@ -682,8 +681,8 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Sampler) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_TRUE(t.value->Is<ast::Sampler>());
ASSERT_FALSE(t.value->As<ast::Sampler>()->IsComparison());
EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As<ast::TypeName>()->name->symbol),
"sampler");
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}}));
}

View File

@ -37,6 +37,7 @@
#include "src/tint/type/sampled_texture.h"
#include "src/tint/type/test_helper.h"
#include "src/tint/type/texture_dimension.h"
#include "src/tint/utils/string.h"
using ::testing::ElementsAre;
using ::testing::HasSubstr;
@ -2114,9 +2115,15 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParam<Textur
}
void add_call_param(std::string name, const ast::Type* type, ExpressionList* call_params) {
if (type->IsAnyOf<ast::Texture, ast::Sampler>()) {
GlobalVar(name, type, Binding(0_a), Group(0_a));
if (auto* type_name = type->As<ast::TypeName>()) {
if (utils::HasPrefix(Symbols().NameFor(type_name->name->symbol), "sampler")) {
GlobalVar(name, type, Binding(0_a), Group(0_a));
return;
}
}
if (type->Is<ast::Texture>()) {
GlobalVar(name, type, Binding(0_a), Group(0_a));
} else {
GlobalVar(name, type, type::AddressSpace::kPrivate);
}

View File

@ -50,7 +50,6 @@
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/return_statement.h"
#include "src/tint/ast/sampled_texture.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/storage_texture.h"
#include "src/tint/ast/stride_attribute.h"
@ -407,7 +406,7 @@ class DependencyScanner {
},
[&](Default) {
if (!ty->IsAnyOf<ast::DepthTexture, ast::DepthMultisampledTexture,
ast::ExternalTexture, ast::Sampler>()) {
ast::ExternalTexture>()) {
UnhandledNode(diagnostics_, ty);
}
});

View File

@ -41,7 +41,6 @@
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/return_statement.h"
#include "src/tint/ast/sampled_texture.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/storage_texture.h"
#include "src/tint/ast/switch_statement.h"
#include "src/tint/ast/traverse_expressions.h"
@ -289,7 +288,6 @@ type::Type* Resolver::Type(const ast::Type* ty) {
}
return nullptr;
},
[&](const ast::Sampler* t) { return builder_->create<type::Sampler>(t->kind); },
[&](const ast::SampledTexture* t) -> type::SampledTexture* {
if (auto* el = Type(t->type)) {
auto* sem = builder_->create<type::SampledTexture>(t->dim, el);
@ -2525,6 +2523,10 @@ type::Type* Resolver::BuiltinType(type::Builtin builtin_ty, const ast::Identifie
return vec(u32(), 3u);
case type::Builtin::kVec4U:
return vec(u32(), 4u);
case type::Builtin::kSampler:
return builder_->create<type::Sampler>(type::SamplerKind::kSampler);
case type::Builtin::kSamplerComparison:
return builder_->create<type::Sampler>(type::SamplerKind::kComparisonSampler);
case type::Builtin::kUndefined:
break;
}

View File

@ -38,7 +38,6 @@
#include "src/tint/ast/pointer.h"
#include "src/tint/ast/return_statement.h"
#include "src/tint/ast/sampled_texture.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/storage_texture.h"
#include "src/tint/ast/switch_statement.h"
#include "src/tint/ast/traverse_expressions.h"

View File

@ -173,7 +173,7 @@ INSTANTIATE_TEST_SUITE_P(ValidCases, {{$enum}}PrintTest, testing::ValuesIn(kVali
{{- /* ------------------------------------------------------------------ */ -}}
{{- $enum := Eval "EnumName" $ -}}
void {{$enum}}Parser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
{{- $exclude := $.NameSet -}}
{{- range $entry := $.PublicEntries }}
"{{Scramble $entry.Name $exclude}}",
@ -186,7 +186,7 @@ void {{$enum}}Parser(::benchmark::State& state) {
{{- end }}
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = Parse{{$enum}}(str);
benchmark::DoNotOptimize(result);
}

View File

@ -167,7 +167,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type
CreateASTTypeFor(ctx, t->type()), t->access());
}
if (auto* s = ty->As<type::Sampler>()) {
return ctx.dst->create<ast::Sampler>(s->kind());
return ctx.dst->ty.sampler(s->kind());
}
TINT_UNREACHABLE(Transform, ctx.dst->Diagnostics())
<< "Unhandled type: " << ty->TypeInfo().name;

View File

@ -30,7 +30,7 @@ namespace tint::type {
namespace {
void AccessParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"ccad", "3", "rVad", "read", "1ead",
"rqaJ", "rlla77", "reqqdppriHHe", "rv_wcit", "reabGwrte",
"read_write", "read_vriite", "re8d_wriWWe", "Meadxxrite", "wggte",
@ -38,7 +38,7 @@ void AccessParser(::benchmark::State& state) {
"wxxidd",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseAccess(str);
benchmark::DoNotOptimize(result);
}

View File

@ -30,7 +30,7 @@ namespace tint::type {
namespace {
void AddressSpaceParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"fccnctin", "ucti3", "functVon", "function", "1unction",
"unJtqqon", "llun77tion", "ppqqivtHH", "prcv", "bivaGe",
"private", "priviive", "8WWivate", "pxxvate", "pXh_cggnstant",
@ -42,7 +42,7 @@ void AddressSpaceParser(::benchmark::State& state) {
"jgkrouRR", "wokroub",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseAddressSpace(str);
benchmark::DoNotOptimize(result);
}

View File

@ -94,6 +94,12 @@ Builtin ParseBuiltin(std::string_view str) {
if (str == "mat4x4h") {
return Builtin::kMat4X4H;
}
if (str == "sampler") {
return Builtin::kSampler;
}
if (str == "sampler_comparison") {
return Builtin::kSamplerComparison;
}
if (str == "u32") {
return Builtin::kU32;
}
@ -184,6 +190,10 @@ std::ostream& operator<<(std::ostream& out, Builtin value) {
return out << "mat4x4f";
case Builtin::kMat4X4H:
return out << "mat4x4h";
case Builtin::kSampler:
return out << "sampler";
case Builtin::kSamplerComparison:
return out << "sampler_comparison";
case Builtin::kU32:
return out << "u32";
case Builtin::kVec2F:

View File

@ -52,6 +52,8 @@ enum class Builtin {
kMat4X3H,
kMat4X4F,
kMat4X4H,
kSampler,
kSamplerComparison,
kU32,
kVec2F,
kVec2H,
@ -78,11 +80,13 @@ std::ostream& operator<<(std::ostream& out, Builtin value);
Builtin ParseBuiltin(std::string_view str);
constexpr const char* kBuiltinStrings[] = {
"bool", "f16", "f32", "i32", "mat2x2f", "mat2x2h", "mat2x3f",
"mat2x3h", "mat2x4f", "mat2x4h", "mat3x2f", "mat3x2h", "mat3x3f", "mat3x3h",
"mat3x4f", "mat3x4h", "mat4x2f", "mat4x2h", "mat4x3f", "mat4x3h", "mat4x4f",
"mat4x4h", "u32", "vec2f", "vec2h", "vec2i", "vec2u", "vec3f",
"vec3h", "vec3i", "vec3u", "vec4f", "vec4h", "vec4i", "vec4u",
"bool", "f16", "f32", "i32", "mat2x2f", "mat2x2h",
"mat2x3f", "mat2x3h", "mat2x4f", "mat2x4h", "mat3x2f", "mat3x2h",
"mat3x3f", "mat3x3h", "mat3x4f", "mat3x4h", "mat4x2f", "mat4x2h",
"mat4x3f", "mat4x3h", "mat4x4f", "mat4x4h", "sampler", "sampler_comparison",
"u32", "vec2f", "vec2h", "vec2i", "vec2u", "vec3f",
"vec3h", "vec3i", "vec3u", "vec4f", "vec4h", "vec4i",
"vec4u",
};
} // namespace tint::type

View File

@ -30,51 +30,269 @@ namespace tint::type {
namespace {
void BuiltinParser(::benchmark::State& state) {
std::array kStrings{
"ccol", "3", "bVol", "bool", "1ool", "bqoJ",
"bllo77", "fppqH", "", "Gb", "f16", "f1vi",
"f8WW", "fxx", "fgg", "X", "332", "f32",
"fE2", "fPTT", "dxx2", "4432", "iSVV2", "RR2",
"i32", "92", "i3", "VOR2", "ma2xyf", "llnarr2772f",
"mat24200", "mat2x2f", "a2oof", "zz2x2f", "miitppx1", "mat2xXXh",
"9II5ann2x2h", "mataSSrHHYh", "mat2x2h", "makkh", "jatgRx", "mb2x2",
"mat2xjf", "at2x3f", "q2x3f", "mat2x3f", "matNN3f", "at23vv",
"QQt2x3f", "maffxr", "mat2xjh", "mNNw2x38", "mat2x3h", "matx3h",
"mrrt2x3h", "Gat2x3h", "mat2x4FF", "at2f", "marrx4f", "mat2x4f",
"t2x4f", "Da2xJJf", "ma84", "m11k4", "matx4h", "maJx4h",
"mat2x4h", "mat2c4h", "mat2x4O", "KK_atvvtt4h", "xx83x2f", "__qatF2",
"matqx2f", "mat3x2f", "33atOx2f", "mtt63x9oQQ", "ma3x66f", "mtOxzz66",
"mat3yy2h", "ZaHH2Z", "mat3x2h", "4WWt3q2h", "mOO3x2h", "oatY2h",
"matx", "ma3xFf", "at3x3w", "mat3x3f", "fGtxKf", "matqKx3f",
"matmmxFf", "at3x3h", "mt3x3q", "mat3xbb", "mat3x3h", "mi3x3h",
"maOO3xq", "matTvvx3h", "maFF3x4f", "Pa00xQf", "mPt3x4f", "mat3x4f",
"ma773xss", "RRCbb3x4f", "mXXt3x4f", "qaCC3xOOh", "ma3s4L", "mXt3x4h",
"mat3x4h", "mat34h", "qa3O4", "mat3x22h", "myzz40XX", "matVViP",
"mannC2f", "mat4x2f", "atx2AHHq", "mat4x2", "fatK2f", "ltgg2h",
"mat4xh", "NTTtcx4h", "mat4x2h", "ma7ppl2h", "mNNt4xg", "uub4XX2h",
"matx3f", "Qt883f", "mt9q3f", "mat4x3f", "m11t4x3f", "22at4iif",
"at4x377", "m2t4xNh", "mVVt4x3h", "FaWW4w11h", "mat4x3h", "mawwx3h",
"Dat4x3h", "mt4x3K", "mat41PPhf", "mat44f", "mYYt4x4f", "mat4x4f",
"mttHH4kk", "mat4rr4f", "WWas4x4f", "Yt4x4h", "mt4qfh", "mav224xuh",
"mat4x4h", "t4x4h", "YYat4h", "may4x4EYY", "Mo2", "uMM",
"u552", "u32", "N", "333", "u33", "mecI",
"vrnK2f", "v2", "vec2f", "ILLcf", "ecf", "UecRY",
"vechh", "qeIIu", "Hec2h", "vec2h", "eQQvv", "e66h",
"7Wc2", "ve055DD", "IIec2i", "vec2", "vec2i", "rec2",
"lec2i", "GeJ2i", "ey2u", "vc2u", "IIeBB2u", "vec2u",
"TTec338", "veUUSS2nnd", "vZx5CC", "kkec3q", "v005if", "vnIIc3f",
"vec3f", "cceW", "cKK", "vec66f", "vePPK", "vexxh",
"qec3h", "vec3h", "veSyMMr", "v3u", "ec", "5eFF3i",
"rrecz44", "vWW", "vec3i", "XJecCZZ", "vePP3", "vec3c",
"ve6ll3u", "vcyy99", "Jec3KK", "vec3u", "_ex3", "Ky3",
"zek3u", "veKSf", "vc4f", "ec4VV", "vec4f", "IAAc4f",
"jbR", "veY4", "ec4h", "vc911", "mmcch", "vec4h",
"vJJch", "lDDcUfC", "vec4g", "CCe", "ec4i", "vIc__i",
"vec4i", "ePPtt", "v3dc4i", "vcyyi", "u4", "v03nnu",
"Cuuecnv", "vec4u", "vX4ll", "vocppu", "vwwc4",
const char* kStrings[] = {
"ccol",
"3",
"bVol",
"bool",
"1ool",
"bqoJ",
"bllo77",
"fppqH",
"",
"Gb",
"f16",
"f1vi",
"f8WW",
"fxx",
"fgg",
"X",
"332",
"f32",
"fE2",
"fPTT",
"dxx2",
"4432",
"iSVV2",
"RR2",
"i32",
"92",
"i3",
"VOR2",
"ma2xyf",
"llnarr2772f",
"mat24200",
"mat2x2f",
"a2oof",
"zz2x2f",
"miitppx1",
"mat2xXXh",
"9II5ann2x2h",
"mataSSrHHYh",
"mat2x2h",
"makkh",
"jatgRx",
"mb2x2",
"mat2xjf",
"at2x3f",
"q2x3f",
"mat2x3f",
"matNN3f",
"at23vv",
"QQt2x3f",
"maffxr",
"mat2xjh",
"mNNw2x38",
"mat2x3h",
"matx3h",
"mrrt2x3h",
"Gat2x3h",
"mat2x4FF",
"at2f",
"marrx4f",
"mat2x4f",
"t2x4f",
"Da2xJJf",
"ma84",
"m11k4",
"matx4h",
"maJx4h",
"mat2x4h",
"mat2c4h",
"mat2x4O",
"KK_atvvtt4h",
"xx83x2f",
"__qatF2",
"matqx2f",
"mat3x2f",
"33atOx2f",
"mtt63x9oQQ",
"ma3x66f",
"mtOxzz66",
"mat3yy2h",
"ZaHH2Z",
"mat3x2h",
"4WWt3q2h",
"mOO3x2h",
"oatY2h",
"matx",
"ma3xFf",
"at3x3w",
"mat3x3f",
"fGtxKf",
"matqKx3f",
"matmmxFf",
"at3x3h",
"mt3x3q",
"mat3xbb",
"mat3x3h",
"mi3x3h",
"maOO3xq",
"matTvvx3h",
"maFF3x4f",
"Pa00xQf",
"mPt3x4f",
"mat3x4f",
"ma773xss",
"RRCbb3x4f",
"mXXt3x4f",
"qaCC3xOOh",
"ma3s4L",
"mXt3x4h",
"mat3x4h",
"mat34h",
"qa3O4",
"mat3x22h",
"myzz40XX",
"matVViP",
"mannC2f",
"mat4x2f",
"atx2AHHq",
"mat4x2",
"fatK2f",
"ltgg2h",
"mat4xh",
"NTTtcx4h",
"mat4x2h",
"ma7ppl2h",
"mNNt4xg",
"uub4XX2h",
"matx3f",
"Qt883f",
"mt9q3f",
"mat4x3f",
"m11t4x3f",
"22at4iif",
"at4x377",
"m2t4xNh",
"mVVt4x3h",
"FaWW4w11h",
"mat4x3h",
"mawwx3h",
"Dat4x3h",
"mt4x3K",
"mat41PPhf",
"mat44f",
"mYYt4x4f",
"mat4x4f",
"mttHH4kk",
"mat4rr4f",
"WWas4x4f",
"Yt4x4h",
"mt4qfh",
"mav224xuh",
"mat4x4h",
"t4x4h",
"YYat4h",
"may4x4EYY",
"daplMor",
"samMMle",
"sampl55r",
"sampler",
"saNpe",
"sa3Ol33",
"s3mpler",
"Iamplercomparismn",
"sampleKrcompannison",
"samlr_copXXison",
"sampler_comparison",
"samplpLL_comparisI",
"smplerfomparison",
"sYmpURDr_comprison",
"u3h",
"IIq",
"u3H",
"u32",
"Qvv",
"66",
"73",
"ve055DD",
"IIec2f",
"vec2",
"vec2f",
"rec2",
"lec2f",
"GeJ2f",
"ey2h",
"vc2h",
"IIeBB2h",
"vec2h",
"TTec338",
"veUUSS2nnd",
"vZx5CC",
"kkec2q",
"v005ii",
"vnIIc2i",
"vec2i",
"cceW",
"cKK",
"vec66i",
"vePPK",
"vexxu",
"qec2u",
"vec2u",
"veSyMMr",
"v2u",
"ec",
"5eFF3f",
"rrecz44",
"vWW",
"vec3f",
"XJecCZZ",
"vePP3",
"vec3c",
"ve6ll3h",
"vcyy99",
"Jec3KK",
"vec3h",
"_ex3",
"Ky3",
"zek3h",
"veKSi",
"vc3i",
"ec3VV",
"vec3i",
"IAAc3i",
"jbR",
"veY4",
"ec3u",
"vc911",
"mmccu",
"vec3u",
"vJJcu",
"lDDcUfC",
"vec3g",
"CCe",
"ec4f",
"vIc__f",
"vec4f",
"ePPtt",
"v3dc4f",
"vcyyf",
"u4",
"v03nnh",
"Cuuecnv",
"vec4h",
"vX4ll",
"vocpph",
"vwwc4",
"veuug",
"vaac",
"TRZccci",
"vec4i",
"vTc4O8",
"vem04i",
"meBB4i",
"Mpp4",
"OOe4u",
"veG4G",
"vec4u",
"11eHH4u",
"veFFe6",
"ve4",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseBuiltin(str);
benchmark::DoNotOptimize(result);
}

View File

@ -43,74 +43,139 @@ inline std::ostream& operator<<(std::ostream& out, Case c) {
}
static constexpr Case kValidCases[] = {
{"bool", Builtin::kBool}, {"f16", Builtin::kF16}, {"f32", Builtin::kF32},
{"i32", Builtin::kI32}, {"mat2x2f", Builtin::kMat2X2F}, {"mat2x2h", Builtin::kMat2X2H},
{"mat2x3f", Builtin::kMat2X3F}, {"mat2x3h", Builtin::kMat2X3H}, {"mat2x4f", Builtin::kMat2X4F},
{"mat2x4h", Builtin::kMat2X4H}, {"mat3x2f", Builtin::kMat3X2F}, {"mat3x2h", Builtin::kMat3X2H},
{"mat3x3f", Builtin::kMat3X3F}, {"mat3x3h", Builtin::kMat3X3H}, {"mat3x4f", Builtin::kMat3X4F},
{"mat3x4h", Builtin::kMat3X4H}, {"mat4x2f", Builtin::kMat4X2F}, {"mat4x2h", Builtin::kMat4X2H},
{"mat4x3f", Builtin::kMat4X3F}, {"mat4x3h", Builtin::kMat4X3H}, {"mat4x4f", Builtin::kMat4X4F},
{"mat4x4h", Builtin::kMat4X4H}, {"u32", Builtin::kU32}, {"vec2f", Builtin::kVec2F},
{"vec2h", Builtin::kVec2H}, {"vec2i", Builtin::kVec2I}, {"vec2u", Builtin::kVec2U},
{"vec3f", Builtin::kVec3F}, {"vec3h", Builtin::kVec3H}, {"vec3i", Builtin::kVec3I},
{"vec3u", Builtin::kVec3U}, {"vec4f", Builtin::kVec4F}, {"vec4h", Builtin::kVec4H},
{"vec4i", Builtin::kVec4I}, {"vec4u", Builtin::kVec4U},
{"bool", Builtin::kBool}, {"f16", Builtin::kF16},
{"f32", Builtin::kF32}, {"i32", Builtin::kI32},
{"mat2x2f", Builtin::kMat2X2F}, {"mat2x2h", Builtin::kMat2X2H},
{"mat2x3f", Builtin::kMat2X3F}, {"mat2x3h", Builtin::kMat2X3H},
{"mat2x4f", Builtin::kMat2X4F}, {"mat2x4h", Builtin::kMat2X4H},
{"mat3x2f", Builtin::kMat3X2F}, {"mat3x2h", Builtin::kMat3X2H},
{"mat3x3f", Builtin::kMat3X3F}, {"mat3x3h", Builtin::kMat3X3H},
{"mat3x4f", Builtin::kMat3X4F}, {"mat3x4h", Builtin::kMat3X4H},
{"mat4x2f", Builtin::kMat4X2F}, {"mat4x2h", Builtin::kMat4X2H},
{"mat4x3f", Builtin::kMat4X3F}, {"mat4x3h", Builtin::kMat4X3H},
{"mat4x4f", Builtin::kMat4X4F}, {"mat4x4h", Builtin::kMat4X4H},
{"sampler", Builtin::kSampler}, {"sampler_comparison", Builtin::kSamplerComparison},
{"u32", Builtin::kU32}, {"vec2f", Builtin::kVec2F},
{"vec2h", Builtin::kVec2H}, {"vec2i", Builtin::kVec2I},
{"vec2u", Builtin::kVec2U}, {"vec3f", Builtin::kVec3F},
{"vec3h", Builtin::kVec3H}, {"vec3i", Builtin::kVec3I},
{"vec3u", Builtin::kVec3U}, {"vec4f", Builtin::kVec4F},
{"vec4h", Builtin::kVec4H}, {"vec4i", Builtin::kVec4I},
{"vec4u", Builtin::kVec4U},
};
static constexpr Case kInvalidCases[] = {
{"ccol", Builtin::kUndefined}, {"3", Builtin::kUndefined},
{"bVol", Builtin::kUndefined}, {"116", Builtin::kUndefined},
{"qJ6", Builtin::kUndefined}, {"f17ll", Builtin::kUndefined},
{"fppqH", Builtin::kUndefined}, {"", Builtin::kUndefined},
{"Gb", Builtin::kUndefined}, {"i3vi", Builtin::kUndefined},
{"i8WW", Builtin::kUndefined}, {"ixx", Builtin::kUndefined},
{"mX2x2gg", Builtin::kUndefined}, {"a2xXf", Builtin::kUndefined},
{"mat232f", Builtin::kUndefined}, {"Eat2x2h", Builtin::kUndefined},
{"mPTT2x2h", Builtin::kUndefined}, {"mat2xdxx", Builtin::kUndefined},
{"m44t2x3f", Builtin::kUndefined}, {"maSS2xVVf", Builtin::kUndefined},
{"RatR22f", Builtin::kUndefined}, {"mF2x9h", Builtin::kUndefined},
{"matx3h", Builtin::kUndefined}, {"VOORRH3h", Builtin::kUndefined},
{"ma2xyf", Builtin::kUndefined}, {"llnarr2774f", Builtin::kUndefined},
{"mat24400", Builtin::kUndefined}, {"a2ooh", Builtin::kUndefined},
{"zz2x4h", Builtin::kUndefined}, {"miitppx1", Builtin::kUndefined},
{"mat3xXXf", Builtin::kUndefined}, {"9II5ann3x2f", Builtin::kUndefined},
{"mataSSrHHYf", Builtin::kUndefined}, {"makkh", Builtin::kUndefined},
{"jatgRx", Builtin::kUndefined}, {"mb3x2", Builtin::kUndefined},
{"mat3xjf", Builtin::kUndefined}, {"at3x3f", Builtin::kUndefined},
{"q3x3f", Builtin::kUndefined}, {"matNN3h", Builtin::kUndefined},
{"at33vv", Builtin::kUndefined}, {"QQt3x3h", Builtin::kUndefined},
{"maffxr", Builtin::kUndefined}, {"mat3xjf", Builtin::kUndefined},
{"mNNw3x48", Builtin::kUndefined}, {"matx4h", Builtin::kUndefined},
{"mrrt3x4h", Builtin::kUndefined}, {"Gat3x4h", Builtin::kUndefined},
{"mat4x2FF", Builtin::kUndefined}, {"at4f", Builtin::kUndefined},
{"marrx2f", Builtin::kUndefined}, {"t4x2h", Builtin::kUndefined},
{"Da4xJJh", Builtin::kUndefined}, {"ma82", Builtin::kUndefined},
{"m11k3", Builtin::kUndefined}, {"matx3f", Builtin::kUndefined},
{"maJx3f", Builtin::kUndefined}, {"mat4c3h", Builtin::kUndefined},
{"mat4x3O", Builtin::kUndefined}, {"KK_atvvtt3h", Builtin::kUndefined},
{"xx84x4f", Builtin::kUndefined}, {"__qatF4", Builtin::kUndefined},
{"matqx4f", Builtin::kUndefined}, {"33atOx4h", Builtin::kUndefined},
{"mtt64x9oQQ", Builtin::kUndefined}, {"ma4x66h", Builtin::kUndefined},
{"zzO6", Builtin::kUndefined}, {"uyy2", Builtin::kUndefined},
{"HZ", Builtin::kUndefined}, {"ecWq4f", Builtin::kUndefined},
{"vOO2f", Builtin::kUndefined}, {"oYe2", Builtin::kUndefined},
{"v2", Builtin::kUndefined}, {"Fe2h", Builtin::kUndefined},
{"vwch", Builtin::kUndefined}, {"vefi", Builtin::kUndefined},
{"KKeq2i", Builtin::kUndefined}, {"vFmm2i", Builtin::kUndefined},
{"vecu", Builtin::kUndefined}, {"qc2u", Builtin::kUndefined},
{"vecbb", Builtin::kUndefined}, {"iic3", Builtin::kUndefined},
{"vqOOf", Builtin::kUndefined}, {"vevvTTf", Builtin::kUndefined},
{"veFF3h", Builtin::kUndefined}, {"00PfQ", Builtin::kUndefined},
{"vec3P", Builtin::kUndefined}, {"vec77s", Builtin::kUndefined},
{"vecbbCi", Builtin::kUndefined}, {"vecXXi", Builtin::kUndefined},
{"CCOOec3", Builtin::kUndefined}, {"vs3u", Builtin::kUndefined},
{"Xec3u", Builtin::kUndefined}, {"ve4f", Builtin::kUndefined},
{"qq4", Builtin::kUndefined}, {"vec422", Builtin::kUndefined},
{"vezzXy", Builtin::kUndefined}, {"ieVVP", Builtin::kUndefined},
{"venCh", Builtin::kUndefined}, {"vHc4Aq", Builtin::kUndefined},
{"ve4i", Builtin::kUndefined}, {"vefK", Builtin::kUndefined},
{"vgg4", Builtin::kUndefined}, {"vecu", Builtin::kUndefined},
{"4TNc4u", Builtin::kUndefined},
{"ccol", Builtin::kUndefined},
{"3", Builtin::kUndefined},
{"bVol", Builtin::kUndefined},
{"116", Builtin::kUndefined},
{"qJ6", Builtin::kUndefined},
{"f17ll", Builtin::kUndefined},
{"fppqH", Builtin::kUndefined},
{"", Builtin::kUndefined},
{"Gb", Builtin::kUndefined},
{"i3vi", Builtin::kUndefined},
{"i8WW", Builtin::kUndefined},
{"ixx", Builtin::kUndefined},
{"mX2x2gg", Builtin::kUndefined},
{"a2xXf", Builtin::kUndefined},
{"mat232f", Builtin::kUndefined},
{"Eat2x2h", Builtin::kUndefined},
{"mPTT2x2h", Builtin::kUndefined},
{"mat2xdxx", Builtin::kUndefined},
{"m44t2x3f", Builtin::kUndefined},
{"maSS2xVVf", Builtin::kUndefined},
{"RatR22f", Builtin::kUndefined},
{"mF2x9h", Builtin::kUndefined},
{"matx3h", Builtin::kUndefined},
{"VOORRH3h", Builtin::kUndefined},
{"ma2xyf", Builtin::kUndefined},
{"llnarr2774f", Builtin::kUndefined},
{"mat24400", Builtin::kUndefined},
{"a2ooh", Builtin::kUndefined},
{"zz2x4h", Builtin::kUndefined},
{"miitppx1", Builtin::kUndefined},
{"mat3xXXf", Builtin::kUndefined},
{"9II5ann3x2f", Builtin::kUndefined},
{"mataSSrHHYf", Builtin::kUndefined},
{"makkh", Builtin::kUndefined},
{"jatgRx", Builtin::kUndefined},
{"mb3x2", Builtin::kUndefined},
{"mat3xjf", Builtin::kUndefined},
{"at3x3f", Builtin::kUndefined},
{"q3x3f", Builtin::kUndefined},
{"matNN3h", Builtin::kUndefined},
{"at33vv", Builtin::kUndefined},
{"QQt3x3h", Builtin::kUndefined},
{"maffxr", Builtin::kUndefined},
{"mat3xjf", Builtin::kUndefined},
{"mNNw3x48", Builtin::kUndefined},
{"matx4h", Builtin::kUndefined},
{"mrrt3x4h", Builtin::kUndefined},
{"Gat3x4h", Builtin::kUndefined},
{"mat4x2FF", Builtin::kUndefined},
{"at4f", Builtin::kUndefined},
{"marrx2f", Builtin::kUndefined},
{"t4x2h", Builtin::kUndefined},
{"Da4xJJh", Builtin::kUndefined},
{"ma82", Builtin::kUndefined},
{"m11k3", Builtin::kUndefined},
{"matx3f", Builtin::kUndefined},
{"maJx3f", Builtin::kUndefined},
{"mat4c3h", Builtin::kUndefined},
{"mat4x3O", Builtin::kUndefined},
{"KK_atvvtt3h", Builtin::kUndefined},
{"xx84x4f", Builtin::kUndefined},
{"__qatF4", Builtin::kUndefined},
{"matqx4f", Builtin::kUndefined},
{"33atOx4h", Builtin::kUndefined},
{"mtt64x9oQQ", Builtin::kUndefined},
{"ma4x66h", Builtin::kUndefined},
{"smOlzz66", Builtin::kUndefined},
{"sampyyer", Builtin::kUndefined},
{"ZaHHeZ", Builtin::kUndefined},
{"sWWpleq_compari44on", Builtin::kUndefined},
{"sampler_compaisoOO", Builtin::kUndefined},
{"smpeoo_coYparison", Builtin::kUndefined},
{"", Builtin::kUndefined},
{"u3", Builtin::kUndefined},
{"3w", Builtin::kUndefined},
{"veff", Builtin::kUndefined},
{"KKeq2f", Builtin::kUndefined},
{"vFmm2f", Builtin::kUndefined},
{"vech", Builtin::kUndefined},
{"qc2h", Builtin::kUndefined},
{"vecbb", Builtin::kUndefined},
{"iic2", Builtin::kUndefined},
{"vqOOi", Builtin::kUndefined},
{"vevvTTi", Builtin::kUndefined},
{"veFF2u", Builtin::kUndefined},
{"00PfQ", Builtin::kUndefined},
{"vec2P", Builtin::kUndefined},
{"vec77s", Builtin::kUndefined},
{"vecbbCf", Builtin::kUndefined},
{"vecXXf", Builtin::kUndefined},
{"CCOOec3", Builtin::kUndefined},
{"vs3u", Builtin::kUndefined},
{"Xec3h", Builtin::kUndefined},
{"ve3i", Builtin::kUndefined},
{"qq3", Builtin::kUndefined},
{"vec322", Builtin::kUndefined},
{"vezzXy", Builtin::kUndefined},
{"ieVVP", Builtin::kUndefined},
{"venCu", Builtin::kUndefined},
{"vHc4Aq", Builtin::kUndefined},
{"ve4f", Builtin::kUndefined},
{"vefK", Builtin::kUndefined},
{"vgg4", Builtin::kUndefined},
{"vech", Builtin::kUndefined},
{"4TNc4h", Builtin::kUndefined},
{"ppec7l", Builtin::kUndefined},
{"zNe4i", Builtin::kUndefined},
{"uXXb4i", Builtin::kUndefined},
{"vec4", Builtin::kUndefined},
{"884K", Builtin::kUndefined},
{"vq9u", Builtin::kUndefined},
};
using BuiltinParseTest = testing::TestWithParam<Case>;

View File

@ -30,7 +30,7 @@ namespace tint::type {
namespace {
void TexelFormatParser(::benchmark::State& state) {
std::array kStrings{
const char* kStrings[] = {
"bgraunccrm", "blranr3", "bVra8unorm", "bgra8unorm", "bgra1unorm",
"bgrJqqnorm", "bgr7ll8unorm", "qq32lppHat", "c2fov", "r32Goat",
"r32float", "r3viiloat", "r3WWflo8t", "rxxfMoat", "rXsingg",
@ -57,7 +57,7 @@ void TexelFormatParser(::benchmark::State& state) {
"rgba8unorm", "ba8unoqqHHA", "rga8unorm", "rgfa8uKKo",
};
for (auto _ : state) {
for (auto& str : kStrings) {
for (auto* str : kStrings) {
auto result = ParseTexelFormat(str);
benchmark::DoNotOptimize(result);
}

View File

@ -61,41 +61,41 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa
case ValidTextureOverload::kDimensionsStorageWO3d:
return {"imageSize"};
case ValidTextureOverload::kGather2dF32:
return R"(textureGather(tint_symbol_sampler, vec2(1.0f, 2.0f), 0))";
return R"(textureGather(Texture_Sampler, vec2(1.0f, 2.0f), 0))";
case ValidTextureOverload::kGather2dOffsetF32:
return R"(textureGatherOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), ivec2(3, 4), int(0u)))";
return R"(textureGatherOffset(Texture_Sampler, vec2(1.0f, 2.0f), ivec2(3, 4), int(0u)))";
case ValidTextureOverload::kGather2dArrayF32:
return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 0))";
return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 0))";
case ValidTextureOverload::kGather2dArrayOffsetF32:
return R"(textureGatherOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3u)), ivec2(4, 5), int(0u)))";
return R"(textureGatherOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3u)), ivec2(4, 5), int(0u)))";
case ValidTextureOverload::kGatherCubeF32:
return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 0))";
return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 0))";
case ValidTextureOverload::kGatherCubeArrayF32:
return R"(textureGather(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), int(0u))";
return R"(textureGather(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), int(0u))";
case ValidTextureOverload::kGatherDepth2dF32:
return R"(textureGather(tint_symbol_sampler, vec2(1.0f, 2.0f), 0.0))";
return R"(textureGather(Texture_Sampler, vec2(1.0f, 2.0f), 0.0))";
case ValidTextureOverload::kGatherDepth2dOffsetF32:
return R"(textureGatherOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), 0.0, ivec2(3, 4))";
return R"(textureGatherOffset(Texture_Sampler, vec2(1.0f, 2.0f), 0.0, ivec2(3, 4))";
case ValidTextureOverload::kGatherDepth2dArrayF32:
return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3u)), 0.0))";
return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, float(3u)), 0.0))";
case ValidTextureOverload::kGatherDepth2dArrayOffsetF32:
return R"(textureGatherOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 0.0, ivec2(4, 5)))";
return R"(textureGatherOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 0.0, ivec2(4, 5)))";
case ValidTextureOverload::kGatherDepthCubeF32:
return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 0.0))";
return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 0.0))";
case ValidTextureOverload::kGatherDepthCubeArrayF32:
return R"(textureGather(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 0.0))";
return R"(textureGather(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 0.0))";
case ValidTextureOverload::kGatherCompareDepth2dF32:
return R"(textureGather(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f))";
return R"(textureGather(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f))";
case ValidTextureOverload::kGatherCompareDepth2dOffsetF32:
return R"(textureGatherOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f, ivec2(4, 5)))";
return R"(textureGatherOffset(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f, ivec2(4, 5)))";
case ValidTextureOverload::kGatherCompareDepth2dArrayF32:
return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 4.0f))";
return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 4.0f))";
case ValidTextureOverload::kGatherCompareDepth2dArrayOffsetF32:
return R"(textureGatherOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 4.0f, ivec2(5, 6)))";
return R"(textureGatherOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 4.0f, ivec2(5, 6)))";
case ValidTextureOverload::kGatherCompareDepthCubeF32:
return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f))";
return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f))";
case ValidTextureOverload::kGatherCompareDepthCubeArrayF32:
return R"(textureGather(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 5.0f))";
return R"(textureGather(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 5.0f))";
case ValidTextureOverload::kNumLayers2dArray:
case ValidTextureOverload::kNumLayersDepth2dArray:
case ValidTextureOverload::kNumLayersCubeArray:
@ -117,156 +117,156 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa
case ValidTextureOverload::kNumSamplesMultisampled2d:
return {"textureSamples"};
case ValidTextureOverload::kSample1dF32:
return R"(texture(tint_symbol_sampler, vec2(1.0f, 0.5f));)";
return R"(texture(Texture_Sampler, vec2(1.0f, 0.5f));)";
case ValidTextureOverload::kSample2dF32:
return R"(texture(tint_symbol_sampler, vec2(1.0f, 2.0f));)";
return R"(texture(Texture_Sampler, vec2(1.0f, 2.0f));)";
case ValidTextureOverload::kSample2dOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), ivec2(3, 4));)";
return R"(textureOffset(Texture_Sampler, vec2(1.0f, 2.0f), ivec2(3, 4));)";
case ValidTextureOverload::kSample2dArrayF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)));)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, float(3)));)";
case ValidTextureOverload::kSample2dArrayOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3u)), ivec2(4, 5));)";
return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3u)), ivec2(4, 5));)";
case ValidTextureOverload::kSample3dF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f));)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f));)";
case ValidTextureOverload::kSample3dOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), ivec3(4, 5, 6));)";
return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), ivec3(4, 5, 6));)";
case ValidTextureOverload::kSampleCubeF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f));)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f));)";
case ValidTextureOverload::kSampleCubeArrayF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)));)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)));)";
case ValidTextureOverload::kSampleDepth2dF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 0.0f));)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 0.0f));)";
case ValidTextureOverload::kSampleDepth2dOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 0.0f), ivec2(3, 4));)";
return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 0.0f), ivec2(3, 4));)";
case ValidTextureOverload::kSampleDepth2dArrayF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3), 0.0f));)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, float(3), 0.0f));)";
case ValidTextureOverload::kSampleDepth2dArrayOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3), 0.0f), ivec2(4, 5));)";
return R"(textureOffset(Texture_Sampler, vec4(1.0f, 2.0f, float(3), 0.0f), ivec2(4, 5));)";
case ValidTextureOverload::kSampleDepthCubeF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, 0.0f));)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, 0.0f));)";
case ValidTextureOverload::kSampleDepthCubeArrayF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 0.0f);)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 0.0f);)";
case ValidTextureOverload::kSampleBias2dF32:
return R"(texture(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f);)";
return R"(texture(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f);)";
case ValidTextureOverload::kSampleBias2dOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), ivec2(4, 5), 3.0f);)";
return R"(textureOffset(Texture_Sampler, vec2(1.0f, 2.0f), ivec2(4, 5), 3.0f);)";
case ValidTextureOverload::kSampleBias2dArrayF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, float(4u)), 3.0f);)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, float(4u)), 3.0f);)";
case ValidTextureOverload::kSampleBias2dArrayOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), ivec2(5, 6), 4.0f);)";
return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), ivec2(5, 6), 4.0f);)";
case ValidTextureOverload::kSampleBias3dF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)";
case ValidTextureOverload::kSampleBias3dOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), ivec3(5, 6, 7), 4.0f);)";
return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), ivec3(5, 6, 7), 4.0f);)";
case ValidTextureOverload::kSampleBiasCubeF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)";
case ValidTextureOverload::kSampleBiasCubeArrayF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(3)), 4.0f);)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(3)), 4.0f);)";
case ValidTextureOverload::kSampleLevel2dF32:
return R"(textureLod(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f);)";
return R"(textureLod(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f);)";
case ValidTextureOverload::kSampleLevel2dOffsetF32:
return R"(textureLodOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f, ivec2(4, 5));)";
return R"(textureLodOffset(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f, ivec2(4, 5));)";
case ValidTextureOverload::kSampleLevel2dArrayF32:
return R"(textureLod(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 4.0f);)";
return R"(textureLod(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 4.0f);)";
case ValidTextureOverload::kSampleLevel2dArrayOffsetF32:
return R"(textureLodOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 4.0f, ivec2(5, 6));)";
return R"(textureLodOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 4.0f, ivec2(5, 6));)";
case ValidTextureOverload::kSampleLevel3dF32:
return R"(textureLod(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)";
return R"(textureLod(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)";
case ValidTextureOverload::kSampleLevel3dOffsetF32:
return R"(textureLodOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f, ivec3(5, 6, 7));)";
return R"(textureLodOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f, ivec3(5, 6, 7));)";
case ValidTextureOverload::kSampleLevelCubeF32:
return R"(textureLod(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)";
return R"(textureLod(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)";
case ValidTextureOverload::kSampleLevelCubeArrayF32:
return R"(textureLod(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)";
return R"(textureLod(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)";
case ValidTextureOverload::kSampleLevelDepth2dF32:
return R"(textureLod(tint_symbol_sampler, vec3(1.0f, 2.0f, 0.0f), float(3u));)";
return R"(textureLod(Texture_Sampler, vec3(1.0f, 2.0f, 0.0f), float(3u));)";
case ValidTextureOverload::kSampleLevelDepth2dOffsetF32:
return R"(textureLodOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 0.0f), float(3), ivec2(4, 5));)";
return R"(textureLodOffset(Texture_Sampler, vec3(1.0f, 2.0f, 0.0f), float(3), ivec2(4, 5));)";
case ValidTextureOverload::kSampleLevelDepth2dArrayF32:
return R"(textureLod(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3u), 0.0f), float(4u));)";
return R"(textureLod(Texture_Sampler, vec4(1.0f, 2.0f, float(3u), 0.0f), float(4u));)";
case ValidTextureOverload::kSampleLevelDepth2dArrayOffsetF32:
return R"(textureLodOffset(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3u), 0.0f), float(4u), ivec2(5, 6));)";
return R"(textureLodOffset(Texture_Sampler, vec4(1.0f, 2.0f, float(3u), 0.0f), float(4u), ivec2(5, 6));)";
case ValidTextureOverload::kSampleLevelDepthCubeF32:
return R"(textureLod(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, 0.0f), float(4)))";
return R"(textureLod(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, 0.0f), float(4)))";
case ValidTextureOverload::kSampleLevelDepthCubeArrayF32:
return R"(textureLod(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), float(5));)";
return R"(textureLod(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), float(5));)";
case ValidTextureOverload::kSampleGrad2dF32:
return R"(textureGrad(tint_symbol_sampler, vec2(1.0f, 2.0f), vec2(3.0f, 4.0f), vec2(5.0f, 6.0f));)";
return R"(textureGrad(Texture_Sampler, vec2(1.0f, 2.0f), vec2(3.0f, 4.0f), vec2(5.0f, 6.0f));)";
case ValidTextureOverload::kSampleGrad2dOffsetF32:
return R"(textureGradOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), vec2(3.0f, 4.0f), vec2(5.0f, 6.0f), ivec2(7));)";
return R"(textureGradOffset(Texture_Sampler, vec2(1.0f, 2.0f), vec2(3.0f, 4.0f), vec2(5.0f, 6.0f), ivec2(7));)";
case ValidTextureOverload::kSampleGrad2dArrayF32:
return R"(textureGrad(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), vec2(4.0f, 5.0f), vec2(6.0f, 7.0f));)";
return R"(textureGrad(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), vec2(4.0f, 5.0f), vec2(6.0f, 7.0f));)";
case ValidTextureOverload::kSampleGrad2dArrayOffsetF32:
return R"(textureGradOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3u)), vec2(4.0f, 5.0f), vec2(6.0f, 7.0f), ivec2(6, 7));)";
return R"(textureGradOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3u)), vec2(4.0f, 5.0f), vec2(6.0f, 7.0f), ivec2(6, 7));)";
case ValidTextureOverload::kSampleGrad3dF32:
return R"(textureGrad(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));)";
return R"(textureGrad(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));)";
case ValidTextureOverload::kSampleGrad3dOffsetF32:
return R"(textureGradOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f), ivec3(0, 1, 2));)";
return R"(textureGradOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f), ivec3(0, 1, 2));)";
case ValidTextureOverload::kSampleGradCubeF32:
return R"(textureGrad(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));)";
return R"(textureGrad(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));)";
case ValidTextureOverload::kSampleGradCubeArrayF32:
return R"(textureGrad(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), vec3(5.0f, 6.0f, 7.0f), vec3(8.0f, 9.0f, 10.0f));)";
return R"(textureGrad(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), vec3(5.0f, 6.0f, 7.0f), vec3(8.0f, 9.0f, 10.0f));)";
case ValidTextureOverload::kSampleCompareDepth2dF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f));)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f));)";
case ValidTextureOverload::kSampleCompareDepth2dOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), ivec2(4, 5));)";
return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), ivec2(4, 5));)";
case ValidTextureOverload::kSampleCompareDepth2dArrayF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, float(4), 3.0f));)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, float(4), 3.0f));)";
case ValidTextureOverload::kSampleCompareDepth2dArrayOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec4(1.0f, 2.0f, float(4u), 3.0f), ivec2(5, 6));)";
return R"(textureOffset(Texture_Sampler, vec4(1.0f, 2.0f, float(4u), 3.0f), ivec2(5, 6));)";
case ValidTextureOverload::kSampleCompareDepthCubeF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, 4.0f));)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, 4.0f));)";
case ValidTextureOverload::kSampleCompareDepthCubeArrayF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)";
case ValidTextureOverload::kSampleCompareLevelDepth2dF32:
return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f));)";
return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f));)";
case ValidTextureOverload::kSampleCompareLevelDepth2dOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), ivec2(4, 5));)";
return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), ivec2(4, 5));)";
case ValidTextureOverload::kSampleCompareLevelDepth2dArrayF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3), 4.0f));)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, float(3), 4.0f));)";
case ValidTextureOverload::kSampleCompareLevelDepth2dArrayOffsetF32:
return R"(textureOffset(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3), 4.0f), ivec2(5, 6));)";
return R"(textureOffset(Texture_Sampler, vec4(1.0f, 2.0f, float(3), 4.0f), ivec2(5, 6));)";
case ValidTextureOverload::kSampleCompareLevelDepthCubeF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, 4.0f));)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, 4.0f));)";
case ValidTextureOverload::kSampleCompareLevelDepthCubeArrayF32:
return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)";
return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)";
case ValidTextureOverload::kLoad1dLevelF32:
return R"(texelFetch(tint_symbol_2, ivec2(uvec2(1u, 0u)), int(3u));)";
return R"(texelFetch(Texture_1, ivec2(uvec2(1u, 0u)), int(3u));)";
case ValidTextureOverload::kLoad1dLevelU32:
case ValidTextureOverload::kLoad1dLevelI32:
return R"(texelFetch(tint_symbol_2, ivec2(1, 0), 3);)";
return R"(texelFetch(Texture_1, ivec2(1, 0), 3);)";
case ValidTextureOverload::kLoad2dLevelU32:
return R"(texelFetch(tint_symbol_2, ivec2(1, 2), 3);)";
return R"(texelFetch(Texture_1, ivec2(1, 2), 3);)";
case ValidTextureOverload::kLoad2dLevelF32:
case ValidTextureOverload::kLoad2dLevelI32:
return R"(texelFetch(tint_symbol_2, ivec2(uvec2(1u, 2u)), int(3u));)";
return R"(texelFetch(Texture_1, ivec2(uvec2(1u, 2u)), int(3u));)";
case ValidTextureOverload::kLoad2dArrayLevelF32:
case ValidTextureOverload::kLoad2dArrayLevelU32:
case ValidTextureOverload::kLoad3dLevelF32:
case ValidTextureOverload::kLoad3dLevelU32:
return R"(texelFetch(tint_symbol_2, ivec3(1, 2, 3), 4);)";
return R"(texelFetch(Texture_1, ivec3(1, 2, 3), 4);)";
case ValidTextureOverload::kLoad2dArrayLevelI32:
case ValidTextureOverload::kLoad3dLevelI32:
return R"(texelFetch(tint_symbol_2, ivec3(uvec3(1u, 2u, 3u)), int(4u));)";
return R"(texelFetch(Texture_1, ivec3(uvec3(1u, 2u, 3u)), int(4u));)";
case ValidTextureOverload::kLoadMultisampled2dF32:
case ValidTextureOverload::kLoadMultisampled2dU32:
return R"(texelFetch(tint_symbol_2, ivec2(1, 2), 3);)";
return R"(texelFetch(Texture_1, ivec2(1, 2), 3);)";
case ValidTextureOverload::kLoadMultisampled2dI32:
return R"(texelFetch(tint_symbol_2, ivec2(uvec2(1u, 2u)), int(3u));)";
return R"(texelFetch(Texture_1, ivec2(uvec2(1u, 2u)), int(3u));)";
case ValidTextureOverload::kLoadDepth2dLevelF32:
return R"(texelFetch(tint_symbol_2, ivec2(1, 2), 3);)";
return R"(texelFetch(Texture_1, ivec2(1, 2), 3);)";
case ValidTextureOverload::kLoadDepth2dArrayLevelF32:
return R"(texelFetch(tint_symbol_2, ivec3(uvec3(1u, 2u, 3u)), int(4u));)";
return R"(texelFetch(Texture_1, ivec3(uvec3(1u, 2u, 3u)), int(4u));)";
case ValidTextureOverload::kLoadDepthMultisampled2dF32:
return R"(texelFetch(tint_symbol_2, ivec2(uvec2(1u, 2u)), int(3u)).x;)";
return R"(texelFetch(Texture_1, ivec2(uvec2(1u, 2u)), int(3u)).x;)";
case ValidTextureOverload::kStoreWO1dRgba32float:
return R"(imageStore(tint_symbol, ivec2(1, 0), vec4(2.0f, 3.0f, 4.0f, 5.0f));)";
return R"(imageStore(Texture, ivec2(1, 0), vec4(2.0f, 3.0f, 4.0f, 5.0f));)";
case ValidTextureOverload::kStoreWO2dRgba32float:
return R"(imageStore(tint_symbol, ivec2(1, 2), vec4(3.0f, 4.0f, 5.0f, 6.0f));)";
return R"(imageStore(Texture, ivec2(1, 2), vec4(3.0f, 4.0f, 5.0f, 6.0f));)";
case ValidTextureOverload::kStoreWO2dArrayRgba32float:
return R"(imageStore(tint_symbol, ivec3(uvec3(1u, 2u, 3u)), vec4(4.0f, 5.0f, 6.0f, 7.0f));)";
return R"(imageStore(Texture, ivec3(uvec3(1u, 2u, 3u)), vec4(4.0f, 5.0f, 6.0f, 7.0f));)";
case ValidTextureOverload::kStoreWO3dRgba32float:
return R"(imageStore(tint_symbol, ivec3(uvec3(1u, 2u, 3u)), vec4(4.0f, 5.0f, 6.0f, 7.0f));)";
return R"(imageStore(Texture, ivec3(uvec3(1u, 2u, 3u)), vec4(4.0f, 5.0f, 6.0f, 7.0f));)";
}
return "<unmatched texture overload>";
} // NOLINT - Ignore the length of this function

View File

@ -2025,60 +2025,81 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
out << " " << param_name;
}
if (type->Is<sem::Struct>()) {
out << " [[stage_in]]";
} else if (type->is_handle()) {
uint32_t binding = get_binding_index(param);
if (binding == kInvalidBindingIndex) {
return false;
}
if (param->type->Is<ast::Sampler>()) {
out << " [[sampler(" << binding << ")]]";
} else if (TINT_LIKELY(param->type->Is<ast::Texture>())) {
out << " [[texture(" << binding << ")]]";
} else {
TINT_ICE(Writer, diagnostics_) << "invalid handle type entry point parameter";
return false;
}
} else if (auto* ptr = param->type->As<ast::Pointer>()) {
auto sc = ptr->address_space;
if (sc == type::AddressSpace::kWorkgroup) {
auto& allocations = workgroup_allocations_[func_name];
out << " [[threadgroup(" << allocations.size() << ")]]";
allocations.push_back(program_->Sem().Get(ptr->type)->Size());
} else if (TINT_LIKELY(sc == type::AddressSpace::kStorage ||
sc == type::AddressSpace::kUniform)) {
bool ok = Switch(
type, //
[&](const type::Struct*) {
out << " [[stage_in]]";
return true;
},
[&](const type::Texture*) {
uint32_t binding = get_binding_index(param);
if (binding == kInvalidBindingIndex) {
return false;
}
out << " [[buffer(" << binding << ")]]";
} else {
out << " [[texture(" << binding << ")]]";
return true;
},
[&](const type::Sampler*) {
uint32_t binding = get_binding_index(param);
if (binding == kInvalidBindingIndex) {
return false;
}
out << " [[sampler(" << binding << ")]]";
return true;
},
[&](const type::Pointer* ptr) {
switch (ptr->AddressSpace()) {
case type::AddressSpace::kWorkgroup: {
auto& allocations = workgroup_allocations_[func_name];
out << " [[threadgroup(" << allocations.size() << ")]]";
allocations.push_back(ptr->StoreType()->Size());
return true;
}
case type::AddressSpace::kStorage:
case type::AddressSpace::kUniform: {
uint32_t binding = get_binding_index(param);
if (binding == kInvalidBindingIndex) {
return false;
}
out << " [[buffer(" << binding << ")]]";
return true;
}
default:
break;
}
TINT_ICE(Writer, diagnostics_)
<< "invalid pointer address space for entry point parameter";
return false;
}
} else {
auto& attrs = param->attributes;
bool builtin_found = false;
for (auto* attr : attrs) {
auto* builtin = attr->As<ast::BuiltinAttribute>();
if (!builtin) {
continue;
},
[&](Default) {
auto& attrs = param->attributes;
bool builtin_found = false;
for (auto* attr : attrs) {
auto* builtin = attr->As<ast::BuiltinAttribute>();
if (!builtin) {
continue;
}
builtin_found = true;
auto name = builtin_to_attribute(builtin->builtin);
if (name.empty()) {
diagnostics_.add_error(diag::System::Writer, "unknown builtin");
return false;
}
out << " [[" << name << "]]";
}
builtin_found = true;
auto name = builtin_to_attribute(builtin->builtin);
if (name.empty()) {
diagnostics_.add_error(diag::System::Writer, "unknown builtin");
if (TINT_UNLIKELY(!builtin_found)) {
TINT_ICE(Writer, diagnostics_) << "Unsupported entry point parameter";
return false;
}
out << " [[" << name << "]]";
}
if (TINT_UNLIKELY(!builtin_found)) {
TINT_ICE(Writer, diagnostics_) << "Unsupported entry point parameter";
}
return true;
});
if (!ok) {
return false;
}
}
out << ") {";

View File

@ -24,7 +24,7 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o
switch (overload) {
case ValidTextureOverload::kDimensions1d:
case ValidTextureOverload::kDimensionsStorageWO1d:
return R"(texture.get_width(0))";
return R"(Texture.get_width(0))";
case ValidTextureOverload::kDimensions2d:
case ValidTextureOverload::kDimensions2dArray:
case ValidTextureOverload::kDimensionsCube:
@ -37,10 +37,10 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o
case ValidTextureOverload::kDimensionsDepthMultisampled2d:
case ValidTextureOverload::kDimensionsStorageWO2d:
case ValidTextureOverload::kDimensionsStorageWO2dArray:
return R"(uint2(texture.get_width(), texture.get_height()))";
return R"(uint2(Texture.get_width(), Texture.get_height()))";
case ValidTextureOverload::kDimensions3d:
case ValidTextureOverload::kDimensionsStorageWO3d:
return R"(uint3(texture.get_width(), texture.get_height(), texture.get_depth()))";
return R"(uint3(Texture.get_width(), Texture.get_height(), Texture.get_depth()))";
case ValidTextureOverload::kDimensions2dLevel:
case ValidTextureOverload::kDimensionsCubeLevel:
case ValidTextureOverload::kDimensionsCubeArrayLevel:
@ -49,51 +49,51 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o
case ValidTextureOverload::kDimensionsDepth2dArrayLevel:
case ValidTextureOverload::kDimensionsDepthCubeLevel:
case ValidTextureOverload::kDimensionsDepthCubeArrayLevel:
return R"(uint2(texture.get_width(1), texture.get_height(1)))";
return R"(uint2(Texture.get_width(1), Texture.get_height(1)))";
case ValidTextureOverload::kDimensions3dLevel:
return R"(uint3(texture.get_width(1), texture.get_height(1), texture.get_depth(1)))";
return R"(uint3(Texture.get_width(1), Texture.get_height(1), Texture.get_depth(1)))";
case ValidTextureOverload::kGather2dF32:
return R"(texture.gather(sampler, float2(1.0f, 2.0f), int2(0), component::x))";
return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), int2(0), component::x))";
case ValidTextureOverload::kGather2dOffsetF32:
return R"(texture.gather(sampler, float2(1.0f, 2.0f), int2(3, 4), component::x))";
return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), int2(3, 4), component::x))";
case ValidTextureOverload::kGather2dArrayF32:
return R"(texture.gather(sampler, float2(1.0f, 2.0f), 3, int2(0), component::x))";
return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), 3, int2(0), component::x))";
case ValidTextureOverload::kGather2dArrayOffsetF32:
return R"(texture.gather(sampler, float2(1.0f, 2.0f), 3u, int2(4, 5), component::x))";
return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), 3u, int2(4, 5), component::x))";
case ValidTextureOverload::kGatherCubeF32:
return R"(texture.gather(sampler, float3(1.0f, 2.0f, 3.0f), component::x))";
return R"(Texture.gather(Sampler, float3(1.0f, 2.0f, 3.0f), component::x))";
case ValidTextureOverload::kGatherCubeArrayF32:
return R"(texture.gather(sampler, float3(1.0f, 2.0f, 3.0f), 4u, component::x))";
return R"(Texture.gather(Sampler, float3(1.0f, 2.0f, 3.0f), 4u, component::x))";
case ValidTextureOverload::kGatherDepth2dF32:
return R"(texture.gather(sampler, float2(1.0f, 2.0f)))";
return R"(Texture.gather(Sampler, float2(1.0f, 2.0f)))";
case ValidTextureOverload::kGatherDepth2dOffsetF32:
return R"(texture.gather(sampler, float2(1.0f, 2.0f), int2(3, 4)))";
return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), int2(3, 4)))";
case ValidTextureOverload::kGatherDepth2dArrayF32:
return R"(texture.gather(sampler, float2(1.0f, 2.0f), 3u))";
return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), 3u))";
case ValidTextureOverload::kGatherDepth2dArrayOffsetF32:
return R"(texture.gather(sampler, float2(1.0f, 2.0f), 3, int2(4, 5)))";
return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), 3, int2(4, 5)))";
case ValidTextureOverload::kGatherDepthCubeF32:
return R"(texture.gather(sampler, float3(1.0f, 2.0f, 3.0f)))";
return R"(Texture.gather(Sampler, float3(1.0f, 2.0f, 3.0f)))";
case ValidTextureOverload::kGatherDepthCubeArrayF32:
return R"(texture.gather(sampler, float3(1.0f, 2.0f, 3.0f), 4u))";
return R"(Texture.gather(Sampler, float3(1.0f, 2.0f, 3.0f), 4u))";
case ValidTextureOverload::kGatherCompareDepth2dF32:
return R"(texture.gather_compare(sampler, float2(1.0f, 2.0f), 3.0f))";
return R"(Texture.gather_compare(Sampler, float2(1.0f, 2.0f), 3.0f))";
case ValidTextureOverload::kGatherCompareDepth2dOffsetF32:
return R"(texture.gather_compare(sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))";
return R"(Texture.gather_compare(Sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))";
case ValidTextureOverload::kGatherCompareDepth2dArrayF32:
return R"(texture.gather_compare(sampler, float2(1.0f, 2.0f), 3, 4.0f))";
return R"(Texture.gather_compare(Sampler, float2(1.0f, 2.0f), 3, 4.0f))";
case ValidTextureOverload::kGatherCompareDepth2dArrayOffsetF32:
return R"(texture.gather_compare(sampler, float2(1.0f, 2.0f), 3, 4.0f, int2(5, 6)))";
return R"(Texture.gather_compare(Sampler, float2(1.0f, 2.0f), 3, 4.0f, int2(5, 6)))";
case ValidTextureOverload::kGatherCompareDepthCubeF32:
return R"(texture.gather_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))";
return R"(Texture.gather_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))";
case ValidTextureOverload::kGatherCompareDepthCubeArrayF32:
return R"(texture.gather_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4u, 5.0f))";
return R"(Texture.gather_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4u, 5.0f))";
case ValidTextureOverload::kNumLayers2dArray:
case ValidTextureOverload::kNumLayersCubeArray:
case ValidTextureOverload::kNumLayersDepth2dArray:
case ValidTextureOverload::kNumLayersDepthCubeArray:
case ValidTextureOverload::kNumLayersStorageWO2dArray:
return R"(texture.get_array_size())";
return R"(Texture.get_array_size())";
case ValidTextureOverload::kNumLevels2d:
case ValidTextureOverload::kNumLevels2dArray:
case ValidTextureOverload::kNumLevels3d:
@ -103,166 +103,166 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o
case ValidTextureOverload::kNumLevelsDepth2dArray:
case ValidTextureOverload::kNumLevelsDepthCube:
case ValidTextureOverload::kNumLevelsDepthCubeArray:
return R"(texture.get_num_mip_levels())";
return R"(Texture.get_num_mip_levels())";
case ValidTextureOverload::kNumSamplesDepthMultisampled2d:
case ValidTextureOverload::kNumSamplesMultisampled2d:
return R"(texture.get_num_samples())";
return R"(Texture.get_num_samples())";
case ValidTextureOverload::kSample1dF32:
return R"(texture.sample(sampler, 1.0f))";
return R"(Texture.sample(Sampler, 1.0f))";
case ValidTextureOverload::kSample2dF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f)))";
case ValidTextureOverload::kSample2dOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), int2(3, 4)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), int2(3, 4)))";
case ValidTextureOverload::kSample2dArrayF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3))";
case ValidTextureOverload::kSample2dArrayOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3u, int2(4, 5)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3u, int2(4, 5)))";
case ValidTextureOverload::kSample3dF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f)))";
case ValidTextureOverload::kSample3dOffsetF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), int3(4, 5, 6)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), int3(4, 5, 6)))";
case ValidTextureOverload::kSampleCubeF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f)))";
case ValidTextureOverload::kSampleCubeArrayF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4))";
case ValidTextureOverload::kSampleDepth2dF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f)))";
case ValidTextureOverload::kSampleDepth2dOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), int2(3, 4)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), int2(3, 4)))";
case ValidTextureOverload::kSampleDepth2dArrayF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3))";
case ValidTextureOverload::kSampleDepth2dArrayOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, int2(4, 5)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, int2(4, 5)))";
case ValidTextureOverload::kSampleDepthCubeF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f)))";
case ValidTextureOverload::kSampleDepthCubeArrayF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4u))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4u))";
case ValidTextureOverload::kSampleBias2dF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), bias(3.0f)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), bias(3.0f)))";
case ValidTextureOverload::kSampleBias2dOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), bias(3.0f), int2(4, 5)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), bias(3.0f), int2(4, 5)))";
case ValidTextureOverload::kSampleBias2dArrayF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 4u, bias(3.0f)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 4u, bias(3.0f)))";
case ValidTextureOverload::kSampleBias2dArrayOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, bias(4.0f), int2(5, 6)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, bias(4.0f), int2(5, 6)))";
case ValidTextureOverload::kSampleBias3dF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f)))";
case ValidTextureOverload::kSampleBias3dOffsetF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f), int3(5, 6, 7)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f), int3(5, 6, 7)))";
case ValidTextureOverload::kSampleBiasCubeF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f)))";
case ValidTextureOverload::kSampleBiasCubeArrayF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 3, bias(4.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 3, bias(4.0f)))";
case ValidTextureOverload::kSampleLevel2dF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), level(3.0f)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), level(3.0f)))";
case ValidTextureOverload::kSampleLevel2dOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), level(3.0f), int2(4, 5)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), level(3.0f), int2(4, 5)))";
case ValidTextureOverload::kSampleLevel2dArrayF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, level(4.0f)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, level(4.0f)))";
case ValidTextureOverload::kSampleLevel2dArrayOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, level(4.0f), int2(5, 6)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, level(4.0f), int2(5, 6)))";
case ValidTextureOverload::kSampleLevel3dF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f)))";
case ValidTextureOverload::kSampleLevel3dOffsetF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f), int3(5, 6, 7)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f), int3(5, 6, 7)))";
case ValidTextureOverload::kSampleLevelCubeF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f)))";
case ValidTextureOverload::kSampleLevelCubeArrayF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4, level(5.0f)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4, level(5.0f)))";
case ValidTextureOverload::kSampleLevelDepth2dF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), level(3u)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), level(3u)))";
case ValidTextureOverload::kSampleLevelDepth2dOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), level(3), int2(4, 5)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), level(3), int2(4, 5)))";
case ValidTextureOverload::kSampleLevelDepth2dArrayF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3u, level(4u)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3u, level(4u)))";
case ValidTextureOverload::kSampleLevelDepth2dArrayOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3u, level(4u), int2(5, 6)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3u, level(4u), int2(5, 6)))";
case ValidTextureOverload::kSampleLevelDepthCubeF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), level(4)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), level(4)))";
case ValidTextureOverload::kSampleLevelDepthCubeArrayF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4, level(5)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4, level(5)))";
case ValidTextureOverload::kSampleGrad2dF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), gradient2d(float2(3.0f, 4.0f), float2(5.0f, 6.0f))))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), gradient2d(float2(3.0f, 4.0f), float2(5.0f, 6.0f))))";
case ValidTextureOverload::kSampleGrad2dOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), gradient2d(float2(3.0f, 4.0f), float2(5.0f, 6.0f)), int2(7)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), gradient2d(float2(3.0f, 4.0f), float2(5.0f, 6.0f)), int2(7)))";
case ValidTextureOverload::kSampleGrad2dArrayF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, gradient2d(float2(4.0f, 5.0f), float2(6.0f, 7.0f))))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, gradient2d(float2(4.0f, 5.0f), float2(6.0f, 7.0f))))";
case ValidTextureOverload::kSampleGrad2dArrayOffsetF32:
return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3u, gradient2d(float2(4.0f, 5.0f), float2(6.0f, 7.0f)), int2(6, 7)))";
return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3u, gradient2d(float2(4.0f, 5.0f), float2(6.0f, 7.0f)), int2(6, 7)))";
case ValidTextureOverload::kSampleGrad3dF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), gradient3d(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), gradient3d(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))))";
case ValidTextureOverload::kSampleGrad3dOffsetF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), gradient3d(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f)), int3(0, 1, 2)))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), gradient3d(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f)), int3(0, 1, 2)))";
case ValidTextureOverload::kSampleGradCubeF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), gradientcube(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), gradientcube(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))))";
case ValidTextureOverload::kSampleGradCubeArrayF32:
return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4u, gradientcube(float3(5.0f, 6.0f, 7.0f), float3(8.0f, 9.0f, 10.0f))))";
return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4u, gradientcube(float3(5.0f, 6.0f, 7.0f), float3(8.0f, 9.0f, 10.0f))))";
case ValidTextureOverload::kSampleCompareDepth2dF32:
return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3.0f))";
return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3.0f))";
case ValidTextureOverload::kSampleCompareDepth2dOffsetF32:
return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))";
return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))";
case ValidTextureOverload::kSampleCompareDepth2dArrayF32:
return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 4, 3.0f))";
return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 4, 3.0f))";
case ValidTextureOverload::kSampleCompareDepth2dArrayOffsetF32:
return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 4u, 3.0f, int2(5, 6)))";
return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 4u, 3.0f, int2(5, 6)))";
case ValidTextureOverload::kSampleCompareDepthCubeF32:
return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))";
return R"(Texture.sample_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))";
case ValidTextureOverload::kSampleCompareDepthCubeArrayF32:
return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f))";
return R"(Texture.sample_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f))";
case ValidTextureOverload::kSampleCompareLevelDepth2dF32:
return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3.0f, level(0)))";
return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3.0f, level(0)))";
case ValidTextureOverload::kSampleCompareLevelDepth2dOffsetF32:
return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3.0f, level(0), int2(4, 5)))";
return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3.0f, level(0), int2(4, 5)))";
case ValidTextureOverload::kSampleCompareLevelDepth2dArrayF32:
return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3, 4.0f, level(0)))";
return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3, 4.0f, level(0)))";
case ValidTextureOverload::kSampleCompareLevelDepth2dArrayOffsetF32:
return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3, 4.0f, level(0), int2(5, 6)))";
return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3, 4.0f, level(0), int2(5, 6)))";
case ValidTextureOverload::kSampleCompareLevelDepthCubeF32:
return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4.0f, level(0)))";
return R"(Texture.sample_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4.0f, level(0)))";
case ValidTextureOverload::kSampleCompareLevelDepthCubeArrayF32:
return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f, level(0)))";
return R"(Texture.sample_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f, level(0)))";
case ValidTextureOverload::kLoad1dLevelF32:
return R"(texture.read(uint(1u), 0))";
return R"(Texture.read(uint(1u), 0))";
case ValidTextureOverload::kLoad1dLevelU32:
return R"(texture.read(uint(1), 0))";
return R"(Texture.read(uint(1), 0))";
case ValidTextureOverload::kLoad1dLevelI32:
return R"(texture.read(uint(1), 0))";
return R"(Texture.read(uint(1), 0))";
case ValidTextureOverload::kLoad2dLevelF32:
return R"(texture.read(uint2(uint2(1u, 2u)), 3u))";
return R"(Texture.read(uint2(uint2(1u, 2u)), 3u))";
case ValidTextureOverload::kLoad2dLevelU32:
return R"(texture.read(uint2(int2(1, 2)), 3))";
return R"(Texture.read(uint2(int2(1, 2)), 3))";
case ValidTextureOverload::kLoad2dArrayLevelF32:
return R"(texture.read(uint2(int2(1, 2)), 3, 4))";
return R"(Texture.read(uint2(int2(1, 2)), 3, 4))";
case ValidTextureOverload::kLoad2dArrayLevelU32:
return R"(texture.read(uint2(int2(1, 2)), 3, 4))";
return R"(Texture.read(uint2(int2(1, 2)), 3, 4))";
case ValidTextureOverload::kLoad2dArrayLevelI32:
return R"(texture.read(uint2(uint2(1u, 2u)), 3u, 4u))";
return R"(Texture.read(uint2(uint2(1u, 2u)), 3u, 4u))";
case ValidTextureOverload::kLoad3dLevelF32:
return R"(texture.read(uint3(int3(1, 2, 3)), 4))";
return R"(Texture.read(uint3(int3(1, 2, 3)), 4))";
case ValidTextureOverload::kLoad3dLevelU32:
return R"(texture.read(uint3(int3(1, 2, 3)), 4))";
return R"(Texture.read(uint3(int3(1, 2, 3)), 4))";
case ValidTextureOverload::kLoad3dLevelI32:
return R"(texture.read(uint3(uint3(1u, 2u, 3u)), 4u))";
return R"(Texture.read(uint3(uint3(1u, 2u, 3u)), 4u))";
case ValidTextureOverload::kLoadMultisampled2dF32:
case ValidTextureOverload::kLoadMultisampled2dU32:
return R"(texture.read(uint2(int2(1, 2)), 3))";
return R"(Texture.read(uint2(int2(1, 2)), 3))";
case ValidTextureOverload::kLoad2dLevelI32:
case ValidTextureOverload::kLoadMultisampled2dI32:
return R"(texture.read(uint2(uint2(1u, 2u)), 3u))";
return R"(Texture.read(uint2(uint2(1u, 2u)), 3u))";
case ValidTextureOverload::kLoadDepth2dLevelF32:
return R"(texture.read(uint2(int2(1, 2)), 3))";
return R"(Texture.read(uint2(int2(1, 2)), 3))";
case ValidTextureOverload::kLoadDepth2dArrayLevelF32:
return R"(texture.read(uint2(uint2(1u, 2u)), 3u, 4u))";
return R"(Texture.read(uint2(uint2(1u, 2u)), 3u, 4u))";
case ValidTextureOverload::kLoadDepthMultisampled2dF32:
return R"(texture.read(uint2(uint2(1u, 2u)), 3u))";
return R"(Texture.read(uint2(uint2(1u, 2u)), 3u))";
case ValidTextureOverload::kStoreWO1dRgba32float:
return R"(texture.write(float4(2.0f, 3.0f, 4.0f, 5.0f), uint(1)))";
return R"(Texture.write(float4(2.0f, 3.0f, 4.0f, 5.0f), uint(1)))";
case ValidTextureOverload::kStoreWO2dRgba32float:
return R"(texture.write(float4(3.0f, 4.0f, 5.0f, 6.0f), uint2(int2(1, 2))))";
return R"(Texture.write(float4(3.0f, 4.0f, 5.0f, 6.0f), uint2(int2(1, 2))))";
case ValidTextureOverload::kStoreWO2dArrayRgba32float:
return R"(texture.write(float4(4.0f, 5.0f, 6.0f, 7.0f), uint2(uint2(1u, 2u)), 3u))";
return R"(Texture.write(float4(4.0f, 5.0f, 6.0f, 7.0f), uint2(uint2(1u, 2u)), 3u))";
case ValidTextureOverload::kStoreWO3dRgba32float:
return R"(texture.write(float4(4.0f, 5.0f, 6.0f, 7.0f), uint3(uint3(1u, 2u, 3u))))";
return R"(Texture.write(float4(4.0f, 5.0f, 6.0f, 7.0f), uint3(uint3(1u, 2u, 3u))))";
}
return "<unmatched texture overload>";
} // NOLINT - Ignore the length of this function

View File

@ -452,14 +452,6 @@ bool GeneratorImpl::EmitType(std::ostream& out, const ast::Type* ty) {
out << ">";
return true;
},
[&](const ast::Sampler* sampler) {
out << "sampler";
if (sampler->IsComparison()) {
out << "_comparison";
}
return true;
},
[&](const ast::ExternalTexture*) {
out << "texture_external";
return true;