tint/resolver: Use utils::Vector in a few places

Use the new vector type in some of the hot code paths of the resolver.

Bug: tint:1613
Change-Id: Ie56d8c96f73c9112f37934ad67e588513aafb982
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96282
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-07-26 07:55:24 +00:00
committed by Dawn LUCI CQ
parent 4b3d53d141
commit 958a4642f1
38 changed files with 493 additions and 478 deletions

View File

@@ -509,7 +509,7 @@ struct CanonicalizeEntryPointIO::State {
}
// Exit early if there is no shader IO to handle.
if (func_sem->Parameters().size() == 0 && func_sem->ReturnType()->Is<sem::Void>() &&
if (func_sem->Parameters().Length() == 0 && func_sem->ReturnType()->Is<sem::Void>() &&
!needs_fixed_sample_mask && !needs_vertex_point_size &&
cfg.shader_style != ShaderStyle::kGlsl) {
return;
@@ -517,7 +517,7 @@ struct CanonicalizeEntryPointIO::State {
// Process the entry point parameters, collecting those that need to be
// aggregated into a single structure.
if (!func_sem->Parameters().empty()) {
if (!func_sem->Parameters().IsEmpty()) {
for (auto* param : func_sem->Parameters()) {
if (param->Type()->Is<sem::Struct>()) {
ProcessStructParameter(param);

View File

@@ -635,7 +635,7 @@ struct DecomposeMemoryAccess::State {
};
// Other parameters are copied as-is:
for (size_t i = 1; i < intrinsic->Parameters().size(); i++) {
for (size_t i = 1; i < intrinsic->Parameters().Length(); i++) {
auto* param = intrinsic->Parameters()[i];
auto* ty = CreateASTTypeFor(ctx, param->Type());
params.emplace_back(b.Param("param_" + std::to_string(i), ty));
@@ -834,7 +834,7 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) con
// X.Y
auto* accessor_sem = sem.Get(accessor);
if (auto* swizzle = accessor_sem->As<sem::Swizzle>()) {
if (swizzle->Indices().size() == 1) {
if (swizzle->Indices().Length() == 1) {
if (auto access = state.TakeAccess(accessor->structure)) {
auto* vec_ty = access.type->As<sem::Vector>();
auto* offset = state.Mul(vec_ty->type()->Size(), swizzle->Indices()[0u]);

View File

@@ -187,7 +187,7 @@ struct MultiplanarExternalTexture::State {
auto* call = sem.Get(expr)->UnwrapMaterialize()->As<sem::Call>();
auto* builtin = call->Target()->As<sem::Builtin>();
if (builtin && !builtin->Parameters().empty() &&
if (builtin && !builtin->Parameters().IsEmpty() &&
builtin->Parameters()[0]->Type()->Is<sem::ExternalTexture>() &&
builtin->Type() != sem::BuiltinType::kTextureDimensions) {
if (auto* var_user = sem.Get<sem::VariableUser>(expr->args[0])) {

View File

@@ -36,7 +36,7 @@ bool VectorizeScalarMatrixConstructors::ShouldRun(const Program* program, const
if (auto* call = program->Sem().Get<sem::Call>(node)) {
if (call->Target()->Is<sem::TypeConstructor>() && call->Type()->Is<sem::Matrix>()) {
auto& args = call->Arguments();
if (args.size() > 0 && args[0]->Type()->UnwrapRef()->is_scalar()) {
if (!args.IsEmpty() && args[0]->Type()->UnwrapRef()->is_scalar()) {
return true;
}
}
@@ -61,7 +61,7 @@ void VectorizeScalarMatrixConstructors::Run(CloneContext& ctx, const DataMap&, D
}
auto& args = call->Arguments();
if (args.size() == 0) {
if (args.IsEmpty()) {
return nullptr;
}
if (!args[0]->Type()->UnwrapRef()->is_scalar()) {
@@ -85,7 +85,7 @@ void VectorizeScalarMatrixConstructors::Run(CloneContext& ctx, const DataMap&, D
return ctx.dst->Construct(CreateASTTypeFor(ctx, mat_type), columns);
};
if (args.size() == 1) {
if (args.Length() == 1) {
// Generate a helper function for constructing the matrix.
// This is done to ensure that the single argument value is only evaluated once, and
// with the correct expression evaluation order.
@@ -109,7 +109,7 @@ void VectorizeScalarMatrixConstructors::Run(CloneContext& ctx, const DataMap&, D
return ctx.dst->Call(fn, ctx.Clone(args[0]->Declaration()));
}
if (args.size() == mat_type->columns() * mat_type->rows()) {
if (args.Length() == mat_type->columns() * mat_type->rows()) {
return build_mat([&](uint32_t c, uint32_t r) {
return ctx.Clone(args[c * mat_type->rows() + r]->Declaration());
});