Skip to content

Commit

Permalink
Merge branch 'SpecialKO:main' into latent-sync-adaptive-tearing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nustat0 authored Nov 25, 2024
2 parents 9565438 + f1c36db commit 8960ab0
Show file tree
Hide file tree
Showing 53 changed files with 2,951 additions and 1,469 deletions.
101 changes: 97 additions & 4 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,112 @@
24.11.17.3
24.11.25
========
+ Disable the option to clear Flip Model backbuffers on present by default,
because it prevents OBS Game Capture in some (D3D11) scenarios.

24.11.24.2
==========
+ Allow moving windows to different monitors by dragging without triggering
SK's monitor-change message (causes games to maximize the game window).

24.11.24.1
==========
+ Fixed accidentally using ImGuiKey_MouseLeft to index the ImGuiIO::MouseDown
array (which only has 5 buttons; the value of ImGuiKey_MouseLeft is 653!)
* It should have been ImGuiIO::AddMouseButtonEvent (ImGuiKey_MouseLeft,...).
>> This relatively new bug only affected games w/ (Low-Level) Mouse Hooks...

+ Ignore mouse button capture when the mouse cursor is over a non-client part
of a game window (i.e. title bar or resize grips).
+ Disengage the "confine cursor" option temporarily while a game window has
been grabbed and is inside of the "size/move" modal loop, so that the
window can actually be resized or repositioned without interference.

24.11.24
========
+ Unload plug-in DLLs at game exit _before_ uninstalling all hooked functions.
+ Add plug-in DLL names to the unload log entires during game shutdown.
+ Run each plug-in unload attempt within its own exception handler and
continue unloading remaining plug-ins if there is an exception.

24.11.23.2
==========
+ Fixed the issue in 24.11.23.1 the correct way :) The staging copy of the
backbuffer needs to be enqueued, the reference to the backbuffer released,
and the command queue flushed immediately and then there are no chances
for the swapchain backbuffers to have outstanding references.

24.11.23.1
==========
+ Fixed D3D11 screenshots occasionally causing display mode changes to fail if
a (Blt Model) game requested a mode change within 500-ms of the last screen
capture.

24.11.23
========
+ Cleaned-up Mouse Cursor section of Input Control Panel and removed the old
"Low-Level Mouse Settings" section.

+ Auto-Bluetooth Compatibility now only powers off PlayStation controllers
that have advanced Bluetooth mode active if SK has seen the game attempt
to poll input using WinMM or DirectInput 7/8 at least one time first.

# Controllers start in "simple" Bluetooth mode when initially powered on,
which is a mode compatible with DirectInput and WinMM.

>> Prior to this change, it could cause an endless loop of the controller
powering off, Steam Input re-initializing the controller in advanced
Bluetooth mode when powered back on, and then SK turning it back off!

* It is a niche feature that is more likely to be accidentally enabled by
users not completely familiar with its purpose than the chances of
playing a game that requires it.

24.11.22
========
+ Update ReShade Add-on API headers to include new events in the next release.
+ Reduce unnecessary WM_NCHITTEST messages sent to games when the cursor is not
even moving.

24.11.21
========
+ Enable Fake Fullscreen mode by default in STALKER 2, because it uses that
crap (in D3D12) for HDR... yay!

24.11.20
========
+ Fixed only a single monitor being listed in the Display menu.
+ Added measures to prevent various ATLUS ports from moving the game window
back to the primary monitor whenever HDR is enabled/disabled or resolution
changes (they handle WM_DISPLAYCHANGE and WM_MOVE weirdly).

24.11.19
========
+ Restored support for using D3D11 Render Mod Tools in games with multiple
deferred contexts to debug shaders when ReShade is active.

24.11.18
========
+ Disable SteamAPI file hash checks on Fallout 4
+ Handle window activation more explicitly in Metaphor Re:Fantazio so that
its Keyboard Hook does not capture input events when the window is not
focused.

24.11.16.3
==========
+ Fixed various problems indicated by static analysis...

24.11.17.2
24.11.16.2
==========
+ Fixed problems with SK not re-initializing D3D11 when the active SwapChain
is destroyed and re-created.
+ Fixed potential issues with loading ReShade as a plug-in and config files
not correctly being passed to create_effect_runtime (...).

24.11.17.1
24.11.16.1
==========
+ Implement Lossy scRGB->HDR10 Quantization the correct way :)

