mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-08 04:59:08 +00:00
tint/uniformity: Violations are now errors
Switch the default severity for all uniformity violations to errors. We now have an opt-out mechanism for deriviative operations (via diagnostic filters), and a `workgroupUniformLoad()` builtin for compute shaders. Bug: tint:1809 Change-Id: I666c706d6195ca0d24ead14c4709e7f646bfcc64 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117741 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
f38ee3e073
commit
bb0229002d
@ -64,8 +64,7 @@ TEST_F(ParserTest, AllowNonUniformDerivatives_False) {
|
|||||||
options.allow_non_uniform_derivatives = false;
|
options.allow_non_uniform_derivatives = false;
|
||||||
auto program = Parse(spv, options);
|
auto program = Parse(spv, options);
|
||||||
auto errs = diag::Formatter().format(program.Diagnostics());
|
auto errs = diag::Formatter().format(program.Diagnostics());
|
||||||
// TODO(jrprice): This will become EXPECT_FALSE.
|
EXPECT_FALSE(program.IsValid()) << errs;
|
||||||
EXPECT_TRUE(program.IsValid()) << errs;
|
|
||||||
EXPECT_THAT(errs, ::testing::HasSubstr("'dpdx' must only be called from uniform control flow"));
|
EXPECT_THAT(errs, ::testing::HasSubstr("'dpdx' must only be called from uniform control flow"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,12 +146,10 @@ bool Resolver::Resolve() {
|
|||||||
// Run the uniformity analysis, which requires a complete semantic module.
|
// Run the uniformity analysis, which requires a complete semantic module.
|
||||||
if (!enabled_extensions_.Contains(ast::Extension::kChromiumDisableUniformityAnalysis)) {
|
if (!enabled_extensions_.Contains(ast::Extension::kChromiumDisableUniformityAnalysis)) {
|
||||||
if (!AnalyzeUniformity(builder_, dependencies_)) {
|
if (!AnalyzeUniformity(builder_, dependencies_)) {
|
||||||
if (kUniformityFailuresAsError) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class ProgramBuilder;
|
|||||||
namespace tint::resolver {
|
namespace tint::resolver {
|
||||||
|
|
||||||
/// If true, uniformity analysis failures will be treated as an error, else as a warning.
|
/// If true, uniformity analysis failures will be treated as an error, else as a warning.
|
||||||
constexpr bool kUniformityFailuresAsError = false;
|
constexpr bool kUniformityFailuresAsError = true;
|
||||||
|
|
||||||
/// Analyze the uniformity of a program.
|
/// Analyze the uniformity of a program.
|
||||||
/// @param builder the program to analyze
|
/// @param builder the program to analyze
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -169,7 +169,7 @@ Validator::Validator(
|
|||||||
valid_type_storage_layouts_(valid_type_storage_layouts) {
|
valid_type_storage_layouts_(valid_type_storage_layouts) {
|
||||||
// Set default severities for filterable diagnostic rules.
|
// Set default severities for filterable diagnostic rules.
|
||||||
diagnostic_filters_.Set(ast::DiagnosticRule::kDerivativeUniformity,
|
diagnostic_filters_.Set(ast::DiagnosticRule::kDerivativeUniformity,
|
||||||
ast::DiagnosticSeverity::kWarning);
|
ast::DiagnosticSeverity::kError);
|
||||||
diagnostic_filters_.Set(ast::DiagnosticRule::kChromiumUnreachableCode,
|
diagnostic_filters_.Set(ast::DiagnosticRule::kChromiumUnreachableCode,
|
||||||
ast::DiagnosticSeverity::kWarning);
|
ast::DiagnosticSeverity::kWarning);
|
||||||
}
|
}
|
||||||
|
@ -542,10 +542,10 @@ fn foo_discard(@location(0) in : f32, @location(1) coord : vec2<f32>) {
|
|||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn foo_no_discard(@location(0) in : f32, @location(1) coord : vec2<f32>) {
|
fn foo_no_discard(@location(0) in : f32, @location(1) coord : vec2<f32>) {
|
||||||
|
let ret = bar_no_discard(in, coord);
|
||||||
if (in == 0.0) {
|
if (in == 0.0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let ret = bar_no_discard(in, coord);
|
|
||||||
v2 = ret;
|
v2 = ret;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -591,10 +591,10 @@ fn foo_discard(@location(0) in : f32, @location(1) coord : vec2<f32>) {
|
|||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn foo_no_discard(@location(0) in : f32, @location(1) coord : vec2<f32>) {
|
fn foo_no_discard(@location(0) in : f32, @location(1) coord : vec2<f32>) {
|
||||||
|
let ret = bar_no_discard(in, coord);
|
||||||
if ((in == 0.0)) {
|
if ((in == 0.0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let ret = bar_no_discard(in, coord);
|
|
||||||
v2 = ret;
|
v2 = ret;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -992,8 +992,9 @@ fn foo(@location(0) in : f32, @location(1) coord : vec2<f32>) -> @location(0) i3
|
|||||||
}
|
}
|
||||||
var result = 0;
|
var result = 0;
|
||||||
for (var i = 0; i < 10; i = atomicAdd(&a, 1)) {
|
for (var i = 0; i < 10; i = atomicAdd(&a, 1)) {
|
||||||
result += i32(textureSample(t, s, coord).x);
|
result += i;
|
||||||
}
|
}
|
||||||
|
result += i32(textureSample(t, s, coord).x);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -1020,7 +1021,7 @@ fn foo(@location(0) in : f32, @location(1) coord : vec2<f32>) -> @location(0) i3
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
result += i32(textureSample(t, s, coord).x);
|
result += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
continuing {
|
continuing {
|
||||||
@ -1032,6 +1033,7 @@ fn foo(@location(0) in : f32, @location(1) coord : vec2<f32>) -> @location(0) i3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result += i32(textureSample(t, s, coord).x);
|
||||||
if (tint_discarded) {
|
if (tint_discarded) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
@ -1060,8 +1062,9 @@ fn foo(@location(0) in : f32, @location(1) coord : vec2<f32>) -> @location(0) i3
|
|||||||
var result = 0;
|
var result = 0;
|
||||||
if (!atomicCompareExchangeWeak(&a, i32(in), 42).exchanged) {
|
if (!atomicCompareExchangeWeak(&a, i32(in), 42).exchanged) {
|
||||||
let xchg = atomicCompareExchangeWeak(&a, i32(in), 42);
|
let xchg = atomicCompareExchangeWeak(&a, i32(in), 42);
|
||||||
result = i32(textureSample(t, s, coord).x) * xchg.old_value;
|
result = xchg.old_value;
|
||||||
}
|
}
|
||||||
|
result += i32(textureSample(t, s, coord).x);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -1100,8 +1103,9 @@ fn foo(@location(0) in : f32, @location(1) coord : vec2<f32>) -> @location(0) i3
|
|||||||
tint_symbol_3.exchanged = tint_symbol_4.exchanged;
|
tint_symbol_3.exchanged = tint_symbol_4.exchanged;
|
||||||
}
|
}
|
||||||
let xchg = tint_symbol_3;
|
let xchg = tint_symbol_3;
|
||||||
result = (i32(textureSample(t, s, coord).x) * xchg.old_value);
|
result = xchg.old_value;
|
||||||
}
|
}
|
||||||
|
result += i32(textureSample(t, s, coord).x);
|
||||||
if (tint_discarded) {
|
if (tint_discarded) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user