diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2018-04-27 10:36:31 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-27 15:52:22 +0000 |
commit | be850adc53e2b2b6397df6b2278802f2354f8204 (patch) | |
tree | b78f8d6c5439679f70dd5b4c73b43a891179755b | |
parent | 0c51c2134379dfc81473a135b9bdf02fa383bcde (diff) |
workaround for Intel OpCompositeConstruct bug
The SPIR-V spec permits constructing a vector from mixed vectors and
scalars, e.g. vec3(vec2, float). Intel's Vulkan driver does not handle
this correctly. We already have a workaround in place for vector
construction (writing the code as vec3(vec2.x, vec2.y, float) instead),
but missed that matrix construction can produce the same problem, as
each column requires a vector to be constructed for it. This CL extends
the workaround to handle matrix construction as well.
Bug: skia:7851
Change-Id: I0fe5d300ec7ad5db87bcc6662cf8371bcd6deed8
Reviewed-on: https://skia-review.googlesource.com/124321
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
-rw-r--r-- | src/sksl/SkSLSPIRVCodeGenerator.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp index c5a5d2c303..e1488e8c2a 100644 --- a/src/sksl/SkSLSPIRVCodeGenerator.cpp +++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp @@ -1247,7 +1247,17 @@ SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, OutputStr ASSERT(currentCount == 0); columnIds.push_back(arguments[i]); } else { - currentColumn.push_back(arguments[i]); + if (c.fArguments[i]->fType.columns() == 1) { + currentColumn.push_back(arguments[i]); + } else { + SpvId componentType = this->getType(c.fArguments[i]->fType.componentType()); + for (int j = 0; j < c.fArguments[j]->fType.columns(); ++j) { + SpvId swizzle = this->nextId(); + this->writeInstruction(SpvOpCompositeExtract, componentType, swizzle, + arguments[i], j, out); + currentColumn.push_back(swizzle); + } + } currentCount += c.fArguments[i]->fType.columns(); if (currentCount == rows) { currentCount = 0; |