| 26 | } |
| 27 | |
| 28 | void DescriptorHeap::Init(ID3D12Device* device, uint64 numDescriptors, D3D12_DESCRIPTOR_HEAP_TYPE heapType, bool shaderVisible) |
| 29 | { |
| 30 | Shutdown(); |
| 31 | Assert_(numDescriptors > 0); |
| 32 | |
| 33 | NumDescriptors = numDescriptors; |
| 34 | HeapType = heapType; |
| 35 | ShaderVisible = shaderVisible; |
| 36 | if(heapType == D3D12_DESCRIPTOR_HEAP_TYPE_RTV || heapType == D3D12_DESCRIPTOR_HEAP_TYPE_DSV) |
| 37 | ShaderVisible = false; |
| 38 | |
| 39 | DeadList.Init(numDescriptors); |
| 40 | for(uint64 i = 0; i < numDescriptors; ++i) |
| 41 | DeadList[i] = uint32(i); |
| 42 | |
| 43 | D3D12_DESCRIPTOR_HEAP_DESC heapDesc = { }; |
| 44 | heapDesc.NumDescriptors = uint32(numDescriptors); |
| 45 | heapDesc.Type = heapType; |
| 46 | heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; |
| 47 | if(ShaderVisible) |
| 48 | heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; |
| 49 | |
| 50 | DXCall(device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&Heap))); |
| 51 | |
| 52 | CPUStart = Heap->GetCPUDescriptorHandleForHeapStart(); |
| 53 | if(ShaderVisible) |
| 54 | GPUStart = Heap->GetGPUDescriptorHandleForHeapStart(); |
| 55 | |
| 56 | DescriptorSize = device->GetDescriptorHandleIncrementSize(heapType); |
| 57 | } |
| 58 | |
| 59 | void DescriptorHeap::Shutdown() |
| 60 | { |
no test coverage detected