tint: Rename SourceVariable() to RootIdentifier()

This is now a well-defined term in the WGSL spec, so we should use it.

Change-Id: Icc46a77f0a465afbfd39cdaec84e506b143c8c0c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109220
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
This commit is contained in:
James Price
2022-11-09 12:16:56 +00:00
committed by Dawn LUCI CQ
parent bb8d7341d6
commit a7cd3aeff0
18 changed files with 108 additions and 108 deletions

View File

@@ -174,15 +174,15 @@ struct LocalizeStructArrayAssignment::State {
// See https://www.w3.org/TR/WGSL/#originating-variable-section
std::pair<const sem::Type*, ast::AddressSpace> GetOriginatingTypeAndAddressSpace(
const ast::AssignmentStatement* assign_stmt) {
auto* source_var = src->Sem().Get(assign_stmt->lhs)->SourceVariable();
if (!source_var) {
auto* root_ident = src->Sem().Get(assign_stmt->lhs)->RootIdentifier();
if (!root_ident) {
TINT_ICE(Transform, b.Diagnostics())
<< "Unable to determine originating variable for lhs of assignment "
"statement";
return {};
}
auto* type = source_var->Type();
auto* type = root_ident->Type();
if (auto* ref = type->As<sem::Reference>()) {
return {ref->StoreType(), ref->AddressSpace()};
} else if (auto* ptr = type->As<sem::Pointer>()) {

View File

@@ -97,7 +97,7 @@ struct SpirvAtomic::State {
b.Call(sem::str(stub->builtin), std::move(out_args)));
}
// Keep track of this expression. We'll need to modify the source variable /
// Keep track of this expression. We'll need to modify the root identifier /
// structure to be atomic.
atomic_expressions.Add(ctx.src->Sem().Get(args[0]));
}
@@ -230,8 +230,8 @@ struct SpirvAtomic::State {
void ReplaceLoadsAndStores() {
// Returns true if 'e' is a reference to an atomic variable or struct member
auto is_ref_to_atomic_var = [&](const sem::Expression* e) {
if (tint::Is<sem::Reference>(e->Type()) && e->SourceVariable() &&
(atomic_variables.count(e->SourceVariable()) != 0)) {
if (tint::Is<sem::Reference>(e->Type()) && e->RootIdentifier() &&
(atomic_variables.count(e->RootIdentifier()) != 0)) {
// If it's a struct member, make sure it's one we marked as atomic
if (auto* ma = e->As<sem::StructMemberAccess>()) {
auto it = forked_structs.find(ma->Member()->Struct()->Declaration());

View File

@@ -498,26 +498,26 @@ struct Std140::State {
AccessChain access;
// Start by looking at the source variable. This must be a std140-forked uniform buffer.
access.var = tint::As<sem::GlobalVariable>(expr->SourceVariable());
// Start by looking at the root identifier. This must be a std140-forked uniform buffer.
access.var = tint::As<sem::GlobalVariable>(expr->RootIdentifier());
if (!access.var || !std140_uniforms.Contains(access.var)) {
// Not at std140-forked uniform buffer access chain.
return std::nullopt;
}
// Walk from the outer-most expression, inwards towards the source variable.
// Walk from the outer-most expression, inwards towards the root identifier.
while (true) {
enum class Action { kStop, kContinue, kError };
Action action = Switch(
expr, //
[&](const sem::VariableUser* user) {
if (user->Variable() == access.var) {
// Walked all the way to the source variable. We're done traversing.
// Walked all the way to the root identifier. We're done traversing.
access.indices.Push(UniformVariable{});
return Action::kStop;
}
if (user->Variable()->Type()->Is<sem::Pointer>()) {
// Found a pointer. As the source variable is a uniform buffer variable,
// Found a pointer. As the root identifier is a uniform buffer variable,
// this must be a pointer-let. Continue traversing from the let
// initializer.
expr = user->Variable()->Initializer();