Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
skgpu::graphite::MtlComputeCommandEncoder Class Reference

#include <MtlComputeCommandEncoder.h>

Inheritance diagram for skgpu::graphite::MtlComputeCommandEncoder:
skgpu::graphite::Resource

Public Member Functions

const char * getResourceType () const override
 
void setLabel (NSString *label)
 
void pushDebugGroup (NSString *string)
 
void popDebugGroup ()
 
void insertDebugSignpost (NSString *string)
 
void setComputePipelineState (id< MTLComputePipelineState > pso)
 
void setBuffer (id< MTLBuffer > buffer, NSUInteger offset, NSUInteger index)
 
void setBufferOffset (NSUInteger offset, NSUInteger index) SK_API_AVAILABLE(macos(10.11)
 
void ios (8.3)
 
void tvos (9.0))
 
void setTexture (id< MTLTexture > texture, NSUInteger index)
 
void setSamplerState (id< MTLSamplerState > sampler, NSUInteger index)
 
void setThreadgroupMemoryLength (NSUInteger length, NSUInteger index)
 
void dispatchThreadgroups (const WorkgroupSize &globalSize, const WorkgroupSize &localSize)
 
void dispatchThreadgroupsWithIndirectBuffer (id< MTLBuffer > indirectBuffer, NSUInteger offset, const WorkgroupSize &localSize)
 
void endEncoding ()
 
- 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
 
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< MtlComputeCommandEncoderMake (const SharedContext *sharedContext, id< MTLCommandBuffer > commandBuffer)
 

Private Member Functions

void freeGpuData () override
 

Additional Inherited Members

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

Detailed Description

Wraps a MTLComputeCommandEncoder object and associated tracked state

Definition at line 23 of file MtlComputeCommandEncoder.h.

Member Function Documentation

◆ dispatchThreadgroups()

void skgpu::graphite::MtlComputeCommandEncoder::dispatchThreadgroups ( const WorkgroupSize globalSize,
const WorkgroupSize localSize 
)
inline

Definition at line 103 of file MtlComputeCommandEncoder.h.

103 {
104 MTLSize threadgroupCount =
105 MTLSizeMake(globalSize.fWidth, globalSize.fHeight, globalSize.fDepth);
106 MTLSize threadsPerThreadgroup =
107 MTLSizeMake(localSize.fWidth, localSize.fHeight, localSize.fDepth);
108 [(*fCommandEncoder) dispatchThreadgroups:threadgroupCount
109 threadsPerThreadgroup:threadsPerThreadgroup];
110 }
void dispatchThreadgroups(const WorkgroupSize &globalSize, const WorkgroupSize &localSize)

◆ dispatchThreadgroupsWithIndirectBuffer()

void skgpu::graphite::MtlComputeCommandEncoder::dispatchThreadgroupsWithIndirectBuffer ( id< MTLBuffer >  indirectBuffer,
NSUInteger  offset,
const WorkgroupSize localSize 
)
inline

Definition at line 112 of file MtlComputeCommandEncoder.h.

114 {
115 MTLSize threadsPerThreadgroup =
116 MTLSizeMake(localSize.fWidth, localSize.fHeight, localSize.fDepth);
117 [(*fCommandEncoder) dispatchThreadgroupsWithIndirectBuffer:indirectBuffer
118 indirectBufferOffset:offset
119 threadsPerThreadgroup:threadsPerThreadgroup];
120 }
void dispatchThreadgroupsWithIndirectBuffer(id< MTLBuffer > indirectBuffer, NSUInteger offset, const WorkgroupSize &localSize)
Point offset

◆ endEncoding()

void skgpu::graphite::MtlComputeCommandEncoder::endEncoding ( )
inline

Definition at line 122 of file MtlComputeCommandEncoder.h.

◆ freeGpuData()

void skgpu::graphite::MtlComputeCommandEncoder::freeGpuData ( )
inlineoverrideprivatevirtual

Implements skgpu::graphite::Resource.

Definition at line 145 of file MtlComputeCommandEncoder.h.

145{ fCommandEncoder.reset(); }

◆ getResourceType()

const char * skgpu::graphite::MtlComputeCommandEncoder::getResourceType ( ) const
inlineoverridevirtual

Implements skgpu::graphite::Resource.

Definition at line 41 of file MtlComputeCommandEncoder.h.

41{ return "Metal Compute Command Encoder"; }

◆ insertDebugSignpost()

void skgpu::graphite::MtlComputeCommandEncoder::insertDebugSignpost ( NSString *  string)
inline

Definition at line 47 of file MtlComputeCommandEncoder.h.

47{ [(*fCommandEncoder) insertDebugSignpost:string]; }

◆ ios()

void skgpu::graphite::MtlComputeCommandEncoder::ios ( 8.  3)

◆ Make()

static sk_sp< MtlComputeCommandEncoder > skgpu::graphite::MtlComputeCommandEncoder::Make ( const SharedContext sharedContext,
id< MTLCommandBuffer >  commandBuffer 
)
inlinestatic

Definition at line 25 of file MtlComputeCommandEncoder.h.

