Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
GrVkCaps Class Reference

#include <GrVkCaps.h>

Inheritance diagram for GrVkCaps:
GrCaps SkCapabilities SkRefCnt SkRefCntBase

Public Member Functions

 GrVkCaps (const GrContextOptions &, const skgpu::VulkanInterface *, VkPhysicalDevice, const VkPhysicalDeviceFeatures2 &, uint32_t instanceVersion, uint32_t physicalDeviceVersion, const skgpu::VulkanExtensions &, skgpu::Protected)
 
bool isFormatSRGB (const GrBackendFormat &) const override
 
bool isFormatTexturable (const GrBackendFormat &, GrTextureType) const override
 
bool isVkFormatTexturable (VkFormat) const
 
bool isFormatCopyable (const GrBackendFormat &) const override
 
bool isFormatAsColorTypeRenderable (GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
 
bool isFormatRenderable (const GrBackendFormat &format, int sampleCount) const override
 
bool isFormatRenderable (VkFormat, int sampleCount) const
 
int getRenderTargetSampleCount (int requestedCount, const GrBackendFormat &) const override
 
int getRenderTargetSampleCount (int requestedCount, VkFormat) const
 
int maxRenderTargetSampleCount (const GrBackendFormat &) const override
 
int maxRenderTargetSampleCount (VkFormat format) const
 
SupportedWrite supportedWritePixelsColorType (GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const override
 
SurfaceReadPixelsSupport surfaceSupportsReadPixels (const GrSurface *) const override
 
bool isVkFormatTexturableLinearly (VkFormat format) const
 
bool formatCanBeDstofBlit (VkFormat format, bool linearTiled) const
 
bool formatCanBeSrcofBlit (VkFormat format, bool linearTiled) const
 
GrColorType transferColorType (VkFormat, GrColorType surfaceColorType) const
 
bool mustSyncCommandBuffersWithQueue () const
 
bool shouldAlwaysUseDedicatedImageMemory () const
 
bool avoidUpdateBuffers () const
 
VkFormat preferredStencilFormat () const
 
bool supportsSwapchain () const
 
bool supportsPhysicalDeviceProperties2 () const
 
bool supportsMemoryRequirements2 () const
 
bool supportsBindMemory2 () const
 
bool supportsMaintenance1 () const
 
bool supportsMaintenance2 () const
 
bool supportsMaintenance3 () const
 
bool supportsDedicatedAllocation () const
 
bool supportsExternalMemory () const
 
bool supportsAndroidHWBExternalMemory () const
 
bool supportsYcbcrConversion () const
 
uint32_t ycbcrCombinedImageSamplerDescriptorCount () const
 
bool supportsDRMFormatModifiers () const
 
bool supportsDeviceFaultInfo () const
 
bool preferPrimaryOverSecondaryCommandBuffers () const
 
int maxPerPoolCachedSecondaryCommandBuffers () const
 
uint32_t maxInputAttachmentDescriptors () const
 
float maxSamplerAnisotropy () const
 
bool mustInvalidatePrimaryCmdBufferStateAfterClearAttachments () const
 
bool gpuOnlyBuffersMorePerformant () const
 
bool shouldPersistentlyMapCpuToGpuBuffers () const
 
uint32_t maxDrawIndirectDrawCount () const
 
bool canCopyImage (VkFormat dstFormat, int dstSampleCnt, bool dstHasYcbcr, VkFormat srcFormat, int srcSamplecnt, bool srcHasYcbcr) const
 
bool canCopyAsBlit (VkFormat dstConfig, int dstSampleCnt, bool dstIsLinear, bool dstHasYcbcr, VkFormat srcConfig, int srcSampleCnt, bool srcIsLinear, bool srcHasYcbcr) const
 
bool canCopyAsResolve (VkFormat dstConfig, int dstSampleCnt, bool dstHasYcbcr, VkFormat srcConfig, int srcSamplecnt, bool srcHasYcbcr) const
 
GrBackendFormat getBackendFormatFromCompressionType (SkTextureCompressionType) const override
 
VkFormat getFormatFromColorType (GrColorType colorType) const
 
skgpu::Swizzle getWriteSwizzle (const GrBackendFormat &, GrColorType) const override
 
uint64_t computeFormatKey (const GrBackendFormat &) const override
 
int getFragmentUniformBinding () const
 
int getFragmentUniformSet () const
 
void addExtraSamplerKey (skgpu::KeyBuilder *, GrSamplerState, const GrBackendFormat &) const override
 
GrProgramDesc makeDesc (GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags) const override
 
GrInternalSurfaceFlags getExtraSurfaceFlagsForDeferredRT () const override
 
VkShaderStageFlags getPushConstantStageFlags () const
 
bool mustLoadFullImageWithDiscardableMSAA () const
 
bool supportsDiscardableMSAAForDMSAA () const
 
bool renderTargetSupportsDiscardableMSAA (const GrVkRenderTarget *) const
 
bool programInfoWillUseDiscardableMSAA (const GrProgramInfo &) const
 
bool dmsaaResolveCanBeUsedAsTextureInSameRenderPass () const override
 
bool supportsMemorylessAttachments () const
 
- Public Member Functions inherited from GrCaps
 GrCaps (const GrContextOptions &)
 
void dumpJSON (SkJSONWriter *) const
 
const GrShaderCapsshaderCaps () const
 
bool npotTextureTileSupport () const
 
bool mipmapSupport () const
 
bool anisoSupport () const
 
bool gpuTracingSupport () const
 
bool oversizedStencilSupport () const
 
bool textureBarrierSupport () const
 
bool sampleLocationsSupport () const
 
bool drawInstancedSupport () const
 
bool nativeDrawIndirectSupport () const
 
bool useClientSideIndirectBuffers () const
 
bool conservativeRasterSupport () const
 
bool wireframeSupport () const
 
bool msaaResolvesAutomatically () const
 
bool preferDiscardableMSAAAttachment () const
 
bool halfFloatVertexAttributeSupport () const
 
bool usePrimitiveRestart () const
 
bool preferClientSideDynamicBuffers () const
 
bool preferFullscreenClears () const
 
bool discardStencilValuesAfterRenderPass () const
 
bool twoSidedStencilRefsAndMasksMustMatch () const
 
bool preferVRAMUseOverFlushes () const
 
bool avoidStencilBuffers () const
 
bool avoidWritePixelsFastPath () const
 
bool nativeDrawIndexedIndirectIsBroken () const
 
BlendEquationSupport blendEquationSupport () const
 
bool advancedBlendEquationSupport () const
 
bool advancedCoherentBlendEquationSupport () const
 
bool isAdvancedBlendEquationDisabled (skgpu::BlendEquation equation) const
 
bool shouldCollapseSrcOverToSrcWhenAble () const
 
bool mustSyncGpuDuringAbandon () const
 
bool reducedShaderMode () const
 
uint32_t mapBufferFlags () const
 
bool reuseScratchTextures () const
 
bool reuseScratchBuffers () const
 
int maxVertexAttributes () const
 maximum number of attribute values per vertex
 
int maxRenderTargetSize () const
 
int maxPreferredRenderTargetSize () const
 
int maxTextureSize () const
 
int maxWindowRectangles () const
 
bool isWindowRectanglesSupportedForRT (const GrBackendRenderTarget &rt) const
 
uint32_t maxPushConstantsSize () const
 
size_t transferBufferRowBytesAlignment () const
 
size_t transferFromBufferToBufferAlignment () const
 
size_t bufferUpdateDataPreserveAlignment () const
 
bool isFormatCompressed (const GrBackendFormat &format) const
 
int internalMultisampleCount (const GrBackendFormat &format) const
 
bool surfaceSupportsWritePixels (const GrSurface *) const
 
SupportedRead supportedReadPixelsColorType (GrColorType srcColorType, const GrBackendFormat &srcFormat, GrColorType dstColorType) const
 
bool writePixelsRowBytesSupport () const
 
bool transferPixelsToRowBytesSupport () const
 
bool readPixelsRowBytesSupport () const
 
bool transferFromSurfaceToBufferSupport () const
 
bool transferFromBufferToTextureSupport () const
 
bool transferFromBufferToBufferSupport () const
 
bool suppressPrints () const
 
size_t bufferMapThreshold () const
 
bool mustClearUploadedBufferData () const
 
bool shouldInitializeTextures () const
 
bool buffersAreInitiallyZero () const
 
bool supportsAHardwareBufferImages () const
 
bool wireframeMode () const
 
bool semaphoreSupport () const
 
bool backendSemaphoreSupport () const
 
bool finishedProcAsyncCallbackSupport () const
 
bool crossContextTextureSupport () const
 
bool canCopySurface (const GrSurfaceProxy *dst, const SkIRect &dstRect, const GrSurfaceProxy *src, const SkIRect &srcRect) const
 
bool dynamicStateArrayGeometryProcessorTextureSupport () const
 
bool supportsProtectedContent () const
 
bool performPartialClearsAsDraws () const
 
bool performColorClearsAsDraws () const
 
bool avoidLargeIndexBufferDraws () const
 
bool performStencilClearsAsDraws () const
 
bool disableTessellationPathRenderer () const
 
GrDstSampleFlags getDstSampleFlagsForProxy (const GrRenderTargetProxy *, bool drawUsesMSAA) const
 
virtual DstCopyRestrictions getDstCopyRestrictions (const GrRenderTargetProxy *src, GrColorType ct) const
 
bool validateSurfaceParams (const SkISize &, const GrBackendFormat &, GrRenderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped, GrTextureType) const
 
bool areColorTypeAndFormatCompatible (GrColorType grCT, const GrBackendFormat &format) const
 
GrBackendFormat getDefaultBackendFormat (GrColorType, GrRenderable) const
 
bool clampToBorderSupport () const
 
skgpu::Swizzle getReadSwizzle (const GrBackendFormat &format, GrColorType colorType) const
 
const GrDriverBugWorkaroundsworkarounds () const
 
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (ProgramDescOverrideFlags)
 
bool supportsDynamicMSAA (const GrRenderTargetProxy *) const
 
bool avoidReorderingRenderTasks () const
 
bool avoidDithering () const
 
bool disablePerspectiveSDFText () const
 
bool avoidLineDraws () const
 
std::tuple< GrColorType, GrBackendFormatgetFallbackColorTypeAndFormat (GrColorType, int sampleCount) const
 
- Public Member Functions inherited from SkCapabilities
SkSL::Version skslVersion () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static int GetStencilFormatTotalBitCount (VkFormat format)
 
- Static Public Member Functions inherited from SkCapabilities
static sk_sp< const SkCapabilitiesRasterBackend ()
 

Private Member Functions

bool onSurfaceSupportsWritePixels (const GrSurface *) const override
 
bool onCanCopySurface (const GrSurfaceProxy *dst, const SkIRect &dstRect, const GrSurfaceProxy *src, const SkIRect &srcRect) const override
 
GrBackendFormat onGetDefaultBackendFormat (GrColorType) const override
 
bool onAreColorTypeAndFormatCompatible (GrColorType, const GrBackendFormat &) const override
 
SupportedRead onSupportedReadPixelsColorType (GrColorType, const GrBackendFormat &, GrColorType) const override
 
skgpu::Swizzle onGetReadSwizzle (const GrBackendFormat &, GrColorType) const override
 
GrDstSampleFlags onGetDstSampleFlagsForProxy (const GrRenderTargetProxy *) const override
 
bool onSupportsDynamicMSAA (const GrRenderTargetProxy *) const override
 

Additional Inherited Members

- Public Types inherited from GrCaps
enum  BlendEquationSupport { kBasic_BlendEquationSupport , kAdvanced_BlendEquationSupport , kAdvancedCoherent_BlendEquationSupport , kLast_BlendEquationSupport = kAdvancedCoherent_BlendEquationSupport }
 
enum  MapFlags { kNone_MapFlags = 0x0 , kCanMap_MapFlag = 0x1 , kSubset_MapFlag = 0x2 , kAsyncRead_MapFlag = 0x4 }
 
enum class  SurfaceReadPixelsSupport { kSupported , kCopyToTexture2D , kUnsupported }
 
enum class  ProgramDescOverrideFlags { kNone = 0 , kVulkanHasResolveLoadSubpass = 0x1 }
 
- Protected Member Functions inherited from GrCaps
void finishInitialization (const GrContextOptions &options)
 
- Protected Member Functions inherited from SkCapabilities
 SkCapabilities ()=default
 
void initSkCaps (const SkSL::ShaderCaps *)
 
- Protected Attributes inherited from GrCaps
std::unique_ptr< GrShaderCapsfShaderCaps
 
bool fNPOTTextureTileSupport: 1
 
bool fMipmapSupport: 1
 
bool fAnisoSupport: 1
 
bool fReuseScratchTextures: 1
 
bool fReuseScratchBuffers: 1
 
bool fGpuTracingSupport: 1
 
bool fOversizedStencilSupport: 1
 
bool fTextureBarrierSupport: 1
 
bool fSampleLocationsSupport: 1
 
bool fDrawInstancedSupport: 1
 
bool fNativeDrawIndirectSupport: 1
 
bool fUseClientSideIndirectBuffers: 1
 
bool fConservativeRasterSupport: 1
 
bool fWireframeSupport: 1
 
bool fMSAAResolvesAutomatically: 1
 
bool fPreferDiscardableMSAAAttachment: 1
 
bool fUsePrimitiveRestart: 1
 
bool fPreferClientSideDynamicBuffers: 1
 
bool fPreferFullscreenClears: 1
 
bool fTwoSidedStencilRefsAndMasksMustMatch: 1
 
bool fMustClearUploadedBufferData: 1
 
bool fBuffersAreInitiallyZero: 1
 
bool fShouldInitializeTextures: 1
 
bool fSupportsAHardwareBufferImages: 1
 
bool fHalfFloatVertexAttributeSupport: 1
 
bool fClampToBorderSupport: 1
 
bool fPerformPartialClearsAsDraws: 1
 
bool fPerformColorClearsAsDraws: 1
 
bool fAvoidLargeIndexBufferDraws: 1
 
bool fPerformStencilClearsAsDraws: 1
 
bool fTransferFromBufferToTextureSupport: 1
 
bool fTransferFromSurfaceToBufferSupport: 1
 
bool fTransferFromBufferToBufferSupport: 1
 
bool fWritePixelsRowBytesSupport: 1
 
bool fTransferPixelsToRowBytesSupport: 1
 
bool fReadPixelsRowBytesSupport: 1
 
bool fShouldCollapseSrcOverToSrcWhenAble: 1
 
bool fMustSyncGpuDuringAbandon: 1
 
bool fDisableTessellationPathRenderer: 1
 
bool fAvoidStencilBuffers: 1
 
bool fAvoidWritePixelsFastPath: 1
 
bool fNativeDrawIndexedIndirectIsBroken: 1
 
bool fAvoidReorderingRenderTasks: 1
 
bool fAvoidDithering: 1
 
bool fDisablePerspectiveSDFText: 1
 
bool fAvoidLineDraws: 1
 
bool fPreferVRAMUseOverFlushes: 1
 
bool fSemaphoreSupport: 1
 
bool fBackendSemaphoreSupport: 1
 
bool fFinishedProcAsyncCallbackSupport: 1
 
bool fCrossContextTextureSupport: 1
 
bool fDynamicStateArrayGeometryProcessorTextureSupport: 1
 
bool fSupportsProtectedContent: 1
 
BlendEquationSupport fBlendEquationSupport
 
uint32_t fAdvBlendEqDisableFlags
 
uint32_t fMapBufferFlags
 
int fBufferMapThreshold
 
int fMaxRenderTargetSize
 
int fMaxPreferredRenderTargetSize
 
int fMaxVertexAttributes
 
int fMaxTextureSize
 
int fMaxWindowRectangles
 
int fInternalMultisampleCount
 
uint32_t fMaxPushConstantsSize = 0
 
size_t fTransferBufferRowBytesAlignment = 1
 
size_t fTransferFromBufferToBufferAlignment = 1
 
size_t fBufferUpdateDataPreserveAlignment = 1
 
GrDriverBugWorkarounds fDriverBugWorkarounds
 
- Protected Attributes inherited from SkCapabilities
SkSL::Version fSkSLVersion = SkSL::Version::k100
 

Detailed Description

Stores some capabilities of a Vk backend.

Definition at line 27 of file GrVkCaps.h.

Constructor & Destructor Documentation

◆ GrVkCaps()

GrVkCaps::GrVkCaps ( const GrContextOptions contextOptions,
const skgpu::VulkanInterface vkInterface,
VkPhysicalDevice  physDev,
const VkPhysicalDeviceFeatures2 features,
uint32_t  instanceVersion,
uint32_t  physicalDeviceVersion,
const skgpu::VulkanExtensions extensions,
skgpu::Protected  isProtected 
)

Creates a GrVkCaps that is set such that nothing is supported. The init function should be called to fill out the caps.

Definition at line 42 of file GrVkCaps.cpp.

50 : INHERITED(contextOptions) {
51 /**************************************************************************
52 * GrCaps fields
53 **************************************************************************/
54 fMipmapSupport = true; // always available in Vulkan
55 fAnisoSupport = true; // always available in Vulkan
56 fNPOTTextureTileSupport = true; // always available in Vulkan
57 fReuseScratchTextures = true; //TODO: figure this out
58 fGpuTracingSupport = false; //TODO: figure this out
59 fOversizedStencilSupport = false; //TODO: figure this out
61
62 fSemaphoreSupport = true; // always available in Vulkan
67
68 // We always copy in/out of a transfer buffer so it's trivial to support row bytes.
71
75
76 fMaxRenderTargetSize = 4096; // minimum required by spec
77 fMaxTextureSize = 4096; // minimum required by spec
78
80
82
83 fShaderCaps = std::make_unique<GrShaderCaps>();
84
85 this->init(contextOptions, vkInterface, physDev, features, physicalDeviceVersion, extensions,
86 isProtected);
87}
bool fDynamicStateArrayGeometryProcessorTextureSupport
Definition GrCaps.h:646
bool fFinishedProcAsyncCallbackSupport
Definition GrCaps.h:640
int fMaxRenderTargetSize
Definition GrCaps.h:657
bool fReadPixelsRowBytesSupport
Definition GrCaps.h:621
std::unique_ptr< GrShaderCaps > fShaderCaps
Definition GrCaps.h:584
bool fReuseScratchTextures
Definition GrCaps.h:589
bool fAnisoSupport
Definition GrCaps.h:588
bool fTransferFromBufferToBufferSupport
Definition GrCaps.h:618
bool fTransferFromBufferToTextureSupport
Definition GrCaps.h:616
bool fTextureBarrierSupport
Definition GrCaps.h:593
bool fBackendSemaphoreSupport
Definition GrCaps.h:639
bool fHalfFloatVertexAttributeSupport
Definition GrCaps.h:610
bool fGpuTracingSupport
Definition GrCaps.h:591
bool fOversizedStencilSupport
Definition GrCaps.h:592
bool fSemaphoreSupport
Definition GrCaps.h:638
bool fMipmapSupport
Definition GrCaps.h:587
bool fWritePixelsRowBytesSupport
Definition GrCaps.h:619
bool fNPOTTextureTileSupport
Definition GrCaps.h:586
bool fTransferFromSurfaceToBufferSupport
Definition GrCaps.h:617
bool fDrawInstancedSupport
Definition GrCaps.h:595
int fMaxTextureSize
Definition GrCaps.h:660
bool fCrossContextTextureSupport
Definition GrCaps.h:643

Member Function Documentation

◆ addExtraSamplerKey()

void GrVkCaps::addExtraSamplerKey ( skgpu::KeyBuilder ,
GrSamplerState  ,
const GrBackendFormat  
) const
overridevirtual

Adds fields to the key to represent the sampler that will be created for the passed in parameters. Currently this extra keying is only needed when building a vulkan pipeline with immutable samplers.

Reimplemented from GrCaps.

Definition at line 1930 of file GrVkCaps.cpp.

1932 {
1934 if (!ycbcrInfo) {
1935 return;
1936 }
1937
1938 GrVkSampler::Key key = GrVkSampler::GenerateKey(samplerState, *ycbcrInfo);
1939
1940 constexpr size_t numInts = (sizeof(key) + 3) / 4;
1941 uint32_t tmp[numInts];
1942 memcpy(tmp, &key, sizeof(key));
1943
1944 for (size_t i = 0; i < numInts; ++i) {
1945 b->add32(tmp[i]);
1946 }
1947}
static SK_END_REQUIRE_DENSE Key GenerateKey(GrSamplerState, const GrVkYcbcrConversionInfo &)
static bool b
uint32_t uint32_t * format
SK_API const GrVkYcbcrConversionInfo * GetVkYcbcrConversionInfo(const GrBackendFormat &)

◆ avoidUpdateBuffers()

bool GrVkCaps::avoidUpdateBuffers ( ) const
inline

Definition at line 99 of file GrVkCaps.h.

99{ return fAvoidUpdateBuffers; }

◆ canCopyAsBlit()

bool GrVkCaps::canCopyAsBlit ( VkFormat  dstConfig,
int  dstSampleCnt,
bool  dstIsLinear,
bool  dstHasYcbcr,
VkFormat  srcConfig,
int  srcSampleCnt,
bool  srcIsLinear,
bool  srcHasYcbcr 
) const

Definition at line 169 of file GrVkCaps.cpp.

171 {
172 // We require that all vulkan GrSurfaces have been created with transfer_dst and transfer_src
173 // as image usage flags.
174 if (!this->formatCanBeDstofBlit(dstFormat, dstIsLinear) ||
175 !this->formatCanBeSrcofBlit(srcFormat, srcIsLinear)) {
176 return false;
177 }
178
179 // We cannot blit images that are multisampled. Will need to figure out if we can blit the
180 // resolved msaa though.
181 if (dstSampleCnt > 1 || srcSampleCnt > 1) {
182 return false;
183 }
184
185 if (dstHasYcbcr || srcHasYcbcr) {
186 return false;
187 }
188
189 return true;
190}
bool formatCanBeDstofBlit(VkFormat format, bool linearTiled) const
Definition GrVkCaps.h:71
bool formatCanBeSrcofBlit(VkFormat format, bool linearTiled) const
Definition GrVkCaps.h:77

◆ canCopyAsResolve()

bool GrVkCaps::canCopyAsResolve ( VkFormat  dstConfig,
int  dstSampleCnt,
bool  dstHasYcbcr,
VkFormat  srcConfig,
int  srcSamplecnt,
bool  srcHasYcbcr 
) const

Definition at line 192 of file GrVkCaps.cpp.

193 {
194 // The src surface must be multisampled.
195 if (srcSampleCnt <= 1) {
196 return false;
197 }
198
199 // The dst must not be multisampled.
200 if (dstSampleCnt > 1) {
201 return false;
202 }
203
204 // Surfaces must have the same format.
205 if (srcFormat != dstFormat) {
206 return false;
207 }
208
209 if (dstHasYcbcr || srcHasYcbcr) {
210 return false;
211 }
212
213 return true;
214}

◆ canCopyImage()

bool GrVkCaps::canCopyImage ( VkFormat  dstFormat,
int  dstSampleCnt,
bool  dstHasYcbcr,
VkFormat  srcFormat,
int  srcSamplecnt,
bool  srcHasYcbcr 
) const

Helpers used by canCopySurface. In all cases if the SampleCnt parameter is zero that means the surface is not a render target, otherwise it is the number of samples in the render target.

Definition at line 154 of file GrVkCaps.cpp.

155 {
156 if ((dstSampleCnt > 1 || srcSampleCnt > 1) && dstSampleCnt != srcSampleCnt) {
157 return false;
158 }
159
160 if (dstHasYcbcr || srcHasYcbcr) {
161 return false;
162 }
163
164 // We require that all Vulkan GrSurfaces have been created with transfer_dst and transfer_src
165 // as image usage flags.
166 return format_compatibility_class(srcFormat) == format_compatibility_class(dstFormat);
167}
static FormatCompatibilityClass format_compatibility_class(VkFormat format)
Definition GrVkCaps.cpp:107

◆ computeFormatKey()

uint64_t GrVkCaps::computeFormatKey ( const GrBackendFormat format) const
overridevirtual

Implements GrCaps.

Definition at line 1876 of file GrVkCaps.cpp.

1876 {
1877 VkFormat vkFormat;
1879
1880#ifdef SK_DEBUG
1881 // We should never be trying to compute a key for an external format
1883 SkASSERT(ycbcrInfo);
1884 SkASSERT(!ycbcrInfo->isValid() || ycbcrInfo->fExternalFormat == 0);
1885#endif
1886
1887 // A VkFormat has a size of 64 bits.
1888 return (uint64_t)vkFormat;
1889}
#define SkAssertResult(cond)
Definition SkAssert.h:123
#define SkASSERT(cond)
Definition SkAssert.h:116
SK_API bool AsVkFormat(const GrBackendFormat &, VkFormat *)
VkFormat

◆ dmsaaResolveCanBeUsedAsTextureInSameRenderPass()

bool GrVkCaps::dmsaaResolveCanBeUsedAsTextureInSameRenderPass ( ) const
inlineoverridevirtual

Reimplemented from GrCaps.

Definition at line 266 of file GrVkCaps.h.

266{ return false; }

◆ formatCanBeDstofBlit()

bool GrVkCaps::formatCanBeDstofBlit ( VkFormat  format,
bool  linearTiled 
) const
inline

Definition at line 71 of file GrVkCaps.h.

71 {
72 const FormatInfo& info = this->getFormatInfo(format);
73 const uint16_t& flags = linearTiled ? info.fLinearFlags : info.fOptimalFlags;
74 return SkToBool(FormatInfo::kBlitDst_Flag & flags);
75 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
FlutterSemanticsFlag flags

◆ formatCanBeSrcofBlit()

bool GrVkCaps::formatCanBeSrcofBlit ( VkFormat  format,
bool  linearTiled 
) const
inline

Definition at line 77 of file GrVkCaps.h.

77 {
78 const FormatInfo& info = this->getFormatInfo(format);
79 const uint16_t& flags = linearTiled ? info.fLinearFlags : info.fOptimalFlags;
80 return SkToBool(FormatInfo::kBlitSrc_Flag & flags);
81 }

◆ getBackendFormatFromCompressionType()

GrBackendFormat GrVkCaps::getBackendFormatFromCompressionType ( SkTextureCompressionType  compressionType) const
overridevirtual

Implements GrCaps.

Definition at line 1800 of file GrVkCaps.cpp.

1801 {
1802 switch (compressionType) {
1804 return {};
1808 }
1809 return {};
1813 }
1814 return {};
1818 }
1819 return {};
1820 }
1821
1823}
#define SkUNREACHABLE
Definition SkAssert.h:135
bool isVkFormatTexturable(VkFormat) const
SK_API GrBackendFormat MakeVk(VkFormat format, bool willUseDRMFormatModifiers=false)
@ VK_FORMAT_BC1_RGB_UNORM_BLOCK
@ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
@ VK_FORMAT_BC1_RGBA_UNORM_BLOCK

