SPIR-V output now always includes DescriptorSet for uniforms
Bug: skia:
Change-Id: I6a31d6ec51d59340ef738c2bc4a8a88a261bef14
Reviewed-on: https://skia-review.googlesource.com/114865
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
(cherry picked from commit 8d2ba44c9cba790cfd8ace80de9e15972bccbe5d)
Reviewed-on: https://skia-review.googlesource.com/115020
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 60a486e..c2eae89 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -2446,9 +2446,9 @@
bool isBuffer = (0 != (intf.fVariable.fModifiers.fFlags & Modifiers::kBuffer_Flag));
bool pushConstant = (0 != (intf.fVariable.fModifiers.fLayout.fFlags &
Layout::kPushConstant_Flag));
- MemoryLayout layout = (pushConstant || isBuffer) ?
- MemoryLayout(MemoryLayout::k430_Standard) :
- fDefaultLayout;
+ MemoryLayout memoryLayout = (pushConstant || isBuffer) ?
+ MemoryLayout(MemoryLayout::k430_Standard) :
+ fDefaultLayout;
SpvId result = this->nextId();
const Type* type = &intf.fVariable.fType;
if (fProgram.fInputs.fRTHeight) {
@@ -2460,7 +2460,7 @@
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, layout);
+ SpvId typeId = this->getType(*type, memoryLayout);
if (intf.fVariable.fModifiers.fFlags & Modifiers::kBuffer_Flag) {
this->writeInstruction(SpvOpDecorate, typeId, SpvDecorationBufferBlock, fDecorationBuffer);
} else {
@@ -2470,7 +2470,11 @@
SpvId ptrType = this->nextId();
this->writeInstruction(SpvOpTypePointer, ptrType, storageClass, typeId, fConstantBuffer);
this->writeInstruction(SpvOpVariable, ptrType, result, storageClass, fConstantBuffer);
- this->writeLayout(intf.fVariable.fModifiers.fLayout, result);
+ Layout layout = intf.fVariable.fModifiers.fLayout;
+ if (intf.fVariable.fModifiers.fFlags & Modifiers::kUniform_Flag && layout.fSet == -1) {
+ layout.fSet = 0;
+ }
+ this->writeLayout(layout, result);
fVariableMap[&intf.fVariable] = result;
if (fProgram.fInputs.fRTHeight) {
delete type;