fixed skslc SPIR-V memory error
BUG=skia:6446 Change-Id: Ibc55124db60d6a05964ddcd02d285e313379f93e Reviewed-on: https://skia-review.googlesource.com/10756 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
c9807b8428
commit
8feeff929e
@ -49,8 +49,8 @@ namespace SkSL {
|
||||
|
||||
Compiler::Compiler()
|
||||
: fErrorCount(0) {
|
||||
auto types = std::shared_ptr<SymbolTable>(new SymbolTable(*this));
|
||||
auto symbols = std::shared_ptr<SymbolTable>(new SymbolTable(types, *this));
|
||||
auto types = std::shared_ptr<SymbolTable>(new SymbolTable(this));
|
||||
auto symbols = std::shared_ptr<SymbolTable>(new SymbolTable(types, this));
|
||||
fIRGenerator = new IRGenerator(&fContext, symbols, *this);
|
||||
fTypes = types;
|
||||
#define ADD_TYPE(t) types->addWithoutOwnership(fContext.f ## t ## _Type->fName, \
|
||||
|
@ -108,7 +108,7 @@ IRGenerator::IRGenerator(const Context* context, std::shared_ptr<SymbolTable> sy
|
||||
, fErrors(errorReporter) {}
|
||||
|
||||
void IRGenerator::pushSymbolTable() {
|
||||
fSymbolTable.reset(new SymbolTable(std::move(fSymbolTable), fErrors));
|
||||
fSymbolTable.reset(new SymbolTable(std::move(fSymbolTable), &fErrors));
|
||||
}
|
||||
|
||||
void IRGenerator::popSymbolTable() {
|
||||
@ -665,7 +665,8 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte
|
||||
(int) i)));
|
||||
}
|
||||
}
|
||||
return std::unique_ptr<InterfaceBlock>(new InterfaceBlock(intf.fPosition, *var,
|
||||
return std::unique_ptr<InterfaceBlock>(new InterfaceBlock(intf.fPosition,
|
||||
var,
|
||||
intf.fTypeName,
|
||||
intf.fInstanceName,
|
||||
std::move(sizes),
|
||||
|
@ -1865,7 +1865,7 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, S
|
||||
// need to remap to a top-left coordinate system
|
||||
if (fRTHeightStructId == (SpvId) -1) {
|
||||
// height variable hasn't been written yet
|
||||
std::shared_ptr<SymbolTable> st(new SymbolTable(fErrors));
|
||||
std::shared_ptr<SymbolTable> st(new SymbolTable(&fErrors));
|
||||
ASSERT(fRTHeightFieldIndex == (SpvId) -1);
|
||||
std::vector<Type::Field> fields;
|
||||
fields.emplace_back(Modifiers(), SkString(SKSL_RTHEIGHT_NAME),
|
||||
@ -1874,8 +1874,12 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, S
|
||||
Type intfStruct(Position(), name, fields);
|
||||
Layout layout(-1, -1, 1, -1, -1, -1, -1, false, false, false, Layout::Format::kUnspecified,
|
||||
false, Layout::kUnspecified_Primitive, -1, -1);
|
||||
Variable intfVar(Position(), Modifiers(layout, Modifiers::kUniform_Flag), name,
|
||||
intfStruct, Variable::kGlobal_Storage);
|
||||
Variable* intfVar = new Variable(Position(),
|
||||
Modifiers(layout, Modifiers::kUniform_Flag),
|
||||
name,
|
||||
intfStruct,
|
||||
Variable::kGlobal_Storage);
|
||||
fSynthetics.takeOwnership(intfVar);
|
||||
InterfaceBlock intf(Position(), intfVar, name, SkString(""),
|
||||
std::vector<std::unique_ptr<Expression>>(), st);
|
||||
fRTHeightStructId = this->writeInterfaceBlock(intf);
|
||||
|
@ -74,7 +74,8 @@ public:
|
||||
, fBoolTrue(0)
|
||||
, fBoolFalse(0)
|
||||
, fSetupFragPosition(false)
|
||||
, fCurrentBlock(0) {
|
||||
, fCurrentBlock(0)
|
||||
, fSynthetics(nullptr, errors) {
|
||||
this->setupIntrinsics();
|
||||
}
|
||||
|
||||
@ -299,6 +300,8 @@ private:
|
||||
std::stack<SpvId> fContinueTarget;
|
||||
SpvId fRTHeightStructId = (SpvId) -1;
|
||||
SpvId fRTHeightFieldIndex = (SpvId) -1;
|
||||
// holds variables synthesized during output, for lifetime purposes
|
||||
SymbolTable fSynthetics;
|
||||
|
||||
friend class PointerLValue;
|
||||
friend class SwizzleLValue;
|
||||
|
@ -25,11 +25,11 @@ namespace SkSL {
|
||||
* At the IR level, this is represented by a single variable of struct type.
|
||||
*/
|
||||
struct InterfaceBlock : public ProgramElement {
|
||||
InterfaceBlock(Position position, const Variable& var, SkString typeName, SkString instanceName,
|
||||
InterfaceBlock(Position position, const Variable* var, SkString typeName, SkString instanceName,
|
||||
std::vector<std::unique_ptr<Expression>> sizes,
|
||||
std::shared_ptr<SymbolTable> typeOwner)
|
||||
: INHERITED(position, kInterfaceBlock_Kind)
|
||||
, fVariable(std::move(var))
|
||||
, fVariable(*var)
|
||||
, fTypeName(std::move(typeName))
|
||||
, fInstanceName(std::move(instanceName))
|
||||
, fSizes(std::move(sizes))
|
||||
|
@ -24,12 +24,12 @@ struct FunctionDeclaration;
|
||||
*/
|
||||
class SymbolTable {
|
||||
public:
|
||||
SymbolTable(ErrorReporter& errorReporter)
|
||||
: fErrorReporter(errorReporter) {}
|
||||
SymbolTable(ErrorReporter* errorReporter)
|
||||
: fErrorReporter(*errorReporter) {}
|
||||
|
||||
SymbolTable(std::shared_ptr<SymbolTable> parent, ErrorReporter& errorReporter)
|
||||
SymbolTable(std::shared_ptr<SymbolTable> parent, ErrorReporter* errorReporter)
|
||||
: fParent(parent)
|
||||
, fErrorReporter(errorReporter) {}
|
||||
, fErrorReporter(*errorReporter) {}
|
||||
|
||||
const Symbol* operator[](const SkString& name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user