mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-05-29 21:13:14 +00:00
stash
This commit is contained in:
@@ -1373,7 +1373,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
m_FrameGenerationConfig.generationRect.width = Config::Instance()->FGRectWidth.value_or(scDesc.BufferDesc.Width);
|
||||
m_FrameGenerationConfig.generationRect.height = Config::Instance()->FGRectHeight.value_or(scDesc.BufferDesc.Height);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
m_FrameGenerationConfig.generationRect.width = Config::Instance()->FGRectWidth.value_or(deviceContext->DisplayWidth());
|
||||
m_FrameGenerationConfig.generationRect.height = Config::Instance()->FGRectHeight.value_or(deviceContext->DisplayHeight());
|
||||
@@ -1415,21 +1415,30 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
|
||||
auto dispatchResult = FfxApiProxy::D3D12_Dispatch()(reinterpret_cast<ffxContext*>(pUserCtx), ¶ms->header);
|
||||
|
||||
#ifdef USE_COPY_QUEUE_FOR_FG
|
||||
ID3D12CommandList* cl[1] = { nullptr };
|
||||
auto result = FrameGen_Dx12::fgCopyCommandList->Close();
|
||||
cl[0] = FrameGen_Dx12::fgCopyCommandList;
|
||||
FrameGen_Dx12::gameCommandQueue->ExecuteCommandLists(1, cl);
|
||||
#endif
|
||||
LOG_DEBUG("(FG) D3D12_Dispatch result: {}", (UINT)dispatchResult);
|
||||
|
||||
if (dispatchResult != FFX_API_RETURN_OK || result != S_OK)
|
||||
LOG_ERROR("(FG) D3D12_Dispatch result: {}({}, Close result: {})", (UINT)dispatchResult, FfxApiProxy::ReturnCodeToString(dispatchResult), (UINT)result);
|
||||
if (dispatchResult == FFX_API_RETURN_OK)
|
||||
{
|
||||
#ifdef USE_COPY_QUEUE_FOR_FG
|
||||
ID3D12CommandList* cl[1] = { nullptr };
|
||||
auto result = FrameGen_Dx12::fgCopyCommandList->Close();
|
||||
cl[0] = FrameGen_Dx12::fgCopyCommandList;
|
||||
FrameGen_Dx12::gameCommandQueue->ExecuteCommandLists(1, cl);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("(FG) Close result: {}", (UINT)result);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DONT_USE_DEPTH_MV_COPIES
|
||||
ResourceBarrier(InCmdList, paramVelocity, D3D12_RESOURCE_STATE_COPY_SOURCE, (D3D12_RESOURCE_STATES)Config::Instance()->MVResourceBarrier.value_or(D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE));
|
||||
ResourceBarrier(InCmdList, paramDepth, D3D12_RESOURCE_STATE_COPY_SOURCE, (D3D12_RESOURCE_STATES)Config::Instance()->DepthResourceBarrier.value_or(D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE));
|
||||
ResourceBarrier(InCmdList, paramVelocity, D3D12_RESOURCE_STATE_COPY_SOURCE, (D3D12_RESOURCE_STATES)Config::Instance()->MVResourceBarrier.value_or(D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE));
|
||||
ResourceBarrier(InCmdList, paramDepth, D3D12_RESOURCE_STATE_COPY_SOURCE, (D3D12_RESOURCE_STATES)Config::Instance()->DepthResourceBarrier.value_or(D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE));
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
return dispatchResult;
|
||||
};
|
||||
|
||||
m_FrameGenerationConfig.onlyPresentGenerated = Config::Instance()->FGOnlyGenerated; // check here
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<IncludePath>$(SolutionDir)external\vulkan\include;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\FidelityFX-SDK\ffx-api\include\ffx_api;$(SolutionDir)external\simpleini;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\spdlog\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(ProjectDir)fsr2\lib;$(ProjectDir)fsr2_212\lib;$(ProjectDir)fsr31\lib;$(ProjectDir)vulkan;$(ProjectDir)d3dx;$(ProjectDir)detours;$(SolutionDir)external\xess\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>dxgi</TargetName>
|
||||
<OutDir>D:\Folders\Games\SteamLibrary\steamapps\common\DEATH STRANDING DIRECTORS CUT\</OutDir>
|
||||
<OutDir>D:\Folders\Games\SteamLibrary\steamapps\common\The Last of Us Part I\</OutDir>
|
||||
<IntDir>.\x64\Debug</IntDir>
|
||||
<TargetExt>.dll</TargetExt>
|
||||
</PropertyGroup>
|
||||
@@ -185,7 +185,7 @@ md $(SolutionDir)x64\Release\a\Licenses
|
||||
copy $(SolutionDir)external\xess\licenses\LICENSE.pdf $(SolutionDir)x64\Release\a\Licenses\XeSS_LICENSE.pdf
|
||||
copy $(SolutionDir)external\xess\bin\libxess.dll $(SolutionDir)x64\Release\a\
|
||||
copy $(SolutionDir)external\FidelityFX-SDK\PrebuiltSignedDLL\amd_fidelityfx_dx12.dll $(SolutionDir)x64\Release\a\
|
||||
copy $(SolutionDir)external\FidelityFX-SDK\LICENSE.txt $(SolutionDir)x64\Release\a\Licenses\FidelityFX_LICENSE.txt
|
||||
copy $(SolutionDir)external\FidelityFX-SDK\docs\license.md $(SolutionDir)x64\Release\a\Licenses\FidelityFX_LICENSE.md
|
||||
copy $(ProjectDir)fsr31\amd_fidelityfx_vk.dll $(SolutionDir)x64\Release\a\
|
||||
copy $(SolutionDir)nvngx.ini $(SolutionDir)x64\Release\a\</Command>
|
||||
</PostBuildEvent>
|
||||
@@ -350,6 +350,7 @@ copy $(SolutionDir)nvngx.ini $(SolutionDir)x64\Release\a\</Command>
|
||||
<ResourceCompile Include="OptiScaler.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\Banishers Ghosts of New Eden\NWD\Binaries\Win64\amd_fidelityfx_dx12.dll" />
|
||||
<None Include="Source.def" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -95,6 +95,8 @@ static bool CreateDLSSContext(xess_context_handle_t handle, ID3D12GraphicsComman
|
||||
return false;
|
||||
|
||||
_contexts[handle] = nvHandle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static std::optional<float> GetQualityOverrideRatio(const xess_quality_settings_t input)
|
||||
@@ -226,6 +228,8 @@ XESS_API xess_result_t xessD3D12Init(xess_context_handle_t hContext, const xess_
|
||||
|
||||
NVSDK_NGX_D3D12_ReleaseFeature(_contexts[hContext]);
|
||||
_contexts.erase(hContext);
|
||||
|
||||
return XESS_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
XESS_API xess_result_t xessD3D12Execute(xess_context_handle_t hContext, ID3D12GraphicsCommandList* pCommandList, const xess_d3d12_execute_params_t* pExecParams)
|
||||
|
||||
+34
-2
@@ -155,6 +155,18 @@ inline std::vector<std::string> vkNames =
|
||||
"vulkan-1",
|
||||
};
|
||||
|
||||
inline std::vector<std::wstring> slIntNamesW =
|
||||
{
|
||||
L"sl.interposer.dll",
|
||||
L"sl.interposer",
|
||||
};
|
||||
|
||||
inline std::vector<std::string> slIntNames =
|
||||
{
|
||||
"sl.interposer.dll",
|
||||
"sl.interposer",
|
||||
};
|
||||
|
||||
inline std::vector<std::wstring> dllNamesW;
|
||||
|
||||
static int loadCount = 0;
|
||||
@@ -265,6 +277,9 @@ inline static HMODULE LoadLibraryCheck(std::string lcaseLibName)
|
||||
HooksDx::HookDxgi();
|
||||
}
|
||||
|
||||
if (CheckDllName(&lcaseLibName, &slIntNames) && Config::Instance()->OverlayMenu.value_or(true))
|
||||
HooksDx::HookSLDxgi();
|
||||
|
||||
if (CheckDllName(&lcaseLibName, &vkNames))
|
||||
{
|
||||
HookForVulkanSpoofing();
|
||||
@@ -345,6 +360,9 @@ inline static HMODULE LoadLibraryCheckW(std::wstring lcaseLibName)
|
||||
if (CheckDllNameW(&lcaseLibName, &dx12NamesW) && Config::Instance()->OverlayMenu.value_or(true))
|
||||
HooksDx::HookDx12();
|
||||
|
||||
if (CheckDllNameW(&lcaseLibName, &slIntNamesW) && Config::Instance()->OverlayMenu.value_or(true))
|
||||
HooksDx::HookSLDxgi();
|
||||
|
||||
if (CheckDllNameW(&lcaseLibName, &dxgiNamesW))
|
||||
{
|
||||
HookForDxgiSpoofing();
|
||||
@@ -697,7 +715,7 @@ static BOOL hkFreeLibrary(HMODULE lpLibrary)
|
||||
}
|
||||
|
||||
return o_FreeLibrary(lpLibrary);
|
||||
}
|
||||
}
|
||||
|
||||
static HMODULE hkLoadLibraryA(LPCSTR lpLibFileName)
|
||||
{
|
||||
@@ -1702,7 +1720,7 @@ static void CheckWorkingMode()
|
||||
if (modeFound)
|
||||
{
|
||||
HMODULE dxgiModule = nullptr;
|
||||
dxgiModule = GetModuleHandle(L"dxgi.dll");
|
||||
dxgiModule = GetModuleHandle(L"dxgi.dll");
|
||||
if (dxgiModule != nullptr)
|
||||
{
|
||||
LOG_DEBUG("dxgi.dll already in memory");
|
||||
@@ -1725,12 +1743,26 @@ static void CheckWorkingMode()
|
||||
HMODULE d3d11Module = nullptr;
|
||||
d3d11Module = GetModuleHandle(L"d3d11.dll");
|
||||
if (Config::Instance()->OverlayMenu.value() && d3d11Module != nullptr)
|
||||
{
|
||||
LOG_DEBUG("d3d11.dll already in memory");
|
||||
HooksDx::HookDx11();
|
||||
}
|
||||
|
||||
HMODULE d3d12Module = nullptr;
|
||||
d3d12Module = GetModuleHandle(L"d3d12.dll");
|
||||
if (Config::Instance()->OverlayMenu.value() && d3d12Module != nullptr)
|
||||
{
|
||||
LOG_DEBUG("d3d12.dll already in memory");
|
||||
HooksDx::HookDx12();
|
||||
}
|
||||
|
||||
HMODULE slInterposerModule = nullptr;
|
||||
slInterposerModule = GetModuleHandle(L"sl.interposer.dll");
|
||||
if (Config::Instance()->OverlayMenu.value() && slInterposerModule != nullptr)
|
||||
{
|
||||
LOG_DEBUG("sl.interposer.dll already in memory");
|
||||
HooksDx::HookSLDxgi();
|
||||
}
|
||||
|
||||
if (Config::Instance()->OverlayMenu.value() && dxgiModule != nullptr)
|
||||
HooksDx::HookDxgi();
|
||||
|
||||
+195
-61
@@ -223,6 +223,9 @@ typedef HRESULT(*PFN_CreateSwapChainForHwnd)(IDXGIFactory*, IUnknown*, HWND, con
|
||||
static PFN_CreateDXGIFactory o_CreateDXGIFactory = nullptr;
|
||||
static PFN_CreateDXGIFactory1 o_CreateDXGIFactory1 = nullptr;
|
||||
static PFN_CreateDXGIFactory2 o_CreateDXGIFactory2 = nullptr;
|
||||
static PFN_CreateDXGIFactory o_SL_CreateDXGIFactory = nullptr;
|
||||
static PFN_CreateDXGIFactory1 o_SL_CreateDXGIFactory1 = nullptr;
|
||||
static PFN_CreateDXGIFactory2 o_SL_CreateDXGIFactory2 = nullptr;
|
||||
|
||||
inline static PFN_EnumAdapters2 ptrEnumAdapters = nullptr;
|
||||
inline static PFN_EnumAdapters12 ptrEnumAdapters1 = nullptr;
|
||||
@@ -527,7 +530,7 @@ static void GetHudless(ID3D12GraphicsCommandList* This)
|
||||
cl[0] = FrameGen_Dx12::fgCopyCommandList;
|
||||
FrameGen_Dx12::gameCommandQueue->ExecuteCommandLists(1, cl);
|
||||
|
||||
LOG_DEBUG("_dispatch result: {0}", (UINT)result);
|
||||
LOG_DEBUG("D3D12_Dispatch result: {0}", (UINT)result);
|
||||
|
||||
fgDispatchCalled = false;
|
||||
FrameGen_Dx12::fgSkipHudlessChecks = false;
|
||||
@@ -703,7 +706,10 @@ static bool CheckForHudless(std::string callerName, ResourceInfo* resource)
|
||||
if ((scDesc.BufferDesc.Height != fgScDesc.BufferDesc.Height || scDesc.BufferDesc.Width != fgScDesc.BufferDesc.Width || scDesc.BufferDesc.Format != fgScDesc.BufferDesc.Format))
|
||||
{
|
||||
LOG_DEBUG("Format change, recreate the FormatTransfer");
|
||||
delete FrameGen_Dx12::fgFormatTransfer;
|
||||
|
||||
if (FrameGen_Dx12::fgFormatTransfer != nullptr)
|
||||
delete FrameGen_Dx12::fgFormatTransfer;
|
||||
|
||||
FrameGen_Dx12::fgFormatTransfer = nullptr;
|
||||
FrameGen_Dx12::fgFormatTransfer = new FT_Dx12("FormatTransfer", g_pd3dDeviceParam, scDesc.BufferDesc.Format);
|
||||
|
||||
@@ -730,8 +736,8 @@ static bool CheckForHudless(std::string callerName, ResourceInfo* resource)
|
||||
return false;
|
||||
|
||||
// resource and target formats are supported by converter
|
||||
if ((resource->format == DXGI_FORMAT_R8G8B8A8_TYPELESS || resource->format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB || resource->format == DXGI_FORMAT_R8G8B8A8_UNORM || resource->format == DXGI_FORMAT_R16G16B16A16_FLOAT ||
|
||||
resource->format == DXGI_FORMAT_R11G11B10_FLOAT || resource->format == DXGI_FORMAT_R32G32B32A32_FLOAT || resource->format == DXGI_FORMAT_R32G32B32_FLOAT || resource->format == DXGI_FORMAT_R10G10B10A2_UNORM ||
|
||||
if ((resource->format == DXGI_FORMAT_R8G8B8A8_TYPELESS || resource->format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB || resource->format == DXGI_FORMAT_R8G8B8A8_UNORM || resource->format == DXGI_FORMAT_R16G16B16A16_FLOAT ||
|
||||
resource->format == DXGI_FORMAT_R11G11B10_FLOAT || resource->format == DXGI_FORMAT_R32G32B32A32_FLOAT || resource->format == DXGI_FORMAT_R32G32B32_FLOAT || resource->format == DXGI_FORMAT_R10G10B10A2_UNORM ||
|
||||
resource->format == DXGI_FORMAT_R10G10B10A2_TYPELESS) &&
|
||||
(fgScDesc.BufferDesc.Format == DXGI_FORMAT_R8G8B8A8_UNORM || fgScDesc.BufferDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM || fgScDesc.BufferDesc.Format == DXGI_FORMAT_R10G10B10A2_UNORM))
|
||||
{
|
||||
@@ -1147,34 +1153,22 @@ static void hkSetGraphicsRootDescriptorTable(ID3D12GraphicsCommandList* This, UI
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InUpscaledList(capturedBuffer->buffer) && !CheckForHudless(__FUNCTION__, capturedBuffer))
|
||||
if (!CheckForHudless(__FUNCTION__, capturedBuffer))
|
||||
return;
|
||||
|
||||
capturedBuffer->state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(hudlessMutex[fIndex]);
|
||||
if (fgPossibleHudless[fIndex].contains(This))
|
||||
if (!fgPossibleHudless[fIndex].contains(This))
|
||||
{
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr)
|
||||
{
|
||||
ResourceInfo upscaledInfo{};
|
||||
FillResourceInfo(FrameGen_Dx12::fgUpscaledImage[fIndex], &upscaledInfo);
|
||||
upscaledInfo.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
|
||||
if (CheckForHudless(__FUNCTION__, &upscaledInfo))
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(FrameGen_Dx12::fgUpscaledImage[fIndex], upscaledInfo);
|
||||
|
||||
FrameGen_Dx12::fgUpscaledImage[fIndex] = nullptr;
|
||||
}
|
||||
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(capturedBuffer->buffer, *capturedBuffer);
|
||||
|
||||
return;
|
||||
ankerl::unordered_dense::map <ID3D12Resource*, ResourceInfo> newMap;
|
||||
fgPossibleHudless[fIndex].insert_or_assign(This, newMap);
|
||||
}
|
||||
|
||||
ankerl::unordered_dense::map <ID3D12Resource*, ResourceInfo> newMap;
|
||||
fgPossibleHudless[fIndex].insert_or_assign(This, newMap);
|
||||
// if current resource is same as upscaled skip adding upscaled one
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr && capturedBuffer->buffer == FrameGen_Dx12::fgUpscaledImage[fIndex])
|
||||
FrameGen_Dx12::fgUpscaledImage[fIndex] = nullptr;
|
||||
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr)
|
||||
{
|
||||
@@ -1231,27 +1225,16 @@ static void hkOMSetRenderTargets(ID3D12GraphicsCommandList* This, UINT NumRender
|
||||
|
||||
resource->state = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||
|
||||
if (fgPossibleHudless[fIndex].contains(This))
|
||||
// check for command list
|
||||
if (!fgPossibleHudless[fIndex].contains(This))
|
||||
{
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr)
|
||||
{
|
||||
ResourceInfo upscaledInfo{};
|
||||
FillResourceInfo(FrameGen_Dx12::fgUpscaledImage[fIndex], &upscaledInfo);
|
||||
upscaledInfo.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
|
||||
if (CheckForHudless(__FUNCTION__, &upscaledInfo))
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(FrameGen_Dx12::fgUpscaledImage[fIndex], upscaledInfo);
|
||||
|
||||
FrameGen_Dx12::fgUpscaledImage[fIndex] = nullptr;
|
||||
}
|
||||
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(resource->buffer, *resource);
|
||||
|
||||
return;
|
||||
ankerl::unordered_dense::map <ID3D12Resource*, ResourceInfo> newMap;
|
||||
fgPossibleHudless[fIndex].insert_or_assign(This, newMap);
|
||||
}
|
||||
|
||||
ankerl::unordered_dense::map <ID3D12Resource*, ResourceInfo> newMap;
|
||||
fgPossibleHudless[fIndex].insert_or_assign(This, newMap);
|
||||
// if current resource is same as upscaled skip adding upscaled one
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr && resource->buffer == FrameGen_Dx12::fgUpscaledImage[fIndex])
|
||||
FrameGen_Dx12::fgUpscaledImage[fIndex] = nullptr;
|
||||
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr)
|
||||
{
|
||||
@@ -1259,12 +1242,15 @@ static void hkOMSetRenderTargets(ID3D12GraphicsCommandList* This, UINT NumRender
|
||||
FillResourceInfo(FrameGen_Dx12::fgUpscaledImage[fIndex], &upscaledInfo);
|
||||
upscaledInfo.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
|
||||
// check if upscaled is fitting
|
||||
if (CheckForHudless(__FUNCTION__, &upscaledInfo))
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(FrameGen_Dx12::fgUpscaledImage[fIndex], upscaledInfo);
|
||||
|
||||
// clear for not duplicating
|
||||
FrameGen_Dx12::fgUpscaledImage[fIndex] = nullptr;
|
||||
}
|
||||
|
||||
// add found resource
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(resource->buffer, *resource);
|
||||
}
|
||||
}
|
||||
@@ -1297,7 +1283,7 @@ static void hkSetComputeRootDescriptorTable(ID3D12GraphicsCommandList* This, UIN
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InUpscaledList(capturedBuffer->buffer) && !CheckForHudless(__FUNCTION__, capturedBuffer))
|
||||
if (!CheckForHudless(__FUNCTION__, capturedBuffer))
|
||||
return;
|
||||
|
||||
if (capturedBuffer->type == UAV)
|
||||
@@ -1307,27 +1293,15 @@ static void hkSetComputeRootDescriptorTable(ID3D12GraphicsCommandList* This, UIN
|
||||
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(hudlessMutex[fIndex]);
|
||||
if (fgPossibleHudless[fIndex].contains(This))
|
||||
if (!fgPossibleHudless[fIndex].contains(This))
|
||||
{
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr)
|
||||
{
|
||||
ResourceInfo upscaledInfo{};
|
||||
FillResourceInfo(FrameGen_Dx12::fgUpscaledImage[fIndex], &upscaledInfo);
|
||||
upscaledInfo.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
|
||||
if (CheckForHudless(__FUNCTION__, &upscaledInfo))
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(FrameGen_Dx12::fgUpscaledImage[fIndex], upscaledInfo);
|
||||
|
||||
FrameGen_Dx12::fgUpscaledImage[fIndex] = nullptr;
|
||||
}
|
||||
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(capturedBuffer->buffer, *capturedBuffer);
|
||||
|
||||
return;
|
||||
ankerl::unordered_dense::map <ID3D12Resource*, ResourceInfo> newMap;
|
||||
fgPossibleHudless[fIndex].insert_or_assign(This, newMap);
|
||||
}
|
||||
|
||||
ankerl::unordered_dense::map <ID3D12Resource*, ResourceInfo> newMap;
|
||||
fgPossibleHudless[fIndex].insert_or_assign(This, newMap);
|
||||
// if current resource is same as upscaled skip adding upscaled one
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr && capturedBuffer->buffer == FrameGen_Dx12::fgUpscaledImage[fIndex])
|
||||
FrameGen_Dx12::fgUpscaledImage[fIndex] = nullptr;
|
||||
|
||||
if (FrameGen_Dx12::fgUpscaledImage[fIndex] != nullptr)
|
||||
{
|
||||
@@ -1888,6 +1862,10 @@ static HRESULT hkCreateSwapChain(IDXGIFactory* pFactory, IUnknown* pDevice, DXGI
|
||||
scInfo.swapChainFormat = pDesc->BufferDesc.Format;
|
||||
scInfo.swapChainBufferCount = pDesc->BufferCount;
|
||||
scInfo.swapChain = (IDXGISwapChain4*)*ppSwapChain;
|
||||
|
||||
// Hack for FSR swapchain
|
||||
// It have 1 extra ref
|
||||
scInfo.swapChain->Release();
|
||||
fgSwapChains.insert_or_assign(pDesc->OutputWindow, scInfo);
|
||||
|
||||
LOG_DEBUG("Created FSR-FG swapchain");
|
||||
@@ -2157,7 +2135,8 @@ static HRESULT hkCreateSwapChainForHwnd(IDXGIFactory* This, IUnknown* pDevice, H
|
||||
|
||||
static HRESULT hkCreateDXGIFactory(REFIID riid, IDXGIFactory** ppFactory)
|
||||
{
|
||||
auto result = o_CreateDXGIFactory(riid, ppFactory);
|
||||
HRESULT result = E_FAIL;
|
||||
result = o_CreateDXGIFactory(riid, ppFactory);
|
||||
|
||||
if (result == S_OK)
|
||||
AttachToFactory(*ppFactory);
|
||||
@@ -2278,6 +2257,130 @@ static HRESULT hkCreateDXGIFactory2(UINT Flags, REFIID riid, IDXGIFactory2** ppF
|
||||
return result;
|
||||
}
|
||||
|
||||
static HRESULT hkSLCreateDXGIFactory(REFIID riid, IDXGIFactory** ppFactory)
|
||||
{
|
||||
HRESULT result = E_FAIL;
|
||||
result = o_CreateDXGIFactory(riid, ppFactory);
|
||||
|
||||
if (result == S_OK)
|
||||
AttachToFactory(*ppFactory);
|
||||
|
||||
if (result == S_OK && oCreateSwapChain == nullptr)
|
||||
{
|
||||
void** pFactoryVTable = *reinterpret_cast<void***>(*ppFactory);
|
||||
|
||||
oCreateSwapChain = (PFN_CreateSwapChain)pFactoryVTable[10];
|
||||
|
||||
if (oCreateSwapChain != nullptr)
|
||||
{
|
||||
LOG_INFO("Hooking native DXGIFactory");
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
DetourAttach(&(PVOID&)oCreateSwapChain, hkCreateSwapChain);
|
||||
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static HRESULT hkSLCreateDXGIFactory1(REFIID riid, IDXGIFactory1** ppFactory)
|
||||
{
|
||||
auto result = o_CreateDXGIFactory1(riid, ppFactory);
|
||||
|
||||
if (result == S_OK)
|
||||
AttachToFactory(*ppFactory);
|
||||
|
||||
if (result == S_OK && oCreateSwapChainForHwnd == nullptr)
|
||||
{
|
||||
IDXGIFactory2* factory2 = nullptr;
|
||||
|
||||
if ((*ppFactory)->QueryInterface(IID_PPV_ARGS(&factory2)) == S_OK && factory2 != nullptr)
|
||||
{
|
||||
void** pFactoryVTable = *reinterpret_cast<void***>(factory2);
|
||||
|
||||
bool skip = false;
|
||||
|
||||
if (oCreateSwapChain == nullptr)
|
||||
oCreateSwapChain = (PFN_CreateSwapChain)pFactoryVTable[10];
|
||||
else
|
||||
skip = true;
|
||||
|
||||
oCreateSwapChainForHwnd = (PFN_CreateSwapChainForHwnd)pFactoryVTable[15];
|
||||
|
||||
if (oCreateSwapChainForHwnd != nullptr)
|
||||
{
|
||||
LOG_INFO("Hooking native DXGIFactory");
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
if (!skip)
|
||||
DetourAttach(&(PVOID&)oCreateSwapChain, hkCreateSwapChain);
|
||||
|
||||
DetourAttach(&(PVOID&)oCreateSwapChainForHwnd, hkCreateSwapChainForHwnd);
|
||||
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
factory2->Release();
|
||||
factory2 = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static HRESULT hkSLCreateDXGIFactory2(UINT Flags, REFIID riid, IDXGIFactory2** ppFactory)
|
||||
{
|
||||
auto result = o_CreateDXGIFactory2(Flags, riid, ppFactory);
|
||||
|
||||
if (result == S_OK)
|
||||
AttachToFactory(*ppFactory);
|
||||
|
||||
if (result == S_OK && oCreateSwapChainForHwnd == nullptr)
|
||||
{
|
||||
IDXGIFactory2* factory2 = nullptr;
|
||||
|
||||
if ((*ppFactory)->QueryInterface(IID_PPV_ARGS(&factory2)) == S_OK && factory2 != nullptr)
|
||||
{
|
||||
void** pFactoryVTable = *reinterpret_cast<void***>(factory2);
|
||||
|
||||
bool skip = false;
|
||||
|
||||
if (oCreateSwapChain == nullptr)
|
||||
oCreateSwapChain = (PFN_CreateSwapChain)pFactoryVTable[10];
|
||||
else
|
||||
skip = true;
|
||||
|
||||
oCreateSwapChainForHwnd = (PFN_CreateSwapChainForHwnd)pFactoryVTable[15];
|
||||
|
||||
if (oCreateSwapChainForHwnd != nullptr)
|
||||
{
|
||||
LOG_INFO("Hooking native DXGIFactory");
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
if (!skip)
|
||||
DetourAttach(&(PVOID&)oCreateSwapChain, hkCreateSwapChain);
|
||||
|
||||
DetourAttach(&(PVOID&)oCreateSwapChainForHwnd, hkCreateSwapChainForHwnd);
|
||||
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
factory2->Release();
|
||||
factory2 = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static HRESULT hkEnumAdapterByGpuPreference(IDXGIFactory6* This, UINT Adapter, DXGI_GPU_PREFERENCE GpuPreference, REFIID riid, IUnknown** ppvAdapter)
|
||||
{
|
||||
auto result = ptrEnumAdapterByGpuPreference(This, Adapter, GpuPreference, riid, ppvAdapter);
|
||||
@@ -2833,6 +2936,37 @@ void HooksDx::HookDxgi()
|
||||
}
|
||||
}
|
||||
|
||||
void HooksDx::HookSLDxgi()
|
||||
{
|
||||
if (o_SL_CreateDXGIFactory != nullptr)
|
||||
return;
|
||||
|
||||
LOG_DEBUG("");
|
||||
|
||||
o_SL_CreateDXGIFactory = (PFN_CreateDXGIFactory)DetourFindFunction("sl.interposer.dll", "CreateDXGIFactory");
|
||||
o_SL_CreateDXGIFactory1 = (PFN_CreateDXGIFactory1)DetourFindFunction("sl.interposer.dll", "CreateDXGIFactory1");
|
||||
o_SL_CreateDXGIFactory2 = (PFN_CreateDXGIFactory2)DetourFindFunction("sl.interposer.dll", "CreateDXGIFactory2");
|
||||
|
||||
if (o_CreateDXGIFactory != nullptr)
|
||||
{
|
||||
LOG_DEBUG("Hooking SL CreateDXGIFactory methods");
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
if (o_SL_CreateDXGIFactory != nullptr)
|
||||
DetourAttach(&(PVOID&)o_SL_CreateDXGIFactory, hkSLCreateDXGIFactory);
|
||||
|
||||
if (o_SL_CreateDXGIFactory1 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_SL_CreateDXGIFactory1, hkSLCreateDXGIFactory1);
|
||||
|
||||
if (o_SL_CreateDXGIFactory2 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_SL_CreateDXGIFactory2, hkSLCreateDXGIFactory2);
|
||||
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
}
|
||||
|
||||
void HooksDx::UnHookDx()
|
||||
{
|
||||
DetourTransactionBegin();
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace HooksDx
|
||||
void HookDx11();
|
||||
void HookDx12();
|
||||
void HookDxgi();
|
||||
void HookSLDxgi();
|
||||
}
|
||||
|
||||
namespace FrameGen_Dx12
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define VER_MAJOR_VERSION 0
|
||||
#define VER_MINOR_VERSION 7
|
||||
#define VER_HOTFIX_VERSION 0
|
||||
#define VER_BUILD_NUMBER 28
|
||||
#define VER_BUILD_NUMBER 30
|
||||
|
||||
#define VER_PRE_RELEASE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user