Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GrD3DBuffer Class Reference

#include <GrD3DBuffer.h>

Inheritance diagram for GrD3DBuffer:
GrGpuBuffer GrGpuResource GrBuffer GrIORef< GrGpuResource > SkNoncopyable

Public Member Functions

 ~GrD3DBuffer () override
 
ID3D12Resource * d3dResource () const
 
void setResourceState (const GrD3DGpu *gpu, D3D12_RESOURCE_STATES newResourceState)
 
- Public Member Functions inherited from GrGpuBuffer
GrAccessPattern accessPattern () const
 
size_t size () const final
 
void ref () const final
 
void unref () const final
 
void * map ()
 
void unmap ()
 
bool isMapped () const
 
bool isCpuBuffer () const final
 
bool clearToZero ()
 
bool updateData (const void *src, size_t offset, size_t size, bool preserve)
 
GrGpuBufferType intendedType () const
 
- Public Member Functions inherited from GrGpuResource
bool wasDestroyed () const
 
const GrDirectContextgetContext () const
 
GrDirectContextgetContext ()
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
const skgpu::UniqueKeygetUniqueKey () const
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
CacheAccess cacheAccess ()
 
const CacheAccess cacheAccess () const
 
ProxyAccess proxyAccess ()
 
ResourcePriv resourcePriv ()
 
const ResourcePriv resourcePriv () const
 
virtual void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual const char * getResourceType () const =0
 
- Public Member Functions inherited from GrIORef< GrGpuResource >
bool unique () const
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 
- Public Member Functions inherited from GrBuffer
 GrBuffer (const GrBuffer &)=delete
 
GrBufferoperator= (const GrBuffer &)=delete
 
virtual ~GrBuffer ()=default
 
virtual void ref () const =0
 
virtual void unref () const =0
 
virtual size_t size () const =0
 
virtual bool isCpuBuffer () const =0
 

Static Public Member Functions

static sk_sp< GrD3DBufferMake (GrD3DGpu *, size_t size, GrGpuBufferType, GrAccessPattern)
 
- Static Public Member Functions inherited from GrGpuBuffer
static void ComputeScratchKeyForDynamicBuffer (size_t size, GrGpuBufferType, skgpu::ScratchKey *)
 
- Static Public Member Functions inherited from GrGpuResource
static uint32_t CreateUniqueID ()
 

Protected Member Functions

 GrD3DBuffer (GrD3DGpu *, size_t size, GrGpuBufferType, GrAccessPattern, gr_cp< ID3D12Resource >, sk_sp< GrD3DAlloc >, D3D12_RESOURCE_STATES, std::string_view label)
 
void onAbandon () override
 
void onRelease () override
 
- Protected Member Functions inherited from GrGpuBuffer
 GrGpuBuffer (GrGpu *, size_t sizeInBytes, GrGpuBufferType, GrAccessPattern, std::string_view label)
 
- Protected Member Functions inherited from GrGpuResource
void registerWithCache (skgpu::Budgeted)
 
void registerWithCacheWrapped (GrWrapCacheable)
 
 GrGpuResource (GrGpu *, std::string_view label)
 
virtual ~GrGpuResource ()
 
GrGpugetGpu () const
 
virtual void onRelease ()
 
virtual void onAbandon ()
 
virtual void setMemoryBacking (SkTraceMemoryDump *, const SkString &) const
 
SkString getResourceName () const
 
