Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
skgpu::graphite::DawnCaps Class Referencefinal

#include <DawnCaps.h>

Inheritance diagram for skgpu::graphite::DawnCaps:
skgpu::graphite::Caps

Public Member Functions

 DawnCaps (const DawnBackendContext &, const ContextOptions &)
 
 ~DawnCaps () override
 
bool useAsyncPipelineCreation () const
 
bool allowScopedErrorChecks () const
 
TextureInfo getDefaultSampledTextureInfo (SkColorType, Mipmapped mipmapped, Protected, Renderable) const override
 
TextureInfo getTextureInfoForSampledCopy (const TextureInfo &textureInfo, Mipmapped mipmapped) const override
 
TextureInfo getDefaultCompressedTextureInfo (SkTextureCompressionType, Mipmapped mipmapped, Protected) const override
 
TextureInfo getDefaultMSAATextureInfo (const TextureInfo &singleSampledInfo, Discardable discardable) const override
 
TextureInfo getDefaultDepthStencilTextureInfo (SkEnumBitMask< DepthStencilFlags >, uint32_t sampleCount, Protected) const override
 
TextureInfo getDefaultStorageTextureInfo (SkColorType) const override
 
SkISize getDepthAttachmentDimensions (const TextureInfo &, const SkISize colorAttachmentDimensions) const override
 
UniqueKey makeGraphicsPipelineKey (const GraphicsPipelineDesc &, const RenderPassDesc &) const override
 
UniqueKey makeComputePipelineKey (const ComputePipelineDesc &) const override
 
uint32_t channelMask (const TextureInfo &) const override
 
bool isRenderable (const TextureInfo &) const override
 
bool isStorage (const TextureInfo &) const override
 
void buildKeyForTexture (SkISize dimensions, const TextureInfo &, ResourceType, Shareable, GraphiteResourceKey *) const override
 
uint64_t getRenderPassDescKey (const RenderPassDesc &renderPassDesc) const
 
- Public Member Functions inherited from skgpu::graphite::Caps
virtual ~Caps ()
 
const SkSL::ShaderCapsshaderCaps () const
 
sk_sp< SkCapabilitiescapabilities () const
 
virtual GraphiteResourceKey makeSamplerKey (const SamplerDesc &samplerDesc) const
 
virtual bool extractGraphicsDescs (const UniqueKey &, GraphicsPipelineDesc *, RenderPassDesc *, const RendererProvider *) const
 
bool areColorTypeAndTextureInfoCompatible (SkColorType, const TextureInfo &) const
 
bool isTexturable (const TextureInfo &) const
 
int maxTextureSize () const
 
int defaultMSAASamplesCount () const
 
const ResourceBindingRequirementsresourceBindingRequirements () const
 
size_t requiredUniformBufferAlignment () const
 
size_t requiredStorageBufferAlignment () const
 
size_t requiredTransferBufferAlignment () const
 
size_t getAlignedTextureDataRowBytes (size_t rowBytes) const
 
SkColorType getRenderableColorType (SkColorType) const
 
bool clampToBorderSupport () const
 
bool protectedSupport () const
 
bool semaphoreSupport () const
 
bool allowCpuSync () const
 
bool storageBufferSupport () const
 
bool storageBufferPreferred () const
 
bool drawBufferCanBeMapped () const
 
bool bufferMapsAreAsync () const
 
bool msaaRenderToSingleSampledSupport () const
 
bool computeSupport () const
 
bool supportsAHardwareBufferImages () const
 
skgpu::Swizzle getReadSwizzle (SkColorType, const TextureInfo &) const
 
skgpu::Swizzle getWriteSwizzle (SkColorType, const TextureInfo &) const
 
skgpu::ShaderErrorHandlershaderErrorHandler () const
 
DstReadRequirement getDstReadRequirement () const
 
float minDistanceFieldFontSize () const
 
float glyphsAsPathsFontSize () const
 
size_t glyphCacheTextureMaximumBytes () const
 
int maxPathAtlasTextureSize () const
 
bool allowMultipleAtlasTextures () const
 
bool supportBilerpFromGlyphAtlas () const
 
bool requireOrderedRecordings () const
 
bool fullCompressedUploadSizeMustAlignToBlockDims () const
 
