Debian Codegraph @

Source/Core/VideoBackends/D3D12/D3D12StreamBuffer.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 <deque>
7 #include <utility>
8
9 #include "Common/CommonTypes.h"
10 #include "VideoBackends/D3D12/Common.h"
11
12 namespace DX12
13 {
14 class StreamBuffer
15 {
16 public:
17 StreamBuffer();
18 ~StreamBuffer();
19
20 bool AllocateBuffer(u32 size);
21
22 ID3D12Resource* GetBuffer() const { return m_buffer; }
23 D3D12_GPU_VIRTUAL_ADDRESS GetGPUPointer() const { return m_gpu_pointer; }
24 u8* GetHostPointer() const { return m_host_pointer; }
25 u8* GetCurrentHostPointer() const { return m_host_pointer + m_current_offset; }
26 D3D12_GPU_VIRTUAL_ADDRESS GetCurrentGPUPointer() const
27 {
28 return m_gpu_pointer + m_current_offset;
29 }
30 u32 GetSize() const { return m_size; }
31 u32 GetCurrentOffset() const { return m_current_offset; }
32 bool ReserveMemory(u32 num_bytes, u32 alignment);
33 void CommitMemory(u32 final_num_bytes);
34
35 private:
36 void UpdateCurrentFencePosition();
37 void UpdateGPUPosition();
38
39 // Waits for as many fences as needed to allocate num_bytes bytes from the buffer.
40 bool WaitForClearSpace(u32 num_bytes);
41
42 u32 m_size = 0;
43 u32 m_current_offset = 0;
44 u32 m_current_gpu_position = 0;
45 u32 m_last_allocation_size = 0;
46
47 ID3D12Resource* m_buffer = nullptr;
48 D3D12_GPU_VIRTUAL_ADDRESS m_gpu_pointer = {};
49 u8* m_host_pointer = nullptr;
50
51 // List of fences and the corresponding positions in the buffer
52 std::deque<std::pair<u64, u32>> m_tracked_fences;
53 };
54
55 } // namespace DX12