Brian Osman | 0a442b7 | 2020-12-02 11:12:51 -0500 | [diff] [blame] | 1 | /* |
| 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 | |
| 16 | namespace SkSL { |
| 17 | |
| 18 | class FunctionDefinition; |
| 19 | struct Program; |
| 20 | |
| 21 | using 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 |
| 27 | skvm::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 Osman | 5933d4c | 2021-01-05 13:02:20 -0500 | [diff] [blame^] | 35 | const FunctionDefinition* Program_GetFunction(const Program& program, const char* function); |
| 36 | |
Brian Osman | 47726a1 | 2020-12-17 16:02:08 -0500 | [diff] [blame] | 37 | bool testingOnly_ProgramToSkVMShader(const Program& program, skvm::Builder* builder); |
| 38 | |
Brian Osman | 0a442b7 | 2020-12-02 11:12:51 -0500 | [diff] [blame] | 39 | } // namespace SkSL |
| 40 | |
| 41 | #endif |