sktext::gpu::SDFTControl getSDFTControl (bool useSDFTForSmallText) const
 

Static Public Attributes

static constexpr size_t kFormatCnt = 16
 

Private Member Functions

const ColorTypeInfogetColorTypeInfo (SkColorType, const TextureInfo &) const override
 
bool onIsTexturable (const TextureInfo &) const override
 
bool supportsWritePixels (const TextureInfo &textureInfo) const override
 
bool supportsReadPixels (const TextureInfo &textureInfo) const override
 
std::pair< SkColorType, bool > supportedWritePixelsColorType (SkColorType dstColorType, const TextureInfo &dstTextureInfo, SkColorType srcColorType) const override
 
std::pair< SkColorType, bool > supportedReadPixelsColorType (SkColorType srcColorType, const TextureInfo &srcTextureInfo, SkColorType dstColorType) const override
 

Additional Inherited Members

- Protected Member Functions inherited from skgpu::graphite::Caps
 Caps ()
 
void finishInitialization (const ContextOptions &)
 
- Static Protected Member Functions inherited from skgpu::graphite::Caps
static uint32_t SamplesToKey (uint32_t numSamples)
 
- Protected Attributes inherited from skgpu::graphite::Caps
int fMaxTextureSize = 0
 
int fDefaultMSAASamples = 4
 
size_t fRequiredUniformBufferAlignment = 0
 
size_t fRequiredStorageBufferAlignment = 0
 
size_t fRequiredTransferBufferAlignment = 0
 
size_t fTextureDataRowBytesAlignment = 1
 
std::unique_ptr< SkSL::ShaderCapsfShaderCaps
 
bool fClampToBorderSupport = true
 
bool fProtectedSupport = false
 
bool fSemaphoreSupport = false
 
bool fAllowCpuSync = true
 
bool fStorageBufferSupport = false
 
bool fStorageBufferPreferred = false
 
bool fDrawBufferCanBeMapped = true
 
bool fBufferMapsAreAsync = false
 
bool fMSAARenderToSingleSampledSupport = false
 
bool fComputeSupport = false
 
bool fSupportsAHardwareBufferImages = false
 
bool fFullCompressedUploadSizeMustAlignToBlockDims = false
 
ResourceBindingRequirements fResourceBindingReqs
 
ShaderErrorHandlerfShaderErrorHandler = nullptr
 
size_t fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4
 
float fMinDistanceFieldFontSize = 18
 
float fGlyphsAsPathsFontSize = 324
 
int fMaxPathAtlasTextureSize = 8192
 
bool fAllowMultipleAtlasTextures = true
 
bool fSupportBilerpFromGlyphAtlas = false
 
bool fRequireOrderedRecordings = false
 

Detailed Description

Definition at line 22 of file DawnCaps.h.

Constructor & Destructor Documentation

◆ DawnCaps()

skgpu::graphite::DawnCaps::DawnCaps ( const DawnBackendContext backendContext,
const ContextOptions options 
)

Definition at line 72 of file DawnCaps.cpp.

73 : Caps() {
74 this->initCaps(backendContext, options);
75 this->initShaderCaps(backendContext.fDevice);
76 this->initFormatTable(backendContext.fDevice);
78}
const char * options
void finishInitialization(const ContextOptions &)
Definition Caps.cpp:29

◆ ~DawnCaps()

skgpu::graphite::DawnCaps::~DawnCaps ( )
overridedefault

Member Function Documentation

◆ allowScopedErrorChecks()

bool skgpu::graphite::DawnCaps::allowScopedErrorChecks ( ) const
inline

Definition at line 28 of file DawnCaps.h.

28{ return fAllowScopedErrorChecks; }

◆ buildKeyForTexture()

