mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 23:00:42 -07:00
sdvx: implement NVAPI for non-NVIDIA GPUs (#816)
## Link to GitHub Issue or related Pull Request, if one exists n/a ## Description of change In summary: for SDVX VM mode, this PR eliminates the need for `Note FPS Target 120Hz` / `Game FPS Target 120Hz` patches typically used for AMD GPU via synthetic responses provided via a fake NVAPI layer. Before this change, playing on AMD GPU required patches to force the game to render at 60Hz (See #107 for relevant discussion). Basically, if NVAPI query fails, the game shows `I:NvDisplayConfig: GetMainDisplayRefreshRate = 60.000hz (DUMMY)` the game renders at 120Hz but the notes render at 60Hz, which would look stuttery. After this change, even without a real `nvapi64.dll`, spice will provide a stub implementation, just enough to convince the game that the main display is 120Hz, which causes notes to render at 120Hz as well. This can be overridden by `-graphics-force-refresh` option. Important note: if user has the `Note FPS Target 60Hz` patch but running the game at 120Hz, before this change the notes would render at 60Hz, but after this they will be at 120Hz. I don't know why anyone would intentionally lower the notes framerate, so this is not going to be fixed. If the user wants to run the game at 60Hz they can do so via `-graphics-force-refresh`. Another change - `-nonvapi` will always force down this synthetic nvapi path, even if the system has the real `nvapi64.dll`. Even on NVDIA GPU this option can be used to force this. ## Testing
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#include "hooks/graphics/graphics.h"
|
||||
#include "hooks/devicehook.h"
|
||||
#include "hooks/libraryhook.h"
|
||||
#ifdef SPICE64
|
||||
#include "hooks/graphics/nvapi_impl.h"
|
||||
#endif
|
||||
#include "hooks/graphics/nvapi_hook.h"
|
||||
#include "hooks/powrprof.h"
|
||||
#include "hooks/sleephook.h"
|
||||
@@ -428,11 +431,24 @@ namespace games::sdvx {
|
||||
if (aio != nullptr) {
|
||||
|
||||
// enable 9on12 for AMD
|
||||
if (!libutils::try_library("nvapi64.dll")) {
|
||||
const auto nvapi = libutils::try_library("nvapi64.dll");
|
||||
if (nvapi == nullptr) {
|
||||
log_info(
|
||||
"sdvx",
|
||||
"nvapi64.dll not found; for non-NVIDIA GPUs, requesting 9on12 to be enabled");
|
||||
GRAPHICS_9_ON_12_REQUESTED_BY_GAME = true;
|
||||
}
|
||||
|
||||
if (nvapi_hook::BYPASS_NVAPI || nvapi == nullptr) {
|
||||
const uint32_t main_refresh_hz = GRAPHICS_FORCE_REFRESH > 0 ?
|
||||
GRAPHICS_FORCE_REFRESH : (is_valkyrie_model() ? 120 : 60);
|
||||
const uint32_t sub_refresh_hz = GRAPHICS_FORCE_REFRESH_SUB.value_or(60);
|
||||
if (!nvapi_impl::initialize(
|
||||
avs::game::DLL_INSTANCE,
|
||||
main_refresh_hz,
|
||||
sub_refresh_hz)) {
|
||||
log_warning("sdvx", "failed to initialize synthetic NVAPI");
|
||||
}
|
||||
} else {
|
||||
// don't let nvapi mess with display settings
|
||||
nvapi_hook::initialize(avs::game::DLL_INSTANCE);
|
||||
|
||||
Reference in New Issue
Block a user