mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-07 15:13:29 +00:00
tint: Fix phony assignments in DemoteToHelper
We just need to skip these. Bug: tint:1723 Change-Id: I311fe0432ecf1f69936eaf08eb57123a6a738175 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109340 Auto-Submit: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
97519c2cd3
commit
78ae4c243b
@ -114,6 +114,11 @@ Transform::ApplyResult DemoteToHelper::Apply(const Program* src, const DataMap&,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip phony assignments.
|
||||||
|
if (assign->lhs->Is<ast::PhonyExpression>()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip writes to invocation-private address spaces.
|
// Skip writes to invocation-private address spaces.
|
||||||
auto* ref = sem.Get(assign->lhs)->Type()->As<sem::Reference>();
|
auto* ref = sem.Get(assign->lhs)->Type()->As<sem::Reference>();
|
||||||
switch (ref->AddressSpace()) {
|
switch (ref->AddressSpace()) {
|
||||||
|
@ -1096,5 +1096,36 @@ fn foo(@location(0) in : f32, @location(1) coord : vec2<f32>) -> @location(0) i3
|
|||||||
EXPECT_EQ(expect, str(got));
|
EXPECT_EQ(expect, str(got));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DemoteToHelperTest, PhonyAssignment) {
|
||||||
|
auto* src = R"(
|
||||||
|
@fragment
|
||||||
|
fn foo(@location(0) in : f32) {
|
||||||
|
if (in == 0.0) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
_ = in;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto* expect = R"(
|
||||||
|
var<private> tint_discarded = false;
|
||||||
|
|
||||||
|
@fragment
|
||||||
|
fn foo(@location(0) in : f32) {
|
||||||
|
if ((in == 0.0)) {
|
||||||
|
tint_discarded = true;
|
||||||
|
}
|
||||||
|
_ = in;
|
||||||
|
if (tint_discarded) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto got = Run<DemoteToHelper>(src);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::transform
|
} // namespace tint::transform
|
||||||
|
Loading…
x
Reference in New Issue
Block a user