Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
skgpu::graphite::CommandBuffer Class Referenceabstract

#include <CommandBuffer.h>

Inheritance diagram for skgpu::graphite::CommandBuffer:
skgpu::graphite::DawnCommandBuffer skgpu::graphite::MtlCommandBuffer skgpu::graphite::VulkanCommandBuffer

Public Types

using DrawPassList = skia_private::TArray< std::unique_ptr< DrawPass > >
 
using DispatchGroupSpan = SkSpan< const std::unique_ptr< DispatchGroup > >
 

Public Member Functions

virtual ~CommandBuffer ()
 
void trackResource (sk_sp< Resource > resource)
 
void trackCommandBufferResource (sk_sp< Resource > resource)
 
void resetCommandBuffer ()
 
virtual bool setNewCommandBufferResources ()=0
 
void addFinishedProc (sk_sp< RefCntedCallback > finishedProc)
 
void callFinishedProcs (bool success)
 
virtual void addWaitSemaphores (size_t numWaitSemaphores, const BackendSemaphore *waitSemaphores)
 
virtual void addSignalSemaphores (size_t numWaitSemaphores, const BackendSemaphore *signalSemaphores)
 
virtual void prepareSurfaceForStateUpdate (SkSurface *targetSurface, const MutableTextureState *newState)
 
void addBuffersToAsyncMapOnSubmit (SkSpan< const sk_sp< Buffer > >)
 
SkSpan< const sk_sp< Buffer > > buffersToAsyncMapOnSubmit () const
 
bool addRenderPass (const RenderPassDesc &, sk_sp< Texture > colorTexture, sk_sp< Texture > resolveTexture, sk_sp< Texture > depthStencilTexture, SkRect viewport, const DrawPassList &drawPasses)
 
bool addComputePass (DispatchGroupSpan dispatchGroups)
 
bool copyBufferToBuffer (const Buffer *srcBuffer, size_t srcOffset, sk_sp< Buffer > dstBuffer, size_t dstOffset, size_t size)
 
bool copyTextureToBuffer (sk_sp< Texture >, SkIRect srcRect, sk_sp< Buffer >, size_t bufferOffset, size_t bufferRowBytes)
 
bool copyBufferToTexture (const Buffer *, sk_sp< Texture >, const BufferTextureCopyData *, int count)
 
bool copyTextureToTexture (sk_sp< Texture > src, SkIRect srcRect, sk_sp< Texture > dst, SkIPoint dstPoint, int mipLevel)
 
bool synchronizeBufferToCpu (sk_sp< Buffer >)
 
bool clearBuffer (const Buffer *buffer, size_t offset, size_t size)
 
void setReplayTranslation (SkIVector translation)
 
void clearReplayTranslation ()
 

Protected Member Functions

 CommandBuffer ()
 

Protected Attributes

SkISize fRenderPassSize
 
SkIVector fReplayTranslation
 

Private Member Functions

virtual void onResetCommandBuffer ()=0
 
virtual bool onAddRenderPass (const RenderPassDesc &, const Texture *colorTexture, const Texture *resolveTexture, const Texture *depthStencilTexture, SkRect viewport, const DrawPassList &drawPasses)=0
 
virtual bool onAddComputePass (DispatchGroupSpan dispatchGroups)=0
 
virtual bool onCopyBufferToBuffer (const Buffer *srcBuffer, size_t srcOffset, const Buffer *dstBuffer, size_t dstOffset, size_t size)=0
 
virtual bool onCopyTextureToBuffer (const Texture *, SkIRect srcRect, const Buffer *, size_t bufferOffset, size_t bufferRowBytes)=0
 
virtual bool onCopyBufferToTexture (const Buffer *, const Texture *, const BufferTextureCopyData *, int count)=0
 
virtual bool onCopyTextureToTexture (const Texture *src, SkIRect srcRect, const Texture *dst, SkIPoint dstPoint, int mipLevel)=0
 
virtual bool onSynchronizeBufferToCpu (const Buffer *, bool *outDidResultInWork)=0
 
virtual bool onClearBuffer (const Buffer *, size_t offset, size_t size)=0
 

Detailed Description

Definition at line 38 of file CommandBuffer.h.

Member Typedef Documentation

◆ DispatchGroupSpan

Definition at line 41 of file CommandBuffer.h.

◆ DrawPassList

Definition at line 40 of file CommandBuffer.h.

Constructor & Destructor Documentation

◆ ~CommandBuffer()

skgpu::graphite::CommandBuffer::~CommandBuffer ( )
virtual

Definition at line 24 of file CommandBuffer.cpp.

24 {
25 this->releaseResources();
26}

◆ CommandBuffer()

