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/SkSLGLSLCodeGenerator.cpp b/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp
index dc25460..53aa8a0 100644
--- a/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp
@@ -780,7 +780,7 @@
if (this->caps().fbFetchSupport()) {
this->write(this->caps().fbFetchColorName());
} else {
- fContext.fErrors->error(ref.fOffset,
+ fContext.fErrors->error(ref.fLine,
"sk_LastFragColor requires framebuffer fetch support");
}
break;
@@ -909,12 +909,12 @@
if (b.getOperator().kind() == Token::Kind::TK_LOGICALAND) {
this->writeExpression(*b.right(), Precedence::kTernary);
} else {
- Literal boolTrue(/*offset=*/-1, /*value=*/1, fContext.fTypes.fBool.get());
+ Literal boolTrue(/*line=*/-1, /*value=*/1, fContext.fTypes.fBool.get());
this->writeLiteral(boolTrue);
}
this->write(" : ");
if (b.getOperator().kind() == Token::Kind::TK_LOGICALAND) {
- Literal boolFalse(/*offset=*/-1, /*value=*/0, fContext.fTypes.fBool.get());
+ Literal boolFalse(/*line=*/-1, /*value=*/0, fContext.fTypes.fBool.get());
this->writeLiteral(boolFalse);
} else {
this->writeExpression(*b.right(), Precedence::kTernary);
@@ -1284,8 +1284,8 @@
if (f.test()) {
if (this->caps().addAndTrueToLoopCondition()) {
std::unique_ptr<Expression> and_true(new BinaryExpression(
- /*offset=*/-1, f.test()->clone(), Token::Kind::TK_LOGICALAND,
- Literal::MakeBool(fContext, /*offset=*/-1, /*value=*/true),
+ /*line=*/-1, f.test()->clone(), Token::Kind::TK_LOGICALAND,
+ Literal::MakeBool(fContext, /*line=*/-1, /*value=*/true),
fContext.fTypes.fBool.get()));
this->writeExpression(*and_true, Precedence::kTopLevel);
} else {
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) + ")]]");
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.h b/src/sksl/codegen/SkSLMetalCodeGenerator.h
index e799dfb..1668e69 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.h
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.h
@@ -97,7 +97,7 @@
void writeStructDefinitions();
- void writeFields(const std::vector<Type::Field>& fields, int parentOffset,
+ void writeFields(const std::vector<Type::Field>& fields, int parentLine,
const InterfaceBlock* parentIntf = nullptr);
int size(const Type* type, bool isPacked) const;
diff --git a/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp b/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
index 47e80a0..aeae383 100644
--- a/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
@@ -447,7 +447,7 @@
for (int32_t i = 0; i < (int32_t) type.fields().size(); i++) {
const Type::Field& field = type.fields()[i];
if (!MemoryLayout::LayoutIsSupported(*field.fType)) {
- fContext.fErrors->error(type.fOffset, "type '" + field.fType->name() +
+ fContext.fErrors->error(type.fLine, "type '" + field.fType->name() +
"' is not permitted here");
return;
}
@@ -456,12 +456,12 @@
const Layout& fieldLayout = field.fModifiers.fLayout;
if (fieldLayout.fOffset >= 0) {
if (fieldLayout.fOffset < (int) offset) {
- fContext.fErrors->error(type.fOffset,
+ fContext.fErrors->error(type.fLine,
"offset of field '" + field.fName + "' must be at "
"least " + to_string((int) offset));
}
if (fieldLayout.fOffset % alignment) {
- fContext.fErrors->error(type.fOffset,
+ fContext.fErrors->error(type.fLine,
"offset of field '" + field.fName + "' must be a multiple"
" of " + to_string((int) alignment));
}
@@ -590,13 +590,13 @@
break;
case Type::TypeKind::kArray: {
if (!MemoryLayout::LayoutIsSupported(*type)) {
- fContext.fErrors->error(type->fOffset,
+ fContext.fErrors->error(type->fLine,
"type '" + type->name() + "' is not permitted here");
return this->nextId(nullptr);
}
if (type->columns() > 0) {
SpvId typeId = this->getType(type->componentType(), layout);
- Literal countLiteral(/*offset=*/-1, type->columns(),
+ Literal countLiteral(/*line=*/-1, type->columns(),
fContext.fTypes.fInt.get());
SpvId countId = this->writeLiteral(countLiteral);
this->writeInstruction(SpvOpTypeArray, result, typeId, countId,
@@ -606,7 +606,7 @@
fDecorationBuffer);
} else {
// We shouldn't have any runtime-sized arrays right now
- fContext.fErrors->error(type->fOffset,
+ fContext.fErrors->error(type->fLine,
"runtime-sized arrays are not supported in SPIR-V");
this->writeInstruction(SpvOpTypeRuntimeArray, result,
this->getType(type->componentType(), layout),
@@ -789,8 +789,7 @@
const FunctionDeclaration& function = c.function();
auto intrinsic = fIntrinsicMap.find(function.intrinsicKind());
if (intrinsic == fIntrinsicMap.end()) {
- fContext.fErrors->error(c.fOffset, "unsupported intrinsic '" + function.description() +
- "'");
+ fContext.fErrors->error(c.fLine, "unsupported intrinsic '" + function.description() + "'");
return -1;
}
int32_t intrinsicId;
@@ -876,8 +875,8 @@
case kSpecial_IntrinsicOpcodeKind:
return this->writeSpecialIntrinsic(c, (SpecialIntrinsic) intrinsicId, out);
default:
- fContext.fErrors->error(c.fOffset, "unsupported intrinsic '" + function.description() +
- "'");
+ fContext.fErrors->error(c.fLine, "unsupported intrinsic '" + function.description() +
+ "'");
return -1;
}
}
@@ -984,9 +983,9 @@
SpvId img = this->writeExpression(*arguments[0], out);
ExpressionArray args;
args.reserve_back(2);
- args.push_back(Literal::MakeInt(fContext, /*offset=*/-1, /*value=*/0));
- args.push_back(Literal::MakeInt(fContext, /*offset=*/-1, /*value=*/0));
- ConstructorCompound ctor(/*offset=*/-1, *fContext.fTypes.fInt2, std::move(args));
+ args.push_back(Literal::MakeInt(fContext, /*line=*/-1, /*value=*/0));
+ args.push_back(Literal::MakeInt(fContext, /*line=*/-1, /*value=*/0));
+ ConstructorCompound ctor(/*line=*/-1, *fContext.fTypes.fInt2, std::move(args));
SpvId coords = this->writeConstantVector(ctor);
if (arguments.size() == 1) {
this->writeInstruction(SpvOpImageRead,
@@ -1051,7 +1050,7 @@
} else {
SkASSERT(arguments.size() == 2);
if (fProgram.fConfig->fSettings.fSharpenTextures) {
- Literal lodBias(/*offset=*/-1, /*value=*/-0.5, fContext.fTypes.fFloat.get());
+ Literal lodBias(/*line=*/-1, /*value=*/-0.5, fContext.fTypes.fFloat.get());
this->writeInstruction(op, type, result, sampler, uv,
SpvImageOperandsBiasMask,
this->writeLiteral(lodBias),
@@ -1091,9 +1090,9 @@
this->writeWord(this->getType(callType), out);
this->writeWord(result, out);
this->writeWord(fn, out);
- this->addRTFlipUniform(c.fOffset);
+ this->addRTFlipUniform(c.fLine);
using namespace dsl;
- DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*offset=*/-1,
+ DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*line=*/-1,
SKSL_RTFLIP_NAME));
SpvId rtFlipY = this->vectorize(*rtFlip.y().release(), callType.columns(), out);
SpvId flipped = this->nextId(&callType);
@@ -1144,8 +1143,8 @@
ExpressionArray finalArgs;
finalArgs.reserve_back(3);
finalArgs.push_back(arguments[0]->clone());
- finalArgs.push_back(Literal::MakeFloat(fContext, /*offset=*/-1, /*value=*/0));
- finalArgs.push_back(Literal::MakeFloat(fContext, /*offset=*/-1, /*value=*/1));
+ finalArgs.push_back(Literal::MakeFloat(fContext, /*line=*/-1, /*value=*/0));
+ finalArgs.push_back(Literal::MakeFloat(fContext, /*line=*/-1, /*value=*/1));
std::vector<SpvId> spvArgs = this->vectorize(finalArgs, out);
this->writeGLSLExtendedInstruction(callType, result, GLSLstd450FClamp, GLSLstd450SClamp,
GLSLstd450UClamp, spvArgs, out);
@@ -1232,8 +1231,8 @@
const ExpressionArray& arguments = c.arguments();
const auto& entry = fFunctionMap.find(&function);
if (entry == fFunctionMap.end()) {
- fContext.fErrors->error(c.fOffset, "function '" + function.description() +
- "' is not defined");
+ fContext.fErrors->error(c.fLine, "function '" + function.description() +
+ "' is not defined");
return -1;
}
// Temp variables are used to write back out-parameters after the function call is complete.
@@ -1333,9 +1332,9 @@
SpvId result = this->nextId(&outputType);
if (inputType.isBoolean()) {
// Use OpSelect to convert the boolean argument to a literal 1.0 or 0.0.
- Literal one(/*offset=*/-1, /*value=*/1, fContext.fTypes.fFloat.get());
+ Literal one(/*line=*/-1, /*value=*/1, fContext.fTypes.fFloat.get());
const SpvId oneID = this->writeLiteral(one);
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpSelect, this->getType(outputType), result,
inputId, oneID, zeroID, out);
@@ -1369,9 +1368,9 @@
SpvId result = this->nextId(&outputType);
if (inputType.isBoolean()) {
// Use OpSelect to convert the boolean argument to a literal 1 or 0.
- Literal one(/*offset=*/-1, /*value=*/1, fContext.fTypes.fInt.get());
+ Literal one(/*line=*/-1, /*value=*/1, fContext.fTypes.fInt.get());
const SpvId oneID = this->writeLiteral(one);
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fInt.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fInt.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpSelect, this->getType(outputType), result,
inputId, oneID, zeroID, out);
@@ -1406,9 +1405,9 @@
SpvId result = this->nextId(&outputType);
if (inputType.isBoolean()) {
// Use OpSelect to convert the boolean argument to a literal 1u or 0u.
- Literal one(/*offset=*/-1, /*value=*/1, fContext.fTypes.fUInt.get());
+ Literal one(/*line=*/-1, /*value=*/1, fContext.fTypes.fUInt.get());
const SpvId oneID = this->writeLiteral(one);
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fUInt.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fUInt.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpSelect, this->getType(outputType), result,
inputId, oneID, zeroID, out);
@@ -1443,19 +1442,19 @@
SpvId result = this->nextId(nullptr);
if (inputType.isSigned()) {
// Synthesize a boolean result by comparing the input against a signed zero literal.
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fInt.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fInt.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpINotEqual, this->getType(outputType), result,
inputId, zeroID, out);
} else if (inputType.isUnsigned()) {
// Synthesize a boolean result by comparing the input against an unsigned zero literal.
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fUInt.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fUInt.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpINotEqual, this->getType(outputType), result,
inputId, zeroID, out);
} else if (inputType.isFloat()) {
// Synthesize a boolean result by comparing the input against a floating-point zero literal.
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpFUnordNotEqual, this->getType(outputType), result,
inputId, zeroID, out);
@@ -1468,7 +1467,7 @@
void SPIRVCodeGenerator::writeUniformScaleMatrix(SpvId id, SpvId diagonal, const Type& type,
OutputStream& out) {
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
SpvId zeroId = this->writeLiteral(zero);
std::vector<SpvId> columnIds;
columnIds.reserve(type.columns());
@@ -1507,9 +1506,9 @@
dstType.rows(),
1));
SkASSERT(dstType.componentType().isFloat());
- Literal zero(/*offset=*/-1, /*value=*/0.0, &dstType.componentType());
+ Literal zero(/*line=*/-1, /*value=*/0.0, &dstType.componentType());
const SpvId zeroId = this->writeLiteral(zero);
- Literal one(/*offset=*/-1, /*value=*/1.0, &dstType.componentType());
+ Literal one(/*line=*/-1, /*value=*/1.0, &dstType.componentType());
const SpvId oneId = this->writeLiteral(one);
SpvId columns[4];
@@ -1864,7 +1863,7 @@
case Expression::Kind::kFieldAccess: {
const FieldAccess& fieldExpr = expr.as<FieldAccess>();
chain = this->getAccessChain(*fieldExpr.base(), out);
- Literal index(/*offset=*/-1, fieldExpr.fieldIndex(), fContext.fTypes.fInt.get());
+ Literal index(/*line=*/-1, fieldExpr.fieldIndex(), fContext.fTypes.fInt.get());
chain.push_back(this->writeLiteral(index));
break;
}
@@ -2013,7 +2012,7 @@
const Variable& var = *expr.as<VariableReference>().variable();
int uniformIdx = this->findUniformFieldIndex(var);
if (uniformIdx >= 0) {
- Literal uniformIdxLiteral{/*offset=*/-1, (double)uniformIdx,
+ Literal uniformIdxLiteral{/*line=*/-1, (double)uniformIdx,
fContext.fTypes.fInt.get()};
SpvId memberId = this->nextId(nullptr);
SpvId typeId = this->getPointerType(type, SpvStorageClassUniform);
@@ -2052,12 +2051,12 @@
}
SpvId base = lvalue->getPointer();
if (base == (SpvId) -1) {
- fContext.fErrors->error(swizzle.fOffset, "unable to retrieve lvalue from swizzle");
+ fContext.fErrors->error(swizzle.fLine, "unable to retrieve lvalue from swizzle");
}
if (swizzle.components().size() == 1) {
SpvId member = this->nextId(nullptr);
SpvId typeId = this->getPointerType(type, get_storage_class(*swizzle.base()));
- Literal index(/*offset=*/-1, swizzle.components()[0], fContext.fTypes.fInt.get());
+ Literal index(/*line=*/-1, swizzle.components()[0], fContext.fTypes.fInt.get());
SpvId indexId = this->writeLiteral(index);
this->writeInstruction(SpvOpAccessChain, typeId, member, base, indexId, out);
return std::make_unique<PointerLValue>(*this,
@@ -2105,7 +2104,7 @@
// Handle inserting use of uniform to flip y when referencing sk_FragCoord.
if (variable->modifiers().fLayout.fBuiltin == SK_FRAGCOORD_BUILTIN) {
- this->addRTFlipUniform(ref.fOffset);
+ this->addRTFlipUniform(ref.fLine);
// Use sk_RTAdjust to compute the flipped coordinate
using namespace dsl;
const char* DEVICE_COORDS_NAME = "__device_FragCoords";
@@ -2113,13 +2112,13 @@
// Use a uniform to flip the Y coordinate. The new expression will be written in
// terms of __device_FragCoords, which is a fake variable that means "access the
// underlying fragcoords directly without flipping it".
- DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*offset=*/-1,
+ DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*line=*/-1,
SKSL_RTFLIP_NAME));
if (!symbols[DEVICE_COORDS_NAME]) {
AutoAttachPoolToThread attach(fProgram.fPool.get());
Modifiers modifiers;
modifiers.fLayout.fBuiltin = DEVICE_FRAGCOORDS_BUILTIN;
- auto coordsVar = std::make_unique<Variable>(/*offset=*/-1,
+ auto coordsVar = std::make_unique<Variable>(/*line=*/-1,
fContext.fModifiersPool->add(modifiers),
DEVICE_COORDS_NAME,
fContext.fTypes.fFloat4.get(),
@@ -2141,20 +2140,20 @@
// Handle flipping sk_Clockwise.
if (variable->modifiers().fLayout.fBuiltin == SK_CLOCKWISE_BUILTIN) {
- this->addRTFlipUniform(ref.fOffset);
+ this->addRTFlipUniform(ref.fLine);
using namespace dsl;
const char* DEVICE_CLOCKWISE_NAME = "__device_Clockwise";
SymbolTable& symbols = *dsl::DSLWriter::SymbolTable();
// Use a uniform to flip the Y coordinate. The new expression will be written in
// terms of __device_Clockwise, which is a fake variable that means "access the
// underlying FrontFacing directly".
- DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*offset=*/-1,
+ DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*line=*/-1,
SKSL_RTFLIP_NAME));
if (!symbols[DEVICE_CLOCKWISE_NAME]) {
AutoAttachPoolToThread attach(fProgram.fPool.get());
Modifiers modifiers;
modifiers.fLayout.fBuiltin = DEVICE_CLOCKWISE_BUILTIN;
- auto clockwiseVar = std::make_unique<Variable>(/*offset=*/-1,
+ auto clockwiseVar = std::make_unique<Variable>(/*line=*/-1,
fContext.fModifiersPool->add(modifiers),
DEVICE_CLOCKWISE_NAME,
fContext.fTypes.fBool.get(),
@@ -2225,7 +2224,7 @@
} else if (is_bool(fContext, operandType)) {
this->writeInstruction(ifBool, this->getType(resultType), result, lhs, rhs, out);
} else {
- fContext.fErrors->error(operandType.fOffset,
+ fContext.fErrors->error(operandType.fLine,
"unsupported operand for binary expression: " + operandType.description());
}
return result;
@@ -2297,12 +2296,12 @@
static std::unique_ptr<Expression> create_literal_1(const Context& context, const Type& type) {
SkASSERT(type.isInteger() || type.isFloat());
- return Literal::Make(/*offset=*/-1, /*value=*/1.0, &type);
+ return Literal::Make(/*line=*/-1, /*value=*/1.0, &type);
}
SpvId SPIRVCodeGenerator::writeReciprocal(const Type& type, SpvId value, OutputStream& out) {
SkASSERT(type.isFloat());
- SpvId one = this->writeLiteral({/*offset=*/-1, /*value=*/1, &type});
+ SpvId one = this->writeLiteral({/*line=*/-1, /*value=*/1, &type});
SpvId reciprocal = this->nextId(&type);
this->writeInstruction(SpvOpFDiv, this->getType(type), reciprocal, one, value, out);
return reciprocal;
@@ -2436,7 +2435,7 @@
resultType, out);
}
} else {
- fContext.fErrors->error(leftType.fOffset, "unsupported mixed-type expression");
+ fContext.fErrors->error(leftType.fLine, "unsupported mixed-type expression");
return -1;
}
} else {
@@ -2707,7 +2706,7 @@
// This converts `expr / 2` into `expr * 0.5`
// This improves codegen, especially for certain types of divides (e.g. vector/scalar).
op = Operator(Token::Kind::TK_STAR);
- Literal reciprocal{right->fOffset, 1.0f / rhsValue, &right->type()};
+ Literal reciprocal{right->fLine, 1.0f / rhsValue, &right->type()};
rhs = this->writeExpression(reciprocal, out);
} else {
// Write the right-hand side expression normally.
@@ -2724,7 +2723,7 @@
SpvId SPIRVCodeGenerator::writeLogicalAnd(const Expression& left, const Expression& right,
OutputStream& out) {
- Literal falseLiteral(/*offset=*/-1, /*value=*/false, fContext.fTypes.fBool.get());
+ Literal falseLiteral(/*line=*/-1, /*value=*/false, fContext.fTypes.fBool.get());
SpvId falseConstant = this->writeLiteral(falseLiteral);
SpvId lhs = this->writeExpression(left, out);
SpvId rhsLabel = this->nextId(nullptr);
@@ -2745,7 +2744,7 @@
SpvId SPIRVCodeGenerator::writeLogicalOr(const Expression& left, const Expression& right,
OutputStream& out) {
- Literal trueLiteral(/*offset=*/-1, /*value=*/true, fContext.fTypes.fBool.get());
+ Literal trueLiteral(/*line=*/-1, /*value=*/true, fContext.fTypes.fBool.get());
SpvId trueConstant = this->writeLiteral(trueLiteral);
SpvId lhs = this->writeExpression(left, out);
SpvId rhsLabel = this->nextId(nullptr);
@@ -3018,7 +3017,7 @@
const Variable& intfVar = intf.variable();
const Type& type = intfVar.type();
if (!MemoryLayout::LayoutIsSupported(type)) {
- fContext.fErrors->error(type.fOffset, "type '" + type.name() + "' is not permitted here");
+ fContext.fErrors->error(type.fLine, "type '" + type.name() + "' is not permitted here");
return this->nextId(nullptr);
}
SpvStorageClass_ storageClass = get_storage_class(intf.variable(), SpvStorageClassFunction);
@@ -3042,16 +3041,16 @@
{
AutoAttachPoolToThread attach(fProgram.fPool.get());
const Type* rtFlipStructType = fProgram.fSymbols->takeOwnershipOfSymbol(
- Type::MakeStructType(type.fOffset, type.name(), std::move(fields)));
+ Type::MakeStructType(type.fLine, type.name(), std::move(fields)));
const Variable* modifiedVar = fProgram.fSymbols->takeOwnershipOfSymbol(
- std::make_unique<Variable>(intfVar.fOffset,
+ std::make_unique<Variable>(intfVar.fLine,
&intfVar.modifiers(),
intfVar.name(),
rtFlipStructType,
intfVar.isBuiltin(),
intfVar.storage()));
fSPIRVBonusVariables.insert(modifiedVar);
- InterfaceBlock modifiedCopy(intf.fOffset,
+ InterfaceBlock modifiedCopy(intf.fLine,
*modifiedVar,
intf.typeName(),
intf.instanceName(),
@@ -3059,7 +3058,7 @@
intf.typeOwner());
result = this->writeInterfaceBlock(modifiedCopy, false);
fProgram.fSymbols->add(std::make_unique<Field>(
- /*offset=*/-1, modifiedVar, rtFlipStructType->fields().size() - 1));
+ /*line=*/-1, modifiedVar, rtFlipStructType->fields().size() - 1));
}
fVariableMap[&intfVar] = result;
fWroteRTFlip = true;
@@ -3374,30 +3373,30 @@
const Symbol* skFragColorSymbol = (*symbolTable)["sk_FragColor"];
SkASSERT(skFragColorSymbol);
const Variable& skFragColorVar = skFragColorSymbol->as<Variable>();
- auto skFragColorRef = std::make_unique<VariableReference>(/*offset=*/-1, &skFragColorVar,
+ auto skFragColorRef = std::make_unique<VariableReference>(/*line=*/-1, &skFragColorVar,
VariableReference::RefKind::kWrite);
// Synthesize a call to the `main()` function.
if (main.returnType() != skFragColorRef->type()) {
- fContext.fErrors->error(main.fOffset, "SPIR-V does not support returning '" +
- main.returnType().description() + "' from main()");
+ fContext.fErrors->error(main.fLine, "SPIR-V does not support returning '" +
+ main.returnType().description() + "' from main()");
return {};
}
ExpressionArray args;
if (main.parameters().size() == 1) {
if (main.parameters()[0]->type() != *fContext.fTypes.fFloat2) {
- fContext.fErrors->error(main.fOffset,
+ fContext.fErrors->error(main.fLine,
"SPIR-V does not support parameter of type '" +
main.parameters()[0]->type().description() + "' to main()");
return {};
}
args.push_back(dsl::Float2(0).release());
}
- auto callMainFn = std::make_unique<FunctionCall>(/*offset=*/-1, &main.returnType(), &main,
+ auto callMainFn = std::make_unique<FunctionCall>(/*line=*/-1, &main.returnType(), &main,
std::move(args));
// Synthesize `skFragColor = main()` as a BinaryExpression.
auto assignmentStmt = std::make_unique<ExpressionStatement>(std::make_unique<BinaryExpression>(
- /*offset=*/-1,
+ /*line=*/-1,
std::move(skFragColorRef),
Token::Kind::TK_EQ,
std::move(callMainFn),
@@ -3406,14 +3405,14 @@
// Function bodies are always wrapped in a Block.
StatementArray entrypointStmts;
entrypointStmts.push_back(std::move(assignmentStmt));
- auto entrypointBlock = Block::Make(/*offset=*/-1, std::move(entrypointStmts),
+ auto entrypointBlock = Block::Make(/*line=*/-1, std::move(entrypointStmts),
symbolTable, /*isScope=*/true);
// Declare an entrypoint function.
EntrypointAdapter adapter;
adapter.fLayout = {};
adapter.fModifiers = Modifiers{adapter.fLayout, Modifiers::kHasSideEffects_Flag};
adapter.entrypointDecl =
- std::make_unique<FunctionDeclaration>(/*offset=*/-1,
+ std::make_unique<FunctionDeclaration>(/*line=*/-1,
&adapter.fModifiers,
"_entrypoint",
/*parameters=*/std::vector<const Variable*>{},
@@ -3421,7 +3420,7 @@
/*builtin=*/false);
// Define it.
adapter.entrypointDef = FunctionDefinition::Convert(fContext,
- /*offset=*/-1,
+ /*line=*/-1,
*adapter.entrypointDecl,
std::move(entrypointBlock),
/*builtin=*/false);
@@ -3444,7 +3443,7 @@
fTopLevelUniformMap[var] = (int)fields.size();
fields.emplace_back(var->modifiers(), var->name(), &var->type());
}
- fUniformBuffer.fStruct = Type::MakeStructType(/*offset=*/-1, kUniformBufferName,
+ fUniformBuffer.fStruct = Type::MakeStructType(/*line=*/-1, kUniformBufferName,
std::move(fields));
// Create a global variable to contain this struct.
@@ -3454,7 +3453,7 @@
Modifiers modifiers{layout, Modifiers::kUniform_Flag};
fUniformBuffer.fInnerVariable = std::make_unique<Variable>(
- /*offset=*/-1, fProgram.fModifiers->add(modifiers), kUniformBufferName,
+ /*line=*/-1, fProgram.fModifiers->add(modifiers), kUniformBufferName,
fUniformBuffer.fStruct.get(), /*builtin=*/false, Variable::Storage::kGlobal);
// Create an interface block object for this global variable.
@@ -3466,7 +3465,7 @@
fUniformBufferId = this->writeInterfaceBlock(*fUniformBuffer.fInterfaceBlock);
}
-void SPIRVCodeGenerator::addRTFlipUniform(int offset) {
+void SPIRVCodeGenerator::addRTFlipUniform(int line) {
if (fWroteRTFlip) {
return;
}
@@ -3475,7 +3474,7 @@
fWroteRTFlip = true;
std::vector<Type::Field> fields;
if (fProgram.fConfig->fSettings.fRTFlipOffset < 0) {
- fContext.fErrors->error(offset, "RTFlipOffset is negative");
+ fContext.fErrors->error(line, "RTFlipOffset is negative");
}
fields.emplace_back(Modifiers(Layout(/*flags=*/0,
/*location=*/-1,
@@ -3490,14 +3489,14 @@
fContext.fTypes.fFloat2.get());
skstd::string_view name = "sksl_synthetic_uniforms";
const Type* intfStruct =
- fSynthetics.takeOwnershipOfSymbol(Type::MakeStructType(/*offset=*/-1, name, fields));
+ fSynthetics.takeOwnershipOfSymbol(Type::MakeStructType(/*line=*/-1, name, fields));
int binding = fProgram.fConfig->fSettings.fRTFlipBinding;
if (binding == -1) {
- fContext.fErrors->error(offset, "layout(binding=...) is required in SPIR-V");
+ fContext.fErrors->error(line, "layout(binding=...) is required in SPIR-V");
}
int set = fProgram.fConfig->fSettings.fRTFlipSet;
if (set == -1) {
- fContext.fErrors->error(offset, "layout(set=...) is required in SPIR-V");
+ fContext.fErrors->error(line, "layout(set=...) is required in SPIR-V");
}
bool usePushConstants = fProgram.fConfig->fSettings.fUsePushConstants;
int flags = usePushConstants ? Layout::Flag::kPushConstant_Flag : 0;
@@ -3516,7 +3515,7 @@
modsPtr = fProgram.fModifiers->add(modifiers);
}
const Variable* intfVar = fSynthetics.takeOwnershipOfSymbol(
- std::make_unique<Variable>(/*offset=*/-1,
+ std::make_unique<Variable>(/*line=*/-1,
modsPtr,
name,
intfStruct,
@@ -3525,9 +3524,9 @@
fSPIRVBonusVariables.insert(intfVar);
{
AutoAttachPoolToThread attach(fProgram.fPool.get());
- fProgram.fSymbols->add(std::make_unique<Field>(/*offset=*/-1, intfVar, /*field=*/0));
+ fProgram.fSymbols->add(std::make_unique<Field>(/*line=*/-1, intfVar, /*field=*/0));
}
- InterfaceBlock intf(/*offset=*/-1,
+ InterfaceBlock intf(/*line=*/-1,
*intfVar,
name,
/*instanceName=*/"",
@@ -3554,7 +3553,7 @@
}
// Make sure we have a main() function.
if (!main) {
- fContext.fErrors->error(/*offset=*/-1, "program does not contain a main() function");
+ fContext.fErrors->error(/*line=*/-1, "program does not contain a main() function");
return;
}
// Emit interface blocks.
diff --git a/src/sksl/codegen/SkSLSPIRVCodeGenerator.h b/src/sksl/codegen/SkSLSPIRVCodeGenerator.h
index 0e7b728..abab85b 100644
--- a/src/sksl/codegen/SkSLSPIRVCodeGenerator.h
+++ b/src/sksl/codegen/SkSLSPIRVCodeGenerator.h
@@ -466,7 +466,7 @@
void writeUniformBuffer(std::shared_ptr<SymbolTable> topLevelSymbolTable);
- void addRTFlipUniform(int offset);
+ void addRTFlipUniform(int line);
const MemoryLayout fDefaultLayout;