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

#include <VulkanCaps.h>

Inheritance diagram for skgpu::graphite::VulkanCaps:
skgpu::graphite::Caps

Public Member Functions

 VulkanCaps (const ContextOptions &, const skgpu::VulkanInterface *, VkPhysicalDevice, uint32_t physicalDeviceVersion, const VkPhysicalDeviceFeatures2 *, const skgpu::VulkanExtensions *, Protected)
 
 ~VulkanCaps () override
 
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
 
UniqueKey makeGraphicsPipelineKey (const GraphicsPipelineDesc &, const RenderPassDesc &) const override
 
UniqueKey makeComputePipelineKey (const ComputePipelineDesc &) const override
 
GraphiteResourceKey makeSamplerKey (const SamplerDesc &) 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
 
bool shouldAlwaysUseDedicatedImageMemory () const
 
bool gpuOnlyBuffersMorePerformant () const
 
bool shouldPersistentlyMapCpuToGpuBuffers () const
 
bool supportsYcbcrConversion () const
 
bool supportsDeviceFaultInfo () const
 
uint32_t maxVertexAttributes () const
 
uint64_t maxUniformBufferRange () const
 
const VkPhysicalDeviceMemoryProperties2physicalDeviceMemoryProperties2 () const
 
bool isTransferSrc (const VulkanTextureInfo &) const
 
bool isTransferDst (const VulkanTextureInfo &) const
 
- Public Member Functions inherited from skgpu::graphite::Caps
virtual ~Caps ()
 
const SkSL::ShaderCapsshaderCaps () const
 
sk_sp< SkCapabilitiescapabilities () const
 
virtual SkISize getDepthAttachmentDimensions (const TextureInfo &, const SkISize colorAttachmentDimensions) 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
 

Private Member Functions

const ColorTypeInfogetColorTypeInfo (SkColorType, const TextureInfo &) const override
 
bool onIsTexturable (const TextureInfo &) const override
 
bool supportsWritePixels (const TextureInfo &) const override
 
