Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
GrD3DCommandList Class Reference

#include <GrD3DCommandList.h>

Inheritance diagram for GrD3DCommandList:
GrD3DCopyCommandList GrD3DDirectCommandList

Public Types

enum class  SubmitResult { kNoWork , kSuccess , kFailure }
 

Public Member Functions

virtual ~GrD3DCommandList ()
 
SubmitResult submit (ID3D12CommandQueue *queue)
 
bool close ()
 
void reset ()
 
void resourceBarrier (sk_sp< GrManagedResource > managedResource, int numBarriers, const D3D12_RESOURCE_TRANSITION_BARRIER *barriers)
 
void uavBarrier (sk_sp< GrManagedResource > managedResource, ID3D12Resource *uavResource)
 
void aliasingBarrier (sk_sp< GrManagedResource > beforeManagedResource, ID3D12Resource *beforeResource, sk_sp< GrManagedResource > afterManagedResource, ID3D12Resource *afterResource)
 
void copyBufferToTexture (ID3D12Resource *srcBuffer, const GrD3DTextureResource *dstTexture, uint32_t subresourceCount, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *bufferFootprints, int left, int top)
 
void copyTextureRegionToTexture (sk_sp< GrManagedResource > dst, const D3D12_TEXTURE_COPY_LOCATION *dstLocation, UINT dstX, UINT dstY, sk_sp< GrManagedResource > src, const D3D12_TEXTURE_COPY_LOCATION *srcLocation, const D3D12_BOX *srcBox)
 
void copyTextureRegionToBuffer (sk_sp< const GrBuffer > dst, const D3D12_TEXTURE_COPY_LOCATION *dstLocation, UINT dstX, UINT dstY, sk_sp< GrManagedResource > src, const D3D12_TEXTURE_COPY_LOCATION *srcLocation, const D3D12_BOX *srcBox)
 
void copyTextureToTexture (const GrD3DTexture *dst, const GrD3DTexture *src, UINT subresourceIndex=-1)
 
void copyBufferToBuffer (sk_sp< GrD3DBuffer > dstBuffer, uint64_t dstOffset, ID3D12Resource *srcBuffer, uint64_t srcOffset, uint64_t numBytes)
 
void addGrBuffer (sk_sp< const GrBuffer > buffer)
 
void addRecycledResource (sk_sp< GrRecycledResource > resource)
 
void releaseResources ()
 
bool hasWork () const
 
void addFinishedCallback (sk_sp< skgpu::RefCntedCallback > callback)
 

Protected Types

template<typename T >
using TrackedResourceArray = skia_private::STArray< kInitialTrackedResourcesCount, T >
 

Protected Member Functions

 GrD3DCommandList (gr_cp< ID3D12CommandAllocator > allocator, gr_cp< ID3D12GraphicsCommandList > commandList)
 
void addResource (sk_sp< GrManagedResource > resource)
 
void addingWork ()
 
virtual void onReset ()
 
void submitResourceBarriers ()
 
 SkDEBUGCODE (bool fIsActive=true;) bool fHasWork
 

Protected Attributes

gr_cp< ID3D12GraphicsCommandList > fCommandList
 
TrackedResourceArray< sk_sp< GrManagedResource > > fTrackedResources
 
TrackedResourceArray< sk_sp< GrRecycledResource > > fTrackedRecycledResources
 
TrackedResourceArray< sk_sp< const GrBuffer > > fTrackedGpuBuffers
 

Detailed Description

Definition at line 33 of file GrD3DCommandList.h.

Member Typedef Documentation

◆ TrackedResourceArray

template<typename T >
using GrD3DCommandList::TrackedResourceArray = skia_private::STArray<kInitialTrackedResourcesCount, T>
protected

Definition at line 138 of file GrD3DCommandList.h.

Member Enumeration Documentation

◆ SubmitResult

enum class GrD3DCommandList::SubmitResult
strong
Enumerator
kNoWork 
kSuccess 
kFailure 

Definition at line 39 of file GrD3DCommandList.h.

Constructor & Destructor Documentation

◆ ~GrD3DCommandList()

virtual GrD3DCommandList::~GrD3DCommandList ( )
inlinevirtual

Definition at line 35 of file GrD3DCommandList.h.

35 {
36 this->releaseResources();
37 }

◆ GrD3DCommandList()

GrD3DCommandList::GrD3DCommandList ( gr_cp< ID3D12CommandAllocator >  allocator,
gr_cp< ID3D12GraphicsCommandList >  commandList 
)
protected

Definition at line 22 of file GrD3DCommandList.cpp.

24 : fCommandList(std::move(commandList))
25 , fAllocator(std::move(allocator)) {
26}
gr_cp< ID3D12GraphicsCommandList > fCommandList

Member Function Documentation

◆ addFinishedCallback()