◆ getExtraSurfaceFlagsForDeferredRT()

GrInternalSurfaceFlags GrVkCaps::getExtraSurfaceFlagsForDeferredRT ( ) const
overridevirtual

Reimplemented from GrCaps.

Definition at line 2049 of file GrVkCaps.cpp.

2049 {
2050 // We always create vulkan RT with the input attachment flag;
2052}

◆ getFormatFromColorType()

VkFormat GrVkCaps::getFormatFromColorType ( GrColorType  colorType) const
inline

Definition at line 235 of file GrVkCaps.h.

235 {
236 int idx = static_cast<int>(colorType);
237 return fColorTypeToFormatTable[idx];
238 }
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)

◆ getFragmentUniformBinding()

int GrVkCaps::getFragmentUniformBinding ( ) const

Definition at line 1922 of file GrVkCaps.cpp.

◆ getFragmentUniformSet()

int GrVkCaps::getFragmentUniformSet ( ) const

Definition at line 1926 of file GrVkCaps.cpp.

◆ getPushConstantStageFlags()

VkShaderStageFlags GrVkCaps::getPushConstantStageFlags ( ) const

Definition at line 2054 of file GrVkCaps.cpp.

2054 {
2056 return stageFlags;
2057}
@ VK_SHADER_STAGE_VERTEX_BIT
@ VK_SHADER_STAGE_FRAGMENT_BIT
VkFlags VkShaderStageFlags

