Converted InterfaceBlock name to string_view
Change-Id: I1d64165b43bc956d0f965fe55f29eebb37a8dbd6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433002 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
66b500a07c
commit
3533ff10c7
@ -1078,8 +1078,8 @@ std::unique_ptr<SkSL::InterfaceBlock> IRGenerator::convertInterfaceBlock(const A
|
||||
}
|
||||
return std::make_unique<SkSL::InterfaceBlock>(intf.fOffset,
|
||||
var,
|
||||
String(id.fTypeName),
|
||||
String(id.fInstanceName),
|
||||
id.fTypeName,
|
||||
id.fInstanceName,
|
||||
arraySize,
|
||||
symbols);
|
||||
}
|
||||
|
@ -299,12 +299,11 @@ std::unique_ptr<ProgramElement> Rehydrator::element() {
|
||||
case Rehydrator::kInterfaceBlock_Command: {
|
||||
const Symbol* var = this->symbol();
|
||||
SkASSERT(var && var->is<Variable>());
|
||||
String typeName(this->readString());
|
||||
String instanceName(this->readString());
|
||||
skstd::string_view typeName = this->readString();
|
||||
skstd::string_view instanceName = this->readString();
|
||||
int arraySize = this->readS8();
|
||||
return std::make_unique<InterfaceBlock>(/*offset=*/-1, &var->as<Variable>(),
|
||||
std::move(typeName), std::move(instanceName),
|
||||
arraySize, nullptr);
|
||||
return std::make_unique<InterfaceBlock>(/*offset=*/-1, &var->as<Variable>(), typeName,
|
||||
instanceName, arraySize, nullptr);
|
||||
}
|
||||
case Rehydrator::kVarDeclarations_Command: {
|
||||
std::unique_ptr<Statement> decl = this->statement();
|
||||
|
@ -1847,7 +1847,8 @@ void MetalCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
|
||||
}
|
||||
fInterfaceBlockNameMap[&intf] = intf.instanceName();
|
||||
} else {
|
||||
fInterfaceBlockNameMap[&intf] = "_anonInterface" + to_string(fAnonInterfaceCount++);
|
||||
fInterfaceBlockNameMap[&intf] = *fProgram.fSymbols->takeOwnershipOfString("_anonInterface" +
|
||||
to_string(fAnonInterfaceCount++));
|
||||
}
|
||||
this->writeLine(";");
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ protected:
|
||||
|
||||
std::unordered_set<skstd::string_view> fReservedWords;
|
||||
std::unordered_map<const Type::Field*, const InterfaceBlock*> fInterfaceBlockMap;
|
||||
std::unordered_map<const InterfaceBlock*, String> fInterfaceBlockNameMap;
|
||||
std::unordered_map<const InterfaceBlock*, skstd::string_view> fInterfaceBlockNameMap;
|
||||
int fAnonInterfaceCount = 0;
|
||||
int fPaddingCount = 0;
|
||||
const char* fLineEnding;
|
||||
|
@ -3648,7 +3648,7 @@ void SPIRVCodeGenerator::addRTFlipUniform(int offset) {
|
||||
}
|
||||
InterfaceBlock intf(/*offset=*/-1,
|
||||
intfVar,
|
||||
String(name),
|
||||
name,
|
||||
/*instanceName=*/"",
|
||||
/*arraySize=*/0,
|
||||
std::make_shared<SymbolTable>(&fErrors, /*builtin=*/false));
|
||||
|
@ -217,8 +217,7 @@ public:
|
||||
DSLWriter::MarkDeclared(var);
|
||||
}
|
||||
DSLWriter::ProgramElements().push_back(std::make_unique<SkSL::InterfaceBlock>(/*offset=*/-1,
|
||||
DSLWriter::Var(var), String(typeName), String(varName), arraySize,
|
||||
DSLWriter::SymbolTable()));
|
||||
DSLWriter::Var(var), typeName, varName, arraySize, DSLWriter::SymbolTable()));
|
||||
if (varName.empty()) {
|
||||
const std::vector<SkSL::Type::Field>& fields = structType->fields();
|
||||
const SkSL::Variable* skslVar = DSLWriter::Var(var);
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "include/core/SkStringView.h"
|
||||
#include "include/private/SkSLProgramElement.h"
|
||||
#include "src/sksl/ir/SkSLSymbolTable.h"
|
||||
#include "src/sksl/ir/SkSLVarDeclarations.h"
|
||||
@ -30,8 +31,9 @@ class InterfaceBlock final : public ProgramElement {
|
||||
public:
|
||||
static constexpr Kind kProgramElementKind = Kind::kInterfaceBlock;
|
||||
|
||||
InterfaceBlock(int offset, const Variable* var, String typeName, String instanceName,
|
||||
int arraySize, std::shared_ptr<SymbolTable> typeOwner)
|
||||
InterfaceBlock(int offset, const Variable* var, skstd::string_view typeName,
|
||||
skstd::string_view instanceName, int arraySize,
|
||||
std::shared_ptr<SymbolTable> typeOwner)
|
||||
: INHERITED(offset, kProgramElementKind)
|
||||
, fVariable(var)
|
||||
, fTypeName(typeName)
|
||||
@ -47,11 +49,11 @@ public:
|
||||
fVariable = var;
|
||||
}
|
||||
|
||||
String typeName() const {
|
||||
skstd::string_view typeName() const {
|
||||
return fTypeName;
|
||||
}
|
||||
|
||||
String instanceName() const {
|
||||
skstd::string_view instanceName() const {
|
||||
return fInstanceName;
|
||||
}
|
||||
|
||||
@ -92,8 +94,8 @@ public:
|
||||
|
||||
private:
|
||||
const Variable* fVariable;
|
||||
String fTypeName;
|
||||
String fInstanceName;
|
||||
skstd::string_view fTypeName;
|
||||
skstd::string_view fInstanceName;
|
||||
int fArraySize;
|
||||
std::shared_ptr<SymbolTable> fTypeOwner;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user