Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
GrOpFlushState Class Referencefinal

#include <GrOpFlushState.h>

Inheritance diagram for GrOpFlushState:
GrDeferredUploadTarget GrMeshDrawTarget

Classes

struct  OpArgs
 

Public Member Functions

 GrOpFlushState (GrGpu *, GrResourceProvider *, skgpu::TokenTracker *, sk_sp< GrBufferAllocPool::CpuBufferCache >=nullptr)
 
 ~GrOpFlushState () final
 
void preExecuteDraws ()
 
void doUpload (GrDeferredTextureUploadFn &, bool shouldPrepareSurfaceForSampling=false)
 
void executeDrawsAndUploadsForMeshDrawOp (const GrOp *op, const SkRect &chainBounds, const GrPipeline *, const GrUserStencilSettings *)
 
GrOpsRenderPassopsRenderPass ()
 
void setOpsRenderPass (GrOpsRenderPass *renderPass)
 
GrGpugpu ()
 
void reset ()
 
void setOpArgs (OpArgs *opArgs)
 
const OpArgsdrawOpArgs () const
 
void setSampledProxyArray (skia_private::TArray< GrSurfaceProxy *, true > *sampledProxies)
 
skia_private::TArray< GrSurfaceProxy *, true > * sampledProxyArray () override
 
const skgpu::TokenTrackertokenTracker () final
 
skgpu::AtlasToken addInlineUpload (GrDeferredTextureUploadFn &&) final
 
skgpu::AtlasToken addASAPUpload (GrDeferredTextureUploadFn &&) final
 
void recordDraw (const GrGeometryProcessor *, const GrSimpleMesh[], int meshCnt, const GrSurfaceProxy *const primProcProxies[], GrPrimitiveType) final
 
void * makeVertexSpace (size_t vertexSize, int vertexCount, sk_sp< const GrBuffer > *, int *startVertex) final
 
uint16_t * makeIndexSpace (int indexCount, sk_sp< const GrBuffer > *, int *startIndex) final
 
void * makeVertexSpaceAtLeast (size_t vertexSize, int minVertexCount, int fallbackVertexCount, sk_sp< const GrBuffer > *, int *startVertex, int *actualVertexCount) final
 
uint16_t * makeIndexSpaceAtLeast (int minIndexCount, int fallbackIndexCount, sk_sp< const GrBuffer > *, int *startIndex, int *actualIndexCount) final
 
GrDrawIndirectWriter makeDrawIndirectSpace (int drawCount, sk_sp< const GrBuffer > *buffer, size_t *offset) override
 
GrDrawIndexedIndirectWriter makeDrawIndexedIndirectSpace (int drawCount, sk_sp< const GrBuffer > *buffer, size_t *offset) override
 
void putBackIndices (int indexCount) final
 
void putBackVertices (int vertices, size_t vertexStride) final
 
void putBackIndirectDraws (int drawCount) final
 
void putBackIndexedIndirectDraws (int drawCount) final
 
const GrSurfaceProxyViewwriteView () const final
 
GrRenderTargetProxyrtProxy () const final
 
bool usesMSAASurface () const final
 
const GrAppliedClipappliedClip () const final
 
const GrAppliedHardClipappliedHardClip () const
 
GrAppliedClip detachAppliedClip () final
 
const GrDstProxyViewdstProxyView () const final
 
GrXferBarrierFlags renderPassBarriers () const final
 
GrLoadOp colorLoadOp () const final
 
GrDeferredUploadTargetdeferredUploadTarget () final
 
const GrCapscaps () const final
 
GrThreadSafeCachethreadSafeCache () const final
 
GrResourceProviderresourceProvider () const final
 
sktext::gpu::StrikeCachestrikeCache () const final
 
GrAtlasManageratlasManager () const final
 
skgpu::ganesh::SmallPathAtlasMgrsmallPathAtlasManager () const final
 
SkArenaAllocallocator () override
 
void bindPipelineAndScissorClip (const GrProgramInfo &programInfo, const SkRect &drawBounds)
 
