blob: 3759d103c75c054b92915329f698661be6eac0e5 [file] [log] [blame]
Brian Osman0a442b72020-12-02 11:12:51 -05001/*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SKSL_VMGENERATOR
9#define SKSL_VMGENERATOR
10
11#include "src/core/SkSpan.h"
12#include "src/core/SkVM.h"
13
14#include <functional>
15
16namespace SkSL {
17
18class FunctionDefinition;
19struct Program;
20
21using SampleChildFn = std::function<skvm::Color(int, skvm::Coord)>;
22
23// TODO: Have a generic entry point, supporting SkSpan<skvm::Val> for parameters and return values.
24// That would be useful for interpreter use cases like SkParticleEffect.
25
26// Convert 'function' to skvm instructions in 'builder', for use by shaders and color filters
27skvm::Color ProgramToSkVM(const Program& program,
28 const FunctionDefinition& function,
29 skvm::Builder* builder,
30 SkSpan<skvm::Val> uniforms,
31 skvm::Coord device,
32 skvm::Coord local,
33 SampleChildFn sampleChild);
34
Brian Osman5933d4c2021-01-05 13:02:20 -050035const FunctionDefinition* Program_GetFunction(const Program& program, const char* function);
36
Brian Osman47726a12020-12-17 16:02:08 -050037bool testingOnly_ProgramToSkVMShader(const Program& program, skvm::Builder* builder);
38
Brian Osman0a442b72020-12-02 11:12:51 -050039} // namespace SkSL
40
41#endif