diff options
| author | 2019-05-30 13:55:11 -0300 | |
|---|---|---|
| committer | 2019-05-30 13:56:03 -0300 | |
| commit | 838b6d2ff891573a612547a1e85d2bc1c541a66d (patch) | |
| tree | 4f41b545d3f58c667e977155d32674612a2f1f57 /src | |
| parent | Merge pull request #2446 from ReinUsesLisp/tid (diff) | |
| download | yuzu-838b6d2ff891573a612547a1e85d2bc1c541a66d.tar.gz yuzu-838b6d2ff891573a612547a1e85d2bc1c541a66d.tar.xz yuzu-838b6d2ff891573a612547a1e85d2bc1c541a66d.zip | |
gl_shader_cache: Flip if condition in GetStageProgram to reduce indentation
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index d66252224..05a56f840 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -547,41 +547,42 @@ std::unordered_map<u64, UnspecializedShader> ShaderCacheOpenGL::GenerateUnspecia | |||
| 547 | 547 | ||
| 548 | Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) { | 548 | Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) { |
| 549 | if (!Core::System::GetInstance().GPU().Maxwell3D().dirty_flags.shaders) { | 549 | if (!Core::System::GetInstance().GPU().Maxwell3D().dirty_flags.shaders) { |
| 550 | return last_shaders[static_cast<u32>(program)]; | 550 | return last_shaders[static_cast<std::size_t>(program)]; |
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | auto& memory_manager{Core::System::GetInstance().GPU().MemoryManager()}; | 553 | auto& memory_manager{Core::System::GetInstance().GPU().MemoryManager()}; |
| 554 | const GPUVAddr program_addr{GetShaderAddress(program)}; | 554 | const GPUVAddr program_addr{GetShaderAddress(program)}; |
| 555 | 555 | ||
| 556 | // Look up shader in the cache based on address | 556 | // Look up shader in the cache based on address |
| 557 | const auto& host_ptr{memory_manager.GetPointer(program_addr)}; | 557 | const auto host_ptr{memory_manager.GetPointer(program_addr)}; |
| 558 | Shader shader{TryGet(host_ptr)}; | 558 | Shader shader{TryGet(host_ptr)}; |
| 559 | if (shader) { | ||
| 560 | return last_shaders[static_cast<std::size_t>(program)] = shader; | ||
| 561 | } | ||
| 559 | 562 | ||
| 560 | if (!shader) { | 563 | // No shader found - create a new one |
| 561 | // No shader found - create a new one | 564 | ProgramCode program_code{GetShaderCode(memory_manager, program_addr, host_ptr)}; |
| 562 | ProgramCode program_code{GetShaderCode(memory_manager, program_addr, host_ptr)}; | 565 | ProgramCode program_code_b; |
| 563 | ProgramCode program_code_b; | 566 | if (program == Maxwell::ShaderProgram::VertexA) { |
| 564 | if (program == Maxwell::ShaderProgram::VertexA) { | 567 | const GPUVAddr program_addr_b{GetShaderAddress(Maxwell::ShaderProgram::VertexB)}; |
| 565 | const GPUVAddr program_addr_b{GetShaderAddress(Maxwell::ShaderProgram::VertexB)}; | 568 | program_code_b = GetShaderCode(memory_manager, program_addr_b, |
| 566 | program_code_b = GetShaderCode(memory_manager, program_addr_b, | 569 | memory_manager.GetPointer(program_addr_b)); |
| 567 | memory_manager.GetPointer(program_addr_b)); | 570 | } |
| 568 | } | 571 | |
| 569 | const u64 unique_identifier = GetUniqueIdentifier(program, program_code, program_code_b); | 572 | const u64 unique_identifier = GetUniqueIdentifier(program, program_code, program_code_b); |
| 570 | const VAddr cpu_addr{*memory_manager.GpuToCpuAddress(program_addr)}; | 573 | const VAddr cpu_addr{*memory_manager.GpuToCpuAddress(program_addr)}; |
| 571 | const auto found = precompiled_shaders.find(unique_identifier); | 574 | const auto found = precompiled_shaders.find(unique_identifier); |
| 572 | if (found != precompiled_shaders.end()) { | 575 | if (found != precompiled_shaders.end()) { |
| 573 | shader = | 576 | shader = std::make_shared<CachedShader>(cpu_addr, unique_identifier, program, disk_cache, |
| 574 | std::make_shared<CachedShader>(cpu_addr, unique_identifier, program, disk_cache, | 577 | precompiled_programs, found->second, host_ptr); |
| 575 | precompiled_programs, found->second, host_ptr); | 578 | } else { |
| 576 | } else { | 579 | shader = std::make_shared<CachedShader>( |
| 577 | shader = std::make_shared<CachedShader>( | 580 | device, cpu_addr, unique_identifier, program, disk_cache, precompiled_programs, |
| 578 | device, cpu_addr, unique_identifier, program, disk_cache, precompiled_programs, | 581 | std::move(program_code), std::move(program_code_b), host_ptr); |
| 579 | std::move(program_code), std::move(program_code_b), host_ptr); | ||
| 580 | } | ||
| 581 | Register(shader); | ||
| 582 | } | 582 | } |
| 583 | Register(shader); | ||
| 583 | 584 | ||
| 584 | return last_shaders[static_cast<u32>(program)] = shader; | 585 | return last_shaders[static_cast<std::size_t>(program)] = shader; |
| 585 | } | 586 | } |
| 586 | 587 | ||
| 587 | } // namespace OpenGL | 588 | } // namespace OpenGL |