Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
GrD3DAMDMemoryAllocator Class Reference

#include <GrD3DAMDMemoryAllocator.h>

Inheritance diagram for GrD3DAMDMemoryAllocator:
GrD3DMemoryAllocator SkRefCnt SkRefCntBase

Classes

class  Alloc
 

Public Member Functions

 ~GrD3DAMDMemoryAllocator () override
 
gr_cp< ID3D12Resource > createResource (D3D12_HEAP_TYPE, const D3D12_RESOURCE_DESC *, D3D12_RESOURCE_STATES initialResourceState, sk_sp< GrD3DAlloc > *allocation, const D3D12_CLEAR_VALUE *) override
 
gr_cp< ID3D12Resource > createAliasingResource (sk_sp< GrD3DAlloc > &allocation, uint64_t localOffset, const D3D12_RESOURCE_DESC *, D3D12_RESOURCE_STATES initialResourceState, const D3D12_CLEAR_VALUE *) override
 
virtual gr_cp< ID3D12Resource > createResource (D3D12_HEAP_TYPE, const D3D12_RESOURCE_DESC *, D3D12_RESOURCE_STATES initialResourceState, sk_sp< GrD3DAlloc > *allocation, const D3D12_CLEAR_VALUE *)=0
 
virtual gr_cp< ID3D12Resource > createAliasingResource (sk_sp< GrD3DAlloc > &allocation, uint64_t localOffset, const D3D12_RESOURCE_DESC *, D3D12_RESOURCE_STATES initialResourceState, const D3D12_CLEAR_VALUE *)=0
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< GrD3DMemoryAllocatorMake (IDXGIAdapter *adapter, ID3D12Device *device)
 

Detailed Description

Definition at line 23 of file GrD3DAMDMemoryAllocator.h.

Constructor & Destructor Documentation

◆ ~GrD3DAMDMemoryAllocator()

GrD3DAMDMemoryAllocator::~GrD3DAMDMemoryAllocator ( )
inlineoverride

Definition at line 27 of file GrD3DAMDMemoryAllocator.h.

27{ fAllocator->Release(); }

Member Function Documentation

◆ createAliasingResource()

gr_cp< ID3D12Resource > GrD3DAMDMemoryAllocator::createAliasingResource ( sk_sp< GrD3DAlloc > &  allocation,
uint64_t  localOffset,
const D3D12_RESOURCE_DESC *  resourceDesc,
D3D12_RESOURCE_STATES  initialResourceState,
const D3D12_CLEAR_VALUE *  clearValue 
)
overridevirtual

Implements GrD3DMemoryAllocator.

Definition at line 50 of file GrD3DAMDMemoryAllocator.cpp.

53 {
54 Alloc* alloc = (Alloc*)allocation.get();
56 HRESULT hr = fAllocator->CreateAliasingResource(alloc->fAllocation, localOffset, resourceDesc,
57 initialResourceState, clearValue,
58 IID_PPV_ARGS(&resource));
59 if (!SUCCEEDED(hr)) {
60 return nullptr;
61 }
62
63 return resource;
64}
static SkString resource(SkPDFResourceType type, int index)
T * get() const
Definition: SkRefCnt.h:303
#define SUCCEEDED(hr)

◆ createResource()

gr_cp< ID3D12Resource > GrD3DAMDMemoryAllocator::createResource ( D3D12_HEAP_TYPE  heapType,
const D3D12_RESOURCE_DESC *  resourceDesc,
D3D12_RESOURCE_STATES  initialResourceState,
sk_sp< GrD3DAlloc > *  allocation,
const D3D12_CLEAR_VALUE *  clearValue 
)
overridevirtual

Implements GrD3DMemoryAllocator.

Definition at line 27 of file GrD3DAMDMemoryAllocator.cpp.

30 {
31 D3D12MA::ALLOCATION_DESC allocationDesc = {};
32 allocationDesc.HeapType = heapType;
33 // TODO: Determine flags. For now create new heaps regardless of budget,
34 // and always suballocate and use CreatePlacedResource.
35 // allocationDesc.Flags = ?
36
38 D3D12MA::Allocation* d3d12maAllocation;
39 HRESULT hr = fAllocator->CreateResource(&allocationDesc, resourceDesc,
40 initialResourceState, clearValue,
41 &d3d12maAllocation, IID_PPV_ARGS(&resource));
42 if (!SUCCEEDED(hr)) {
43 return nullptr;
44 }
45
46 allocation->reset(new Alloc(d3d12maAllocation));
47 return resource;
48}

◆ Make()

sk_sp< GrD3DMemoryAllocator > GrD3DAMDMemoryAllocator::Make ( IDXGIAdapter *  adapter,
ID3D12Device *  device 
)
static

Definition at line 11 of file GrD3DAMDMemoryAllocator.cpp.

12 {
13 D3D12MA::ALLOCATOR_DESC allocatorDesc = {};
14 allocatorDesc.pAdapter = adapter;
15 allocatorDesc.pDevice = device;
16 allocatorDesc.Flags = D3D12MA::ALLOCATOR_FLAG_SINGLETHREADED; // faster if we're single-threaded
17
18 D3D12MA::Allocator* allocator;
19 HRESULT hr = D3D12MA::CreateAllocator(&allocatorDesc, &allocator);
20 if (!SUCCEEDED(hr)) {
21 return nullptr;
22 }
23
25}
VkDevice device
Definition: main.cc:53

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