void skgpu::graphite::DawnCaps::buildKeyForTexture ( SkISize  dimensions,
const TextureInfo info,
ResourceType  type,
Shareable  shareable,
GraphiteResourceKey key 
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 888 of file DawnCaps.cpp.

892 {
893 const DawnTextureSpec& dawnSpec = info.dawnTextureSpec();
894
895 SkASSERT(!dimensions.isEmpty());
896
897 SkASSERT(dawnSpec.getViewFormat() != wgpu::TextureFormat::Undefined);
898 uint32_t formatKey = static_cast<uint32_t>(dawnSpec.getViewFormat());
899
900 uint32_t samplesKey = SamplesToKey(info.numSamples());
901 // We don't have to key the number of mip levels because it is inherit in the combination of
902 // isMipped and dimensions.
903 bool isMipped = info.mipmapped() == Mipmapped::kYes;
904
905 // Confirm all the below parts of the key can fit in a single uint32_t. The sum of the shift
906 // amounts in the asserts must be less than or equal to 32.
907 SkASSERT(samplesKey < (1u << 3)); // sample key is first 3 bits
908 SkASSERT(static_cast<uint32_t>(isMipped) < (1u << 1)); // isMapped is 4th bit
909 SkASSERT(static_cast<uint32_t>(dawnSpec.fUsage) < (1u << 28)); // usage is remaining 28 bits
910
911 // We need two uint32_ts for dimensions, 1 for format, and 1 for the rest of the key;
912 static int kNum32DataCnt = 2 + 1 + 1;
913
914 GraphiteResourceKey::Builder builder(key, type, kNum32DataCnt, shareable);
915
916 builder[0] = dimensions.width();
917 builder[1] = dimensions.height();
918 builder[2] = formatKey;
919 builder[3] = (samplesKey << 0) |
920 (static_cast<uint32_t>(isMipped) << 3) |
921 (static_cast<uint32_t>(dawnSpec.fUsage) << 4);
922}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
#define SkASSERT(cond)
Definition SkAssert.h:116
static uint32_t SamplesToKey(uint32_t numSamples)
Definition Caps.h:305
bool isEmpty() const
Definition SkSize.h:31
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

◆ channelMask()

uint32_t skgpu::graphite::DawnCaps::channelMask ( const TextureInfo info) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 82 of file DawnCaps.cpp.

82 {
83 return DawnFormatChannels(info.dawnTextureSpec().getViewFormat());
84}
uint32_t DawnFormatChannels(wgpu::TextureFormat format)
Definition DawnUtils.cpp:57

◆ getColorTypeInfo()

const Caps::ColorTypeInfo * skgpu::graphite::DawnCaps::getColorTypeInfo ( SkColorType  colorType,
const TextureInfo textureInfo 
) const
overrideprivatevirtual

Implements skgpu::graphite::Caps.

Definition at line 344 of file DawnCaps.cpp.

345 {
346 auto dawnFormat = textureInfo.dawnTextureSpec().getViewFormat();
347 if (dawnFormat == wgpu::TextureFormat::Undefined) {
348 SkASSERT(false);
349 return nullptr;
350 }
351
352 const FormatInfo& info = this->getFormatInfo(dawnFormat);
353 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
354 const ColorTypeInfo& ctInfo = info.fColorTypeInfos[i];
355 if (ctInfo.fColorType == colorType) {
356 return &ctInfo;
357 }
358 }
359
360 return nullptr;
361}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)

◆ getDefaultCompressedTextureInfo()