void bindTextures (const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
 
void drawMesh (const GrSimpleMesh &mesh)
 
void bindPipeline (const GrProgramInfo &programInfo, const SkRect &drawBounds)
 
void setScissorRect (const SkIRect &scissorRect)
 
void bindTextures (const GrGeometryProcessor &geomProc, const GrSurfaceProxy *const geomProcTextures[], const GrPipeline &pipeline)
 
void bindBuffers (sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
 
void draw (int vertexCount, int baseVertex)
 
void drawIndexed (int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex)
 
void drawInstanced (int instanceCount, int baseInstance, int vertexCount, int baseVertex)
 
void drawIndexedInstanced (int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex)
 
void drawIndirect (const GrBuffer *drawIndirectBuffer, size_t offset, int drawCount)
 
void drawIndexedIndirect (const GrBuffer *drawIndirectBuffer, size_t offset, int drawCount)
 
void drawIndexPattern (int patternIndexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, int patternVertexCount, int baseVertex)
 
- Public Member Functions inherited from GrDeferredUploadTarget
virtual ~GrDeferredUploadTarget ()
 
- Public Member Functions inherited from GrMeshDrawTarget
virtual ~GrMeshDrawTarget ()
 
void recordDraw (const GrGeometryProcessor *gp, const GrSimpleMesh meshes[], int meshCnt, GrPrimitiveType primitiveType)
 
skgpu::VertexWriter makeVertexWriter (size_t vertexSize, int vertexCount, sk_sp< const GrBuffer > *, int *startVertex)
 
skgpu::IndexWriter makeIndexWriter (int indexCount, sk_sp< const GrBuffer > *, int *startIndex)
 
skgpu::VertexWriter makeVertexWriterAtLeast (size_t vertexSize, int minVertexCount, int fallbackVertexCount, sk_sp< const GrBuffer > *, int *startVertex, int *actualVertexCount)
 
skgpu::IndexWriter makeIndexWriterAtLeast (int minIndexCount, int fallbackIndexCount, sk_sp< const GrBuffer > *, int *startIndex, int *actualIndexCount)
 
GrSimpleMeshallocMesh ()
 
GrSimpleMeshallocMeshes (int n)
 
const GrSurfaceProxy ** allocPrimProcProxyPtrs (int n)
 
uint32_t contextUniqueID () const
 

Detailed Description

Tracks the state across all the GrOps (really just the GrDrawOps) in a OpsTask flush.

Definition at line 58 of file GrOpFlushState.h.

Constructor & Destructor Documentation

◆ GrOpFlushState()

GrOpFlushState::GrOpFlushState ( GrGpu gpu,
GrResourceProvider resourceProvider,
skgpu::TokenTracker tokenTracker,
sk_sp< GrBufferAllocPool::CpuBufferCache cpuBufferCache = nullptr 
)

Definition at line 31 of file GrOpFlushState.cpp.

34 : fVertexPool(gpu, cpuBufferCache)
35 , fIndexPool(gpu, cpuBufferCache)
36 , fDrawIndirectPool(gpu, std::move(cpuBufferCache))
37 , fGpu(gpu)
38 , fResourceProvider(resourceProvider)
39 , fTokenTracker(tokenTracker) {}
const skgpu::TokenTracker * tokenTracker() final
GrResourceProvider * resourceProvider() const final

◆ ~GrOpFlushState()

GrOpFlushState::~GrOpFlushState ( )
inlinefinal

Definition at line 66 of file GrOpFlushState.h.

66{ this->reset(); }

Member Function Documentation

◆ addASAPUpload()

skgpu::AtlasToken GrOpFlushState::addASAPUpload ( GrDeferredTextureUploadFn &&  upload)
finalvirtual

Returns the token of the draw that this upload will occur before. Since ASAP uploads are done first during a flush, this will be the first token since the most recent flush.

Implements GrDeferredUploadTarget.

Definition at line 157 of file GrOpFlushState.cpp.

157 {
158 fASAPUploads.append(&fArena, std::move(upload));
159 return fTokenTracker->nextFlushToken();
160}
T & append(SkArenaAlloc *arena, Args... args)
AtlasToken nextFlushToken() const
Definition AtlasTypes.h:207

◆ addInlineUpload()

skgpu::AtlasToken GrOpFlushState::addInlineUpload ( GrDeferredTextureUploadFn &&  )
finalvirtual

Returns the token of the draw that this upload will occur before.

Implements GrDeferredUploadTarget.

Definition at line 152 of file GrOpFlushState.cpp.

152 {
153 return fInlineUploads.append(&fArena, std::move(upload), fTokenTracker->nextDrawToken())
154 .fUploadBeforeToken;
155}
AtlasToken nextDrawToken() const
Definition AtlasTypes.h:214

◆ allocator()

SkArenaAlloc * GrOpFlushState::allocator ( )
inlineoverridevirtual

GrMeshDrawTarget override.

Implements GrMeshDrawTarget.

Definition at line 223 of file GrOpFlushState.h.

223{ return &fArena; }

◆ appliedClip()

const GrAppliedClip * GrOpFlushState::appliedClip ( ) const
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 190 of file GrOpFlushState.h.

190{ return this->drawOpArgs().appliedClip(); }
const OpArgs & drawOpArgs() const
GrAppliedClip * appliedClip()

◆ appliedHardClip()

const GrAppliedHardClip & GrOpFlushState::appliedHardClip ( ) const
inline

Definition at line 191 of file GrOpFlushState.h.

191 {
192 return (fOpArgs->appliedClip()) ?
194 }
const GrAppliedHardClip & hardClip() const
static const GrAppliedHardClip & Disabled()

◆ atlasManager()

GrAtlasManager * GrOpFlushState::atlasManager ( ) const
finalvirtual

Implements GrMeshDrawTarget.

Definition at line 228 of file GrOpFlushState.cpp.

228 {
229 return fGpu->getContext()->priv().getAtlasManager();
230}
GrAtlasManager * getAtlasManager()
GrDirectContextPriv priv()
GrDirectContext * getContext()
Definition GrGpu.h:67

◆ bindBuffers()

void GrOpFlushState::bindBuffers ( sk_sp< const GrBuffer indexBuffer,
sk_sp< const GrBuffer instanceBuffer,
sk_sp< const GrBuffer vertexBuffer,
GrPrimitiveRestart  primitiveRestart = GrPrimitiveRestart::kNo 
)
inline

Definition at line 261 of file GrOpFlushState.h.

263 {
264 fOpsRenderPass->bindBuffers(std::move(indexBuffer), std::move(instanceBuffer),
265 std::move(vertexBuffer), primitiveRestart);
266 }
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart=GrPrimitiveRestart::kNo)

◆ bindPipeline()

void GrOpFlushState::bindPipeline ( const GrProgramInfo programInfo,
const SkRect drawBounds 
)
inline

Definition at line 250 of file GrOpFlushState.h.

250 {
251 fOpsRenderPass->bindPipeline(programInfo, drawBounds);
252 }
void bindPipeline(const GrProgramInfo &, const SkRect &drawBounds)

◆ bindPipelineAndScissorClip()

void GrOpFlushState::bindPipelineAndScissorClip ( const GrProgramInfo programInfo,
const SkRect drawBounds 
)
inline

Definition at line 227 of file GrOpFlushState.h.

227 {
228 SkASSERT((programInfo.pipeline().isScissorTestEnabled()) ==
229 (this->appliedClip() && this->appliedClip()->scissorState().enabled()));
230 this->bindPipeline(programInfo, drawBounds);
231 if (programInfo.pipeline().isScissorTestEnabled()) {
232 this->setScissorRect(this->appliedClip()->scissorState().rect());
233 }
234 }
#define SkASSERT(cond)
Definition SkAssert.h:116
void setScissorRect(const SkIRect &scissorRect)
const GrAppliedClip * appliedClip() const final
void bindPipeline(const GrProgramInfo &programInfo, const SkRect &drawBounds)
bool isScissorTestEnabled() const
Definition GrPipeline.h:163
const GrPipeline & pipeline() const
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350

◆ bindTextures() [1/2]

void GrOpFlushState::bindTextures ( const GrGeometryProcessor geomProc,
const GrSurfaceProxy singleGeomProcTexture,
const GrPipeline pipeline 
)
inline

Definition at line 238 of file GrOpFlushState.h.

240 {
241 SkASSERT(geomProc.numTextureSamplers() == 1);
242 const GrSurfaceProxy* ptr = &singleGeomProcTexture;
243 this->bindTextures(geomProc, &ptr, pipeline);
244 }
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)

