diff options
| author | 2019-01-21 16:38:23 -0300 | |
|---|---|---|
| committer | 2019-02-06 22:23:40 -0300 | |
| commit | eb7324743372d3b94db9a915a5508d8293d45ecb (patch) | |
| tree | 085261558efeb2b47ce5316b52314980005b3e5c /src | |
| parent | gl_shader_cache: Set GL_PROGRAM_SEPARABLE to dumped shaders (diff) | |
| download | yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.tar.gz yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.tar.xz yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.zip | |
gl_shader_cache: Link loading screen with disk shader cache load
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/rasterizer_interface.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 29 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.h | 5 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 9 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 8 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 3 |
10 files changed, 62 insertions, 12 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 1d71312aa..1dd576c26 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -176,8 +176,6 @@ struct System::Impl { | |||
| 176 | static_cast<u32>(load_result)); | 176 | static_cast<u32>(load_result)); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | renderer->Rasterizer().LoadDiskResources(); | ||
| 180 | |||
| 181 | status = ResultStatus::Success; | 179 | status = ResultStatus::Success; |
| 182 | return status; | 180 | return status; |
| 183 | } | 181 | } |
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index bb4bc0e36..77da135a0 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <atomic> | ||
| 7 | #include <functional> | 8 | #include <functional> |
| 8 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 9 | #include "video_core/engines/fermi_2d.h" | 10 | #include "video_core/engines/fermi_2d.h" |
| @@ -63,6 +64,7 @@ public: | |||
| 63 | virtual void UpdatePagesCachedCount(Tegra::GPUVAddr addr, u64 size, int delta) {} | 64 | virtual void UpdatePagesCachedCount(Tegra::GPUVAddr addr, u64 size, int delta) {} |
| 64 | 65 | ||
| 65 | /// Initialize disk cached resources for the game being emulated | 66 | /// Initialize disk cached resources for the game being emulated |
| 66 | virtual void LoadDiskResources() {} | 67 | virtual void LoadDiskResources(const std::atomic_bool& stop_loading = false, |
| 68 | const DiskResourceLoadCallback& callback = {}) {} | ||
| 67 | }; | 69 | }; |
| 68 | } // namespace VideoCore | 70 | } // namespace VideoCore |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 94a5058de..974ca6a20 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -449,7 +449,7 @@ static constexpr auto RangeFromInterval(Map& map, const Interval& interval) { | |||
| 449 | return boost::make_iterator_range(map.equal_range(interval)); | 449 | return boost::make_iterator_range(map.equal_range(interval)); |
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | void RasterizerOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { | 452 | void RasterizerOpenGL::UpdatePagesCachedCount(Tegra::GPUVAddr addr, u64 size, int delta) { |
| 453 | const u64 page_start{addr >> Memory::PAGE_BITS}; | 453 | const u64 page_start{addr >> Memory::PAGE_BITS}; |
| 454 | const u64 page_end{(addr + size + Memory::PAGE_SIZE - 1) >> Memory::PAGE_BITS}; | 454 | const u64 page_end{(addr + size + Memory::PAGE_SIZE - 1) >> Memory::PAGE_BITS}; |
| 455 | 455 | ||
| @@ -479,8 +479,9 @@ void RasterizerOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { | |||
| 479 | cached_pages.add({pages_interval, delta}); | 479 | cached_pages.add({pages_interval, delta}); |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | void RasterizerOpenGL::LoadDiskResources() { | 482 | void RasterizerOpenGL::LoadDiskResources(const std::atomic_bool& stop_loading, |
| 483 | shader_cache.LoadDiskCache(); | 483 | const VideoCore::DiskResourceLoadCallback& callback) { |
| 484 | shader_cache.LoadDiskCache(stop_loading, callback); | ||
| 484 | } | 485 | } |
| 485 | 486 | ||
| 486 | std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers( | 487 | std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers( |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index ebabf80d1..f3b607f4d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <atomic> | ||
| 8 | #include <cstddef> | 9 | #include <cstddef> |
| 9 | #include <map> | 10 | #include <map> |
| 10 | #include <memory> | 11 | #include <memory> |
| @@ -65,7 +66,8 @@ public: | |||
| 65 | u32 pixel_stride) override; | 66 | u32 pixel_stride) override; |
| 66 | bool AccelerateDrawBatch(bool is_indexed) override; | 67 | bool AccelerateDrawBatch(bool is_indexed) override; |
| 67 | void UpdatePagesCachedCount(Tegra::GPUVAddr addr, u64 size, int delta) override; | 68 | void UpdatePagesCachedCount(Tegra::GPUVAddr addr, u64 size, int delta) override; |
| 68 | void LoadDiskResources() override; | 69 | void LoadDiskResources(const std::atomic_bool& stop_loading, |
| 70 | const VideoCore::DiskResourceLoadCallback& callback) override; | ||
| 69 | 71 | ||
| 70 | /// Maximum supported size that a constbuffer can have in bytes. | 72 | /// Maximum supported size that a constbuffer can have in bytes. |
| 71 | static constexpr std::size_t MaxConstbufferSize = 0x10000; | 73 | static constexpr std::size_t MaxConstbufferSize = 0x10000; |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 7eeae082a..e0e624e6f 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -345,7 +345,8 @@ ShaderDiskCacheUsage CachedShader::GetUsage(GLenum primitive_mode, | |||
| 345 | ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system) | 345 | ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system) |
| 346 | : RasterizerCache{rasterizer}, disk_cache{system} {} | 346 | : RasterizerCache{rasterizer}, disk_cache{system} {} |
| 347 | 347 | ||
| 348 | void ShaderCacheOpenGL::LoadDiskCache() { | 348 | void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, |
| 349 | const VideoCore::DiskResourceLoadCallback& callback) { | ||
| 349 | const auto transferable = disk_cache.LoadTransferable(); | 350 | const auto transferable = disk_cache.LoadTransferable(); |
| 350 | if (!transferable) { | 351 | if (!transferable) { |
| 351 | return; | 352 | return; |
| @@ -355,10 +356,18 @@ void ShaderCacheOpenGL::LoadDiskCache() { | |||
| 355 | auto [decompiled, dumps] = disk_cache.LoadPrecompiled(); | 356 | auto [decompiled, dumps] = disk_cache.LoadPrecompiled(); |
| 356 | 357 | ||
| 357 | const auto supported_formats{GetSupportedFormats()}; | 358 | const auto supported_formats{GetSupportedFormats()}; |
| 358 | const auto unspecialized{GenerateUnspecializedShaders(raws, decompiled)}; | 359 | const auto unspecialized{ |
| 360 | GenerateUnspecializedShaders(stop_loading, callback, raws, decompiled)}; | ||
| 361 | if (stop_loading) | ||
| 362 | return; | ||
| 359 | 363 | ||
| 360 | // Build shaders | 364 | // Build shaders |
| 365 | if (callback) | ||
| 366 | callback(VideoCore::LoadCallbackStage::Build, 0, usages.size()); | ||
| 361 | for (std::size_t i = 0; i < usages.size(); ++i) { | 367 | for (std::size_t i = 0; i < usages.size(); ++i) { |
| 368 | if (stop_loading) | ||
| 369 | return; | ||
| 370 | |||
| 362 | const auto& usage{usages[i]}; | 371 | const auto& usage{usages[i]}; |
| 363 | LOG_INFO(Render_OpenGL, "Building shader {:016x} ({} of {})", usage.unique_identifier, | 372 | LOG_INFO(Render_OpenGL, "Building shader {:016x} ({} of {})", usage.unique_identifier, |
| 364 | i + 1, usages.size()); | 373 | i + 1, usages.size()); |
| @@ -381,6 +390,9 @@ void ShaderCacheOpenGL::LoadDiskCache() { | |||
| 381 | usage.bindings, usage.primitive, true); | 390 | usage.bindings, usage.primitive, true); |
| 382 | } | 391 | } |
| 383 | precompiled_programs.insert({usage, std::move(shader)}); | 392 | precompiled_programs.insert({usage, std::move(shader)}); |
| 393 | |||
| 394 | if (callback) | ||
| 395 | callback(VideoCore::LoadCallbackStage::Build, i + 1, usages.size()); | ||
| 384 | } | 396 | } |
| 385 | 397 | ||
| 386 | // TODO(Rodrigo): Do state tracking for transferable shaders and do a dummy draw before | 398 | // TODO(Rodrigo): Do state tracking for transferable shaders and do a dummy draw before |
| @@ -420,11 +432,19 @@ CachedProgram ShaderCacheOpenGL::GeneratePrecompiledProgram( | |||
| 420 | } | 432 | } |
| 421 | 433 | ||
| 422 | std::map<u64, UnspecializedShader> ShaderCacheOpenGL::GenerateUnspecializedShaders( | 434 | std::map<u64, UnspecializedShader> ShaderCacheOpenGL::GenerateUnspecializedShaders( |
| 435 | const std::atomic_bool& stop_loading, const VideoCore::DiskResourceLoadCallback& callback, | ||
| 423 | const std::vector<ShaderDiskCacheRaw>& raws, | 436 | const std::vector<ShaderDiskCacheRaw>& raws, |
| 424 | const std::map<u64, ShaderDiskCacheDecompiled>& decompiled) { | 437 | const std::map<u64, ShaderDiskCacheDecompiled>& decompiled) { |
| 425 | std::map<u64, UnspecializedShader> unspecialized; | 438 | std::map<u64, UnspecializedShader> unspecialized; |
| 426 | 439 | ||
| 427 | for (const auto& raw : raws) { | 440 | if (callback) |
| 441 | callback(VideoCore::LoadCallbackStage::Decompile, 0, raws.size()); | ||
| 442 | |||
| 443 | for (std::size_t i = 0; i < raws.size(); ++i) { | ||
| 444 | if (stop_loading) | ||
| 445 | return {}; | ||
| 446 | |||
| 447 | const auto& raw{raws[i]}; | ||
| 428 | const u64 unique_identifier = raw.GetUniqueIdentifier(); | 448 | const u64 unique_identifier = raw.GetUniqueIdentifier(); |
| 429 | const u64 calculated_hash = | 449 | const u64 calculated_hash = |
| 430 | GetUniqueIdentifier(raw.GetProgramType(), raw.GetProgramCode(), raw.GetProgramCodeB()); | 450 | GetUniqueIdentifier(raw.GetProgramType(), raw.GetProgramCode(), raw.GetProgramCodeB()); |
| @@ -454,6 +474,9 @@ std::map<u64, UnspecializedShader> ShaderCacheOpenGL::GenerateUnspecializedShade | |||
| 454 | unspecialized.insert( | 474 | unspecialized.insert( |
| 455 | {raw.GetUniqueIdentifier(), | 475 | {raw.GetUniqueIdentifier(), |
| 456 | {std::move(result.first), std::move(result.second), raw.GetProgramType()}}); | 476 | {std::move(result.first), std::move(result.second), raw.GetProgramType()}}); |
| 477 | |||
| 478 | if (callback) | ||
| 479 | callback(VideoCore::LoadCallbackStage::Decompile, i, raws.size()); | ||
| 457 | } | 480 | } |
| 458 | return unspecialized; | 481 | return unspecialized; |
| 459 | } | 482 | } |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index 6914127c3..9c6b19fc3 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "common/assert.h" | 15 | #include "common/assert.h" |
| 16 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 17 | #include "video_core/rasterizer_cache.h" | 17 | #include "video_core/rasterizer_cache.h" |
| 18 | #include "video_core/renderer_base.h" | ||
| 18 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 19 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 19 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" | 20 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" |
| 20 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" | 21 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" |
| @@ -114,13 +115,15 @@ public: | |||
| 114 | explicit ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system); | 115 | explicit ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system); |
| 115 | 116 | ||
| 116 | /// Loads disk cache for the current game | 117 | /// Loads disk cache for the current game |
| 117 | void LoadDiskCache(); | 118 | void LoadDiskCache(const std::atomic_bool& stop_loading, |
| 119 | const VideoCore::DiskResourceLoadCallback& callback); | ||
| 118 | 120 | ||
| 119 | /// Gets the current specified shader stage program | 121 | /// Gets the current specified shader stage program |
| 120 | Shader GetStageProgram(Maxwell::ShaderProgram program); | 122 | Shader GetStageProgram(Maxwell::ShaderProgram program); |
| 121 | 123 | ||
| 122 | private: | 124 | private: |
| 123 | std::map<u64, UnspecializedShader> GenerateUnspecializedShaders( | 125 | std::map<u64, UnspecializedShader> GenerateUnspecializedShaders( |
| 126 | const std::atomic_bool& stop_loading, const VideoCore::DiskResourceLoadCallback& callback, | ||
| 124 | const std::vector<ShaderDiskCacheRaw>& raws, | 127 | const std::vector<ShaderDiskCacheRaw>& raws, |
| 125 | const std::map<u64, ShaderDiskCacheDecompiled>& decompiled); | 128 | const std::map<u64, ShaderDiskCacheDecompiled>& decompiled); |
| 126 | 129 | ||
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index f74cb693a..73b04b749 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -29,6 +29,15 @@ void EmuThread::run() { | |||
| 29 | 29 | ||
| 30 | stop_run = false; | 30 | stop_run = false; |
| 31 | 31 | ||
| 32 | emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); | ||
| 33 | |||
| 34 | Core::System::GetInstance().Renderer().Rasterizer().LoadDiskResources( | ||
| 35 | stop_run, [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { | ||
| 36 | emit LoadProgress(stage, value, total); | ||
| 37 | }); | ||
| 38 | |||
| 39 | emit LoadProgress(VideoCore::LoadCallbackStage::Complete, 0, 0); | ||
| 40 | |||
| 32 | // holds whether the cpu was running during the last iteration, | 41 | // holds whether the cpu was running during the last iteration, |
| 33 | // so that the DebugModeLeft signal can be emitted before the | 42 | // so that the DebugModeLeft signal can be emitted before the |
| 34 | // next execution step | 43 | // next execution step |
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index d1f37e503..7226e690e 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -22,6 +22,10 @@ class GGLWidgetInternal; | |||
| 22 | class GMainWindow; | 22 | class GMainWindow; |
| 23 | class GRenderWindow; | 23 | class GRenderWindow; |
| 24 | 24 | ||
| 25 | namespace VideoCore { | ||
| 26 | enum class LoadCallbackStage; | ||
| 27 | } | ||
| 28 | |||
| 25 | class EmuThread : public QThread { | 29 | class EmuThread : public QThread { |
| 26 | Q_OBJECT | 30 | Q_OBJECT |
| 27 | 31 | ||
| @@ -75,7 +79,7 @@ public: | |||
| 75 | private: | 79 | private: |
| 76 | bool exec_step = false; | 80 | bool exec_step = false; |
| 77 | bool running = false; | 81 | bool running = false; |
| 78 | std::atomic<bool> stop_run{false}; | 82 | std::atomic_bool stop_run{false}; |
| 79 | std::mutex running_mutex; | 83 | std::mutex running_mutex; |
| 80 | std::condition_variable running_cv; | 84 | std::condition_variable running_cv; |
| 81 | 85 | ||
| @@ -101,6 +105,8 @@ signals: | |||
| 101 | void DebugModeLeft(); | 105 | void DebugModeLeft(); |
| 102 | 106 | ||
| 103 | void ErrorThrown(Core::System::ResultStatus, std::string); | 107 | void ErrorThrown(Core::System::ResultStatus, std::string); |
| 108 | |||
| 109 | void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); | ||
| 104 | }; | 110 | }; |
| 105 | 111 | ||
| 106 | class GRenderWindow : public QWidget, public Core::Frontend::EmuWindow { | 112 | class GRenderWindow : public QWidget, public Core::Frontend::EmuWindow { |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 485e29de2..1d460c189 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -887,6 +887,9 @@ void GMainWindow::BootGame(const QString& filename) { | |||
| 887 | connect(emu_thread.get(), &EmuThread::DebugModeLeft, waitTreeWidget, | 887 | connect(emu_thread.get(), &EmuThread::DebugModeLeft, waitTreeWidget, |
| 888 | &WaitTreeWidget::OnDebugModeLeft, Qt::BlockingQueuedConnection); | 888 | &WaitTreeWidget::OnDebugModeLeft, Qt::BlockingQueuedConnection); |
| 889 | 889 | ||
| 890 | connect(emu_thread.get(), &EmuThread::LoadProgress, loading_screen, | ||
| 891 | &LoadingScreen::OnLoadProgress, Qt::QueuedConnection); | ||
| 892 | |||
| 890 | // Update the GUI | 893 | // Update the GUI |
| 891 | if (ui.action_Single_Window_Mode->isChecked()) { | 894 | if (ui.action_Single_Window_Mode->isChecked()) { |
| 892 | game_list->hide(); | 895 | game_list->hide(); |
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 806127b12..c34b5467f 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include "core/loader/loader.h" | 28 | #include "core/loader/loader.h" |
| 29 | #include "core/settings.h" | 29 | #include "core/settings.h" |
| 30 | #include "core/telemetry_session.h" | 30 | #include "core/telemetry_session.h" |
| 31 | #include "video_core/renderer_base.h" | ||
| 31 | #include "yuzu_cmd/config.h" | 32 | #include "yuzu_cmd/config.h" |
| 32 | #include "yuzu_cmd/emu_window/emu_window_sdl2.h" | 33 | #include "yuzu_cmd/emu_window/emu_window_sdl2.h" |
| 33 | 34 | ||
| @@ -217,6 +218,8 @@ int main(int argc, char** argv) { | |||
| 217 | 218 | ||
| 218 | Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); | 219 | Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); |
| 219 | 220 | ||
| 221 | system.Renderer().Rasterizer().LoadDiskResources(); | ||
| 222 | |||
| 220 | while (emu_window->IsOpen()) { | 223 | while (emu_window->IsOpen()) { |
| 221 | system.RunLoop(); | 224 | system.RunLoop(); |
| 222 | } | 225 | } |