skgpu::graphite::CommandBuffer::CommandBuffer ( )
protected

Definition at line 22 of file CommandBuffer.cpp.

22{}

Member Function Documentation

◆ addBuffersToAsyncMapOnSubmit()

void skgpu::graphite::CommandBuffer::addBuffersToAsyncMapOnSubmit ( SkSpan< const sk_sp< Buffer > >  buffers)

Definition at line 64 of file CommandBuffer.cpp.

64 {
65 for (size_t i = 0; i < buffers.size(); ++i) {
66 SkASSERT(buffers[i]);
67 fBuffersToAsyncMap.push_back(buffers[i]);
68 }
69}
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr size_t size() const
Definition: SkSpan_impl.h:95

◆ addComputePass()

bool skgpu::graphite::CommandBuffer::addComputePass ( DispatchGroupSpan  dispatchGroups)

Definition at line 110 of file CommandBuffer.cpp.

110 {
111 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
112
113 if (!this->onAddComputePass(dispatchGroups)) {
114 return false;
115 }
116
117 SkDEBUGCODE(fHasWork = true;)
118
119 return true;
120}
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
virtual bool onAddComputePass(DispatchGroupSpan dispatchGroups)=0
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ addFinishedProc()

void skgpu::graphite::CommandBuffer::addFinishedProc ( sk_sp< RefCntedCallback finishedProc)

Definition at line 51 of file CommandBuffer.cpp.

51 {
52 fFinishedProcs.push_back(std::move(finishedProc));
53}

◆ addRenderPass()

bool skgpu::graphite::CommandBuffer::addRenderPass ( const RenderPassDesc renderPassDesc,
sk_sp< Texture colorTexture,
sk_sp< Texture resolveTexture,
sk_sp< Texture depthStencilTexture,
SkRect  viewport,
const DrawPassList drawPasses 
)

Definition at line 75 of file CommandBuffer.cpp.

80 {
81 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
82
83 fRenderPassSize = colorTexture->dimensions();
84 if (!this->onAddRenderPass(renderPassDesc,
85 colorTexture.get(),
86 resolveTexture.get(),
87 depthStencilTexture.get(),
88 viewport,
89 drawPasses)) {
90 return false;
91 }
92
93 if (colorTexture) {
94 this->trackCommandBufferResource(std::move(colorTexture));
95 }
96 if (resolveTexture) {
97 this->trackCommandBufferResource(std::move(resolveTexture));
98 }
99 if (depthStencilTexture) {
100 this->trackCommandBufferResource(std::move(depthStencilTexture));
101 }
102 // We just assume if you are adding a render pass that the render pass will actually do work. In
103 // theory we could have a discard load that doesn't submit any draws, clears, etc. But hopefully
104 // something so trivial would be caught before getting here.
105 SkDEBUGCODE(fHasWork = true;)
106
107 return true;
108}
T * get() const
Definition: SkRefCnt.h:303
virtual bool onAddRenderPass(const RenderPassDesc &, const Texture *colorTexture, const Texture *resolveTexture, const Texture *depthStencilTexture, SkRect viewport, const DrawPassList &drawPasses)=0
void trackCommandBufferResource(sk_sp< Resource > resource)

◆ addSignalSemaphores()

virtual void skgpu::graphite::CommandBuffer::addSignalSemaphores ( size_t  numWaitSemaphores,
const BackendSemaphore signalSemaphores 
)
inlinevirtual

Reimplemented in skgpu::graphite::MtlCommandBuffer.

Definition at line 68 of file CommandBuffer.h.

69 {}

◆ addWaitSemaphores()

virtual void skgpu::graphite::CommandBuffer::addWaitSemaphores ( size_t  numWaitSemaphores,
const BackendSemaphore waitSemaphores 
)
inlinevirtual

Reimplemented in skgpu::graphite::MtlCommandBuffer.

Definition at line 66 of file CommandBuffer.h.

67 {}

◆ buffersToAsyncMapOnSubmit()

SkSpan< const sk_sp< Buffer > > skgpu::graphite::CommandBuffer::buffersToAsyncMapOnSubmit ( ) const

Definition at line 71 of file CommandBuffer.cpp.

71 {
72 return fBuffersToAsyncMap;
73}

◆ callFinishedProcs()

void skgpu::graphite::CommandBuffer::callFinishedProcs ( bool  success)

Definition at line 55 of file CommandBuffer.cpp.

55 {
56 if (!success) {
57 for (int i = 0; i < fFinishedProcs.size(); ++i) {
58 fFinishedProcs[i]->setFailureResult();
59 }
60 }
61 fFinishedProcs.clear();
62}

◆ clearBuffer()

