From 7d4eb4e03bb48c498f5b8f49e329bbcb2bd413ed Mon Sep 17 00:00:00 2001 From: crosire Date: Mon, 19 Dec 2022 00:44:14 +0100 Subject: [PATCH] Make it possible to prevent effect rendering altogether by calling "render_effects" with no render target view --- source/runtime.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/source/runtime.cpp b/source/runtime.cpp index f26f7a2c4d..feec0f68ef 100644 --- a/source/runtime.cpp +++ b/source/runtime.cpp @@ -3364,27 +3364,15 @@ void reshade::runtime::update_effects() void reshade::runtime::render_effects(api::command_list *cmd_list, api::resource_view rtv, api::resource_view rtv_srgb) { // Cannot render effects twice in a frame or while they are still loading - if (is_loading() || _effects_rendered_this_frame || rtv == 0) + if (is_loading() || _effects_rendered_this_frame) return; _effects_rendered_this_frame = true; - if (rtv_srgb == 0) - rtv_srgb = rtv; - // Nothing to do here if effects are disabled globally if (!_effects_enabled || _techniques.empty()) return; - const api::resource back_buffer_resource = _device->get_resource_from_view(rtv); - -#if RESHADE_ADDON - // Ensure format of the effect color resource matches that of the input back buffer resource (so that the copy to the effect color resource succeeds) - // TODO: Technically would need to recompile effects as well to update 'BUFFER_COLOR_BIT_DEPTH' etc. - if (!_is_in_present_call && !update_effect_color_tex(_device->get_resource_desc(back_buffer_resource).texture.format)) - return; -#endif - #ifdef NDEBUG // Lock input so it cannot be modified by other threads while we are reading it here // TODO: This does not catch input happening between now and 'on_present' @@ -3613,6 +3601,20 @@ void reshade::runtime::render_effects(api::command_list *cmd_list, api::resource } } + if (rtv == 0) + return; + if (rtv_srgb == 0) + rtv_srgb = rtv; + + const api::resource back_buffer_resource = _device->get_resource_from_view(rtv); + +#if RESHADE_ADDON + // Ensure format of the effect color resource matches that of the input back buffer resource (so that the copy to the effect color resource succeeds) + // TODO: Technically would need to recompile effects as well to update 'BUFFER_COLOR_BIT_DEPTH' etc. + if (!_is_in_present_call && !update_effect_color_tex(_device->get_resource_desc(back_buffer_resource).texture.format)) + return; +#endif + #if RESHADE_ADDON invoke_addon_event(this, cmd_list, rtv, rtv_srgb); #endif