void GrD3DCommandList::addFinishedCallback ( sk_sp< skgpu::RefCntedCallback callback)

Definition at line 83 of file GrD3DCommandList.cpp.

83 {
84 fFinishedCallbacks.push_back(std::move(callback));
85}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ addGrBuffer()

void GrD3DCommandList::addGrBuffer ( sk_sp< const GrBuffer buffer)
inline

Definition at line 100 of file GrD3DCommandList.h.

100 {
101 fTrackedGpuBuffers.push_back(std::move(buffer));
102 }
TrackedResourceArray< sk_sp< const GrBuffer > > fTrackedGpuBuffers
static const uint8_t buffer[]

◆ addingWork()

void GrD3DCommandList::addingWork ( )
protected

Definition at line 263 of file GrD3DCommandList.cpp.

263 {
265 fHasWork = true;
266}

◆ addRecycledResource()

void GrD3DCommandList::addRecycledResource ( sk_sp< GrRecycledResource resource)
inline

Definition at line 106 of file GrD3DCommandList.h.

106 {
107 fTrackedRecycledResources.push_back(std::move(resource));
108 }
TrackedResourceArray< sk_sp< GrRecycledResource > > fTrackedRecycledResources

◆ addResource()

void GrD3DCommandList::addResource ( sk_sp< GrManagedResource resource)
inlineprotected

Definition at line 125 of file GrD3DCommandList.h.

125 {
126 SkASSERT(resource);
127 fTrackedResources.push_back(std::move(resource));
128 }
#define SkASSERT(cond)
Definition SkAssert.h:116
TrackedResourceArray< sk_sp< GrManagedResource > > fTrackedResources

◆ aliasingBarrier()

void GrD3DCommandList::aliasingBarrier ( sk_sp< GrManagedResource beforeManagedResource,
ID3D12Resource *  beforeResource,
sk_sp< GrManagedResource afterManagedResource,
ID3D12Resource *  afterResource 
)

Definition at line 125 of file GrD3DCommandList.cpp.

128 {
129 SkASSERT(fIsActive);
130 // D3D will apply barriers in order so we can just add onto the end
131 D3D12_RESOURCE_BARRIER& newBarrier = fResourceBarriers.push_back();
132 newBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING;
133 newBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
134 newBarrier.Aliasing.pResourceBefore = beforeResource;
135 newBarrier.Aliasing.pResourceAfter = afterResource;
136
137 fHasWork = true;
138 if (beforeResource) {
139 SkASSERT(beforeManagedResource);
140 this->addResource(std::move(beforeManagedResource));
141 }
142 // Aliasing barriers can accept a null pointer for the second resource,
143 // but at this point we're not using that feature.
144 SkASSERT(afterResource);
145 SkASSERT(afterManagedResource);
146 this->addResource(std::move(afterManagedResource));
147}
void addResource(sk_sp< GrManagedResource > resource)

◆ close()

bool GrD3DCommandList::close ( )

Definition at line 28 of file GrD3DCommandList.cpp.

28 {
29 SkASSERT(fIsActive);
31 HRESULT hr = fCommandList->Close();
32 SkDEBUGCODE(fIsActive = false;)
33 return SUCCEEDED(hr);
34}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
#define SUCCEEDED(hr)

◆ copyBufferToBuffer()

void GrD3DCommandList::copyBufferToBuffer ( sk_sp< GrD3DBuffer dstBuffer,
uint64_t  dstOffset,
ID3D12Resource *  srcBuffer,
uint64_t  srcOffset,
uint64_t  numBytes 
)

Definition at line 246 of file GrD3DCommandList.cpp.

248 {
249 SkASSERT(fIsActive);
250
251 this->addingWork();
252 ID3D12Resource* dstBuffer = dst->d3dResource();
253 uint64_t dstSize = dstBuffer->GetDesc().Width;
254 uint64_t srcSize = srcBuffer->GetDesc().Width;
255 if (dstSize == srcSize && srcSize == numBytes) {
256 fCommandList->CopyResource(dstBuffer, srcBuffer);
257 } else {
258 fCommandList->CopyBufferRegion(dstBuffer, dstOffset, srcBuffer, srcOffset, numBytes);
259 }
260 this->addGrBuffer(std::move(dst));
261}
void addGrBuffer(sk_sp< const GrBuffer > buffer)
dst
Definition cp.py:12

◆ copyBufferToTexture()

void GrD3DCommandList::copyBufferToTexture ( ID3D12Resource *  srcBuffer,
const GrD3DTextureResource dstTexture,
uint32_t  subresourceCount,
D3D12_PLACED_SUBRESOURCE_FOOTPRINT *  bufferFootprints,
int  left,
int  top 
)

Definition at line 159 of file GrD3DCommandList.cpp.

