Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
skgpu::graphite::ScratchBuffer Class Referencefinal

#include <BufferManager.h>

Public Member Functions

 ScratchBuffer ()=default
 
 ~ScratchBuffer ()
 
 ScratchBuffer (const ScratchBuffer &)=delete
 
ScratchBufferoperator= (const ScratchBuffer &)=delete
 
 ScratchBuffer (ScratchBuffer &&)=default
 
ScratchBufferoperator= (ScratchBuffer &&)=default
 
bool isValid () const
 
 operator bool ()
 
size_t size () const
 
BindBufferInfo suballocate (size_t requiredBytes)
 
void returnToPool ()
 

Friends

class DrawBufferManager
 

Detailed Description

ScratchBuffer represents a GPU buffer object that is allowed to be reused across strictly sequential tasks within a Recording. It can be used to sub-allocate multiple bindings. When a ScratchBuffer gets deallocated, the underlying GPU buffer gets returned to the originating DrawBufferManager for reuse.

Definition at line 38 of file BufferManager.h.

Constructor & Destructor Documentation

◆ ScratchBuffer() [1/3]

skgpu::graphite::ScratchBuffer::ScratchBuffer ( )
default

◆ ~ScratchBuffer()

skgpu::graphite::ScratchBuffer::~ScratchBuffer ( )

Definition at line 90 of file BufferManager.cpp.

◆ ScratchBuffer() [2/3]

skgpu::graphite::ScratchBuffer::ScratchBuffer ( const ScratchBuffer )
delete

◆ ScratchBuffer() [3/3]

skgpu::graphite::ScratchBuffer::ScratchBuffer ( ScratchBuffer &&  )
default

Member Function Documentation

◆ isValid()

bool skgpu::graphite::ScratchBuffer::isValid ( ) const
inline

Definition at line 57 of file BufferManager.h.

57{ return static_cast<bool>(fBuffer); }

◆ operator bool()

skgpu::graphite::ScratchBuffer::operator bool ( )
inlineexplicit

Definition at line 60 of file BufferManager.h.

60{ return this->isValid(); }

◆ operator=() [1/2]

ScratchBuffer & skgpu::graphite::ScratchBuffer::operator= ( const ScratchBuffer )
delete

◆ operator=() [2/2]

ScratchBuffer & skgpu::graphite::ScratchBuffer::operator= ( ScratchBuffer &&  )
default

◆ returnToPool()

void skgpu::graphite::ScratchBuffer::returnToPool ( )

Definition at line 104 of file BufferManager.cpp.

104 {
105 if (fOwner && fBuffer) {
106 // TODO: Generalize the pool to other buffer types.
107 fOwner->fReusableScratchStorageBuffers.push_back(std::move(fBuffer));
108 SkASSERT(!fBuffer);
109 }
110}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ size()

size_t skgpu::graphite::ScratchBuffer::size ( ) const
inline

Definition at line 66 of file BufferManager.h.

66{ return fSize; }

◆ suballocate()

BindBufferInfo skgpu::graphite::ScratchBuffer::suballocate ( size_t  requiredBytes)

Definition at line 92 of file BufferManager.cpp.

92 {
93 if (!this->isValid()) {
94 return {};
95 }
96 if (!can_fit(requiredBytes, fBuffer->size(), fOffset, fAlignment)) {
97 return {};
98 }
99 const size_t offset = SkAlignTo(fOffset, fAlignment);
100 fOffset = offset + requiredBytes;
101 return {fBuffer.get(), offset};
102}
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
Definition SkAlign.h:33
Point offset

Friends And Related Symbol Documentation

◆ DrawBufferManager

friend class DrawBufferManager
friend

Definition at line 81 of file BufferManager.h.


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