mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-09-22 21:35:51 +00:00
Added CBV tracking option
This commit is contained in:
@@ -96,6 +96,7 @@ bool Config::Reload(std::filesystem::path iniPath)
|
||||
FGHudfixHalfSync.set_from_config(readBool("OptiFG", "HudfixHalfSync"));
|
||||
FGHudfixFullSync.set_from_config(readBool("OptiFG", "HudfixFullSync"));
|
||||
FGHudfixTrackRelease.set_from_config(readBool("OptiFG", "HudfixTrackRelease"));
|
||||
FGHudfixCBVTrackMode.set_from_config(readInt("OptiFG", "HudfixCBVTrackMode"));
|
||||
}
|
||||
|
||||
// Framerate
|
||||
@@ -609,6 +610,8 @@ bool Config::SaveIni()
|
||||
ini.SetValue("OptiFG", "HudfixHalfSync", GetBoolValue(Instance()->FGHudfixHalfSync.value_for_config()).c_str());
|
||||
ini.SetValue("OptiFG", "HudfixFullSync", GetBoolValue(Instance()->FGHudfixFullSync.value_for_config()).c_str());
|
||||
ini.SetValue("OptiFG", "HudfixTrackRelease", GetBoolValue(Instance()->FGHudfixTrackRelease.value_for_config()).c_str());
|
||||
|
||||
ini.SetValue("OptiFG", "HudfixCBVTrackMode", GetIntValue(Instance()->FGHudfixCBVTrackMode.value_for_config()).c_str());
|
||||
}
|
||||
|
||||
// Framerate
|
||||
|
||||
+3
-1
@@ -341,12 +341,14 @@ public:
|
||||
CustomOptional<bool> FGFramePacingTuning{ true };
|
||||
CustomOptional<float> FGFPTSafetyMarginInMs{ 0.01f };
|
||||
CustomOptional<float> FGFPTVarianceFactor{ 0.3f };
|
||||
CustomOptional<bool> FGFPTAllowHybridSpin{ true };
|
||||
CustomOptional<bool> FGFPTAllowHybridSpin{ false };
|
||||
CustomOptional<int> FGFPTHybridSpinTime{ 2 };
|
||||
CustomOptional<bool> FGFPTAllowWaitForSingleObjectOnFence{ false };
|
||||
CustomOptional<bool> FGHudfixHalfSync{ false };
|
||||
CustomOptional<bool> FGHudfixFullSync{ false };
|
||||
CustomOptional<bool> FGHudfixTrackRelease{ false };
|
||||
CustomOptional<int> FGHudfixCBVTrackMode{ 0 }; // 0 off, 1 after upscaler, 2 full
|
||||
|
||||
|
||||
// DLSS Enabler
|
||||
std::optional<int> DE_FramerateLimit; // off - vsync - number
|
||||
|
||||
@@ -1690,6 +1690,18 @@ bool MenuCommon::RenderMenu()
|
||||
}
|
||||
ShowHelpMarker("Always track resources, might cause performace issues\nbut also might fix HudFix related crashes!");
|
||||
|
||||
const char* cbv[] = { "Not Tracking", "Track After Upscaling", "Always Track" };
|
||||
if (ImGui::BeginCombo("CBV Tracking", cbv[Config::Instance()->FGHudfixCBVTrackMode.value_or_default()]))
|
||||
{
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
{
|
||||
if (ImGui::Selectable(cbv[i], (Config::Instance()->FGHudfixCBVTrackMode.value_or_default() == i)))
|
||||
Config::Instance()->FGHudfixCBVTrackMode = i;
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
auto tr = Config::Instance()->FGHudfixTrackRelease.value_or_default();
|
||||
if (ImGui::Checkbox("Track Resource Release", &tr))
|
||||
{
|
||||
|
||||
@@ -103,12 +103,12 @@ struct HeapCacheTLS
|
||||
unsigned genSeen = 0;
|
||||
};
|
||||
|
||||
static thread_local HeapCacheTLS cache;
|
||||
static thread_local HeapCacheTLS cacheRTV;
|
||||
static thread_local HeapCacheTLS cacheCBV;
|
||||
static thread_local HeapCacheTLS cacheSRV;
|
||||
static thread_local HeapCacheTLS cacheUAV;
|
||||
static std::atomic<unsigned> gHeapGeneration{ 1 };
|
||||
static thread_local HeapCacheTLS cache;
|
||||
static thread_local HeapCacheTLS cacheRTV;
|
||||
static thread_local HeapCacheTLS cacheCBV;
|
||||
static thread_local HeapCacheTLS cacheSRV;
|
||||
static thread_local HeapCacheTLS cacheUAV;
|
||||
static std::atomic<unsigned> gHeapGeneration{ 1 };
|
||||
|
||||
#ifdef USE_RESOURCE_DISCARD
|
||||
// created resources
|
||||
@@ -567,16 +567,19 @@ static void hkCreateDepthStencilView(ID3D12Device* This, ID3D12Resource* pResour
|
||||
//}
|
||||
}
|
||||
|
||||
static void hkCreateConstantBufferView(ID3D12Device* This, const D3D12_CONSTANT_BUFFER_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
void ResTrack_Dx12::hkCreateConstantBufferView(ID3D12Device* This, const D3D12_CONSTANT_BUFFER_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
o_CreateConstantBufferView(This, pDesc, DestDescriptor);
|
||||
|
||||
if (DestDescriptor.ptr != 0)
|
||||
if (Config::Instance()->FGHudfixCBVTrackMode.value_or_default() == 2 || (Config::Instance()->FGHudfixCBVTrackMode.value_or_default() == 1 && IsHudFixActive()))
|
||||
{
|
||||
auto heap = GetHeapByCpuHandleCBV(DestDescriptor.ptr);
|
||||
if (DestDescriptor.ptr != 0)
|
||||
{
|
||||
auto heap = GetHeapByCpuHandleCBV(DestDescriptor.ptr);
|
||||
|
||||
if (heap != nullptr)
|
||||
heap->ClearByCpuHandle(DestDescriptor.ptr);
|
||||
if (heap != nullptr)
|
||||
heap->ClearByCpuHandle(DestDescriptor.ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2008,6 +2011,9 @@ static void HookToQueue(ID3D12Device* InDevice)
|
||||
|
||||
void ResTrack_Dx12::HookDevice(ID3D12Device* device)
|
||||
{
|
||||
if (Config::Instance()->FGType.value_or_default() != OptiFG || !Config::Instance()->OverlayMenu.value_or_default())
|
||||
return;
|
||||
|
||||
if (o_CreateDescriptorHeap != nullptr || device == nullptr)
|
||||
return;
|
||||
|
||||
@@ -2032,7 +2038,7 @@ void ResTrack_Dx12::HookDevice(ID3D12Device* device)
|
||||
o_CopyDescriptorsSimple = (PFN_CopyDescriptorsSimple)pVTable[24];
|
||||
|
||||
// Apply the detour
|
||||
if (o_CreateDescriptorHeap != nullptr || o_CreateRenderTargetView != nullptr)
|
||||
if (o_CreateDescriptorHeap != nullptr)
|
||||
{
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
@@ -2040,33 +2046,29 @@ void ResTrack_Dx12::HookDevice(ID3D12Device* device)
|
||||
if (o_CreateDescriptorHeap != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateDescriptorHeap, hkCreateDescriptorHeap);
|
||||
|
||||
if (Config::Instance()->FGType.value_or_default() == OptiFG && Config::Instance()->OverlayMenu.value_or_default())
|
||||
{
|
||||
if (o_CreateConstantBufferView != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateConstantBufferView, hkCreateConstantBufferView);
|
||||
if (o_CreateConstantBufferView != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateConstantBufferView, hkCreateConstantBufferView);
|
||||
|
||||
if (o_CreateRenderTargetView != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateRenderTargetView, hkCreateRenderTargetView);
|
||||
if (o_CreateRenderTargetView != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateRenderTargetView, hkCreateRenderTargetView);
|
||||
|
||||
//if (o_CreateDepthStencilView != nullptr)
|
||||
// DetourAttach(&(PVOID&)o_CreateDepthStencilView, hkCreateDepthStencilView);
|
||||
//if (o_CreateDepthStencilView != nullptr)
|
||||
// DetourAttach(&(PVOID&)o_CreateDepthStencilView, hkCreateDepthStencilView);
|
||||
|
||||
//if (o_CreateSampler != nullptr)
|
||||
// DetourAttach(&(PVOID&)o_CreateSampler, hkCreateSampler);
|
||||
//if (o_CreateSampler != nullptr)
|
||||
// DetourAttach(&(PVOID&)o_CreateSampler, hkCreateSampler);
|
||||
|
||||
if (o_CreateShaderResourceView != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateShaderResourceView, hkCreateShaderResourceView);
|
||||
if (o_CreateShaderResourceView != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateShaderResourceView, hkCreateShaderResourceView);
|
||||
|
||||
if (o_CreateUnorderedAccessView != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateUnorderedAccessView, hkCreateUnorderedAccessView);
|
||||
if (o_CreateUnorderedAccessView != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CreateUnorderedAccessView, hkCreateUnorderedAccessView);
|
||||
|
||||
if (o_CopyDescriptors != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CopyDescriptors, hkCopyDescriptors);
|
||||
if (o_CopyDescriptors != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CopyDescriptors, hkCopyDescriptors);
|
||||
|
||||
if (o_CopyDescriptorsSimple != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CopyDescriptorsSimple, hkCopyDescriptorsSimple);
|
||||
|
||||
}
|
||||
if (o_CopyDescriptorsSimple != nullptr)
|
||||
DetourAttach(&(PVOID&)o_CopyDescriptorsSimple, hkCopyDescriptorsSimple);
|
||||
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
@@ -179,6 +179,8 @@ private:
|
||||
|
||||
static void hkExecuteBundle(ID3D12GraphicsCommandList* This, ID3D12GraphicsCommandList* pCommandList);
|
||||
|
||||
static void hkCreateConstantBufferView(ID3D12Device* This, const D3D12_CONSTANT_BUFFER_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor);
|
||||
|
||||
static ULONG hkRelease(ID3D12Resource* This);
|
||||
|
||||
static void HookCommandList(ID3D12Device* InDevice);
|
||||
|
||||
Reference in New Issue
Block a user