diff options
| author | 2020-04-22 22:09:38 -0400 | |
|---|---|---|
| committer | 2020-04-22 22:09:38 -0400 | |
| commit | bf2ddb8fd5feaeaf2806fe102de8e3089f893137 (patch) | |
| tree | b97d388da23608c00808b6662e3c0564fc4f6d59 /src/video_core/gpu_thread.cpp | |
| parent | Merge pull request #3767 from ReinUsesLisp/point-size-pipeline (diff) | |
| parent | GL_Fence_Manager: use GL_TIMEOUT_IGNORED instead of a loop, (diff) | |
| download | yuzu-bf2ddb8fd5feaeaf2806fe102de8e3089f893137.tar.gz yuzu-bf2ddb8fd5feaeaf2806fe102de8e3089f893137.tar.xz yuzu-bf2ddb8fd5feaeaf2806fe102de8e3089f893137.zip | |
Merge pull request #3677 from FernandoS27/better-sync
Introduce Predictive Flushing and Improve ASYNC GPU
Diffstat (limited to 'src/video_core/gpu_thread.cpp')
| -rw-r--r-- | src/video_core/gpu_thread.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 10cda686b..c3bb4fe06 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/microprofile.h" | 6 | #include "common/microprofile.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/frontend/emu_window.h" | 8 | #include "core/frontend/emu_window.h" |
| 9 | #include "core/settings.h" | ||
| 9 | #include "video_core/dma_pusher.h" | 10 | #include "video_core/dma_pusher.h" |
| 10 | #include "video_core/gpu.h" | 11 | #include "video_core/gpu.h" |
| 11 | #include "video_core/gpu_thread.h" | 12 | #include "video_core/gpu_thread.h" |
| @@ -14,8 +15,9 @@ | |||
| 14 | namespace VideoCommon::GPUThread { | 15 | namespace VideoCommon::GPUThread { |
| 15 | 16 | ||
| 16 | /// Runs the GPU thread | 17 | /// Runs the GPU thread |
| 17 | static void RunThread(VideoCore::RendererBase& renderer, Core::Frontend::GraphicsContext& context, | 18 | static void RunThread(Core::System& system, VideoCore::RendererBase& renderer, |
| 18 | Tegra::DmaPusher& dma_pusher, SynchState& state) { | 19 | Core::Frontend::GraphicsContext& context, Tegra::DmaPusher& dma_pusher, |
| 20 | SynchState& state) { | ||
| 19 | MicroProfileOnThreadCreate("GpuThread"); | 21 | MicroProfileOnThreadCreate("GpuThread"); |
| 20 | 22 | ||
| 21 | // Wait for first GPU command before acquiring the window context | 23 | // Wait for first GPU command before acquiring the window context |
| @@ -37,10 +39,14 @@ static void RunThread(VideoCore::RendererBase& renderer, Core::Frontend::Graphic | |||
| 37 | dma_pusher.DispatchCalls(); | 39 | dma_pusher.DispatchCalls(); |
| 38 | } else if (const auto data = std::get_if<SwapBuffersCommand>(&next.data)) { | 40 | } else if (const auto data = std::get_if<SwapBuffersCommand>(&next.data)) { |
| 39 | renderer.SwapBuffers(data->framebuffer ? &*data->framebuffer : nullptr); | 41 | renderer.SwapBuffers(data->framebuffer ? &*data->framebuffer : nullptr); |
| 42 | } else if (const auto data = std::get_if<OnCommandListEndCommand>(&next.data)) { | ||
| 43 | renderer.Rasterizer().ReleaseFences(); | ||
| 44 | } else if (const auto data = std::get_if<GPUTickCommand>(&next.data)) { | ||
| 45 | system.GPU().TickWork(); | ||
| 40 | } else if (const auto data = std::get_if<FlushRegionCommand>(&next.data)) { | 46 | } else if (const auto data = std::get_if<FlushRegionCommand>(&next.data)) { |
| 41 | renderer.Rasterizer().FlushRegion(data->addr, data->size); | 47 | renderer.Rasterizer().FlushRegion(data->addr, data->size); |
| 42 | } else if (const auto data = std::get_if<InvalidateRegionCommand>(&next.data)) { | 48 | } else if (const auto data = std::get_if<InvalidateRegionCommand>(&next.data)) { |
| 43 | renderer.Rasterizer().InvalidateRegion(data->addr, data->size); | 49 | renderer.Rasterizer().OnCPUWrite(data->addr, data->size); |
| 44 | } else if (std::holds_alternative<EndProcessingCommand>(next.data)) { | 50 | } else if (std::holds_alternative<EndProcessingCommand>(next.data)) { |
| 45 | return; | 51 | return; |
| 46 | } else { | 52 | } else { |
| @@ -65,8 +71,8 @@ ThreadManager::~ThreadManager() { | |||
| 65 | void ThreadManager::StartThread(VideoCore::RendererBase& renderer, | 71 | void ThreadManager::StartThread(VideoCore::RendererBase& renderer, |
| 66 | Core::Frontend::GraphicsContext& context, | 72 | Core::Frontend::GraphicsContext& context, |
| 67 | Tegra::DmaPusher& dma_pusher) { | 73 | Tegra::DmaPusher& dma_pusher) { |
| 68 | thread = std::thread{RunThread, std::ref(renderer), std::ref(context), std::ref(dma_pusher), | 74 | thread = std::thread{RunThread, std::ref(system), std::ref(renderer), |
| 69 | std::ref(state)}; | 75 | std::ref(context), std::ref(dma_pusher), std::ref(state)}; |
| 70 | } | 76 | } |
| 71 | 77 | ||
| 72 | void ThreadManager::SubmitList(Tegra::CommandList&& entries) { | 78 | void ThreadManager::SubmitList(Tegra::CommandList&& entries) { |
| @@ -78,16 +84,29 @@ void ThreadManager::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { | |||
| 78 | } | 84 | } |
| 79 | 85 | ||
| 80 | void ThreadManager::FlushRegion(VAddr addr, u64 size) { | 86 | void ThreadManager::FlushRegion(VAddr addr, u64 size) { |
| 81 | PushCommand(FlushRegionCommand(addr, size)); | 87 | if (!Settings::IsGPULevelHigh()) { |
| 88 | PushCommand(FlushRegionCommand(addr, size)); | ||
| 89 | return; | ||
| 90 | } | ||
| 91 | if (!Settings::IsGPULevelExtreme()) { | ||
| 92 | return; | ||
| 93 | } | ||
| 94 | if (system.Renderer().Rasterizer().MustFlushRegion(addr, size)) { | ||
| 95 | auto& gpu = system.GPU(); | ||
| 96 | u64 fence = gpu.RequestFlush(addr, size); | ||
| 97 | PushCommand(GPUTickCommand()); | ||
| 98 | while (fence > gpu.CurrentFlushRequestFence()) { | ||
| 99 | } | ||
| 100 | } | ||
| 82 | } | 101 | } |
| 83 | 102 | ||
| 84 | void ThreadManager::InvalidateRegion(VAddr addr, u64 size) { | 103 | void ThreadManager::InvalidateRegion(VAddr addr, u64 size) { |
| 85 | system.Renderer().Rasterizer().InvalidateRegion(addr, size); | 104 | system.Renderer().Rasterizer().OnCPUWrite(addr, size); |
| 86 | } | 105 | } |
| 87 | 106 | ||
| 88 | void ThreadManager::FlushAndInvalidateRegion(VAddr addr, u64 size) { | 107 | void ThreadManager::FlushAndInvalidateRegion(VAddr addr, u64 size) { |
| 89 | // Skip flush on asynch mode, as FlushAndInvalidateRegion is not used for anything too important | 108 | // Skip flush on asynch mode, as FlushAndInvalidateRegion is not used for anything too important |
| 90 | InvalidateRegion(addr, size); | 109 | system.Renderer().Rasterizer().OnCPUWrite(addr, size); |
| 91 | } | 110 | } |
| 92 | 111 | ||
| 93 | void ThreadManager::WaitIdle() const { | 112 | void ThreadManager::WaitIdle() const { |
| @@ -95,6 +114,10 @@ void ThreadManager::WaitIdle() const { | |||
| 95 | } | 114 | } |
| 96 | } | 115 | } |
| 97 | 116 | ||
| 117 | void ThreadManager::OnCommandListEnd() { | ||
| 118 | PushCommand(OnCommandListEndCommand()); | ||
| 119 | } | ||
| 120 | |||
| 98 | u64 ThreadManager::PushCommand(CommandData&& command_data) { | 121 | u64 ThreadManager::PushCommand(CommandData&& command_data) { |
| 99 | const u64 fence{++state.last_fence}; | 122 | const u64 fence{++state.last_fence}; |
| 100 | state.queue.Push(CommandDataContainer(std::move(command_data), fence)); | 123 | state.queue.Push(CommandDataContainer(std::move(command_data), fence)); |