fixed SPIR-V global initializer ordering

Bug: skia:8649
Change-Id: I737ae2ef0b13511332f9b480a1cb5cb73320d22a
Reviewed-on: https://skia-review.googlesource.com/c/179880
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Ethan Nicholas 2018-12-21 14:50:42 -05:00 committed by Skia Commit-Bot
parent b49d68c230
commit 8eb64d3be5

View File

@ -2512,12 +2512,12 @@ SpvId SPIRVCodeGenerator::writeFunction(const FunctionDefinition& f, OutputStrea
fVariableBuffer.reset();
SpvId result = this->writeFunctionStart(f.fDeclaration, out);
this->writeLabel(this->nextId(), out);
if (f.fDeclaration.fName == "main") {
write_stringstream(fGlobalInitializersBuffer, out);
}
StringStream bodyBuffer;
this->writeBlock((Block&) *f.fBody, bodyBuffer);
write_stringstream(fVariableBuffer, out);
if (f.fDeclaration.fName == "main") {
write_stringstream(fGlobalInitializersBuffer, out);
}
write_stringstream(bodyBuffer, out);
if (fCurrentBlock) {
if (f.fDeclaration.fReturnType == *fContext.fVoid_Type) {