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#include "src/sksl/SkSLSPIRVtoHLSL.h"
9
10#if defined(SK_DIRECT3D)
11
12#include "third_party/externals/spirv-cross/spirv_hlsl.hpp"
13
14/*
15 * This translation unit serves as a bridge between Skia/SkSL and SPIRV-Cross.
16 * Each library is built with a separate copy of spirv.h (or spirv.hpp), so we
17 * avoid conflicts by never including both in the same cpp.
18 */
19
20namespace SkSL {
21
22bool SPIRVtoHLSL(const String& spirv, String* hlsl) {
23 spirv_cross::CompilerHLSL hlslCompiler((const uint32_t*)spirv.c_str(),
24 spirv.size() / sizeof(uint32_t));
25 hlsl->assign(hlslCompiler.compile());
26 return true;
27}
28
29}
30
31#else
32
33namespace SkSL { bool SPIRVtoHLSL(const String&, String*) { return false; } }
34
35#endif
36