summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/gpu.cpp7
-rw-r--r--src/video_core/gpu.h4
-rw-r--r--src/video_core/gpu_thread.cpp30
-rw-r--r--src/video_core/gpu_thread.h5
4 files changed, 34 insertions, 12 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index f99a8a0de..6ab06775f 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -38,7 +38,7 @@ GPU::GPU(Core::System& system_, bool is_async_, bool use_nvdec_)
38 maxwell_dma{std::make_unique<Engines::MaxwellDMA>(system, *memory_manager)}, 38 maxwell_dma{std::make_unique<Engines::MaxwellDMA>(system, *memory_manager)},
39 kepler_memory{std::make_unique<Engines::KeplerMemory>(system, *memory_manager)}, 39 kepler_memory{std::make_unique<Engines::KeplerMemory>(system, *memory_manager)},
40 shader_notify{std::make_unique<VideoCore::ShaderNotify>()}, is_async{is_async_}, 40 shader_notify{std::make_unique<VideoCore::ShaderNotify>()}, is_async{is_async_},
41 gpu_thread{system_} {} 41 gpu_thread{system_, is_async_} {}
42 42
43GPU::~GPU() = default; 43GPU::~GPU() = default;
44 44
@@ -524,7 +524,10 @@ void GPU::WaitIdle() const {
524} 524}
525 525
526void GPU::OnCommandListEnd() { 526void GPU::OnCommandListEnd() {
527 gpu_thread.OnCommandListEnd(); 527 if (is_async) {
528 // This command only applies to asynchronous GPU mode
529 gpu_thread.OnCommandListEnd();
530 }
528} 531}
529 532
530} // namespace Tegra 533} // namespace Tegra
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index a2bb4d82d..d81e38680 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -406,10 +406,10 @@ private:
406 u64 last_flush_fence{}; 406 u64 last_flush_fence{};
407 std::mutex flush_request_mutex; 407 std::mutex flush_request_mutex;
408 408
409 const bool is_async;
410
409 VideoCommon::GPUThread::ThreadManager gpu_thread; 411 VideoCommon::GPUThread::ThreadManager gpu_thread;
410 std::unique_ptr<Core::Frontend::GraphicsContext> cpu_context; 412 std::unique_ptr<Core::Frontend::GraphicsContext> cpu_context;
411
412 const bool is_async;
413}; 413};
414 414
415#define ASSERT_REG_POSITION(field_name, position) \ 415#define ASSERT_REG_POSITION(field_name, position) \
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp
index e27218b96..56b9621b1 100644
--- a/src/video_core/gpu_thread.cpp
+++ b/src/video_core/gpu_thread.cpp
@@ -65,7 +65,8 @@ static void RunThread(Core::System& system, VideoCore::RendererBase& renderer,
65 } 65 }
66} 66}
67 67
68ThreadManager::ThreadManager(Core::System& system_) : system{system_} {} 68ThreadManager::ThreadManager(Core::System& system_, bool is_async_)
69 : system{system_}, is_async{is_async_} {}
69 70
70ThreadManager::~ThreadManager() { 71ThreadManager::~ThreadManager() {
71 if (!thread.joinable()) { 72 if (!thread.joinable()) {
@@ -97,19 +98,30 @@ void ThreadManager::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
97} 98}
98 99
99void ThreadManager::FlushRegion(VAddr addr, u64 size) { 100void ThreadManager::FlushRegion(VAddr addr, u64 size) {
100 if (!Settings::IsGPULevelHigh()) { 101 if (!is_async) {
102 // Always flush with synchronous GPU mode
101 PushCommand(FlushRegionCommand(addr, size)); 103 PushCommand(FlushRegionCommand(addr, size));
102 return; 104 return;
103 } 105 }
104 if (!Settings::IsGPULevelExtreme()) { 106
105 return; 107 // Asynchronous GPU mode
106 } 108 switch (Settings::values.gpu_accuracy.GetValue()) {
107 if (system.Renderer().Rasterizer().MustFlushRegion(addr, size)) { 109 case Settings::GPUAccuracy::Normal:
110 PushCommand(FlushRegionCommand(addr, size));
111 break;
112 case Settings::GPUAccuracy::High:
113 // TODO(bunnei): Is this right? Preserving existing behavior for now
114 break;
115 case Settings::GPUAccuracy::Extreme: {
108 auto& gpu = system.GPU(); 116 auto& gpu = system.GPU();
109 u64 fence = gpu.RequestFlush(addr, size); 117 u64 fence = gpu.RequestFlush(addr, size);
110 PushCommand(GPUTickCommand()); 118 PushCommand(GPUTickCommand());
111 while (fence > gpu.CurrentFlushRequestFence()) { 119 while (fence > gpu.CurrentFlushRequestFence()) {
112 } 120 }
121 break;
122 }
123 default:
124 UNIMPLEMENTED_MSG("Unsupported gpu_accuracy {}", Settings::values.gpu_accuracy.GetValue());
113 } 125 }
114} 126}
115 127
@@ -134,6 +146,12 @@ void ThreadManager::OnCommandListEnd() {
134u64 ThreadManager::PushCommand(CommandData&& command_data) { 146u64 ThreadManager::PushCommand(CommandData&& command_data) {
135 const u64 fence{++state.last_fence}; 147 const u64 fence{++state.last_fence};
136 state.queue.Push(CommandDataContainer(std::move(command_data), fence)); 148 state.queue.Push(CommandDataContainer(std::move(command_data), fence));
149
150 if (!is_async) {
151 // In synchronous GPU mode, block the caller until the command has executed
152 WaitIdle();
153 }
154
137 return fence; 155 return fence;
138} 156}
139 157
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h
index 0071195d6..2775629e7 100644
--- a/src/video_core/gpu_thread.h
+++ b/src/video_core/gpu_thread.h
@@ -27,7 +27,7 @@ class System;
27} // namespace Core 27} // namespace Core
28 28
29namespace VideoCore { 29namespace VideoCore {
30 class RendererBase; 30class RendererBase;
31} // namespace VideoCore 31} // namespace VideoCore
32 32
33namespace VideoCommon::GPUThread { 33namespace VideoCommon::GPUThread {
@@ -117,7 +117,7 @@ struct SynchState final {
117/// Class used to manage the GPU thread 117/// Class used to manage the GPU thread
118class ThreadManager final { 118class ThreadManager final {
119public: 119public:
120 explicit ThreadManager(Core::System& system_); 120 explicit ThreadManager(Core::System& system_, bool is_async_);
121 ~ThreadManager(); 121 ~ThreadManager();
122 122
123 /// Creates and starts the GPU thread. 123 /// Creates and starts the GPU thread.
@@ -155,6 +155,7 @@ private:
155 Core::System& system; 155 Core::System& system;
156 std::thread thread; 156 std::thread thread;
157 std::thread::id thread_id; 157 std::thread::id thread_id;
158 const bool is_async;
158}; 159};
159 160
160} // namespace VideoCommon::GPUThread 161} // namespace VideoCommon::GPUThread