Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8b43dad

Browse files
brianosmanSkia Commit-Bot
authored andcommitted
In SPIRVCodeGenerator, use the Program's ModifiersPool
We were passing in the IR generator's which had already been reset, so technically belonged to the *next* Program to be compiled. Change-Id: Ib68c283591f02d1642bb7c2d9658f5caa76b0f15 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324700 Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
1 parent 141d35c commit 8b43dad

File tree

5 files changed

+18
-26
lines changed

5 files changed

+18
-26
lines changed

src/sksl/SkSLCompiler.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,6 @@ bool Compiler::optimize(Program& program) {
16091609
break;
16101610
}
16111611
}
1612-
program.finish();
16131612
return fErrorCount == 0;
16141613
}
16151614

@@ -1619,7 +1618,7 @@ bool Compiler::toSPIRV(Program& program, OutputStream& out) {
16191618
#ifdef SK_ENABLE_SPIRV_VALIDATION
16201619
StringStream buffer;
16211620
fSource = program.fSource.get();
1622-
SPIRVCodeGenerator cg(fContext.get(), fIRGenerator->fModifiers.get(), &program, this, &buffer);
1621+
SPIRVCodeGenerator cg(fContext.get(), &program, this, &buffer);
16231622
bool result = cg.generateCode();
16241623
fSource = nullptr;
16251624
if (result) {
@@ -1637,7 +1636,7 @@ bool Compiler::toSPIRV(Program& program, OutputStream& out) {
16371636
}
16381637
#else
16391638
fSource = program.fSource.get();
1640-
SPIRVCodeGenerator cg(fContext.get(), fIRGenerator->fModifiers.get(), &program, this, &out);
1639+
SPIRVCodeGenerator cg(fContext.get(), &program, this, &out);
16411640
bool result = cg.generateCode();
16421641
fSource = nullptr;
16431642
#endif

src/sksl/SkSLModifiersPool.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ class ModifiersPool {
5959
return Handle(this, index);
6060
}
6161

62-
void finish() {
63-
fModifiersMap.clear();
64-
}
65-
6662
private:
6763
std::vector<Modifiers> fModifiers;
6864
std::unordered_map<Modifiers, int> fModifiersMap;

src/sksl/SkSLSPIRVCodeGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
18791879
Modifiers modifiers(layout, Modifiers::kUniform_Flag);
18801880
const Variable* intfVar = fSynthetics.takeOwnershipOfSymbol(
18811881
std::make_unique<Variable>(/*offset=*/-1,
1882-
fModifiers.handle(modifiers),
1882+
fProgram.fModifiers->handle(modifiers),
18831883
name,
18841884
&intfStruct,
18851885
/*builtin=*/false,

src/sksl/SkSLSPIRVCodeGenerator.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,20 @@ class SPIRVCodeGenerator : public CodeGenerator {
104104
virtual void store(SpvId value, OutputStream& out) = 0;
105105
};
106106

107-
SPIRVCodeGenerator(const Context* context, ModifiersPool* modifiers,
108-
const Program* program, ErrorReporter* errors, OutputStream* out)
109-
: INHERITED(program, errors, out)
110-
, fContext(*context)
111-
, fModifiers(*modifiers)
112-
, fDefaultLayout(MemoryLayout::k140_Standard)
113-
, fCapabilities(0)
114-
, fIdCount(1)
115-
, fBoolTrue(0)
116-
, fBoolFalse(0)
117-
, fSetupFragPosition(false)
118-
, fCurrentBlock(0)
119-
, fSynthetics(errors) {
107+
SPIRVCodeGenerator(const Context* context,
108+
const Program* program,
109+
ErrorReporter* errors,
110+
OutputStream* out)
111+
: INHERITED(program, errors, out)
112+
, fContext(*context)
113+
, fDefaultLayout(MemoryLayout::k140_Standard)
114+
, fCapabilities(0)
115+
, fIdCount(1)
116+
, fBoolTrue(0)
117+
, fBoolFalse(0)
118+
, fSetupFragPosition(false)
119+
, fCurrentBlock(0)
120+
, fSynthetics(errors) {
120121
this->setupIntrinsics();
121122
}
122123

@@ -367,7 +368,6 @@ class SPIRVCodeGenerator : public CodeGenerator {
367368
void writeGeometryShaderExecutionMode(SpvId entryPoint, OutputStream& out);
368369

369370
const Context& fContext;
370-
ModifiersPool& fModifiers;
371371
const MemoryLayout fDefaultLayout;
372372

373373
uint64_t fCapabilities;

src/sksl/ir/SkSLProgram.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ struct Program {
177177

178178
const std::vector<std::unique_ptr<ProgramElement>>& elements() const { return fElements; }
179179

180-
void finish() {
181-
fModifiers->finish();
182-
}
183-
184180
Kind fKind;
185181
std::unique_ptr<String> fSource;
186182
Settings fSettings;
@@ -195,6 +191,7 @@ struct Program {
195191
std::unique_ptr<ModifiersPool> fModifiers;
196192

197193
friend class Compiler;
194+
friend class SPIRVCodeGenerator; // fModifiers
198195
};
199196

200197
} // namespace SkSL

0 commit comments

Comments
 (0)