◆ getRenderTargetSampleCount() [1/2]

int GrVkCaps::getRenderTargetSampleCount ( int  requestedCount,
const GrBackendFormat format 
) const
overridevirtual

Implements GrCaps.

Definition at line 1597 of file GrVkCaps.cpp.

1598 {
1599 VkFormat vkFormat;
1600 if (!GrBackendFormats::AsVkFormat(format, &vkFormat)) {
1601 return 0;
1602 }
1603
1604 return this->getRenderTargetSampleCount(requestedCount, vkFormat);
1605}
int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const override

◆ getRenderTargetSampleCount() [2/2]

int GrVkCaps::getRenderTargetSampleCount ( int  requestedCount,
VkFormat  format 
) const

Definition at line 1607 of file GrVkCaps.cpp.

1607 {
1608 requestedCount = std::max(1, requestedCount);
1609
1610 const FormatInfo& info = this->getFormatInfo(format);
1611
1612 int count = info.fColorSampleCounts.size();
1613
1614 if (!count) {
1615 return 0;
1616 }
1617
1618 if (1 == requestedCount) {
1619 SkASSERT(!info.fColorSampleCounts.empty() && info.fColorSampleCounts[0] == 1);
1620 return 1;
1621 }
1622
1623 for (int i = 0; i < count; ++i) {
1624 if (info.fColorSampleCounts[i] >= requestedCount) {
1625 return info.fColorSampleCounts[i];
1626 }
1627 }
1628 return 0;
1629}
int count

