48class FinalizationVisitor :
public ProgramVisitor {
50 FinalizationVisitor(
const Context& c,
const ProgramUsage& u) :
fContext(c), fUsage(u) {}
52 bool visitProgramElement(
const ProgramElement& pe)
override {
54 case ProgramElement::Kind::kGlobalVar:
55 this->checkGlobalVariableSizeLimit(pe.as<GlobalVarDeclaration>());
57 case ProgramElement::Kind::kInterfaceBlock:
60 this->checkBindUniqueness(pe.as<InterfaceBlock>());
63 this->checkOutParamsAreAssigned(pe.as<FunctionDefinition>());
65 case ProgramElement::Kind::kModifiers:
66 this->checkWorkgroupLocalSize(pe.as<ModifiersDeclaration>());
74 void checkGlobalVariableSizeLimit(
const GlobalVarDeclaration& globalDecl) {
78 const VarDeclaration& decl = globalDecl.varDeclaration();
80 size_t prevSlotsUsed = fGlobalSlotsUsed;
81 fGlobalSlotsUsed =
SkSafeMath::Add(fGlobalSlotsUsed, decl.var()->type().slotCount());
85 fContext.fErrors->error(decl.fPosition,
86 "global variable '" + std::string(decl.var()->name()) +
87 "' exceeds the size limit");
91 void checkBindUniqueness(
const InterfaceBlock& block) {
92 const Variable* var = block.var();
93 int32_t
set = var->layout().fSet;
94 int32_t binding = var->layout().fBinding;
99 uint64_t
key = ((uint64_t)
set << 32) + binding;
100 if (!fBindings.contains(
key)) {
104 fContext.fErrors->error(block.fPosition,
107 ") has already been defined");
109 fContext.fErrors->error(block.fPosition,
111 ") has already been defined");
117 void checkOutParamsAreAssigned(
const FunctionDefinition& funcDef) {
118 const FunctionDeclaration& funcDecl = funcDef.declaration();
122 for (
const Variable* param : funcDecl.parameters()) {
126 ProgramUsage::VariableCounts
counts = fUsage.get(*param);
128 fContext.fErrors->error(param->fPosition,
129 "function '" + std::string(funcDecl.name()) +
130 "' never assigns a value to out parameter '" +
131 std::string(param->name()) +
"'");
137 void checkWorkgroupLocalSize(
const ModifiersDeclaration&
d) {
138 if (
d.layout().fLocalSizeX >= 0) {
139 if (fLocalSizeX >= 0) {
140 fContext.fErrors->error(
d.fPosition,
"'local_size_x' was specified more than once");
142 fLocalSizeX =
d.layout().fLocalSizeX;
145 if (
d.layout().fLocalSizeY >= 0) {
146 if (fLocalSizeY >= 0) {
147 fContext.fErrors->error(
d.fPosition,
"'local_size_y' was specified more than once");
149 fLocalSizeY =
d.layout().fLocalSizeY;
152 if (
d.layout().fLocalSizeZ >= 0) {
153 if (fLocalSizeZ >= 0) {
154 fContext.fErrors->error(
d.fPosition,
"'local_size_z' was specified more than once");
156 fLocalSizeZ =
d.layout().fLocalSizeZ;
161 bool visitExpression(
const Expression& expr)
override {
162 switch (expr.kind()) {
163 case Expression::Kind::kFunctionCall: {
164 const FunctionDeclaration& decl = expr.as<FunctionCall>().
function();
165 if (!decl.isBuiltin() && !decl.definition()) {
166 fContext.fErrors->error(expr.fPosition,
"function '" + decl.description() +
171 case Expression::Kind::kFunctionReference:
172 case Expression::Kind::kMethodReference:
173 case Expression::Kind::kTypeReference:
174 SkDEBUGFAIL(
"invalid reference-expr, should have been reported by coerce()");
175 fContext.fErrors->error(expr.fPosition,
"invalid expression");
178 if (expr.type().matches(*
fContext.fTypes.fInvalid)) {
179 fContext.fErrors->error(expr.fPosition,
"invalid expression");
186 bool definesLocalSize()
const {
187 return fLocalSizeX >= 0 || fLocalSizeY >= 0 || fLocalSizeZ >= 0;
192 size_t fGlobalSlotsUsed = 0;
194 const ProgramUsage& fUsage;
200 int fLocalSizeX = -1;
201 int fLocalSizeY = -1;
202 int fLocalSizeZ = -1;
209 FinalizationVisitor visitor{*program.
fContext, *program.
usage()};
210 for (
const std::unique_ptr<ProgramElement>& element : program.
fOwnedElements) {
211 visitor.visitProgramElement(*element);
215 "compute programs must specify a workgroup size");
#define SkDEBUGFAIL(message)
#define INHERITED(method,...)
virtual bool visitExpression(typename T::Expression &expression)
virtual bool visitProgramElement(typename T::ProgramElement &programElement)
static size_t Add(size_t x, size_t y)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Dart_NativeFunction function
void DoFinalizationChecks(const Program &program)
static constexpr int kVariableSlotLimit
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core counts
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
static SkString to_string(int n)
static bool IsRuntimeEffect(ProgramKind kind)
static bool IsCompute(ProgramKind kind)
std::vector< std::unique_ptr< ProgramElement > > fOwnedElements
std::shared_ptr< Context > fContext
const ProgramUsage * usage() const
std::unique_ptr< ProgramConfig > fConfig