Debian Codegraph @

Source/Core/VideoBackends/D3D12/DescriptorAllocator.h

raw symbols SCIP
1 // Copyright 2019 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <map>
7
8 #include "VideoBackends/D3D12/DescriptorHeapManager.h"
9 #include "VideoCommon/Constants.h"
10
11 namespace DX12
12 {
13 class DescriptorAllocator
14 {
15 public:
16 DescriptorAllocator();
17 ~DescriptorAllocator();
18
19 ID3D12DescriptorHeap* GetDescriptorHeap() const { return m_descriptor_heap.Get(); }
20 u32 GetDescriptorIncrementSize() const { return m_descriptor_increment_size; }
21
22 bool Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE type, u32 num_descriptors);
23
24 bool Allocate(u32 num_handles, DescriptorHandle* out_base_handle);
25 void Reset();
26
27 protected:
28 ComPtr<ID3D12DescriptorHeap> m_descriptor_heap;
29 u32 m_descriptor_increment_size = 0;
30 u32 m_num_descriptors = 0;
31 u32 m_current_offset = 0;
32
33 D3D12_CPU_DESCRIPTOR_HANDLE m_heap_base_cpu = {};
34 D3D12_GPU_DESCRIPTOR_HANDLE m_heap_base_gpu = {};
35 };
36
37 struct SamplerStateSet final
38 {
39 SamplerState states[VideoCommon::MAX_PIXEL_SHADER_SAMPLERS];
40 };
41
42 bool operator==(const SamplerStateSet& lhs, const SamplerStateSet& rhs);
43 bool operator!=(const SamplerStateSet& lhs, const SamplerStateSet& rhs);
44 bool operator<(const SamplerStateSet& lhs, const SamplerStateSet& rhs);
45
46 class SamplerAllocator final : public DescriptorAllocator
47 {
48 public:
49 SamplerAllocator();
50 ~SamplerAllocator();
51
52 bool Create(ID3D12Device* device);
53 bool GetGroupHandle(const SamplerStateSet& sss, D3D12_GPU_DESCRIPTOR_HANDLE* handle);
54 bool ShouldReset() const;
55 void Reset();
56
57 private:
58 std::map<SamplerStateSet, D3D12_GPU_DESCRIPTOR_HANDLE> m_sampler_map;
59 };
60
61 } // namespace DX12