xref: /aosp_15_r20/external/skia/src/sksl/codegen/SkSLSPIRVCodeGenerator.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2016 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_SPIRVCODEGENERATOR
9 #define SKSL_SPIRVCODEGENERATOR
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 /**
24  * Converts a Program into a SPIR-V binary.
25  */
26 bool ToSPIRV(Program& program, const ShaderCaps* caps, OutputStream& out, ValidateSPIRVProc = nullptr);
27 bool ToSPIRV(Program& program, const ShaderCaps* caps, std::string* out, ValidateSPIRVProc);
28 
29 // This explicit overload is used by SkSLToBackend.
ToSPIRV(Program & program,const ShaderCaps * caps,std::string * out)30 inline bool ToSPIRV(Program& program, const ShaderCaps* caps, std::string* out) {
31     return ToSPIRV(program, caps, out, nullptr);
32 }
33 }  // namespace SkSL
34 
35 #endif
36