◆ bindTextures() [2/2]

void GrOpFlushState::bindTextures ( const GrGeometryProcessor geomProc,
const GrSurfaceProxy *const  geomProcTextures[],
const GrPipeline pipeline 
)
inline

Definition at line 256 of file GrOpFlushState.h.

258 {
259 fOpsRenderPass->bindTextures(geomProc, geomProcTextures, pipeline);
260 }
void bindTextures(const GrGeometryProcessor &, const GrSurfaceProxy *const geomProcTextures[], const GrPipeline &)

◆ caps()

const GrCaps & GrOpFlushState::caps ( ) const
finalvirtual

Implements GrMeshDrawTarget.

Definition at line 41 of file GrOpFlushState.cpp.

41 {
42 return *fGpu->caps();
43}
const GrCaps * caps() const
Definition GrGpu.h:73

◆ colorLoadOp()

GrLoadOp GrOpFlushState::colorLoadOp ( ) const
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 204 of file GrOpFlushState.h.

204 {
205 return this->drawOpArgs().colorLoadOp();
206 }
GrLoadOp colorLoadOp() const

◆ deferredUploadTarget()

GrDeferredUploadTarget * GrOpFlushState::deferredUploadTarget ( )
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 208 of file GrOpFlushState.h.

208{ return this; }

◆ detachAppliedClip()

GrAppliedClip GrOpFlushState::detachAppliedClip ( )
finalvirtual

Implements GrMeshDrawTarget.

Definition at line 220 of file GrOpFlushState.cpp.

220 {
221 return fOpArgs->appliedClip() ? std::move(*fOpArgs->appliedClip()) : GrAppliedClip::Disabled();
222}

◆ doUpload()

void GrOpFlushState::doUpload ( GrDeferredTextureUploadFn upload,
bool  shouldPrepareSurfaceForSampling = false 
)