163 {
164 SkASSERT(fIsActive);
165 SkASSERT(subresourceCount == 1 || (left == 0 && top == 0));
166
167 this->addingWork();
168 this->addResource(dstTexture->resource());
169
170 for (uint32_t subresource = 0; subresource < subresourceCount; ++subresource) {
171 D3D12_TEXTURE_COPY_LOCATION src = {};
172 src.pResource = srcBuffer;
173 src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
174 src.PlacedFootprint = bufferFootprints[subresource];
175
176 D3D12_TEXTURE_COPY_LOCATION dst = {};
177 dst.pResource = dstTexture->d3dResource();
178 dst.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
179 dst.SubresourceIndex = subresource;
180
181 fCommandList->CopyTextureRegion(&dst, left, top, 0, &src, nullptr);
182 }
183}
static bool left(const SkPoint &p0, const SkPoint &p1)
ID3D12Resource * d3dResource() const
sk_sp< Resource > resource() const

◆ copyTextureRegionToBuffer()

void GrD3DCommandList::copyTextureRegionToBuffer ( sk_sp< const GrBuffer dst,
const D3D12_TEXTURE_COPY_LOCATION *  dstLocation,
UINT  dstX,
UINT  dstY,
sk_sp< GrManagedResource src,
const D3D12_TEXTURE_COPY_LOCATION *  srcLocation,
const D3D12_BOX *  srcBox 
)

Definition at line 199 of file GrD3DCommandList.cpp.

205 {
206 SkASSERT(fIsActive);
207 SkASSERT(dst);
208 this->addingWork();
209 this->addGrBuffer(std::move(dst));
210 this->addResource(std::move(src));
211 fCommandList->CopyTextureRegion(dstLocation, dstX, dstY, 0, srcLocation, srcBox);
212}

◆ copyTextureRegionToTexture()

void GrD3DCommandList::copyTextureRegionToTexture ( sk_sp< GrManagedResource dst,
const D3D12_TEXTURE_COPY_LOCATION *  dstLocation,
UINT  dstX,
UINT  dstY,
sk_sp< GrManagedResource src,
const D3D12_TEXTURE_COPY_LOCATION *  srcLocation,
const D3D12_BOX *  srcBox 
)

Definition at line 185 of file GrD3DCommandList.cpp.

190 {
191 SkASSERT(fIsActive);
192 SkASSERT(dst);
193 this->addingWork();
194 this->addResource(dst);
195 this->addResource(std::move(src));
196 fCommandList->CopyTextureRegion(dstLocation, dstX, dstY, 0, srcLocation, srcBox);
197}

◆ copyTextureToTexture()

void GrD3DCommandList::copyTextureToTexture ( const GrD3DTexture dst,
const GrD3DTexture src,
UINT  subresourceIndex = -1 
)

Definition at line 215 of file GrD3DCommandList.cpp.

216 {
217 SkASSERT(fIsActive);
218 SkASSERT(src);
219 SkASSERT(dst);
220 SkASSERT(src->width() == dst->width() && src->height() == dst->height());
221
222 this->addingWork();
223 ID3D12Resource* dstTexture = dst->d3dResource();
224 ID3D12Resource* srcTexture = src->d3dResource();
225 if (subresourceIndex == (UINT)-1) {
226 fCommandList->CopyResource(dstTexture, srcTexture);
227 } else {
228 SkASSERT(subresourceIndex < src->mipLevels() &&
229 subresourceIndex < dst->mipLevels());
230 D3D12_TEXTURE_COPY_LOCATION srcLoc = {};
231 srcLoc.pResource = srcTexture;
232 srcLoc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
233 srcLoc.SubresourceIndex = subresourceIndex;
234
235 D3D12_TEXTURE_COPY_LOCATION dstLoc = {};
236 dstLoc.pResource = dstTexture;
237 dstLoc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
238 dstLoc.SubresourceIndex = subresourceIndex;
239
240 fCommandList->CopyTextureRegion(&dstLoc, 0, 0, 0, &srcLoc, nullptr);
241 }
242 this->addResource(dst->resource());
243 this->addResource(src->resource());
244}
unsigned int UINT

◆ hasWork()

bool GrD3DCommandList::hasWork ( ) const
inline

Definition at line 112 of file GrD3DCommandList.h.

112{ return fHasWork; }

◆ onReset()

virtual void GrD3DCommandList::onReset ( )
inlineprotectedvirtual

Reimplemented in GrD3DDirectCommandList.

Definition at line 131 of file GrD3DCommandList.h.

131{}

◆ releaseResources()

void GrD3DCommandList::releaseResources ( )

Definition at line 65 of file GrD3DCommandList.cpp.

