Debian Codegraph @

src/gpu/graphite/dawn/DawnGraphiteUtils.h

raw
1 /*
2 * Copyright 2022 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_graphite_DawnTypesPriv_DEFINED
9 #define skgpu_graphite_DawnTypesPriv_DEFINED
10
11 #include "include/core/SkImageInfo.h"
12 #include "include/core/SkString.h"
13 #include "include/core/SkTextureCompressionType.h"
14 #include "include/gpu/graphite/dawn/DawnGraphiteTypes.h"
15 #include "src/gpu/SkSLToBackend.h"
16 #include "src/gpu/graphite/ResourceTypes.h"
17 #include "src/sksl/SkSLProgramKind.h"
18 #include "src/sksl/codegen/SkSLNativeShader.h"
19 #include "src/sksl/codegen/SkSLWGSLCodeGenerator.h"
20 #include "src/sksl/ir/SkSLProgram.h"
21
22 #include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
23
24 namespace SkSL {
25
26 enum class ProgramKind : int8_t;
27 struct ProgramInterface;
28 struct ProgramSettings;
29 struct ShaderCaps;
30
31 } // namespace SkSL
32
33 namespace skgpu {
34
35 class ShaderErrorHandler;
36
37 inline bool SkSLToWGSL(const SkSL::ShaderCaps* caps,
38 const std::string& sksl,
39 SkSL::ProgramKind programKind,
40 const SkSL::ProgramSettings& settings,
41 SkSL::NativeShader* wgsl,
42 SkSL::ProgramInterface* outInterface,
43 ShaderErrorHandler* errorHandler) {
44 return SkSLToBackend(caps,
45 &SkSL::ToWGSL,
46 "WGSL",
47 sksl,
48 programKind,
49 settings,
50 wgsl,
51 outInterface,
52 errorHandler);
53 }
54
55 } // namespace skgpu
56
57 namespace skgpu::graphite {
58
59 class DawnSharedContext;
60 enum class TextureFormat : uint8_t;
61
62 bool DawnCompileWGSLShaderModule(const DawnSharedContext* sharedContext,
63 const char* label,
64 const SkSL::NativeShader& wgsl,
65 wgpu::ShaderModule* module,
66 ShaderErrorHandler*);
67
68 #if !defined(__EMSCRIPTEN__)
69
70 bool DawnDescriptorIsValid(const wgpu::YCbCrVkDescriptor&);
71
72 bool DawnDescriptorUsesExternalFormat(const wgpu::YCbCrVkDescriptor&);
73
74 bool DawnDescriptorsAreEquivalent(const wgpu::YCbCrVkDescriptor&, const wgpu::YCbCrVkDescriptor&);
75
76 ImmutableSamplerInfo DawnDescriptorToImmutableSamplerInfo(const wgpu::YCbCrVkDescriptor&);
77 wgpu::YCbCrVkDescriptor DawnDescriptorFromImmutableSamplerInfo(ImmutableSamplerInfo);
78
79 #endif // !defined(__EMSCRIPTEN__)
80
81 SkTextureCompressionType DawnFormatToCompressionType(wgpu::TextureFormat format);
82
83 TextureFormat DawnFormatToTextureFormat(wgpu::TextureFormat);
84 wgpu::TextureFormat TextureFormatToDawnFormat(TextureFormat);
85
86 namespace BackendTextures {
87
88 WGPUTexture GetDawnTexturePtr(const BackendTexture&);
89 WGPUTextureView GetDawnTextureViewPtr(const BackendTexture&);
90
91 } // namespace BackendTextures
92
93 } // namespace skgpu::graphite
94
95 #endif // skgpu_graphite_DawnTypesPriv_DEFINED