Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
skgpu::graphite::MtlCaps Class Referencefinal

#include <MtlCaps.h>

Inheritance diagram for skgpu::graphite::MtlCaps:
skgpu::graphite::Caps

Public Member Functions

 MtlCaps (const id< MTLDevice >, const ContextOptions &)
 
 ~MtlCaps () 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
 
bool extractGraphicsDescs (const UniqueKey &, GraphicsPipelineDesc *, RenderPassDesc *, const RendererProvider *) const override
 
uint64_t getRenderPassDescKey (const RenderPassDesc &) const
 
bool isMac () const
 
bool isApple () const
 
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
 
- Public Member Functions inherited from skgpu::graphite::Caps
virtual ~Caps ()
 
const SkSL::ShaderCapsshaderCaps () const
 
sk_sp< SkCapabilitiescapabilities () const
 
virtual TextureInfo getDefaultSampledTextureInfo (SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
 
virtual TextureInfo getTextureInfoForSampledCopy (const TextureInfo &textureInfo, Mipmapped mipmapped) const =0
 
virtual TextureInfo getDefaultCompressedTextureInfo (SkTextureCompressionType, Mipmapped mipmapped, Protected) const =0
 
virtual TextureInfo getDefaultMSAATextureInfo (const TextureInfo &singleSampledInfo, Discardable discardable) const =0
 
virtual TextureInfo getDefaultDepthStencilTextureInfo (SkEnumBitMask< DepthStencilFlags >, uint32_t sampleCount, Protected) const =0
 
virtual TextureInfo getDefaultStorageTextureInfo (SkColorType) const =0
 
virtual SkISize getDepthAttachmentDimensions (const TextureInfo &, const SkISize colorAttachmentDimensions) const
 
virtual UniqueKey makeGraphicsPipelineKey (const GraphicsPipelineDesc &, const RenderPassDesc &) const =0
 
virtual UniqueKey makeComputePipelineKey (const ComputePipelineDesc &) const =0
 
virtual GraphiteResourceKey makeSamplerKey (const SamplerDesc &samplerDesc) const
 
virtual ImmutableSamplerInfo getImmutableSamplerInfo (const TextureProxy *) const
 
virtual bool extractGraphicsDescs (const UniqueKey &, GraphicsPipelineDesc *, RenderPassDesc *, const RendererProvider *) const
 
bool areColorTypeAndTextureInfoCompatible (SkColorType, const TextureInfo &) const
 
virtual uint32_t channelMask (const TextureInfo &) const =0
 
bool isTexturable (const TextureInfo &) const
 
virtual bool isRenderable (const TextureInfo &) const =0
 
virtual bool isStorage (const TextureInfo &) const =0
 
int maxTextureSize () const
 
int defaultMSAASamplesCount () const
 
virtual void buildKeyForTexture (SkISize dimensions, const TextureInfo &, ResourceType, Shareable, GraphiteResourceKey *) const =0
 
const ResourceBindingRequirementsresourceBindingRequirements () const
 
size_t requiredUniformBufferAlignment () const
 
size_t requiredStorageBufferAlignment () const
 
size_t requiredTransferBufferAlignment () const
 
size_t getAlignedTextureDataRowBytes (size_t rowBytes) const
 
virtual bool supportsWritePixels (const TextureInfo &textureInfo) const =0
 
virtual bool supportsReadPixels (const TextureInfo &textureInfo) const =0
 
virtual std::pair< SkColorType, bool > supportedWritePixelsColorType (SkColorType dstColorType, const TextureInfo &dstTextureInfo, SkColorType srcColorType) const =0
 
virtual std::pair< SkColorType, bool > supportedReadPixelsColorType (SkColorType srcColorType, const TextureInfo &srcTextureInfo, SkColorType dstColorType) const =0
 
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
 
bool setBackendLabels () const
 

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
 
bool fSetBackendLabels = false
 

Detailed Description

Definition at line 20 of file MtlCaps.h.

Constructor & Destructor Documentation

◆ MtlCaps()

skgpu::graphite::MtlCaps::MtlCaps ( const id< MTLDevice >  device,
const ContextOptions options 
)

Definition at line 27 of file MtlCaps.mm.

28 : Caps() {
29 this->initGPUFamily(device);
30 this->initCaps(device);
31 this->initShaderCaps();
32
33 this->initFormatTable(device);
34
35 // Metal-specific MtlCaps
36
38}
const char * options
void finishInitialization(const ContextOptions &)
Definition: Caps.cpp:29
VkDevice device
Definition: main.cc:53

◆ ~MtlCaps()

skgpu::graphite::MtlCaps::~MtlCaps ( )
inlineoverride

Definition at line 23 of file MtlCaps.h.

23{}

Member Function Documentation

◆ buildKeyForTexture()

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

Implements skgpu::graphite::Caps.

Definition at line 1156 of file MtlCaps.mm.

1160 {
1161 const MtlTextureSpec& mtlSpec = info.mtlTextureSpec();
1162
1163 SkASSERT(!dimensions.isEmpty());
1164
1165 // A MTLPixelFormat is an NSUInteger type which is documented to be 32 bits in 32 bit
1166 // applications and 64 bits in 64 bit applications. So it should fit in an uint64_t, but adding
1167 // the assert heere to make sure.
1168 static_assert(sizeof(MTLPixelFormat) <= sizeof(uint64_t));
1169 SkASSERT(mtlSpec.fFormat != MTLPixelFormatInvalid);
1170 uint64_t formatKey = static_cast<uint64_t>(mtlSpec.fFormat);
1171
1172 uint32_t samplesKey = SamplesToKey(info.numSamples());
1173 // We don't have to key the number of mip levels because it is inherit in the combination of
1174 // isMipped and dimensions.
1175 bool isMipped = info.mipmapped() == Mipmapped::kYes;
1176 Protected isProtected = info.isProtected();
1177 bool isFBOnly = mtlSpec.fFramebufferOnly;
1178
1179 // Confirm all the below parts of the key can fit in a single uint32_t. The sum of the shift
1180 // amounts in the asserts must be less than or equal to 32.
1181 SkASSERT(samplesKey < (1u << 3));
1182 SkASSERT(static_cast<uint32_t>(isMipped) < (1u << 1));
1183 SkASSERT(static_cast<uint32_t>(isProtected) < (1u << 1));
1184 SkASSERT(mtlSpec.fUsage < (1u << 5));
1185 SkASSERT(mtlSpec.fStorageMode < (1u << 2));
1186 SkASSERT(static_cast<uint32_t>(isFBOnly) < (1u << 1));
1187
1188 // We need two uint32_ts for dimensions, 2 for format, and 1 for the rest of the key;
1189 static int kNum32DataCnt = 2 + 2 + 1;
1190
1191 GraphiteResourceKey::Builder builder(key, type, kNum32DataCnt, shareable);
1192
1193 builder[0] = dimensions.width();
1194 builder[1] = dimensions.height();
1195 builder[2] = formatKey & 0xFFFFFFFF;
1196 builder[3] = (formatKey >> 32) & 0xFFFFFFFF;
1197 builder[4] = (samplesKey << 0) |
1198 (static_cast<uint32_t>(isMipped) << 3) |
1199 (static_cast<uint32_t>(isProtected) << 4) |
1200 (static_cast<uint32_t>(mtlSpec.fUsage) << 5) |
1201 (static_cast<uint32_t>(mtlSpec.fStorageMode) << 10)|
1202 (static_cast<uint32_t>(isFBOnly) << 12);
1203
1204}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SkASSERT(cond)
Definition: SkAssert.h:116
GLenum type
static uint32_t SamplesToKey(uint32_t numSamples)
Definition: Caps.h:314
DlVertices::Builder Builder
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

◆ channelMask()

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

Implements skgpu::graphite::Caps.

Definition at line 1024 of file MtlCaps.mm.

1024 {
1025 return skgpu::MtlFormatChannels((MTLPixelFormat)info.mtlTextureSpec().fFormat);
1026}
uint32_t MtlFormatChannels(MTLPixelFormat mtlFormat)
Definition: MtlUtils.mm:102

◆ extractGraphicsDescs()

bool skgpu::graphite::MtlCaps::extractGraphicsDescs ( const UniqueKey key,
GraphicsPipelineDesc pipelineDesc,
RenderPassDesc renderPassDesc,
const RendererProvider rendererProvider 
) const
overridevirtual

Reimplemented from skgpu::graphite::Caps.

Definition at line 921 of file MtlCaps.mm.

924 {
925 struct UnpackedKeyData {
926 // From the GraphicsPipelineDesc
927 uint32_t fRenderStepID = 0;
928 UniquePaintParamsID fPaintParamsID;
929
930 // From the RenderPassDesc
931 MtlPixelFormat fColorFormat = 0;
932 uint32_t fColorSampleCount = 1;
933
934 MtlPixelFormat fDSFormat = 0;
935 uint32_t fDSSampleCount = 1;
936
937 Swizzle fWriteSwizzle;
938 } keyData;
939
942
943 const uint32_t* rawKeyData = key.data();
944
945 keyData.fRenderStepID = rawKeyData[0];
946 keyData.fPaintParamsID = rawKeyData[1] ? UniquePaintParamsID(rawKeyData[1])
947 : UniquePaintParamsID::InvalidID();
948
949 keyData.fDSFormat = static_cast<MtlPixelFormat>((rawKeyData[2] >> 16) & 0xFFFF);
950 keyData.fDSSampleCount = rawKeyData[2] & 0xFFFF;
951
952 keyData.fColorFormat = static_cast<MtlPixelFormat>((rawKeyData[3] >> 16) & 0xFFFF);
953 keyData.fColorSampleCount = rawKeyData[3] & 0xFFFF;
954
955 keyData.fWriteSwizzle = SwizzleCtorAccessor::Make(rawKeyData[4]);
956
957 // Recreate the RenderPassDesc
958 SkASSERT(keyData.fColorSampleCount == keyData.fDSSampleCount);
959
960 MTLPixelFormat dsFormat = (MTLPixelFormat) keyData.fDSFormat;
962 if (MtlFormatIsDepth(dsFormat)) {
963 dsFlags |= DepthStencilFlags::kDepth;
964 }
965 if (MtlFormatIsStencil(dsFormat)) {
967 }
968
969 MtlTextureInfo mtlInfo(keyData.fColorSampleCount,
971 keyData.fColorFormat,
972 MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget,
973 MTLStorageModePrivate,
974 /* framebufferOnly= */ false);
975 TextureInfo info(mtlInfo);
976
977 *renderPassDesc = RenderPassDesc::Make(this,
978 info,
981 dsFlags,
982 /* clearColor= */ { .0f, .0f, .0f, .0f },
983 /* requiresMSAA= */ keyData.fColorSampleCount > 1,
984 keyData.fWriteSwizzle);
985
986 // Recreate the GraphicsPipelineDesc
987 const RenderStep* renderStep = rendererProvider->lookup(keyData.fRenderStepID);
988
989 UniquePaintParamsID paintID = renderStep->performsShading() ? keyData.fPaintParamsID
991
992 *pipelineDesc = GraphicsPipelineDesc(renderStep, paintID);
993
994 return true;
995}
static Swizzle Make(uint16_t key)
Definition: SwizzlePriv.h:21
static UniquePaintParamsID InvalidID()
if(end==-1)
unsigned int MtlPixelFormat
static const int kGraphicsPipelineKeyData32Count
Definition: MtlCaps.mm:896
static const skgpu::UniqueKey::Domain kGraphicsPipelineDomain
Definition: MtlCaps.mm:895
bool MtlFormatIsStencil(MTLPixelFormat format)
Definition: MtlUtils.mm:47
bool MtlFormatIsDepth(MTLPixelFormat format)
Definition: MtlUtils.mm:33
static RenderPassDesc Make(const Caps *caps, const TextureInfo &targetInfo, LoadOp loadOp, StoreOp storeOp, SkEnumBitMask< DepthStencilFlags > depthStencilFlags, const std::array< float, 4 > &clearColor, bool requiresMSAA, Swizzle writeSwizzle)

◆ getDefaultCompressedTextureInfo()

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

Implements skgpu::graphite::Caps.

Definition at line 761 of file MtlCaps.mm.

763 {
764 MTLTextureUsage usage = MTLTextureUsageShaderRead;
765
766 MtlPixelFormat format = format_from_compression(compression);
767 if (format == MTLPixelFormatInvalid) {
768 return {};
769 }
770
771 MtlTextureInfo info;
772 info.fSampleCount = 1;
773 info.fMipmapped = mipmapped;
774 info.fFormat = format;
775 info.fUsage = usage;
776 info.fStorageMode = MTLStorageModePrivate;
777 info.fFramebufferOnly = false;
778
779 return info;
780}
uint32_t uint32_t * format
static void usage(char *argv0)

◆ getDefaultDepthStencilTextureInfo()

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

Implements skgpu::graphite::Caps.

Definition at line 838 of file MtlCaps.mm.

841 {
842 MtlTextureInfo info;
843 info.fSampleCount = sampleCount;
844 info.fMipmapped = Mipmapped::kNo;
845 info.fFormat = this->getFormatFromDepthStencilFlags(depthStencilType);
846 info.fUsage = MTLTextureUsageRenderTarget;
847 info.fStorageMode = this->getDefaultMSAAStorageMode(Discardable::kYes);
848 info.fFramebufferOnly = false;
849
850 return info;
851}

◆ getDefaultMSAATextureInfo()

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

Implements skgpu::graphite::Caps.

Definition at line 793 of file MtlCaps.mm.

794 {
795 if (fDefaultMSAASamples <= 1) {
796 return {};
797 }
798 const MtlTextureSpec& singleSpec = singleSampledInfo.mtlTextureSpec();
799 if (!this->isRenderable((MTLPixelFormat)singleSpec.fFormat, fDefaultMSAASamples)) {
800 return {};
801 }
802
803 MTLTextureUsage usage = MTLTextureUsageRenderTarget;
804
805 MtlTextureInfo info;
806 info.fSampleCount = fDefaultMSAASamples;
807 info.fMipmapped = Mipmapped::kNo;
808 info.fFormat = singleSpec.fFormat;
809 info.fUsage = usage;
810 info.fStorageMode = this->getDefaultMSAAStorageMode(discardable);
811 info.fFramebufferOnly = false;
812
813 return info;
814}
int fDefaultMSAASamples
Definition: Caps.h:357
bool isRenderable(const TextureInfo &) const override
Definition: MtlCaps.mm:1046

◆ getDefaultSampledTextureInfo()

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

Implements skgpu::graphite::Caps.

Definition at line 705 of file MtlCaps.mm.

708 {
709 MTLTextureUsage usage = MTLTextureUsageShaderRead;
710 if (renderable == Renderable::kYes) {
711 usage |= MTLTextureUsageRenderTarget;
712 }
713
714 MtlPixelFormat format = this->getFormatFromColorType(colorType);
715 if (format == MTLPixelFormatInvalid) {
716 return {};
717 }
718
719 MtlTextureInfo info;
720 info.fSampleCount = 1;
721 info.fMipmapped = mipmapped;
722 info.fFormat = format;
723 info.fUsage = usage;
724 info.fStorageMode = MTLStorageModePrivate;
725 info.fFramebufferOnly = false;
726
727 return info;
728}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)

