summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-04-25 20:10:20 -0300
committerGravatar ReinUsesLisp2019-05-20 22:46:05 -0300
commit69215b5a550ef8b2f3a2854bc99af03bcd31a6c7 (patch)
treeb0519d6d9e27177bfd537aad462f34c88bdc4823
parentgl_shader_cache: Use shared contexts to build shaders in parallel (diff)
downloadyuzu-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.cpp7
-rw-r--r--src/video_core/renderer_opengl/gl_shader_disk_cache.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_shader_disk_cache.h7
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
186std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, 186std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, ShaderDumpsMap>
187 std::unordered_map<ShaderDiskCacheUsage, ShaderDiskCacheDump>>
188ShaderDiskCacheOpenGL::LoadPrecompiled() { 187ShaderDiskCacheOpenGL::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
211std::optional<std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, 210std::optional<std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, ShaderDumpsMap>>
212 std::unordered_map<ShaderDiskCacheUsage, ShaderDiskCacheDump>>>
213ShaderDiskCacheOpenGL::LoadPrecompiledFile(FileUtil::IOFile& file) { 211ShaderDiskCacheOpenGL::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 {
33using ProgramCode = std::vector<u64>; 33using ProgramCode = std::vector<u64>;
34using Maxwell = Tegra::Engines::Maxwell3D::Regs; 34using Maxwell = Tegra::Engines::Maxwell3D::Regs;
35 35
36struct ShaderDiskCacheUsage;
37struct ShaderDiskCacheDump;
38
39using 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
37struct BaseBindings { 42struct 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