◆ GetStencilFormatTotalBitCount()

static int GrVkCaps::GetStencilFormatTotalBitCount ( VkFormat  format)
inlinestatic

Definition at line 107 of file GrVkCaps.h.

107 {
108 switch (format) {
110 return 8;
112 return 32;
114 // can optionally have 24 unused bits at the end so we assume the total bits is 64.
115 return 64;
116 default:
117 SkASSERT(false);
118 return 0;
119 }
120 }
@ VK_FORMAT_D24_UNORM_S8_UINT
@ VK_FORMAT_S8_UINT
@ VK_FORMAT_D32_SFLOAT_S8_UINT

◆ getWriteSwizzle()

skgpu::Swizzle GrVkCaps::getWriteSwizzle ( const GrBackendFormat ,
GrColorType   
) const
overridevirtual

Returns the skgpu::Swizzle to use when writing colors to a surface with the passed in GrBackendFormat and GrColorType.

Implements GrCaps.

Definition at line 1849 of file GrVkCaps.cpp.

1850 {
1851 VkFormat vkFormat;
1853 const auto& info = this->getFormatInfo(vkFormat);
1854 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1855 const auto& ctInfo = info.fColorTypeInfos[i];
1856 if (ctInfo.fColorType == colorType) {
1857 return ctInfo.fWriteSwizzle;
1858 }
1859 }
1860 SkDEBUGFAILF("Illegal color type (%d) and format (%d) combination.",
1861 (int)colorType, (int)vkFormat);
1862 return {};
1863}
#define SkDEBUGFAILF(fmt,...)
Definition SkAssert.h:119

◆ gpuOnlyBuffersMorePerformant()

bool GrVkCaps::gpuOnlyBuffersMorePerformant ( ) const
inline

Definition at line 193 of file GrVkCaps.h.

193{ return fGpuOnlyBuffersMorePerformant; }

◆ isFormatAsColorTypeRenderable()

bool GrVkCaps::isFormatAsColorTypeRenderable ( GrColorType  ct,
const GrBackendFormat format,
int  sampleCount = 1 
) const
overridevirtual

Implements GrCaps.

Definition at line 1569 of file GrVkCaps.cpp.

1570 {
1571 if (!this->isFormatRenderable(format, sampleCount)) {
1572 return false;
1573 }
1574 VkFormat vkFormat;
1575 if (!GrBackendFormats::AsVkFormat(format, &vkFormat)) {
1576 return false;
1577 }
1578 const auto& info = this->getFormatInfo(vkFormat);
1579 if (!SkToBool(info.colorTypeFlags(ct) & ColorTypeInfo::kRenderable_Flag)) {
1580 return false;
1581 }
1582 return true;
1583}
bool isFormatRenderable(const GrBackendFormat &format, int sampleCount) const override

