Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Unified Diff: src/sksl/SkSLSPIRVCodeGenerator.cpp

Issue 2509673002: Revert of added support for push_constant layout (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/SkSLSPIRVCodeGenerator.h ('k') | src/sksl/SkSLUtil.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/SkSLSPIRVCodeGenerator.cpp
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index b899e4fcbd4a98590c8e79fe26645fe931582a46..a4919686742f20c006b2a39f933e2aeb0184b228 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -968,13 +968,13 @@
return fIdCount++;
}
-void SPIRVCodeGenerator::writeStruct(const Type& type, const MemoryLayout& layout, SpvId resultId) {
+void SPIRVCodeGenerator::writeStruct(const Type& type, SpvId resultId) {
this->writeInstruction(SpvOpName, resultId, type.name().c_str(), fNameBuffer);
// go ahead and write all of the field types, so we don't inadvertently write them while we're
// in the middle of writing the struct instruction
std::vector<SpvId> types;
for (const auto& f : type.fields()) {
- types.push_back(this->getType(*f.fType, layout));
+ types.push_back(this->getType(*f.fType));
}
this->writeOpCode(SpvOpTypeStruct, 2 + (int32_t) types.size(), fConstantBuffer);
this->writeWord(resultId, fConstantBuffer);
@@ -983,8 +983,8 @@
}
size_t offset = 0;
for (int32_t i = 0; i < (int32_t) type.fields().size(); i++) {
- size_t size = layout.size(*type.fields()[i].fType);
- size_t alignment = layout.alignment(*type.fields()[i].fType);
+ size_t size = type.fields()[i].fType->size();
+ size_t alignment = type.fields()[i].fType->alignment();
size_t mod = offset % alignment;
if (mod != 0) {
offset += alignment - mod;
@@ -1000,8 +1000,7 @@
this->writeInstruction(SpvOpMemberDecorate, resultId, i, SpvDecorationColMajor,
fDecorationBuffer);
this->writeInstruction(SpvOpMemberDecorate, resultId, i, SpvDecorationMatrixStride,
- (SpvId) layout.stride(*type.fields()[i].fType),
- fDecorationBuffer);
+ (SpvId) type.fields()[i].fType->stride(), fDecorationBuffer);
}
offset += size;
Type::Kind kind = type.fields()[i].fType->kind();
@@ -1013,12 +1012,7 @@
}
SpvId SPIRVCodeGenerator::getType(const Type& type) {
- return this->getType(type, fDefaultLayout);
-}
-
-SpvId SPIRVCodeGenerator::getType(const Type& type, const MemoryLayout& layout) {
- std::string key = type.name() + to_string((int) layout.fStd);
- auto entry = fTypeMap.find(key);
+ auto entry = fTypeMap.find(type.name());
if (entry == fTypeMap.end()) {
SpvId result = this->nextId();
switch (type.kind()) {
@@ -1039,38 +1033,35 @@
break;
case Type::kVector_Kind:
this->writeInstruction(SpvOpTypeVector, result,
- this->getType(type.componentType(), layout),
+ this->getType(type.componentType()),
type.columns(), fConstantBuffer);
break;
case Type::kMatrix_Kind:
this->writeInstruction(SpvOpTypeMatrix, result,
- this->getType(index_type(fContext, type), layout),
+ this->getType(index_type(fContext, type)),
type.columns(), fConstantBuffer);
break;
case Type::kStruct_Kind:
- this->writeStruct(type, layout, result);
+ this->writeStruct(type, result);
break;
case Type::kArray_Kind: {
if (type.columns() > 0) {
IntLiteral count(fContext, Position(), type.columns());
this->writeInstruction(SpvOpTypeArray, result,
- this->getType(type.componentType(), layout),
+ this->getType(type.componentType()),
this->writeIntLiteral(count), fConstantBuffer);
this->writeInstruction(SpvOpDecorate, result, SpvDecorationArrayStride,
- (int32_t) layout.stride(type),
- fDecorationBuffer);
+ (int32_t) type.stride(), fDecorationBuffer);
} else {
ABORT("runtime-sized arrays are not yet supported");
this->writeInstruction(SpvOpTypeRuntimeArray, result,
- this->getType(type.componentType(), layout),
- fConstantBuffer);
+ this->getType(type.componentType()), fConstantBuffer);
}
break;
}
case Type::kSampler_Kind: {
SpvId image = this->nextId();
- this->writeInstruction(SpvOpTypeImage, image,
- this->getType(*fContext.fFloat_Type, layout),
+ this->writeInstruction(SpvOpTypeImage, image, this->getType(*fContext.fFloat_Type),
type.dimensions(), type.isDepth(), type.isArrayed(),
type.isMultisampled(), type.isSampled(),
SpvImageFormatUnknown, fConstantBuffer);
@@ -1084,7 +1075,7 @@
ABORT("invalid type: %s", type.description().c_str());
}
}
- fTypeMap[key] = result;
+ fTypeMap[type.name()] = result;
return result;
}
return entry->second;
@@ -1147,13 +1138,9 @@
return entry->second;
}
-SpvId SPIRVCodeGenerator::getPointerType(const Type& type, SpvStorageClass_ storageClass) {
- return this->getPointerType(type, fDefaultLayout, storageClass);
-}
-
-SpvId SPIRVCodeGenerator::getPointerType(const Type& type, const MemoryLayout& layout,
+SpvId SPIRVCodeGenerator::getPointerType(const Type& type,
SpvStorageClass_ storageClass) {
- std::string key = type.description() + "*" + to_string(layout.fStd) + to_string(storageClass);
+ std::string key = type.description() + "*" + to_string(storageClass);
auto entry = fTypeMap.find(key);
if (entry == fTypeMap.end()) {
SpvId result = this->nextId();
@@ -1564,15 +1551,10 @@
SpvStorageClass_ get_storage_class(const Modifiers& modifiers) {
if (modifiers.fFlags & Modifiers::kIn_Flag) {
- ASSERT(!modifiers.fLayout.fPushConstant);
return SpvStorageClassInput;
} else if (modifiers.fFlags & Modifiers::kOut_Flag) {
- ASSERT(!modifiers.fLayout.fPushConstant);
return SpvStorageClassOutput;
} else if (modifiers.fFlags & Modifiers::kUniform_Flag) {
- if (modifiers.fLayout.fPushConstant) {
- return SpvStorageClassPushConstant;
- }
return SpvStorageClassUniform;
} else {
return SpvStorageClassFunction;
@@ -2376,10 +2358,7 @@
}
SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
- MemoryLayout layout = intf.fVariable.fModifiers.fLayout.fPushConstant ?
- MemoryLayout(MemoryLayout::k430_Standard) :
- fDefaultLayout;
- SpvId type = this->getType(intf.fVariable.fType, layout);
+ SpvId type = this->getType(intf.fVariable.fType);
SpvId result = this->nextId();
this->writeInstruction(SpvOpDecorate, type, SpvDecorationBlock, fDecorationBuffer);
SpvStorageClass_ storageClass = get_storage_class(intf.fVariable.fModifiers);
@@ -2432,11 +2411,10 @@
this->writeInstruction(SpvOpVariable, type, id, storageClass, fConstantBuffer);
this->writeInstruction(SpvOpName, id, var->fName.c_str(), fNameBuffer);
if (var->fType.kind() == Type::kMatrix_Kind) {
- this->writeInstruction(SpvOpMemberDecorate, id, (SpvId) i, SpvDecorationColMajor,
+ this->writeInstruction(SpvOpMemberDecorate, id, (SpvId) i, SpvDecorationColMajor,
fDecorationBuffer);
- this->writeInstruction(SpvOpMemberDecorate, id, (SpvId) i, SpvDecorationMatrixStride,
- (SpvId) fDefaultLayout.stride(var->fType),
- fDecorationBuffer);
+ this->writeInstruction(SpvOpMemberDecorate, id, (SpvId) i, SpvDecorationMatrixStride,
+ (SpvId) var->fType.stride(), fDecorationBuffer);
}
if (varDecl.fValue) {
ASSERT(!fCurrentBlock);
« no previous file with comments | « src/sksl/SkSLSPIRVCodeGenerator.h ('k') | src/sksl/SkSLUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698