diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-07-18 15:54:59 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-24 14:46:48 +0000 |
commit | bd553225faf42476131593d9fe0e316bb560437c (patch) | |
tree | ba3a24c5fda1668d97eed1d179cb78b717e6b208 | |
parent | dc0e1c3e5945019eaf14f188fcb1458d54ae3d77 (diff) |
SPIR-V array constructors
Bug: skia:
Change-Id: I88c896e126c764fc07a7e5a5adace1651070a494
Reviewed-on: https://skia-review.googlesource.com/24243
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
-rw-r--r-- | src/sksl/SkSLSPIRVCodeGenerator.cpp | 20 | ||||
-rw-r--r-- | src/sksl/SkSLSPIRVCodeGenerator.h | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp index 8c606ae456..c07a6db67e 100644 --- a/src/sksl/SkSLSPIRVCodeGenerator.cpp +++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp @@ -1760,6 +1760,24 @@ SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStr return result; } +SpvId SPIRVCodeGenerator::writeArrayConstructor(const Constructor& c, OutputStream& out) { + ASSERT(c.fType.kind() == Type::kArray_Kind); + // go ahead and write the arguments so we don't try to write new instructions in the middle of + // an instruction + std::vector<SpvId> arguments; + for (size_t i = 0; i < c.fArguments.size(); i++) { + arguments.push_back(this->writeExpression(*c.fArguments[i], out)); + } + SpvId result = this->nextId(); + this->writeOpCode(SpvOpCompositeConstruct, 3 + (int32_t) c.fArguments.size(), out); + this->writeWord(this->getType(c.fType), out); + this->writeWord(result, out); + for (SpvId id : arguments) { + this->writeWord(id, out); + } + return result; +} + SpvId SPIRVCodeGenerator::writeConstructor(const Constructor& c, OutputStream& out) { if (c.fType == *fContext.fFloat_Type) { return this->writeFloatConstructor(c, out); @@ -1773,6 +1791,8 @@ SpvId SPIRVCodeGenerator::writeConstructor(const Constructor& c, OutputStream& o return this->writeVectorConstructor(c, out); case Type::kMatrix_Kind: return this->writeMatrixConstructor(c, out); + case Type::kArray_Kind: + return this->writeArrayConstructor(c, out); default: ABORT("unsupported constructor: %s", c.description().c_str()); } diff --git a/src/sksl/SkSLSPIRVCodeGenerator.h b/src/sksl/SkSLSPIRVCodeGenerator.h index 4500abbff1..5db4bb4dac 100644 --- a/src/sksl/SkSLSPIRVCodeGenerator.h +++ b/src/sksl/SkSLSPIRVCodeGenerator.h @@ -173,6 +173,8 @@ private: SpvId writeVectorConstructor(const Constructor& c, OutputStream& out); + SpvId writeArrayConstructor(const Constructor& c, OutputStream& out); + SpvId writeConstructor(const Constructor& c, OutputStream& out); SpvId writeFieldAccess(const FieldAccess& f, OutputStream& out); |