◆ isFormatCopyable()

bool GrVkCaps::isFormatCopyable ( const GrBackendFormat ) const
inlineoverridevirtual

Implements GrCaps.

Definition at line 47 of file GrVkCaps.h.

47{ return true; }

◆ isFormatRenderable() [1/2]

bool GrVkCaps::isFormatRenderable ( const GrBackendFormat format,
int  sampleCount 
) const
overridevirtual

Implements GrCaps.

Definition at line 1585 of file GrVkCaps.cpp.

1585 {
1586 VkFormat vkFormat;
1587 if (!GrBackendFormats::AsVkFormat(format, &vkFormat)) {
1588 return false;
1589 }
1590 return this->isFormatRenderable(vkFormat, sampleCount);
1591}

◆ isFormatRenderable() [2/2]

bool GrVkCaps::isFormatRenderable ( VkFormat  format,
int  sampleCount 
) const

Definition at line 1593 of file GrVkCaps.cpp.

1593 {
1594 return sampleCount <= this->maxRenderTargetSampleCount(format);
1595}
int maxRenderTargetSampleCount(const GrBackendFormat &) const override

◆ isFormatSRGB()

bool GrVkCaps::isFormatSRGB ( const GrBackendFormat format) const
overridevirtual

Implements GrCaps.

Definition at line 1539 of file GrVkCaps.cpp.

1539 {
1540 VkFormat vkFormat;
1541 if (!GrBackendFormats::AsVkFormat(format, &vkFormat)) {
1542 return false;
1543 }
1545 return false;
1546 }
1547
1548 return format_is_srgb(vkFormat);
1549}
static bool format_is_srgb(MTLPixelFormat format)
Definition GrMtlCaps.mm:452
static bool backend_format_is_external(const GrBackendFormat &format)

◆ isFormatTexturable()

bool GrVkCaps::isFormatTexturable ( const GrBackendFormat format,
GrTextureType   
) const
overridevirtual

Implements GrCaps.

Definition at line 1551 of file GrVkCaps.cpp.

1551 {
1552 VkFormat vkFormat;
1553 if (!GrBackendFormats::AsVkFormat(format, &vkFormat)) {
1554 return false;
1555 }
1557 // We can always texture from an external format (assuming we have the ycbcr conversion
1558 // info which we require to be passed in).
1559 return true;
1560 }
1561 return this->isVkFormatTexturable(vkFormat);
1562}

◆ isVkFormatTexturable()

bool GrVkCaps::isVkFormatTexturable ( VkFormat  format) const

Definition at line 1564 of file GrVkCaps.cpp.

1564 {
1565 const FormatInfo& info = this->getFormatInfo(format);
1566 return SkToBool(FormatInfo::kTexturable_Flag & info.fOptimalFlags);
1567}

◆ isVkFormatTexturableLinearly()

bool GrVkCaps::isVkFormatTexturableLinearly ( VkFormat  format) const
inline

Definition at line 67 of file GrVkCaps.h.

67 {
68 return SkToBool(FormatInfo::kTexturable_Flag & this->getFormatInfo(format).fLinearFlags);
69 }

◆ makeDesc()

GrProgramDesc GrVkCaps::makeDesc ( GrRenderTarget rt,
const GrProgramInfo programInfo,
ProgramDescOverrideFlags  overrideFlags 
) const
overridevirtual

For Vulkan we want to cache the entire VkPipeline for reuse of draws. The Desc here holds all the information needed to differentiate one pipeline from another.

The GrProgramDesc contains all the information need to create the actual shaders for the pipeline.

For Vulkan we need to add to the GrProgramDesc to include the rest of the state on the pipline. This includes stencil settings, blending information, render pass format, draw face information, and primitive type. Note that some state is set dynamically on the pipeline for each draw and thus is not included in this descriptor. This includes the viewport, scissor, and blend constant.

Implements GrCaps.

Definition at line 1962 of file GrVkCaps.cpp.

1964 {
1966 GrProgramDesc::Build(&desc, programInfo, *this);
1967
1968 skgpu::KeyBuilder b(desc.key());
1969
1970 // This will become part of the sheared off key used to persistently cache
1971 // the SPIRV code. It needs to be added right after the base key so that,
1972 // when the base-key is sheared off, the shearing code can include it in the
1973 // reduced key (c.f. the +4s in the SkData::MakeWithCopy calls in
1974 // GrVkPipelineStateBuilder.cpp).
1976
1978 if (programInfo.renderPassBarriers() & GrXferBarrierFlags::kBlend) {
1980 }
1983 }
1984
1985 bool needsResolve = this->programInfoWillUseDiscardableMSAA(programInfo);
1986
1987 bool forceLoadFromResolve =
1989 SkASSERT(!forceLoadFromResolve || needsResolve);
1990
1992 if (needsResolve && (programInfo.colorLoadOp() == GrLoadOp::kLoad || forceLoadFromResolve)) {
1994 }
1995
1996 if (rt) {
1997 GrVkRenderTarget* vkRT = (GrVkRenderTarget*) rt;
1998
1999 SkASSERT(!needsResolve || (vkRT->resolveAttachment() &&
2001
2002 bool needsStencil = programInfo.needsStencil() || programInfo.isStencilEnabled();
2003 // TODO: support failure in getSimpleRenderPass
2004 auto rp = vkRT->getSimpleRenderPass(needsResolve, needsStencil, selfDepFlags,
2005 loadFromResolve);
2006 SkASSERT(rp);
2007 rp->genKey(&b);
2008
2009#ifdef SK_DEBUG
2010 if (!rp->isExternal()) {
2011 // This is to ensure ReconstructAttachmentsDescriptor keeps matching
2012 // getSimpleRenderPass' result
2013 GrVkRenderPass::AttachmentsDescriptor attachmentsDescriptor;
2014 GrVkRenderPass::AttachmentFlags attachmentFlags;
2016 &attachmentsDescriptor,
2017 &attachmentFlags);
2018 SkASSERT(rp->isCompatible(attachmentsDescriptor, attachmentFlags, selfDepFlags,
2019 loadFromResolve));
2020 }
2021#endif
2022 } else {
2023 GrVkRenderPass::AttachmentsDescriptor attachmentsDescriptor;
2024 GrVkRenderPass::AttachmentFlags attachmentFlags;
2026 &attachmentsDescriptor,
2027 &attachmentFlags);
2028
2029 // kExternal_AttachmentFlag is only set for wrapped secondary command buffers - which
2030 // will always go through the above 'rt' path (i.e., we can always pass 0 as the final
2031 // parameter to GenKey).
2032 GrVkRenderPass::GenKey(&b, attachmentFlags, attachmentsDescriptor, selfDepFlags,
2033 loadFromResolve, 0);
2034 }
2035
2036 GrStencilSettings stencil = programInfo.nonGLStencilSettings();
2037 stencil.genKey(&b, true);
2038
2039 programInfo.pipeline().genKey(&b, *this);
2040 b.add32(programInfo.numSamples());
2041
2042 // Vulkan requires the full primitive type as part of its key
2043 b.add32(programInfo.primitiveTypeKey());
2044
2045 b.flush();
2046 return desc;
2047}
void genKey(skgpu::KeyBuilder *, const GrCaps &) const
static void Build(GrProgramDesc *, const GrProgramInfo &, const GrCaps &)
uint16_t primitiveTypeKey() const
int numSamples() const
const GrPipeline & pipeline() const
bool isStencilEnabled() const
GrLoadOp colorLoadOp() const
int needsStencil() const
GrStencilSettings nonGLStencilSettings() const
GrXferBarrierFlags renderPassBarriers() const
void genKey(skgpu::KeyBuilder *b, bool includeRefsAndMasks) const
bool programInfoWillUseDiscardableMSAA(const GrProgramInfo &) const
@ kShader_PersistentCacheKeyType
Definition GrVkGpu.h:185
bool supportsInputAttachmentUsage() const
Definition GrVkImage.h:101
static void GenKey(skgpu::KeyBuilder *, AttachmentFlags, const AttachmentsDescriptor &, SelfDependencyFlags selfDepFlags, LoadFromResolve, uint64_t externalRenderPass)
static void ReconstructAttachmentsDescriptor(const GrVkCaps &vkCaps, const GrProgramInfo &programInfo, GrVkRenderPass::AttachmentsDescriptor *desc, GrVkRenderPass::AttachmentFlags *flags)
GrVkImage * resolveAttachment() const
const GrVkRenderPass * getSimpleRenderPass(bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)