bool supportsReadPixels (const 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 20 of file VulkanCaps.h.

Constructor & Destructor Documentation

◆ VulkanCaps()

skgpu::graphite::VulkanCaps::VulkanCaps ( const ContextOptions contextOptions,
const skgpu::VulkanInterface vkInterface,
VkPhysicalDevice  physDev,
uint32_t  physicalDeviceVersion,
const VkPhysicalDeviceFeatures2 features,
const skgpu::VulkanExtensions extensions,
Protected  isProtected 
)

Definition at line 32 of file VulkanCaps.cpp.

39 : Caps() {
40 this->init(contextOptions, vkInterface, physDev, physicalDeviceVersion, features, extensions,
41 isProtected);
42}

◆ ~VulkanCaps()

skgpu::graphite::VulkanCaps::~VulkanCaps ( )
override

Definition at line 44 of file VulkanCaps.cpp.

44{}

Member Function Documentation

◆ buildKeyForTexture()

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

Implements skgpu::graphite::Caps.

Definition at line 1424 of file VulkanCaps.cpp.

1428 {
1429 const VulkanTextureSpec& vkSpec = info.vulkanTextureSpec();
1430
1431 SkASSERT(!dimensions.isEmpty());
1432
1433 // We expect that the VkFormat enum is at most a 32-bit value.
1434 static_assert(VK_FORMAT_MAX_ENUM == 0x7FFFFFFF);
1435 SkASSERT(vkSpec.fFormat != VK_FORMAT_UNDEFINED);
1436 uint32_t formatKey = static_cast<uint32_t>(vkSpec.fFormat);
1437
1438 uint32_t samplesKey = SamplesToKey(info.numSamples());
1439 // We don't have to key the number of mip levels because it is inherit in the combination of
1440 // isMipped and dimensions.
1441 bool isMipped = info.mipmapped() == Mipmapped::kYes;
1442 Protected isProtected = info.isProtected();
1443
1444 // Confirm all the below parts of the key can fit in a single uint32_t. The sum of the shift
1445 // amounts in the asserts must be less than or equal to 32. vkSpec.fFlags will go into its
1446 // own 32-bit block.
1447 SkASSERT(samplesKey < (1u << 3)); // sample key is first 3 bits
1448 SkASSERT(static_cast<uint32_t>(isMipped) < (1u << 1)); // isMapped is 4th bit
1449 SkASSERT(static_cast<uint32_t>(isProtected) < (1u << 1)); // isProtected is 5th bit
1450 SkASSERT(vkSpec.fImageTiling < (1u << 1)); // imageTiling is 6th bit
1451 SkASSERT(vkSpec.fSharingMode < (1u << 1)); // sharingMode is 7th bit
1452 SkASSERT(vkSpec.fAspectMask < (1u << 11)); // aspectMask is bits 8 - 19
1453 SkASSERT(vkSpec.fImageUsageFlags < (1u << 12)); // imageUsageFlags are bits 20-32
1454
1455 // We need two uint32_ts for dimensions, 1 for format, and 2 for the rest of the key.
1456 static int kNum32DataCnt = 2 + 1 + 2;
1457
1458 GraphiteResourceKey::Builder builder(key, type, kNum32DataCnt, shareable);
1459
1460 builder[0] = dimensions.width();
1461 builder[1] = dimensions.height();
1462 builder[2] = formatKey;
1463 builder[3] = (static_cast<uint32_t>(vkSpec.fFlags));
1464 builder[4] = (samplesKey << 0) |
1465 (static_cast<uint32_t>(isMipped) << 3) |
1466 (static_cast<uint32_t>(isProtected) << 4) |
1467 (static_cast<uint32_t>(vkSpec.fImageTiling) << 5) |
1468 (static_cast<uint32_t>(vkSpec.fSharingMode) << 6) |
1469 (static_cast<uint32_t>(vkSpec.fAspectMask) << 7) |
1470 (static_cast<uint32_t>(vkSpec.fImageUsageFlags) << 19);
1471}
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
Protected
Definition GpuTypes.h:61
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
@ VK_FORMAT_UNDEFINED
@ VK_FORMAT_MAX_ENUM

◆ channelMask()

uint32_t skgpu::graphite::VulkanCaps::channelMask ( const TextureInfo textureInfo) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 395 of file VulkanCaps.cpp.

395 {
396 return skgpu::VkFormatChannels(textureInfo.vulkanTextureSpec().fFormat);
397}
static constexpr uint32_t VkFormatChannels(VkFormat vkFormat)

◆ getColorTypeInfo()

const Caps::ColorTypeInfo * skgpu::graphite::VulkanCaps::getColorTypeInfo ( SkColorType  ct,
const TextureInfo textureInfo 
) const
overrideprivatevirtual

Implements skgpu::graphite::Caps.

Definition at line 1206 of file VulkanCaps.cpp.

1207 {
1208 VkFormat vkFormat = textureInfo.vulkanTextureSpec().fFormat;
1209 if (vkFormat == VK_FORMAT_UNDEFINED) {
1210 return nullptr;
1211 }
1212
1213 const FormatInfo& info = this->getFormatInfo(vkFormat);
1214 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1215 const ColorTypeInfo& ctInfo = info.fColorTypeInfos[i];
1216 if (ctInfo.fColorType == ct) {
1217 return &ctInfo;
1218 }
1219 }
1220
1221 return nullptr;
1222}
VkFormat

◆ getDefaultCompressedTextureInfo()

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

Implements skgpu::graphite::Caps.

Definition at line 282 of file VulkanCaps.cpp.

