summaryrefslogtreecommitdiff
path: root/src/video_core/gpu_thread.h
diff options
context:
space:
mode:
authorGravatar Levi2021-01-10 22:09:56 -0700
committerGravatar Levi2021-01-10 22:09:56 -0700
commit7a3c884e39fccfbb498b855080bffabc9ce2e7f1 (patch)
tree5056f9406dec188439cb0deb87603498243a9412 /src/video_core/gpu_thread.h
parentMore forgetting... duh (diff)
parentMerge pull request #5229 from Morph1984/fullscreen-opt (diff)
downloadyuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.gz
yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.xz
yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.zip
Merge remote-tracking branch 'upstream/master' into int-flags
Diffstat (limited to 'src/video_core/gpu_thread.h')
-rw-r--r--src/video_core/gpu_thread.h48
1 files changed, 32 insertions, 16 deletions
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h
index 5a28335d6..2775629e7 100644
--- a/src/video_core/gpu_thread.h
+++ b/src/video_core/gpu_thread.h
@@ -10,8 +10,9 @@
10#include <optional> 10#include <optional>
11#include <thread> 11#include <thread>
12#include <variant> 12#include <variant>
13
13#include "common/threadsafe_queue.h" 14#include "common/threadsafe_queue.h"
14#include "video_core/gpu.h" 15#include "video_core/framebuffer_config.h"
15 16
16namespace Tegra { 17namespace Tegra {
17struct FramebufferConfig; 18struct FramebufferConfig;
@@ -25,6 +26,10 @@ class GraphicsContext;
25class System; 26class System;
26} // namespace Core 27} // namespace Core
27 28
29namespace VideoCore {
30class RendererBase;
31} // namespace VideoCore
32
28namespace VideoCommon::GPUThread { 33namespace VideoCommon::GPUThread {
29 34
30/// Command to signal to the GPU thread that processing has ended 35/// Command to signal to the GPU thread that processing has ended
@@ -32,22 +37,30 @@ struct EndProcessingCommand final {};
32 37
33/// Command to signal to the GPU thread that a command list is ready for processing 38/// Command to signal to the GPU thread that a command list is ready for processing
34struct SubmitListCommand final { 39struct SubmitListCommand final {
35 explicit SubmitListCommand(Tegra::CommandList&& entries) : entries{std::move(entries)} {} 40 explicit SubmitListCommand(Tegra::CommandList&& entries_) : entries{std::move(entries_)} {}
36 41
37 Tegra::CommandList entries; 42 Tegra::CommandList entries;
38}; 43};
39 44
45/// Command to signal to the GPU thread that a cdma command list is ready for processing
46struct SubmitChCommandEntries final {
47 explicit SubmitChCommandEntries(Tegra::ChCommandHeaderList&& entries_)
48 : entries{std::move(entries_)} {}
49
50 Tegra::ChCommandHeaderList entries;
51};
52
40/// Command to signal to the GPU thread that a swap buffers is pending 53/// Command to signal to the GPU thread that a swap buffers is pending
41struct SwapBuffersCommand final { 54struct SwapBuffersCommand final {
42 explicit SwapBuffersCommand(std::optional<const Tegra::FramebufferConfig> framebuffer) 55 explicit SwapBuffersCommand(std::optional<const Tegra::FramebufferConfig> framebuffer_)
43 : framebuffer{std::move(framebuffer)} {} 56 : framebuffer{std::move(framebuffer_)} {}
44 57
45 std::optional<Tegra::FramebufferConfig> framebuffer; 58 std::optional<Tegra::FramebufferConfig> framebuffer;
46}; 59};
47 60
48/// Command to signal to the GPU thread to flush a region 61/// Command to signal to the GPU thread to flush a region
49struct FlushRegionCommand final { 62struct FlushRegionCommand final {
50 explicit constexpr FlushRegionCommand(VAddr addr, u64 size) : addr{addr}, size{size} {} 63 explicit constexpr FlushRegionCommand(VAddr addr_, u64 size_) : addr{addr_}, size{size_} {}
51 64
52 VAddr addr; 65 VAddr addr;
53 u64 size; 66 u64 size;
@@ -55,7 +68,7 @@ struct FlushRegionCommand final {
55 68
56/// Command to signal to the GPU thread to invalidate a region 69/// Command to signal to the GPU thread to invalidate a region
57struct InvalidateRegionCommand final { 70struct InvalidateRegionCommand final {
58 explicit constexpr InvalidateRegionCommand(VAddr addr, u64 size) : addr{addr}, size{size} {} 71 explicit constexpr InvalidateRegionCommand(VAddr addr_, u64 size_) : addr{addr_}, size{size_} {}
59 72
60 VAddr addr; 73 VAddr addr;
61 u64 size; 74 u64 size;
@@ -63,8 +76,8 @@ struct InvalidateRegionCommand final {
63 76
64/// Command to signal to the GPU thread to flush and invalidate a region 77/// Command to signal to the GPU thread to flush and invalidate a region
65struct FlushAndInvalidateRegionCommand final { 78struct FlushAndInvalidateRegionCommand final {
66 explicit constexpr FlushAndInvalidateRegionCommand(VAddr addr, u64 size) 79 explicit constexpr FlushAndInvalidateRegionCommand(VAddr addr_, u64 size_)
67 : addr{addr}, size{size} {} 80 : addr{addr_}, size{size_} {}
68 81
69 VAddr addr; 82 VAddr addr;
70 u64 size; 83 u64 size;
@@ -77,15 +90,15 @@ struct OnCommandListEndCommand final {};
77struct GPUTickCommand final {}; 90struct GPUTickCommand final {};
78 91
79using CommandData = 92using CommandData =
80 std::variant<EndProcessingCommand, SubmitListCommand, SwapBuffersCommand, FlushRegionCommand, 93 std::variant<EndProcessingCommand, SubmitListCommand, SubmitChCommandEntries,
81 InvalidateRegionCommand, FlushAndInvalidateRegionCommand, OnCommandListEndCommand, 94 SwapBuffersCommand, FlushRegionCommand, InvalidateRegionCommand,
82 GPUTickCommand>; 95 FlushAndInvalidateRegionCommand, OnCommandListEndCommand, GPUTickCommand>;
83 96
84struct CommandDataContainer { 97struct CommandDataContainer {
85 CommandDataContainer() = default; 98 CommandDataContainer() = default;
86 99
87 CommandDataContainer(CommandData&& data, u64 next_fence) 100 explicit CommandDataContainer(CommandData&& data_, u64 next_fence_)
88 : data{std::move(data)}, fence{next_fence} {} 101 : data{std::move(data_)}, fence{next_fence_} {}
89 102
90 CommandData data; 103 CommandData data;
91 u64 fence{}; 104 u64 fence{};
@@ -104,16 +117,19 @@ struct SynchState final {
104/// Class used to manage the GPU thread 117/// Class used to manage the GPU thread
105class ThreadManager final { 118class ThreadManager final {
106public: 119public:
107 explicit ThreadManager(Core::System& system); 120 explicit ThreadManager(Core::System& system_, bool is_async_);
108 ~ThreadManager(); 121 ~ThreadManager();
109 122
110 /// Creates and starts the GPU thread. 123 /// Creates and starts the GPU thread.
111 void StartThread(VideoCore::RendererBase& renderer, Core::Frontend::GraphicsContext& context, 124 void StartThread(VideoCore::RendererBase& renderer, Core::Frontend::GraphicsContext& context,
112 Tegra::DmaPusher& dma_pusher); 125 Tegra::DmaPusher& dma_pusher, Tegra::CDmaPusher& cdma_pusher);
113 126
114 /// Push GPU command entries to be processed 127 /// Push GPU command entries to be processed
115 void SubmitList(Tegra::CommandList&& entries); 128 void SubmitList(Tegra::CommandList&& entries);
116 129
130 /// Push GPU CDMA command buffer entries to be processed
131 void SubmitCommandBuffer(Tegra::ChCommandHeaderList&& entries);
132
117 /// Swap buffers (render frame) 133 /// Swap buffers (render frame)
118 void SwapBuffers(const Tegra::FramebufferConfig* framebuffer); 134 void SwapBuffers(const Tegra::FramebufferConfig* framebuffer);
119 135
@@ -135,11 +151,11 @@ private:
135 /// Pushes a command to be executed by the GPU thread 151 /// Pushes a command to be executed by the GPU thread
136 u64 PushCommand(CommandData&& command_data); 152 u64 PushCommand(CommandData&& command_data);
137 153
138private:
139 SynchState state; 154 SynchState state;
140 Core::System& system; 155 Core::System& system;
141 std::thread thread; 156 std::thread thread;
142 std::thread::id thread_id; 157 std::thread::id thread_id;
158 const bool is_async;
143}; 159};
144 160
145} // namespace VideoCommon::GPUThread 161} // namespace VideoCommon::GPUThread