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_HLSLCODEGENERATOR
9 #define SKSL_HLSLCODEGENERATOR
10
11 #include <string>
12 #include <string_view>
13
14 namespace SkSL {
15
16 class ErrorReporter;
17 class OutputStream;
18 struct Program;
19 struct ShaderCaps;
20
21 using ValidateSPIRVProc = bool (*)(ErrorReporter&, std::string_view);
22
23 /** Converts a Program into HLSL code. */
24 bool ToHLSL(Program& program,
25 const ShaderCaps* caps,
26 OutputStream& out,
27 ValidateSPIRVProc = nullptr);
28 bool ToHLSL(Program& program, const ShaderCaps* caps, std::string* out, ValidateSPIRVProc);
29
30 // This explicit overload is used by SkSLToBackend.
ToHLSL(Program & program,const ShaderCaps * caps,std::string * out)31 inline bool ToHLSL(Program& program, const ShaderCaps* caps, std::string* out) {
32 return ToHLSL(program, caps, out, nullptr);
33 }
34
35 } // namespace SkSL
36
37 #endif
38