24.11.17
24.11.16
========
+ Added texture sampling fixes for Metaphor: ReFantazio so that it actually
can make use of anisotropic filtering, instead of setting MaxAnisotropy
Expand Down
9 changes: 9 additions & 0 deletions SpecialK.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,15 @@ if exist "$(TargetDir)$(TargetName).exp" ( del "$(TargetDir)$(TargetName).exp" )
<ClInclude Include="depends\include\nvapi\nvHLSLExtns.h" />
<ClInclude Include="depends\include\nvapi\nvHLSLExtnsInternal.h" />
<ClInclude Include="depends\include\nvapi\nvShaderExtnEnums.h" />
<ClInclude Include="depends\include\ReShade\reshade.hpp" />
<ClInclude Include="depends\include\ReShade\reshade_api.hpp" />
<ClInclude Include="depends\include\ReShade\reshade_api_device.hpp" />
<ClInclude Include="depends\include\ReShade\reshade_api_display.hpp" />
<ClInclude Include="depends\include\ReShade\reshade_api_format.hpp" />
<ClInclude Include="depends\include\ReShade\reshade_api_pipeline.hpp" />
<ClInclude Include="depends\include\ReShade\reshade_api_resource.hpp" />
<ClInclude Include="depends\include\ReShade\reshade_events.hpp" />
<ClInclude Include="depends\include\ReShade\reshade_overlay.hpp" />
<ClInclude Include="depends\include\steamapi\isteamapplist.h" />
<ClInclude Include="depends\include\steamapi\isteamapps.h" />
<ClInclude Include="depends\include\steamapi\isteamappticket.h" />
Expand Down
96 changes: 58 additions & 38 deletions depends/include/ReShade/reshade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#pragma once

#define RESHADE_NO_IMGUI

#include "reshade_events.hpp"
#include "reshade_overlay.hpp"
#include <charconv>
Expand All @@ -29,15 +31,20 @@ RESHADE_API_LIBRARY_DECL void ReShadeGetBasePath(char *path, size_t *path_size);

RESHADE_API_LIBRARY_DECL bool ReShadeGetConfigValue(HMODULE module, reshade::api::effect_runtime *runtime, const char *section, const char *key, char *value, size_t *value_size);
RESHADE_API_LIBRARY_DECL void ReShadeSetConfigValue(HMODULE module, reshade::api::effect_runtime *runtime, const char *section, const char *key, const char *value);
RESHADE_API_LIBRARY_DECL void ReShadeSetConfigArray(HMODULE module, reshade::api::effect_runtime *runtime, const char *section, const char *key, const char *value, size_t value_size);

RESHADE_API_LIBRARY_DECL bool ReShadeRegisterAddon(HMODULE module, uint32_t api_version);
RESHADE_API_LIBRARY_DECL void ReShadeUnregisterAddon(HMODULE module);

RESHADE_API_LIBRARY_DECL void ReShadeRegisterEvent(reshade::addon_event ev, void *callback);
RESHADE_API_LIBRARY_DECL void ReShadeRegisterEventForAddon(HMODULE module, reshade::addon_event ev, void *callback);
RESHADE_API_LIBRARY_DECL void ReShadeUnregisterEvent(reshade::addon_event ev, void *callback);
RESHADE_API_LIBRARY_DECL void ReShadeUnregisterEventForAddon(HMODULE module, reshade::addon_event ev, void *callback);

RESHADE_API_LIBRARY_DECL void ReShadeRegisterOverlay(const char *title, void(*callback)(reshade::api::effect_runtime *runtime));
RESHADE_API_LIBRARY_DECL void ReShadeRegisterOverlayForAddon(HMODULE module, const char *title, void(*callback)(reshade::api::effect_runtime *runtime));
RESHADE_API_LIBRARY_DECL void ReShadeUnregisterOverlay(const char *title, void(*callback)(reshade::api::effect_runtime *runtime));
RESHADE_API_LIBRARY_DECL void ReShadeUnregisterOverlayForAddon(HMODULE module, const char *title, void(*callback)(reshade::api::effect_runtime *runtime));

