mirror of
https://github.com/citra-emu/citra-nightly.git
synced 2024-12-26 12:55:37 +00:00
gl_shader_manager: std::move std::string where applicable
Prevents unnecessary copies from occurring. In the case of ShaderCache, we can just remove the parameter, given it's unused.
This commit is contained in:
parent
397bd1bb73
commit
c72d9b806b
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue