mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 15:16:16 +00:00
validation: Require interpolate(flat) for integers
This was made a warning in M97, and can now become a hard error. Fixed: tint:1224 Change-Id: Ied72f6e28b3dc64a6ab832e0eac53f62ce045d40 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77700 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com> Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
d5560400a3
commit
1c02eb8cb0
@@ -1332,11 +1332,10 @@ TEST_F(InterpolateTest, FragmentInput_Integer_MissingFlatInterpolation) {
|
||||
ty.void_(), {},
|
||||
ast::DecorationList{Stage(ast::PipelineStage::kFragment)});
|
||||
|
||||
// TODO(crbug.com/tint/1224): Make this an error.
|
||||
EXPECT_TRUE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 warning: integral user-defined fragment inputs must have a "
|
||||
"flat interpolation attribute");
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: integral user-defined fragment inputs must have a flat interpolation attribute)");
|
||||
}
|
||||
|
||||
TEST_F(InterpolateTest, VertexOutput_Integer_MissingFlatInterpolation) {
|
||||
@@ -1350,11 +1349,11 @@ TEST_F(InterpolateTest, VertexOutput_Integer_MissingFlatInterpolation) {
|
||||
Func("main", {}, ty.Of(s), {Return(Construct(ty.Of(s)))},
|
||||
ast::DecorationList{Stage(ast::PipelineStage::kVertex)});
|
||||
|
||||
// TODO(crbug.com/tint/1224): Make this an error.
|
||||
EXPECT_TRUE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 warning: integral user-defined vertex outputs must have a "
|
||||
"flat interpolation attribute");
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: integral user-defined vertex outputs must have a flat interpolation attribute
|
||||
note: while analysing entry point 'main')");
|
||||
}
|
||||
|
||||
TEST_F(InterpolateTest, MissingLocationAttribute_Parameter) {
|
||||
|
||||
@@ -371,9 +371,9 @@ static constexpr Params cases[] = {
|
||||
|
||||
TEST_P(TypeValidationTest, BareInputs) {
|
||||
// @stage(fragment)
|
||||
// fn main(@location(0) a : *) {}
|
||||
// fn main(@location(0) @interpolate(flat) a : *) {}
|
||||
auto params = GetParam();
|
||||
auto* a = Param("a", params.create_ast_type(*this), {Location(0)});
|
||||
auto* a = Param("a", params.create_ast_type(*this), {Location(0), Flat()});
|
||||
Func(Source{{12, 34}}, "main", {a}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
|
||||
@@ -386,13 +386,13 @@ TEST_P(TypeValidationTest, BareInputs) {
|
||||
|
||||
TEST_P(TypeValidationTest, StructInputs) {
|
||||
// struct Input {
|
||||
// @location(0) a : *;
|
||||
// @location(0) @interpolate(flat) a : *;
|
||||
// };
|
||||
// @stage(fragment)
|
||||
// fn main(a : Input) {}
|
||||
auto params = GetParam();
|
||||
auto* input = Structure(
|
||||
"Input", {Member("a", params.create_ast_type(*this), {Location(0)})});
|
||||
auto* input = Structure("Input", {Member("a", params.create_ast_type(*this),
|
||||
{Location(0), Flat()})});
|
||||
auto* a = Param("a", ty.Of(input), {});
|
||||
Func(Source{{12, 34}}, "main", {a}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
@@ -454,9 +454,9 @@ using LocationDecorationTests = ResolverTest;
|
||||
|
||||
TEST_F(LocationDecorationTests, Pass) {
|
||||
// @stage(fragment)
|
||||
// fn frag_main(@location(0) a: i32) {}
|
||||
// fn frag_main(@location(0) @interpolate(flat) a: i32) {}
|
||||
|
||||
auto* p = Param(Source{{12, 34}}, "a", ty.i32(), {Location(0)});
|
||||
auto* p = Param(Source{{12, 34}}, "a", ty.i32(), {Location(0), Flat()});
|
||||
Func("frag_main", {p}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
|
||||
|
||||
@@ -1055,21 +1055,21 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
||||
if (pipeline_io_attribute &&
|
||||
pipeline_io_attribute->Is<ast::LocationDecoration>()) {
|
||||
if (ty->is_integer_scalar_or_vector() && !interpolate_attribute) {
|
||||
// TODO(crbug.com/tint/1224): Make these errors once downstream
|
||||
// usages have caught up (no sooner than M99).
|
||||
if (decl->PipelineStage() == ast::PipelineStage::kVertex &&
|
||||
param_or_ret == ParamOrRetType::kReturnType) {
|
||||
AddWarning(
|
||||
AddError(
|
||||
"integral user-defined vertex outputs must have a flat "
|
||||
"interpolation attribute",
|
||||
source);
|
||||
return false;
|
||||
}
|
||||
if (decl->PipelineStage() == ast::PipelineStage::kFragment &&
|
||||
param_or_ret == ParamOrRetType::kParameter) {
|
||||
AddWarning(
|
||||
AddError(
|
||||
"integral user-defined fragment inputs must have a flat "
|
||||
"interpolation attribute",
|
||||
source);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user