xref: /aosp_15_r20/external/skia/src/sksl/codegen/SkSLWGSLCodeGenerator.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2022 Google Inc.
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_WGSLCODEGENERATOR
9 #define SKSL_WGSLCODEGENERATOR
10 
11 #include <string>
12 
13 namespace SkSL {
14 
15 class ErrorReporter;
16 class OutputStream;
17 enum class PrettyPrint : bool;
18 struct Program;
19 struct ShaderCaps;
20 
21 enum class IncludeSyntheticCode : bool {
22     kNo = false,
23     kYes = true,
24 };
25 
26 using ValidateWGSLProc = bool (*)(ErrorReporter&, std::string_view wgsl, std::string* warnings);
27 
28 /**
29  * Convert a Program into WGSL code.
30  */
31 bool ToWGSL(Program& program,
32             const ShaderCaps* caps,
33             OutputStream& out,
34             PrettyPrint,
35             IncludeSyntheticCode,
36             ValidateWGSLProc);
37 bool ToWGSL(Program& program, const ShaderCaps* caps, OutputStream& out);
38 bool ToWGSL(Program& program, const ShaderCaps* caps, std::string* out);
39 
40 }  // namespace SkSL
41 
42 #endif  // SKSL_WGSLCODEGENERATOR
43