mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-11-22 13:47:11 +00:00
Add support for Enabler on Vulkan + new RDNA2/3 DLSSG Vk glitch workaround
Slopped.
This commit is contained in:
1 parent
d6b02459c6
commit
e366f98de2
16 files changed
+268
-39
No files matched your search
@@ -220,6 +220,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
|
||||
<ClInclude Include="framegen\IFGFeature_Dx12.h" />
|
||||
<ClInclude Include="framegen\IFGFeature_Vk.h" />
|
||||
<ClInclude Include="framegen\nvngx\Nvngx_FG.h" />
|
||||
<ClInclude Include="framegen\nvngx\NvngxVkLayouts.h" />
|
||||
<ClInclude Include="fsr4\FSR4DriverProviderDx12.h" />
|
||||
<ClInclude Include="fsr4\FSR4Models.h" />
|
||||
<ClInclude Include="fsr4\FSR4Presets.h" />
|
||||
|
||||
@@ -884,6 +884,9 @@
|
||||
<ClInclude Include="framegen\nvngx\Nvngx_FG.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framegen\nvngx\NvngxVkLayouts.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NVNGX_Parameter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -24,6 +24,10 @@ class IFGNvngx
|
||||
virtual bool isVulkanAvailable() = 0;
|
||||
virtual feature_version extraVersion() { return {}; }; // extra version the provider may want to report
|
||||
|
||||
// Whether the provider takes the DLSSG.DispatchFlags of DLSS Enabler's frame generation: antighosting, HUD handling
|
||||
// and debug views
|
||||
virtual bool supportsDispatchFlags() { return false; }
|
||||
|
||||
// D3D12
|
||||
virtual NVSDK_NGX_Result D3D12_Init(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath,
|
||||
ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo,
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
// Streamline and the DLSSG replacements sometimes transition an image from VK_IMAGE_LAYOUT_UNDEFINED while it still
|
||||
// holds a frame that is read next. RDNA2/3 reinitialize the DCC metadata on that and read the frame back as noise.
|
||||
// Such barriers start from the image's last seen layout instead.
|
||||
// Tracked images: the DLSSG parameters, plus anything barriered on the thread running the replacement's evaluate.
|
||||
class NvngxVkLayouts
|
||||
{
|
||||
inline static std::unordered_map<VkImage, VkImageLayout> _layouts;
|
||||
// ponytail: one global lock per barrier once DLSSG ran, shared_mutex or sharding if it shows in profiles
|
||||
inline static std::mutex _mutex;
|
||||
inline static std::atomic<bool> _active = false;
|
||||
|
||||
public:
|
||||
inline static thread_local bool inEvaluate = false;
|
||||
|
||||
static void Track(VkImage image)
|
||||
{
|
||||
std::scoped_lock lock(_mutex);
|
||||
_layouts.try_emplace(image, VK_IMAGE_LAYOUT_UNDEFINED);
|
||||
_active = true;
|
||||
}
|
||||
|
||||
// Handles get reused, a new image must not inherit the old one's layout
|
||||
static void Forget(VkImage image)
|
||||
{
|
||||
if (!_active)
|
||||
return;
|
||||
|
||||
std::scoped_lock lock(_mutex);
|
||||
_layouts.erase(image);
|
||||
}
|
||||
|
||||
// Returns barriers, or storage holding the fixed copies
|
||||
template <typename Barrier>
|
||||
static const Barrier* Fixup(const Barrier* barriers, uint32_t count, std::vector<Barrier>& storage)
|
||||
{
|
||||
if (barriers == nullptr || (!_active && !inEvaluate))
|
||||
return barriers;
|
||||
|
||||
std::scoped_lock lock(_mutex);
|
||||
|
||||
if (inEvaluate)
|
||||
_active = true;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++)
|
||||
{
|
||||
auto it = inEvaluate ? _layouts.try_emplace(barriers[i].image, VK_IMAGE_LAYOUT_UNDEFINED).first
|
||||
: _layouts.find(barriers[i].image);
|
||||
|
||||
if (it == _layouts.end())
|
||||
continue;
|
||||
|
||||
if (barriers[i].oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && it->second != VK_IMAGE_LAYOUT_UNDEFINED)
|
||||
{
|
||||
LOG_TRACE("Image {:X}: UNDEFINED -> {} now starts from {}", (size_t) barriers[i].image,
|
||||
(int) barriers[i].newLayout, (int) it->second);
|
||||
|
||||
if (storage.empty())
|
||||
storage.assign(barriers, barriers + count);
|
||||
|
||||
storage[i].oldLayout = it->second;
|
||||
}
|
||||
|
||||
it->second = barriers[i].newLayout;
|
||||
}
|
||||
|
||||
return storage.empty() ? barriers : storage.data();
|
||||
}
|
||||
|
||||
static const VkDependencyInfo* Fixup(const VkDependencyInfo* info, VkDependencyInfo& copy,
|
||||
std::vector<VkImageMemoryBarrier2>& storage)
|
||||
{
|
||||
if (info == nullptr ||
|
||||
Fixup(info->pImageMemoryBarriers, info->imageMemoryBarrierCount, storage) == info->pImageMemoryBarriers)
|
||||
return info;
|
||||
|
||||
copy = *info;
|
||||
copy.pImageMemoryBarriers = storage.data();
|
||||
return ©
|
||||
}
|
||||
};
|
||||
@@ -19,19 +19,13 @@ void Nvngx_Arturs::QueryVersions()
|
||||
_version = tempVersion;
|
||||
|
||||
// Antighosting version
|
||||
NVNGX_Parameters tempParams(API::DX12, false);
|
||||
QueryReportedParameters();
|
||||
|
||||
if (_DLSSG_D3D12_PopulateParameters_Impl(&tempParams) == NVSDK_NGX_Result_Success)
|
||||
{
|
||||
auto result = tempParams.Get("FrameInterpolation.GhostbusterVersionMajor", &ghostbusterVersion.major);
|
||||
tempParams.Get("FrameInterpolation.GhostbusterVersionMinor", &ghostbusterVersion.minor);
|
||||
|
||||
if (result != NVSDK_NGX_Result_Success)
|
||||
LOG_WARN("Couldn't query version");
|
||||
}
|
||||
if (!Nvngx_DllProxy::supportsDispatchFlags())
|
||||
LOG_WARN("Couldn't query version");
|
||||
|
||||
LOG_INFO("DE Ver: {}.{}.{}.{}, GB Ver: {}.{}", _version.major, _version.minor, _version.patch, _version.reserved,
|
||||
ghostbusterVersion.major, ghostbusterVersion.minor);
|
||||
antighostingVersion.major, antighostingVersion.minor);
|
||||
}
|
||||
|
||||
void Nvngx_Arturs::LoadLibraries()
|
||||
@@ -62,6 +56,26 @@ void Nvngx_Arturs::LoadLibraries()
|
||||
_DLSSG_D3D12_PopulateParameters_Impl =
|
||||
(PFN_D3D12_PopulateParameters_Impl) GetProcAddress(dll, "DLSSG_NVSDK_NGX_D3D12_PopulateParameters_Impl");
|
||||
|
||||
_DLSSG_VULKAN_Init = (PFN_VULKAN_Init) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_Init");
|
||||
_DLSSG_VULKAN_Init_Ext = (PFN_VULKAN_Init_Ext) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_Init_Ext");
|
||||
_DLSSG_VULKAN_Init_Ext2 = (PFN_VULKAN_Init_Ext2) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_Init_Ext2");
|
||||
_DLSSG_VULKAN_Shutdown = (PFN_VULKAN_Shutdown) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_Shutdown");
|
||||
_DLSSG_VULKAN_Shutdown1 = (PFN_VULKAN_Shutdown1) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_Shutdown1");
|
||||
_DLSSG_VULKAN_GetScratchBufferSize =
|
||||
(PFN_VULKAN_GetScratchBufferSize) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_GetScratchBufferSize");
|
||||
_DLSSG_VULKAN_CreateFeature =
|
||||
(PFN_VULKAN_CreateFeature) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_CreateFeature");
|
||||
_DLSSG_VULKAN_CreateFeature1 =
|
||||
(PFN_VULKAN_CreateFeature1) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_CreateFeature1");
|
||||
_DLSSG_VULKAN_ReleaseFeature =
|
||||
(PFN_VULKAN_ReleaseFeature) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_ReleaseFeature");
|
||||
_DLSSG_VULKAN_GetFeatureRequirements =
|
||||
(PFN_VULKAN_GetFeatureRequirements) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_GetFeatureRequirements");
|
||||
_DLSSG_VULKAN_EvaluateFeature =
|
||||
(PFN_VULKAN_EvaluateFeature) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_EvaluateFeature");
|
||||
_DLSSG_VULKAN_PopulateParameters_Impl =
|
||||
(PFN_VULKAN_PopulateParameters_Impl) GetProcAddress(dll, "DLSSG_NVSDK_NGX_VULKAN_PopulateParameters_Impl");
|
||||
|
||||
QueryVersions();
|
||||
|
||||
LOG_INFO("Artur's initialized");
|
||||
@@ -71,5 +85,3 @@ void Nvngx_Arturs::LoadLibraries()
|
||||
LOG_WARN("Artur's enabled but cannot be loaded");
|
||||
}
|
||||
}
|
||||
|
||||
feature_version Nvngx_Arturs::extraVersion() { return ghostbusterVersion; }
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
class Nvngx_Arturs : public Nvngx_DllProxy
|
||||
{
|
||||
feature_version ghostbusterVersion {};
|
||||
|
||||
void QueryVersions();
|
||||
|
||||
protected:
|
||||
@@ -15,5 +13,7 @@ class Nvngx_Arturs : public Nvngx_DllProxy
|
||||
|
||||
int getMaxFakeFramesCount() override { return 5; }
|
||||
FGNvngxReplacement getType() override { return FGNvngxReplacement::Arturs; }
|
||||
feature_version extraVersion() override;
|
||||
|
||||
// DLSS Enabler's own, even when it doesn't report its antighosting version
|
||||
bool supportsDispatchFlags() override { return true; }
|
||||
};
|
||||
@@ -68,4 +68,5 @@ class Nvngx_Combo : public IFGNvngx
|
||||
FGNvngxReplacement getType() override { return FGNvngxReplacement::Combo; }
|
||||
feature_version version() override;
|
||||
feature_version extraVersion() override;
|
||||
bool supportsDispatchFlags() override { return artursProvider->supportsDispatchFlags(); }
|
||||
};
|
||||
@@ -13,17 +13,11 @@ void Nvngx_Custom::LoadLibraries()
|
||||
LoadNgxExports();
|
||||
|
||||
// Max fake frames are reported like DLSSG does, which only reports them once inited
|
||||
auto populate = _DLSSG_D3D12_PopulateParameters_Impl != nullptr
|
||||
? _DLSSG_D3D12_PopulateParameters_Impl
|
||||
: (PFN_D3D12_PopulateParameters_Impl) _DLSSG_VULKAN_PopulateParameters_Impl;
|
||||
NVNGX_Parameters params(API::DX12, false);
|
||||
int countMax = 0;
|
||||
QueryReportedParameters();
|
||||
|
||||
if (populate != nullptr && populate(¶ms) == NVSDK_NGX_Result_Success &&
|
||||
params.Get("DLSSG.MultiFrameCountMax", &countMax) == NVSDK_NGX_Result_Success && countMax > 0)
|
||||
{
|
||||
_maxFakeFrames = countMax;
|
||||
}
|
||||
|
||||
LOG_INFO("Custom DLSSG {} initialized, max fake frames: {}", _name, _maxFakeFrames);
|
||||
if (!Nvngx_DllProxy::supportsDispatchFlags())
|
||||
LOG_INFO("Custom DLSSG {} initialized, max fake frames: {}", _name, getMaxFakeFramesCount());
|
||||
else
|
||||
LOG_INFO("Custom DLSSG {} initialized, max fake frames: {}, antighosting version: {}.{}", _name,
|
||||
getMaxFakeFramesCount(), antighostingVersion.major, antighostingVersion.minor);
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
class Nvngx_Custom : public Nvngx_DllProxy
|
||||
{
|
||||
std::string _name;
|
||||
int _maxFakeFrames = 1;
|
||||
|
||||
protected:
|
||||
void LoadLibraries() override final;
|
||||
@@ -13,6 +12,6 @@ class Nvngx_Custom : public Nvngx_DllProxy
|
||||
public:
|
||||
explicit Nvngx_Custom(std::string name) : _name(std::move(name)) { LoadLibraries(); }
|
||||
|
||||
int getMaxFakeFramesCount() override { return _maxFakeFrames; }
|
||||
int getMaxFakeFramesCount() override { return reportedMaxFakeFrames > 0 ? reportedMaxFakeFrames : 1; }
|
||||
FGNvngxReplacement getType() override { return FGNvngxReplacement::Custom; }
|
||||
};
|
||||
@@ -37,6 +37,37 @@ void Nvngx_DllProxy::LoadNgxExports()
|
||||
(PFN_VULKAN_PopulateParameters_Impl) GetProcAddress(dll, "NVSDK_NGX_VULKAN_PopulateParameters_Impl");
|
||||
}
|
||||
|
||||
void Nvngx_DllProxy::QueryReportedParameters()
|
||||
{
|
||||
// Both take the same parameters, which aren't tied to an API
|
||||
auto populate = _DLSSG_D3D12_PopulateParameters_Impl != nullptr
|
||||
? _DLSSG_D3D12_PopulateParameters_Impl
|
||||
: (PFN_D3D12_PopulateParameters_Impl) _DLSSG_VULKAN_PopulateParameters_Impl;
|
||||
NVNGX_Parameters params(API::DX12, false);
|
||||
|
||||
if (populate == nullptr || populate(¶ms) != NVSDK_NGX_Result_Success)
|
||||
return;
|
||||
|
||||
int countMax = 0;
|
||||
if (params.Get("DLSSG.MultiFrameCountMax", &countMax) == NVSDK_NGX_Result_Success && countMax > 0)
|
||||
reportedMaxFakeFrames = countMax;
|
||||
|
||||
if (params.Get("FrameInterpolation.GhostbusterVersionMajor", &antighostingVersion.major) ==
|
||||
NVSDK_NGX_Result_Success)
|
||||
{
|
||||
params.Get("FrameInterpolation.GhostbusterVersionMinor", &antighostingVersion.minor);
|
||||
}
|
||||
}
|
||||
|
||||
void Nvngx_DllProxy::SetDispatchFlags(NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
bool showDebug = Config::Instance()->NvngxFGShowDebug.value_or_default();
|
||||
uint32_t flags = Config::Instance()->NvngxFGDispatchFlags.value_or_default();
|
||||
|
||||
InParameters->Set("DLSSG.ShowDebug", showDebug);
|
||||
InParameters->Set("DLSSG.DispatchFlags", flags);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result Nvngx_DllProxy::D3D12_Init(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath,
|
||||
ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo,
|
||||
NVSDK_NGX_Version InSDKVersion)
|
||||
@@ -224,11 +255,7 @@ NVSDK_NGX_Result Nvngx_DllProxy::D3D12_EvaluateFeature(ID3D12GraphicsCommandList
|
||||
DeferredRelease::Release(depthCopy[1]);
|
||||
}
|
||||
|
||||
bool showDebug = Config::Instance()->NvngxFGShowDebug.value_or_default();
|
||||
uint32_t flags = Config::Instance()->NvngxFGDispatchFlags.value_or_default();
|
||||
|
||||
InParameters->Set("DLSSG.ShowDebug", showDebug);
|
||||
InParameters->Set("DLSSG.DispatchFlags", flags);
|
||||
SetDispatchFlags(InParameters);
|
||||
|
||||
return _DLSSG_D3D12_EvaluateFeature(InCmdList, InFeatureHandle, InParameters, InCallback);
|
||||
}
|
||||
@@ -350,6 +377,8 @@ NVSDK_NGX_Result Nvngx_DllProxy::VULKAN_EvaluateFeature(VkCommandBuffer InCmdLis
|
||||
{
|
||||
if (isVulkanAvailable())
|
||||
{
|
||||
SetDispatchFlags(InParameters);
|
||||
|
||||
return _DLSSG_VULKAN_EvaluateFeature(InCmdList, InFeatureHandle, InParameters, InCallback);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,20 @@ class Nvngx_DllProxy : public IFGNvngx
|
||||
PFN_VULKAN_EvaluateFeature _DLSSG_VULKAN_EvaluateFeature = nullptr;
|
||||
PFN_VULKAN_PopulateParameters_Impl _DLSSG_VULKAN_PopulateParameters_Impl = nullptr;
|
||||
|
||||
// What PopulateParameters reports before init
|
||||
int reportedMaxFakeFrames = 0;
|
||||
feature_version antighostingVersion {};
|
||||
|
||||
virtual void LoadLibraries() = 0;
|
||||
|
||||
void LoadNgxExports();
|
||||
|
||||
// Fills reportedMaxFakeFrames and antighostingVersion from PopulateParameters, D3D12's or else Vulkan's
|
||||
void QueryReportedParameters();
|
||||
|
||||
// DLSSG.ShowDebug and DLSSG.DispatchFlags from the config
|
||||
static void SetDispatchFlags(NVSDK_NGX_Parameter* InParameters);
|
||||
|
||||
public:
|
||||
Nvngx_DllProxy() = default;
|
||||
~Nvngx_DllProxy()
|
||||
@@ -52,6 +62,11 @@ class Nvngx_DllProxy : public IFGNvngx
|
||||
bool isDx12Available() override final { return _DLSSG_D3D12_Init != nullptr; };
|
||||
bool isVulkanAvailable() override final { return _DLSSG_VULKAN_Init != nullptr; };
|
||||
|
||||
// A provider reporting the antighosting (GhostBuster) version is DLSS Enabler's frame generation or passes its
|
||||
// parameters through, so it takes DLSS Enabler's DLSSG.DispatchFlags
|
||||
feature_version extraVersion() override { return antighostingVersion; }
|
||||
bool supportsDispatchFlags() override { return antighostingVersion.major != 0 || antighostingVersion.minor != 0; }
|
||||
|
||||
// D3D12
|
||||
NVSDK_NGX_Result D3D12_Init(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath,
|
||||
ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "Nvngx_FFX.h"
|
||||
#include "Nvngx_Combo.h"
|
||||
#include "Nvngx_Custom.h"
|
||||
#include "NvngxVkLayouts.h"
|
||||
#include <imgui/ImGuiNotify.hpp>
|
||||
#include <nvsdk_ngx_vk.h>
|
||||
|
||||
@@ -189,6 +190,16 @@ feature_version Nvngx_FG::extraVersion()
|
||||
return provider->extraVersion();
|
||||
}
|
||||
|
||||
bool Nvngx_FG::supportsDispatchFlags()
|
||||
{
|
||||
auto* provider = getProvider();
|
||||
|
||||
if (!provider)
|
||||
return false;
|
||||
|
||||
return provider->supportsDispatchFlags();
|
||||
}
|
||||
|
||||
void Nvngx_FG::setDebugView(bool enabled)
|
||||
{
|
||||
auto* provider = getProvider();
|
||||
@@ -730,9 +741,37 @@ NVSDK_NGX_Result Nvngx_FG::VULKAN_EvaluateFeature(VkCommandBuffer InCmdList, con
|
||||
if (Config::Instance()->NvngxFGDisableHudless.value_or_default())
|
||||
InParameters->Set("DLSSG.HUDLess", (void*) nullptr);
|
||||
|
||||
static constexpr const char* trackedImages[] = {
|
||||
"DLSSG.Backbuffer",
|
||||
"DLSSG.MVecs",
|
||||
"DLSSG.Depth",
|
||||
"DLSSG.HUDLess",
|
||||
"DLSSG.UI",
|
||||
"DLSSG.UIAlpha",
|
||||
"DLSSG.NoWarp",
|
||||
"DLSSG.BidirectionalDistortionField",
|
||||
"DLSSG.OutputInterpolated",
|
||||
"DLSSG.OutputReal",
|
||||
"DLSSG.OutputDisableInterpolation",
|
||||
};
|
||||
|
||||
for (auto name : trackedImages)
|
||||
{
|
||||
NVSDK_NGX_Resource_VK* resource = nullptr;
|
||||
|
||||
if (InParameters->Get(name, (void**) &resource) == NVSDK_NGX_Result_Success && resource != nullptr &&
|
||||
resource->Type == NVSDK_NGX_RESOURCE_VK_TYPE_VK_IMAGEVIEW)
|
||||
{
|
||||
NvngxVkLayouts::Track(resource->Resource.ImageViewInfo.Image);
|
||||
}
|
||||
}
|
||||
|
||||
// LOG_TRACE("Handle received from the game: {:X}", (uint64_t) InFeatureHandle);
|
||||
|
||||
return provider->VULKAN_EvaluateFeature(InCmdList, ourHandle->nativeHandle, InParameters, InCallback);
|
||||
NvngxVkLayouts::inEvaluate = true;
|
||||
auto result = provider->VULKAN_EvaluateFeature(InCmdList, ourHandle->nativeHandle, InParameters, InCallback);
|
||||
NvngxVkLayouts::inEvaluate = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result Nvngx_FG::VULKAN_PopulateParameters_Impl(NVSDK_NGX_Parameter* InParameters)
|
||||
|
||||
@@ -44,6 +44,7 @@ class Nvngx_FG
|
||||
static bool isVulkanAvailable();
|
||||
static feature_version version();
|
||||
static feature_version extraVersion();
|
||||
static bool supportsDispatchFlags();
|
||||
|
||||
// TODO: nukem-specific, unify
|
||||
static void setDebugView(bool enabled);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <misc/IdentifyGpu.h>
|
||||
#include <framegen/nvngx/NvngxVkLayouts.h>
|
||||
|
||||
static PFN_vkQueueSubmit o_vkQueueSubmit = nullptr;
|
||||
static PFN_vkQueueSubmit2 o_vkQueueSubmit2 = nullptr;
|
||||
@@ -33,6 +34,8 @@ static PFN_vkCreateCommandPool o_vkCreateCommandPool = nullptr;
|
||||
static std::mutex mutexCommandPoolToQueueFamilyMap;
|
||||
static std::unordered_map<VkCommandPool, uint32_t> commandPoolToQueueFamilyMap;
|
||||
|
||||
static PFN_vkDestroyImage o_vkDestroyImage = nullptr;
|
||||
|
||||
// #define LOG_ALL_RECORDS
|
||||
|
||||
#ifndef LOG_ALL_RECORDS
|
||||
@@ -1056,6 +1059,9 @@ void Vulkan_wDx12::hk_vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipe
|
||||
uint32_t imageMemoryBarrierCount,
|
||||
const VkImageMemoryBarrier* pImageMemoryBarriers)
|
||||
{
|
||||
std::vector<VkImageMemoryBarrier> fixedBarriers;
|
||||
pImageMemoryBarriers = NvngxVkLayouts::Fixup(pImageMemoryBarriers, imageMemoryBarrierCount, fixedBarriers);
|
||||
|
||||
auto primaryGpu = IdentifyGpu::getPrimaryGpu();
|
||||
if (State::Instance().gameQuirks & GameQuirk::VulkanDLSSBarrierFixup &&
|
||||
(primaryGpu.vendorId != VendorId::Nvidia || !primaryGpu.dlssCapable))
|
||||
@@ -1130,6 +1136,12 @@ void Vulkan_wDx12::hk_vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipe
|
||||
pImageMemoryBarriers);
|
||||
}
|
||||
|
||||
void Vulkan_wDx12::hk_vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
NvngxVkLayouts::Forget(image);
|
||||
o_vkDestroyImage(device, image, pAllocator);
|
||||
}
|
||||
|
||||
void Vulkan_wDx12::hk_vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query,
|
||||
VkQueryControlFlags flags)
|
||||
{
|
||||
@@ -1560,6 +1572,10 @@ void Vulkan_wDx12::hk_vkCmdWaitEvents2(VkCommandBuffer commandBuffer, uint32_t e
|
||||
|
||||
void Vulkan_wDx12::hk_vkCmdPipelineBarrier2(VkCommandBuffer commandBuffer, const VkDependencyInfo* pDependencyInfo)
|
||||
{
|
||||
std::vector<VkImageMemoryBarrier2> fixedBarriers;
|
||||
VkDependencyInfo fixedInfo;
|
||||
pDependencyInfo = NvngxVkLayouts::Fixup(pDependencyInfo, fixedInfo, fixedBarriers);
|
||||
|
||||
VkCommandBuffer cmdBuffer = commandBuffer;
|
||||
|
||||
auto mappedVirtualCmdBuffer = GetVirtualCommandBuffer(cmdBuffer);
|
||||
@@ -2778,6 +2794,10 @@ void Vulkan_wDx12::hk_vkCmdWaitEvents2KHR(VkCommandBuffer commandBuffer, uint32_
|
||||
|
||||
void Vulkan_wDx12::hk_vkCmdPipelineBarrier2KHR(VkCommandBuffer commandBuffer, const VkDependencyInfo* pDependencyInfo)
|
||||
{
|
||||
std::vector<VkImageMemoryBarrier2> fixedBarriers;
|
||||
VkDependencyInfo fixedInfo;
|
||||
pDependencyInfo = NvngxVkLayouts::Fixup(pDependencyInfo, fixedInfo, fixedBarriers);
|
||||
|
||||
VkCommandBuffer cmdBuffer = commandBuffer;
|
||||
|
||||
auto mappedVirtualCmdBuffer = GetVirtualCommandBuffer(cmdBuffer);
|
||||
@@ -7447,6 +7467,13 @@ PFN_vkVoidFunction Vulkan_wDx12::GetAddress(const PFN_vkVoidFunction original, c
|
||||
|
||||
return (PFN_vkVoidFunction) hk_vkCmdWaitEvents;
|
||||
}
|
||||
if (procName == std::string("vkDestroyImage"))
|
||||
{
|
||||
if (o_vkDestroyImage == nullptr)
|
||||
o_vkDestroyImage = (PFN_vkDestroyImage) original;
|
||||
|
||||
return (PFN_vkVoidFunction) hk_vkDestroyImage;
|
||||
}
|
||||
if (procName == std::string("vkCmdPipelineBarrier"))
|
||||
{
|
||||
// LOG_DEBUG("vkCmdPipelineBarrier");
|
||||
@@ -9637,6 +9664,7 @@ void Vulkan_wDx12::Hook(HMODULE vulkanModule)
|
||||
o_vkCmdResetEvent = (PFN_vkCmdResetEvent) DetouredExport(vulkanModule, "vkCmdResetEvent");
|
||||
o_vkCmdWaitEvents = (PFN_vkCmdWaitEvents) DetouredExport(vulkanModule, "vkCmdWaitEvents");
|
||||
o_vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) DetouredExport(vulkanModule, "vkCmdPipelineBarrier");
|
||||
o_vkDestroyImage = (PFN_vkDestroyImage) DetouredExport(vulkanModule, "vkDestroyImage");
|
||||
o_vkCmdBeginQuery = (PFN_vkCmdBeginQuery) DetouredExport(vulkanModule, "vkCmdBeginQuery");
|
||||
o_vkCmdEndQuery = (PFN_vkCmdEndQuery) DetouredExport(vulkanModule, "vkCmdEndQuery");
|
||||
o_vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool) DetouredExport(vulkanModule, "vkCmdResetQueryPool");
|
||||
@@ -10170,6 +10198,9 @@ void Vulkan_wDx12::Hook(HMODULE vulkanModule)
|
||||
if (o_vkCmdPipelineBarrier)
|
||||
DetourAttach(&(PVOID&) o_vkCmdPipelineBarrier, hk_vkCmdPipelineBarrier);
|
||||
|
||||
if (o_vkDestroyImage)
|
||||
DetourAttach(&(PVOID&) o_vkDestroyImage, hk_vkDestroyImage);
|
||||
|
||||
if (o_vkCmdBeginQuery)
|
||||
DetourAttach(&(PVOID&) o_vkCmdBeginQuery, hk_vkCmdBeginQuery);
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ class Vulkan_wDx12
|
||||
const VkBufferMemoryBarrier* pBufferMemoryBarriers,
|
||||
uint32_t imageMemoryBarrierCount,
|
||||
const VkImageMemoryBarrier* pImageMemoryBarriers);
|
||||
static void hk_vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator);
|
||||
static void hk_vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query,
|
||||
VkQueryControlFlags flags);
|
||||
static void hk_vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query);
|
||||
@@ -655,6 +656,7 @@ class Vulkan_wDx12
|
||||
VALIDATE_MEMBER_HOOK(hk_vkCmdResetEvent, PFN_vkCmdResetEvent)
|
||||
VALIDATE_MEMBER_HOOK(hk_vkCmdWaitEvents, PFN_vkCmdWaitEvents)
|
||||
VALIDATE_MEMBER_HOOK(hk_vkCmdPipelineBarrier, PFN_vkCmdPipelineBarrier)
|
||||
VALIDATE_MEMBER_HOOK(hk_vkDestroyImage, PFN_vkDestroyImage)
|
||||
VALIDATE_MEMBER_HOOK(hk_vkCmdBeginQuery, PFN_vkCmdBeginQuery)
|
||||
VALIDATE_MEMBER_HOOK(hk_vkCmdEndQuery, PFN_vkCmdEndQuery)
|
||||
VALIDATE_MEMBER_HOOK(hk_vkCmdResetQueryPool, PFN_vkCmdResetQueryPool)
|
||||
|
||||
@@ -6350,12 +6350,21 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
|
||||
if (isLoaded)
|
||||
{
|
||||
if (activeNvngxFg == FGNvngxReplacement::Arturs || activeNvngxFg == FGNvngxReplacement::Combo)
|
||||
// DLSS Enabler's own, or any custom provider reporting its antighosting version
|
||||
if (Nvngx_FG::supportsDispatchFlags())
|
||||
{
|
||||
auto featureVer = Nvngx_FG::version();
|
||||
auto antighostingVer = Nvngx_FG::extraVersion();
|
||||
ImGui::Text("DE Ver: %d.%d.%d.%d GB Ver: %d.%d", featureVer.major, featureVer.minor, featureVer.patch,
|
||||
featureVer.reserved, antighostingVer.major, antighostingVer.minor);
|
||||
|
||||
if (activeNvngxFg == FGNvngxReplacement::Arturs || activeNvngxFg == FGNvngxReplacement::Combo)
|
||||
{
|
||||
auto featureVer = Nvngx_FG::version();
|
||||
ImGui::Text("DE Ver: %d.%d.%d.%d GB Ver: %d.%d", featureVer.major, featureVer.minor,
|
||||
featureVer.patch, featureVer.reserved, antighostingVer.major, antighostingVer.minor);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("GB Ver: %d.%d", antighostingVer.major, antighostingVer.minor);
|
||||
}
|
||||
|
||||
static std::vector<FlagDefinition> common_flags = {
|
||||
{ "Antighosting (GB)", 0x00100000, "Enable anti-ghosting correction" },
|
||||
|
||||
Reference in new issue
Block a user