26 {
27 // Inserting a pool here so the autorelease occurs when we return and the
28 // only remaining ref is the retain below.
29 @autoreleasepool {
30 // Adding a retain here to keep our own ref separate from the autorelease pool
31 sk_cfp<id<MTLComputeCommandEncoder>> encoder =
32 sk_ret_cfp([commandBuffer computeCommandEncoder]);
33
34 // TODO(armansito): Support concurrent dispatch of compute passes using
35 // MTLDispatchTypeConcurrent on macOS 10.14+ and iOS 12.0+.
37 new MtlComputeCommandEncoder(sharedContext, std::move(encoder)));
38 }
39 }
const SharedContext * sharedContext() const
Definition Resource.h:187

◆ popDebugGroup()

void skgpu::graphite::MtlComputeCommandEncoder::popDebugGroup ( )
inline

Definition at line 46 of file MtlComputeCommandEncoder.h.

◆ pushDebugGroup()

void skgpu::graphite::MtlComputeCommandEncoder::pushDebugGroup ( NSString *  string)
inline

Definition at line 45 of file MtlComputeCommandEncoder.h.

45{ [(*fCommandEncoder) pushDebugGroup:string]; }

◆ setBuffer()

void skgpu::graphite::MtlComputeCommandEncoder::setBuffer ( id< MTLBuffer >  buffer,
NSUInteger  offset,
NSUInteger  index 
)
inline

Definition at line 56 of file MtlComputeCommandEncoder.h.

56 {
57 SkASSERT(buffer != nil);
58 SkASSERT(index < kMaxExpectedBuffers);
59 if (@available(macOS 10.11, iOS 8.3, tvOS 9.0, *)) {
60 if (fBuffers[index] == buffer) {
61 this->setBufferOffset(offset, index);
62 return;
63 }
64 }
65 if (fBuffers[index] != buffer || fBufferOffsets[index] != offset) {
66 [(*fCommandEncoder) setBuffer:buffer offset:offset atIndex:index];
67 fBuffers[index] = buffer;
68 fBufferOffsets[index] = offset;
69 }
70 }
#define SkASSERT(cond)
Definition SkAssert.h:116
void setBuffer(id< MTLBuffer > buffer, NSUInteger offset, NSUInteger index)
void setBufferOffset(NSUInteger offset, NSUInteger index) SK_API_AVAILABLE(macos(10.11)
static const uint8_t buffer[]

◆ setBufferOffset()

void skgpu::graphite::MtlComputeCommandEncoder::setBufferOffset ( NSUInteger  offset,
NSUInteger  index 
)

◆ setComputePipelineState()

void skgpu::graphite::MtlComputeCommandEncoder::setComputePipelineState ( id< MTLComputePipelineState >  pso)
inline

Definition at line 49 of file MtlComputeCommandEncoder.h.

49 {
50 if (fCurrentComputePipelineState != pso) {
51 [(*fCommandEncoder) setComputePipelineState:pso];
52 fCurrentComputePipelineState = pso;
53 }
54 }
void setComputePipelineState(id< MTLComputePipelineState > pso)

◆ setLabel()

void skgpu::graphite::MtlComputeCommandEncoder::setLabel ( NSString *  label)
inline

Definition at line 43 of file MtlComputeCommandEncoder.h.

43{ [(*fCommandEncoder) setLabel:label]; }

◆ setSamplerState()

void skgpu::graphite::MtlComputeCommandEncoder::setSamplerState ( id< MTLSamplerState >  sampler,
NSUInteger  index 
)
inline

Definition at line 89 of file MtlComputeCommandEncoder.h.

89 {
90 SkASSERT(index < kMaxExpectedTextures);
91 if (fSamplers[index] != sampler) {
92 [(*fCommandEncoder) setSamplerState:sampler atIndex:index];
93 fSamplers[index] = sampler;
94 }
95 }
void setSamplerState(id< MTLSamplerState > sampler, NSUInteger index)

◆ setTexture()

void skgpu::graphite::MtlComputeCommandEncoder::setTexture ( id< MTLTexture >  texture,
NSUInteger  index 
)
inline

Definition at line 81 of file MtlComputeCommandEncoder.h.

81 {
82 SkASSERT(index < kMaxExpectedTextures);
83 if (fTextures[index] != texture) {
84 [(*fCommandEncoder) setTexture:texture atIndex:index];
85 fTextures[index] = texture;
86 }
87 }
void setTexture(id< MTLTexture > texture, NSUInteger index)
FlTexture * texture

◆ setThreadgroupMemoryLength()

void skgpu::graphite::MtlComputeCommandEncoder::setThreadgroupMemoryLength ( NSUInteger  length,
NSUInteger  index 
)
inline

Definition at line 98 of file MtlComputeCommandEncoder.h.

98 {
99 SkASSERT(length % 16 == 0);
100 [(*fCommandEncoder) setThreadgroupMemoryLength:length atIndex:index];
101 }
void setThreadgroupMemoryLength(NSUInteger length, NSUInteger index)
size_t length

◆ tvos()

void skgpu::graphite::MtlComputeCommandEncoder::tvos ( 9.  0)
inline

Definition at line 73 of file MtlComputeCommandEncoder.h.

73 {
74 SkASSERT(index < kMaxExpectedBuffers);
75 if (fBufferOffsets[index] != offset) {
76 [(*fCommandEncoder) setBufferOffset:offset atIndex:index];
77 fBufferOffsets[index] = offset;
78 }
79 }

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