Skip to content

Commit 7748784

Browse files
committed
Clean up code
1 parent dd568de commit 7748784

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

examples/09-depth/generic_depth_addon.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1163,25 +1163,25 @@ static void draw_settings_overlay(effect_runtime *runtime)
11631163
{
11641164
bool force_reset = false;
11651165

1166-
const char *const draw_stats_heuristics_items[] = {
1166+
const char *const draw_stats_heuristic_items[] = {
11671167
"Default",
11681168
"Higher vertices",
11691169
"Higher draw calls"
11701170
};
1171-
if (ImGui::Combo("Draw stats heuristic", reinterpret_cast<int *>(&s_draw_stats_heuristic), draw_stats_heuristics_items, static_cast<int>(std::size(draw_stats_heuristics_items))))
1171+
if (ImGui::Combo("Draw stats heuristic", reinterpret_cast<int *>(&s_draw_stats_heuristic), draw_stats_heuristic_items, static_cast<int>(std::size(draw_stats_heuristic_items))))
11721172
{
11731173
reshade::set_config_value(nullptr, "DEPTH", "DrawStatsHeuristic", static_cast<unsigned int>(s_draw_stats_heuristic));
11741174
force_reset = true;
11751175
}
11761176

1177-
const char *const aspect_ratio_heuristics_items[] = {
1177+
const char *const aspect_ratio_heuristic_items[] = {
11781178
"None",
11791179
"Similar aspect ratio",
11801180
"Multiples of resolution (for DLSS or resolution scaling)",
11811181
"Match resolution exactly",
11821182
"Match custom width and height exactly"
11831183
};
1184-
if (ImGui::Combo("Aspect ratio heuristic", reinterpret_cast<int *>(&s_aspect_ratio_heuristic), aspect_ratio_heuristics_items, static_cast<int>(std::size(aspect_ratio_heuristics_items))))
1184+
if (ImGui::Combo("Aspect ratio heuristic", reinterpret_cast<int *>(&s_aspect_ratio_heuristic), aspect_ratio_heuristic_items, static_cast<int>(std::size(aspect_ratio_heuristic_items))))
11851185
{
11861186
reshade::set_config_value(nullptr, "DEPTH", "UseAspectRatioHeuristics", static_cast<unsigned int>(s_aspect_ratio_heuristic));
11871187
force_reset = true;

include/reshade_api.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ namespace reshade { namespace api
510510
/// Binds new shader resource views to all texture variables that use the specified <paramref name="semantic"/>.
511511
/// </summary>
512512
/// <remarks>
513-
/// The resource the shader resource views point to has to be in the <see cref="resource_usage::shader_resource"/> state at the time <see cref="render_effects"/> is executed.
513+
/// The resource the shader resource views point to has to be in the <see cref="resource_usage::shader_resource"/> state at the time <see cref="render_effects"/> or <see cref="render_technique"/> is executed.
514514
/// </remarks>
515515
/// <param name="semantic">ReShade FX semantic to filter textures to update by (<c>texture name : SEMANTIC</c>).</param>
516516
/// <param name="srv">Shader resource view to use for samplers with <c>SRGBTexture</c> state set to <see langword="false"/> (this should be a shader resource view of the target resource, created with a non-sRGB format variant).</param>

source/input.cpp

+6-20
Original file line numberDiff line numberDiff line change
@@ -942,13 +942,12 @@ extern "C" HHOOK WINAPI HookSetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTAN
942942
reshade::log::message(reshade::log::level::info, "Redirecting SetWindowsHookExA(idHook = %d, lpfn = %p, hmod = %p, dwThreadId = %lu) ...", idHook, lpfn, hmod, dwThreadId);
943943
#endif
944944

945-
HHOOK *hook = nullptr;
945+
HOOKPROC orig_hook_proc = lpfn;
946946
const UINT64 thread_lookup_key = dwThreadId | (static_cast<UINT64>(idHook) << 32);
947947

948948
if (const auto it = s_windows_hooks.find(thread_lookup_key);
949949
it == s_windows_hooks.end() || it->second.first == nullptr)
950950
{
951-
HOOKPROC orig_hook_proc = lpfn;
952951
switch (idHook)
953952
{
954953
case WH_MOUSE:
@@ -964,12 +963,6 @@ extern "C" HHOOK WINAPI HookSetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTAN
964963
lpfn = &handle_windows_hook<WH_KEYBOARD_LL, reshade::input::is_blocking_any_keyboard_input>;
965964
break;
966965
}
967-
968-
if (orig_hook_proc != lpfn)
969-
{
970-
s_windows_hooks[thread_lookup_key] = std::make_pair(nullptr, orig_hook_proc);
971-
hook = &s_windows_hooks[thread_lookup_key].first;
972-
}
973966
}
974967
else
975968
{
@@ -981,13 +974,13 @@ extern "C" HHOOK WINAPI HookSetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTAN
981974
static const auto trampoline = reshade::hooks::call(HookSetWindowsHookExA);
982975
const HHOOK result = trampoline(idHook, lpfn, hmod, dwThreadId);
983976

984-
if (hook != nullptr)
977+
if (result != nullptr && lpfn != orig_hook_proc)
985978
{
986979
#if RESHADE_VERBOSE_LOG
987980
reshade::log::message(reshade::log::level::info, "Windows hook function of type %d registered for thread %lu.", idHook, dwThreadId);
988981
#endif
989982

990-
*hook = result;
983+
s_windows_hooks[thread_lookup_key] = std::make_pair(result, orig_hook_proc);
991984
}
992985

993986
return result;
@@ -998,13 +991,12 @@ extern "C" HHOOK WINAPI HookSetWindowsHookExW(int idHook, HOOKPROC lpfn, HINSTAN
998991
reshade::log::message(reshade::log::level::info, "Redirecting SetWindowsHookExW(idHook = %d, lpfn = %p, hmod = %p, dwThreadId = %lu) ...", idHook, lpfn, hmod, dwThreadId);
999992
#endif
1000993

1001-
HHOOK *hook = nullptr;
994+
HOOKPROC orig_hook_proc = lpfn;
1002995
const UINT64 thread_lookup_key = dwThreadId | (static_cast<UINT64>(idHook) << 32);
1003996

1004997
if (const auto it = s_windows_hooks.find(thread_lookup_key);
1005998
it == s_windows_hooks.end() || it->second.first == nullptr)
1006999
{
1007-
HOOKPROC orig_hook_proc = lpfn;
10081000
switch (idHook)
10091001
{
10101002
case WH_MOUSE:
@@ -1020,12 +1012,6 @@ extern "C" HHOOK WINAPI HookSetWindowsHookExW(int idHook, HOOKPROC lpfn, HINSTAN
10201012
lpfn = &handle_windows_hook<WH_KEYBOARD_LL, reshade::input::is_blocking_any_keyboard_input>;
10211013
break;
10221014
}
1023-
1024-
if (orig_hook_proc != lpfn)
1025-
{
1026-
s_windows_hooks[thread_lookup_key] = std::make_pair(nullptr, orig_hook_proc);
1027-
hook = &s_windows_hooks[thread_lookup_key].first;
1028-
}
10291015
}
10301016
else
10311017
{
@@ -1037,13 +1023,13 @@ extern "C" HHOOK WINAPI HookSetWindowsHookExW(int idHook, HOOKPROC lpfn, HINSTAN
10371023
static const auto trampoline = reshade::hooks::call(HookSetWindowsHookExW);
10381024
const HHOOK result = trampoline(idHook, lpfn, hmod, dwThreadId);
10391025

1040-
if (hook != nullptr)
1026+
if (result != nullptr && lpfn != orig_hook_proc)
10411027
{
10421028
#if RESHADE_VERBOSE_LOG
10431029
reshade::log::message(reshade::log::level::info, "Windows hook function of type %d registered for thread %lu.", idHook, dwThreadId);
10441030
#endif
10451031

1046-
*hook = result;
1032+
s_windows_hooks[thread_lookup_key] = std::make_pair(result, orig_hook_proc);
10471033
}
10481034

10491035
return result;

0 commit comments

Comments
 (0)