Called to upload data to a texture using the GrDeferredTextureUploadFn. If the uploaded surface needs to be prepared for being sampled in a draw after the upload, the caller should pass in true for shouldPrepareSurfaceForSampling. This feature is needed for Vulkan when doing inline uploads to reset the image layout back to sampled.

Definition at line 110 of file GrOpFlushState.cpp.

111 {
112 GrDeferredTextureUploadWritePixelsFn wp = [this, shouldPrepareSurfaceForSampling](
113 GrTextureProxy* dstProxy,
116 const void* buffer,
117 size_t rowBytes) {
118 GrSurface* dstSurface = dstProxy->peekSurface();
119 if (!fGpu->caps()->surfaceSupportsWritePixels(dstSurface)) {
120 return false;
121 }
123 colorType, dstSurface->backendFormat(), colorType);
124 size_t tightRB = rect.width()*GrColorTypeBytesPerPixel(supportedWrite.fColorType);
125 SkASSERT(rowBytes >= tightRB);
126 std::unique_ptr<char[]> tmpPixels;
127 if (supportedWrite.fColorType != colorType ||
128 (!fGpu->caps()->writePixelsRowBytesSupport() && rowBytes != tightRB)) {
129 tmpPixels.reset(new char[rect.height()*tightRB]);
130 // Use kUnknown to ensure no alpha type conversions or clamping occur.
131 static constexpr auto kAT = kUnknown_SkAlphaType;
132 GrImageInfo srcInfo(colorType, kAT, nullptr, rect.size());
133 GrImageInfo tmpInfo(supportedWrite.fColorType, kAT, nullptr, rect.size());
134 if (!GrConvertPixels( GrPixmap(tmpInfo, tmpPixels.get(), tightRB ),
135 GrCPixmap(srcInfo, buffer, rowBytes))) {
136 return false;
137 }
138 rowBytes = tightRB;
139 buffer = tmpPixels.get();
140 }
141 return this->fGpu->writePixels(dstSurface,
142 rect,
143 colorType,
144 supportedWrite.fColorType,
145 buffer,
146 rowBytes,
147 shouldPrepareSurfaceForSampling);
148 };
149 upload(wp);
150}
bool GrConvertPixels(const GrPixmap &dst, const GrCPixmap &src, bool flipY)
std::function< bool(GrTextureProxy *, SkIRect, GrColorType srcColorType, const void *, size_t rowBytes)> GrDeferredTextureUploadWritePixelsFn
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
GrColorType
@ kUnknown_SkAlphaType
uninitialized
Definition SkAlphaType.h:27
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
virtual SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const =0
bool surfaceSupportsWritePixels(const GrSurface *) const
Definition GrCaps.cpp:305
bool writePixelsRowBytesSupport() const
Definition GrCaps.h:354
bool writePixels(GrSurface *surface, SkIRect rect, GrColorType surfaceColorType, GrColorType srcColorType, const GrMipLevel texels[], int mipLevelCount, bool prepForTexSampling=false)
Definition GrGpu.cpp:461
GrSurface * peekSurface() const
virtual GrBackendFormat backendFormat() const =0
static const uint8_t buffer[]
GrColorType fColorType
Definition GrCaps.h:318

◆ draw()

void GrOpFlushState::draw ( int  vertexCount,
int  baseVertex 
)
inline

Definition at line 267 of file GrOpFlushState.h.

267 {
268 fOpsRenderPass->draw(vertexCount, baseVertex);
269 }
void draw(int vertexCount, int baseVertex)

◆ drawIndexed()

void GrOpFlushState::drawIndexed ( int  indexCount,
int  baseIndex,
uint16_t  minIndexValue,
uint16_t  maxIndexValue,
int  baseVertex 
)
inline

Definition at line 270 of file GrOpFlushState.h.

271 {
272 fOpsRenderPass->drawIndexed(indexCount, baseIndex, minIndexValue, maxIndexValue,
273 baseVertex);
274 }
void drawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex)

◆ drawIndexedIndirect()

void GrOpFlushState::drawIndexedIndirect ( const GrBuffer drawIndirectBuffer,
size_t  offset,
int  drawCount 
)
inline

Definition at line 286 of file GrOpFlushState.h.

286 {
287 fOpsRenderPass->drawIndexedIndirect(drawIndirectBuffer, offset, drawCount);
288 }
void drawIndexedIndirect(const GrBuffer *drawIndirectBuffer, size_t bufferOffset, int drawCount)
Point offset

◆ drawIndexedInstanced()

void GrOpFlushState::drawIndexedInstanced ( int  indexCount,
int  baseIndex,
int  instanceCount,
int  baseInstance,
int  baseVertex 
)
inline

Definition at line 278 of file GrOpFlushState.h.