bool skgpu::graphite::CommandBuffer::clearBuffer ( const Buffer buffer,
size_t  offset,
size_t  size 
)

Definition at line 222 of file CommandBuffer.cpp.

222 {
224
225 if (!this->onClearBuffer(buffer, offset, size)) {
226 return false;
227 }
228
229 SkDEBUGCODE(fHasWork = true;)
230
231 return true;
232}
virtual bool onClearBuffer(const Buffer *, size_t offset, size_t size)=0
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SeparatedVector2 offset

◆ clearReplayTranslation()

void skgpu::graphite::CommandBuffer::clearReplayTranslation ( )
inline

Definition at line 113 of file CommandBuffer.h.

113{ fReplayTranslation = {0, 0}; }

◆ copyBufferToBuffer()

bool skgpu::graphite::CommandBuffer::copyBufferToBuffer ( const Buffer srcBuffer,
size_t  srcOffset,
sk_sp< Buffer dstBuffer,
size_t  dstOffset,
size_t  size 
)

Definition at line 122 of file CommandBuffer.cpp.

126 {
127 SkASSERT(srcBuffer);
128 SkASSERT(dstBuffer);
129
130 if (!this->onCopyBufferToBuffer(srcBuffer, srcOffset, dstBuffer.get(), dstOffset, size)) {
131 return false;
132 }
133
134 this->trackResource(std::move(dstBuffer));
135
136 SkDEBUGCODE(fHasWork = true;)
137
138 return true;
139}
virtual bool onCopyBufferToBuffer(const Buffer *srcBuffer, size_t srcOffset, const Buffer *dstBuffer, size_t dstOffset, size_t size)=0
void trackResource(sk_sp< Resource > resource)

◆ copyBufferToTexture()

bool skgpu::graphite::CommandBuffer::copyBufferToTexture ( const Buffer buffer,
sk_sp< Texture texture,
const BufferTextureCopyData copyData,
int  count 
)

Definition at line 162 of file CommandBuffer.cpp.

165 {
168 SkASSERT(count > 0 && copyData);
169
170 if (!this->onCopyBufferToTexture(buffer, texture.get(), copyData, count)) {
171 return false;
172 }
173
174 this->trackCommandBufferResource(std::move(texture));
175
176 SkDEBUGCODE(fHasWork = true;)
177
178 return true;
179}
int count
Definition: FontMgrTest.cpp:50
virtual bool onCopyBufferToTexture(const Buffer *, const Texture *, const BufferTextureCopyData *, int count)=0
FlTexture * texture

◆ copyTextureToBuffer()

bool skgpu::graphite::CommandBuffer::copyTextureToBuffer ( sk_sp< Texture texture,
SkIRect  srcRect,
sk_sp< Buffer buffer,
size_t  bufferOffset,
size_t  bufferRowBytes 
)

Definition at line 141 of file CommandBuffer.cpp.

145 {
148
149 if (!this->onCopyTextureToBuffer(texture.get(), srcRect, buffer.get(), bufferOffset,
150 bufferRowBytes)) {
151 return false;
152 }
153
154 this->trackCommandBufferResource(std::move(texture));
155 this->trackResource(std::move(buffer));
156
157 SkDEBUGCODE(fHasWork = true;)
158
159 return true;
160}
virtual bool onCopyTextureToBuffer(const Texture *, SkIRect srcRect, const Buffer *, size_t bufferOffset, size_t bufferRowBytes)=0

◆ copyTextureToTexture()

bool skgpu::graphite::CommandBuffer::copyTextureToTexture ( sk_sp< Texture src,
SkIRect  srcRect,
sk_sp< Texture dst,
SkIPoint  dstPoint,
int  mipLevel 
)

Definition at line 181 of file CommandBuffer.cpp.

185 {
186 SkASSERT(src);
187 SkASSERT(dst);
188 if (src->textureInfo().isProtected() == Protected::kYes &&
189 dst->textureInfo().isProtected() != Protected::kYes) {
190 SKGPU_LOG_E("Can't copy from protected memory to non-protected");
191 return false;
192 }
193
194 if (!this->onCopyTextureToTexture(src.get(), srcRect, dst.get(), dstPoint, mipLevel)) {
195 return false;
196 }
197
198 this->trackCommandBufferResource(std::move(src));
199 this->trackCommandBufferResource(std::move(dst));
200
201 SkDEBUGCODE(fHasWork = true;)
202
203 return true;
204}
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38
virtual bool onCopyTextureToTexture(const Texture *src, SkIRect srcRect, const Texture *dst, SkIPoint dstPoint, int mipLevel)=0
dst
Definition: cp.py:12

◆ onAddComputePass()

virtual bool skgpu::graphite::CommandBuffer::onAddComputePass ( DispatchGroupSpan  dispatchGroups)
privatepure virtual