◆ getDefaultStorageTextureInfo()

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

Implements skgpu::graphite::Caps.

Definition at line 853 of file MtlCaps.mm.

853 {
854 // Storage textures are currently always sampleable from a shader.
855 MTLPixelFormat format = static_cast<MTLPixelFormat>(this->getFormatFromColorType(colorType));
856 if (format == MTLPixelFormatInvalid) {
857 return {};
858 }
859
860 const FormatInfo& formatInfo = this->getFormatInfo(format);
861 if (!SkToBool(FormatInfo::kStorage_Flag & formatInfo.fFlags)) {
862 return {};
863 }
864
865 MTLTextureUsage usage = MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
866 MtlTextureInfo info;
867 info.fSampleCount = 1;
868 info.fMipmapped = Mipmapped::kNo;
869 info.fFormat = format;
870 info.fUsage = usage;
871 info.fStorageMode = MTLStorageModePrivate;
872 info.fFramebufferOnly = false;
873
874 return info;
875}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ getRenderPassDescKey()

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

Definition at line 997 of file MtlCaps.mm.

997 {
998 MtlTextureInfo colorInfo, depthStencilInfo;
999 renderPassDesc.fColorAttachment.fTextureInfo.getMtlTextureInfo(&colorInfo);
1000 renderPassDesc.fDepthStencilAttachment.fTextureInfo.getMtlTextureInfo(&depthStencilInfo);
1001 SkASSERT(colorInfo.fFormat < 65535 && depthStencilInfo.fFormat < 65535);
1002 uint32_t colorAttachmentKey = colorInfo.fFormat << 16 | colorInfo.fSampleCount;
1003 uint32_t dsAttachmentKey = depthStencilInfo.fFormat << 16 | depthStencilInfo.fSampleCount;
1004 return (((uint64_t) colorAttachmentKey) << 32) | dsAttachmentKey;
1005}

