[wgsl] Remove kIgnoreAddressSpace validation override
This is no longer used by any AST transforms.
Change-Id: I1ba1329136fd31d02612b062db4560785bc8fa4c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/236087
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/wgsl/ast/disable_validation_attribute.cc b/src/tint/lang/wgsl/ast/disable_validation_attribute.cc
index 13027fd..cbc2dee 100644
--- a/src/tint/lang/wgsl/ast/disable_validation_attribute.cc
+++ b/src/tint/lang/wgsl/ast/disable_validation_attribute.cc
@@ -46,8 +46,6 @@
return "disable_validation__function_has_no_body";
case DisabledValidation::kBindingPointCollision:
return "disable_validation__binding_point_collision";
- case DisabledValidation::kIgnoreAddressSpace:
- return "disable_validation__ignore_address_space";
case DisabledValidation::kFunctionParameter:
return "disable_validation__function_parameter";
case DisabledValidation::kIgnoreStrideAttribute:
diff --git a/src/tint/lang/wgsl/ast/disable_validation_attribute.h b/src/tint/lang/wgsl/ast/disable_validation_attribute.h
index 0da652e..75012a7 100644
--- a/src/tint/lang/wgsl/ast/disable_validation_attribute.h
+++ b/src/tint/lang/wgsl/ast/disable_validation_attribute.h
@@ -42,9 +42,6 @@
/// When applied to a module-scoped variable, the validator will not complain if two resource
/// variables have the same binding points.
kBindingPointCollision,
- /// When applied to a variable, the validator will not complain about the declared address
- /// space.
- kIgnoreAddressSpace,
/// When applied to a function parameter, the parameter will not be validated.
kFunctionParameter,
/// When applied to a member attribute, a stride attribute may be applied to non-array types.
diff --git a/src/tint/lang/wgsl/resolver/entry_point_validation_test.cc b/src/tint/lang/wgsl/resolver/entry_point_validation_test.cc
index 0a43290..1005cbf 100644
--- a/src/tint/lang/wgsl/resolver/entry_point_validation_test.cc
+++ b/src/tint/lang/wgsl/resolver/entry_point_validation_test.cc
@@ -464,14 +464,6 @@
"extension 'chromium_experimental_push_constant'");
}
-TEST_F(ResolverEntryPointValidationTest, PushConstantAllowedWithIgnoreAddressSpaceAttribute) {
- // var<push_constant> a : u32; // With ast::DisabledValidation::kIgnoreAddressSpace
- GlobalVar("a", ty.u32(), core::AddressSpace::kPushConstant,
- Vector{Disable(ast::DisabledValidation::kIgnoreAddressSpace)});
-
- EXPECT_TRUE(r()->Resolve());
-}
-
TEST_F(ResolverEntryPointValidationTest, PushConstantOneVariableUsedInEntryPoint) {
// enable chromium_experimental_push_constant;
// var<push_constant> a : u32;
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index c19cfe4..6608b5c 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -579,9 +579,7 @@
}
}
- if (!is_global && sem->AddressSpace() != core::AddressSpace::kFunction &&
- validator_.IsValidationEnabled(var->attributes,
- ast::DisabledValidation::kIgnoreAddressSpace)) {
+ if (!is_global && sem->AddressSpace() != core::AddressSpace::kFunction) {
AddError(var->source)
<< "function-scope 'var' declaration must use 'function' address space";
return nullptr;
diff --git a/src/tint/lang/wgsl/resolver/validator.cc b/src/tint/lang/wgsl/resolver/validator.cc
index b09d53c..33dcaa5 100644
--- a/src/tint/lang/wgsl/resolver/validator.cc
+++ b/src/tint/lang/wgsl/resolver/validator.cc
@@ -333,8 +333,7 @@
return false;
}
- return CheckTypeAccessAddressSpace(s->StoreType(), s->Access(), s->AddressSpace(), tint::Empty,
- a->source);
+ return CheckTypeAccessAddressSpace(s->StoreType(), s->Access(), s->AddressSpace(), a->source);
}
bool Validator::StorageTexture(const core::type::StorageTexture* t, const Source& source) const {
@@ -686,14 +685,11 @@
return Switch(
decl, //
[&](const ast::Var* var) {
- if (IsValidationEnabled(var->attributes,
- ast::DisabledValidation::kIgnoreAddressSpace)) {
- if (!local->Type()->UnwrapRef()->IsConstructible()) {
- AddError(var->type ? var->type->source : var->source)
- << "function-scope " << style::Keyword("var")
- << " must have a constructible type";
- return false;
- }
+ if (!local->Type()->UnwrapRef()->IsConstructible()) {
+ AddError(var->type ? var->type->source : var->source)
+ << "function-scope " << style::Keyword("var")
+ << " must have a constructible type";
+ return false;
}
return Var(local);
}, //
@@ -841,12 +837,11 @@
}
if (!CheckTypeAccessAddressSpace(v->Type()->UnwrapRef(), v->Access(), v->AddressSpace(),
- var->attributes, var->source)) {
+ var->source)) {
return false;
}
- if (IsValidationEnabled(var->attributes, ast::DisabledValidation::kIgnoreAddressSpace) &&
- (v->AddressSpace() == core::AddressSpace::kIn ||
+ if ((v->AddressSpace() == core::AddressSpace::kIn ||
v->AddressSpace() == core::AddressSpace::kOut)) {
AddError(var->source) << "invalid use of input/output address space";
return false;
@@ -908,29 +903,27 @@
}
if (auto* ref = var->Type()->As<core::type::Pointer>()) {
- if (IsValidationEnabled(decl->attributes, ast::DisabledValidation::kIgnoreAddressSpace)) {
- bool ok = false;
+ bool ok = false;
- auto sc = ref->AddressSpace();
- switch (sc) {
- case core::AddressSpace::kFunction:
- case core::AddressSpace::kPrivate:
- ok = true;
- break;
- case core::AddressSpace::kStorage:
- case core::AddressSpace::kUniform:
- case core::AddressSpace::kWorkgroup:
- ok = allowed_features_.features.count(
- wgsl::LanguageFeature::kUnrestrictedPointerParameters) != 0;
- break;
- default:
- break;
- }
- if (!ok) {
- AddError(decl->source) << "function parameter of pointer type cannot be in "
- << style::Enum(sc) << " address space";
- return false;
- }
+ auto sc = ref->AddressSpace();
+ switch (sc) {
+ case core::AddressSpace::kFunction:
+ case core::AddressSpace::kPrivate:
+ ok = true;
+ break;
+ case core::AddressSpace::kStorage:
+ case core::AddressSpace::kUniform:
+ case core::AddressSpace::kWorkgroup:
+ ok = allowed_features_.features.count(
+ wgsl::LanguageFeature::kUnrestrictedPointerParameters) != 0;
+ break;
+ default:
+ break;
+ }
+ if (!ok) {
+ AddError(decl->source) << "function parameter of pointer type cannot be in "
+ << style::Enum(sc) << " address space";
+ return false;
}
}
@@ -3073,7 +3066,6 @@
bool Validator::CheckTypeAccessAddressSpace(const core::type::Type* store_ty,
core::Access access,
core::AddressSpace address_space,
- VectorRef<const tint::ast::Attribute*> attributes,
const Source& source) const {
if (!AddressSpaceLayout(store_ty, address_space, source)) {
return false;
@@ -3104,9 +3096,7 @@
break;
case core::AddressSpace::kPushConstant:
if (DAWN_UNLIKELY(!enabled_extensions_.Contains(
- wgsl::Extension::kChromiumExperimentalPushConstant) &&
- IsValidationEnabled(attributes,
- ast::DisabledValidation::kIgnoreAddressSpace))) {
+ wgsl::Extension::kChromiumExperimentalPushConstant))) {
AddError(source) << "use of variable address space " << style::Enum("push_constant")
<< " requires enabling extension "
<< style::Code("chromium_experimental_push_constant");
diff --git a/src/tint/lang/wgsl/resolver/validator.h b/src/tint/lang/wgsl/resolver/validator.h
index 53e1603..d4c731b 100644
--- a/src/tint/lang/wgsl/resolver/validator.h
+++ b/src/tint/lang/wgsl/resolver/validator.h
@@ -650,7 +650,6 @@
bool CheckTypeAccessAddressSpace(const core::type::Type* store_ty,
core::Access access,
core::AddressSpace address_space,
- VectorRef<const tint::ast::Attribute*> attributes,
const Source& source) const;
/// Raises an error if the entry_point @p entry_point uses two or more module-scope 'var's with