From bca23d7865c8d9fe09662b5653bfa967080837e5 Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Fri, 29 Nov 2024 11:49:37 +0800 Subject: [PATCH] dx11on12 support --- external/FusionDxHook | 2 +- external/sire | 2 +- source/PCSX2F.XboxRainDroplets.cpp | 53 +++++++++++++++++++++++++++--- source/XboxRainDropletsWrapper.cpp | 50 +++++++++++++++++++++++----- 4 files changed, 92 insertions(+), 15 deletions(-) diff --git a/external/FusionDxHook b/external/FusionDxHook index e5d78ba..2f9123c 160000 --- a/external/FusionDxHook +++ b/external/FusionDxHook @@ -1 +1 @@ -Subproject commit e5d78bade2426eb43f14b831a25abfda70df7098 +Subproject commit 2f9123cd6d540b18417771b48ef3ae44ff11c2be diff --git a/external/sire b/external/sire index 428313d..fe500aa 160000 --- a/external/sire +++ b/external/sire @@ -1 +1 @@ -Subproject commit 428313dcba6d02664ef0b5eaa67a64a8bcbd15a7 +Subproject commit fe500aac549e9b97bb7dcafea5af66a8d1a6b353 diff --git a/source/PCSX2F.XboxRainDroplets.cpp b/source/PCSX2F.XboxRainDroplets.cpp index 77de34d..130d319 100644 --- a/source/PCSX2F.XboxRainDroplets.cpp +++ b/source/PCSX2F.XboxRainDroplets.cpp @@ -236,9 +236,13 @@ extern "C" __declspec(dllexport) void InitializeASI() #if FUSIONDXHOOK_INCLUDE_D3D11 FusionDxHook::D3D11::onPresentEvent += [](IDXGISwapChain* pSwapChain) { - Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); - - RenderDroplets(); + #ifdef SIRE_INCLUDE_DX11ON12 + if (!d3d11on12::isD3D11on12) + #endif + { + Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); + RenderDroplets(); + } }; FusionDxHook::D3D11::onAfterResizeEvent += [](IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) @@ -247,11 +251,52 @@ extern "C" __declspec(dllexport) void InitializeASI() }; FusionDxHook::D3D11::onShutdownEvent += []() + { + #ifdef SIRE_INCLUDE_DX11ON12 + if (!d3d11on12::isD3D11on12) + #endif + { + WaterDrops::Shutdown(); + Sire::Shutdown(); + } + }; + #endif // FUSIONDXHOOK_INCLUDE_D3D11 + + // D3D11on12 + #if FUSIONDXHOOK_INCLUDE_D3D12 + FusionDxHook::D3D12::onPresentEvent += [](IDXGISwapChain* pSwapChain) + { + Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); + RenderDroplets(); + }; + + #ifdef SIRE_INCLUDE_DX11ON12 + FusionDxHook::D3D12::onExecuteCommandListsEvent += [](ID3D12CommandQueue* pCommandQueue, UINT NumCommandLists, const ID3D12CommandList** ppCommandLists) + { + if (pCommandQueue->GetDesc().Type == D3D12_COMMAND_LIST_TYPE_DIRECT) + { + Sire::SetCommandQueue(pCommandQueue); + } + }; + #endif + + FusionDxHook::D3D12::onBeforeResizeEvent += [](IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) + { + WaterDrops::Reset(); + Sire::Shutdown(); + }; + + FusionDxHook::D3D12::onAfterResizeEvent += [](IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) + { + + }; + + FusionDxHook::D3D12::onShutdownEvent += []() { WaterDrops::Shutdown(); Sire::Shutdown(); }; - #endif // FUSIONDXHOOK_INCLUDE_D3D11 + #endif // FUSIONDXHOOK_INCLUDE_D3D12 #if FUSIONDXHOOK_INCLUDE_OPENGL FusionDxHook::OPENGL::onSwapBuffersEvent += [](HDC hDC) diff --git a/source/XboxRainDropletsWrapper.cpp b/source/XboxRainDropletsWrapper.cpp index cacd88a..bcb7777 100644 --- a/source/XboxRainDropletsWrapper.cpp +++ b/source/XboxRainDropletsWrapper.cpp @@ -8,7 +8,7 @@ #define FUSIONDXHOOK_INCLUDE_OPENGL 1 #define FUSIONDXHOOK_INCLUDE_VULKAN 1 #define FUSIONDXHOOK_USE_SAFETYHOOK 1 -#define DELAYED_BIND 2000ms +#define DELAYED_BIND 10000ms #include "FusionDxHook.h" extern "C" __declspec(dllexport) void InitializeASI() @@ -100,15 +100,26 @@ extern "C" __declspec(dllexport) void InitializeASI() #if FUSIONDXHOOK_INCLUDE_D3D11 FusionDxHook::D3D11::onPresentEvent += [](IDXGISwapChain* pSwapChain) { - Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); - - WaterDrops::Process(); - WaterDrops::Render(); + #ifdef SIRE_INCLUDE_DX11ON12 + if (!d3d11on12::isD3D11on12) + #endif + { + Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); + + WaterDrops::Process(); + WaterDrops::Render(); + } }; - FusionDxHook::D3D11::onAfterResizeEvent += [](IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) + FusionDxHook::D3D11::onBeforeResizeEvent += [](IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) { - + #ifdef SIRE_INCLUDE_DX11ON12 + if (!d3d11on12::isD3D11on12) + #endif + { + WaterDrops::Reset(); + Sire::Shutdown(); + } }; FusionDxHook::D3D11::onShutdownEvent += []() @@ -118,21 +129,42 @@ extern "C" __declspec(dllexport) void InitializeASI() }; #endif // FUSIONDXHOOK_INCLUDE_D3D11 + // D3D11on12 #if FUSIONDXHOOK_INCLUDE_D3D12 - FusionDxHook::D3D12::onPresentEvent += [](IDXGISwapChain*) + FusionDxHook::D3D12::onPresentEvent += [](IDXGISwapChain* pSwapChain) { + Sire::Init(Sire::SIRE_RENDERER_DX11, pSwapChain); + WaterDrops::Process(); + WaterDrops::Render(); }; - FusionDxHook::D3D12::onBeforeResizeEvent += [](IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) + #ifdef SIRE_INCLUDE_DX11ON12 + FusionDxHook::D3D12::onExecuteCommandListsEvent += [](ID3D12CommandQueue* pCommandQueue, UINT NumCommandLists, const ID3D12CommandList** ppCommandLists) { + if (pCommandQueue->GetDesc().Type == D3D12_COMMAND_LIST_TYPE_DIRECT) + { + Sire::SetCommandQueue(pCommandQueue); + } + }; + #endif + FusionDxHook::D3D12::onBeforeResizeEvent += [](IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) + { + WaterDrops::Reset(); + Sire::Shutdown(); }; FusionDxHook::D3D12::onAfterResizeEvent += [](IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) { }; + + FusionDxHook::D3D12::onShutdownEvent += []() + { + WaterDrops::Shutdown(); + Sire::Shutdown(); + }; #endif // FUSIONDXHOOK_INCLUDE_D3D12 #if FUSIONDXHOOK_INCLUDE_OPENGL