◆ getTextureInfoForSampledCopy()

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

Implements skgpu::graphite::Caps.

Definition at line 730 of file MtlCaps.mm.

731 {
732 MtlTextureInfo info;
733 if (!textureInfo.getMtlTextureInfo(&info)) {
734 return {};
735 }
736
737 info.fSampleCount = 1;
738 info.fMipmapped = mipmapped;
739 info.fUsage = MTLTextureUsageShaderRead;
740 info.fStorageMode = MTLStorageModePrivate;
741 info.fFramebufferOnly = false;
742
743 return info;
744}

◆ isApple()

bool skgpu::graphite::MtlCaps::isApple ( ) const
inline

Definition at line 60 of file MtlCaps.h.

60{ return fGPUFamily == GPUFamily::kApple; }

◆ isMac()

bool skgpu::graphite::MtlCaps::isMac ( ) const
inline

Definition at line 59 of file MtlCaps.h.

59{ return fGPUFamily == GPUFamily::kMac; }

◆ isRenderable()

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

Implements skgpu::graphite::Caps.

Definition at line 1046 of file MtlCaps.mm.

1046 {
1047 return info.isValid() &&
1048 (info.mtlTextureSpec().fUsage & MTLTextureUsageRenderTarget) &&
1049 this->isRenderable((MTLPixelFormat)info.mtlTextureSpec().fFormat, info.numSamples());
1050}

