| 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 "include/core/SkSpan.h" |
| 12 |
#include "src/sksl/codegen/SkSLNativeShader.h" |
| 13 |
|
| 14 |
#include <cstdint> |
| 15 |
#include <string> |
| 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 |
/** Converts a Program into HLSL code. */ |
| 27 |
bool ToHLSL(Program& program, |
| 28 |
const ShaderCaps* caps, |
| 29 |
OutputStream& out, |
| 30 |
ValidateSPIRVProc = nullptr); |
| 31 |
bool ToHLSL(Program& program, const ShaderCaps* caps, std::string* out, ValidateSPIRVProc); |
| 32 |
|
| 33 |
// This explicit overload is used by SkSLToBackend. |
| 34 |
inline bool ToHLSL(Program& program, const ShaderCaps* caps, NativeShader* out) { |
| 35 |
return ToHLSL(program, caps, &out->fText, (ValidateSPIRVProc) nullptr); |
| 36 |
} |
| 37 |
|
| 38 |
} // namespace SkSL |
| 39 |
|
| 40 |
#endif |