◆ maxDrawIndirectDrawCount()

uint32_t GrVkCaps::maxDrawIndirectDrawCount ( ) const
inline

Definition at line 203 of file GrVkCaps.h.

203{ return fMaxDrawIndirectDrawCount; }

◆ maxInputAttachmentDescriptors()

uint32_t GrVkCaps::maxInputAttachmentDescriptors ( ) const
inline

Definition at line 181 of file GrVkCaps.h.

181{ return fMaxInputAttachmentDescriptors; }

◆ maxPerPoolCachedSecondaryCommandBuffers()

int GrVkCaps::maxPerPoolCachedSecondaryCommandBuffers ( ) const
inline

Definition at line 177 of file GrVkCaps.h.

177 {
178 return fMaxPerPoolCachedSecondaryCommandBuffers;
179 }

◆ maxRenderTargetSampleCount() [1/2]

int GrVkCaps::maxRenderTargetSampleCount ( const GrBackendFormat format) const
overridevirtual

Implements GrCaps.

Definition at line 1631 of file GrVkCaps.cpp.

1631 {
1632 VkFormat vkFormat;
1633 if (!GrBackendFormats::AsVkFormat(format, &vkFormat)) {
1634 return 0;
1635 }
1636 return this->maxRenderTargetSampleCount(vkFormat);
1637}

◆ maxRenderTargetSampleCount() [2/2]

int GrVkCaps::maxRenderTargetSampleCount ( VkFormat  format) const

Definition at line 1639 of file GrVkCaps.cpp.

1639 {
1640 const FormatInfo& info = this->getFormatInfo(format);
1641
1642 const auto& table = info.fColorSampleCounts;
1643 if (table.empty()) {
1644 return 0;
1645 }
1646 return table[table.size() - 1];
1647}
SI F table(const skcms_Curve *curve, F v)

◆ maxSamplerAnisotropy()

float GrVkCaps::maxSamplerAnisotropy ( ) const
inline

Definition at line 183 of file GrVkCaps.h.

183{ return fMaxSamplerAnisotropy; }

◆ mustInvalidatePrimaryCmdBufferStateAfterClearAttachments()

bool GrVkCaps::mustInvalidatePrimaryCmdBufferStateAfterClearAttachments ( ) const
inline

Definition at line 185 of file GrVkCaps.h.

185 {
186 return fMustInvalidatePrimaryCmdBufferStateAfterClearAttachments;
187 }

◆ mustLoadFullImageWithDiscardableMSAA()

bool GrVkCaps::mustLoadFullImageWithDiscardableMSAA ( ) const
inline

Definition at line 259 of file GrVkCaps.h.

259 {
260 return fMustLoadFullImageWithDiscardableMSAA;
261 }

◆ mustSyncCommandBuffersWithQueue()

bool GrVkCaps::mustSyncCommandBuffersWithQueue ( ) const
inline

Definition at line 91 of file GrVkCaps.h.

91{ return fMustSyncCommandBuffersWithQueue; }

◆ onAreColorTypeAndFormatCompatible()

bool GrVkCaps::onAreColorTypeAndFormatCompatible ( GrColorType  ct,
const GrBackendFormat format 
) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 1743 of file GrVkCaps.cpp.

1744 {
1745 VkFormat vkFormat;
1746 if (!GrBackendFormats::AsVkFormat(format, &vkFormat)) {
1747 return false;
1748 }
1750 SkASSERT(ycbcrInfo);
1751
1752 if (ycbcrInfo->isValid() && !skgpu::VkFormatNeedsYcbcrSampler(vkFormat)) {
1753 // Format may be undefined for external images, which are required to have YCbCr conversion.
1754 if (VK_FORMAT_UNDEFINED == vkFormat && ycbcrInfo->fExternalFormat != 0) {
1755 return true;
1756 }
1757 return false;
1758 }
1759
1760 const auto& info = this->getFormatInfo(vkFormat);
1761 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1762 if (info.fColorTypeInfos[i].fColorType == ct) {
1763 return true;
1764 }
1765 }
1766 return false;
1767}
static constexpr bool VkFormatNeedsYcbcrSampler(VkFormat format)
@ VK_FORMAT_UNDEFINED

◆ onCanCopySurface()

bool GrVkCaps::onCanCopySurface ( const GrSurfaceProxy dst,
const SkIRect dstRect,
const GrSurfaceProxy src,
const SkIRect srcRect 
) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 216 of file GrVkCaps.cpp.

217 {
218 if (src->isProtected() == GrProtected::kYes && dst->isProtected() != GrProtected::kYes) {
219 return false;
220 }
221
222 // TODO: Figure out a way to track if we've wrapped a linear texture in a proxy (e.g.
223 // PromiseImage which won't get instantiated right away. Does this need a similar thing like the
224 // tracking of external or rectangle textures in GL? For now we don't create linear textures
225 // internally, and I don't believe anyone is wrapping them.
226 bool srcIsLinear = false;
227 bool dstIsLinear = false;
228
229 int dstSampleCnt = 0;
230 int srcSampleCnt = 0;
231 if (const GrRenderTargetProxy* rtProxy = dst->asRenderTargetProxy()) {
232 // Copying to or from render targets that wrap a secondary command buffer is not allowed
233 // since they would require us to know the VkImage, which we don't have, as well as need us
234 // to stop and start the VkRenderPass which we don't have access to.
235 if (rtProxy->wrapsVkSecondaryCB()) {
236 return false;
237 }
238 if (this->preferDiscardableMSAAAttachment() && dst->asTextureProxy() &&
239 rtProxy->supportsVkInputAttachment()) {
240 dstSampleCnt = 1;
241 } else {
242 dstSampleCnt = rtProxy->numSamples();
243 }
244 }
245 if (const GrRenderTargetProxy* rtProxy = src->asRenderTargetProxy()) {
246 // Copying to or from render targets that wrap a secondary command buffer is not allowed
247 // since they would require us to know the VkImage, which we don't have, as well as need us
248 // to stop and start the VkRenderPass which we don't have access to.
249 if (rtProxy->wrapsVkSecondaryCB()) {
250 return false;
251 }
252 if (this->preferDiscardableMSAAAttachment() && src->asTextureProxy() &&
253 rtProxy->supportsVkInputAttachment()) {
254 srcSampleCnt = 1;
255 } else {
256 srcSampleCnt = rtProxy->numSamples();
257 }
258 }
259 SkASSERT((dstSampleCnt > 0) == SkToBool(dst->asRenderTargetProxy()));
260 SkASSERT((srcSampleCnt > 0) == SkToBool(src->asRenderTargetProxy()));
261
262 bool dstHasYcbcr = false;
263 if (auto ycbcr = GrBackendFormats::GetVkYcbcrConversionInfo(dst->backendFormat())) {
264 if (ycbcr->isValid()) {
265 dstHasYcbcr = true;
266 }
267 }
268
269 bool srcHasYcbcr = false;
270 if (auto ycbcr = GrBackendFormats::GetVkYcbcrConversionInfo(src->backendFormat())) {
271 if (ycbcr->isValid()) {
272 srcHasYcbcr = true;
273 }
274 }
275
276 VkFormat dstFormat, srcFormat;
277 SkAssertResult(GrBackendFormats::AsVkFormat(dst->backendFormat(), &dstFormat));
278 SkAssertResult(GrBackendFormats::AsVkFormat(src->backendFormat(), &srcFormat));
279
280 // Only blits support scaling, but since we've already clamped the src and dst rects,
281 // the dimensions of the scaled blit aren't important to know if it's allowed.
282 const bool copyScales = srcRect.size() != dstRect.size();
283 if (!copyScales && (this->canCopyImage(dstFormat, dstSampleCnt, dstHasYcbcr,
284 srcFormat, srcSampleCnt, srcHasYcbcr) ||
285 this->canCopyAsResolve(dstFormat, dstSampleCnt, dstHasYcbcr,
286 srcFormat, srcSampleCnt, srcHasYcbcr))) {
287 return true;
288 }
289 return this->canCopyAsBlit(dstFormat, dstSampleCnt, dstIsLinear, dstHasYcbcr,
290 srcFormat, srcSampleCnt, srcIsLinear, srcHasYcbcr);
291
292}
bool preferDiscardableMSAAAttachment() const
Definition GrCaps.h:107
virtual GrTextureProxy * asTextureProxy()
bool canCopyAsResolve(VkFormat dstConfig, int dstSampleCnt, bool dstHasYcbcr, VkFormat srcConfig, int srcSamplecnt, bool srcHasYcbcr) const
Definition GrVkCaps.cpp:192
bool canCopyAsBlit(VkFormat dstConfig, int dstSampleCnt, bool dstIsLinear, bool dstHasYcbcr, VkFormat srcConfig, int srcSampleCnt, bool srcIsLinear, bool srcHasYcbcr) const
Definition GrVkCaps.cpp:169
bool canCopyImage(VkFormat dstFormat, int dstSampleCnt, bool dstHasYcbcr, VkFormat srcFormat, int srcSamplecnt, bool srcHasYcbcr) const
Definition GrVkCaps.cpp:154
dst
Definition cp.py:12
constexpr SkISize size() const
Definition SkRect.h:172