◆ isStorage()

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

Implements skgpu::graphite::Caps.

Definition at line 1056 of file MtlCaps.mm.

1056 {
1057 if (!info.isValid()) {
1058 return false;
1059 }
1060 if (!(info.mtlTextureSpec().fUsage & MTLTextureUsageShaderWrite)) {
1061 return false;
1062 }
1063 if (info.mtlTextureSpec().fFramebufferOnly) {
1064 return false;
1065 }
1066 const FormatInfo& formatInfo =
1067 this->getFormatInfo((MTLPixelFormat)info.mtlTextureSpec().fFormat);
1068 return info.numSamples() == 1 && SkToBool(FormatInfo::kStorage_Flag & formatInfo.fFlags);
1069}

◆ makeComputePipelineKey()

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

Implements skgpu::graphite::Caps.

Definition at line 1007 of file MtlCaps.mm.

1007 {
1008 UniqueKey pipelineKey;
1009 {
1010 static const skgpu::UniqueKey::Domain kComputePipelineDomain = UniqueKey::GenerateDomain();
1011 // The key is made up of a single uint32_t corresponding to the compute step ID.
1012 UniqueKey::Builder builder(&pipelineKey, kComputePipelineDomain, 1, "ComputePipeline");
1013 builder[0] = pipelineDesc.computeStep()->uniqueID();
1014
1015 // TODO(b/240615224): The local work group size should factor into the key on platforms
1016 // that don't support specialization constants and require the workgroup/threadgroup size to
1017 // be specified in the shader text (D3D12, Vulkan 1.0, and OpenGL).
1018
1019 builder.finish();
1020 }
1021 return pipelineKey;
1022}
static Domain GenerateDomain()
Definition: ResourceKey.cpp:27

◆ makeGraphicsPipelineKey()

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

Implements skgpu::graphite::Caps.

Definition at line 898 of file MtlCaps.mm.

899 {
900 UniqueKey pipelineKey;
901 {
902 // 5 uint32_t's (render step id, paint id, uint64 renderpass desc, uint16 write swizzle key)
904 kGraphicsPipelineKeyData32Count, "GraphicsPipeline");
905 // add GraphicsPipelineDesc key
906 builder[0] = pipelineDesc.renderStepID();
907 builder[1] = pipelineDesc.paintParamsID().asUInt();
908
909 // add RenderPassDesc key
910 uint64_t renderPassKey = this->getRenderPassDescKey(renderPassDesc);
911 builder[2] = renderPassKey & 0xFFFFFFFF;
912 builder[3] = (renderPassKey >> 32) & 0xFFFFFFFF;
913 builder[4] = renderPassDesc.fWriteSwizzle.asKey();
914
915 builder.finish();
916 }
917
918 return pipelineKey;
919}
uint64_t getRenderPassDescKey(const RenderPassDesc &) const
Definition: MtlCaps.mm:997

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