sem: Add BindingPoint() to sem::Variable

The Resolver already has this information, so just propagate it to the
semantic variable.

Change-Id: Id9fc58d3fc706a1433aba7cb3845b4f53f3fc386
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55120
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2021-06-18 09:27:13 +00:00
committed by Tint LUCI CQ
parent 44382a1857
commit e55e2109b3
4 changed files with 30 additions and 4 deletions

View File

@@ -2863,8 +2863,9 @@ void Resolver::CreateSemanticNodes() const {
sem_var = builder_->create<sem::Variable>(var, info->type, constant_id);
} else {
sem_var = builder_->create<sem::Variable>(
var, info->type, info->storage_class, info->access);
sem_var =
builder_->create<sem::Variable>(var, info->type, info->storage_class,
info->access, info->binding_point);
}
std::vector<const sem::VariableUser*> users;

View File

@@ -2020,6 +2020,22 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) {
EXPECT_EQ(Sem().Get(var)->Access(), ast::Access::kRead);
}
TEST_F(ResolverTest, BindingPoint_SetForResources) {
// [[group(1), binding(2)]] var s1 : sampler;
// [[group(3), binding(4)]] var s2 : sampler;
auto* s1 = Global(Sym(), ty.sampler(ast::SamplerKind::kSampler),
ast::DecorationList{create<ast::GroupDecoration>(1),
create<ast::BindingDecoration>(2)});
auto* s2 = Global(Sym(), ty.sampler(ast::SamplerKind::kSampler),
ast::DecorationList{create<ast::GroupDecoration>(3),
create<ast::BindingDecoration>(4)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_EQ(Sem().Get(s1)->BindingPoint(), (sem::BindingPoint{1u, 2u}));
EXPECT_EQ(Sem().Get(s2)->BindingPoint(), (sem::BindingPoint{3u, 4u}));
}
TEST_F(ResolverTest, Function_EntryPoints_StageDecoration) {
// fn b() {}
// fn c() { b(); }