Remove use of UnwrapAll()

Change-Id: I26518ecd17cd3a69357698d1e1a2201fcbc460e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48880
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ryan Harrison 2021-04-23 08:36:33 +00:00 committed by Commit Bot service account
parent 43d2b98d85
commit 099ceb2050
1 changed files with 31 additions and 29 deletions

View File

@ -502,7 +502,7 @@ bool Resolver::ValidateGlobalVariable(const VariableInfo* info) {
bool Resolver::ValidateVariable(const ast::Variable* var) { bool Resolver::ValidateVariable(const ast::Variable* var) {
auto* type = variable_to_info_[var]->type; auto* type = variable_to_info_[var]->type;
if (auto* r = type->UnwrapAll()->As<sem::ArrayType>()) { if (auto* r = type->As<sem::ArrayType>()) {
if (r->IsRuntimeArray()) { if (r->IsRuntimeArray()) {
diagnostics_.add_error( diagnostics_.add_error(
"v-0015", "v-0015",
@ -512,7 +512,7 @@ bool Resolver::ValidateVariable(const ast::Variable* var) {
} }
} }
if (auto* r = type->UnwrapAll()->As<sem::MultisampledTexture>()) { if (auto* r = type->As<sem::MultisampledTexture>()) {
if (r->dim() != ast::TextureDimension::k2d) { if (r->dim() != ast::TextureDimension::k2d) {
diagnostics_.add_error("Only 2d multisampled textures are supported", diagnostics_.add_error("Only 2d multisampled textures are supported",
var->source()); var->source());
@ -528,36 +528,38 @@ bool Resolver::ValidateVariable(const ast::Variable* var) {
} }
} }
if (auto* r = type->UnwrapAll()->As<sem::StorageTexture>()) { if (type->As<sem::StorageTexture>()) {
auto* ac = type->As<sem::AccessControl>(); diagnostics_.add_error("Storage Textures must have access control.",
if (!ac) { var->source());
diagnostics_.add_error("Storage Textures must have access control.", return false;
var->source()); }
return false;
}
if (ac->IsReadWrite()) { if (auto* ac = type->As<sem::AccessControl>()) {
diagnostics_.add_error( if (auto* r = ac->type()->As<sem::StorageTexture>()) {
"Storage Textures only support Read-Only and Write-Only access " if (ac->IsReadWrite()) {
"control.", diagnostics_.add_error(
var->source()); "Storage Textures only support Read-Only and Write-Only access "
return false; "control.",
} var->source());
return false;
}
if (!IsValidStorageTextureDimension(r->dim())) { if (!IsValidStorageTextureDimension(r->dim())) {
diagnostics_.add_error( diagnostics_.add_error(
"Cube dimensions for storage textures are not " "Cube dimensions for storage textures are not "
"supported.", "supported.",
var->source()); var->source());
return false; return false;
} }
if (!IsValidStorageTextureImageFormat(r->image_format())) { if (!IsValidStorageTextureImageFormat(r->image_format())) {
diagnostics_.add_error( diagnostics_.add_error(
"image format must be one of the texel formats specified for storage " "image format must be one of the texel formats specified for "
"textues in https://gpuweb.github.io/gpuweb/wgsl/#texel-formats", "storage textues in "
var->source()); "https://gpuweb.github.io/gpuweb/wgsl/#texel-formats",
return false; var->source());
return false;
}
} }
} }