279 {
280 fOpsRenderPass->drawIndexedInstanced(indexCount, baseIndex, instanceCount, baseInstance,
281 baseVertex);
282 }
void drawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex)

◆ drawIndexPattern()

void GrOpFlushState::drawIndexPattern ( int  patternIndexCount,
int  patternRepeatCount,
int  maxPatternRepetitionsInIndexBuffer,
int  patternVertexCount,
int  baseVertex 
)
inline

Definition at line 289 of file GrOpFlushState.h.

291 {
292 fOpsRenderPass->drawIndexPattern(patternIndexCount, patternRepeatCount,
293 maxPatternRepetitionsInIndexBuffer, patternVertexCount,
294 baseVertex);
295 }
void drawIndexPattern(int patternIndexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, int patternVertexCount, int baseVertex)

◆ drawIndirect()

void GrOpFlushState::drawIndirect ( const GrBuffer drawIndirectBuffer,
size_t  offset,
int  drawCount 
)
inline

Definition at line 283 of file GrOpFlushState.h.

283 {
284 fOpsRenderPass->drawIndirect(drawIndirectBuffer, offset, drawCount);
285 }
void drawIndirect(const GrBuffer *drawIndirectBuffer, size_t bufferOffset, int drawCount)

◆ drawInstanced()

void GrOpFlushState::drawInstanced ( int  instanceCount,
int  baseInstance,
int  vertexCount,
int  baseVertex 
)
inline

Definition at line 275 of file GrOpFlushState.h.

275 {
276 fOpsRenderPass->drawInstanced(instanceCount, baseInstance, vertexCount, baseVertex);
277 }
void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex)

◆ drawMesh()

void GrOpFlushState::drawMesh ( const GrSimpleMesh mesh)

Definition at line 238 of file GrOpFlushState.cpp.

238 {
239 SkASSERT(mesh.fIsInitialized);
240 if (!mesh.fIndexBuffer) {
241 this->bindBuffers(nullptr, nullptr, mesh.fVertexBuffer);
242 this->draw(mesh.fVertexCount, mesh.fBaseVertex);
243 } else {
244 this->bindBuffers(mesh.fIndexBuffer, nullptr, mesh.fVertexBuffer, mesh.fPrimitiveRestart);
245 if (0 == mesh.fPatternRepeatCount) {
246 this->drawIndexed(mesh.fIndexCount, mesh.fBaseIndex, mesh.fMinIndexValue,
247 mesh.fMaxIndexValue, mesh.fBaseVertex);
248 } else {
249 this->drawIndexPattern(mesh.fIndexCount, mesh.fPatternRepeatCount,
250 mesh.fMaxPatternRepetitionsInIndexBuffer, mesh.fVertexCount,
251 mesh.fBaseVertex);
252 }
253 }
254}
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
void drawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex)
void draw(int vertexCount, int baseVertex)
void drawIndexPattern(int patternIndexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, int patternVertexCount, int baseVertex)
SkMesh mesh
Definition SkRecords.h:345
sk_sp< const GrBuffer > fIndexBuffer
sk_sp< const GrBuffer > fVertexBuffer

◆ drawOpArgs()

const OpArgs & GrOpFlushState::drawOpArgs ( ) const
inline

Definition at line 137 of file GrOpFlushState.h.

137 {
138 SkASSERT(fOpArgs);
139 SkDEBUGCODE(fOpArgs->validate());
140 return *fOpArgs;
141 }
#define SkDEBUGCODE(...)
Definition SkDebug.h:23

◆ dstProxyView()

const GrDstProxyView & GrOpFlushState::dstProxyView ( ) const
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 196 of file GrOpFlushState.h.

196 {
197 return this->drawOpArgs().dstProxyView();
198 }
const GrDstProxyView & dstProxyView() const

◆ executeDrawsAndUploadsForMeshDrawOp()

void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp ( const GrOp op,
const SkRect chainBounds,
const GrPipeline pipeline,
const GrUserStencilSettings userStencilSettings 
)

Called as ops are executed. Must be called in the same order as the ops were prepared.

Definition at line 49 of file GrOpFlushState.cpp.

