tint/uniformity: filter should not affect result

A derivative_uniformity diagnostic filter should not affect the
uniformity of the return value of a derivative builtin.

Fixed: tint:1815
Change-Id: I58e714978dab747598af5136dc9808a5a658c60e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118001
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
James Price 2023-02-02 00:29:27 +00:00 committed by Dawn LUCI CQ
parent d9f659670d
commit 072f83c682
2 changed files with 35 additions and 1 deletions

View File

@ -1512,8 +1512,8 @@ class UniformityGraph {
sem_.DiagnosticSeverity(call, ast::DiagnosticRule::kDerivativeUniformity);
if (severity != ast::DiagnosticSeverity::kOff) {
callsite_tag = {CallSiteTag::CallSiteRequiredToBeUniform, severity};
function_tag = ReturnValueMayBeNonUniform;
}
function_tag = ReturnValueMayBeNonUniform;
} else if (builtin->IsAtomic()) {
callsite_tag = {CallSiteTag::CallSiteNoRestriction};
function_tag = ReturnValueMayBeNonUniform;

View File

@ -8132,6 +8132,40 @@ test:35:7 note: reading from read_write storage buffer 'non_uniform' may result
)");
}
TEST_F(UniformityAnalysisDiagnosticFilterTest, BuiltinReturnValueNotAffected) {
// Make sure that a diagnostic filter does not affect the uniformity of the return value of a
// derivative builtin.
std::string src = R"(
fn foo() {
var x: f32;
@diagnostic(off,derivative_uniformity) {
x = dpdx(1.0);
}
if (x < 0.5) {
_ = dpdy(1.0); // Should trigger an error
}
}
)";
RunTest(src, false);
EXPECT_EQ(error_,
R"(test:10:9 error: 'dpdy' must only be called from uniform control flow
_ = dpdy(1.0); // Should trigger an error
^^^^
test:9:3 note: control flow depends on possibly non-uniform value
if (x < 0.5) {
^^
test:6:9 note: return value of 'dpdx' may be non-uniform
x = dpdx(1.0);
^^^^
)");
}
TEST_F(UniformityAnalysisDiagnosticFilterTest, BarriersNotAffected) {
// Make sure that the diagnostic filter does not affect barriers.
std::string src = R"(