Flutter Engine
The Flutter Engine
GrD3DBuffer.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrD3DBuffer_DEFINED
9
10#define GrD3DBuffer_DEFINED
11
15
16class GrD3DGpu;
17
18class GrD3DBuffer : public GrGpuBuffer {
19public:
21
22 ~GrD3DBuffer() override {}
23
24 ID3D12Resource* d3dResource() const {
25 SkASSERT(fD3DResource);
26 return fD3DResource.get();
27 }
28
29 void setResourceState(const GrD3DGpu* gpu, D3D12_RESOURCE_STATES newResourceState);
30
31protected:
33 sk_sp<GrD3DAlloc>, D3D12_RESOURCE_STATES, std::string_view label);
34
35 void onAbandon() override;
36 void onRelease() override;
37
38 D3D12_RESOURCE_STATES fResourceState;
39
40private:
41 void releaseResource();
42
43 void onMap(MapType) override;
44 void onUnmap(MapType) override;
45 bool onClearToZero() override;
46 bool onUpdateData(const void* src, size_t offset, size_t size, bool preserve) override;
47
48 void* internalMap(MapType, size_t offset, size_t size);
49 void internalUnmap(MapType, size_t offset, size_t size);
50
51#ifdef SK_DEBUG
52 void validate() const;
53#endif
54
55 void onSetLabel() override;
56
57 GrD3DGpu* getD3DGpu() const {
58 SkASSERT(!this->wasDestroyed());
59 return reinterpret_cast<GrD3DGpu*>(this->getGpu());
60 }
61
62 gr_cp<ID3D12Resource> fD3DResource;
63 sk_sp<GrD3DAlloc> fAlloc;
64 ID3D12Resource* fStagingBuffer = nullptr;
65 size_t fStagingOffset = 0;
66
67 using INHERITED = GrGpuBuffer;
68};
69
70#endif
GrGpuBufferType
Definition: GrTypesPriv.h:411
GrAccessPattern
Definition: GrTypesPriv.h:424
#define SkASSERT(cond)
Definition: SkAssert.h:116
void onAbandon() override
ID3D12Resource * d3dResource() const
Definition: GrD3DBuffer.h:24
void setResourceState(const GrD3DGpu *gpu, D3D12_RESOURCE_STATES newResourceState)
Definition: GrD3DBuffer.cpp:98
void onRelease() override
~GrD3DBuffer() override
Definition: GrD3DBuffer.h:22
D3D12_RESOURCE_STATES fResourceState
Definition: GrD3DBuffer.h:38
static sk_sp< GrD3DBuffer > Make(GrD3DGpu *, size_t size, GrGpuBufferType, GrAccessPattern)
Definition: GrD3DBuffer.cpp:64
GrD3DBuffer(GrD3DGpu *, size_t size, GrGpuBufferType, GrAccessPattern, gr_cp< ID3D12Resource >, sk_sp< GrD3DAlloc >, D3D12_RESOURCE_STATES, std::string_view label)
Definition: GrD3DBuffer.cpp:82
size_t size() const final
Definition: GrGpuBuffer.h:34
GrGpuBuffer(GrGpu *, size_t sizeInBytes, GrGpuBufferType, GrAccessPattern, std::string_view label)
Definition: GrGpuBuffer.cpp:19
GrGpu * getGpu() const
bool wasDestroyed() const
T * get() const
Definition: GrD3DTypes.h:108
SeparatedVector2 offset