tint/SingleEntryPoint: Handle diagnostic directive

Add some E2E tests to make sure that we actually produce valid code
for each backend when diagnostic filtering is present.

Bug: tint:1809
Change-Id: I5e903ac0d2ca385967211bb889f86cb85de8f418
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117590
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
James Price
2023-01-26 11:31:19 +00:00
committed by Dawn LUCI CQ
parent 1226320a5b
commit 2dbb7b4f6a
16 changed files with 433 additions and 0 deletions

View File

@@ -114,6 +114,7 @@ Transform::ApplyResult SingleEntryPoint::Apply(const Program* src,
}
},
[&](const ast::Enable* ext) { b.AST().AddEnable(ctx.Clone(ext)); },
[&](const ast::DiagnosticControl* dc) { b.AST().AddDiagnosticControl(ctx.Clone(dc)); },
[&](Default) {
TINT_UNREACHABLE(Transform, b.Diagnostics())
<< "unhandled global declaration: " << decl->TypeInfo().name;

View File

@@ -611,5 +611,25 @@ fn main() {
EXPECT_EQ(expect, str(got));
}
TEST_F(SingleEntryPointTest, Directives) {
// Make sure that directives are preserved.
auto* src = R"(
enable f16;
diagnostic(off, derivative_uniformity);
@compute @workgroup_size(1)
fn main() {
}
)";
SingleEntryPoint::Config cfg("main");
DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
EXPECT_EQ(src, str(got));
}
} // namespace
} // namespace tint::transform