284 {
285 VkFormat format = format_from_compression(compression);
286 const FormatInfo& formatInfo = this->getFormatInfo(format);
287 static constexpr int defaultSampleCount = 1;
288 if ((isProtected == Protected::kYes && !this->protectedSupport()) ||
289 !formatInfo.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
290 return {};
291 }
292
293 VulkanTextureInfo info;
294 info.fSampleCount = defaultSampleCount;
295 info.fMipmapped = mipmapped;
296 info.fFlags = (isProtected == Protected::kYes) ? VK_IMAGE_CREATE_PROTECTED_BIT : 0;
297 info.fFormat = format;
298 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
299 info.fImageUsageFlags = VK_IMAGE_USAGE_SAMPLED_BIT |
302 info.fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
303 info.fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
304
305 return info;
306}
bool protectedSupport() const
Definition Caps.h:219
uint32_t uint32_t * format
@ VK_SHARING_MODE_EXCLUSIVE
@ VK_IMAGE_CREATE_PROTECTED_BIT
@ VK_IMAGE_TILING_OPTIMAL
@ VK_IMAGE_ASPECT_COLOR_BIT
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT

◆ getDefaultDepthStencilTextureInfo()

TextureInfo skgpu::graphite::VulkanCaps::getDefaultDepthStencilTextureInfo ( SkEnumBitMask< DepthStencilFlags flags,
uint32_t  sampleCount,
Protected  isProtected 
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 346 of file VulkanCaps.cpp.

348 {
349 VkFormat format = this->getFormatFromDepthStencilFlags(flags);
350 const DepthStencilFormatInfo& formatInfo = this->getDepthStencilFormatInfo(format);
351 if ( (isProtected == Protected::kYes && !this->protectedSupport()) ||
352 !formatInfo.isDepthStencilSupported(formatInfo.fFormatProperties.optimalTilingFeatures) ||
353 !formatInfo.fSupportedSampleCounts.isSampleCountSupported(sampleCount)) {
354 return {};
355 }
356
357 VulkanTextureInfo info;
358 info.fSampleCount = sampleCount;
359 info.fMipmapped = Mipmapped::kNo;
360 info.fFlags = (isProtected == Protected::kYes) ? VK_IMAGE_CREATE_PROTECTED_BIT : 0;
361 info.fFormat = format;
362 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
363 // TODO: Passing in a discardable flag to this method, and if true, add the TRANSIENT bit.
365 info.fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
366 info.fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
367
368 return info;
369}
FlutterSemanticsFlag flags
@ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT

◆ getDefaultMSAATextureInfo()

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

Graphite, unlike ganesh, does not require a dedicated MSAA attachment on every surface. MSAA textures now get resolved within the scope of a render pass, which can be done simply with the color attachment usage flag. So we no longer require transfer src/dst usage flags.

Implements skgpu::graphite::Caps.

Definition at line 308 of file VulkanCaps.cpp.

309 {
310 if (fDefaultMSAASamples <= 1) {
311 return {};
312 }
313
314 const VkFormat singleSpecFormat = singleSampledInfo.vulkanTextureSpec().fFormat;
315 const FormatInfo& formatInfo = this->getFormatInfo(singleSpecFormat);
316 if ((singleSampledInfo.isProtected() == Protected::kYes && !this->protectedSupport()) ||
317 !formatInfo.isRenderable(VK_IMAGE_TILING_OPTIMAL, fDefaultMSAASamples)) {
318 return {};
319 }
320
321 VulkanTextureInfo info;
322 info.fSampleCount = fDefaultMSAASamples;
323 info.fMipmapped = Mipmapped::kNo;
324 info.fFlags = (singleSampledInfo.isProtected() == Protected::kYes) ?
326 info.fFormat = singleSpecFormat;
327 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
328
329 /**
330 * Graphite, unlike ganesh, does not require a dedicated MSAA attachment on every surface.
331 * MSAA textures now get resolved within the scope of a render pass, which can be done simply
332 * with the color attachment usage flag. So we no longer require transfer src/dst usage flags.
333 */
335 if (discardable == Discardable::kYes && fSupportsMemorylessAttachments) {
337 }
338
339 info.fImageUsageFlags = flags;
340 info.fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
341 info.fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
342
343 return info;
344}
VkFlags VkImageUsageFlags
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT

◆ getDefaultSampledTextureInfo()

TextureInfo skgpu::graphite::VulkanCaps::getDefaultSampledTextureInfo ( SkColorType  ct,
Mipmapped  mipmapped,
Protected  isProtected,
Renderable  isRenderable 
) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 214 of file VulkanCaps.cpp.

217 {
218 VkFormat format = this->getFormatFromColorType(ct);
219 const FormatInfo& formatInfo = this->getFormatInfo(format);
220 static constexpr int defaultSampleCount = 1;
221 if ((isProtected == Protected::kYes && !this->protectedSupport()) ||
222 !formatInfo.isTexturable(VK_IMAGE_TILING_OPTIMAL) ||
223 (isRenderable == Renderable::kYes &&
224 !formatInfo.isRenderable(VK_IMAGE_TILING_OPTIMAL, defaultSampleCount)) ) {
225 return {};
226 }
227
228 VulkanTextureInfo info;
229 info.fSampleCount = defaultSampleCount;
230 info.fMipmapped = mipmapped;
231 info.fFlags = (isProtected == Protected::kYes) ? VK_IMAGE_CREATE_PROTECTED_BIT : 0;
232 info.fFormat = format;
233 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
234 info.fImageUsageFlags = VK_IMAGE_USAGE_SAMPLED_BIT |
237 if (isRenderable == Renderable::kYes) {
238 // We make all renderable images support being used as input attachment
239 info.fImageUsageFlags = info.fImageUsageFlags |
242 }
243 info.fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
244 info.fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
245
246 return info;
247}
bool isRenderable(const TextureInfo &) const override
@ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT

◆ getDefaultStorageTextureInfo()

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

Implements skgpu::graphite::Caps.

Definition at line 371 of file VulkanCaps.cpp.

371 {
372 VkFormat format = this->getFormatFromColorType(colorType);
373 const FormatInfo& formatInfo = this->getFormatInfo(format);
374 if (!formatInfo.isTexturable(VK_IMAGE_TILING_OPTIMAL) ||
375 !formatInfo.isStorage(VK_IMAGE_TILING_OPTIMAL)) {
376 return {};
377 }
378
379 VulkanTextureInfo info;
380 info.fSampleCount = 1;
381 info.fMipmapped = Mipmapped::kNo;
382 info.fFlags = 0;
383 info.fFormat = format;
384 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
385 // Storage textures are currently always sampleable from a shader
386 info.fImageUsageFlags = VK_IMAGE_USAGE_STORAGE_BIT |
389 info.fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
390 info.fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
391
392 return info;
393}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
@ VK_IMAGE_USAGE_STORAGE_BIT

◆ getTextureInfoForSampledCopy()

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

Implements skgpu::graphite::Caps.

Definition at line 249 of file VulkanCaps.cpp.

250 {
251 VulkanTextureInfo info;
252 if (!textureInfo.getVulkanTextureInfo(&info)) {
253 return {};
254 }
255
256 info.fSampleCount = 1;
257 info.fMipmapped = mipmapped;
258 info.fFlags = (textureInfo.fProtected == Protected::kYes) ? VK_IMAGE_CREATE_PROTECTED_BIT : 0;
259 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
262 info.fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
263
264 return info;
265}

◆ gpuOnlyBuffersMorePerformant()

bool skgpu::graphite::VulkanCaps::gpuOnlyBuffersMorePerformant ( ) const
inline

Definition at line 77 of file VulkanCaps.h.

77{ return fGpuOnlyBuffersMorePerformant; }

◆ isRenderable()

bool skgpu::graphite::VulkanCaps::isRenderable ( const TextureInfo texInfo) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 1239 of file VulkanCaps.cpp.

1239 {
1240 VulkanTextureInfo vkInfo;
1241 if (!texInfo.getVulkanTextureInfo(&vkInfo)) {
1242 return false;
1243 }
1244
1245 const FormatInfo& info = this->getFormatInfo(vkInfo.fFormat);
1246 return info.isRenderable(vkInfo.fImageTiling, texInfo.numSamples());
1247}

◆ isStorage()

bool skgpu::graphite::VulkanCaps::isStorage ( const TextureInfo texInfo) const
overridevirtual

Implements skgpu::graphite::Caps.

Definition at line 1249 of file VulkanCaps.cpp.

1249 {
1250 VulkanTextureInfo vkInfo;
1251 if (!texInfo.getVulkanTextureInfo(&vkInfo)) {
1252 return false;
1253 }
1254
1255 const FormatInfo& info = this->getFormatInfo(vkInfo.fFormat);
1256 return info.isStorage(vkInfo.fImageTiling);
1257}

◆ isTransferDst()

bool skgpu::graphite::VulkanCaps::isTransferDst ( const VulkanTextureInfo vkInfo) const

Definition at line 1264 of file VulkanCaps.cpp.

1264 {
1265 const FormatInfo& info = this->getFormatInfo(vkInfo.fFormat);
1266 return info.isTransferDst(vkInfo.fImageTiling);
1267}

◆ isTransferSrc()

bool skgpu::graphite::VulkanCaps::isTransferSrc ( const VulkanTextureInfo vkInfo) const

Definition at line 1259 of file VulkanCaps.cpp.

1259 {
1260 const FormatInfo& info = this->getFormatInfo(vkInfo.fFormat);
1261 return info.isTransferSrc(vkInfo.fImageTiling);
1262}

◆ makeComputePipelineKey()

UniqueKey skgpu::graphite::VulkanCaps::makeComputePipelineKey ( const ComputePipelineDesc ) const
inlineoverridevirtual

Implements skgpu::graphite::Caps.

Definition at line 54 of file VulkanCaps.h.

54{ return {}; }

◆ makeGraphicsPipelineKey()

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

Implements skgpu::graphite::Caps.

Definition at line 1379 of file VulkanCaps.cpp.

1380 {
1381 UniqueKey pipelineKey;
1382 {
1385
1386 VulkanRenderPass::VulkanRenderPassMetaData rpMetaData {renderPassDesc};
1387
1388 // Reserve 3 uint32s for the render step id, paint id, and write swizzle.
1389 static constexpr int kUint32sNeededForPipelineInfo = 3;
1390 // The uint32s needed for a RenderPass is variable number, so consult rpMetaData to
1391 // determine how many to reserve.
1392 UniqueKey::Builder builder(&pipelineKey,
1394 kUint32sNeededForPipelineInfo + rpMetaData.fUint32DataCnt,
1395 "GraphicsPipeline");
1396
1397 int idx = 0;
1398 // Add GraphicsPipelineDesc information
1399 builder[idx++] = pipelineDesc.renderStepID();
1400 builder[idx++] = pipelineDesc.paintParamsID().asUInt();
1401 // Add RenderPass info relevant for pipeline creation that's not captured in RenderPass keys
1402 builder[idx++] = renderPassDesc.fWriteSwizzle.asKey();
1403 // Add RenderPassDesc information
1404 VulkanRenderPass::AddRenderPassInfoToKey(rpMetaData, builder, idx, /*compatibleOnly=*/true);
1405
1406 builder.finish();
1407 }
1408
1409 return pipelineKey;
1410}
static Domain GenerateDomain()
static void AddRenderPassInfoToKey(VulkanRenderPassMetaData &rpMetaData, ResourceKey::Builder &builder, int &builderIdx, bool compatibleOnly)
static const skgpu::UniqueKey::Domain kGraphicsPipelineDomain
Definition MtlCaps.mm:959

◆ makeSamplerKey()

GraphiteResourceKey skgpu::graphite::VulkanCaps::makeSamplerKey ( const SamplerDesc samplerDesc) const
overridevirtual

Reimplemented from skgpu::graphite::Caps.

Definition at line 1412 of file VulkanCaps.cpp.

1412 {
1413 GraphiteResourceKey samplerKey;
1415 GraphiteResourceKey::Builder builder(&samplerKey, kType, 1, Shareable::kYes);
1416
1417 // TODO(b/311392779): When needed, add YCbCr info to the sampler key.
1418
1419 builder[0] = samplerDesc.desc();
1420 builder.finish();
1421 return samplerKey;
1422}
uint32_t ResourceType

◆ maxUniformBufferRange()

uint64_t skgpu::graphite::VulkanCaps::maxUniformBufferRange ( ) const
inline

Definition at line 93 of file VulkanCaps.h.

93{ return fMaxUniformBufferRange; }

◆ maxVertexAttributes()

uint32_t skgpu::graphite::VulkanCaps::maxVertexAttributes ( ) const
inline

Definition at line 90 of file VulkanCaps.h.

90 {
91 return fMaxVertexAttributes;
92 }

◆ onIsTexturable()

bool skgpu::graphite::VulkanCaps::onIsTexturable ( const TextureInfo texInfo) const
overrideprivatevirtual

Implements skgpu::graphite::Caps.

Definition at line 1224 of file VulkanCaps.cpp.

1224 {
1225 VulkanTextureInfo vkInfo;
1226 if (!texInfo.getVulkanTextureInfo(&vkInfo)) {
1227 return false;
1228 }
1229
1230 // TODO:
1231 // Once we support external formats with associated YCbCr conversion info, check for that
1232 // and return true here because we can always texture from an external format.
1233
1234 const FormatInfo& info = this->getFormatInfo(vkInfo.fFormat);
1235 return info.isTexturable(vkInfo.fImageTiling);
1236}

◆ physicalDeviceMemoryProperties2()

const VkPhysicalDeviceMemoryProperties2 & skgpu::graphite::VulkanCaps::physicalDeviceMemoryProperties2 ( ) const
inline

Definition at line 95 of file VulkanCaps.h.

95 {
96 return fPhysicalDeviceMemoryProperties2;
97 }

◆ shouldAlwaysUseDedicatedImageMemory()

bool skgpu::graphite::VulkanCaps::shouldAlwaysUseDedicatedImageMemory ( ) const
inline

Definition at line 69 of file VulkanCaps.h.

69 {
70 return fShouldAlwaysUseDedicatedImageMemory;
71 }

◆ shouldPersistentlyMapCpuToGpuBuffers()

bool skgpu::graphite::VulkanCaps::shouldPersistentlyMapCpuToGpuBuffers ( ) const
inline

Definition at line 82 of file VulkanCaps.h.

82 {
83 return fShouldPersistentlyMapCpuToGpuBuffers;
84 }

◆ supportedReadPixelsColorType()

std::pair< SkColorType, bool > skgpu::graphite::VulkanCaps::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 1347 of file VulkanCaps.cpp.

1350 {
1351 VulkanTextureInfo vkInfo;
1352 if (!srcTextureInfo.getVulkanTextureInfo(&vkInfo)) {
1353 return {kUnknown_SkColorType, false};
1354 }
1355
1356 // Can't read from YCbCr formats
1357 // TODO: external formats?
1358 if (VkFormatNeedsYcbcrSampler(vkInfo.fFormat)) {
1359 return {kUnknown_SkColorType, false};
1360 }
1361
1362 // TODO: handle compressed formats
1363 if (VkFormatIsCompressed(vkInfo.fFormat)) {
1364 SkASSERT(this->isTexturable(vkInfo));
1365 return {kUnknown_SkColorType, false};
1366 }
1367
1368 const FormatInfo& info = this->getFormatInfo(vkInfo.fFormat);
1369 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1370 const auto& ctInfo = info.fColorTypeInfos[i];
1371 if (ctInfo.fColorType == srcColorType) {
1372 return {ctInfo.fTransferColorType, vkInfo.fFormat == VK_FORMAT_R8G8B8_UNORM};
1373 }
1374 }
1375
1376 return {kUnknown_SkColorType, false};
1377}
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
bool isTexturable(const TextureInfo &) const
Definition Caps.cpp:65
static constexpr bool VkFormatNeedsYcbcrSampler(VkFormat format)
static constexpr bool VkFormatIsCompressed(VkFormat vkFormat)
@ VK_FORMAT_R8G8B8_UNORM