◆ onGetDefaultBackendFormat()

GrBackendFormat GrVkCaps::onGetDefaultBackendFormat ( GrColorType  ct) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 1769 of file GrVkCaps.cpp.

1769 {
1771 if (format == VK_FORMAT_UNDEFINED) {
1772 return {};
1773 }
1775}
VkFormat getFormatFromColorType(GrColorType colorType) const
Definition GrVkCaps.h:235

◆ onGetDstSampleFlagsForProxy()

GrDstSampleFlags GrVkCaps::onGetDstSampleFlagsForProxy ( const GrRenderTargetProxy rt) const
overrideprivatevirtual

Reimplemented from GrCaps.

Definition at line 1865 of file GrVkCaps.cpp.

1865 {
1866 bool isMSAAWithResolve = rt->numSamples() > 1 && rt->asTextureProxy();
1867 // TODO: Currently if we have an msaa rt with a resolve, the supportsVkInputAttachment call
1868 // references whether the resolve is supported as an input attachment. We need to add a check to
1869 // allow checking the color attachment (msaa or not) supports input attachment specifically.
1870 if (!isMSAAWithResolve && rt->supportsVkInputAttachment()) {
1872 }
1874}
bool supportsVkInputAttachment() const

◆ onGetReadSwizzle()

skgpu::Swizzle GrVkCaps::onGetReadSwizzle ( const GrBackendFormat format,
GrColorType  colorType 
) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 1825 of file GrVkCaps.cpp.

1826 {
1827 VkFormat vkFormat;
1830 SkASSERT(ycbcrInfo);
1831 if (ycbcrInfo->isValid() && ycbcrInfo->fExternalFormat != 0) {
1832 // We allow these to work with any color type and never swizzle. See
1833 // onAreColorTypeAndFormatCompatible.
1834 return skgpu::Swizzle{"rgba"};
1835 }
1836
1837 const auto& info = this->getFormatInfo(vkFormat);
1838 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1839 const auto& ctInfo = info.fColorTypeInfos[i];
1840 if (ctInfo.fColorType == colorType) {
1841 return ctInfo.fReadSwizzle;
1842 }
1843 }
1844 SkDEBUGFAILF("Illegal color type (%d) and format (%d) combination.",
1845 (int)colorType, (int)vkFormat);
1846 return {};
1847}

◆ onSupportedReadPixelsColorType()

GrCaps::SupportedRead GrVkCaps::onSupportedReadPixelsColorType ( GrColorType  srcColorType,
const GrBackendFormat srcBackendFormat,
GrColorType  dstColorType 
) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 1891 of file GrVkCaps.cpp.

1893 {
1894 VkFormat vkFormat;
1895 if (!GrBackendFormats::AsVkFormat(srcBackendFormat, &vkFormat)) {
1896 return {GrColorType::kUnknown, 0};
1897 }
1898
1899 if (skgpu::VkFormatNeedsYcbcrSampler(vkFormat)) {
1900 return {GrColorType::kUnknown, 0};
1901 }
1902
1903 SkTextureCompressionType compression = GrBackendFormatToCompressionType(srcBackendFormat);
1904 if (compression != SkTextureCompressionType::kNone) {
1907 }
1908
1909 // The VkBufferImageCopy bufferOffset field must be both a multiple of 4 and of a single texel.
1910 size_t offsetAlignment = align_to_4(skgpu::VkFormatBytesPerBlock(vkFormat));
1911
1912 const auto& info = this->getFormatInfo(vkFormat);
1913 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1914 const auto& ctInfo = info.fColorTypeInfos[i];
1915 if (ctInfo.fColorType == srcColorType) {
1916 return {ctInfo.fTransferColorType, offsetAlignment};
1917 }
1918 }
1919 return {GrColorType::kUnknown, 0};
1920}
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
static size_t align_to_4(size_t v)
static constexpr bool SkTextureCompressionTypeIsOpaque(SkTextureCompressionType compression)
static constexpr size_t VkFormatBytesPerBlock(VkFormat vkFormat)

◆ onSupportsDynamicMSAA()

bool GrVkCaps::onSupportsDynamicMSAA ( const GrRenderTargetProxy rtProxy) const
overrideprivatevirtual

Reimplemented from GrCaps.

Definition at line 1777 of file GrVkCaps.cpp.

1777 {
1778 // We must be able to use the rtProxy as an input attachment to load into the discardable msaa
1779 // attachment. Also the rtProxy should have a sample count of 1 so that it can be used as a
1780 // resolve attachment.
1781 return this->supportsDiscardableMSAAForDMSAA() &&
1782 rtProxy->supportsVkInputAttachment() &&
1783 rtProxy->numSamples() == 1;
1784}
bool supportsDiscardableMSAAForDMSAA() const
Definition GrVkCaps.h:262

◆ onSurfaceSupportsWritePixels()

bool GrVkCaps::onSurfaceSupportsWritePixels ( const GrSurface surface) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 1725 of file GrVkCaps.cpp.

1725 {
1726 if (auto rt = surface->asRenderTarget()) {
1727 return rt->numSamples() <= 1 && SkToBool(surface->asTexture());
1728 }
1729 // We can't write to a texture that has a ycbcr sampler.
1730 if (auto tex = static_cast<const GrVkTexture*>(surface->asTexture())) {
1731 auto texImage = tex->textureImage();
1732 if (!texImage) {
1733 return false;
1734 }
1735 // We can't directly read from a VkImage that has a ycbcr sampler.
1736 if (texImage->ycbcrConversionInfo().isValid()) {
1737 return false;
1738 }
1739 }
1740 return true;
1741}
VkSurfaceKHR surface
Definition main.cc:49

◆ preferPrimaryOverSecondaryCommandBuffers()

bool GrVkCaps::preferPrimaryOverSecondaryCommandBuffers ( ) const
inline

Definition at line 173 of file GrVkCaps.h.

173 {
174 return fPreferPrimaryOverSecondaryCommandBuffers;
175 }

◆ preferredStencilFormat()

VkFormat GrVkCaps::preferredStencilFormat ( ) const
inline

Returns both a supported and most preferred stencil format to use in draws.

Definition at line 104 of file GrVkCaps.h.

104{ return fPreferredStencilFormat; }

◆ programInfoWillUseDiscardableMSAA()

bool GrVkCaps::programInfoWillUseDiscardableMSAA ( const GrProgramInfo programInfo) const

Definition at line 1793 of file GrVkCaps.cpp.

1793 {
1794 return programInfo.targetHasVkResolveAttachmentWithInput() &&
1795 programInfo.numSamples() > 1 &&
1796 ((programInfo.targetsNumSamples() > 1 && this->preferDiscardableMSAAAttachment()) ||
1797 (programInfo.targetsNumSamples() == 1 && this->supportsDiscardableMSAAForDMSAA()));
1798}
int targetsNumSamples() const
bool targetHasVkResolveAttachmentWithInput() const

