Hash :
27423bff
Author :
Date :
2024-03-05T17:57:24
Metal: Generate names for rewritten inputs When expanding multi-component fields to multiple single-component fields, use AngleInternal namespace for the new names. The names are generated with form "someField_0" where _0 is the component index. If these are not created in AngleInternal, caller is able to create a name clash by introducing single-component field "someField_0". Fixes an assert where the vec4(a_) + vec4(a) would assert on size mismatch because the variable lookup for "a_" would find a rewritten variable for the expanded matrix row of "a". Bug: angleproject:8558 Change-Id: I64b7a755d7d534543fdb0f4c43008dd5c63f4aad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5323060 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kyle Piddington <kpiddington@apple.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef COMPILER_TRANSLATOR_MSL_NAME_H_
#define COMPILER_TRANSLATOR_MSL_NAME_H_
#include "compiler/translator/ImmutableString.h"
#include "compiler/translator/InfoSink.h"
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/Symbol.h"
#include "compiler/translator/Types.h"
namespace sh
{
constexpr char kAngleInternalPrefix[] = "ANGLE";
// Represents the name of a symbol.
class Name
{
public:
constexpr Name(const Name &) = default;
constexpr Name() : Name(kEmptyImmutableString, SymbolType::Empty) {}
constexpr Name(ImmutableString rawName, SymbolType symbolType)
: mRawName(rawName), mSymbolType(symbolType)
{
ASSERT(rawName.empty() == (symbolType == SymbolType::Empty));
}
explicit constexpr Name(const char *rawName, SymbolType symbolType = SymbolType::AngleInternal)
: Name(ImmutableString(rawName), symbolType)
{}
Name(const std::string &rawName, SymbolType symbolType)
: Name(ImmutableString(rawName), symbolType)
{}
explicit Name(const TField &field);
explicit Name(const TSymbol &symbol);
Name &operator=(const Name &) = default;
bool operator==(const Name &other) const;
bool operator!=(const Name &other) const;
bool operator<(const Name &other) const;
constexpr const ImmutableString &rawName() const { return mRawName; }
constexpr SymbolType symbolType() const { return mSymbolType; }
bool empty() const;
bool beginsWith(const Name &prefix) const;
void emit(TInfoSinkBase &out) const;
private:
ImmutableString mRawName;
SymbolType mSymbolType;
template <typename T>
void emitImpl(T &out) const;
friend std::ostream &operator<<(std::ostream &os, const sh::Name &name);
};
constexpr Name kBaseInstanceName = Name("baseInstance");
[[nodiscard]] bool ExpressionContainsName(const Name &name, TIntermTyped &node);
} // namespace sh
#endif // COMPILER_TRANSLATOR_MSL_NAME_H_