51 {
52 SkASSERT(this->opsRenderPass());
53
54 while (fCurrDraw != fDraws.end() && fCurrDraw->fOp == op) {
55 skgpu::AtlasToken drawToken = fTokenTracker->nextFlushToken();
56 while (fCurrUpload != fInlineUploads.end() &&
57 fCurrUpload->fUploadBeforeToken == drawToken) {
58 this->opsRenderPass()->inlineUpload(this, fCurrUpload->fUpload);
59 ++fCurrUpload;
60 }
61
62 GrProgramInfo programInfo(this->caps(),
63 this->writeView(),
64 this->usesMSAASurface(),
65 pipeline,
66 userStencilSettings,
67 fCurrDraw->fGeometryProcessor,
68 fCurrDraw->fPrimitiveType,
69 this->renderPassBarriers(),
70 this->colorLoadOp());
71
72 this->bindPipelineAndScissorClip(programInfo, chainBounds);
73 this->bindTextures(programInfo.geomProc(), fCurrDraw->fGeomProcProxies,
74 programInfo.pipeline());
75 for (int i = 0; i < fCurrDraw->fMeshCnt; ++i) {
76 this->drawMesh(fCurrDraw->fMeshes[i]);
77 }
78
79 fTokenTracker->issueFlushToken();
80 ++fCurrDraw;
81 }
82}
void drawMesh(const GrSimpleMesh &mesh)
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
const GrSurfaceProxyView & writeView() const final
const GrCaps & caps() const final
GrOpsRenderPass * opsRenderPass()
bool usesMSAASurface() const final
virtual void inlineUpload(GrOpFlushState *, GrDeferredTextureUploadFn &)=0

◆ gpu()

GrGpu * GrOpFlushState::gpu ( )
inline

Definition at line 85 of file GrOpFlushState.h.

85{ return fGpu; }

◆ makeDrawIndexedIndirectSpace()

GrDrawIndexedIndirectWriter GrOpFlushState::makeDrawIndexedIndirectSpace ( int  drawCount,
sk_sp< const GrBuffer > *  ,
size_t *  offsetInBytes 
)
inlineoverridevirtual

Makes space for elements in a draw-indexed-indirect buffer. Upon success, the returned pointer is a CPU mapping where the data should be written.

Implements GrMeshDrawTarget.

Definition at line 176 of file GrOpFlushState.h.

178 {
179 return fDrawIndirectPool.makeIndexedSpace(drawCount, buffer, offset);
180 }
GrDrawIndexedIndirectWriter makeIndexedSpace(int drawCount, sk_sp< const GrBuffer > *buffer, size_t *offset)

◆ makeDrawIndirectSpace()

GrDrawIndirectWriter GrOpFlushState::makeDrawIndirectSpace ( int  drawCount,
sk_sp< const GrBuffer > *  buffer,
size_t *  offsetInBytes 
)
inlineoverridevirtual

Makes space for elements in a draw-indirect buffer. Upon success, the returned pointer is a CPU mapping where the data should be written.

Implements GrMeshDrawTarget.

Definition at line 172 of file GrOpFlushState.h.

173 {
174 return fDrawIndirectPool.makeSpace(drawCount, buffer, offset);
175 }
GrDrawIndirectWriter makeSpace(int drawCount, sk_sp< const GrBuffer > *buffer, size_t *offset)

◆ makeIndexSpace()

uint16_t * GrOpFlushState::makeIndexSpace ( int  indexCount,
sk_sp< const GrBuffer > *  ,
int startIndex 
)
finalvirtual

Makes space for index data. The returned pointer is the location where index data should be written. On return the buffer that will hold the data as well as an offset into the buffer (in uint16_t units) where the data will be placed.

Implements GrMeshDrawTarget.

Definition at line 193 of file GrOpFlushState.cpp.

194 {
195 return reinterpret_cast<uint16_t*>(fIndexPool.makeSpace(indexCount, buffer, startIndex));
196}
void * makeSpace(int indexCount, sk_sp< const GrBuffer > *buffer, int *startIndex)

◆ makeIndexSpaceAtLeast()

uint16_t * GrOpFlushState::makeIndexSpaceAtLeast ( int  minIndexCount,
int  fallbackIndexCount,
sk_sp< const GrBuffer > *  ,
int startIndex,
int actualIndexCount 
)
finalvirtual

This is similar to makeIndexSpace. It allows the caller to use up to 'actualIndexCount' indices in the returned pointer, which may exceed 'minIndexCount'. 'fallbackIndexCount' is the maximum number of indices that should be allocated if a new buffer is allocated on behalf of this request.

Implements GrMeshDrawTarget.

Definition at line 205 of file GrOpFlushState.cpp.

207 {
208 return reinterpret_cast<uint16_t*>(fIndexPool.makeSpaceAtLeast(
209 minIndexCount, fallbackIndexCount, buffer, startIndex, actualIndexCount));
210}
void * makeSpaceAtLeast(int minIndexCount, int fallbackIndexCount, sk_sp< const GrBuffer > *buffer, int *startIndex, int *actualIndexCount)

◆ makeVertexSpace()

void * GrOpFlushState::makeVertexSpace ( size_t  vertexSize,
int  vertexCount,
sk_sp< const GrBuffer > *  ,
int startVertex 
)
finalvirtual

Makes space for vertex data. The returned pointer is the location where vertex data should be written. On return the buffer that will hold the data as well as an offset into the buffer (in 'vertexSize' units) where the data will be placed.

Implements GrMeshDrawTarget.

Definition at line 188 of file GrOpFlushState.cpp.

