forked from ShuriZma/suyu
gl_shader_cache: Flip if condition in GetStageProgram to reduce indentation
This commit is contained in:
parent
e3608578e4
commit
838b6d2ff8
|
@ -547,41 +547,42 @@ std::unordered_map<u64, UnspecializedShader> ShaderCacheOpenGL::GenerateUnspecia
|
||||||
|
|
||||||
Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
|
Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
|
||||||
if (!Core::System::GetInstance().GPU().Maxwell3D().dirty_flags.shaders) {
|
if (!Core::System::GetInstance().GPU().Maxwell3D().dirty_flags.shaders) {
|
||||||
return last_shaders[static_cast<u32>(program)];
|
return last_shaders[static_cast<std::size_t>(program)];
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& memory_manager{Core::System::GetInstance().GPU().MemoryManager()};
|
auto& memory_manager{Core::System::GetInstance().GPU().MemoryManager()};
|
||||||
const GPUVAddr program_addr{GetShaderAddress(program)};
|
const GPUVAddr program_addr{GetShaderAddress(program)};
|
||||||
|
|
||||||
// Look up shader in the cache based on address
|
// Look up shader in the cache based on address
|
||||||
const auto& host_ptr{memory_manager.GetPointer(program_addr)};
|
const auto host_ptr{memory_manager.GetPointer(program_addr)};
|
||||||
Shader shader{TryGet(host_ptr)};
|
Shader shader{TryGet(host_ptr)};
|
||||||
|
if (shader) {
|
||||||
if (!shader) {
|
return last_shaders[static_cast<std::size_t>(program)] = shader;
|
||||||
// No shader found - create a new one
|
|
||||||
ProgramCode program_code{GetShaderCode(memory_manager, program_addr, host_ptr)};
|
|
||||||
ProgramCode program_code_b;
|
|
||||||
if (program == Maxwell::ShaderProgram::VertexA) {
|
|
||||||
const GPUVAddr program_addr_b{GetShaderAddress(Maxwell::ShaderProgram::VertexB)};
|
|
||||||
program_code_b = GetShaderCode(memory_manager, program_addr_b,
|
|
||||||
memory_manager.GetPointer(program_addr_b));
|
|
||||||
}
|
|
||||||
const u64 unique_identifier = GetUniqueIdentifier(program, program_code, program_code_b);
|
|
||||||
const VAddr cpu_addr{*memory_manager.GpuToCpuAddress(program_addr)};
|
|
||||||
const auto found = precompiled_shaders.find(unique_identifier);
|
|
||||||
if (found != precompiled_shaders.end()) {
|
|
||||||
shader =
|
|
||||||
std::make_shared<CachedShader>(cpu_addr, unique_identifier, program, disk_cache,
|
|
||||||
precompiled_programs, found->second, host_ptr);
|
|
||||||
} else {
|
|
||||||
shader = std::make_shared<CachedShader>(
|
|
||||||
device, cpu_addr, unique_identifier, program, disk_cache, precompiled_programs,
|
|
||||||
std::move(program_code), std::move(program_code_b), host_ptr);
|
|
||||||
}
|
|
||||||
Register(shader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return last_shaders[static_cast<u32>(program)] = shader;
|
// No shader found - create a new one
|
||||||
|
ProgramCode program_code{GetShaderCode(memory_manager, program_addr, host_ptr)};
|
||||||
|
ProgramCode program_code_b;
|
||||||
|
if (program == Maxwell::ShaderProgram::VertexA) {
|
||||||
|
const GPUVAddr program_addr_b{GetShaderAddress(Maxwell::ShaderProgram::VertexB)};
|
||||||
|
program_code_b = GetShaderCode(memory_manager, program_addr_b,
|
||||||
|
memory_manager.GetPointer(program_addr_b));
|
||||||
|
}
|
||||||
|
|
||||||
|
const u64 unique_identifier = GetUniqueIdentifier(program, program_code, program_code_b);
|
||||||
|
const VAddr cpu_addr{*memory_manager.GpuToCpuAddress(program_addr)};
|
||||||
|
const auto found = precompiled_shaders.find(unique_identifier);
|
||||||
|
if (found != precompiled_shaders.end()) {
|
||||||
|
shader = std::make_shared<CachedShader>(cpu_addr, unique_identifier, program, disk_cache,
|
||||||
|
precompiled_programs, found->second, host_ptr);
|
||||||
|
} else {
|
||||||
|
shader = std::make_shared<CachedShader>(
|
||||||
|
device, cpu_addr, unique_identifier, program, disk_cache, precompiled_programs,
|
||||||
|
std::move(program_code), std::move(program_code_b), host_ptr);
|
||||||
|
}
|
||||||
|
Register(shader);
|
||||||
|
|
||||||
|
return last_shaders[static_cast<std::size_t>(program)] = shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
|
Loading…
Reference in New Issue