Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::DawnBuffer Class Reference

#include <DawnBuffer.h>

Inheritance diagram for skgpu::graphite::DawnBuffer:
skgpu::graphite::Buffer skgpu::graphite::Resource

Public Member Functions

bool isUnmappable () const override
 
const wgpu::Buffer & dawnBuffer () const
 
- Public Member Functions inherited from skgpu::graphite::Buffer
size_t size () const
 
void * map ()
 
void asyncMap (GpuFinishedProc=nullptr, GpuFinishedContext=nullptr)
 
void unmap ()
 
bool isMapped () const
 
virtual bool isUnmappable () const
 
const char * getResourceType () const override
 
- 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
 
virtual const char * getResourceType () const =0
 
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< DawnBufferMake (const DawnSharedContext *, size_t size, BufferType type, AccessPattern)
 

Additional Inherited Members

- Protected Member Functions inherited from skgpu::graphite::Buffer
 Buffer (const SharedContext *sharedContext, size_t size, bool commandBufferRefsAsUsageRefs=false)
 
- Protected Member Functions inherited from skgpu::graphite::Resource
 Resource (const SharedContext *, Ownership, skgpu::Budgeted, size_t gpuMemorySize, bool commandBufferRefsAsUsageRefs=false)
 
virtual ~Resource ()
 
const SharedContextsharedContext () const
 
virtual void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const
 
void setDeleteASAP ()
 
- Protected Attributes inherited from skgpu::graphite::Buffer
void * fMapPtr = nullptr
 

Detailed Description

Definition at line 23 of file DawnBuffer.h.

Member Function Documentation

◆ dawnBuffer()

const wgpu::Buffer & skgpu::graphite::DawnBuffer::dawnBuffer ( ) const
inline

Definition at line 32 of file DawnBuffer.h.

32{ return fBuffer; }

◆ isUnmappable()

bool skgpu::graphite::DawnBuffer::isUnmappable ( ) const
overridevirtual

Reimplemented from skgpu::graphite::Buffer.

Definition at line 285 of file DawnBuffer.cpp.

285 {
286 return fBuffer.GetMapState() != wgpu::BufferMapState::Unmapped;
287}

◆ Make()

sk_sp< DawnBuffer > skgpu::graphite::DawnBuffer::Make ( const DawnSharedContext sharedContext,
size_t  size,
BufferType  type,
AccessPattern  accessPattern 
)
static

Definition at line 18 of file DawnBuffer.cpp.

21 {
22 if (size <= 0) {
23 return nullptr;
24 }
25
26 wgpu::BufferUsage usage = wgpu::BufferUsage::None;
27
28 switch (type) {
30 usage = wgpu::BufferUsage::Vertex | wgpu::BufferUsage::CopyDst;
31 break;
33 usage = wgpu::BufferUsage::Index | wgpu::BufferUsage::CopyDst;
34 break;
36 usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::MapWrite;
37 break;
39 usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::MapRead;
40 break;
42 usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst;
43 break;
45 usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst |
46 wgpu::BufferUsage::CopySrc;
47 break;
49 usage = wgpu::BufferUsage::Indirect | wgpu::BufferUsage::Storage |
50 wgpu::BufferUsage::CopyDst;
51 break;
53 usage = wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Storage;
54 break;
56 usage = wgpu::BufferUsage::Index | wgpu::BufferUsage::Storage;
57 break;
58 }
59
61 accessPattern == AccessPattern::kHostVisible &&
63 // If the buffer is intended to be mappabe, add MapWrite usage and remove
64 // CopyDst.
65 // We don't want to allow both CPU and GPU to write to the same buffer.
66 usage |= wgpu::BufferUsage::MapWrite;
67 usage &= ~wgpu::BufferUsage::CopyDst;
68 }
69
70 wgpu::BufferDescriptor desc;
71 desc.usage = usage;
72 desc.size = size;
73 // Specifying mappedAtCreation avoids clearing the buffer on the GPU which can cause MapAsync to
74 // be very slow as it waits for GPU execution to complete.
75 desc.mappedAtCreation = SkToBool(usage & wgpu::BufferUsage::MapWrite);
76
77 auto buffer = sharedContext->device().CreateBuffer(&desc);
78 if (!buffer) {
79 return {};
80 }
81
82 void* mappedAtCreationPtr = nullptr;
83 if (desc.mappedAtCreation) {
84 mappedAtCreationPtr = buffer.GetMappedRange();
85 SkASSERT(mappedAtCreationPtr);
86 }
87
88 return sk_sp<DawnBuffer>(
89 new DawnBuffer(sharedContext, size, std::move(buffer), mappedAtCreationPtr));
90}
GrTriangulator::Vertex Vertex
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkMeshSpecification::Uniform Uniform
Definition: SkMesh.cpp:66
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
GLenum type
size_t size() const
Definition: Buffer.h:19
bool drawBufferCanBeMapped() const
Definition: Caps.h:242
const SharedContext * sharedContext() const
Definition: Resource.h:189
const Caps * caps() const
Definition: SharedContext.h:39
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
VulkanMemoryAllocator::BufferUsage BufferUsage
static void usage(char *argv0)

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