[wgsl] Remove handling of IO attributes on global variables
This was only needed to support code generated by AST transforms in
the SPIR-V and GLSL backends.
Change-Id: Ic2ab24cf68e84f8f7af2c5dace68a17dcdaf68d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/236088
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index 6608b5c..71c3d08 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -610,9 +610,6 @@
}
if (is_global) {
- bool has_io_address_space = sem->AddressSpace() == core::AddressSpace::kIn ||
- sem->AddressSpace() == core::AddressSpace::kOut;
-
std::optional<uint32_t> group, binding, input_attachment_index;
for (auto* attribute : var->attributes) {
Mark(attribute);
@@ -643,57 +640,6 @@
input_attachment_index = value.Get();
return kSuccess;
},
- [&](const ast::LocationAttribute* attr) {
- if (!has_io_address_space) {
- return kInvalid;
- }
- auto value = LocationAttribute(attr);
- if (value != Success) {
- return kErrored;
- }
- global->Attributes().location = value.Get();
- return kSuccess;
- },
- [&](const ast::BlendSrcAttribute* attr) {
- if (!has_io_address_space) {
- return kInvalid;
- }
- auto value = BlendSrcAttribute(attr);
- if (value != Success) {
- return kErrored;
- }
- global->Attributes().blend_src = value.Get();
- return kSuccess;
- },
- [&](const ast::ColorAttribute* attr) {
- if (!has_io_address_space) {
- return kInvalid;
- }
- auto value = ColorAttribute(attr);
- if (value != Success) {
- return kErrored;
- }
- global->Attributes().color = value.Get();
- return kSuccess;
- },
- [&](const ast::BuiltinAttribute*) {
- if (!has_io_address_space) {
- return kInvalid;
- }
- return kSuccess;
- },
- [&](const ast::InterpolateAttribute*) {
- if (!has_io_address_space) {
- return kInvalid;
- }
- return kSuccess;
- },
- [&](const ast::InvariantAttribute* attr) {
- if (!has_io_address_space) {
- return kInvalid;
- }
- return InvariantAttribute(attr) ? kSuccess : kErrored;
- },
[&](const ast::InternalAttribute* attr) {
return InternalAttribute(attr) ? kSuccess : kErrored;
},
diff --git a/src/tint/lang/wgsl/resolver/validator.cc b/src/tint/lang/wgsl/resolver/validator.cc
index 33dcaa5..eaa3576 100644
--- a/src/tint/lang/wgsl/resolver/validator.cc
+++ b/src/tint/lang/wgsl/resolver/validator.cc
@@ -1505,22 +1505,9 @@
if (decl->PipelineStage() == ast::PipelineStage::kVertex &&
!builtins.Contains(core::BuiltinValue::kPosition)) {
- // Check module-scope variables, as the SPIR-V sanitizer generates these.
- bool found = false;
- for (auto* global : func->TransitivelyReferencedGlobals()) {
- if (auto* builtin_attr =
- ast::GetAttribute<ast::BuiltinAttribute>(global->Declaration()->attributes)) {
- if (builtin_attr->builtin == core::BuiltinValue::kPosition) {
- found = true;
- break;
- }
- }
- }
- if (!found) {
- AddError(decl->source) << "a vertex shader must include the " << style::Enum("position")
- << " builtin in its return type";
- return false;
- }
+ AddError(decl->source) << "a vertex shader must include the " << style::Enum("position")
+ << " builtin in its return type";
+ return false;
}
if (decl->PipelineStage() == ast::PipelineStage::kCompute) {
diff --git a/src/tint/lang/wgsl/sem/variable.h b/src/tint/lang/wgsl/sem/variable.h
index 5f8a3d0..b5c845f 100644
--- a/src/tint/lang/wgsl/sem/variable.h
+++ b/src/tint/lang/wgsl/sem/variable.h
@@ -157,18 +157,6 @@
std::optional<tint::OverrideId> override_id;
/// the resource binding point for the variable, if set.
std::optional<tint::BindingPoint> binding_point;
- /// The `location` attribute value for the variable, if set
- /// @note a GlobalVariable generally doesn't have a `location` in WGSL, as it isn't allowed by
- /// the spec. The location maybe attached by transforms such as CanonicalizeEntryPointIO.
- std::optional<uint32_t> location;
- /// The `blend_src` attribute value for the variable, if set
- /// @note a GlobalVariable generally doesn't have a `blend_src` in WGSL, as it isn't allowed by
- /// the spec. The location maybe attached by transforms such as CanonicalizeEntryPointIO.
- std::optional<uint32_t> blend_src;
- /// The `color` attribute value for the variable, if set
- /// @note a GlobalVariable generally doesn't have a `color` in WGSL, as it isn't allowed by
- /// the spec. The location maybe attached by transforms such as CanonicalizeEntryPointIO.
- std::optional<uint32_t> color;
/// The `input_attachment_index` attribute value for the variable, if set
std::optional<uint32_t> input_attachment_index;
};