mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 22:17:51 +00:00
Program: Remove deprecated symbol methods
Fixup all usages Bug: tint:390 Change-Id: If861b044eae006af2fd86d348de6ba62f448bc6a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38549 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
@@ -51,12 +51,12 @@ Transform::Output EmitVertexPointSize::Run(const Program* in) {
|
||||
|
||||
// Declare the pointsize builtin output variable.
|
||||
auto* pointsize_var = out.program.create<ast::Variable>(
|
||||
Source{}, // source
|
||||
out.program.RegisterSymbol(kPointSizeVar), // symbol
|
||||
ast::StorageClass::kOutput, // storage_class
|
||||
f32, // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
Source{}, // source
|
||||
out.program.Symbols().Register(kPointSizeVar), // symbol
|
||||
ast::StorageClass::kOutput, // storage_class
|
||||
f32, // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
out.program.create<ast::BuiltinDecoration>(Source{},
|
||||
@@ -68,7 +68,7 @@ Transform::Output EmitVertexPointSize::Run(const Program* in) {
|
||||
auto* one = out.program.create<ast::ScalarConstructorExpression>(
|
||||
Source{}, out.program.create<ast::FloatLiteral>(Source{}, f32, 1.0f));
|
||||
auto* pointsize_ident = out.program.create<ast::IdentifierExpression>(
|
||||
Source{}, out.program.RegisterSymbol(kPointSizeVar));
|
||||
Source{}, out.program.Symbols().Register(kPointSizeVar));
|
||||
auto* pointsize_assign = out.program.create<ast::AssignmentStatement>(
|
||||
Source{}, pointsize_ident, one);
|
||||
|
||||
|
||||
@@ -65,13 +65,13 @@ ast::Variable* clone_variable_with_new_name(CloneContext* ctx,
|
||||
ast::Variable* in,
|
||||
std::string new_name) {
|
||||
return ctx->dst->create<ast::Variable>(
|
||||
ctx->Clone(in->source()), // source
|
||||
ctx->dst->RegisterSymbol(new_name), // symbol
|
||||
in->storage_class(), // storage_class
|
||||
ctx->Clone(in->type()), // type
|
||||
in->is_const(), // is_const
|
||||
ctx->Clone(in->constructor()), // constructor
|
||||
ctx->Clone(in->decorations())); // decorations
|
||||
ctx->Clone(in->source()), // source
|
||||
ctx->dst->Symbols().Register(new_name), // symbol
|
||||
in->storage_class(), // storage_class
|
||||
ctx->Clone(in->type()), // type
|
||||
in->is_const(), // is_const
|
||||
ctx->Clone(in->constructor()), // constructor
|
||||
ctx->Clone(in->decorations())); // decorations
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -85,7 +85,7 @@ Transform::Output FirstIndexOffset::Run(const Program* in) {
|
||||
// First do a quick check to see if the transform has already been applied.
|
||||
for (ast::Variable* var : in->AST().GlobalVariables()) {
|
||||
if (auto* dec_var = var->As<ast::Variable>()) {
|
||||
if (dec_var->symbol() == in->GetSymbol(kBufferName)) {
|
||||
if (dec_var->symbol() == in->Symbols().Get(kBufferName)) {
|
||||
diag::Diagnostic err;
|
||||
err.message = "First index offset transform has already been applied.";
|
||||
err.severity = diag::Severity::Error;
|
||||
@@ -137,13 +137,13 @@ Transform::Output FirstIndexOffset::Run(const Program* in) {
|
||||
has_vertex_index_ = true;
|
||||
return clone_variable_with_new_name(
|
||||
ctx, var,
|
||||
kIndexOffsetPrefix + in->SymbolToName(var->symbol()));
|
||||
kIndexOffsetPrefix + in->Symbols().NameFor(var->symbol()));
|
||||
} else if (blt_type == ast::Builtin::kInstanceIndex) {
|
||||
instance_index_sym = var->symbol();
|
||||
has_instance_index_ = true;
|
||||
return clone_variable_with_new_name(
|
||||
ctx, var,
|
||||
kIndexOffsetPrefix + in->SymbolToName(var->symbol()));
|
||||
kIndexOffsetPrefix + in->Symbols().NameFor(var->symbol()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,12 +162,12 @@ Transform::Output FirstIndexOffset::Run(const Program* in) {
|
||||
func->local_referenced_builtin_variables()) {
|
||||
if (data.second->value() == ast::Builtin::kVertexIndex) {
|
||||
statements.emplace_back(CreateFirstIndexOffset(
|
||||
in->SymbolToName(vertex_index_sym), kFirstVertexName,
|
||||
in->Symbols().NameFor(vertex_index_sym), kFirstVertexName,
|
||||
buffer_var, ctx->dst));
|
||||
} else if (data.second->value() == ast::Builtin::kInstanceIndex) {
|
||||
statements.emplace_back(CreateFirstIndexOffset(
|
||||
in->SymbolToName(instance_index_sym), kFirstInstanceName,
|
||||
buffer_var, ctx->dst));
|
||||
in->Symbols().NameFor(instance_index_sym),
|
||||
kFirstInstanceName, buffer_var, ctx->dst));
|
||||
}
|
||||
}
|
||||
return CloneWithStatementsAtStart(ctx, func, statements);
|
||||
@@ -204,7 +204,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(Program* dst) {
|
||||
member_dec.push_back(
|
||||
dst->create<ast::StructMemberOffsetDecoration>(Source{}, offset));
|
||||
members.push_back(dst->create<ast::StructMember>(
|
||||
Source{}, dst->RegisterSymbol(kFirstVertexName), u32_type,
|
||||
Source{}, dst->Symbols().Register(kFirstVertexName), u32_type,
|
||||
std::move(member_dec)));
|
||||
vertex_index_offset_ = offset;
|
||||
offset += 4;
|
||||
@@ -215,7 +215,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(Program* dst) {
|
||||
member_dec.push_back(
|
||||
dst->create<ast::StructMemberOffsetDecoration>(Source{}, offset));
|
||||
members.push_back(dst->create<ast::StructMember>(
|
||||
Source{}, dst->RegisterSymbol(kFirstInstanceName), u32_type,
|
||||
Source{}, dst->Symbols().Register(kFirstInstanceName), u32_type,
|
||||
std::move(member_dec)));
|
||||
instance_index_offset_ = offset;
|
||||
offset += 4;
|
||||
@@ -225,16 +225,16 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(Program* dst) {
|
||||
decos.push_back(dst->create<ast::StructBlockDecoration>(Source{}));
|
||||
|
||||
auto* struct_type = dst->create<type::Struct>(
|
||||
dst->RegisterSymbol(kStructName),
|
||||
dst->Symbols().Register(kStructName),
|
||||
dst->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
||||
|
||||
auto* idx_var = dst->create<ast::Variable>(
|
||||
Source{}, // source
|
||||
dst->RegisterSymbol(kBufferName), // symbol
|
||||
ast::StorageClass::kUniform, // storage_class
|
||||
struct_type, // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
Source{}, // source
|
||||
dst->Symbols().Register(kBufferName), // symbol
|
||||
ast::StorageClass::kUniform, // storage_class
|
||||
struct_type, // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
ast::VariableDecorationList{
|
||||
dst->create<ast::BindingDecoration>(Source{}, binding_),
|
||||
dst->create<ast::GroupDecoration>(Source{}, group_),
|
||||
@@ -259,19 +259,19 @@ ast::VariableDeclStatement* FirstIndexOffset::CreateFirstIndexOffset(
|
||||
auto* constructor = dst->create<ast::BinaryExpression>(
|
||||
Source{}, ast::BinaryOp::kAdd,
|
||||
dst->create<ast::IdentifierExpression>(Source{},
|
||||
dst->RegisterSymbol(lhs_name)),
|
||||
dst->Symbols().Register(lhs_name)),
|
||||
dst->create<ast::MemberAccessorExpression>(
|
||||
Source{}, buffer,
|
||||
dst->create<ast::IdentifierExpression>(
|
||||
Source{}, dst->RegisterSymbol(field_name))));
|
||||
auto* var =
|
||||
dst->create<ast::Variable>(Source{}, // source
|
||||
dst->RegisterSymbol(original_name), // symbol
|
||||
ast::StorageClass::kNone, // storage_class
|
||||
dst->create<type::U32>(), // type
|
||||
true, // is_const
|
||||
constructor, // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
Source{}, dst->Symbols().Register(field_name))));
|
||||
auto* var = dst->create<ast::Variable>(
|
||||
Source{}, // source
|
||||
dst->Symbols().Register(original_name), // symbol
|
||||
ast::StorageClass::kNone, // storage_class
|
||||
dst->create<type::U32>(), // type
|
||||
true, // is_const
|
||||
constructor, // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
return dst->create<ast::VariableDeclStatement>(Source{}, var);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,8 @@ Transform::Output VertexPulling::Run(const Program* in) {
|
||||
}
|
||||
|
||||
// Find entry point
|
||||
auto* func = in->AST().Functions().Find(in->GetSymbol(cfg.entry_point_name),
|
||||
ast::PipelineStage::kVertex);
|
||||
auto* func = in->AST().Functions().Find(
|
||||
in->Symbols().Get(cfg.entry_point_name), ast::PipelineStage::kVertex);
|
||||
if (func == nullptr) {
|
||||
diag::Diagnostic err;
|
||||
err.severity = diag::Severity::Error;
|
||||
@@ -158,7 +158,7 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() {
|
||||
for (auto* d : v->decorations()) {
|
||||
if (auto* builtin = d->As<ast::BuiltinDecoration>()) {
|
||||
if (builtin->value() == ast::Builtin::kVertexIndex) {
|
||||
vertex_index_name = in->SymbolToName(v->symbol());
|
||||
vertex_index_name = in->Symbols().NameFor(v->symbol());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -169,12 +169,12 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() {
|
||||
vertex_index_name = kDefaultVertexIndexName;
|
||||
|
||||
auto* var = out->create<ast::Variable>(
|
||||
Source{}, // source
|
||||
out->RegisterSymbol(vertex_index_name), // symbol
|
||||
ast::StorageClass::kInput, // storage_class
|
||||
GetI32Type(), // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
Source{}, // source
|
||||
out->Symbols().Register(vertex_index_name), // symbol
|
||||
ast::StorageClass::kInput, // storage_class
|
||||
GetI32Type(), // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
out->create<ast::BuiltinDecoration>(Source{},
|
||||
@@ -205,7 +205,7 @@ void VertexPulling::State::FindOrInsertInstanceIndexIfUsed() {
|
||||
for (auto* d : v->decorations()) {
|
||||
if (auto* builtin = d->As<ast::BuiltinDecoration>()) {
|
||||
if (builtin->value() == ast::Builtin::kInstanceIndex) {
|
||||
instance_index_name = in->SymbolToName(v->symbol());
|
||||
instance_index_name = in->Symbols().NameFor(v->symbol());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -216,12 +216,12 @@ void VertexPulling::State::FindOrInsertInstanceIndexIfUsed() {
|
||||
instance_index_name = kDefaultInstanceIndexName;
|
||||
|
||||
auto* var = out->create<ast::Variable>(
|
||||
Source{}, // source
|
||||
out->RegisterSymbol(instance_index_name), // symbol
|
||||
ast::StorageClass::kInput, // storage_class
|
||||
GetI32Type(), // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
Source{}, // source
|
||||
out->Symbols().Register(instance_index_name), // symbol
|
||||
ast::StorageClass::kInput, // storage_class
|
||||
GetI32Type(), // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
out->create<ast::BuiltinDecoration>(Source{},
|
||||
@@ -274,26 +274,26 @@ void VertexPulling::State::AddVertexStorageBuffers() {
|
||||
out->create<ast::StructMemberOffsetDecoration>(Source{}, 0u));
|
||||
|
||||
members.push_back(out->create<ast::StructMember>(
|
||||
Source{}, out->RegisterSymbol(kStructBufferName), internal_array_type,
|
||||
Source{}, out->Symbols().Register(kStructBufferName), internal_array_type,
|
||||
std::move(member_dec)));
|
||||
|
||||
ast::StructDecorationList decos;
|
||||
decos.push_back(out->create<ast::StructBlockDecoration>(Source{}));
|
||||
|
||||
auto* struct_type = out->create<type::Struct>(
|
||||
out->RegisterSymbol(kStructName),
|
||||
out->Symbols().Register(kStructName),
|
||||
out->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
||||
|
||||
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
|
||||
// The decorated variable with struct type
|
||||
std::string name = GetVertexBufferName(i);
|
||||
auto* var = out->create<ast::Variable>(
|
||||
Source{}, // source
|
||||
out->RegisterSymbol(name), // symbol
|
||||
ast::StorageClass::kStorage, // storage_class
|
||||
struct_type, // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
Source{}, // source
|
||||
out->Symbols().Register(name), // symbol
|
||||
ast::StorageClass::kStorage, // storage_class
|
||||
struct_type, // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
out->create<ast::BindingDecoration>(Source{}, i),
|
||||
@@ -313,13 +313,13 @@ ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
|
||||
// Declare the |kPullingPosVarName| variable in the shader
|
||||
auto* pos_declaration = out->create<ast::VariableDeclStatement>(
|
||||
Source{}, out->create<ast::Variable>(
|
||||
Source{}, // source
|
||||
out->RegisterSymbol(kPullingPosVarName), // symbol
|
||||
ast::StorageClass::kFunction, // storage_class
|
||||
GetI32Type(), // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
Source{}, // source
|
||||
out->Symbols().Register(kPullingPosVarName), // symbol
|
||||
ast::StorageClass::kFunction, // storage_class
|
||||
GetI32Type(), // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
// |kPullingPosVarName| refers to the byte location of the current read. We
|
||||
// declare a variable in the shader to avoid having to reuse Expression
|
||||
@@ -342,7 +342,7 @@ ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
|
||||
: instance_index_name;
|
||||
// Identifier to index by
|
||||
auto* index_identifier = out->create<ast::IdentifierExpression>(
|
||||
Source{}, out->RegisterSymbol(name));
|
||||
Source{}, out->Symbols().Register(name));
|
||||
|
||||
// An expression for the start of the read in the buffer in bytes
|
||||
auto* pos_value = out->create<ast::BinaryExpression>(
|
||||
@@ -357,11 +357,11 @@ ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
|
||||
Source{}, CreatePullingPositionIdent(), pos_value);
|
||||
stmts.emplace_back(set_pos_expr);
|
||||
|
||||
auto ident_name = in->SymbolToName(v->symbol());
|
||||
auto ident_name = in->Symbols().NameFor(v->symbol());
|
||||
stmts.emplace_back(out->create<ast::AssignmentStatement>(
|
||||
Source{},
|
||||
out->create<ast::IdentifierExpression>(
|
||||
Source{}, out->RegisterSymbol(ident_name)),
|
||||
Source{}, out->Symbols().Register(ident_name)),
|
||||
AccessByFormat(i, attribute_desc.format)));
|
||||
}
|
||||
}
|
||||
@@ -376,7 +376,7 @@ ast::Expression* VertexPulling::State::GenUint(uint32_t value) const {
|
||||
|
||||
ast::Expression* VertexPulling::State::CreatePullingPositionIdent() const {
|
||||
return out->create<ast::IdentifierExpression>(
|
||||
Source{}, out->RegisterSymbol(kPullingPosVarName));
|
||||
Source{}, out->Symbols().Register(kPullingPosVarName));
|
||||
}
|
||||
|
||||
ast::Expression* VertexPulling::State::AccessByFormat(
|
||||
@@ -420,9 +420,9 @@ ast::Expression* VertexPulling::State::AccessU32(uint32_t buffer,
|
||||
out->create<ast::MemberAccessorExpression>(
|
||||
Source{},
|
||||
out->create<ast::IdentifierExpression>(
|
||||
Source{}, out->RegisterSymbol(vbuf_name)),
|
||||
Source{}, out->Symbols().Register(vbuf_name)),
|
||||
out->create<ast::IdentifierExpression>(
|
||||
Source{}, out->RegisterSymbol(kStructBufferName))),
|
||||
Source{}, out->Symbols().Register(kStructBufferName))),
|
||||
out->create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kDivide, pos,
|
||||
GenUint(4)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user