Moved scanInterfaceBlock into DSLCore
Change-Id: I984477cad7885ef941fbc6d2dc7f48fc617a740c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459118
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 4049a03..5589d07 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -170,22 +170,6 @@
SkASSERT(layoutFlags == 0);
}
-void IRGenerator::scanInterfaceBlock(SkSL::InterfaceBlock& intf) {
- const std::vector<Type::Field>& fields = intf.variable().type().componentType().fields();
- for (size_t i = 0; i < fields.size(); ++i) {
- const Type::Field& f = fields[i];
- if (f.fName == Compiler::RTADJUST_NAME) {
- if (*f.fType == *fContext.fTypes.fFloat4) {
- ThreadContext::RTAdjustData& rtAdjust = ThreadContext::RTAdjustState();
- rtAdjust.fInterfaceBlock = &intf.variable();
- rtAdjust.fFieldIndex = i;
- } else {
- this->errorReporter().error(intf.fLine, "sk_RTAdjust must have type 'float4'");
- }
- }
- }
-}
-
std::unique_ptr<Expression> IRGenerator::convertIdentifier(int line, skstd::string_view name) {
const Symbol* result = (*fSymbolTable)[name];
if (!result) {
diff --git a/src/sksl/SkSLIRGenerator.h b/src/sksl/SkSLIRGenerator.h
index 865ad98..fbd54b2 100644
--- a/src/sksl/SkSLIRGenerator.h
+++ b/src/sksl/SkSLIRGenerator.h
@@ -98,7 +98,6 @@
private:
IRGenerator::IRBundle finish();
- void scanInterfaceBlock(SkSL::InterfaceBlock& intf);
/** Appends sk_Position fixup to the bottom of main() if this is a vertex program. */
void appendRTAdjustFixupToVertexMain(const FunctionDeclaration& decl, Block* body);
diff --git a/src/sksl/dsl/DSLCore.cpp b/src/sksl/dsl/DSLCore.cpp
index e8750af..746d7e1 100644
--- a/src/sksl/dsl/DSLCore.cpp
+++ b/src/sksl/dsl/DSLCore.cpp
@@ -212,6 +212,25 @@
ifTrue.release(), ifFalse.releaseIfPossible());
}
+ static void FindRTAdjust(SkSL::InterfaceBlock& intf, PositionInfo pos) {
+ const std::vector<SkSL::Type::Field>& fields =
+ intf.variable().type().componentType().fields();
+ const Context& context = ThreadContext::Context();
+ for (size_t i = 0; i < fields.size(); ++i) {
+ const SkSL::Type::Field& f = fields[i];
+ if (f.fName == SkSL::Compiler::RTADJUST_NAME) {
+ if (*f.fType == *context.fTypes.fFloat4) {
+ ThreadContext::RTAdjustData& rtAdjust = ThreadContext::RTAdjustState();
+ rtAdjust.fInterfaceBlock = &intf.variable();
+ rtAdjust.fFieldIndex = i;
+ } else {
+ ThreadContext::ReportError("sk_RTAdjust must have type 'float4'", pos);
+ }
+ break;
+ }
+ }
+ }
+
static DSLGlobalVar InterfaceBlock(const DSLModifiers& modifiers, skstd::string_view typeName,
SkTArray<DSLField> fields, skstd::string_view varName,
int arraySize, PositionInfo pos) {
@@ -245,7 +264,7 @@
if (skslVar) {
auto intf = std::make_unique<SkSL::InterfaceBlock>(pos.line(),
*skslVar, typeName, varName, arraySize, ThreadContext::SymbolTable());
- ThreadContext::IRGenerator().scanInterfaceBlock(*intf);
+ FindRTAdjust(*intf, pos);
ThreadContext::ProgramElements().push_back(std::move(intf));
if (varName.empty()) {
const std::vector<SkSL::Type::Field>& structFields = structType->fields();