189 {
190 return fVertexPool.makeSpace(vertexSize, vertexCount, buffer, startVertex);
191}
void * makeSpace(size_t vertexSize, int vertexCount, sk_sp< const GrBuffer > *buffer, int *startVertex)

◆ makeVertexSpaceAtLeast()

void * GrOpFlushState::makeVertexSpaceAtLeast ( size_t  vertexSize,
int  minVertexCount,
int  fallbackVertexCount,
sk_sp< const GrBuffer > *  ,
int startVertex,
int actualVertexCount 
)
finalvirtual

This is similar to makeVertexSpace. It allows the caller to use up to 'actualVertexCount' vertices in the returned pointer, which may exceed 'minVertexCount'. 'fallbackVertexCount' is the maximum number of vertices that should be allocated if a new buffer is allocated on behalf of this request.

Implements GrMeshDrawTarget.

Definition at line 198 of file GrOpFlushState.cpp.

200 {
201 return fVertexPool.makeSpaceAtLeast(vertexSize, minVertexCount, fallbackVertexCount, buffer,
202 startVertex, actualVertexCount);
203}
void * makeSpaceAtLeast(size_t vertexSize, int minVertexCount, int fallbackVertexCount, sk_sp< const GrBuffer > *buffer, int *startVertex, int *actualVertexCount)

◆ opsRenderPass()

GrOpsRenderPass * GrOpFlushState::opsRenderPass ( )
inline

Definition at line 82 of file GrOpFlushState.h.

82{ return fOpsRenderPass; }

◆ preExecuteDraws()

void GrOpFlushState::preExecuteDraws ( )

This is called after each op has a chance to prepare its draws and before the draws are executed.

Definition at line 84 of file GrOpFlushState.cpp.

84 {
85 fVertexPool.unmap();
86 fIndexPool.unmap();
87 fDrawIndirectPool.unmap();
88 for (auto& upload : fASAPUploads) {
89 this->doUpload(upload);
90 }
91 // Setup execution iterators.
92 fCurrDraw = fDraws.begin();
93 fCurrUpload = fInlineUploads.begin();
94 fGpu->willExecute();
95}
virtual void willExecute()
Definition GrGpu.h:413
void doUpload(GrDeferredTextureUploadFn &, bool shouldPrepareSurfaceForSampling=false)

◆ putBackIndexedIndirectDraws()

void GrOpFlushState::putBackIndexedIndirectDraws ( int  drawCount)
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 184 of file GrOpFlushState.h.

184 {
185 fDrawIndirectPool.putBackIndexed(drawCount);
186 }

◆ putBackIndices()

void GrOpFlushState::putBackIndices ( int  indices)
finalvirtual

Helpers for ops which over-allocate and then return excess data to the pool.

Implements GrMeshDrawTarget.

Definition at line 212 of file GrOpFlushState.cpp.

212 {
213 fIndexPool.putBack(indexCount * sizeof(uint16_t));
214}
void putBack(size_t bytes)

◆ putBackIndirectDraws()

void GrOpFlushState::putBackIndirectDraws ( int  drawCount)
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 183 of file GrOpFlushState.h.

183{ fDrawIndirectPool.putBack(drawCount); }

◆ putBackVertices()

void GrOpFlushState::putBackVertices ( int  vertices,
size_t  vertexStride 
)
finalvirtual

Implements GrMeshDrawTarget.

Definition at line 216 of file GrOpFlushState.cpp.

216 {
217 fVertexPool.putBack(vertices * vertexStride);
218}

◆ recordDraw()

void GrOpFlushState::recordDraw ( const GrGeometryProcessor geomProc,
const GrSimpleMesh  meshes[],
int  meshCnt,
const GrSurfaceProxy *const  primProcProxies[],
GrPrimitiveType  primitiveType 
)
finalvirtual

Overrides of GrMeshDrawTarget.

Implements GrMeshDrawTarget.

Definition at line 162 of file GrOpFlushState.cpp.

167 {
168 SkASSERT(fOpArgs);
169 SkDEBUGCODE(fOpArgs->validate());
170 bool firstDraw = fDraws.begin() == fDraws.end();
171 auto& draw = fDraws.append(&fArena);
172 skgpu::AtlasToken token = fTokenTracker->issueDrawToken();
173 for (int i = 0; i < geomProc->numTextureSamplers(); ++i) {
174 SkASSERT(geomProcProxies && geomProcProxies[i]);
175 geomProcProxies[i]->ref();
176 }
177 draw.fGeometryProcessor = geomProc;
178 draw.fGeomProcProxies = geomProcProxies;
179 draw.fMeshes = meshes;
180 draw.fMeshCnt = meshCnt;
181 draw.fOp = fOpArgs->op();
182 draw.fPrimitiveType = primitiveType;
183 if (firstDraw) {
184 fBaseDrawToken = token;
185 }
186}

