MCPcopy Create free account
hub / github.com/crosire/reshade / render_effects

Method render_effects

source/runtime.cpp:3691–3954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3689#endif
3690}
3691void reshade::runtime::render_effects(api::command_list *cmd_list, api::resource_view rtv, api::resource_view rtv_srgb)
3692{
3693 // Do not render effects twice in a frame
3694 if (_effects_rendered_this_frame)
3695 return;
3696 _effects_rendered_this_frame = true;
3697
3698 // Nothing to do here if effects are still loading or disabled globally
3699 if (is_loading() || _techniques.empty())
3700 return;
3701 if (!_effects_enabled && std::all_of(_effects.cbegin(), _effects.cend(), [](const effect &effect) { return !effect.addon; }))
3702 return;
3703
3704 // Lock input so it cannot be modified by other threads while we are reading it here
3705 std::unique_lock<std::recursive_mutex> input_lock;
3706 if (_input != nullptr
3707#if RESHADE_ADDON
3708 && !_is_in_present_call
3709#endif
3710 )
3711 input_lock = _input->lock();
3712
3713 // Update special uniform variables
3714 for (effect &effect : _effects)
3715 {
3716 if (!effect.rendering || (!_effects_enabled && !effect.addon))
3717 continue;
3718
3719 for (uniform &variable : effect.uniforms)
3720 {
3721 switch (variable.special)
3722 {
3723 case special_uniform::frame_time:
3724 set_uniform_value(variable, _last_frame_duration.count() * 1e-6f);
3725 break;
3726 case special_uniform::frame_count:
3727 if (variable.type.is_boolean())
3728 set_uniform_value(variable, (_frame_count % 2) == 0);
3729 else
3730 set_uniform_value(variable, static_cast<unsigned int>(_frame_count % UINT_MAX));
3731 break;
3732 case special_uniform::random:
3733 {
3734 const int min = variable.annotation_as_int("min", 0, 0);
3735 const int max = variable.annotation_as_int("max", 0, RAND_MAX);
3736 set_uniform_value(variable, min + (std::rand() % (std::abs(max - min) + 1)));
3737 }
3738 break;
3739 case special_uniform::ping_pong:
3740 {
3741 const float min = variable.annotation_as_float("min", 0, 0.0f);
3742 const float max = variable.annotation_as_float("max", 0, 1.0f);
3743 const float step_min = variable.annotation_as_float("step", 0);
3744 const float step_max = variable.annotation_as_float("step", 1);
3745 float increment = step_max == 0 ? step_min : (step_min + std::fmod(static_cast<float>(std::rand()), step_max - step_min + 1));
3746 const float smoothing = variable.annotation_as_float("smoothing");
3747
3748 float value[2] = { 0, 0 };

Callers 1

on_end_render_passFunction · 0.80

Calls 15

is_loadingFunction · 0.85
set_uniform_valueFunction · 0.85
format_to_typelessFunction · 0.85
lockMethod · 0.80
is_booleanMethod · 0.80
mouse_position_xMethod · 0.80
mouse_position_yMethod · 0.80
mouse_wheel_deltaMethod · 0.80
annotation_as_intMethod · 0.45
annotation_as_floatMethod · 0.45

Tested by

no test coverage detected