diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2018-05-03 16:20:41 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-04 11:04:06 +0000 |
commit | 5226b777edeef1b8168c9cf7f4fb34a0fdc606a1 (patch) | |
tree | fb4e96ed0e6724302bd2d14e7fbe8238cb994479 /src/sksl | |
parent | 452c90256c188f60bd20d918e5948d112261a0f4 (diff) |
fix for SPIR-V sk_in definition which was upsetting Intel NUC
Bug: skia:7852
Change-Id: Ife747f3531d19e69dc70c2e0b9a9c6cfe001da72
Reviewed-on: https://skia-review.googlesource.com/125743
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/sksl')
-rw-r--r-- | src/sksl/SkSLSPIRVCodeGenerator.cpp | 48 | ||||
-rw-r--r-- | src/sksl/SkSLSPIRVCodeGenerator.h | 1 | ||||
-rw-r--r-- | src/sksl/sksl_geom.inc | 2 |
3 files changed, 41 insertions, 10 deletions
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp index e1488e8c2a..1cbe4c0920 100644 --- a/src/sksl/SkSLSPIRVCodeGenerator.cpp +++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp @@ -500,6 +500,7 @@ SpvId SPIRVCodeGenerator::getType(const Type& rawType, const MemoryLayout& layou (int32_t) layout.stride(type), fDecorationBuffer); } else { + ASSERT(false); // we shouldn't have any runtime-sized arrays right now this->writeInstruction(SpvOpTypeRuntimeArray, result, this->getType(type.componentType(), layout), fConstantBuffer); @@ -1588,13 +1589,19 @@ std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const OutputStream& out) { switch (expr.fKind) { case Expression::kVariableReference_Kind: { + SpvId type; const Variable& var = ((VariableReference&) expr).fVariable; + if (var.fModifiers.fLayout.fBuiltin == SK_IN_BUILTIN) { + type = this->getType(Type("sk_in", Type::kArray_Kind, var.fType.componentType(), + fSkInCount)); + } else { + type = this->getType(expr.fType); + } auto entry = fVariableMap.find(&var); ASSERT(entry != fVariableMap.end()); - return std::unique_ptr<SPIRVCodeGenerator::LValue>(new PointerLValue( - *this, - entry->second, - this->getType(expr.fType))); + return std::unique_ptr<SPIRVCodeGenerator::LValue>(new PointerLValue(*this, + entry->second, + type)); } case Expression::kIndex_Kind: // fall through case Expression::kFieldAccess_Kind: { @@ -2505,7 +2512,24 @@ SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) { fields.emplace_back(Modifiers(), StringFragment(SKSL_RTHEIGHT_NAME), fContext.fFloat_Type.get()); type = new Type(type->fOffset, type->name(), fields); } - SpvId typeId = this->getType(*type, memoryLayout); + SpvId typeId; + if (intf.fVariable.fModifiers.fLayout.fBuiltin == SK_IN_BUILTIN) { + for (const auto& e : fProgram) { + if (e.fKind == ProgramElement::kModifiers_Kind) { + const Modifiers& m = ((ModifiersDeclaration&) e).fModifiers; + if (m.fFlags & Modifiers::kIn_Flag) { + if (m.fLayout.fInvocations != -1) { + fSkInCount = m.fLayout.fInvocations; + break; + } + } + } + } + typeId = this->getType(Type("sk_in", Type::kArray_Kind, intf.fVariable.fType.componentType(), + fSkInCount), memoryLayout); + } else { + typeId = this->getType(*type, memoryLayout); + } if (intf.fVariable.fModifiers.fFlags & Modifiers::kBuffer_Flag) { this->writeInstruction(SpvOpDecorate, typeId, SpvDecorationBufferBlock, fDecorationBuffer); } else { @@ -2583,7 +2607,14 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio } SpvId id = this->nextId(); fVariableMap[var] = id; - SpvId type = this->getPointerType(var->fType, storageClass); + SpvId type; + if (var->fModifiers.fLayout.fBuiltin == SK_IN_BUILTIN) { + type = this->getPointerType(Type("sk_in", Type::kArray_Kind, + var->fType.componentType(), fSkInCount), + storageClass); + } else { + type = this->getPointerType(var->fType, storageClass); + } this->writeInstruction(SpvOpVariable, type, id, storageClass, fConstantBuffer); this->writeInstruction(SpvOpName, id, var->fName, fNameBuffer); this->writePrecisionModifier(var->fModifiers, id); @@ -2870,6 +2901,7 @@ void SPIRVCodeGenerator::writeGeometryShaderExecutionMode(SpvId entryPoint, Outp if (m.fFlags & Modifiers::kIn_Flag) { if (m.fLayout.fInvocations != -1) { invocations = m.fLayout.fInvocations; + fSkInCount = invocations; } SpvId input; switch (m.fLayout.fPrimitive) { @@ -3000,9 +3032,7 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream& const Variable* var = entry.first; if (var->fStorage == Variable::kGlobal_Storage && ((var->fModifiers.fFlags & Modifiers::kIn_Flag) || - (var->fModifiers.fFlags & Modifiers::kOut_Flag)) && - var->fModifiers.fLayout.fBuiltin != SK_IN_BUILTIN && - var->fModifiers.fLayout.fBuiltin != SK_OUT_BUILTIN) { + (var->fModifiers.fFlags & Modifiers::kOut_Flag))) { interfaceVars.insert(entry.second); } } diff --git a/src/sksl/SkSLSPIRVCodeGenerator.h b/src/sksl/SkSLSPIRVCodeGenerator.h index 8f6dcd95c0..e7bec1e558 100644 --- a/src/sksl/SkSLSPIRVCodeGenerator.h +++ b/src/sksl/SkSLSPIRVCodeGenerator.h @@ -340,6 +340,7 @@ private: SpvId fRTHeightFieldIndex = (SpvId) -1; // holds variables synthesized during output, for lifetime purposes SymbolTable fSynthetics; + int fSkInCount = 1; friend class PointerLValue; friend class SwizzleLValue; diff --git a/src/sksl/sksl_geom.inc b/src/sksl/sksl_geom.inc index 90c6c83663..6d535d26a3 100644 --- a/src/sksl/sksl_geom.inc +++ b/src/sksl/sksl_geom.inc @@ -6,7 +6,7 @@ layout(builtin=10002) in sk_PerVertex { layout(builtin=0) float4 sk_Position; layout(builtin=1) float sk_PointSize; layout(builtin=3) float sk_ClipDistance[1]; -} sk_in[]; +} sk_in[1]; layout(builtin=10007) out sk_PerVertex { layout(builtin=0) float4 sk_Position; |