65 {
66 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
67 if (fTrackedResources.size() == 0 && fTrackedRecycledResources.size() == 0) {
68 return;
69 }
70 SkASSERT(!fIsActive);
71 for (int i = 0; i < fTrackedRecycledResources.size(); ++i) {
72 auto resource = fTrackedRecycledResources[i].release();
73 resource->recycle();
74 }
75
76 fTrackedResources.clear();
78 fTrackedGpuBuffers.clear();
79
80 this->callFinishedCallbacks();
81}
#define TRACE_FUNC
#define TRACE_EVENT0(category_group, name)

◆ reset()

void GrD3DCommandList::reset ( )

Definition at line 53 of file GrD3DCommandList.cpp.

53 {
54 SkASSERT(!fIsActive);
55 GR_D3D_CALL_ERRCHECK(fAllocator->Reset());
56 GR_D3D_CALL_ERRCHECK(fCommandList->Reset(fAllocator.get(), nullptr));
57 this->onReset();
58
59 this->releaseResources();
60
61 SkDEBUGCODE(fIsActive = true;)
62 fHasWork = false;
63}
#define GR_D3D_CALL_ERRCHECK(X)
Definition GrD3DUtil.h:16
virtual void onReset()
T * get() const
Definition GrD3DTypes.h:108

◆ resourceBarrier()

void GrD3DCommandList::resourceBarrier ( sk_sp< GrManagedResource managedResource,
int  numBarriers,
const D3D12_RESOURCE_TRANSITION_BARRIER *  barriers 
)

Definition at line 91 of file GrD3DCommandList.cpp.

93 {
94 SkASSERT(fIsActive);
95 SkASSERT(barriers);
96 for (int i = 0; i < numBarriers; ++i) {
97 // D3D will apply barriers in order so we can just add onto the end
98 D3D12_RESOURCE_BARRIER& newBarrier = fResourceBarriers.push_back();
99 newBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
100 newBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
101 newBarrier.Transition = barriers[i];
102 }
103
104 fHasWork = true;
105 if (resource) {
106 this->addResource(std::move(resource));
107 }
108}

◆ SkDEBUGCODE()

GrD3DCommandList::SkDEBUGCODE ( bool  fIsActive = true;)
protected

◆ submit()

GrD3DCommandList::SubmitResult GrD3DCommandList::submit ( ID3D12CommandQueue *  queue)

Definition at line 36 of file GrD3DCommandList.cpp.

36 {
37 SkASSERT(fIsActive);
38 if (!this->hasWork()) {
39 this->callFinishedCallbacks();
41 }
42
43 if (!this->close()) {
45 }
46 SkASSERT(!fIsActive);
47 ID3D12CommandList* ppCommandLists[] = { fCommandList.get() };
48 queue->ExecuteCommandLists(1, ppCommandLists);
49
51}
VkQueue queue
Definition main.cc:55

◆ submitResourceBarriers()

void GrD3DCommandList::submitResourceBarriers ( )
protected

Definition at line 149 of file GrD3DCommandList.cpp.

149 {
150 SkASSERT(fIsActive);
151
152 if (fResourceBarriers.size()) {
153 fCommandList->ResourceBarrier(fResourceBarriers.size(), fResourceBarriers.begin());
154 fResourceBarriers.clear();
155 }
156 SkASSERT(!fResourceBarriers.size());
157}
int size() const
Definition SkTArray.h:416

◆ uavBarrier()

void GrD3DCommandList::uavBarrier ( sk_sp< GrManagedResource managedResource,
ID3D12Resource *  uavResource 
)

Definition at line 110 of file GrD3DCommandList.cpp.

111 {
112 SkASSERT(fIsActive);
113 // D3D will apply barriers in order so we can just add onto the end
114 D3D12_RESOURCE_BARRIER& newBarrier = fResourceBarriers.push_back();
115 newBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
116 newBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
117 newBarrier.UAV.pResource = uavResource;
118
119 fHasWork = true;
120 if (resource) {
121 this->addResource(std::move(resource));
122 }
123}

Member Data Documentation

◆ fCommandList

gr_cp<ID3D12GraphicsCommandList> GrD3DCommandList::fCommandList
protected

Definition at line 135 of file GrD3DCommandList.h.

◆ fTrackedGpuBuffers

TrackedResourceArray<sk_sp<const GrBuffer> > GrD3DCommandList::fTrackedGpuBuffers
protected

Definition at line 141 of file GrD3DCommandList.h.

◆ fTrackedRecycledResources

TrackedResourceArray<sk_sp<GrRecycledResource> > GrD3DCommandList::fTrackedRecycledResources
protected

Definition at line 140 of file GrD3DCommandList.h.

◆ fTrackedResources

TrackedResourceArray<sk_sp<GrManagedResource> > GrD3DCommandList::fTrackedResources
protected

Definition at line 139 of file GrD3DCommandList.h.


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