| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkSLSPIRVCodeGenerator.h" | 8 #include "SkSLSPIRVCodeGenerator.h" |
| 9 | 9 |
| 10 #include "string.h" | 10 #include "string.h" |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 if (fCapabilities & bit) { | 968 if (fCapabilities & bit) { |
| 969 this->writeInstruction(SpvOpCapability, (SpvId) i, out); | 969 this->writeInstruction(SpvOpCapability, (SpvId) i, out); |
| 970 } | 970 } |
| 971 } | 971 } |
| 972 } | 972 } |
| 973 | 973 |
| 974 SpvId SPIRVCodeGenerator::nextId() { | 974 SpvId SPIRVCodeGenerator::nextId() { |
| 975 return fIdCount++; | 975 return fIdCount++; |
| 976 } | 976 } |
| 977 | 977 |
| 978 void SPIRVCodeGenerator::writeStruct(const Type& type, SpvId resultId) { | 978 void SPIRVCodeGenerator::writeStruct(const Type& type, const MemoryLayout& layou
t, SpvId resultId) { |
| 979 this->writeInstruction(SpvOpName, resultId, type.name().c_str(), fNameBuffer
); | 979 this->writeInstruction(SpvOpName, resultId, type.name().c_str(), fNameBuffer
); |
| 980 // go ahead and write all of the field types, so we don't inadvertently writ
e them while we're | 980 // go ahead and write all of the field types, so we don't inadvertently writ
e them while we're |
| 981 // in the middle of writing the struct instruction | 981 // in the middle of writing the struct instruction |
| 982 std::vector<SpvId> types; | 982 std::vector<SpvId> types; |
| 983 for (const auto& f : type.fields()) { | 983 for (const auto& f : type.fields()) { |
| 984 types.push_back(this->getType(*f.fType)); | 984 types.push_back(this->getType(*f.fType, layout)); |
| 985 } | 985 } |
| 986 this->writeOpCode(SpvOpTypeStruct, 2 + (int32_t) types.size(), fConstantBuff
er); | 986 this->writeOpCode(SpvOpTypeStruct, 2 + (int32_t) types.size(), fConstantBuff
er); |
| 987 this->writeWord(resultId, fConstantBuffer); | 987 this->writeWord(resultId, fConstantBuffer); |
| 988 for (SpvId id : types) { | 988 for (SpvId id : types) { |
| 989 this->writeWord(id, fConstantBuffer); | 989 this->writeWord(id, fConstantBuffer); |
| 990 } | 990 } |
| 991 size_t offset = 0; | 991 size_t offset = 0; |
| 992 for (int32_t i = 0; i < (int32_t) type.fields().size(); i++) { | 992 for (int32_t i = 0; i < (int32_t) type.fields().size(); i++) { |
| 993 size_t size = type.fields()[i].fType->size(); | 993 size_t size = layout.size(*type.fields()[i].fType); |
| 994 size_t alignment = type.fields()[i].fType->alignment(); | 994 size_t alignment = layout.alignment(*type.fields()[i].fType); |
| 995 size_t mod = offset % alignment; | 995 size_t mod = offset % alignment; |
| 996 if (mod != 0) { | 996 if (mod != 0) { |
| 997 offset += alignment - mod; | 997 offset += alignment - mod; |
| 998 } | 998 } |
| 999 this->writeInstruction(SpvOpMemberName, resultId, i, type.fields()[i].fN
ame.c_str(), | 999 this->writeInstruction(SpvOpMemberName, resultId, i, type.fields()[i].fN
ame.c_str(), |
| 1000 fNameBuffer); | 1000 fNameBuffer); |
| 1001 this->writeLayout(type.fields()[i].fModifiers.fLayout, resultId, i); | 1001 this->writeLayout(type.fields()[i].fModifiers.fLayout, resultId, i); |
| 1002 if (type.fields()[i].fModifiers.fLayout.fBuiltin < 0) { | 1002 if (type.fields()[i].fModifiers.fLayout.fBuiltin < 0) { |
| 1003 this->writeInstruction(SpvOpMemberDecorate, resultId, (SpvId) i, Spv
DecorationOffset, | 1003 this->writeInstruction(SpvOpMemberDecorate, resultId, (SpvId) i, Spv
DecorationOffset, |
| 1004 (SpvId) offset, fDecorationBuffer); | 1004 (SpvId) offset, fDecorationBuffer); |
| 1005 } | 1005 } |
| 1006 if (type.fields()[i].fType->kind() == Type::kMatrix_Kind) { | 1006 if (type.fields()[i].fType->kind() == Type::kMatrix_Kind) { |
| 1007 this->writeInstruction(SpvOpMemberDecorate, resultId, i, SpvDecorati
onColMajor, | 1007 this->writeInstruction(SpvOpMemberDecorate, resultId, i, SpvDecorati
onColMajor, |
| 1008 fDecorationBuffer); | 1008 fDecorationBuffer); |
| 1009 this->writeInstruction(SpvOpMemberDecorate, resultId, i, SpvDecorati
onMatrixStride, | 1009 this->writeInstruction(SpvOpMemberDecorate, resultId, i, SpvDecorati
onMatrixStride, |
| 1010 (SpvId) type.fields()[i].fType->stride(), fDe
corationBuffer); | 1010 (SpvId) layout.stride(*type.fields()[i].fType
), |
| 1011 fDecorationBuffer); |
| 1011 } | 1012 } |
| 1012 offset += size; | 1013 offset += size; |
| 1013 Type::Kind kind = type.fields()[i].fType->kind(); | 1014 Type::Kind kind = type.fields()[i].fType->kind(); |
| 1014 if ((kind == Type::kArray_Kind || kind == Type::kStruct_Kind) && offset
% alignment != 0) { | 1015 if ((kind == Type::kArray_Kind || kind == Type::kStruct_Kind) && offset
% alignment != 0) { |
| 1015 offset += alignment - offset % alignment; | 1016 offset += alignment - offset % alignment; |
| 1016 } | 1017 } |
| 1017 } | 1018 } |
| 1018 } | 1019 } |
| 1019 | 1020 |
| 1020 SpvId SPIRVCodeGenerator::getType(const Type& type) { | 1021 SpvId SPIRVCodeGenerator::getType(const Type& type) { |
| 1021 auto entry = fTypeMap.find(type.name()); | 1022 return this->getType(type, fDefaultLayout); |
| 1023 } |
| 1024 |
| 1025 SpvId SPIRVCodeGenerator::getType(const Type& type, const MemoryLayout& layout)
{ |
| 1026 SkString key = type.name() + to_string((int) layout.fStd); |
| 1027 auto entry = fTypeMap.find(key); |
| 1022 if (entry == fTypeMap.end()) { | 1028 if (entry == fTypeMap.end()) { |
| 1023 SpvId result = this->nextId(); | 1029 SpvId result = this->nextId(); |
| 1024 switch (type.kind()) { | 1030 switch (type.kind()) { |
| 1025 case Type::kScalar_Kind: | 1031 case Type::kScalar_Kind: |
| 1026 if (type == *fContext.fBool_Type) { | 1032 if (type == *fContext.fBool_Type) { |
| 1027 this->writeInstruction(SpvOpTypeBool, result, fConstantBuffe
r); | 1033 this->writeInstruction(SpvOpTypeBool, result, fConstantBuffe
r); |
| 1028 } else if (type == *fContext.fInt_Type) { | 1034 } else if (type == *fContext.fInt_Type) { |
| 1029 this->writeInstruction(SpvOpTypeInt, result, 32, 1, fConstan
tBuffer); | 1035 this->writeInstruction(SpvOpTypeInt, result, 32, 1, fConstan
tBuffer); |
| 1030 } else if (type == *fContext.fUInt_Type) { | 1036 } else if (type == *fContext.fUInt_Type) { |
| 1031 this->writeInstruction(SpvOpTypeInt, result, 32, 0, fConstan
tBuffer); | 1037 this->writeInstruction(SpvOpTypeInt, result, 32, 0, fConstan
tBuffer); |
| 1032 } else if (type == *fContext.fFloat_Type) { | 1038 } else if (type == *fContext.fFloat_Type) { |
| 1033 this->writeInstruction(SpvOpTypeFloat, result, 32, fConstant
Buffer); | 1039 this->writeInstruction(SpvOpTypeFloat, result, 32, fConstant
Buffer); |
| 1034 } else if (type == *fContext.fDouble_Type) { | 1040 } else if (type == *fContext.fDouble_Type) { |
| 1035 this->writeInstruction(SpvOpTypeFloat, result, 64, fConstant
Buffer); | 1041 this->writeInstruction(SpvOpTypeFloat, result, 64, fConstant
Buffer); |
| 1036 } else { | 1042 } else { |
| 1037 ASSERT(false); | 1043 ASSERT(false); |
| 1038 } | 1044 } |
| 1039 break; | 1045 break; |
| 1040 case Type::kVector_Kind: | 1046 case Type::kVector_Kind: |
| 1041 this->writeInstruction(SpvOpTypeVector, result, | 1047 this->writeInstruction(SpvOpTypeVector, result, |
| 1042 this->getType(type.componentType()), | 1048 this->getType(type.componentType(), layou
t), |
| 1043 type.columns(), fConstantBuffer); | 1049 type.columns(), fConstantBuffer); |
| 1044 break; | 1050 break; |
| 1045 case Type::kMatrix_Kind: | 1051 case Type::kMatrix_Kind: |
| 1046 this->writeInstruction(SpvOpTypeMatrix, result, | 1052 this->writeInstruction(SpvOpTypeMatrix, result, |
| 1047 this->getType(index_type(fContext, type))
, | 1053 this->getType(index_type(fContext, type),
layout), |
| 1048 type.columns(), fConstantBuffer); | 1054 type.columns(), fConstantBuffer); |
| 1049 break; | 1055 break; |
| 1050 case Type::kStruct_Kind: | 1056 case Type::kStruct_Kind: |
| 1051 this->writeStruct(type, result); | 1057 this->writeStruct(type, layout, result); |
| 1052 break; | 1058 break; |
| 1053 case Type::kArray_Kind: { | 1059 case Type::kArray_Kind: { |
| 1054 if (type.columns() > 0) { | 1060 if (type.columns() > 0) { |
| 1055 IntLiteral count(fContext, Position(), type.columns()); | 1061 IntLiteral count(fContext, Position(), type.columns()); |
| 1056 this->writeInstruction(SpvOpTypeArray, result, | 1062 this->writeInstruction(SpvOpTypeArray, result, |
| 1057 this->getType(type.componentType()), | 1063 this->getType(type.componentType(), l
ayout), |
| 1058 this->writeIntLiteral(count), fConsta
ntBuffer); | 1064 this->writeIntLiteral(count), fConsta
ntBuffer); |
| 1059 this->writeInstruction(SpvOpDecorate, result, SpvDecorationA
rrayStride, | 1065 this->writeInstruction(SpvOpDecorate, result, SpvDecorationA
rrayStride, |
| 1060 (int32_t) type.stride(), fDecorationB
uffer); | 1066 (int32_t) layout.stride(type), |
| 1067 fDecorationBuffer); |
| 1061 } else { | 1068 } else { |
| 1062 ABORT("runtime-sized arrays are not yet supported"); | 1069 ABORT("runtime-sized arrays are not yet supported"); |
| 1063 this->writeInstruction(SpvOpTypeRuntimeArray, result, | 1070 this->writeInstruction(SpvOpTypeRuntimeArray, result, |
| 1064 this->getType(type.componentType()),
fConstantBuffer); | 1071 this->getType(type.componentType(), l
ayout), |
| 1072 fConstantBuffer); |
| 1065 } | 1073 } |
| 1066 break; | 1074 break; |
| 1067 } | 1075 } |
| 1068 case Type::kSampler_Kind: { | 1076 case Type::kSampler_Kind: { |
| 1069 SpvId image = result; | 1077 SpvId image = result; |
| 1070 if (SpvDimSubpassData != type.dimensions()) { | 1078 if (SpvDimSubpassData != type.dimensions()) { |
| 1071 image = this->nextId(); | 1079 image = this->nextId(); |
| 1072 } | 1080 } |
| 1073 this->writeInstruction(SpvOpTypeImage, image, this->getType(*fCo
ntext.fFloat_Type), | 1081 this->writeInstruction(SpvOpTypeImage, image, |
| 1082 this->getType(*fContext.fFloat_Type, layo
ut), |
| 1074 type.dimensions(), type.isDepth(), type.i
sArrayed(), | 1083 type.dimensions(), type.isDepth(), type.i
sArrayed(), |
| 1075 type.isMultisampled(), type.isSampled() ?
1 : 2, | 1084 type.isMultisampled(), type.isSampled() ?
1 : 2, |
| 1076 SpvImageFormatUnknown, fConstantBuffer); | 1085 SpvImageFormatUnknown, fConstantBuffer); |
| 1077 if (SpvDimSubpassData != type.dimensions()) { | 1086 if (SpvDimSubpassData != type.dimensions()) { |
| 1078 this->writeInstruction(SpvOpTypeSampledImage, result, image,
fConstantBuffer); | 1087 this->writeInstruction(SpvOpTypeSampledImage, result, image,
fConstantBuffer); |
| 1079 } | 1088 } |
| 1080 break; | 1089 break; |
| 1081 } | 1090 } |
| 1082 default: | 1091 default: |
| 1083 if (type == *fContext.fVoid_Type) { | 1092 if (type == *fContext.fVoid_Type) { |
| 1084 this->writeInstruction(SpvOpTypeVoid, result, fConstantBuffe
r); | 1093 this->writeInstruction(SpvOpTypeVoid, result, fConstantBuffe
r); |
| 1085 } else { | 1094 } else { |
| 1086 ABORT("invalid type: %s", type.description().c_str()); | 1095 ABORT("invalid type: %s", type.description().c_str()); |
| 1087 } | 1096 } |
| 1088 } | 1097 } |
| 1089 fTypeMap[type.name()] = result; | 1098 fTypeMap[key] = result; |
| 1090 return result; | 1099 return result; |
| 1091 } | 1100 } |
| 1092 return entry->second; | 1101 return entry->second; |
| 1093 } | 1102 } |
| 1094 | 1103 |
| 1095 SpvId SPIRVCodeGenerator::getFunctionType(const FunctionDeclaration& function) { | 1104 SpvId SPIRVCodeGenerator::getFunctionType(const FunctionDeclaration& function) { |
| 1096 SkString key = function.fReturnType.description() + "("; | 1105 SkString key = function.fReturnType.description() + "("; |
| 1097 SkString separator; | 1106 SkString separator; |
| 1098 for (size_t i = 0; i < function.fParameters.size(); i++) { | 1107 for (size_t i = 0; i < function.fParameters.size(); i++) { |
| 1099 key += separator; | 1108 key += separator; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 this->writeWord(returnType, fConstantBuffer); | 1151 this->writeWord(returnType, fConstantBuffer); |
| 1143 for (SpvId id : parameterTypes) { | 1152 for (SpvId id : parameterTypes) { |
| 1144 this->writeWord(id, fConstantBuffer); | 1153 this->writeWord(id, fConstantBuffer); |
| 1145 } | 1154 } |
| 1146 fTypeMap[key] = result; | 1155 fTypeMap[key] = result; |
| 1147 return result; | 1156 return result; |
| 1148 } | 1157 } |
| 1149 return entry->second; | 1158 return entry->second; |
| 1150 } | 1159 } |
| 1151 | 1160 |
| 1152 SpvId SPIRVCodeGenerator::getPointerType(const Type& type, | 1161 SpvId SPIRVCodeGenerator::getPointerType(const Type& type, SpvStorageClass_ stor
ageClass) { |
| 1162 return this->getPointerType(type, fDefaultLayout, storageClass); |
| 1163 } |
| 1164 |
| 1165 SpvId SPIRVCodeGenerator::getPointerType(const Type& type, const MemoryLayout& l
ayout, |
| 1153 SpvStorageClass_ storageClass) { | 1166 SpvStorageClass_ storageClass) { |
| 1154 SkString key = type.description() + "*" + to_string(storageClass); | 1167 SkString key = type.description() + "*" + to_string(layout.fStd) + to_string
(storageClass); |
| 1155 auto entry = fTypeMap.find(key); | 1168 auto entry = fTypeMap.find(key); |
| 1156 if (entry == fTypeMap.end()) { | 1169 if (entry == fTypeMap.end()) { |
| 1157 SpvId result = this->nextId(); | 1170 SpvId result = this->nextId(); |
| 1158 this->writeInstruction(SpvOpTypePointer, result, storageClass, | 1171 this->writeInstruction(SpvOpTypePointer, result, storageClass, |
| 1159 this->getType(type), fConstantBuffer); | 1172 this->getType(type), fConstantBuffer); |
| 1160 fTypeMap[key] = result; | 1173 fTypeMap[key] = result; |
| 1161 return result; | 1174 return result; |
| 1162 } | 1175 } |
| 1163 return entry->second; | 1176 return entry->second; |
| 1164 } | 1177 } |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 return this->writeVectorConstructor(c, out); | 1596 return this->writeVectorConstructor(c, out); |
| 1584 case Type::kMatrix_Kind: | 1597 case Type::kMatrix_Kind: |
| 1585 return this->writeMatrixConstructor(c, out); | 1598 return this->writeMatrixConstructor(c, out); |
| 1586 default: | 1599 default: |
| 1587 ABORT("unsupported constructor: %s", c.description().c_str()); | 1600 ABORT("unsupported constructor: %s", c.description().c_str()); |
| 1588 } | 1601 } |
| 1589 } | 1602 } |
| 1590 | 1603 |
| 1591 SpvStorageClass_ get_storage_class(const Modifiers& modifiers) { | 1604 SpvStorageClass_ get_storage_class(const Modifiers& modifiers) { |
| 1592 if (modifiers.fFlags & Modifiers::kIn_Flag) { | 1605 if (modifiers.fFlags & Modifiers::kIn_Flag) { |
| 1606 ASSERT(!modifiers.fLayout.fPushConstant); |
| 1593 return SpvStorageClassInput; | 1607 return SpvStorageClassInput; |
| 1594 } else if (modifiers.fFlags & Modifiers::kOut_Flag) { | 1608 } else if (modifiers.fFlags & Modifiers::kOut_Flag) { |
| 1609 ASSERT(!modifiers.fLayout.fPushConstant); |
| 1595 return SpvStorageClassOutput; | 1610 return SpvStorageClassOutput; |
| 1596 } else if (modifiers.fFlags & Modifiers::kUniform_Flag) { | 1611 } else if (modifiers.fFlags & Modifiers::kUniform_Flag) { |
| 1612 if (modifiers.fLayout.fPushConstant) { |
| 1613 return SpvStorageClassPushConstant; |
| 1614 } |
| 1597 return SpvStorageClassUniform; | 1615 return SpvStorageClassUniform; |
| 1598 } else { | 1616 } else { |
| 1599 return SpvStorageClassFunction; | 1617 return SpvStorageClassFunction; |
| 1600 } | 1618 } |
| 1601 } | 1619 } |
| 1602 | 1620 |
| 1603 SpvStorageClass_ get_storage_class(const Expression& expr) { | 1621 SpvStorageClass_ get_storage_class(const Expression& expr) { |
| 1604 switch (expr.fKind) { | 1622 switch (expr.fKind) { |
| 1605 case Expression::kVariableReference_Kind: | 1623 case Expression::kVariableReference_Kind: |
| 1606 return get_storage_class(((VariableReference&) expr).fVariable.fModi
fiers); | 1624 return get_storage_class(((VariableReference&) expr).fVariable.fModi
fiers); |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 this->writeInstruction(SpvOpDecorate, target, member, SpvDecorationInput
AttachmentIndex, | 2415 this->writeInstruction(SpvOpDecorate, target, member, SpvDecorationInput
AttachmentIndex, |
| 2398 layout.fInputAttachmentIndex, fDecorationBuffer); | 2416 layout.fInputAttachmentIndex, fDecorationBuffer); |
| 2399 } | 2417 } |
| 2400 if (layout.fBuiltin >= 0) { | 2418 if (layout.fBuiltin >= 0) { |
| 2401 this->writeInstruction(SpvOpMemberDecorate, target, member, SpvDecoratio
nBuiltIn, | 2419 this->writeInstruction(SpvOpMemberDecorate, target, member, SpvDecoratio
nBuiltIn, |
| 2402 layout.fBuiltin, fDecorationBuffer); | 2420 layout.fBuiltin, fDecorationBuffer); |
| 2403 } | 2421 } |
| 2404 } | 2422 } |
| 2405 | 2423 |
| 2406 SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) { | 2424 SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) { |
| 2407 SpvId type = this->getType(intf.fVariable.fType); | 2425 MemoryLayout layout = intf.fVariable.fModifiers.fLayout.fPushConstant ? |
| 2426 MemoryLayout(MemoryLayout::k430_Standard) : |
| 2427 fDefaultLayout; |
| 2428 SpvId type = this->getType(intf.fVariable.fType, layout); |
| 2408 SpvId result = this->nextId(); | 2429 SpvId result = this->nextId(); |
| 2409 this->writeInstruction(SpvOpDecorate, type, SpvDecorationBlock, fDecorationB
uffer); | 2430 this->writeInstruction(SpvOpDecorate, type, SpvDecorationBlock, fDecorationB
uffer); |
| 2410 SpvStorageClass_ storageClass = get_storage_class(intf.fVariable.fModifiers)
; | 2431 SpvStorageClass_ storageClass = get_storage_class(intf.fVariable.fModifiers)
; |
| 2411 SpvId ptrType = this->nextId(); | 2432 SpvId ptrType = this->nextId(); |
| 2412 this->writeInstruction(SpvOpTypePointer, ptrType, storageClass, type, fConst
antBuffer); | 2433 this->writeInstruction(SpvOpTypePointer, ptrType, storageClass, type, fConst
antBuffer); |
| 2413 this->writeInstruction(SpvOpVariable, ptrType, result, storageClass, fConsta
ntBuffer); | 2434 this->writeInstruction(SpvOpVariable, ptrType, result, storageClass, fConsta
ntBuffer); |
| 2414 this->writeLayout(intf.fVariable.fModifiers.fLayout, result); | 2435 this->writeLayout(intf.fVariable.fModifiers.fLayout, result); |
| 2415 fVariableMap[&intf.fVariable] = result; | 2436 fVariableMap[&intf.fVariable] = result; |
| 2416 return result; | 2437 return result; |
| 2417 } | 2438 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 } | 2474 } |
| 2454 SpvId id = this->nextId(); | 2475 SpvId id = this->nextId(); |
| 2455 fVariableMap[var] = id; | 2476 fVariableMap[var] = id; |
| 2456 SpvId type = this->getPointerType(var->fType, storageClass); | 2477 SpvId type = this->getPointerType(var->fType, storageClass); |
| 2457 this->writeInstruction(SpvOpVariable, type, id, storageClass, fConstantB
uffer); | 2478 this->writeInstruction(SpvOpVariable, type, id, storageClass, fConstantB
uffer); |
| 2458 this->writeInstruction(SpvOpName, id, var->fName.c_str(), fNameBuffer); | 2479 this->writeInstruction(SpvOpName, id, var->fName.c_str(), fNameBuffer); |
| 2459 if (var->fType.kind() == Type::kMatrix_Kind) { | 2480 if (var->fType.kind() == Type::kMatrix_Kind) { |
| 2460 this->writeInstruction(SpvOpMemberDecorate, id, (SpvId) i, SpvDecora
tionColMajor, | 2481 this->writeInstruction(SpvOpMemberDecorate, id, (SpvId) i, SpvDecora
tionColMajor, |
| 2461 fDecorationBuffer); | 2482 fDecorationBuffer); |
| 2462 this->writeInstruction(SpvOpMemberDecorate, id, (SpvId) i, SpvDecora
tionMatrixStride, | 2483 this->writeInstruction(SpvOpMemberDecorate, id, (SpvId) i, SpvDecora
tionMatrixStride, |
| 2463 (SpvId) var->fType.stride(), fDecorationBuffe
r); | 2484 (SpvId) fDefaultLayout.stride(var->fType), fD
ecorationBuffer); |
| 2464 } | 2485 } |
| 2465 if (varDecl.fValue) { | 2486 if (varDecl.fValue) { |
| 2466 ASSERT(!fCurrentBlock); | 2487 ASSERT(!fCurrentBlock); |
| 2467 fCurrentBlock = -1; | 2488 fCurrentBlock = -1; |
| 2468 SpvId value = this->writeExpression(*varDecl.fValue, fGlobalInitiali
zersBuffer); | 2489 SpvId value = this->writeExpression(*varDecl.fValue, fGlobalInitiali
zersBuffer); |
| 2469 this->writeInstruction(SpvOpStore, id, value, fGlobalInitializersBuf
fer); | 2490 this->writeInstruction(SpvOpStore, id, value, fGlobalInitializersBuf
fer); |
| 2470 fCurrentBlock = 0; | 2491 fCurrentBlock = 0; |
| 2471 } | 2492 } |
| 2472 this->writeLayout(var->fModifiers.fLayout, id); | 2493 this->writeLayout(var->fModifiers.fLayout, id); |
| 2473 } | 2494 } |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2694 this->writeWord(SpvVersion, out); | 2715 this->writeWord(SpvVersion, out); |
| 2695 this->writeWord(SKSL_MAGIC, out); | 2716 this->writeWord(SKSL_MAGIC, out); |
| 2696 SkDynamicMemoryWStream buffer; | 2717 SkDynamicMemoryWStream buffer; |
| 2697 this->writeInstructions(program, buffer); | 2718 this->writeInstructions(program, buffer); |
| 2698 this->writeWord(fIdCount, out); | 2719 this->writeWord(fIdCount, out); |
| 2699 this->writeWord(0, out); // reserved, always zero | 2720 this->writeWord(0, out); // reserved, always zero |
| 2700 write_data(*buffer.detachAsData(), out); | 2721 write_data(*buffer.detachAsData(), out); |
| 2701 } | 2722 } |
| 2702 | 2723 |
| 2703 } | 2724 } |
| OLD | NEW |