diff --git a/OptiScaler/nvapi/fakenvapi/fakenvapi.cpp b/OptiScaler/nvapi/fakenvapi/fakenvapi.cpp index c293c6d7..e4b27f8f 100644 --- a/OptiScaler/nvapi/fakenvapi/fakenvapi.cpp +++ b/OptiScaler/nvapi/fakenvapi/fakenvapi.cpp @@ -3,38 +3,40 @@ namespace nvd { NvAPI_Status __cdecl NvAPI_Initialize() { - IDXGIFactory1* pFactory = nullptr; - if (FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory))) { - spdlog::error("Failed to create DXGI Factory"); - return Error(); - } + if (!deviceId) { + IDXGIFactory1* pFactory = nullptr; + if (FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory))) { + spdlog::error("Failed to create DXGI Factory"); + return Error(); + } - IDXGIAdapter1* pAdapter = nullptr; - if (FAILED(pFactory->EnumAdapters1(0, &pAdapter))) { - spdlog::error("Failed to enumerate adapters"); - pFactory->Release(); - return Error(); - } + IDXGIAdapter1* pAdapter = nullptr; + if (FAILED(pFactory->EnumAdapters1(0, &pAdapter))) { + spdlog::error("Failed to enumerate adapters"); + pFactory->Release(); + return Error(); + } + + DXGI_ADAPTER_DESC1 adapterDesc; + if (FAILED(pAdapter->GetDesc1(&adapterDesc))) { + spdlog::error("Failed to get adapter description"); + pAdapter->Release(); + pFactory->Release(); + return Error(); + } + + luid = adapterDesc.AdapterLuid; + deviceId = adapterDesc.DeviceId; + vendorId = adapterDesc.VendorId; + subSysId = adapterDesc.SubSysId; + revisionId = adapterDesc.Revision; - DXGI_ADAPTER_DESC1 adapterDesc; - if (FAILED(pAdapter->GetDesc1(&adapterDesc))) { - spdlog::error("Failed to get adapter description"); pAdapter->Release(); pFactory->Release(); - return Error(); + + lowlatency_ctx.init_lfx(); } - luid = adapterDesc.AdapterLuid; - deviceId = adapterDesc.DeviceId; - vendorId = adapterDesc.VendorId; - subSysId = adapterDesc.SubSysId; - revisionId = adapterDesc.Revision; - - pAdapter->Release(); - pFactory->Release(); - - lowlatency_ctx.init_lfx(); - return Ok(); } diff --git a/OptiScaler/nvapi/fakenvapi/fakenvapi.h b/OptiScaler/nvapi/fakenvapi/fakenvapi.h index cab5a125..fc8349f1 100644 --- a/OptiScaler/nvapi/fakenvapi/fakenvapi.h +++ b/OptiScaler/nvapi/fakenvapi/fakenvapi.h @@ -23,11 +23,11 @@ namespace nvd { static auto drsSession = reinterpret_cast(&drs); static auto drsProfile = reinterpret_cast(&drs); - static LUID luid; - static UINT deviceId; - static UINT vendorId; - static UINT subSysId; - static UINT revisionId; + static LUID luid = {}; + static UINT deviceId = {}; + static UINT vendorId = {}; + static UINT subSysId = {}; + static UINT revisionId = {}; static LowLatency lowlatency_ctx; diff --git a/OptiScaler/nvapi/fakenvapi/log.cpp b/OptiScaler/nvapi/fakenvapi/log.cpp index 6b530ecf..b4b5ceb9 100644 --- a/OptiScaler/nvapi/fakenvapi/log.cpp +++ b/OptiScaler/nvapi/fakenvapi/log.cpp @@ -23,8 +23,8 @@ NvAPI_Status Error(NvAPI_Status status, const std::source_location& location) { void prepareLogging(spdlog::level::level_enum level) { try { if (level != spdlog::level::off) { - auto logger = spdlog::basic_logger_mt("basic_logger", "fakenvapi.log"); - spdlog::set_default_logger(logger); + auto logger = spdlog::basic_logger_mt("basic_logger", "fakenvapi.log", true); + spdlog::set_default_logger(std::move(logger)); if (level == spdlog::level::trace) spdlog::set_pattern("[%H:%M:%S.%f] [%L] [thread %t] %v"); else diff --git a/OptiScaler/nvapi/fakenvapi/main.cpp b/OptiScaler/nvapi/fakenvapi/main.cpp index aa57c66e..2fbbcf94 100755 --- a/OptiScaler/nvapi/fakenvapi/main.cpp +++ b/OptiScaler/nvapi/fakenvapi/main.cpp @@ -18,11 +18,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: - if (get_config(L"fakenvapi", L"enable_log", false)) - prepareLogging(spdlog::level::trace); + if (get_config(L"fakenvapi", L"enable_logs", true)) + if (get_config(L"fakenvapi", L"enable_trace_logs", false)) + prepareLogging(spdlog::level::trace); + else + prepareLogging(spdlog::level::info); else prepareLogging(spdlog::level::off); - spdlog::critical("----------------"); break; case DLL_PROCESS_DETACH: closeLogging();