◆ onAddRenderPass()

virtual bool skgpu::graphite::CommandBuffer::onAddRenderPass ( const RenderPassDesc ,
const Texture colorTexture,
const Texture resolveTexture,
const Texture depthStencilTexture,
SkRect  viewport,
const DrawPassList drawPasses 
)
privatepure virtual

◆ onClearBuffer()

virtual bool skgpu::graphite::CommandBuffer::onClearBuffer ( const Buffer ,
size_t  offset,
size_t  size 
)
privatepure virtual

◆ onCopyBufferToBuffer()

virtual bool skgpu::graphite::CommandBuffer::onCopyBufferToBuffer ( const Buffer srcBuffer,
size_t  srcOffset,
const Buffer dstBuffer,
size_t  dstOffset,
size_t  size 
)
privatepure virtual

◆ onCopyBufferToTexture()

virtual bool skgpu::graphite::CommandBuffer::onCopyBufferToTexture ( const Buffer ,
const Texture ,
const BufferTextureCopyData ,
int  count 
)
privatepure virtual

◆ onCopyTextureToBuffer()

virtual bool skgpu::graphite::CommandBuffer::onCopyTextureToBuffer ( const Texture ,
SkIRect  srcRect,
const Buffer ,
size_t  bufferOffset,
size_t  bufferRowBytes 
)
privatepure virtual

◆ onCopyTextureToTexture()

virtual bool skgpu::graphite::CommandBuffer::onCopyTextureToTexture ( const Texture src,
SkIRect  srcRect,
const Texture dst,
SkIPoint  dstPoint,
int  mipLevel 
)
privatepure virtual

◆ onResetCommandBuffer()

virtual void skgpu::graphite::CommandBuffer::onResetCommandBuffer ( )
privatepure virtual

◆ onSynchronizeBufferToCpu()

virtual bool skgpu::graphite::CommandBuffer::onSynchronizeBufferToCpu ( const Buffer ,
bool *  outDidResultInWork 
)
privatepure virtual

◆ prepareSurfaceForStateUpdate()

virtual void skgpu::graphite::CommandBuffer::prepareSurfaceForStateUpdate ( SkSurface targetSurface,
const MutableTextureState newState 
)
inlinevirtual

Definition at line 70 of file CommandBuffer.h.

71 {}

◆ resetCommandBuffer()

void skgpu::graphite::CommandBuffer::resetCommandBuffer ( )

Definition at line 35 of file CommandBuffer.cpp.

35 {
36 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
37
38 this->releaseResources();
40 fBuffersToAsyncMap.clear();
41}
virtual void onResetCommandBuffer()=0

◆ setNewCommandBufferResources()

virtual bool skgpu::graphite::CommandBuffer::setNewCommandBufferResources ( )
pure virtual

◆ setReplayTranslation()

void skgpu::graphite::CommandBuffer::setReplayTranslation ( SkIVector  translation)
inline

Definition at line 112 of file CommandBuffer.h.

112{ fReplayTranslation = translation; }

◆ synchronizeBufferToCpu()

bool skgpu::graphite::CommandBuffer::synchronizeBufferToCpu ( sk_sp< Buffer buffer)

Definition at line 206 of file CommandBuffer.cpp.

206 {
208
209 bool didResultInWork = false;
210 if (!this->onSynchronizeBufferToCpu(buffer.get(), &didResultInWork)) {
211 return false;
212 }
213
214 if (didResultInWork) {
215 this->trackResource(std::move(buffer));
216 SkDEBUGCODE(fHasWork = true;)
217 }
218
219 return true;
220}
virtual bool onSynchronizeBufferToCpu(const Buffer *, bool *outDidResultInWork)=0

◆ trackCommandBufferResource()

void skgpu::graphite::CommandBuffer::trackCommandBufferResource ( sk_sp< Resource resource)

Definition at line 47 of file CommandBuffer.cpp.

47 {
48 fCommandBufferResources.push_back(std::move(resource));
49}
static SkString resource(SkPDFResourceType type, int index)

◆ trackResource()

void skgpu::graphite::CommandBuffer::trackResource ( sk_sp< Resource resource)

Definition at line 43 of file CommandBuffer.cpp.

43 {
44 fTrackedUsageResources.push_back(std::move(resource));
45}

Member Data Documentation

◆ fRenderPassSize

SkISize skgpu::graphite::CommandBuffer::fRenderPassSize
protected

Definition at line 118 of file CommandBuffer.h.

◆ fReplayTranslation

SkIVector skgpu::graphite::CommandBuffer::fReplayTranslation
protected

Definition at line 119 of file CommandBuffer.h.


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