RESHADE_API_LIBRARY_DECL bool ReShadeCreateEffectRuntime(reshade::api::device_api api, void *opaque_device, void *opaque_command_queue, void *opaque_swapchain, const char *config_path, reshade::api::effect_runtime **out_runtime);
RESHADE_API_LIBRARY_DECL void ReShadeDestroyEffectRuntime(reshade::api::effect_runtime *runtime);
Expand All @@ -53,9 +60,9 @@ namespace reshade { namespace internal
/// <summary>
/// Gets the handle to the ReShade module.
/// </summary>
inline HMODULE get_reshade_module_handle(HMODULE reshade_module = nullptr)
inline HMODULE get_reshade_module_handle(HMODULE initial_handle = nullptr)
{
static HMODULE handle = reshade_module;
static HMODULE handle = initial_handle;
if (handle == nullptr)
{
HMODULE modules[1024]; DWORD num = 0;
Expand All @@ -81,13 +88,12 @@ namespace reshade { namespace internal
/// <summary>
/// Gets the handle to the current add-on module.
/// </summary>
inline HMODULE get_current_module_handle(HMODULE addon_module = nullptr)
inline HMODULE get_current_module_handle(HMODULE initial_handle = nullptr)
{
static HMODULE handle = addon_module;
static HMODULE handle = initial_handle;
return handle;
}

inline BOOL has_addon(const wchar_t* name)
inline BOOL has_addon(const wchar_t* name)
{
if (name == nullptr)
return FALSE;
Expand Down Expand Up @@ -118,44 +124,49 @@ namespace reshade { namespace internal

namespace reshade
{
/// <summary>
/// Available log severity levels.
/// </summary>
enum class log_level
#if !defined(RESHADE_API_LIBRARY_EXPORT) || defined(BUILTIN_ADDON)
namespace log
{
/// <summary>
/// | [ERROR] | ...
/// </summary>
error = 1,
/// <summary>
/// | [WARN] | ...
/// Severity levels for logging.
/// </summary>
warning = 2,
/// <summary>
/// | [INFO] | ...
/// </summary>
info = 3,
enum class level
{
/// <summary>
/// | ERROR | ...
/// </summary>
error = 1,
/// <summary>
/// | WARN | ...
/// </summary>
warning = 2,
/// <summary>
/// | INFO | ...
/// </summary>
info = 3,
/// <summary>
/// | DEBUG | ...
/// </summary>
debug = 4,
};

/// <summary>
/// | [DEBUG] | ...
/// Writes a message to ReShade's log.
/// </summary>
debug = 4
};

/// <summary>
/// Writes a message to ReShade's log.
/// </summary>
/// <param name="level">Severity level.</param>
/// <param name="message">A null-terminated message string.</param>
inline void log_message(log_level level, const char *message)
{
/// <param name="level">Severity level.</param>
/// <param name="message">A null-terminated message string.</param>
inline void message(level level, const char *message)
{
#if defined(RESHADE_API_LIBRARY)
ReShadeLogMessage(nullptr, static_cast<int>(level), message);
ReShadeLogMessage(nullptr, static_cast<int>(level), message);
#else
static const auto func = reinterpret_cast<void(*)(HMODULE, int, const char *)>(
GetProcAddress(internal::get_reshade_module_handle(), "ReShadeLogMessage"));
func(internal::get_current_module_handle(), static_cast<int>(level), message);
static const auto func = reinterpret_cast<void(*)(HMODULE, int, const char *)>(
GetProcAddress(internal::get_reshade_module_handle(), "ReShadeLogMessage"));
func(internal::get_current_module_handle(), static_cast<int>(level), message);
#endif
}
}
#endif

/// <summary>
/// Gets the base path ReShade uses to resolve relative paths.
Expand Down Expand Up @@ -245,6 +256,16 @@ namespace reshade
set_config_value<int>(runtime, section, key, value ? 1 : 0);
}
#endif
inline void set_config_value(api::effect_runtime *runtime, const char *section, const char *key, const char *value, size_t value_size)
{
#if defined(RESHADE_API_LIBRARY)
ReShadeSetConfigArray(nullptr, runtime, section, key, value, value_size);
#else
static const auto func = reinterpret_cast<void(*)(HMODULE, api::effect_runtime *, const char *, const char *, const char *, size_t)>(
GetProcAddress(internal::get_reshade_module_handle(), "ReShadeSetConfigArray"));
func(internal::get_current_module_handle(), runtime, section, key, value, value_size);
#endif
}

/// <summary>
/// Registers this module as an add-on with ReShade.
Expand All @@ -268,14 +289,13 @@ namespace reshade
// Check that the ReShade module supports the used API
if (func == nullptr || !func(addon_module, RESHADE_API_VERSION))
return false;
#if 0
#if defined(IMGUI_VERSION_NUM)

#if defined(IMGUI_VERSION_NUM) && !defined(RESHADE_NO_IMGUI)
const auto imgui_func = reinterpret_cast<const imgui_function_table *(*)(uint32_t)>(
GetProcAddress(reshade_module, "ReShadeGetImGuiFunctionTable"));
// Check that the ReShade module was built with Dear ImGui support and supports the used version
if (imgui_func == nullptr || !(imgui_function_table_instance() = imgui_func(IMGUI_VERSION_NUM)))
return false;
#endif
#endif

return true;
Expand Down
Loading

0 comments on commit 8960ab0

Please sign in to comment.