From db0ecf29f63d340757902f933bb6f44db7aae6b0 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Thu, 17 Oct 2024 17:46:54 +0300 Subject: [PATCH] re-enabled linux support --- OptiScaler/dllmain.cpp | 4 +-- OptiScaler/dllmain.h | 2 +- OptiScaler/imgui/imgui_overlay_dx.cpp | 40 +++++++++++++++++---------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/OptiScaler/dllmain.cpp b/OptiScaler/dllmain.cpp index 7367747e..20b6eacd 100644 --- a/OptiScaler/dllmain.cpp +++ b/OptiScaler/dllmain.cpp @@ -1614,9 +1614,7 @@ static void CheckWorkingMode() Config::Instance()->OverlayMenu = (!isNvngxMode || isWorkingWithEnabler) && Config::Instance()->OverlayMenu.value_or(true); if (Config::Instance()->OverlayMenu.value()) { - if (!Config::Instance()->IsRunningOnLinux && !Config::Instance()->IsRunningOnDXVK) - ImGuiOverlayDx::HookDx(); - + ImGuiOverlayDx::HookDx(); ImGuiOverlayVk::HookVk(); } diff --git a/OptiScaler/dllmain.h b/OptiScaler/dllmain.h index 071e19af..02143a13 100644 --- a/OptiScaler/dllmain.h +++ b/OptiScaler/dllmain.h @@ -1346,7 +1346,7 @@ struct dxgi_dll bool SkipSpoofing() { - auto skip = !Config::Instance()->DxgiSpoofing.value_or(true) || Config::Instance()->dxgiSkipSpoofing || Config::Instance()->IsRunningOnLinux; + auto skip = !Config::Instance()->DxgiSpoofing.value_or(true) || Config::Instance()->dxgiSkipSpoofing; // || Config::Instance()->IsRunningOnLinux; if (skip) LOG_TRACE("DxgiSpoofing: {}, dxgiSkipSpoofing: {}, skipping spoofing", diff --git a/OptiScaler/imgui/imgui_overlay_dx.cpp b/OptiScaler/imgui/imgui_overlay_dx.cpp index 9d433896..07f77f84 100644 --- a/OptiScaler/imgui/imgui_overlay_dx.cpp +++ b/OptiScaler/imgui/imgui_overlay_dx.cpp @@ -215,10 +215,10 @@ typedef HRESULT(*PFN_CreateDXGIFactory)(REFIID riid, IDXGIFactory** ppFactory); typedef HRESULT(*PFN_CreateDXGIFactory1)(REFIID riid, IDXGIFactory1** ppFactory); typedef HRESULT(*PFN_CreateDXGIFactory2)(UINT Flags, REFIID riid, IDXGIFactory2** ppFactory); -typedef HRESULT(WINAPI* PFN_EnumAdapterByGpuPreference2)(IDXGIFactory6* This, UINT Adapter, DXGI_GPU_PREFERENCE GpuPreference, REFIID riid, IUnknown** ppvAdapter); -typedef HRESULT(WINAPI* PFN_EnumAdapterByLuid2)(IDXGIFactory4* This, LUID AdapterLuid, REFIID riid, IUnknown** ppvAdapter); -typedef HRESULT(WINAPI* PFN_EnumAdapters12)(IDXGIFactory1* This, UINT Adapter, IUnknown** ppAdapter); -typedef HRESULT(WINAPI* PFN_EnumAdapters2)(IDXGIFactory* This, UINT Adapter, IUnknown** ppAdapter); +typedef HRESULT(*PFN_EnumAdapterByGpuPreference2)(IDXGIFactory6* This, UINT Adapter, DXGI_GPU_PREFERENCE GpuPreference, REFIID riid, IUnknown** ppvAdapter); +typedef HRESULT(*PFN_EnumAdapterByLuid2)(IDXGIFactory4* This, LUID AdapterLuid, REFIID riid, IUnknown** ppvAdapter); +typedef HRESULT(*PFN_EnumAdapters12)(IDXGIFactory1* This, UINT Adapter, IUnknown** ppAdapter); +typedef HRESULT(*PFN_EnumAdapters2)(IDXGIFactory* This, UINT Adapter, IUnknown** ppAdapter); static PFN_CreateDXGIFactory o_CreateDXGIFactory = nullptr; static PFN_CreateDXGIFactory1 o_CreateDXGIFactory1 = nullptr; @@ -746,10 +746,10 @@ static void CaptureHudless(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* r else { ResourceBarrier(cmdList, resource, state, D3D12_RESOURCE_STATE_COPY_SOURCE); - + if (CreateBufferResource(g_pd3dDeviceParam, resource, D3D12_RESOURCE_STATE_COPY_DEST, &fgHudless[fIndex])) cmdList->CopyResource(fgHudless[fIndex], resource); - + ResourceBarrier(cmdList, resource, D3D12_RESOURCE_STATE_COPY_SOURCE, state); } @@ -779,14 +779,14 @@ static bool CheckForHudless(ResourceInfo* resource, bool checkFormat = true) (resource->format == DXGI_FORMAT_R16G16B16A16_FLOAT || resource->format == DXGI_FORMAT_R11G11B10_FLOAT || resource->format == DXGI_FORMAT_R32G32B32A32_FLOAT || resource->format == DXGI_FORMAT_R32G32B32_FLOAT) && (fgScDesc.BufferDesc.Format == DXGI_FORMAT_R8G8B8A8_UNORM || fgScDesc.BufferDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM || fgScDesc.BufferDesc.Format == DXGI_FORMAT_R10G10B10A2_UNORM)))) { - LOG_DEBUG_ONLY("Width: {}/{}, Height: {}/{}, Format: {}/{}, checkFormat: {} -> TRUE", - resource->width, fgScDesc.BufferDesc.Width, resource->height, fgScDesc.BufferDesc.Height, (UINT)resource->format, (UINT)fgScDesc.BufferDesc.Format, checkFormat); + LOG_TRACE("Width: {}/{}, Height: {}/{}, Format: {}/{}, checkFormat: {} -> TRUE", + resource->width, fgScDesc.BufferDesc.Width, resource->height, fgScDesc.BufferDesc.Height, (UINT)resource->format, (UINT)fgScDesc.BufferDesc.Format, checkFormat); return true; } - LOG_DEBUG_ONLY("Width: {}/{}, Height: {}/{}, Format: {}/{}, checkFormat: {} -> FALSE", - resource->width, fgScDesc.BufferDesc.Width, resource->height, fgScDesc.BufferDesc.Height, (UINT)resource->format, (UINT)fgScDesc.BufferDesc.Format, checkFormat); + LOG_TRACE("Width: {}/{}, Height: {}/{}, Format: {}/{}, checkFormat: {} -> FALSE", + resource->width, fgScDesc.BufferDesc.Width, resource->height, fgScDesc.BufferDesc.Height, (UINT)resource->format, (UINT)fgScDesc.BufferDesc.Format, checkFormat); return false; } @@ -812,7 +812,7 @@ static void hkDiscardResource(ID3D12GraphicsCommandList* This, ID3D12Resource* p fgHandlesByResources.erase(pResource); LOG_DEBUG_ONLY("Erased"); -} + } } #endif @@ -1721,9 +1721,21 @@ static HRESULT Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags else presentResult = ((IDXGISwapChain1*)pSwapChain)->Present1(SyncInterval, Flags, pPresentParameters); - //fgPresentRunning = false; ImGuiOverlayDx::fgSkipHudlessChecks = false; + if (Config::Instance()->CurrentFeature != nullptr) + fgPresentedFrame = Config::Instance()->CurrentFeature->FrameCount(); + + auto now = Util::MillisecondsNow(); + + if (fgLastFrameTime != 0) + { + fgLastDeltaTime = now - fgLastFrameTime; + LOG_DEBUG("fgLastDeltaTime: {0:.2f}, frameCounter: {1}", fgLastDeltaTime, frameCounter); + } + + fgLastFrameTime = now; + //LOG_DEBUG("Return"); return presentResult; @@ -1838,7 +1850,6 @@ static HRESULT Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags } } - // dx11 multi thread safety ID3D11Multithread* dx11MultiThread = nullptr; ID3D11DeviceContext* dx11Context = nullptr; @@ -2056,6 +2067,7 @@ static HRESULT hkCreateSwapChain(IDXGIFactory* pFactory, IUnknown* pDevice, DXGI createSwapChainDesc.gameQueue = (ID3D12CommandQueue*)pDevice; createSwapChainDesc.desc = pDesc; createSwapChainDesc.swapchain = (IDXGISwapChain4**)ppSwapChain; + fgSkipSCWrapping = true; Config::Instance()->dxgiSkipSpoofing = true; @@ -2187,7 +2199,7 @@ static HRESULT hkCreateSwapChainForHwnd(IDXGIFactory* This, IUnknown* pDevice, H LOG_ERROR("_createContext error: {}", result); - return E_INVALIDARG; + return result; } auto result = oCreateSwapChainForHwnd(This, pDevice, hWnd, pDesc, pFullscreenDesc, pRestrictToOutput, ppSwapChain);