mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 19:01:24 +00:00
validation: Require [[location]] for [[interpolate]]
The spec now has this requirement: https://github.com/gpuweb/gpuweb/pull/2251 Fixed: tint:982 Change-Id: I5ac7fdba336116bbcd0d805ba8b52ddab505df55 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68921 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
1310e68091
commit
a660b510ac
@ -276,7 +276,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
TestParams{DecorationKind::kBinding, false},
|
TestParams{DecorationKind::kBinding, false},
|
||||||
TestParams{DecorationKind::kBuiltin, true},
|
TestParams{DecorationKind::kBuiltin, true},
|
||||||
TestParams{DecorationKind::kGroup, false},
|
TestParams{DecorationKind::kGroup, false},
|
||||||
TestParams{DecorationKind::kInterpolate, true},
|
// kInterpolate tested separately (requires [[location]])
|
||||||
TestParams{DecorationKind::kInvariant, true},
|
TestParams{DecorationKind::kInvariant, true},
|
||||||
TestParams{DecorationKind::kLocation, true},
|
TestParams{DecorationKind::kLocation, true},
|
||||||
TestParams{DecorationKind::kOverride, false},
|
TestParams{DecorationKind::kOverride, false},
|
||||||
@ -470,7 +470,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
TestParams{DecorationKind::kBinding, false},
|
TestParams{DecorationKind::kBinding, false},
|
||||||
TestParams{DecorationKind::kBuiltin, true},
|
TestParams{DecorationKind::kBuiltin, true},
|
||||||
TestParams{DecorationKind::kGroup, false},
|
TestParams{DecorationKind::kGroup, false},
|
||||||
TestParams{DecorationKind::kInterpolate, true},
|
// kInterpolate tested separately (requires [[location]])
|
||||||
TestParams{DecorationKind::kInvariant, true},
|
TestParams{DecorationKind::kInvariant, true},
|
||||||
TestParams{DecorationKind::kLocation, false},
|
TestParams{DecorationKind::kLocation, false},
|
||||||
TestParams{DecorationKind::kOverride, false},
|
TestParams{DecorationKind::kOverride, false},
|
||||||
@ -618,7 +618,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
TestParams{DecorationKind::kBinding, false},
|
TestParams{DecorationKind::kBinding, false},
|
||||||
TestParams{DecorationKind::kBuiltin, true},
|
TestParams{DecorationKind::kBuiltin, true},
|
||||||
TestParams{DecorationKind::kGroup, false},
|
TestParams{DecorationKind::kGroup, false},
|
||||||
TestParams{DecorationKind::kInterpolate, true},
|
// kInterpolate tested separately (requires [[location]])
|
||||||
// kInvariant tested separately (requires position builtin)
|
// kInvariant tested separately (requires position builtin)
|
||||||
TestParams{DecorationKind::kLocation, true},
|
TestParams{DecorationKind::kLocation, true},
|
||||||
TestParams{DecorationKind::kOverride, false},
|
TestParams{DecorationKind::kOverride, false},
|
||||||
@ -1392,6 +1392,47 @@ TEST_F(InterpolateTest, VertexOutput_Integer_MissingFlatInterpolation) {
|
|||||||
"flat interpolation attribute");
|
"flat interpolation attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(InterpolateTest, MissingLocationAttribute_Parameter) {
|
||||||
|
Func("main",
|
||||||
|
ast::VariableList{
|
||||||
|
Param("a", ty.vec4<f32>(),
|
||||||
|
{Builtin(ast::Builtin::kPosition),
|
||||||
|
Interpolate(Source{{12, 34}}, ast::InterpolationType::kFlat,
|
||||||
|
ast::InterpolationSampling::kNone)})},
|
||||||
|
ty.void_(), {},
|
||||||
|
ast::DecorationList{Stage(ast::PipelineStage::kFragment)});
|
||||||
|
|
||||||
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
EXPECT_EQ(r()->error(),
|
||||||
|
"12:34 error: interpolate attribute must only be used with "
|
||||||
|
"[[location]]");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(InterpolateTest, MissingLocationAttribute_ReturnType) {
|
||||||
|
Func("main", {}, ty.vec4<f32>(), {Return(Construct(ty.vec4<f32>()))},
|
||||||
|
ast::DecorationList{Stage(ast::PipelineStage::kVertex)},
|
||||||
|
{Builtin(ast::Builtin::kPosition),
|
||||||
|
Interpolate(Source{{12, 34}}, ast::InterpolationType::kFlat,
|
||||||
|
ast::InterpolationSampling::kNone)});
|
||||||
|
|
||||||
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
EXPECT_EQ(r()->error(),
|
||||||
|
"12:34 error: interpolate attribute must only be used with "
|
||||||
|
"[[location]]");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(InterpolateTest, MissingLocationAttribute_Struct) {
|
||||||
|
Structure(
|
||||||
|
"S", {Member("a", ty.f32(),
|
||||||
|
{Interpolate(Source{{12, 34}}, ast::InterpolationType::kFlat,
|
||||||
|
ast::InterpolationSampling::kNone)})});
|
||||||
|
|
||||||
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
EXPECT_EQ(r()->error(),
|
||||||
|
"12:34 error: interpolate attribute must only be used with "
|
||||||
|
"[[location]]");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace InterpolateTests
|
} // namespace InterpolateTests
|
||||||
|
|
||||||
|
@ -1158,6 +1158,15 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (interpolate_attribute) {
|
||||||
|
if (!pipeline_io_attribute ||
|
||||||
|
!pipeline_io_attribute->Is<ast::LocationDecoration>()) {
|
||||||
|
AddError("interpolate attribute must only be used with [[location]]",
|
||||||
|
interpolate_attribute->source);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (invariant_attribute) {
|
if (invariant_attribute) {
|
||||||
bool has_position = false;
|
bool has_position = false;
|
||||||
if (pipeline_io_attribute) {
|
if (pipeline_io_attribute) {
|
||||||
@ -1927,8 +1936,10 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto has_location = false;
|
||||||
auto has_position = false;
|
auto has_position = false;
|
||||||
const ast::InvariantDecoration* invariant_attribute = nullptr;
|
const ast::InvariantDecoration* invariant_attribute = nullptr;
|
||||||
|
const ast::InterpolateDecoration* interpolate_attribute = nullptr;
|
||||||
for (auto* deco : member->Declaration()->decorations) {
|
for (auto* deco : member->Declaration()->decorations) {
|
||||||
if (!deco->IsAnyOf<ast::BuiltinDecoration, //
|
if (!deco->IsAnyOf<ast::BuiltinDecoration, //
|
||||||
ast::InternalDecoration, //
|
ast::InternalDecoration, //
|
||||||
@ -1951,6 +1962,7 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
|
|||||||
if (auto* invariant = deco->As<ast::InvariantDecoration>()) {
|
if (auto* invariant = deco->As<ast::InvariantDecoration>()) {
|
||||||
invariant_attribute = invariant;
|
invariant_attribute = invariant;
|
||||||
} else if (auto* location = deco->As<ast::LocationDecoration>()) {
|
} else if (auto* location = deco->As<ast::LocationDecoration>()) {
|
||||||
|
has_location = true;
|
||||||
if (!ValidateLocationDecoration(location, member->Type(), locations,
|
if (!ValidateLocationDecoration(location, member->Type(), locations,
|
||||||
member->Declaration()->source)) {
|
member->Declaration()->source)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1964,6 +1976,7 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
|
|||||||
has_position = true;
|
has_position = true;
|
||||||
}
|
}
|
||||||
} else if (auto* interpolate = deco->As<ast::InterpolateDecoration>()) {
|
} else if (auto* interpolate = deco->As<ast::InterpolateDecoration>()) {
|
||||||
|
interpolate_attribute = interpolate;
|
||||||
if (!ValidateInterpolateDecoration(interpolate, member->Type())) {
|
if (!ValidateInterpolateDecoration(interpolate, member->Type())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1976,6 +1989,12 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (interpolate_attribute && !has_location) {
|
||||||
|
AddError("interpolate attribute must only be used with [[location]]",
|
||||||
|
interpolate_attribute->source);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (auto* member_struct_type = member->Type()->As<sem::Struct>()) {
|
if (auto* member_struct_type = member->Type()->As<sem::Struct>()) {
|
||||||
if (auto* member_struct_type_block_decoration =
|
if (auto* member_struct_type_block_decoration =
|
||||||
ast::GetDecoration<ast::StructBlockDecoration>(
|
ast::GetDecoration<ast::StructBlockDecoration>(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user