◆ renderPassBarriers()

GrXferBarrierFlags GrOpFlushState::renderPassBarriers ( ) const
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 200 of file GrOpFlushState.h.

200 {
201 return this->drawOpArgs().renderPassBarriers();
202 }
GrXferBarrierFlags renderPassBarriers() const

◆ reset()

void GrOpFlushState::reset ( )

Definition at line 97 of file GrOpFlushState.cpp.

97 {
98 SkASSERT(fCurrDraw == fDraws.end());
99 SkASSERT(fCurrUpload == fInlineUploads.end());
100 fVertexPool.reset();
101 fIndexPool.reset();
102 fDrawIndirectPool.reset();
103 fArena.reset();
104 fASAPUploads.reset();
105 fInlineUploads.reset();
106 fDraws.reset();
107 fBaseDrawToken = skgpu::AtlasToken::InvalidToken();
108}
static AtlasToken InvalidToken()
Definition AtlasTypes.h:153

◆ resourceProvider()

GrResourceProvider * GrOpFlushState::resourceProvider ( ) const
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 211 of file GrOpFlushState.h.

211{ return fResourceProvider; }

◆ rtProxy()

GrRenderTargetProxy * GrOpFlushState::rtProxy ( ) const
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 188 of file GrOpFlushState.h.

188{ return this->drawOpArgs().rtProxy(); }
GrRenderTargetProxy * rtProxy() const

◆ sampledProxyArray()

skia_private::TArray< GrSurfaceProxy *, true > * GrOpFlushState::sampledProxyArray ( )
inlineoverridevirtual

Implements GrMeshDrawTarget.

Definition at line 147 of file GrOpFlushState.h.

147 {
148 return fSampledProxies;
149 }

◆ setOpArgs()

void GrOpFlushState::setOpArgs ( OpArgs opArgs)
inline

Definition at line 135 of file GrOpFlushState.h.

135{ fOpArgs = opArgs; }

◆ setOpsRenderPass()

void GrOpFlushState::setOpsRenderPass ( GrOpsRenderPass renderPass)
inline

Definition at line 83 of file GrOpFlushState.h.

83{ fOpsRenderPass = renderPass; }

◆ setSampledProxyArray()

void GrOpFlushState::setSampledProxyArray ( skia_private::TArray< GrSurfaceProxy *, true > *  sampledProxies)
inline

Definition at line 143 of file GrOpFlushState.h.

143 {
144 fSampledProxies = sampledProxies;
145 }

◆ setScissorRect()

void GrOpFlushState::setScissorRect ( const SkIRect scissorRect)
inline

Definition at line 253 of file GrOpFlushState.h.

253 {
254 fOpsRenderPass->setScissorRect(scissorRect);
255 }
void setScissorRect(const SkIRect &)

◆ smallPathAtlasManager()

skgpu::ganesh::SmallPathAtlasMgr * GrOpFlushState::smallPathAtlasManager ( ) const
finalvirtual

Implements GrMeshDrawTarget.

Definition at line 233 of file GrOpFlushState.cpp.

233 {
234 return fGpu->getContext()->priv().getSmallPathAtlasMgr();
235}
skgpu::ganesh::SmallPathAtlasMgr * getSmallPathAtlasMgr()

◆ strikeCache()

sktext::gpu::StrikeCache * GrOpFlushState::strikeCache ( ) const
finalvirtual

Implements GrMeshDrawTarget.

Definition at line 224 of file GrOpFlushState.cpp.

224 {
225 return fGpu->getContext()->priv().getStrikeCache();
226}
sktext::gpu::StrikeCache * getStrikeCache()

◆ threadSafeCache()

GrThreadSafeCache * GrOpFlushState::threadSafeCache ( ) const
finalvirtual

Implements GrMeshDrawTarget.

Definition at line 45 of file GrOpFlushState.cpp.

45 {
46 return fGpu->getContext()->priv().threadSafeCache();
47}
GrThreadSafeCache * threadSafeCache()

◆ tokenTracker()

const skgpu::TokenTracker * GrOpFlushState::tokenTracker ( )
inlinefinalvirtual

Overrides of GrDeferredUploadTarget.

Implements GrDeferredUploadTarget.

Definition at line 153 of file GrOpFlushState.h.

153{ return fTokenTracker; }

◆ usesMSAASurface()

bool GrOpFlushState::usesMSAASurface ( ) const
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 189 of file GrOpFlushState.h.

189{ return this->drawOpArgs().usesMSAASurface(); }

◆ writeView()

const GrSurfaceProxyView & GrOpFlushState::writeView ( ) const
inlinefinalvirtual

Implements GrMeshDrawTarget.

Definition at line 187 of file GrOpFlushState.h.

187{ return this->drawOpArgs().writeView(); }
const GrSurfaceProxyView & writeView() const

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