Debian Codegraph @

src/sksl/codegen/SkSLSPIRVCodeGenerator.h

raw
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 "include/core/SkSpan.h"
12 #include "src/sksl/codegen/SkSLNativeShader.h"
13
14 #include <cstdint>
15 #include <vector>
16
17 namespace SkSL {
18
19 class ErrorReporter;
20 class OutputStream;
21 struct Program;
22 struct ShaderCaps;
23
24 using ValidateSPIRVProc = bool (*)(ErrorReporter&, SkSpan<const uint32_t>);
25
26 /**
27 * Converts a Program into a SPIR-V binary. Prefer the std::vector<uint32_t> variant bacause the
28 * OutputStream variant incurs an additional copy.
29 */
30 bool ToSPIRV(Program& program, const ShaderCaps* caps, OutputStream& out, ValidateSPIRVProc = nullptr);
31 bool ToSPIRV(Program& program,
32 const ShaderCaps* caps,
33 std::vector<uint32_t>* out,
34 ValidateSPIRVProc = nullptr);
35
36 // This explicit overload is used by SkSLToBackend.
37 inline bool ToSPIRV(Program& program, const ShaderCaps* caps, NativeShader* out) {
38 return ToSPIRV(program, caps, &out->fBinary, nullptr);
39 }
40 } // namespace SkSL
41
42 #endif