From 099ceb205068fa43500f51023a7011a0ea3f4df1 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 23 Apr 2021 08:36:33 +0000 Subject: [PATCH] Remove use of UnwrapAll() Change-Id: I26518ecd17cd3a69357698d1e1a2201fcbc460e0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48880 Auto-Submit: Ryan Harrison Kokoro: Kokoro Commit-Queue: Ben Clayton Reviewed-by: Ben Clayton --- src/resolver/resolver.cc | 60 +++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index 06bb7c972e..85501b0469 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -502,7 +502,7 @@ bool Resolver::ValidateGlobalVariable(const VariableInfo* info) { bool Resolver::ValidateVariable(const ast::Variable* var) { auto* type = variable_to_info_[var]->type; - if (auto* r = type->UnwrapAll()->As()) { + if (auto* r = type->As()) { if (r->IsRuntimeArray()) { diagnostics_.add_error( "v-0015", @@ -512,7 +512,7 @@ bool Resolver::ValidateVariable(const ast::Variable* var) { } } - if (auto* r = type->UnwrapAll()->As()) { + if (auto* r = type->As()) { if (r->dim() != ast::TextureDimension::k2d) { diagnostics_.add_error("Only 2d multisampled textures are supported", var->source()); @@ -528,36 +528,38 @@ bool Resolver::ValidateVariable(const ast::Variable* var) { } } - if (auto* r = type->UnwrapAll()->As()) { - auto* ac = type->As(); - if (!ac) { - diagnostics_.add_error("Storage Textures must have access control.", - var->source()); - return false; - } + if (type->As()) { + diagnostics_.add_error("Storage Textures must have access control.", + var->source()); + return false; + } - if (ac->IsReadWrite()) { - diagnostics_.add_error( - "Storage Textures only support Read-Only and Write-Only access " - "control.", - var->source()); - return false; - } + if (auto* ac = type->As()) { + if (auto* r = ac->type()->As()) { + if (ac->IsReadWrite()) { + diagnostics_.add_error( + "Storage Textures only support Read-Only and Write-Only access " + "control.", + var->source()); + return false; + } - if (!IsValidStorageTextureDimension(r->dim())) { - diagnostics_.add_error( - "Cube dimensions for storage textures are not " - "supported.", - var->source()); - return false; - } + if (!IsValidStorageTextureDimension(r->dim())) { + diagnostics_.add_error( + "Cube dimensions for storage textures are not " + "supported.", + var->source()); + return false; + } - if (!IsValidStorageTextureImageFormat(r->image_format())) { - diagnostics_.add_error( - "image format must be one of the texel formats specified for storage " - "textues in https://gpuweb.github.io/gpuweb/wgsl/#texel-formats", - var->source()); - return false; + if (!IsValidStorageTextureImageFormat(r->image_format())) { + diagnostics_.add_error( + "image format must be one of the texel formats specified for " + "storage textues in " + "https://gpuweb.github.io/gpuweb/wgsl/#texel-formats", + var->source()); + return false; + } } }