◆ supportedWritePixelsColorType()

std::pair< SkColorType, bool > skgpu::graphite::VulkanCaps::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 1321 of file VulkanCaps.cpp.

1324 {
1325 VulkanTextureInfo vkInfo;
1326 if (!dstTextureInfo.getVulkanTextureInfo(&vkInfo)) {
1327 return {kUnknown_SkColorType, false};
1328 }
1329
1330 // Can't write to YCbCr formats
1331 // TODO: Can't write to external formats, either
1332 if (VkFormatNeedsYcbcrSampler(vkInfo.fFormat)) {
1333 return {kUnknown_SkColorType, false};
1334 }
1335
1336 const FormatInfo& info = this->getFormatInfo(vkInfo.fFormat);
1337 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1338 const auto& ctInfo = info.fColorTypeInfos[i];
1339 if (ctInfo.fColorType == dstColorType) {
1340 return {ctInfo.fTransferColorType, vkInfo.fFormat == VK_FORMAT_R8G8B8_UNORM};
1341 }
1342 }
1343
1344 return {kUnknown_SkColorType, false};
1345}

◆ supportsDeviceFaultInfo()

bool skgpu::graphite::VulkanCaps::supportsDeviceFaultInfo ( ) const
inline

Definition at line 88 of file VulkanCaps.h.

