[wgsl] Remove kEntryPointParameter validation override
This is no longer used by any AST transforms.
Change-Id: Ic4eb2efd83b10e02c1e53e77cf005c27f03a45ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/236080
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 59f1ad2..2cec814 100644
--- a/src/tint/lang/wgsl/ast/disable_validation_attribute.cc
+++ b/src/tint/lang/wgsl/ast/disable_validation_attribute.cc
@@ -48,8 +48,6 @@
return "disable_validation__binding_point_collision";
case DisabledValidation::kIgnoreAddressSpace:
return "disable_validation__ignore_address_space";
- case DisabledValidation::kEntryPointParameter:
- return "disable_validation__entry_point_parameter";
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 c6127bc..77ef54f 100644
--- a/src/tint/lang/wgsl/ast/disable_validation_attribute.h
+++ b/src/tint/lang/wgsl/ast/disable_validation_attribute.h
@@ -45,9 +45,6 @@
/// When applied to a variable, the validator will not complain about the declared address
/// space.
kIgnoreAddressSpace,
- /// When applied to an entry-point function parameter, the validator will not check for entry IO
- /// attributes.
- kEntryPointParameter,
/// 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/attribute_validation_test.cc b/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
index 99a3a62..16cd0f8 100644
--- a/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
+++ b/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
@@ -1284,36 +1284,6 @@
1:2 note: first attribute declared here)",
}));
-using EntryPointParameterAttributeTest = TestWithParams;
-TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) {
- auto* s = Param("s", ty.sampler(core::type::SamplerKind::kSampler),
- Vector{
- Binding(0_a),
- Group(0_a),
- Disable(ast::DisabledValidation::kBindingPointCollision),
- Disable(ast::DisabledValidation::kEntryPointParameter),
- });
- Func("f", Vector{s}, ty.void_(), tint::Empty,
- Vector{
- Stage(ast::PipelineStage::kFragment),
- });
-
- EXPECT_TRUE(r()->Resolve()) << r()->error();
-}
-
-using EntryPointReturnTypeAttributeTest = ResolverTest;
-TEST_F(EntryPointReturnTypeAttributeTest, DuplicateInternalAttribute) {
- Func("f", tint::Empty, ty.i32(), Vector{Return(1_i)},
- Vector{
- Stage(ast::PipelineStage::kFragment),
- },
- Vector{
- Disable(ast::DisabledValidation::kBindingPointCollision),
- Disable(ast::DisabledValidation::kEntryPointParameter),
- });
-
- EXPECT_TRUE(r()->Resolve()) << r()->error();
-}
} // namespace EntryPointInputAndOutputTests
namespace StructAndStructMemberTests {
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index e7f3631..9abd981 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -782,32 +782,6 @@
},
[&](const ast::InterpolateAttribute*) { return true; },
[&](const ast::InternalAttribute* attr) -> bool { return InternalAttribute(attr); },
- [&](const ast::GroupAttribute* attr) {
- if (validator_.IsValidationEnabled(
- param->attributes, ast::DisabledValidation::kEntryPointParameter)) {
- ErrorInvalidAttribute(attribute, StyledText{} << "function parameters");
- return false;
- }
- auto value = GroupAttribute(attr);
- if (DAWN_UNLIKELY(value != Success)) {
- return false;
- }
- group = value.Get();
- return true;
- },
- [&](const ast::BindingAttribute* attr) -> bool {
- if (validator_.IsValidationEnabled(
- param->attributes, ast::DisabledValidation::kEntryPointParameter)) {
- ErrorInvalidAttribute(attribute, StyledText{} << "function parameters");
- return false;
- }
- auto value = BindingAttribute(attr);
- if (DAWN_UNLIKELY(value != Success)) {
- return false;
- }
- binding = value.Get();
- return true;
- },
[&](Default) {
ErrorInvalidAttribute(attribute, StyledText{} << "function parameters");
return false;
@@ -1089,9 +1063,7 @@
if (decl->IsEntryPoint()) {
// Determine if the return type has a location
bool permissive = validator_.IsValidationDisabled(
- decl->attributes, ast::DisabledValidation::kEntryPointParameter) ||
- validator_.IsValidationDisabled(
- decl->attributes, ast::DisabledValidation::kFunctionParameter);
+ decl->attributes, ast::DisabledValidation::kFunctionParameter);
for (auto* attribute : decl->return_type_attributes) {
Mark(attribute);
enum Status { kSuccess, kErrored, kInvalid };
diff --git a/src/tint/lang/wgsl/resolver/validator.cc b/src/tint/lang/wgsl/resolver/validator.cc
index 48934d3..15fca0d 100644
--- a/src/tint/lang/wgsl/resolver/validator.cc
+++ b/src/tint/lang/wgsl/resolver/validator.cc
@@ -1373,92 +1373,88 @@
}
}
- if (IsValidationEnabled(attrs, ast::DisabledValidation::kEntryPointParameter)) {
- if (is_struct_member && ty->Is<core::type::Struct>()) {
- AddError(source) << "nested structures cannot be used for entry point IO";
- return false;
- }
+ if (is_struct_member && ty->Is<core::type::Struct>()) {
+ AddError(source) << "nested structures cannot be used for entry point IO";
+ return false;
+ }
- if (!ty->Is<core::type::Struct>() && !pipeline_io_attribute) {
- auto& err = AddError(source) << "missing entry point IO attribute";
- if (!is_struct_member) {
- err << (param_or_ret == ParamOrRetType::kParameter ? " on parameter"
- : " on return type");
- }
- return false;
+ if (!ty->Is<core::type::Struct>() && !pipeline_io_attribute) {
+ auto& err = AddError(source) << "missing entry point IO attribute";
+ if (!is_struct_member) {
+ err << (param_or_ret == ParamOrRetType::kParameter ? " on parameter"
+ : " on return type");
}
+ return false;
+ }
- if (pipeline_io_attribute && pipeline_io_attribute->Is<ast::LocationAttribute>()) {
- if (ty->IsIntegerScalarOrVector() && !interpolate_attribute) {
- if (decl->PipelineStage() == ast::PipelineStage::kVertex &&
- param_or_ret == ParamOrRetType::kReturnType) {
- AddError(source)
- << "integral user-defined vertex outputs must have a "
- << style::Attribute("@interpolate")
- << style::Code("(", style::Enum("flat"), ")") << " attribute";
- return false;
- }
- if (decl->PipelineStage() == ast::PipelineStage::kFragment &&
- param_or_ret == ParamOrRetType::kParameter) {
- AddError(source)
- << "integral user-defined fragment inputs must have a "
- << style::Attribute("@interpolate")
- << style::Code("(", style::Enum("flat"), ")") << " attribute";
- return false;
- }
- }
- }
-
- if (location_attribute) {
- std::pair<uint32_t, uint32_t> location_and_blend_src(location.value(),
- blend_src.value_or(0));
- if (!locations_and_blend_srcs.Add(location_and_blend_src)) {
- auto& err = AddError(location_attribute->source)
- << style::Attribute("@location")
- << style::Code("(", style::Literal(location.value()), ")");
- if (blend_src_attribute) {
- err << style::Attribute(" @blend_src")
- << style::Code("(", style::Literal(blend_src.value()), ")");
- }
- err << " appears multiple times";
+ if (pipeline_io_attribute && pipeline_io_attribute->Is<ast::LocationAttribute>()) {
+ if (ty->IsIntegerScalarOrVector() && !interpolate_attribute) {
+ if (decl->PipelineStage() == ast::PipelineStage::kVertex &&
+ param_or_ret == ParamOrRetType::kReturnType) {
+ AddError(source) << "integral user-defined vertex outputs must have a "
+ << style::Attribute("@interpolate")
+ << style::Code("(", style::Enum("flat"), ")") << " attribute";
return false;
}
- }
-
- if (color_attribute && !colors.Add(color.value())) {
- AddError(color_attribute->source)
- << style::Attribute("@color")
- << style::Code("(", style::Literal(color.value()), ")")
- << " appears multiple times";
- return false;
- }
-
- if (interpolate_attribute) {
- if (!pipeline_io_attribute ||
- !pipeline_io_attribute->Is<ast::LocationAttribute>()) {
- AddError(interpolate_attribute->source)
- << style::Attribute("@interpolate") << " can only be used with "
- << style::Attribute("@location");
- return false;
- }
- }
-
- if (invariant_attribute) {
- bool has_position = false;
- if (pipeline_io_attribute) {
- if (auto* builtin_attr = pipeline_io_attribute->As<ast::BuiltinAttribute>()) {
- has_position = (builtin_attr->builtin == core::BuiltinValue::kPosition);
- }
- }
- if (!has_position) {
- AddError(invariant_attribute->source)
- << style::Attribute("@invariant") << " must be applied to a "
- << style::Attribute("@builtin")
- << style::Code("(", style::Enum("position"), ")");
+ if (decl->PipelineStage() == ast::PipelineStage::kFragment &&
+ param_or_ret == ParamOrRetType::kParameter) {
+ AddError(source) << "integral user-defined fragment inputs must have a "
+ << style::Attribute("@interpolate")
+ << style::Code("(", style::Enum("flat"), ")") << " attribute";
return false;
}
}
}
+
+ if (location_attribute) {
+ std::pair<uint32_t, uint32_t> location_and_blend_src(location.value(),
+ blend_src.value_or(0));
+ if (!locations_and_blend_srcs.Add(location_and_blend_src)) {
+ auto& err = AddError(location_attribute->source)
+ << style::Attribute("@location")
+ << style::Code("(", style::Literal(location.value()), ")");
+ if (blend_src_attribute) {
+ err << style::Attribute(" @blend_src")
+ << style::Code("(", style::Literal(blend_src.value()), ")");
+ }
+ err << " appears multiple times";
+ return false;
+ }
+ }
+
+ if (color_attribute && !colors.Add(color.value())) {
+ AddError(color_attribute->source)
+ << style::Attribute("@color")
+ << style::Code("(", style::Literal(color.value()), ")")
+ << " appears multiple times";
+ return false;
+ }
+
+ if (interpolate_attribute) {
+ if (!pipeline_io_attribute || !pipeline_io_attribute->Is<ast::LocationAttribute>()) {
+ AddError(interpolate_attribute->source)
+ << style::Attribute("@interpolate") << " can only be used with "
+ << style::Attribute("@location");
+ return false;
+ }
+ }
+
+ if (invariant_attribute) {
+ bool has_position = false;
+ if (pipeline_io_attribute) {
+ if (auto* builtin_attr = pipeline_io_attribute->As<ast::BuiltinAttribute>()) {
+ has_position = (builtin_attr->builtin == core::BuiltinValue::kPosition);
+ }
+ }
+ if (!has_position) {
+ AddError(invariant_attribute->source)
+ << style::Attribute("@invariant") << " must be applied to a "
+ << style::Attribute("@builtin")
+ << style::Code("(", style::Enum("position"), ")");
+ return false;
+ }
+ }
+
return true;
};