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

#include <GrD3DDescriptorHeap.h>

Classes

struct  CPUHandle
 
struct  GPUHandle
 

Public Member Functions

 ~GrD3DDescriptorHeap ()=default
 
uint32_t uniqueID () const
 
CPUHandle getCPUHandle (unsigned int index)
 
GPUHandle getGPUHandle (unsigned int index)
 
ID3D12DescriptorHeap * descriptorHeap () const
 
size_t handleIncrementSize ()
 
size_t getIndex (const CPUHandle &handle)
 
size_t getIndex (const GPUHandle &handle)
 

Static Public Member Functions

static std::unique_ptr< GrD3DDescriptorHeapMake (GrD3DGpu *gpu, D3D12_DESCRIPTOR_HEAP_TYPE, unsigned int numDescriptors, D3D12_DESCRIPTOR_HEAP_FLAGS)
 

Protected Member Functions

 GrD3DDescriptorHeap (const gr_cp< ID3D12DescriptorHeap > &, unsigned int handleIncrementSize)
 

Static Protected Member Functions

static uint32_t GenID ()
 

Protected Attributes

gr_cp< ID3D12DescriptorHeap > fHeap
 
size_t fHandleIncrementSize
 
D3D12_CPU_DESCRIPTOR_HANDLE fCPUHeapStart
 
D3D12_GPU_DESCRIPTOR_HANDLE fGPUHeapStart
 
uint32_t fUniqueID
 

Detailed Description

Definition at line 17 of file GrD3DDescriptorHeap.h.

Constructor & Destructor Documentation

◆ ~GrD3DDescriptorHeap()

GrD3DDescriptorHeap::~GrD3DDescriptorHeap ( )
default

◆ GrD3DDescriptorHeap()

GrD3DDescriptorHeap::GrD3DDescriptorHeap ( const gr_cp< ID3D12DescriptorHeap > &  heap,
unsigned int  handleIncrementSize 
)
protected

Definition at line 28 of file GrD3DDescriptorHeap.cpp.

30 : fHeap(heap)
32 , fUniqueID(GenID()) {
33 fCPUHeapStart = fHeap->GetCPUDescriptorHandleForHeapStart();
34 fGPUHeapStart = fHeap->GetGPUDescriptorHandleForHeapStart();
35}
D3D12_GPU_DESCRIPTOR_HANDLE fGPUHeapStart
static uint32_t GenID()
gr_cp< ID3D12DescriptorHeap > fHeap
D3D12_CPU_DESCRIPTOR_HANDLE fCPUHeapStart

Member Function Documentation

◆ descriptorHeap()

ID3D12DescriptorHeap * GrD3DDescriptorHeap::descriptorHeap ( ) const
inline

Definition at line 39 of file GrD3DDescriptorHeap.h.

39{ return fHeap.get(); }
T * get() const
Definition: GrD3DTypes.h:108

◆ GenID()

static uint32_t GrD3DDescriptorHeap::GenID ( )
inlinestaticprotected

Definition at line 61 of file GrD3DDescriptorHeap.h.

61 {
62 static std::atomic<uint32_t> nextID{1};
63 uint32_t id;
64 do {
65 id = nextID++;
66 } while (id == SK_InvalidUniqueID);
67 return id;
68 }
static constexpr uint32_t SK_InvalidUniqueID
Definition: SkTypes.h:196
const uintptr_t id

◆ getCPUHandle()

GrD3DDescriptorHeap::CPUHandle GrD3DDescriptorHeap::getCPUHandle ( unsigned int  index)

Definition at line 37 of file GrD3DDescriptorHeap.cpp.

37 {
38 SkASSERT(index < fHeap->GetDesc().NumDescriptors);
39 D3D12_CPU_DESCRIPTOR_HANDLE handle = fCPUHeapStart;
40 handle.ptr += index * fHandleIncrementSize;
41 return {handle, fUniqueID};
42}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ getGPUHandle()

GrD3DDescriptorHeap::GPUHandle GrD3DDescriptorHeap::getGPUHandle ( unsigned int  index)

Definition at line 44 of file GrD3DDescriptorHeap.cpp.

