mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-06 21:25:58 +00:00
tint/uniformity: Fix struct member partial pointers
This assertion was mistakenly changed to only allow index accessors when the ast::AccessorExpression base class was added. Bug: chromium:1420257 Change-Id: Ic2b695dd7605c8852ab6d822602dca5d28ecf2d4 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122103 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
b7c2aed189
commit
7c21fe5d92
@ -1353,14 +1353,14 @@ class UniformityGraph {
|
|||||||
// To determine if we're dereferencing a partial pointer, unwrap *&
|
// To determine if we're dereferencing a partial pointer, unwrap *&
|
||||||
// chains; if the final expression is an identifier, see if it's a
|
// chains; if the final expression is an identifier, see if it's a
|
||||||
// partial pointer. If it's not an identifier, then it must be an
|
// partial pointer. If it's not an identifier, then it must be an
|
||||||
// index/accessor expression, and thus a partial pointer.
|
// index/member accessor expression, and thus a partial pointer.
|
||||||
auto* e = UnwrapIndirectAndAddressOfChain(u);
|
auto* e = UnwrapIndirectAndAddressOfChain(u);
|
||||||
if (auto* var_user = sem_.Get<sem::VariableUser>(e)) {
|
if (auto* var_user = sem_.Get<sem::VariableUser>(e)) {
|
||||||
if (current_function_->partial_ptrs.Contains(var_user->Variable())) {
|
if (current_function_->partial_ptrs.Contains(var_user->Variable())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TINT_ASSERT(Resolver, e->Is<ast::IndexAccessorExpression>());
|
TINT_ASSERT(Resolver, e->Is<ast::AccessorExpression>());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -6375,6 +6375,43 @@ test:11:9 note: reading from read_write storage buffer 'rw' may result in a non-
|
|||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(UniformityAnalysisTest, StructMember_MemberBecomesUniformThroughPartialPointer) {
|
||||||
|
// For aggregate types, we conservatively consider them to be non-uniform once they
|
||||||
|
// become non-uniform. Test that after assigning a uniform value to a member, that member is
|
||||||
|
// still considered to be non-uniform.
|
||||||
|
std::string src = R"(
|
||||||
|
struct S {
|
||||||
|
a : i32,
|
||||||
|
b : i32,
|
||||||
|
}
|
||||||
|
@group(0) @binding(0) var<storage, read_write> rw : i32;
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
var s : S;
|
||||||
|
s.a = rw;
|
||||||
|
*&s.a = 0;
|
||||||
|
if (s.a == 0) {
|
||||||
|
workgroupBarrier();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
RunTest(src, false);
|
||||||
|
EXPECT_EQ(error_,
|
||||||
|
R"(test:13:5 error: 'workgroupBarrier' must only be called from uniform control flow
|
||||||
|
workgroupBarrier();
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
test:12:3 note: control flow depends on possibly non-uniform value
|
||||||
|
if (s.a == 0) {
|
||||||
|
^^
|
||||||
|
|
||||||
|
test:10:9 note: reading from read_write storage buffer 'rw' may result in a non-uniform value
|
||||||
|
s.a = rw;
|
||||||
|
^^
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(UniformityAnalysisTest, StructMember_MemberBecomesUniformThroughCapturedPartialPointer) {
|
TEST_F(UniformityAnalysisTest, StructMember_MemberBecomesUniformThroughCapturedPartialPointer) {
|
||||||
// For aggregate types, we conservatively consider them to be non-uniform once they
|
// For aggregate types, we conservatively consider them to be non-uniform once they
|
||||||
// become non-uniform. Test that after assigning a uniform value to a member, that member is
|
// become non-uniform. Test that after assigning a uniform value to a member, that member is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user