Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::MtlComputePipeline Class Referencefinal

#include <MtlComputePipeline.h>

Inheritance diagram for skgpu::graphite::MtlComputePipeline:
skgpu::graphite::ComputePipeline skgpu::graphite::Resource

Public Types

using MSLFunction = std::pair< id< MTLLibrary >, std::string >
 

Public Member Functions

 ~MtlComputePipeline () override=default
 
id< MTLComputePipelineState > mtlPipelineState () const
 
- Public Member Functions inherited from skgpu::graphite::ComputePipeline
 ~ComputePipeline () override=default
 
const char * getResourceType () const override
 
- Public Member Functions inherited from skgpu::graphite::Resource
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
Resourceoperator= (const Resource &)=delete
 
Resourceoperator= (Resource &&)=delete
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
Ownership ownership () const
 
skgpu::Budgeted budgeted () const
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
virtual const char * getResourceType () const =0
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
bool wasDestroyed () const
 
const GraphiteResourceKeykey () const
 
void setKey (const GraphiteResourceKey &key)
 
void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual void prepareForReturnToCache (const std::function< void()> &takeRef)
 

Static Public Member Functions

static sk_sp< MtlComputePipelineMake (const MtlSharedContext *, const std::string &label, MSLFunction computeMain)
 

Additional Inherited Members

- Protected Member Functions inherited from skgpu::graphite::ComputePipeline
 ComputePipeline (const SharedContext *)
 
- Protected Member Functions inherited from skgpu::graphite::Resource
 Resource (const SharedContext *, Ownership, skgpu::Budgeted, size_t gpuMemorySize, bool commandBufferRefsAsUsageRefs=false)
 
virtual ~Resource ()
 
const SharedContextsharedContext () const
 
virtual void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const
 
void setDeleteASAP ()
 

Detailed Description

Definition at line 23 of file MtlComputePipeline.h.

Member Typedef Documentation

◆ MSLFunction

using skgpu::graphite::MtlComputePipeline::MSLFunction = std::pair<id<MTLLibrary>, std::string>

Definition at line 25 of file MtlComputePipeline.h.

Constructor & Destructor Documentation

◆ ~MtlComputePipeline()

skgpu::graphite::MtlComputePipeline::~MtlComputePipeline ( )
overridedefault

Member Function Documentation

◆ Make()

sk_sp< MtlComputePipeline > skgpu::graphite::MtlComputePipeline::Make ( const MtlSharedContext sharedContext,
const std::string &  label,
MSLFunction  computeMain 
)
static

Definition at line 22 of file MtlComputePipeline.mm.

24 {
25 id<MTLLibrary> library = std::get<0>(computeMain);
26 if (!library) {
27 return nullptr;
28 }
29
30 sk_cfp<MTLComputePipelineDescriptor*> psoDescriptor([MTLComputePipelineDescriptor new]);
31
32 (*psoDescriptor).label = @(label.c_str());
33
34 NSString* entryPointName = [NSString stringWithUTF8String:std::get<1>(computeMain).c_str()];
35 (*psoDescriptor).computeFunction = [library newFunctionWithName:entryPointName];
36
37 // TODO(b/240604614): Populate input data attribute and buffer layout descriptors using the
38 // `stageInputDescriptor` property based on the contents of `pipelineDesc` (on iOS 10+ or
39 // macOS 10.12+).
40
41 // TODO(b/240604614): Define input buffer mutability using the `buffers` property based on
42 // the contents of `pipelineDesc` (on iOS 11+ or macOS 10.13+).
43
44 // TODO(b/240615224): Metal docs claim that setting the
45 // `threadGroupSizeIsMultipleOfThreadExecutionWidth` to YES may improve performance, IF we can
46 // guarantee that the thread group size used in a dispatch command is a multiple of
47 // `threadExecutionWidth` property of the pipeline state object (otherwise this will cause UB).
48
49 NSError* error;
50 sk_cfp<id<MTLComputePipelineState>> pso([sharedContext->device()
51 newComputePipelineStateWithDescriptor:psoDescriptor.get()
52 options:MTLPipelineOptionNone
53 reflection:nil
54 error:&error]);
55 if (!pso) {
56 SKGPU_LOG_E("Compute pipeline creation failure:\n%s", error.debugDescription.UTF8String);
57 return nullptr;
58 }
59
60 return sk_sp<MtlComputePipeline>(new MtlComputePipeline(sharedContext, std::move(pso)));
61}
const char * options
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38
const SharedContext * sharedContext() const
Definition: Resource.h:189
const uint8_t uint32_t uint32_t GError ** error
const myers::Point & get< 1 >(const myers::Segment &s)
Definition: Myers.h:81
const myers::Point & get< 0 >(const myers::Segment &s)
Definition: Myers.h:80

◆ mtlPipelineState()

id< MTLComputePipelineState > skgpu::graphite::MtlComputePipeline::mtlPipelineState ( ) const
inline

Definition at line 32 of file MtlComputePipeline.h.

32{ return fPipelineState.get(); }

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