44 {
45 SkASSERT(index < fHeap->GetDesc().NumDescriptors);
46 D3D12_GPU_DESCRIPTOR_HANDLE handle = fGPUHeapStart;
47 handle.ptr += index * fHandleIncrementSize;
48 return {handle, fUniqueID};
49}

◆ getIndex() [1/2]

size_t GrD3DDescriptorHeap::getIndex ( const CPUHandle handle)
inline

Definition at line 42 of file GrD3DDescriptorHeap.h.

42 {
43 SkASSERT(handle.fHeapID == fUniqueID);
44 size_t index = (handle.fHandle.ptr - fCPUHeapStart.ptr) / fHandleIncrementSize;
45 SkASSERT(index < fHeap->GetDesc().NumDescriptors);
46 SkASSERT(handle.fHandle.ptr == fCPUHeapStart.ptr + index * fHandleIncrementSize);
47 return index;
48 }

◆ getIndex() [2/2]

size_t GrD3DDescriptorHeap::getIndex ( const GPUHandle handle)
inline

Definition at line 50 of file GrD3DDescriptorHeap.h.

50 {
51 SkASSERT(handle.fHeapID == fUniqueID);
52 size_t index = (handle.fHandle.ptr - fCPUHeapStart.ptr) / fHandleIncrementSize;
53 SkASSERT(index < fHeap->GetDesc().NumDescriptors);
54 SkASSERT(handle.fHandle.ptr == fCPUHeapStart.ptr + index * fHandleIncrementSize);
55 return index;
56 }

◆ handleIncrementSize()

size_t GrD3DDescriptorHeap::handleIncrementSize ( )
inline

Definition at line 40 of file GrD3DDescriptorHeap.h.

40{ return fHandleIncrementSize; }

◆ Make()

std::unique_ptr< GrD3DDescriptorHeap > GrD3DDescriptorHeap::Make ( GrD3DGpu gpu,
D3D12_DESCRIPTOR_HEAP_TYPE  type,
unsigned int  numDescriptors,
D3D12_DESCRIPTOR_HEAP_FLAGS  flags 
)
static

Definition at line 11 of file GrD3DDescriptorHeap.cpp.

14 {
15 D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
16 heapDesc.Type = type;
17 heapDesc.NumDescriptors = numDescriptors;
18 heapDesc.Flags = flags;
19
20 ID3D12DescriptorHeap* heap;
21 gpu->device()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&heap));
22
23 return std::unique_ptr<GrD3DDescriptorHeap>(
25 gpu->device()->GetDescriptorHandleIncrementSize(type)));
26}
GLenum type
GrD3DDescriptorHeap(const gr_cp< ID3D12DescriptorHeap > &, unsigned int handleIncrementSize)
ID3D12Device * device() const
Definition: GrD3DGpu.h:43
FlutterSemanticsFlag flags

◆ uniqueID()

uint32_t GrD3DDescriptorHeap::uniqueID ( ) const
inline

Definition at line 25 of file GrD3DDescriptorHeap.h.

25{ return fUniqueID; }

Member Data Documentation

◆ fCPUHeapStart

D3D12_CPU_DESCRIPTOR_HANDLE GrD3DDescriptorHeap::fCPUHeapStart
protected

Definition at line 72 of file GrD3DDescriptorHeap.h.

◆ fGPUHeapStart

D3D12_GPU_DESCRIPTOR_HANDLE GrD3DDescriptorHeap::fGPUHeapStart
protected

Definition at line 73 of file GrD3DDescriptorHeap.h.

◆ fHandleIncrementSize

size_t GrD3DDescriptorHeap::fHandleIncrementSize
protected

Definition at line 71 of file GrD3DDescriptorHeap.h.

◆ fHeap

gr_cp<ID3D12DescriptorHeap> GrD3DDescriptorHeap::fHeap
protected

Definition at line 70 of file GrD3DDescriptorHeap.h.

◆ fUniqueID

uint32_t GrD3DDescriptorHeap::fUniqueID
protected

Definition at line 74 of file GrD3DDescriptorHeap.h.


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