Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
skgpu::graphite::DrawWriter::DynamicInstances< VertexCountProxy > Class Template Reference

#include <DrawWriter.h>

Inheritance diagram for skgpu::graphite::DrawWriter::DynamicInstances< VertexCountProxy >:
skgpu::graphite::DrawWriter::Appender

Public Member Functions

 DynamicInstances (DrawWriter &w, BindBufferInfo vertices, BindBufferInfo indices)
 
 ~DynamicInstances () override
 
template<typename V >
VertexWriter append (const V &vertexCount, unsigned int instanceCount)
 
void reserve (unsigned int count)
 

Private Member Functions

void onFlush () override
 

Detailed Description

template<typename VertexCountProxy>
class skgpu::graphite::DrawWriter::DynamicInstances< VertexCountProxy >

Definition at line 347 of file DrawWriter.h.

Constructor & Destructor Documentation

◆ DynamicInstances()

template<typename VertexCountProxy >
skgpu::graphite::DrawWriter::DynamicInstances< VertexCountProxy >::DynamicInstances ( DrawWriter w,
BindBufferInfo  vertices,
BindBufferInfo  indices 
)
inline

Definition at line 349 of file DrawWriter.h.

352 : Appender(w, Target::kInstances) {
353 w.setTemplate(vertices, indices, w.fInstances, -1);
354 }
SkScalar w

◆ ~DynamicInstances()

template<typename VertexCountProxy >
skgpu::graphite::DrawWriter::DynamicInstances< VertexCountProxy >::~DynamicInstances ( )
inlineoverride

Definition at line 356 of file DrawWriter.h.

356 {
357 // Persist the template count since the DrawWriter could continue batching if a new
358 // compatible DynamicInstances object is created for the next draw.
359 this->updateTemplateCount();
360 }

Member Function Documentation

◆ append()

template<typename VertexCountProxy >
template<typename V >
VertexWriter skgpu::graphite::DrawWriter::DynamicInstances< VertexCountProxy >::append ( const V vertexCount,
unsigned int  instanceCount 
)
inline

Definition at line 365 of file DrawWriter.h.

365 {
366 VertexWriter w = this->Appender::append(instanceCount);
367 // Record index count after appending instance data in case the append triggered a flush
368 // and the max index count is reset. However, the contents of 'w' will not have been flushed
369 // so 'fProxy' will account for 'vertexCount' when it is actually drawn.
370 fProxy << vertexCount;
371 return w;
372 }
VertexWriter append(unsigned int count)
Definition DrawWriter.h:301

◆ onFlush()

template<typename VertexCountProxy >
void skgpu::graphite::DrawWriter::DynamicInstances< VertexCountProxy >::onFlush ( )
inlineoverrideprivatevirtual

Reimplemented from skgpu::graphite::DrawWriter::Appender.

Definition at line 383 of file DrawWriter.h.

383 {
384 // Update the DrawWriter's template count before its flush() is invoked and the appender
385 // starts recording to a new buffer, which ensures the flush's draw call uses the most
386 // up-to-date vertex count derived from fProxy.
387 this->updateTemplateCount();
388 }

◆ reserve()

template<typename VertexCountProxy >
void skgpu::graphite::DrawWriter::Appender::reserve ( unsigned int  count)
inline

Definition at line 274 of file DrawWriter.h.

274 {
275 if (fReservedCount >= count) {
276 return;
277 } else if (fReservedCount > 0) {
278 // Have contiguous bytes that can't satisfy request, so return them in the event the
279 // DBM has additional contiguous bytes after the prior reserved range.
281 }
282
284 // NOTE: Cannot bind tuple directly to fNextWriter, compilers don't produce the right
285 // move assignment.
286 auto [writer, reservedChunk] = fDrawer.fManager->getVertexWriter(count * fStride);
287 if (reservedChunk.fBuffer != fTarget.fBuffer ||
288 reservedChunk.fOffset !=
289 (fTarget.fOffset + (fDrawer.fPendingBase + fDrawer.fPendingCount) * fStride)) {
290 // Not contiguous, so flush and update binding to 'reservedChunk'
291 this->onFlush();
292 fDrawer.flush();
293
294 fTarget = reservedChunk;
295 fDrawer.fPendingBase = 0;
296 fDrawer.fPendingBufferBinds = true;
297 }
298 fNextWriter = std::move(writer);
299 }
int count
std::pair< VertexWriter, BindBufferInfo > getVertexWriter(size_t requiredBytes)
void returnVertexBytes(size_t unusedBytes)

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