diff options
| author | 2020-12-12 00:24:33 -0800 | |
|---|---|---|
| committer | 2020-12-28 16:33:48 -0800 | |
| commit | 40571c073faa02a6a4301e7f0ce365ef50a400aa (patch) | |
| tree | f36bf8633469b5fc370495477e3c7cbc6e97a9c6 /src/video_core/gpu_thread.cpp | |
| parent | video_core: gpu: Refactor out synchronous/asynchronous GPU implementations. (diff) | |
| download | yuzu-40571c073faa02a6a4301e7f0ce365ef50a400aa.tar.gz yuzu-40571c073faa02a6a4301e7f0ce365ef50a400aa.tar.xz yuzu-40571c073faa02a6a4301e7f0ce365ef50a400aa.zip | |
video_core: gpu: Implement synchronous mode using threaded GPU.
Diffstat (limited to 'src/video_core/gpu_thread.cpp')
| -rw-r--r-- | src/video_core/gpu_thread.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
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 | ||
| 68 | ThreadManager::ThreadManager(Core::System& system_) : system{system_} {} | 68 | ThreadManager::ThreadManager(Core::System& system_, bool is_async_) |
| 69 | : system{system_}, is_async{is_async_} {} | ||
| 69 | 70 | ||
| 70 | ThreadManager::~ThreadManager() { | 71 | ThreadManager::~ThreadManager() { |
| 71 | if (!thread.joinable()) { | 72 | if (!thread.joinable()) { |
| @@ -97,19 +98,30 @@ void ThreadManager::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { | |||
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | void ThreadManager::FlushRegion(VAddr addr, u64 size) { | 100 | void 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() { | |||
| 134 | u64 ThreadManager::PushCommand(CommandData&& command_data) { | 146 | u64 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 | ||