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:
parent
44382a1857
commit
e55e2109b3
|
@ -2863,8 +2863,9 @@ void Resolver::CreateSemanticNodes() const {
|
||||||
|
|
||||||
sem_var = builder_->create<sem::Variable>(var, info->type, constant_id);
|
sem_var = builder_->create<sem::Variable>(var, info->type, constant_id);
|
||||||
} else {
|
} else {
|
||||||
sem_var = builder_->create<sem::Variable>(
|
sem_var =
|
||||||
var, info->type, info->storage_class, info->access);
|
builder_->create<sem::Variable>(var, info->type, info->storage_class,
|
||||||
|
info->access, info->binding_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const sem::VariableUser*> users;
|
std::vector<const sem::VariableUser*> users;
|
||||||
|
|
|
@ -2020,6 +2020,22 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) {
|
||||||
EXPECT_EQ(Sem().Get(var)->Access(), ast::Access::kRead);
|
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) {
|
TEST_F(ResolverTest, Function_EntryPoints_StageDecoration) {
|
||||||
// fn b() {}
|
// fn b() {}
|
||||||
// fn c() { b(); }
|
// fn c() { b(); }
|
||||||
|
|
|
@ -26,11 +26,13 @@ namespace sem {
|
||||||
Variable::Variable(const ast::Variable* declaration,
|
Variable::Variable(const ast::Variable* declaration,
|
||||||
const sem::Type* type,
|
const sem::Type* type,
|
||||||
ast::StorageClass storage_class,
|
ast::StorageClass storage_class,
|
||||||
ast::Access access)
|
ast::Access access,
|
||||||
|
sem::BindingPoint binding_point)
|
||||||
: declaration_(declaration),
|
: declaration_(declaration),
|
||||||
type_(type),
|
type_(type),
|
||||||
storage_class_(storage_class),
|
storage_class_(storage_class),
|
||||||
access_(access),
|
access_(access),
|
||||||
|
binding_point_(binding_point),
|
||||||
is_pipeline_constant_(false) {}
|
is_pipeline_constant_(false) {}
|
||||||
|
|
||||||
Variable::Variable(const ast::Variable* declaration,
|
Variable::Variable(const ast::Variable* declaration,
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "src/ast/access.h"
|
#include "src/ast/access.h"
|
||||||
#include "src/ast/storage_class.h"
|
#include "src/ast/storage_class.h"
|
||||||
|
#include "src/sem/binding_point.h"
|
||||||
#include "src/sem/expression.h"
|
#include "src/sem/expression.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -43,10 +44,12 @@ class Variable : public Castable<Variable, Node> {
|
||||||
/// @param type the variable type
|
/// @param type the variable type
|
||||||
/// @param storage_class the variable storage class
|
/// @param storage_class the variable storage class
|
||||||
/// @param access the variable access control type
|
/// @param access the variable access control type
|
||||||
|
/// @param binding_point the optional resource binding point of the variable
|
||||||
Variable(const ast::Variable* declaration,
|
Variable(const ast::Variable* declaration,
|
||||||
const sem::Type* type,
|
const sem::Type* type,
|
||||||
ast::StorageClass storage_class,
|
ast::StorageClass storage_class,
|
||||||
ast::Access access);
|
ast::Access access,
|
||||||
|
sem::BindingPoint binding_point = {});
|
||||||
|
|
||||||
/// Constructor for overridable pipeline constants
|
/// Constructor for overridable pipeline constants
|
||||||
/// @param declaration the AST declaration node
|
/// @param declaration the AST declaration node
|
||||||
|
@ -71,6 +74,9 @@ class Variable : public Castable<Variable, Node> {
|
||||||
/// @returns the access control for the variable
|
/// @returns the access control for the variable
|
||||||
ast::Access Access() const { return access_; }
|
ast::Access Access() const { return access_; }
|
||||||
|
|
||||||
|
/// @returns the resource binding point for the variable
|
||||||
|
sem::BindingPoint BindingPoint() const { return binding_point_; }
|
||||||
|
|
||||||
/// @returns the expressions that use the variable
|
/// @returns the expressions that use the variable
|
||||||
const std::vector<const VariableUser*>& Users() const { return users_; }
|
const std::vector<const VariableUser*>& Users() const { return users_; }
|
||||||
|
|
||||||
|
@ -88,6 +94,7 @@ class Variable : public Castable<Variable, Node> {
|
||||||
const sem::Type* const type_;
|
const sem::Type* const type_;
|
||||||
ast::StorageClass const storage_class_;
|
ast::StorageClass const storage_class_;
|
||||||
ast::Access const access_;
|
ast::Access const access_;
|
||||||
|
sem::BindingPoint binding_point_;
|
||||||
std::vector<const VariableUser*> users_;
|
std::vector<const VariableUser*> users_;
|
||||||
const bool is_pipeline_constant_;
|
const bool is_pipeline_constant_;
|
||||||
const uint16_t constant_id_ = 0;
|
const uint16_t constant_id_ = 0;
|
||||||
|
|
Loading…
Reference in New Issue