| 3547 | } |
| 3548 | |
| 3549 | void reshade::runtime::update_effects() |
| 3550 | { |
| 3551 | // Delay first load to the first render call to avoid loading while the application is still initializing |
| 3552 | if (_frame_count == 0 && !_no_reload_on_init) |
| 3553 | reload_effects(); |
| 3554 | |
| 3555 | if (!is_loading() && !_is_in_preset_transition && !_reload_required_effects.empty()) |
| 3556 | { |
| 3557 | _reload_remaining_effects = 0; |
| 3558 | |
| 3559 | // Sort list so that all default permutations are reloaded first (since that resets the entire effect), before other permutations |
| 3560 | std::sort(_reload_required_effects.begin(), _reload_required_effects.end(), |
| 3561 | [](const std::pair<size_t, size_t> &lhs, const std::pair<size_t, size_t> &rhs) { |
| 3562 | return lhs.second < rhs.second || (lhs.second == rhs.second && lhs.first < rhs.first); |
| 3563 | }); |
| 3564 | |
| 3565 | for (size_t i = 0; i < _reload_required_effects.size(); ++i) |
| 3566 | { |
| 3567 | const auto [effect_index, permutation_index] = _reload_required_effects[i]; |
| 3568 | |
| 3569 | if (effect_index >= _effects.size()) |
| 3570 | { |
| 3571 | reload_effects(); |
| 3572 | assert(_reload_required_effects.empty()); |
| 3573 | break; |
| 3574 | } |
| 3575 | |
| 3576 | if (permutation_index == 0) |
| 3577 | { |
| 3578 | if (!reload_effect(effect_index)) |
| 3579 | continue; |
| 3580 | } |
| 3581 | else |
| 3582 | { |
| 3583 | // This resize should only happen on the first non-default permutation, before launching threads that can access it |
| 3584 | if (_effects[effect_index].permutations.size() < _effect_permutations.size()) |
| 3585 | _effects[effect_index].permutations.resize(_effect_permutations.size()); |
| 3586 | |
| 3587 | _reload_remaining_effects += 1; |
| 3588 | |
| 3589 | _worker_threads.emplace_back([this, effect_index, permutation_index]() { |
| 3590 | load_effect(_effects[effect_index].source_file, ini_file::load_cache(_current_preset_path), effect_index, permutation_index, true); |
| 3591 | }); |
| 3592 | } |
| 3593 | |
| 3594 | // Force immediate effect initialization of this permutation after reloading |
| 3595 | // This can cause attempts to create an effect that failed to compile, so need to handle that case in 'create_effect' below |
| 3596 | if (std::find(_reload_create_queue.cbegin(), _reload_create_queue.cend(), _reload_required_effects[i]) == _reload_create_queue.cend()) |
| 3597 | _reload_create_queue.push_back(_reload_required_effects[i]); |
| 3598 | } |
| 3599 | |
| 3600 | _reload_required_effects.clear(); |
| 3601 | } |
| 3602 | |
| 3603 | if (_reload_remaining_effects == 0) |
| 3604 | { |
| 3605 | // Clear the thread list now that they all have finished |
| 3606 | for (std::thread &thread : _worker_threads) |
nothing calls this directly
no test coverage detected