◆ renderTargetSupportsDiscardableMSAA()

bool GrVkCaps::renderTargetSupportsDiscardableMSAA ( const GrVkRenderTarget rt) const

Definition at line 1786 of file GrVkCaps.cpp.

1786 {
1787 return rt->resolveAttachment() &&
1789 ((rt->numSamples() > 1 && this->preferDiscardableMSAAAttachment()) ||
1790 (rt->numSamples() == 1 && this->supportsDiscardableMSAAForDMSAA()));
1791}
int numSamples() const

◆ shouldAlwaysUseDedicatedImageMemory()

bool GrVkCaps::shouldAlwaysUseDedicatedImageMemory ( ) const
inline

Definition at line 94 of file GrVkCaps.h.

94 {
95 return fShouldAlwaysUseDedicatedImageMemory;
96 }

◆ shouldPersistentlyMapCpuToGpuBuffers()

bool GrVkCaps::shouldPersistentlyMapCpuToGpuBuffers ( ) const
inline

Definition at line 198 of file GrVkCaps.h.

198 {
199 return fShouldPersistentlyMapCpuToGpuBuffers;
200 }

◆ supportedWritePixelsColorType()

GrCaps::SupportedWrite GrVkCaps::supportedWritePixelsColorType ( GrColorType  surfaceColorType,
const GrBackendFormat surfaceFormat,
GrColorType  srcColorType 
) const
overridevirtual

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 GrGpu::writePixels().

Implements GrCaps.

Definition at line 1660 of file GrVkCaps.cpp.

1662 {
1663 VkFormat vkFormat;
1664 if (!GrBackendFormats::AsVkFormat(surfaceFormat, &vkFormat)) {
1665 return {GrColorType::kUnknown, 0};
1666 }
1667
1668 // We don't support the ability to upload to external formats or formats that require a ycbcr
1669 // sampler. In general these types of formats are only used for sampling in a shader.
1670 if (backend_format_is_external(surfaceFormat) || skgpu::VkFormatNeedsYcbcrSampler(vkFormat)) {
1671 return {GrColorType::kUnknown, 0};
1672 }
1673
1674 // The VkBufferImageCopy bufferOffset field must be both a multiple of 4 and of a single texel.
1675 size_t offsetAlignment = align_to_4(skgpu::VkFormatBytesPerBlock(vkFormat));
1676
1677 const auto& info = this->getFormatInfo(vkFormat);
1678 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1679 const auto& ctInfo = info.fColorTypeInfos[i];
1680 if (ctInfo.fColorType == surfaceColorType) {
1681 return {ctInfo.fTransferColorType, offsetAlignment};
1682 }
1683 }
1684 return {GrColorType::kUnknown, 0};
1685}

◆ supportsAndroidHWBExternalMemory()

bool GrVkCaps::supportsAndroidHWBExternalMemory ( ) const
inline

Definition at line 150 of file GrVkCaps.h.

150{ return fSupportsAndroidHWBExternalMemory; }

◆ supportsBindMemory2()

bool GrVkCaps::supportsBindMemory2 ( ) const
inline

Definition at line 134 of file GrVkCaps.h.

134{ return fSupportsBindMemory2; }

◆ supportsDedicatedAllocation()

bool GrVkCaps::supportsDedicatedAllocation ( ) const
inline

Definition at line 145 of file GrVkCaps.h.

145{ return fSupportsDedicatedAllocation; }

◆ supportsDeviceFaultInfo()

bool GrVkCaps::supportsDeviceFaultInfo ( ) const
inline

Definition at line 170 of file GrVkCaps.h.

170{ return fSupportsDeviceFaultInfo; }

◆ supportsDiscardableMSAAForDMSAA()

bool GrVkCaps::supportsDiscardableMSAAForDMSAA ( ) const
inline

Definition at line 262 of file GrVkCaps.h.

262{ return fSupportsDiscardableMSAAForDMSAA; }

◆ supportsDRMFormatModifiers()

bool GrVkCaps::supportsDRMFormatModifiers ( ) const
inline

Definition at line 168 of file GrVkCaps.h.

168{ return fSupportsDRMFormatModifiers; }

◆ supportsExternalMemory()

bool GrVkCaps::supportsExternalMemory ( ) const
inline

Definition at line 148 of file GrVkCaps.h.

148{ return fSupportsExternalMemory; }

◆ supportsMaintenance1()

bool GrVkCaps::supportsMaintenance1 ( ) const
inline

Definition at line 138 of file GrVkCaps.h.

138{ return fSupportsMaintenance1; }

◆ supportsMaintenance2()

bool GrVkCaps::supportsMaintenance2 ( ) const
inline

Definition at line 139 of file GrVkCaps.h.

139{ return fSupportsMaintenance2; }

◆ supportsMaintenance3()

bool GrVkCaps::supportsMaintenance3 ( ) const
inline

Definition at line 140 of file GrVkCaps.h.

140{ return fSupportsMaintenance3; }

◆ supportsMemorylessAttachments()

bool GrVkCaps::supportsMemorylessAttachments ( ) const
inline

Definition at line 268 of file GrVkCaps.h.

268{ return fSupportsMemorylessAttachments; }

◆ supportsMemoryRequirements2()

bool GrVkCaps::supportsMemoryRequirements2 ( ) const
inline

Definition at line 131 of file GrVkCaps.h.

131{ return fSupportsMemoryRequirements2; }

◆ supportsPhysicalDeviceProperties2()

bool GrVkCaps::supportsPhysicalDeviceProperties2 ( ) const
inline

Definition at line 129 of file GrVkCaps.h.

129{ return fSupportsPhysicalDeviceProperties2; }

◆ supportsSwapchain()

bool GrVkCaps::supportsSwapchain ( ) const
inline

Definition at line 126 of file GrVkCaps.h.

126{ return fSupportsSwapchain; }

◆ supportsYcbcrConversion()

bool GrVkCaps::supportsYcbcrConversion ( ) const
inline

Definition at line 153 of file GrVkCaps.h.

153{ return fSupportsYcbcrConversion; }

◆ surfaceSupportsReadPixels()

GrCaps::SurfaceReadPixelsSupport GrVkCaps::surfaceSupportsReadPixels ( const GrSurface ) const
overridevirtual

Backends may have restrictions on what types of surfaces support GrGpu::readPixels(). We may either be able to read directly from the surface, read from a copy of the surface, or not read at all.

Implements GrCaps.

Definition at line 1687 of file GrVkCaps.cpp.

1688 {
1689 if (surface->isProtected()) {
1691 }
1692 if (auto tex = static_cast<const GrVkTexture*>(surface->asTexture())) {
1693 auto texImage = tex->textureImage();
1694 if (!texImage) {
1696 }
1697 // We can't directly read from a VkImage that has a ycbcr sampler.
1698 if (texImage->ycbcrConversionInfo().isValid()) {
1700 }
1701 // We can't directly read from a compressed format
1702 if (skgpu::VkFormatIsCompressed(texImage->imageFormat())) {
1704 }
1706 } else if (auto rt = surface->asRenderTarget()) {
1707 if (rt->numSamples() > 1) {
1709 }
1711 }
1713}
static constexpr bool VkFormatIsCompressed(VkFormat vkFormat)

◆ transferColorType()

GrColorType GrVkCaps::transferColorType ( VkFormat  vkFormat,
GrColorType  surfaceColorType 
) const

Definition at line 1715 of file GrVkCaps.cpp.

1715 {
1716 const auto& info = this->getFormatInfo(vkFormat);
1717 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1718 if (info.fColorTypeInfos[i].fColorType == surfaceColorType) {
1719 return info.fColorTypeInfos[i].fTransferColorType;
1720 }
1721 }
1722 return GrColorType::kUnknown;
1723}

◆ ycbcrCombinedImageSamplerDescriptorCount()

uint32_t GrVkCaps::ycbcrCombinedImageSamplerDescriptorCount ( ) const
inline

Definition at line 163 of file GrVkCaps.h.

163 {
164 return 3;
165 }

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