88{ return fSupportsDeviceFaultInfo; }

◆ supportsReadPixels()

bool skgpu::graphite::VulkanCaps::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 1291 of file VulkanCaps.cpp.

1291 {
1292 if (texInfo.isProtected() == Protected::kYes) {
1293 return false;
1294 }
1295
1296 VulkanTextureInfo vkInfo;
1297 if (!texInfo.getVulkanTextureInfo(&vkInfo)) {
1298 return false;
1299 }
1300
1301 // Can't read if it needs a YCbCr sampler
1302 if (VkFormatNeedsYcbcrSampler(vkInfo.fFormat)) {
1303 return false;
1304 }
1305
1306 if (VkFormatIsCompressed(vkInfo.fFormat)) {
1307 return false;
1308 }
1309
1310 if (vkInfo.fSampleCount > 1) {
1311 return false;
1312 }
1313
1314 if (!SkToBool(vkInfo.fImageUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT)) {
1315 return false;
1316 }
1317
1318 return true;
1319}
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35

◆ supportsWritePixels()

bool skgpu::graphite::VulkanCaps::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 1269 of file VulkanCaps.cpp.

1269 {
1270 VulkanTextureInfo vkInfo;
1271 if (!texInfo.getVulkanTextureInfo(&vkInfo)) {
1272 return false;
1273 }
1274
1275 // Can't write if it needs a YCbCr sampler
1276 if (VkFormatNeedsYcbcrSampler(vkInfo.fFormat)) {
1277 return false;
1278 }
1279
1280 if (vkInfo.fSampleCount > 1) {
1281 return false;
1282 }
1283
1284 if (!SkToBool(vkInfo.fImageUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT)) {
1285 return false;
1286 }
1287
1288 return true;
1289}

◆ supportsYcbcrConversion()

bool skgpu::graphite::VulkanCaps::supportsYcbcrConversion ( ) const
inline

Definition at line 86 of file VulkanCaps.h.

86{ return fSupportsYcbcrConversion; }

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