diff --git a/include/SpecialK/log.h b/include/SpecialK/log.h index 5a49f809e..4b80502d4 100644 --- a/include/SpecialK/log.h +++ b/include/SpecialK/log.h @@ -143,7 +143,7 @@ std::wstring __stdcall SK_SummarizeCaller (LPVOID lpReturnAddr = _ReturnAddress ()); -#define SK_LOG_CALL(source) { \ +#define SK_LOG_CALL(source) do { \ char szSymbol [1024] = { }; \ ULONG ulLen = 1024; \ \ @@ -158,16 +158,17 @@ SK_SummarizeCaller (LPVOID lpReturnAddr = _ReturnAddress ()); __FUNCTIONW__, \ SK_SummarizeCaller ().c_str () \ ); \ -} +} while (0) #define SK_ARGS(...) __VA_ARGS__ #define SK_STRIP_PARENTHESIS(X) X #define SK_VARIADIC(X) SK_STRIP_PARENTHESIS( SK_ARGS X ) -#define SK_LOG_EX(level,first,expr) \ - if (config.system.log_level >= (level)) \ - dll_log->LogEx (first, SK_VARIADIC (expr)) +#define SK_LOG_EX(level,first,expr) do { \ + if (config.system.log_level >= (level)) \ + dll_log->LogEx (first, SK_VARIADIC (expr)); \ +} while (0) #define SK_LOG0_EX(first,expr) SK_LOG_EX(0,first,expr) #define SK_LOG1_EX(first,expr) SK_LOG_EX(1,first,expr) @@ -175,10 +176,11 @@ SK_SummarizeCaller (LPVOID lpReturnAddr = _ReturnAddress ()); #define SK_LOG3_EX(first,expr) SK_LOG_EX(3,first,expr) #define SK_LOG4_EX(first,expr) SK_LOG_EX(4,first,expr) -#define SK_LOG(expr,level,source) \ +#define SK_LOG(expr,level,source) do { \ if (config.system.log_level >= level) \ dll_log->Log (L"[" source L"] " \ - SK_VARIADIC (expr)) + SK_VARIADIC (expr)); \ +} while (0) #define SK_LOG0(expr,src) SK_LOG(expr,0,src) #define SK_LOG1(expr,src) SK_LOG(expr,1,src) diff --git a/include/SpecialK/utility.h b/include/SpecialK/utility.h index e6511bc41..c6b061f1b 100644 --- a/include/SpecialK/utility.h +++ b/include/SpecialK/utility.h @@ -349,8 +349,8 @@ SK_GetBitness (void) // Avoid the C++ stdlib and use CPU interlocked instructions instead, so this // is safe to use even by parts of the DLL that run before the CRT initializes -#define SK_RunOnce(x) { static volatile LONG __once = TRUE; \ - if (InterlockedCompareExchange (&__once, FALSE, TRUE)) { x; } } +#define SK_RunOnce(x) do { static volatile LONG __once = TRUE; \ + if (InterlockedCompareExchange (&__once, FALSE, TRUE)) { x; } } while (0) static inline auto SK_RunOnceEx = [](auto x){ static std::once_flag the_wuncler; @@ -358,12 +358,12 @@ static inline auto #define SK_RunIf32Bit(x) { SK_GetBitness () == ThirtyTwoBit ? (x) : 0; } #define SK_RunIf64Bit(x) { SK_GetBitness () == SixtyFourBit ? (x) : 0; } -#define SK_RunLHIfBitness(b,l,r) SK_GetBitness () == (b) ? (l) : (r) +#define SK_RunLHIfBitness(b,l,r) (SK_GetBitness () == (b) ? (l) : (r)) -#define SK_LOG_FIRST_CALL { SK_RunOnce ({ \ +#define SK_LOG_FIRST_CALL SK_RunOnce ({ \ SK_LOG0 ( (L"[!] > First Call: %34s", __FUNCTIONW__), __SK_SUBSYSTEM__); \ - SK_LOG1 ( (L" <*> %s", SK_SummarizeCaller ().c_str ()), __SK_SUBSYSTEM__); }); } + SK_LOG1 ( (L" <*> %s", SK_SummarizeCaller ().c_str ()), __SK_SUBSYSTEM__); }); void SK_ImGui_Warning (const wchar_t* wszMessage); @@ -395,9 +395,9 @@ void SK_ImGui_WarningWithTitle (const wchar_t* wszMessage, L"First-Chance Assertion Failure" ) \ ); } } } -#define SK_ReleaseAssert(expr) { SK_ReleaseAssertEx ( (expr),L#expr, \ +#define SK_ReleaseAssert(expr) do { SK_ReleaseAssertEx ( (expr),L#expr, \ __FILEW__,__LINE__, \ - __FUNCSIG__ ) } + __FUNCSIG__ ) } while (0) struct SK_ThreadSuspension_Ctx { diff --git a/src/core.cpp b/src/core.cpp index 2a9a5f540..1c179d1b4 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -2975,7 +2975,7 @@ SK_FrameCallback ( SK_RenderBackend& rb, game_window.active |= (SK_GetForegroundWindow () == game_window.hWnd); - }) + }); } } diff --git a/src/diagnostics/debug_utils.cpp b/src/diagnostics/debug_utils.cpp index 785218f9c..5d267c1aa 100644 --- a/src/diagnostics/debug_utils.cpp +++ b/src/diagnostics/debug_utils.cpp @@ -146,7 +146,7 @@ SK_Debug_LoadHelper (void) else SK_Thread_SpinUntilAtomicMin (&__init, 2); - SK_ReleaseAssert (hModDbgHelp != nullptr) + SK_ReleaseAssert (hModDbgHelp != nullptr); return hModDbgHelp; diff --git a/src/diagnostics/load_library.cpp b/src/diagnostics/load_library.cpp index 42bc51a1a..c35ad2fdc 100644 --- a/src/diagnostics/load_library.cpp +++ b/src/diagnostics/load_library.cpp @@ -463,7 +463,7 @@ SK_TraceLoadLibrary ( HMODULE hCallingMod, // NVIDIA's User-Mode D3D Frontend StrStrI (lpFileName, SK_TEXT("nvd3dum.dll")) || StrStrIW (wszModName, L"nvd3dum.dll") ) ) - SK_RunOnce (SK_BootD3D9 ()) + SK_RunOnce (SK_BootD3D9 ()); #ifdef _M_IX86 else if ( (! (SK_GetDLLRole () & DLL_ROLE::D3D8)) && config.apis.d3d8.hook && ( StrStrI (lpFileName, SK_TEXT("d3d8.dll")) || @@ -477,50 +477,50 @@ SK_TraceLoadLibrary ( HMODULE hCallingMod, else if ( (! (SK_GetDLLRole () & DLL_ROLE::DXGI)) && config.apis.dxgi.d3d11.hook && ( StrStrI (lpFileName, SK_TEXT("d3d11.dll")) || StrStrIW (wszModName, L"d3d11.dll") )) - SK_RunOnce (SK_BootDXGI ()) + SK_RunOnce (SK_BootDXGI ()); else if ( (! (SK_GetDLLRole () & DLL_ROLE::DXGI)) && config.apis.dxgi.d3d11.hook && ( StrStrI (lpFileName, SK_TEXT("dxcore.dll")) || // Unity?! WTF are you doing? StrStrIW (wszModName, L"dxcore.dll") )) - SK_RunOnce (SK_BootDXGI ()) + SK_RunOnce (SK_BootDXGI ()); else if ( (! (SK_GetDLLRole () & DLL_ROLE::DXGI)) && config.apis.dxgi.d3d12.hook && ( StrStrI (lpFileName, SK_TEXT("d3d12.dll")) || StrStrIW (wszModName, L"d3d12.dll") )) - SK_RunOnce (SK_BootDXGI ()) + SK_RunOnce (SK_BootDXGI ()); #ifdef _M_AMD64 else if ( StrStrI (lpFileName, SK_TEXT("vulkan-1.dll")) || StrStrIW (wszModName, L"vulkan-1.dll") ) - SK_RunOnce (SK_BootVulkan ()) + SK_RunOnce (SK_BootVulkan ()); #endif else if ( (! (SK_GetDLLRole () & DLL_ROLE::OpenGL)) && config.apis.OpenGL.hook && ( StrStrI (lpFileName, SK_TEXT("OpenGL32.dll")) || StrStrIW (wszModName, L"OpenGL32.dll") )) - SK_RunOnce (SK_BootOpenGL ()) + SK_RunOnce (SK_BootOpenGL ()); else if ( //SK_XInput_LinkedVersion.empty () && StrStrI (lpFileName, SK_TEXT("xinput1_3.dll")) ) - SK_RunOnce (SK_Input_HookXInput1_3 ()) + SK_RunOnce (SK_Input_HookXInput1_3 ()); else if ( //SK_XInput_LinkedVersion.empty () && StrStrI (lpFileName, SK_TEXT("xinput1_4.dll")) ) - SK_RunOnce (SK_Input_HookXInput1_4 ()) + SK_RunOnce (SK_Input_HookXInput1_4 ()); else if ( //SK_XInput_LinkedVersion.empty () && StrStrI (lpFileName, SK_TEXT("xinput9_1_0.dll")) ) - SK_RunOnce (SK_Input_HookXInput9_1_0 ()) + SK_RunOnce (SK_Input_HookXInput9_1_0 ()); else if ( StrStrI (lpFileName, SK_TEXT("dinput8.dll")) ) - SK_RunOnce (SK_Input_HookDI8 ()) + SK_RunOnce (SK_Input_HookDI8 ()); else if ( StrStrI (lpFileName, SK_TEXT("dinput.dll")) ) - SK_RunOnce (SK_Input_HookDI7 ()) + SK_RunOnce (SK_Input_HookDI7 ()); else if ( StrStrI (lpFileName, SK_TEXT("hid.dll")) ) - SK_RunOnce (SK_Input_HookHID ()) + SK_RunOnce (SK_Input_HookHID ()); else if ( StrStrI ( lpFileName, SK_TEXT("EOSSDK-Win")) || StrStrIW (wszModName, L"EOSSDK-Win") ) - SK_RunOnce (SK::EOS::Init (false)) + SK_RunOnce (SK::EOS::Init (false)); else if ( StrStrI ( lpFileName, SK_TEXT("libScePad")) || StrStrIW (wszModName, L"libScePad") ) - SK_RunOnce (SK_Input_HookScePad ()) + SK_RunOnce (SK_Input_HookScePad ()); else if ( StrStrI ( lpFileName, SK_TEXT("dstorage.dll")) || StrStrIW (wszModName, L"dstorage.dll") ) { extern void SK_DStorage_Init (void); - SK_RunOnce (SK_DStorage_Init ()) + SK_RunOnce (SK_DStorage_Init ()); } else if ( StrStrI ( lpFileName, SK_TEXT("sl.interposer.dll")) || StrStrIW (wszModName, L"sl.interposer.dll") ) diff --git a/src/imgui/backends/imgui_d3d12.cpp b/src/imgui/backends/imgui_d3d12.cpp index 517de41f7..811378e04 100644 --- a/src/imgui/backends/imgui_d3d12.cpp +++ b/src/imgui/backends/imgui_d3d12.cpp @@ -1996,9 +1996,7 @@ SK_D3D12_RenderCtx::init (IDXGISwapChain3 *pSwapChain, ID3D12CommandQueue *pComm SK_ComPtr pNativeDev12; if (SK_slGetNativeInterface (_pDevice.p, (void **)&pNativeDev12.p) == sl::Result::eOk) - { - _pDevice = pNativeDev12; - } + _pDevice = pNativeDev12; } if (_pDevice.p != nullptr) @@ -2024,14 +2022,11 @@ SK_D3D12_RenderCtx::init (IDXGISwapChain3 *pSwapChain, ID3D12CommandQueue *pComm _pCommandQueue = pCommandQueue; if (_pCommandQueue != nullptr) - { - _pCommandQueue->GetDevice (IID_PPV_ARGS (&_pDevice.p)); + { _pCommandQueue->GetDevice (IID_PPV_ARGS (&_pDevice.p)); SK_ComPtr pNativeDev12; if (SK_slGetNativeInterface (_pDevice, (void **)&pNativeDev12.p) == sl::Result::eOk) - { - _pDevice = pNativeDev12; - } + _pDevice = pNativeDev12; } #endif } diff --git a/src/ini.cpp b/src/ini.cpp index a55b3a498..5a83b3224 100644 --- a/src/ini.cpp +++ b/src/ini.cpp @@ -91,7 +91,7 @@ iSK_INI::reload (const wchar_t *fname) if (fname == nullptr) { - SK_ReleaseAssert (name.size () > 0) + SK_ReleaseAssert (name.size () > 0); if ( name.empty ()) return false; // Empty String -> Dummy INI fname = name.c_str (); @@ -151,11 +151,11 @@ iSK_INI::reload (const wchar_t *fname) sk::narrow_cast (SK_File_GetSize (fname)); // A 4 MiB INI file seems pretty dman unlikely... - SK_ReleaseAssert (size >= 0 && size < (4L * 1024L * 1024L)) + SK_ReleaseAssert (size >= 0 && size < (4L * 1024L * 1024L)); data.resize (size + 3); - SK_ReleaseAssert (data.size () > 0) + SK_ReleaseAssert (data.size () > 0); if (data.size () == 0) { @@ -220,7 +220,7 @@ iSK_INI::reload (const wchar_t *fname) char* string = pTLS->scratch_memory->ini.utf8_string.alloc (real_size + 3, true); - SK_ReleaseAssert (string != nullptr) + SK_ReleaseAssert (string != nullptr); if (string == nullptr) { @@ -253,7 +253,7 @@ iSK_INI::reload (const wchar_t *fname) if (data.size () < converted_size + 3) data.resize (converted_size + 3); - SK_ReleaseAssert (data.size () > 0) + SK_ReleaseAssert (data.size () > 0); if (data.size () > 0) { @@ -284,7 +284,7 @@ iSK_INI::iSK_INI (const wchar_t* filename) AddRef (); SK_ReleaseAssert ( - filename != nullptr) + filename != nullptr); if ( filename == nullptr) return; if ( *filename == L'\0' ) return; // Empty String -> Dummy INI @@ -308,7 +308,7 @@ iSK_INI::~iSK_INI (void) ULONG refs = Release (); - SK_ReleaseAssert (refs == 0) // Memory leak? + SK_ReleaseAssert (refs == 0); // Memory leak? if (refs == 0) { @@ -388,7 +388,7 @@ Process_Section ( iSK_INISection &kSection, for (wchar_t* l = value; l <= end; l < end ? l = CharNextW (l) : nullptr) { - SK_ReleaseAssert (l != nullptr) + SK_ReleaseAssert (l != nullptr); if (l == nullptr) break; @@ -516,7 +516,7 @@ void __stdcall iSK_INI::parse (void) { - SK_ReleaseAssert (data.size () > 0) + SK_ReleaseAssert (data.size () > 0); SK_TLS* pTLS = SK_TLS_Bottom (); @@ -1202,7 +1202,7 @@ iSK_INI::get_section_f ( _In_z_ _Printf_format_string_ // ASSERT: Length <= 127 characters len += vswprintf (wszFormatted, _Format, _ArgList); - SK_ReleaseAssert (len <= 127) + SK_ReleaseAssert (len <= 127); } va_end (_ArgList); @@ -1684,7 +1684,7 @@ iSK_INI::import_file (const wchar_t* fname) } SK_ReleaseAssert ( - wszImportData != nullptr) + wszImportData != nullptr); if (wszImportData != nullptr) { MultiByteToWideChar ( CP_UTF8, 0, string, real_size, diff --git a/src/input/xinput_hotplug.cpp b/src/input/xinput_hotplug.cpp index b63f787ed..edf21f642 100644 --- a/src/input/xinput_hotplug.cpp +++ b/src/input/xinput_hotplug.cpp @@ -182,7 +182,7 @@ SK_XInput_NotifyDeviceArrival (void) SK_ReleaseAssert ( pDevHdr->dbch_size >= sizeof (DEV_BROADCAST_DEVICEINTERFACE_W) - ) + ); DEV_BROADCAST_DEVICEINTERFACE_W *pDev = (DEV_BROADCAST_DEVICEINTERFACE_W *)pDevHdr; @@ -346,7 +346,7 @@ SK_XInput_NotifyDeviceArrival (void) return 0; }, L"[SK] HID Hotplug Dispatch", (LPVOID)SK_XInputHot_NotifyEvent ); - }) + }); } diff --git a/src/plugins/persona4.cpp b/src/plugins/persona4.cpp index fa5483a1f..439f076b7 100644 --- a/src/plugins/persona4.cpp +++ b/src/plugins/persona4.cpp @@ -197,5 +197,5 @@ SK_Persona4_InitPlugin (void) plugin_mgr->config_fns.insert (SK_Persona4_PlugInCfg); plugin_mgr->end_frame_fns.insert (SK_Persona4_EndFrame); - }) + }); } \ No newline at end of file diff --git a/src/render/d3d11/d3d11.cpp b/src/render/d3d11/d3d11.cpp index d19e1a297..a56ad5974 100644 --- a/src/render/d3d11/d3d11.cpp +++ b/src/render/d3d11/d3d11.cpp @@ -8503,7 +8503,7 @@ SK_D3D11_EndFrame (SK_TLS* pTLS) // * This is recoverable and by the next full frame // all of SK's Critical Sections will be setup // - SK_ReleaseAssert (cs_render_view != nullptr) + SK_ReleaseAssert (cs_render_view != nullptr); if (!cs_render_view) // Skip this frame, we'll get it { // on the next go-around. diff --git a/src/render/d3d11/d3d11_screenshot.cpp b/src/render/d3d11/d3d11_screenshot.cpp index c50266c4f..041f13da8 100644 --- a/src/render/d3d11/d3d11_screenshot.cpp +++ b/src/render/d3d11/d3d11_screenshot.cpp @@ -198,7 +198,7 @@ struct ShaderBase { #pragma warning (push) #pragma warning (disable: 4130) // No @#$% sherlock - SK_ReleaseAssert ("WTF?!" == nullptr) + SK_ReleaseAssert ("WTF?!" == nullptr); #pragma warning (pop) } diff --git a/src/render/d3d11/d3d11_shader.cpp b/src/render/d3d11/d3d11_shader.cpp index 342af2a19..ed6d084bf 100644 --- a/src/render/d3d11/d3d11_shader.cpp +++ b/src/render/d3d11/d3d11_shader.cpp @@ -751,7 +751,7 @@ SK_D3D11_SetShaderResources_Impl ( // Static analysis seems to think this is possible: // ( Both are FALSE or Both are TRUE ), // but I am pretty sure it never happens. - SK_ReleaseAssert (hooked ^ ( _vftable != nullptr ) ) + SK_ReleaseAssert (hooked ^ ( _vftable != nullptr ) ); if ((! hooked) && (! _vftable)) return; diff --git a/src/render/d3d12/d3d11on12_shader_restitution.cpp b/src/render/d3d12/d3d11on12_shader_restitution.cpp index cf8cb602c..98a83f818 100644 --- a/src/render/d3d12/d3d11on12_shader_restitution.cpp +++ b/src/render/d3d12/d3d11on12_shader_restitution.cpp @@ -223,7 +223,7 @@ struct ShaderBase { #pragma warning (push) #pragma warning (disable: 4130) // No @#$% sherlock - SK_ReleaseAssert ("WTF?!" == nullptr) + SK_ReleaseAssert ("WTF?!" == nullptr); #pragma warning (pop) } diff --git a/src/render/d3d12/d3d12_command_queue.cpp b/src/render/d3d12/d3d12_command_queue.cpp index 5dd44324d..70144d3e1 100644 --- a/src/render/d3d12/d3d12_command_queue.cpp +++ b/src/render/d3d12/d3d12_command_queue.cpp @@ -120,18 +120,10 @@ _InstallCommandQueueHooksImpl (ID3D12Device* pDevice12) if (bHasStreamline) { - SK_LOGi0 (L"Hooking Streamline Native Interface for ID3D12CommandQueue..."); - - if (SK_slGetNativeInterface (pDevice12, (void **)&pDev12.p) != sl::Result::eOk) - { - SK_LOGi0 (L"Failed to Get Native Interface for D3D12 Device!"); - - pDev12 = pDevice12; - } - } - - else - pDev12 = pDevice12; + if (SK_slGetNativeInterface (pDevice12, (void **)&pDev12.p) == sl::Result::eOk) + SK_LOGi0 (L"Hooking Streamline Native Interface for ID3D12CommandQueue..."); + else pDev12 = pDevice12; + } else pDev12 = pDevice12; SK_ComPtr < ID3D12CommandQueue > p12Queue; D3D12_COMMAND_QUEUE_DESC queue_desc = { }; diff --git a/src/render/d3d12/d3d12_device.cpp b/src/render/d3d12/d3d12_device.cpp index 6186c5c9c..8d2d40e98 100644 --- a/src/render/d3d12/d3d12_device.cpp +++ b/src/render/d3d12/d3d12_device.cpp @@ -2202,18 +2202,10 @@ _InstallDeviceHooksImpl (ID3D12Device* pDevice12) if (bHasStreamline) { - SK_LOGi0 (L"Hooking Streamline Native Interface for ID3D12Device..."); - - if (SK_slGetNativeInterface (pDevice12, (void **)&pDev12.p) != sl::Result::eOk) - { - SK_LOGi0 (L"Failed to Get Native Interface for D3D12 Device!"); - - pDev12 = pDevice12; - } - } - - else - pDev12 = pDevice12; + if (SK_slGetNativeInterface (pDevice12, (void **)&pDev12.p) == sl::Result::eOk) + SK_LOGi0 (L"Hooking Streamline Native Interface for ID3D12Device..."); + else pDev12 = pDevice12; + } else pDev12 = pDevice12; SK_CreateVFTableHook2 ( L"ID3D12Device::CreateCommandAllocator", *(void ***)*(&pDev12), 9, diff --git a/src/render/d3d12/d3d12_screenshot.cpp b/src/render/d3d12/d3d12_screenshot.cpp index b474d29ac..e4daf9e8b 100644 --- a/src/render/d3d12/d3d12_screenshot.cpp +++ b/src/render/d3d12/d3d12_screenshot.cpp @@ -223,7 +223,7 @@ struct ShaderBase { #pragma warning (push) #pragma warning (disable: 4130) // No @#$% sherlock - SK_ReleaseAssert ("WTF?!" == nullptr) + SK_ReleaseAssert ("WTF?!" == nullptr); #pragma warning (pop) } diff --git a/src/render/d3d9/d3d9.cpp b/src/render/d3d9/d3d9.cpp index 6f6371886..9f3ddcb9e 100644 --- a/src/render/d3d9/d3d9.cpp +++ b/src/render/d3d9/d3d9.cpp @@ -803,12 +803,12 @@ SK_D3DX9_GetModule (bool acquire = false) if ( nullptr == hModD3DX9_43 && acquire ) { SK_RunOnce ( hModD3DX9_43 = - SK_D3DX9_Unpack () ) } + SK_D3DX9_Unpack () ); } if ( nullptr != hModD3DX9_43 ) { SK_RunOnce ( std::atexit ( [] - {FreeLibrary (hModD3DX9_43);}) ) + {FreeLibrary (hModD3DX9_43);}) ); } return diff --git a/src/render/dxgi/dxgi.cpp b/src/render/dxgi/dxgi.cpp index 830126a72..25ff1dab3 100644 --- a/src/render/dxgi/dxgi.cpp +++ b/src/render/dxgi/dxgi.cpp @@ -2032,7 +2032,7 @@ SK_ImGui_DrawD3D11 (IDXGISwapChain* This) { SK_RunOnce ( SK_LOGi0 (L"Immediate Context Unsafely Wrapped By Other Software") - ) + ); } D3D11_TEXTURE2D_DESC tex2d_desc = { }; @@ -7155,7 +7155,7 @@ DXGIDisableVBlankVirtualization (void) if (DXGIDisableVBlankVirtualization_Import == nullptr) { - SK_RunOnce (SK_BootDXGI ()) + SK_RunOnce (SK_BootDXGI ()); WaitForInitDXGI (); } @@ -7194,7 +7194,7 @@ DXGIDeclareAdapterRemovalSupport (void) if (DXGIDeclareAdapterRemovalSupport_Import == nullptr) { - SK_RunOnce (SK_BootDXGI ()) + SK_RunOnce (SK_BootDXGI ()); WaitForInitDXGI (); } @@ -7218,7 +7218,7 @@ DXGIGetDebugInterface1 ( UINT Flags, if (DXGIGetDebugInterface1_Import == nullptr) { - SK_RunOnce (SK_BootDXGI ()) + SK_RunOnce (SK_BootDXGI ()); WaitForInitDXGI (); } @@ -7274,7 +7274,7 @@ WINAPI CreateDXGIFactory (REFIID riid, if (CreateDXGIFactory_Import == nullptr) { - SK_RunOnce (SK_BootDXGI ()) + SK_RunOnce (SK_BootDXGI ()); WaitForInitDXGI (); } @@ -7449,7 +7449,7 @@ WINAPI CreateDXGIFactory2 (UINT Flags, if (CreateDXGIFactory2_Import == nullptr) { - SK_RunOnce (SK_BootDXGI ()) + SK_RunOnce (SK_BootDXGI ()); WaitForInitDXGI (); } @@ -7734,8 +7734,17 @@ dxgi_init_callback (finish_pfn finish) if (! SK_IsHostAppSKIM ()) { - SK_BootDXGI (); - //WaitForInitDXGI (); + SK_BootDXGI (); + do + { + if (! SwitchToThread ()) + { + static UINT + spin_count = 0; + if (++spin_count > 100) + break; + } + } while (! ReadAcquire (&__dxgi_ready)); } finish (); @@ -8268,18 +8277,11 @@ SK_DXGI_HookSwapChain (IDXGISwapChain* pProxySwapChain) if (bHasStreamline) { - SK_LOGi0 (L"Hooking Streamline Native Interface for IDXGISwapChain..."); - - if (SK_slGetNativeInterface (pProxySwapChain, (void **)&pSwapChain.p) != sl::Result::eOk) - { - SK_LOGi0 (L"Failed to Get Native Interface for DXGI SwapChain!"); + if (SK_slGetNativeInterface (pProxySwapChain, (void **)&pSwapChain.p) == sl::Result::eOk) + SK_LOGi0 (L"Hooking Streamline Native Interface for IDXGISwapChain..."); - pSwapChain = pProxySwapChain; - } - } - - else - pSwapChain = pProxySwapChain; + else pSwapChain = pProxySwapChain; + } else pSwapChain = pProxySwapChain; if (pSwapChain == nullptr) return; @@ -8474,18 +8476,11 @@ SK_DXGI_HookFactory (IDXGIFactory* pProxyFactory) if (bHasStreamline) { - SK_LOGi0 (L"Hooking Streamline Native Interface for IDXGIFactory..."); - - if (SK_slGetNativeInterface (pProxyFactory, (void **)&pFactory.p) != sl::Result::eOk) - { - SK_LOGi0 (L"Failed to Get Native Interface for DXGI Factory!"); + if (SK_slGetNativeInterface (pProxyFactory, (void **)&pFactory.p) == sl::Result::eOk) + SK_LOGi0 (L"Hooking Streamline Native Interface for IDXGIFactory..."); - pFactory = pProxyFactory; - } - } - - else - pFactory = pProxyFactory; + else pFactory = pProxyFactory; + } else pFactory = pProxyFactory; if (! InterlockedCompareExchangeAcquire (&hooked, TRUE, FALSE)) { @@ -8771,8 +8766,6 @@ HookDXGI (LPVOID user) ? DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL : DXGI_SWAP_EFFECT_DISCARD; - extern LPVOID pfnD3D11CreateDeviceAndSwapChain; - SK_COMPAT_UnloadFraps (); if ((SK_GetDLLRole () & DLL_ROLE::DXGI) || (SK_GetDLLRole () & DLL_ROLE::DInput8)) @@ -8981,44 +8974,29 @@ HookDXGI (LPVOID user) if (SUCCEEDED (hr)) { - if (bHasStreamline) - { - if (SK_slGetNativeInterface (pFactory, (void **)&pNativeFactory.p) == sl::Result::eOk) - { - SK_LOGi0 (L"Got Native Interface for Streamline Proxy'd DXGI Factory..."); + if (SK_slGetNativeInterface (pFactory, (void **)&pNativeFactory.p) == sl::Result::eOk) + pFactory = pNativeFactory; - pFactory.p->AddRef (); - pFactory = pNativeFactory; - } - } + if (SK_slGetNativeInterface (pDevice.p, (void **)&pNativeDevice.p) == sl::Result::eOk) + pDevice = pNativeDevice; - pFactory->CreateSwapChain (pDevice.p, &desc, &pSwapChain.p); + if (SK_slGetNativeInterface (pImmediateContext.p, (void **)&pNativeImmediateContext.p) == sl::Result::eOk) + pImmediateContext = pNativeImmediateContext; - if (bHasStreamline) + if (SUCCEEDED (pFactory->CreateSwapChain (pDevice.p, &desc, &pSwapChain.p))) { - SK_LOGi0 (L"Upgrading D3D11 Device(Context) and SwapChains to Streamline..."); - - SK_slUpgradeInterface ((void **)&pDevice.p); - SK_slUpgradeInterface ((void **)&pSwapChain.p); - SK_slUpgradeInterface ((void **)&pImmediateContext.p); - } - - sk_hook_d3d11_t d3d11_hook_ctx = { }; - - d3d11_hook_ctx.ppDevice = &pDevice.p; - d3d11_hook_ctx.ppImmediateContext = &pImmediateContext.p; + if (SK_slGetNativeInterface (pSwapChain.p, (void **)&pNativeSwapChain.p) == sl::Result::eOk) + { pSwapChain.p->AddRef (); + pSwapChain = pNativeSwapChain; + } - HookD3D11 (&d3d11_hook_ctx); - SK_DXGI_HookFactory (pFactory); - //if (SUCCEEDED (pFactory->CreateSwapChain (pDevice, &desc, &pSwapChain))) - bHookSuccess = true; + sk_hook_d3d11_t d3d11_hook_ctx = + { &pDevice.p, &pImmediateContext.p }; - if (bHasStreamline && SK_slGetNativeInterface (pSwapChain.p, (void **)&pNativeSwapChain.p) == sl::Result::eOk) - { - SK_LOGi0 (L"Got Native Interface for Streamline Proxy'd DXGI SwapChain..."); + HookD3D11 (&d3d11_hook_ctx); + SK_DXGI_HookFactory (pFactory); - pSwapChain.p->AddRef (); - pSwapChain = pNativeSwapChain; + bHookSuccess = true; } } } @@ -9045,16 +9023,11 @@ HookDXGI (LPVOID user) } if (! bEnable) SK_DisableApplyQueuedHooks (); - extern volatile LONG SK_D3D11_initialized; InterlockedIncrementRelease (&SK_D3D11_initialized); if (config.apis.dxgi.d3d11.hook) SK_D3D11_EnableHooks (); -/////#ifdef _WIN64 -///// if (config.apis.dxgi.d3d12.hook) SK_D3D12_EnableHooks (); -/////#endif - WriteRelease (&__dxgi_ready, TRUE); } @@ -9116,12 +9089,6 @@ SK::DXGI::Shutdown (void) } SK_D3D11_PurgeHookAddressCache (); - - ///iSK_INI* ini = - /// SK_GetDLLConfig (); - /// - ///if (ini != nullptr) - /// ini->write (ini->get_filename ()); } @@ -9990,25 +9957,37 @@ SK_DXGI_QuickHook (void) if (config.render.dxgi.debug_layer) return; + + extern BOOL + __SK_DisableQuickHook; + if (__SK_DisableQuickHook) + return; + + if ( PathFileExistsW (L"dxgi.dll") || PathFileExistsW (L"d3d11.dll") ) { SK_LOGi0 (L" # DXGI QuickHook disabled because a local dxgi.dll or d3d11.dll is present..."); - return; + __SK_DisableQuickHook = TRUE; } - extern BOOL - __SK_DisableQuickHook; + if ( SK_IsModuleLoaded (L"sl.interposer.dll") ) + { + SK_LOGi0 (L" # DXGI QuickHook disabled because an NVIDIA Streamline Interposer is present..."); + + __SK_DisableQuickHook = TRUE; + } + + if (__SK_DisableQuickHook) return; - static volatile LONG quick_hooked = FALSE; - + static volatile LONG quick_hooked = FALSE; if (! InterlockedCompareExchangeAcquire (&quick_hooked, TRUE, FALSE)) { - SK_D3D11_QuickHook (); + SK_D3D11_QuickHook (); sk_hook_cache_enablement_s state = SK_Hook_PreCacheModule ( L"DXGI", @@ -10038,16 +10017,6 @@ SK_DXGI_QuickHook (void) InterlockedIncrementRelease (&quick_hooked); } - - //if (SK_GetModuleHandle (L"d3d11.dll") != nullptr) - //{ - // SK_D3D11_Init (); -#ifdef SK_AGGRESSIVE_HOOKS - SK_ApplyQueuedHooks (); -#endif - - // SK_Thread_SpinUntilAtomicMin (&quick_hooked, 2); - //} } diff --git a/src/render/dxgi/dxgi_util.cpp b/src/render/dxgi/dxgi_util.cpp index 96961a380..2b56ecd8a 100644 --- a/src/render/dxgi/dxgi_util.cpp +++ b/src/render/dxgi/dxgi_util.cpp @@ -1268,7 +1268,7 @@ SK_D3D11_BltCopySurface ( ID3D11Texture2D *pSrcTex, SK_LOGi0 ( L" *** SK_D3D11_BltCopySurface (...) from src w/ %d mip levels to dst w/ %d", srcTexDesc.MipLevels, dstTexDesc.MipLevels ) - ) + ); } struct { diff --git a/src/tls.cpp b/src/tls.cpp index 6f9d43db1..1a50f5b7a 100644 --- a/src/tls.cpp +++ b/src/tls.cpp @@ -797,7 +797,7 @@ SK_D3D9_ThreadContext::allocStackScratchStorage (size_t size) { stack_scratch.size = (uint32_t)size; RtlSecureZeroMemory (stack_scratch.storage, size); - } else SK_ReleaseAssert (false) + } else SK_ReleaseAssert (false); } } @@ -906,7 +906,7 @@ SK_D3D11_ThreadContext::allocScreenshotMemory (size_t bytesNeeded) uint8_t* SK_DXTex_ThreadContext::alignedAlloc (size_t alignment, size_t elems) { - SK_ReleaseAssert (alignment == 16) + SK_ReleaseAssert (alignment == 16); bool new_alloc = true; diff --git a/src/widgets/tobii.cpp b/src/widgets/tobii.cpp index 8beee0e05..e6e4abd13 100644 --- a/src/widgets/tobii.cpp +++ b/src/widgets/tobii.cpp @@ -836,7 +836,7 @@ SK_Tobii_Startup ( tobii_api_t*& api, SK_Tobii_Callback_GazePoint, nullptr ); - SK_ReleaseAssert (error == TOBII_ERROR_NO_ERROR) + SK_ReleaseAssert (error == TOBII_ERROR_NO_ERROR); if (error != TOBII_ERROR_NO_ERROR) { diff --git a/src/window.cpp b/src/window.cpp index 751515c4e..fc20a9ec3 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3235,7 +3235,7 @@ SK_Window_RepositionIfNeeded (void) SK_SetWindowStyleEx ( SK_GetWindowLongPtrW (game_window.hWnd, GWL_EXSTYLE) ); - }) + }); } static constexpr DWORD _WorkSignal = WAIT_OBJECT_0 + 1;