TextureInfo skgpu::graphite::DawnCaps::getDefaultCompressedTextureInfo ( SkTextureCompressionType  compression,
Mipmapped  mipmapped,
Protected   
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 236 of file DawnCaps.cpp.

238 {
239 wgpu::TextureUsage usage = wgpu::TextureUsage::TextureBinding |
240 wgpu::TextureUsage::CopyDst |
241 wgpu::TextureUsage::CopySrc;
242
243 wgpu::TextureFormat format = format_from_compression(compression);
244 if (format == wgpu::TextureFormat::Undefined) {
245 return {};
246 }
247
248 DawnTextureInfo info;
249 info.fSampleCount = 1;
250 info.fMipmapped = mipmapped;
251 info.fFormat = format;
252 info.fViewFormat = format;
253 info.fUsage = usage;
254
255 return info;
256}
uint32_t uint32_t * format
static void usage(char *argv0)

◆ getDefaultDepthStencilTextureInfo()

TextureInfo skgpu::graphite::DawnCaps::getDefaultDepthStencilTextureInfo ( SkEnumBitMask< DepthStencilFlags depthStencilType,
uint32_t  sampleCount,
Protected   
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 281 of file DawnCaps.cpp.

284 {
285 DawnTextureInfo info;
286 info.fSampleCount = sampleCount;
287 info.fMipmapped = Mipmapped::kNo;
288 info.fFormat = DawnDepthStencilFlagsToFormat(depthStencilType);
289 info.fViewFormat = info.fFormat;
290 info.fUsage = wgpu::TextureUsage::RenderAttachment;
291
292#if !defined(__EMSCRIPTEN__)
293 if (fTransientAttachmentSupport) {
294 info.fUsage |= wgpu::TextureUsage::TransientAttachment;
295 }
296#endif
297
298 return info;
299}
wgpu::TextureFormat DawnDepthStencilFlagsToFormat(SkEnumBitMask< DepthStencilFlags > mask)

◆ getDefaultMSAATextureInfo()

TextureInfo skgpu::graphite::DawnCaps::getDefaultMSAATextureInfo ( const TextureInfo singleSampledInfo,
Discardable  discardable 
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 258 of file DawnCaps.cpp.

259 {
260 if (fDefaultMSAASamples <= 1) {
261 return {};
262 }
263 const DawnTextureSpec& singleSpec = singleSampledInfo.dawnTextureSpec();
264
265 DawnTextureInfo info;
266 info.fSampleCount = fDefaultMSAASamples;
267 info.fMipmapped = Mipmapped::kNo;
268 info.fFormat = singleSpec.fFormat;
269 info.fViewFormat = singleSpec.fFormat;
270 info.fUsage = wgpu::TextureUsage::RenderAttachment;
271
272#if !defined(__EMSCRIPTEN__)
273 if (fTransientAttachmentSupport && discardable == Discardable::kYes) {
274 info.fUsage |= wgpu::TextureUsage::TransientAttachment;
275 }
276#endif
277
278 return info;
279}

◆ getDefaultSampledTextureInfo()

TextureInfo skgpu::graphite::DawnCaps::getDefaultSampledTextureInfo ( SkColorType  colorType,
Mipmapped  mipmapped,
Protected  ,
Renderable  renderable 
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 182 of file DawnCaps.cpp.

185 {
186 wgpu::TextureUsage usage = wgpu::TextureUsage::TextureBinding |
187 wgpu::TextureUsage::CopyDst |
188 wgpu::TextureUsage::CopySrc;
189 if (renderable == Renderable::kYes) {
190 usage |= wgpu::TextureUsage::RenderAttachment;
191 }
192
193 wgpu::TextureFormat format = this->getFormatFromColorType(colorType);
194 if (format == wgpu::TextureFormat::Undefined) {
195 return {};
196 }
197
198 DawnTextureInfo info;
199 info.fSampleCount = 1;
200 info.fMipmapped = mipmapped;
201 info.fFormat = format;
202 info.fViewFormat = format;
203 info.fUsage = usage;
204
205 return info;
206}

◆ getDefaultStorageTextureInfo()

TextureInfo skgpu::graphite::DawnCaps::getDefaultStorageTextureInfo ( SkColorType  colorType) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 301 of file DawnCaps.cpp.

301 {
302 wgpu::TextureFormat format = this->getFormatFromColorType(colorType);
303 if (format == wgpu::TextureFormat::Undefined) {
304 SkDebugf("colorType=%d is not supported\n", static_cast<int>(colorType));
305 return {};
306 }
307
308 const FormatInfo& formatInfo = this->getFormatInfo(format);
309 if (!SkToBool(FormatInfo::kStorage_Flag & formatInfo.fFlags)) {
310 return {};
311 }
312
313 wgpu::TextureUsage usage = wgpu::TextureUsage::StorageBinding |
314 wgpu::TextureUsage::TextureBinding |
315 wgpu::TextureUsage::CopySrc;
316 DawnTextureInfo info;
317 info.fSampleCount = 1;
318 info.fMipmapped = Mipmapped::kNo;
319 info.fFormat = format;
320 info.fViewFormat = format;
321 info.fUsage = usage;
322
323 return info;
324}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35

◆ getDepthAttachmentDimensions()

SkISize skgpu::graphite::DawnCaps::getDepthAttachmentDimensions ( const TextureInfo textureInfo,
const SkISize  colorAttachmentDimensions 
) const
overridevirtual

Reimplemented from skgpu::graphite::Caps.

Definition at line 326 of file DawnCaps.cpp.

327 {
328#if !defined(__EMSCRIPTEN__)
329 // For multiplanar textures, texture->textureInfo() uses the format of planes instead of
330 // textures (R8, R8G8, vs R8BG8Biplanar420Unorm), so we have to query texture format from
331 // wgpu::Texture object, and then use it reconstruct the full dimensions.
332 const auto& dawnTextureSpec = textureInfo.dawnTextureSpec();
333 wgpu::TextureFormat format = dawnTextureSpec.fFormat;
334 if (IsMultiplanarFormat(format) && dawnTextureSpec.fAspect == wgpu::TextureAspect::Plane1Only) {
335 // Dawn requires depth attachment to match the size of Y plane (texture size).
336 return SkISize::Make(colorAttachmentDimensions.width() * 2,
337 colorAttachmentDimensions.height() * 2);
338 }
339#endif
340
341 return colorAttachmentDimensions;
342}
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getRenderPassDescKey()

uint64_t skgpu::graphite::DawnCaps::getRenderPassDescKey ( const RenderPassDesc renderPassDesc) const

Definition at line 836 of file DawnCaps.cpp.

836 {
837 DawnTextureInfo colorInfo, depthStencilInfo;
838 renderPassDesc.fColorAttachment.fTextureInfo.getDawnTextureInfo(&colorInfo);
839 renderPassDesc.fDepthStencilAttachment.fTextureInfo.getDawnTextureInfo(&depthStencilInfo);
840 SkASSERT(static_cast<uint32_t>(colorInfo.getViewFormat()) <= 0xffff &&
841 static_cast<uint32_t>(depthStencilInfo.getViewFormat()) <= 0xffff);
842 uint32_t colorAttachmentKey =
843 static_cast<uint32_t>(colorInfo.getViewFormat()) << 16 | colorInfo.fSampleCount;
844 uint32_t dsAttachmentKey = static_cast<uint32_t>(depthStencilInfo.getViewFormat()) << 16 |
845 depthStencilInfo.fSampleCount;
846 return (((uint64_t) colorAttachmentKey) << 32) | dsAttachmentKey;
847}

◆ getTextureInfoForSampledCopy()

TextureInfo skgpu::graphite::DawnCaps::getTextureInfoForSampledCopy ( const TextureInfo textureInfo,
Mipmapped  mipmapped 
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 208 of file DawnCaps.cpp.

209 {
210 DawnTextureInfo info;
211 if (!textureInfo.getDawnTextureInfo(&info)) {
212 return {};
213 }
214
215 info.fSampleCount = 1;
216 info.fMipmapped = mipmapped;
217 info.fUsage = wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::CopyDst |
218 wgpu::TextureUsage::CopySrc;
219
220 return info;
221}

◆ isRenderable()

bool skgpu::graphite::DawnCaps::isRenderable ( const TextureInfo info) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 149 of file DawnCaps.cpp.

149 {
150 return info.isValid() &&
151 (info.dawnTextureSpec().fUsage & wgpu::TextureUsage::RenderAttachment) &&
152 this->isRenderable(info.dawnTextureSpec().getViewFormat(), info.numSamples());
153}
bool isRenderable(const TextureInfo &) const override
Definition DawnCaps.cpp:149

◆ isStorage()

bool skgpu::graphite::DawnCaps::isStorage ( const TextureInfo info) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 155 of file DawnCaps.cpp.

155 {
156 if (!info.isValid()) {
157 return false;
158 }
159 if (!(info.dawnTextureSpec().fUsage & wgpu::TextureUsage::StorageBinding)) {
160 return false;
161 }
162 const FormatInfo& formatInfo = this->getFormatInfo(info.dawnTextureSpec().getViewFormat());
163 return info.numSamples() == 1 && SkToBool(FormatInfo::kStorage_Flag & formatInfo.fFlags);
164}

◆ makeComputePipelineKey()

UniqueKey skgpu::graphite::DawnCaps::makeComputePipelineKey ( const ComputePipelineDesc pipelineDesc) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 871 of file DawnCaps.cpp.

871 {
872 UniqueKey pipelineKey;
873 {
874 static const skgpu::UniqueKey::Domain kComputePipelineDomain = UniqueKey::GenerateDomain();
875 // The key is made up of a single uint32_t corresponding to the compute step ID.
876 UniqueKey::Builder builder(&pipelineKey, kComputePipelineDomain, 1, "ComputePipeline");
877 builder[0] = pipelineDesc.computeStep()->uniqueID();
878
879 // TODO(b/240615224): The local work group size should factor into the key here since it is
880 // specified in the shader text on Dawn/SPIR-V. This is not a problem right now since
881 // ComputeSteps don't vary their workgroup size dynamically.
882
883 builder.finish();
884 }
885 return pipelineKey;
886}
static Domain GenerateDomain()

◆ makeGraphicsPipelineKey()

UniqueKey skgpu::graphite::DawnCaps::makeGraphicsPipelineKey ( const GraphicsPipelineDesc pipelineDesc,
const RenderPassDesc renderPassDesc 
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 849 of file DawnCaps.cpp.

850 {
851 UniqueKey pipelineKey;
852 {
854 // 5 uint32_t's (render step id, paint id, uint64 RenderPass desc, uint16 write swizzle)
855 UniqueKey::Builder builder(&pipelineKey, kGraphicsPipelineDomain, 5, "GraphicsPipeline");
856 // add GraphicsPipelineDesc key
857 builder[0] = pipelineDesc.renderStepID();
858 builder[1] = pipelineDesc.paintParamsID().asUInt();
859
860 // add RenderPassDesc key
861 uint64_t renderPassKey = this->getRenderPassDescKey(renderPassDesc);
862 builder[2] = renderPassKey & 0xFFFFFFFF;
863 builder[3] = (renderPassKey >> 32) & 0xFFFFFFFF;
864 builder[4] = renderPassDesc.fWriteSwizzle.asKey();
865 builder.finish();
866 }
867
868 return pipelineKey;
869}
uint64_t getRenderPassDescKey(const RenderPassDesc &renderPassDesc) const
Definition DawnCaps.cpp:836
static const skgpu::UniqueKey::Domain kGraphicsPipelineDomain
Definition MtlCaps.mm:959

◆ onIsTexturable()

bool skgpu::graphite::DawnCaps::onIsTexturable ( const TextureInfo info) const
overrideprivatevirtual

Implements skgpu::graphite::Caps.

Definition at line 86 of file DawnCaps.cpp.

86 {
87 if (!info.isValid()) {
88 return false;
89 }
90
91 const auto& spec = info.dawnTextureSpec();
92
93 if (!(spec.fUsage & wgpu::TextureUsage::TextureBinding)) {
94 return false;
95 }
96
97#if !defined(__EMSCRIPTEN__)
98 switch (spec.fFormat) {
99 case wgpu::TextureFormat::R8BG8Biplanar420Unorm: {
100 if (spec.fAspect == wgpu::TextureAspect::Plane0Only &&
101 spec.getViewFormat() != wgpu::TextureFormat::R8Unorm) {
102 return false;
103 }
104 if (spec.fAspect == wgpu::TextureAspect::Plane1Only &&
105 spec.getViewFormat() != wgpu::TextureFormat::RG8Unorm) {
106 return false;
107 }
108 break;
109 }
110 case wgpu::TextureFormat::R10X6BG10X6Biplanar420Unorm: {
111 if (spec.fAspect == wgpu::TextureAspect::Plane0Only &&
112 spec.getViewFormat() != wgpu::TextureFormat::R16Unorm) {
113 return false;
114 }
115 if (spec.fAspect == wgpu::TextureAspect::Plane1Only &&
116 spec.getViewFormat() != wgpu::TextureFormat::RG16Unorm) {
117 return false;
118 }
119 break;
120 }
121 case wgpu::TextureFormat::R8BG8A8Triplanar420Unorm: {
122 if (spec.fAspect == wgpu::TextureAspect::Plane0Only &&
123 spec.getViewFormat() != wgpu::TextureFormat::R8Unorm) {
124 return false;
125 }
126 if (spec.fAspect == wgpu::TextureAspect::Plane1Only &&
127 spec.getViewFormat() != wgpu::TextureFormat::RG8Unorm) {
128 return false;
129 }
130 if (spec.fAspect == wgpu::TextureAspect::Plane2Only &&
131 spec.getViewFormat() != wgpu::TextureFormat::R8Unorm) {
132 return false;
133 }
134 break;
135 }
136 default:
137 break;
138 }
139#endif
140
141 return this->isTexturable(info.dawnTextureSpec().getViewFormat());
142}

◆ supportedReadPixelsColorType()

std::pair< SkColorType, bool > skgpu::graphite::DawnCaps::supportedReadPixelsColorType ( SkColorType  srcColorType,
const TextureInfo srcTextureInfo,
SkColorType  dstColorType 
) const
overrideprivatevirtual

Given a src surface's color type and its texture info as well as a color type the caller would like read into, this provides a legal color type that the caller can use for readPixels. The returned color type may differ from the passed dstColorType, in which case the caller must convert the read pixel data (see GrConvertPixels). When converting to dstColorType the swizzle in the returned struct should be applied. The caller must check the returned color type for kUnknown.

We currently don't have an SkColorType for a 3 channel RGB format. Additionally the current implementation of raster pipeline requires power of 2 channels, so it is not easy to add such an SkColorType. Thus we need to check for data that is 3 channels using the isRGBFormat return value and handle it manually

Implements skgpu::graphite::Caps.

Definition at line 380 of file DawnCaps.cpp.

383 {
384 auto dawnFormat = getFormatFromColorType(srcColorType);
385 const FormatInfo& info = this->getFormatInfo(dawnFormat);
386 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
387 const auto& ctInfo = info.fColorTypeInfos[i];
388 if (ctInfo.fColorType == srcColorType) {
389 return {srcColorType, false};
390 }
391 }
392 return {kUnknown_SkColorType, false};
393}
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20

◆ supportedWritePixelsColorType()

std::pair< SkColorType, bool > skgpu::graphite::DawnCaps::supportedWritePixelsColorType ( SkColorType  dstColorType,
const TextureInfo dstTextureInfo,
SkColorType  srcColorType 
) const
overrideprivatevirtual

Given a dst pixel config and a src color type what color type must the caller coax the the data into in order to use writePixels.

We currently don't have an SkColorType for a 3 channel RGB format. Additionally the current implementation of raster pipeline requires power of 2 channels, so it is not easy to add such an SkColorType. Thus we need to check for data that is 3 channels using the isRGBFormat return value and handle it manually

Implements skgpu::graphite::Caps.

Definition at line 373 of file DawnCaps.cpp.

376 {
377 return {dstColorType, false};
378}

◆ supportsReadPixels()

bool skgpu::graphite::DawnCaps::supportsReadPixels ( const TextureInfo textureInfo) const
overrideprivatevirtual

Backends may have restrictions on what types of textures support Device::readPixels(). If this returns false then the caller should implement a fallback where a temporary texture is created, the original texture is copied or drawn into it, and then pixels read from the temporary texture.

Implements skgpu::graphite::Caps.

Definition at line 368 of file DawnCaps.cpp.

368 {
369 const auto& spec = textureInfo.dawnTextureSpec();
370 return spec.fUsage & wgpu::TextureUsage::CopySrc;
371}

◆ supportsWritePixels()

bool skgpu::graphite::DawnCaps::supportsWritePixels ( const TextureInfo textureInfo) const
overrideprivatevirtual

Backends may have restrictions on what types of textures support Device::writePixels(). If this returns false then the caller should implement a fallback where a temporary texture is created, pixels are written to it, and then that is copied or drawn into the the surface.

Implements skgpu::graphite::Caps.

Definition at line 363 of file DawnCaps.cpp.

363 {
364 const auto& spec = textureInfo.dawnTextureSpec();
365 return spec.fUsage & wgpu::TextureUsage::CopyDst;
366}

◆ useAsyncPipelineCreation()

bool skgpu::graphite::DawnCaps::useAsyncPipelineCreation ( ) const
inline

Definition at line 27 of file DawnCaps.h.

27{ return fUseAsyncPipelineCreation; }

Member Data Documentation

◆ kFormatCnt

constexpr size_t skgpu::graphite::DawnCaps::kFormatCnt = 16
staticconstexpr

Definition at line 60 of file DawnCaps.h.


The documentation for this class was generated from the following files: