aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLSPIRVCodeGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-06-01 11:29:45 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-02 13:23:36 +0000
commit88bd8edcff23dc9cf31b664cba7ba73b235318b0 (patch)
treebda38d25837904f6e5320e3f54b91465a9aab3d9 /src/sksl/SkSLSPIRVCodeGenerator.cpp
parentec4400bfe34bbb90eaceaae168b2c6edf9aca4d9 (diff)
Fixed an issue with sksl variable declarations
There was an issue where multiple variables defined in the same declaration were not being sequenced appropriately during analysis, so 'int x = 0, y = x + 1' would report that x was undefined. Bug: skia: Change-Id: I882f7e216467306f6a6013a0a34aac30a4c60744 Reviewed-on: https://skia-review.googlesource.com/18313 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLSPIRVCodeGenerator.cpp')
-rw-r--r--src/sksl/SkSLSPIRVCodeGenerator.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 9cc25b90fe..20d292fd67 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -2603,7 +2603,7 @@ SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclarations& decl,
OutputStream& out) {
for (size_t i = 0; i < decl.fVars.size(); i++) {
- const VarDeclaration& varDecl = *decl.fVars[i];
+ const VarDeclaration& varDecl = (VarDeclaration&) *decl.fVars[i];
const Variable* var = varDecl.fVar;
// These haven't been implemented in our SPIR-V generator yet and we only currently use them
// in the OpenGL backend.
@@ -2665,8 +2665,9 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
}
void SPIRVCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, OutputStream& out) {
- for (const auto& varDecl : decl.fVars) {
- const Variable* var = varDecl->fVar;
+ for (const auto& stmt : decl.fVars) {
+ VarDeclaration& varDecl = (VarDeclaration&) *stmt;
+ const Variable* var = varDecl.fVar;
// These haven't been implemented in our SPIR-V generator yet and we only currently use them
// in the OpenGL backend.
ASSERT(!(var->fModifiers.fFlags & (Modifiers::kReadOnly_Flag |
@@ -2679,8 +2680,8 @@ void SPIRVCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, Outpu
SpvId type = this->getPointerType(var->fType, SpvStorageClassFunction);
this->writeInstruction(SpvOpVariable, type, id, SpvStorageClassFunction, fVariableBuffer);
this->writeInstruction(SpvOpName, id, var->fName.c_str(), fNameBuffer);
- if (varDecl->fValue) {
- SpvId value = this->writeExpression(*varDecl->fValue, out);
+ if (varDecl.fValue) {
+ SpvId value = this->writeExpression(*varDecl.fValue, out);
this->writeInstruction(SpvOpStore, id, value, out);
}
}