void dumpMemoryStatisticsPriv (SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
 
- Protected Member Functions inherited from GrIORef< GrGpuResource >
 GrIORef ()
 
bool internalHasRef () const
 
bool internalHasNoCommandBufferUsages () const
 
void addInitialRef () const
 
- Protected Member Functions inherited from GrBuffer
 GrBuffer ()=default
 

Protected Attributes

D3D12_RESOURCE_STATES fResourceState
 
- Protected Attributes inherited from GrGpuBuffer
void * fMapPtr
 

Additional Inherited Members

- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 
- Protected Types inherited from GrGpuBuffer
enum class  MapType { kRead , kWriteDiscard }
 

Detailed Description

Definition at line 18 of file GrD3DBuffer.h.

Constructor & Destructor Documentation

◆ ~GrD3DBuffer()

GrD3DBuffer::~GrD3DBuffer ( )
inlineoverride

Definition at line 22 of file GrD3DBuffer.h.

22{}

◆ GrD3DBuffer()

GrD3DBuffer::GrD3DBuffer ( GrD3DGpu gpu,
size_t  size,
GrGpuBufferType  intendedType,
GrAccessPattern  accessPattern,
gr_cp< ID3D12Resource >  bufferResource,
sk_sp< GrD3DAlloc alloc,
D3D12_RESOURCE_STATES  resourceState,
std::string_view  label 
)
protected

Definition at line 82 of file GrD3DBuffer.cpp.

87 : INHERITED(gpu, size, intendedType, accessPattern, label)
88 , fResourceState(resourceState)
89 , fD3DResource(std::move(bufferResource))
90 , fAlloc(std::move(alloc)) {
92
93 // TODO: persistently map UPLOAD resources?
94
95 VALIDATE();
96}
#define VALIDATE()
Definition: GrD3DBuffer.cpp:16
D3D12_RESOURCE_STATES fResourceState
Definition: GrD3DBuffer.h:38
size_t size() const final
Definition: GrGpuBuffer.h:34
GrGpuBufferType intendedType() const
Definition: GrGpuBuffer.h:99
GrAccessPattern accessPattern() const
Definition: GrGpuBuffer.h:32
void registerWithCache(skgpu::Budgeted)

Member Function Documentation

◆ d3dResource()

ID3D12Resource * GrD3DBuffer::d3dResource ( ) const
inline

Definition at line 24 of file GrD3DBuffer.h.

24 {
25 SkASSERT(fD3DResource);
26 return fD3DResource.get();
27 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
T * get() const
Definition: GrD3DTypes.h:108

◆ Make()

sk_sp< GrD3DBuffer > GrD3DBuffer::Make ( GrD3DGpu gpu,
size_t  size,
GrGpuBufferType  intendedType,
GrAccessPattern  accessPattern 
)
static

Definition at line 64 of file GrD3DBuffer.cpp.

65 {
67 D3D12_RESOURCE_STATES resourceState;
68
71 &resourceState, &alloc);
72 if (!resource) {
73 return nullptr;
74 }
75
77 std::move(resource), std::move(alloc),
78 resourceState,
79 /*label=*/"MakeD3DBuffer"));
80}
static gr_cp< ID3D12Resource > make_d3d_buffer(GrD3DGpu *gpu, size_t size, GrGpuBufferType intendedType, GrAccessPattern accessPattern, D3D12_RESOURCE_STATES *resourceState, sk_sp< GrD3DAlloc > *alloc)
Definition: GrD3DBuffer.cpp:19
@ kStatic_GrAccessPattern
Definition: GrTypesPriv.h:428
static SkString resource(SkPDFResourceType type, int index)
GrD3DBuffer(GrD3DGpu *, size_t size, GrGpuBufferType, GrAccessPattern, gr_cp< ID3D12Resource >, sk_sp< GrD3DAlloc >, D3D12_RESOURCE_STATES, std::string_view label)
Definition: GrD3DBuffer.cpp:82
bool protectedContext() const
Definition: GrD3DGpu.h:55

◆ onAbandon()

void GrD3DBuffer::onAbandon ( )
overrideprotectedvirtual

Overridden to abandon any internal handles, ptrs, etc to backend API resources. This may be called when the underlying 3D context is no longer valid and so no backend API calls should be made.

Reimplemented from GrGpuResource.

Definition at line 138 of file GrD3DBuffer.cpp.

138 {
139 this->releaseResource();
140 this->INHERITED::onAbandon();
141}
virtual void onAbandon()

◆ onRelease()

void GrD3DBuffer::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Definition at line 133 of file GrD3DBuffer.cpp.

133 {
134 this->releaseResource();
135 this->INHERITED::onRelease();
136}
virtual void onRelease()

◆ setResourceState()

void GrD3DBuffer::setResourceState ( const GrD3DGpu gpu,
D3D12_RESOURCE_STATES  newResourceState 
)

Definition at line 98 of file GrD3DBuffer.cpp.

99 {
100 if (newResourceState == fResourceState ||
101 // GENERIC_READ encapsulates a lot of different read states
102 (fResourceState == D3D12_RESOURCE_STATE_GENERIC_READ &&
103 SkToBool(newResourceState | fResourceState))) {
104 return;
105 }
106
107 D3D12_RESOURCE_TRANSITION_BARRIER barrier = {};
108 barrier.pResource = this->d3dResource();
109 barrier.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
110 barrier.StateBefore = fResourceState;
111 barrier.StateAfter = newResourceState;
112
113 gpu->addBufferResourceBarriers(this, 1, &barrier);
114
115 fResourceState = newResourceState;
116}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
ID3D12Resource * d3dResource() const
Definition: GrD3DBuffer.h:24
void addBufferResourceBarriers(GrD3DBuffer *buffer, int numBarriers, D3D12_RESOURCE_TRANSITION_BARRIER *barriers) const
Definition: GrD3DGpu.cpp:1729

Member Data Documentation

◆ fResourceState

D3D12_RESOURCE_STATES GrD3DBuffer::fResourceState
protected

Definition at line 38 of file GrD3DBuffer.h.


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