diff options
| author | 2019-04-25 20:10:20 -0300 | |
|---|---|---|
| committer | 2019-05-20 22:46:05 -0300 | |
| commit | 69215b5a550ef8b2f3a2854bc99af03bcd31a6c7 (patch) | |
| tree | b0519d6d9e27177bfd537aad462f34c88bdc4823 | |
| parent | gl_shader_cache: Use shared contexts to build shaders in parallel (diff) | |
| download | yuzu-69215b5a550ef8b2f3a2854bc99af03bcd31a6c7.tar.gz yuzu-69215b5a550ef8b2f3a2854bc99af03bcd31a6c7.tar.xz yuzu-69215b5a550ef8b2f3a2854bc99af03bcd31a6c7.zip | |
gl_shader_cache: Fix clang strict standard build issues
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.h | 7 |
3 files changed, 13 insertions, 9 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 9d3f96f9c..7ee1c99c0 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -382,7 +382,8 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, | |||
| 382 | std::atomic_bool compilation_failed = false; | 382 | std::atomic_bool compilation_failed = false; |
| 383 | 383 | ||
| 384 | const auto Worker = [&](Core::Frontend::GraphicsContext* context, std::size_t begin, | 384 | const auto Worker = [&](Core::Frontend::GraphicsContext* context, std::size_t begin, |
| 385 | std::size_t end) { | 385 | std::size_t end, const std::vector<ShaderDiskCacheUsage>& shader_usages, |
| 386 | const ShaderDumpsMap& dumps) { | ||
| 386 | context->MakeCurrent(); | 387 | context->MakeCurrent(); |
| 387 | SCOPE_EXIT({ return context->DoneCurrent(); }); | 388 | SCOPE_EXIT({ return context->DoneCurrent(); }); |
| 388 | 389 | ||
| @@ -422,7 +423,7 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, | |||
| 422 | } | 423 | } |
| 423 | }; | 424 | }; |
| 424 | 425 | ||
| 425 | const std::size_t num_workers{std::thread::hardware_concurrency() + 1}; | 426 | const auto num_workers{static_cast<std::size_t>(std::thread::hardware_concurrency() + 1)}; |
| 426 | const std::size_t bucket_size{shader_usages.size() / num_workers}; | 427 | const std::size_t bucket_size{shader_usages.size() / num_workers}; |
| 427 | std::vector<std::unique_ptr<Core::Frontend::GraphicsContext>> contexts(num_workers); | 428 | std::vector<std::unique_ptr<Core::Frontend::GraphicsContext>> contexts(num_workers); |
| 428 | std::vector<std::thread> threads(num_workers); | 429 | std::vector<std::thread> threads(num_workers); |
| @@ -433,7 +434,7 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, | |||
| 433 | 434 | ||
| 434 | // On some platforms the shared context has to be created from the GUI thread | 435 | // On some platforms the shared context has to be created from the GUI thread |
| 435 | contexts[i] = emu_window.CreateSharedContext(); | 436 | contexts[i] = emu_window.CreateSharedContext(); |
| 436 | threads[i] = std::thread(Worker, contexts[i].get(), start, end); | 437 | threads[i] = std::thread(Worker, contexts[i].get(), start, end, shader_usages, dumps); |
| 437 | } | 438 | } |
| 438 | for (auto& thread : threads) { | 439 | for (auto& thread : threads) { |
| 439 | thread.join(); | 440 | thread.join(); |
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp index fba9c594a..ee4a45ca2 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | |||
| @@ -183,8 +183,7 @@ ShaderDiskCacheOpenGL::LoadTransferable() { | |||
| 183 | return {{raws, usages}}; | 183 | return {{raws, usages}}; |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, | 186 | std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, ShaderDumpsMap> |
| 187 | std::unordered_map<ShaderDiskCacheUsage, ShaderDiskCacheDump>> | ||
| 188 | ShaderDiskCacheOpenGL::LoadPrecompiled() { | 187 | ShaderDiskCacheOpenGL::LoadPrecompiled() { |
| 189 | if (!IsUsable()) | 188 | if (!IsUsable()) |
| 190 | return {}; | 189 | return {}; |
| @@ -208,8 +207,7 @@ ShaderDiskCacheOpenGL::LoadPrecompiled() { | |||
| 208 | return *result; | 207 | return *result; |
| 209 | } | 208 | } |
| 210 | 209 | ||
| 211 | std::optional<std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, | 210 | std::optional<std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, ShaderDumpsMap>> |
| 212 | std::unordered_map<ShaderDiskCacheUsage, ShaderDiskCacheDump>>> | ||
| 213 | ShaderDiskCacheOpenGL::LoadPrecompiledFile(FileUtil::IOFile& file) { | 211 | ShaderDiskCacheOpenGL::LoadPrecompiledFile(FileUtil::IOFile& file) { |
| 214 | // Read compressed file from disk and decompress to virtual precompiled cache file | 212 | // Read compressed file from disk and decompress to virtual precompiled cache file |
| 215 | std::vector<u8> compressed(file.GetSize()); | 213 | std::vector<u8> compressed(file.GetSize()); |
| @@ -230,7 +228,7 @@ ShaderDiskCacheOpenGL::LoadPrecompiledFile(FileUtil::IOFile& file) { | |||
| 230 | } | 228 | } |
| 231 | 229 | ||
| 232 | std::unordered_map<u64, ShaderDiskCacheDecompiled> decompiled; | 230 | std::unordered_map<u64, ShaderDiskCacheDecompiled> decompiled; |
| 233 | std::unordered_map<ShaderDiskCacheUsage, ShaderDiskCacheDump> dumps; | 231 | ShaderDumpsMap dumps; |
| 234 | while (precompiled_cache_virtual_file_offset < precompiled_cache_virtual_file.GetSize()) { | 232 | while (precompiled_cache_virtual_file_offset < precompiled_cache_virtual_file.GetSize()) { |
| 235 | PrecompiledEntryKind kind{}; | 233 | PrecompiledEntryKind kind{}; |
| 236 | if (!LoadObjectFromPrecompiled(kind)) { | 234 | if (!LoadObjectFromPrecompiled(kind)) { |
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.h b/src/video_core/renderer_opengl/gl_shader_disk_cache.h index 2da0a4a23..ecd72ba58 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h | |||
| @@ -33,6 +33,11 @@ namespace OpenGL { | |||
| 33 | using ProgramCode = std::vector<u64>; | 33 | using ProgramCode = std::vector<u64>; |
| 34 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; | 34 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; |
| 35 | 35 | ||
| 36 | struct ShaderDiskCacheUsage; | ||
| 37 | struct ShaderDiskCacheDump; | ||
| 38 | |||
| 39 | using ShaderDumpsMap = std::unordered_map<ShaderDiskCacheUsage, ShaderDiskCacheDump>; | ||
| 40 | |||
| 36 | /// Allocated bindings used by an OpenGL shader program | 41 | /// Allocated bindings used by an OpenGL shader program |
| 37 | struct BaseBindings { | 42 | struct BaseBindings { |
| 38 | u32 cbuf{}; | 43 | u32 cbuf{}; |
| @@ -294,4 +299,4 @@ private: | |||
| 294 | bool tried_to_load{}; | 299 | bool tried_to_load{}; |
| 295 | }; | 300 | }; |
| 296 | 301 | ||
| 297 | } // namespace OpenGL \ No newline at end of file | 302 | } // namespace OpenGL |