Reland "Renamed SkSL "offset" to "line""
This reverts commit cc91452f0a65f261283615db9ed3d37b1c3acd15.
Change-Id: I7eff0ddeebef4ce298893f9b3ba410b09647e9a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453138
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
index c0cd482..9b6b7d2 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
@@ -110,7 +110,7 @@
const Type& type = s.type();
this->writeLine("struct " + type.name() + " {");
fIndentation++;
- this->writeFields(type.fields(), type.fOffset);
+ this->writeFields(type.fields(), type.fLine);
fIndentation--;
this->writeLine("};");
}
@@ -1131,7 +1131,7 @@
} else if (c.type().isMatrix()) {
this->writeConstructorCompoundMatrix(c, parentPrecedence);
} else {
- fContext.fErrors->error(c.fOffset, "unsupported compound constructor");
+ fContext.fErrors->error(c.fLine, "unsupported compound constructor");
}
}
@@ -1798,13 +1798,13 @@
const VarDeclaration& var = decls.declaration()->as<VarDeclaration>();
if (var.var().type().typeKind() == Type::TypeKind::kSampler) {
if (var.var().modifiers().fLayout.fBinding < 0) {
- fContext.fErrors->error(decls.fOffset,
+ fContext.fErrors->error(decls.fLine,
"Metal samplers must have 'layout(binding=...)'");
return false;
}
if (var.var().type().dimensions() != SpvDim2D) {
// Not yet implemented--Skia currently only uses 2D textures.
- fContext.fErrors->error(decls.fOffset, "Unsupported texture dimensions");
+ fContext.fErrors->error(decls.fLine, "Unsupported texture dimensions");
return false;
}
this->write(", texture2d<float> ");
@@ -1960,7 +1960,7 @@
structType = &structType->componentType();
}
fIndentation++;
- this->writeFields(structType->fields(), structType->fOffset, &intf);
+ this->writeFields(structType->fields(), structType->fLine, &intf);
if (fProgram.fInputs.fUseFlipRTUniform) {
this->writeLine("float2 " SKSL_RTFLIP_NAME ";");
}
@@ -1982,7 +1982,7 @@
this->writeLine(";");
}
-void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int parentOffset,
+void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int parentLine,
const InterfaceBlock* parentIntf) {
MemoryLayout memoryLayout(MemoryLayout::kMetal_Standard);
int currentOffset = 0;
@@ -1990,13 +1990,13 @@
int fieldOffset = field.fModifiers.fLayout.fOffset;
const Type* fieldType = field.fType;
if (!MemoryLayout::LayoutIsSupported(*fieldType)) {
- fContext.fErrors->error(parentOffset, "type '" + fieldType->name() +
- "' is not permitted here");
+ fContext.fErrors->error(parentLine, "type '" + fieldType->name() +
+ "' is not permitted here");
return;
}
if (fieldOffset != -1) {
if (currentOffset > fieldOffset) {
- fContext.fErrors->error(parentOffset,
+ fContext.fErrors->error(parentLine,
"offset of field '" + field.fName + "' must be at least " +
to_string((int) currentOffset));
return;
@@ -2010,7 +2010,7 @@
}
int alignment = memoryLayout.alignment(*fieldType);
if (fieldOffset % alignment) {
- fContext.fErrors->error(parentOffset,
+ fContext.fErrors->error(parentLine,
"offset of field '" + field.fName + "' must be a multiple of " +
to_string((int) alignment));
return;
@@ -2018,7 +2018,7 @@
}
size_t fieldSize = memoryLayout.size(*fieldType);
if (fieldSize > static_cast<size_t>(std::numeric_limits<int>::max() - currentOffset)) {
- fContext.fErrors->error(parentOffset, "field offset overflow");
+ fContext.fErrors->error(parentLine, "field offset overflow");
return;
}
currentOffset += fieldSize;
@@ -2213,7 +2213,7 @@
this->writeExpression(*r.expression(), Precedence::kTopLevel);
this->writeLine(";");
} else {
- fContext.fErrors->error(r.fOffset,
+ fContext.fErrors->error(r.fLine,
"Metal does not support returning '" +
r.expression()->type().description() + "' from main()");
}
@@ -2249,7 +2249,7 @@
this->write("struct Uniforms {\n");
fUniformBuffer = uniformSet;
} else if (uniformSet != fUniformBuffer) {
- fContext.fErrors->error(decls.fOffset,
+ fContext.fErrors->error(decls.fLine,
"Metal backend requires all uniforms to have the same "
"'layout(set=...)'");
}
@@ -2314,7 +2314,7 @@
int location = var.modifiers().fLayout.fLocation;
if (location < 0) {
- fContext.fErrors->error(var.fOffset,
+ fContext.fErrors->error(var.fLine,
"Metal out variables must have 'layout(location=...)'");
} else if (fProgram.fConfig->fKind == ProgramKind::kVertex) {
this->write(" [[user(locn" + to_string(location) + ")]]");