1 /*
2 * Copyright 2023 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 skgpu_DawnUtilsPriv_DEFINED
9 #define skgpu_DawnUtilsPriv_DEFINED
10
11 #include "include/core/SkTextureCompressionType.h"
12 #include "src/gpu/SkSLToBackend.h"
13 #include "src/sksl/codegen/SkSLWGSLCodeGenerator.h"
14 #include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
15
16 namespace SkSL {
17
18 enum class ProgramKind : int8_t;
19 struct ProgramInterface;
20 struct ProgramSettings;
21 struct ShaderCaps;
22
23 } // namespace SkSL
24
25 namespace skgpu {
26
27 class ShaderErrorHandler;
28
SkSLToWGSL(const SkSL::ShaderCaps * caps,const std::string & sksl,SkSL::ProgramKind programKind,const SkSL::ProgramSettings & settings,std::string * wgsl,SkSL::ProgramInterface * outInterface,ShaderErrorHandler * errorHandler)29 inline bool SkSLToWGSL(const SkSL::ShaderCaps* caps,
30 const std::string& sksl,
31 SkSL::ProgramKind programKind,
32 const SkSL::ProgramSettings& settings,
33 std::string* wgsl,
34 SkSL::ProgramInterface* outInterface,
35 ShaderErrorHandler* errorHandler) {
36 return SkSLToBackend(caps, &SkSL::ToWGSL, "WGSL",
37 sksl, programKind, settings, wgsl, outInterface, errorHandler);
38 }
39
40 namespace graphite {
41
42 class DawnSharedContext;
43
44 size_t DawnFormatBytesPerBlock(wgpu::TextureFormat format);
45
46 SkTextureCompressionType DawnFormatToCompressionType(wgpu::TextureFormat format);
47
48 uint32_t DawnFormatChannels(wgpu::TextureFormat format);
49
50 } // namespace graphite
51 } // namespace skgpu
52
53 #endif // skgpu_DawnUtilsPriv_DEFINED
54