Flutter Engine
The Flutter Engine
DawnTypes.h
Go to the documentation of this file.
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_DawnTypes_DEFINED
9#define skgpu_graphite_DawnTypes_DEFINED
10
12#include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
13
14namespace skgpu::graphite {
15
17 uint32_t fSampleCount = 1;
19
20 // wgpu::TextureDescriptor properties
21 wgpu::TextureFormat fFormat = wgpu::TextureFormat::Undefined;
22 // `fViewFormat` for multiplanar formats corresponds to the plane TextureView's format.
23 wgpu::TextureFormat fViewFormat = wgpu::TextureFormat::Undefined;
24 wgpu::TextureUsage fUsage = wgpu::TextureUsage::None;
25 // TODO(b/308944094): Migrate aspect information to BackendTextureViews.
26 wgpu::TextureAspect fAspect = wgpu::TextureAspect::All;
27 uint32_t fSlice = 0;
28
29#if !defined(__EMSCRIPTEN__)
30 // The descriptor of the YCbCr info (if any) for this texture. Dawn's YCbCr
31 // sampling will be used for this texture if this info is set. Setting the
32 // info is supported only on Android and only if using Vulkan as the
33 // underlying GPU driver.
34 wgpu::YCbCrVkDescriptor fYcbcrVkDescriptor = {};
35#endif
36
37 wgpu::TextureFormat getViewFormat() const {
38 return fViewFormat != wgpu::TextureFormat::Undefined ? fViewFormat : fFormat;
39 }
40
41 DawnTextureInfo() = default;
42
43 DawnTextureInfo(uint32_t sampleCount,
44 Mipmapped mipmapped,
45 wgpu::TextureFormat format,
47 wgpu::TextureAspect aspect)
48 : DawnTextureInfo(sampleCount,
49 mipmapped,
50 /*format=*/format,
51 /*viewFormat=*/format,
52 usage,
53 aspect,
54 /*slice=*/0) {}
55
56 DawnTextureInfo(uint32_t sampleCount,
57 Mipmapped mipmapped,
58 wgpu::TextureFormat format,
59 wgpu::TextureFormat viewFormat,
61 wgpu::TextureAspect aspect,
62 uint32_t slice)
63 : fSampleCount(sampleCount)
64 , fMipmapped(mipmapped)
66 , fViewFormat(viewFormat)
67 , fUsage(usage)
68 , fAspect(aspect)
69 , fSlice(slice) {}
70
71#if !defined(__EMSCRIPTEN__)
72 DawnTextureInfo(uint32_t sampleCount,
73 Mipmapped mipmapped,
74 wgpu::TextureFormat format,
75 wgpu::TextureFormat viewFormat,
77 wgpu::TextureAspect aspect,
78 uint32_t slice,
79 wgpu::YCbCrVkDescriptor ycbcrVkDescriptor)
80 : fSampleCount(sampleCount)
81 , fMipmapped(mipmapped)
83 , fViewFormat(viewFormat)
84 , fUsage(usage)
85 , fAspect(aspect)
86 , fSlice(slice)
87 , fYcbcrVkDescriptor(ycbcrVkDescriptor) {}
88#endif
89};
90
91} // namespace skgpu::graphite
92
93#endif // skgpu_graphite_DawnTypes_DEFINED
94
95
uint32_t uint32_t * format
TextureUsage
Definition: formats.h:300
Mipmapped
Definition: GpuTypes.h:53
static void usage(char *argv0)
wgpu::TextureFormat fViewFormat
Definition: DawnTypes.h:23
wgpu::TextureFormat getViewFormat() const
Definition: DawnTypes.h:37
DawnTextureInfo(uint32_t sampleCount, Mipmapped mipmapped, wgpu::TextureFormat format, wgpu::TextureFormat viewFormat, wgpu::TextureUsage usage, wgpu::TextureAspect aspect, uint32_t slice, wgpu::YCbCrVkDescriptor ycbcrVkDescriptor)
Definition: DawnTypes.h:72
wgpu::TextureFormat fFormat
Definition: DawnTypes.h:21
wgpu::YCbCrVkDescriptor fYcbcrVkDescriptor
Definition: DawnTypes.h:34
DawnTextureInfo(uint32_t sampleCount, Mipmapped mipmapped, wgpu::TextureFormat format, wgpu::TextureFormat viewFormat, wgpu::TextureUsage usage, wgpu::TextureAspect aspect, uint32_t slice)
Definition: DawnTypes.h:56
wgpu::TextureAspect fAspect
Definition: DawnTypes.h:26
wgpu::TextureUsage fUsage
Definition: DawnTypes.h:24
DawnTextureInfo(uint32_t sampleCount, Mipmapped mipmapped, wgpu::TextureFormat format, wgpu::TextureUsage usage, wgpu::TextureAspect aspect)
Definition: DawnTypes.h:43