Merge pull request #5244 from lioncash/move3

gl_shader_manager: std::move std::string where applicable
This commit is contained in:
Sebastian Valle 2020-04-19 21:48:15 -05:00 committed by GitHub
commit 1469ad339c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -229,7 +229,7 @@ public:
return {cached_shader.GetHandle(), result}; return {cached_shader.GetHandle(), result};
} }
void Inject(const KeyConfigType& key, std::string decomp, OGLProgram&& program) { void Inject(const KeyConfigType& key, OGLProgram&& program) {
OGLShaderStage stage{separable}; OGLShaderStage stage{separable};
stage.Inject(std::move(program)); stage.Inject(std::move(program));
shaders.emplace(key, std::move(stage)); shaders.emplace(key, std::move(stage));
@ -284,9 +284,9 @@ public:
void Inject(const KeyConfigType& key, std::string decomp, OGLProgram&& program) { void Inject(const KeyConfigType& key, std::string decomp, OGLProgram&& program) {
OGLShaderStage stage{separable}; OGLShaderStage stage{separable};
stage.Inject(std::move(program)); stage.Inject(std::move(program));
auto [iter, new_shader] = shader_cache.emplace(decomp, std::move(stage)); const auto iter = shader_cache.emplace(std::move(decomp), std::move(stage)).first;
OGLShaderStage& cached_shader = iter->second; OGLShaderStage& cached_shader = iter->second;
shader_map[key] = &cached_shader; shader_map.insert_or_assign(key, &cached_shader);
} }
private: private:
@ -518,8 +518,7 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading,
} else if (raw.GetProgramType() == ProgramType::FS) { } else if (raw.GetProgramType() == ProgramType::FS) {
PicaFSConfig conf = PicaFSConfig::BuildFromRegs(raw.GetRawShaderConfig()); PicaFSConfig conf = PicaFSConfig::BuildFromRegs(raw.GetRawShaderConfig());
std::scoped_lock lock(mutex); std::scoped_lock lock(mutex);
impl->fragment_shaders.Inject(conf, decomp->second.result.code, impl->fragment_shaders.Inject(conf, std::move(shader));
std::move(shader));
} else { } else {
// Unsupported shader type got stored somehow so nuke the cache // Unsupported shader type got stored somehow so nuke the cache