mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-09-25 14:56:04 +00:00
checkpoint
This commit is contained in:
@@ -0,0 +1,197 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{8d2b73fb-eecd-45ce-b8e5-335610462f58}</ProjectGuid>
|
||||
<RootNamespace>CyberXeSS</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)\external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(VULKAN_SDK)\include;$(XESS_SDK)\inc\xess;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(XESS_SDK)\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)\external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(VULKAN_SDK)\include;$(XESS_SDK)\inc\xess;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(XESS_SDK)\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\vulkan\include;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(ProjectDir)external\minhook\build\VC17\bin\Debug;$(SolutionDir)external\xess\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>nvngx</TargetName>
|
||||
<OutDir>..\..\God of War</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\vulkan\include;$(IncludePath)</IncludePath>
|
||||
<TargetName>nvngx</TargetName>
|
||||
<LibraryPath>$(SolutionDir)external\xess\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;CYBERXESS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;CYBERXESS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;CYBERXESS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>d3d11.lib;dxgi.lib;d3d12.lib;dxguid.lib;libxess.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;CYBERXESS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>d3d11.lib;d3dx11.lib;dxgi.lib;d3d12.lib;dxguid.lib;libxess.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Config.h" />
|
||||
<ClInclude Include="CyberXess.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="NvParameter.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="Util.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Config.cpp" />
|
||||
<ClCompile Include="CyberXess.cpp" />
|
||||
<ClCompile Include="CyberXessDx11.cpp" />
|
||||
<ClCompile Include="CyberXessDx12.cpp" />
|
||||
<ClCompile Include="CyberXessVk.cpp" />
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="NvParameter.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CyberXess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Util.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NvParameter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CyberXess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NvParameter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CyberXessDx12.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CyberXessDx11.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CyberXessVk.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -79,14 +79,15 @@
|
||||
<LibraryPath>$(XESS_SDK)\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\vulkan\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)external\xess\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\vulkan\include;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(ProjectDir)external\minhook\build\VC17\bin\Debug;$(SolutionDir)external\xess\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>nvngx</TargetName>
|
||||
<OutDir>..\..\..\Games\God of War</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\vulkan\include;$(IncludePath)</IncludePath>
|
||||
<TargetName>nvngx</TargetName>
|
||||
<LibraryPath>$(SolutionDir)external\xess\lib;$(LibraryPath)</LibraryPath>
|
||||
<LibraryPath>$(SolutionDir)external\xess\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -140,7 +141,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>dxguid.lib;libxess.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>d3d11.lib;dxgi.lib;d3d12.lib;dxguid.lib;libxess.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -162,7 +163,7 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>libxess.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>d3d11.lib;dxgi.lib;d3d12.lib;dxguid.lib;libxess.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
FeatureContext* CyberXessContext::CreateContext()
|
||||
{
|
||||
auto handleId = rand();
|
||||
auto handleId = handleCounter++;
|
||||
Contexts[handleId] = std::make_unique<FeatureContext>();
|
||||
Contexts[handleId]->Handle.Id = handleId;
|
||||
return Contexts[handleId].get();
|
||||
@@ -24,3 +24,4 @@ CyberXessContext::CyberXessContext()
|
||||
{
|
||||
MyConfig = std::make_unique<Config>(L"nvngx.ini");
|
||||
}
|
||||
|
||||
|
||||
+244
-4
@@ -3,6 +3,9 @@
|
||||
#include "NvParameter.h"
|
||||
#include "xess_d3d12.h"
|
||||
#include "xess_debug.h"
|
||||
#include "dxgi1_6.h"
|
||||
|
||||
static unsigned int handleCounter = 1000;
|
||||
|
||||
class FeatureContext;
|
||||
|
||||
@@ -11,17 +14,98 @@ class CyberXessContext
|
||||
{
|
||||
CyberXessContext();
|
||||
|
||||
void GetHardwareAdapter(IDXGIFactory1* pFactory, IDXGIAdapter** ppAdapter, D3D_FEATURE_LEVEL featureLevel, bool requestHighPerformanceAdapter) const
|
||||
{
|
||||
*ppAdapter = nullptr;
|
||||
|
||||
IDXGIAdapter1* adapter;
|
||||
|
||||
IDXGIFactory6* factory6;
|
||||
if (SUCCEEDED(pFactory->QueryInterface(IID_PPV_ARGS(&factory6))))
|
||||
{
|
||||
for (
|
||||
UINT adapterIndex = 0;
|
||||
DXGI_ERROR_NOT_FOUND != factory6->EnumAdapterByGpuPreference(
|
||||
adapterIndex,
|
||||
requestHighPerformanceAdapter == true ? DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE : DXGI_GPU_PREFERENCE_UNSPECIFIED,
|
||||
IID_PPV_ARGS(&adapter));
|
||||
++adapterIndex)
|
||||
{
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
adapter->GetDesc1(&desc);
|
||||
|
||||
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
|
||||
{
|
||||
// Don't select the Basic Render Driver adapter.
|
||||
// If you want a software adapter, pass in "/warp" on the command line.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check to see whether the adapter supports Direct3D 12, but don't create the
|
||||
// actual device yet.
|
||||
|
||||
auto result = D3D12CreateDevice(adapter, featureLevel, _uuidof(ID3D12Device), nullptr);
|
||||
|
||||
if (result == S_FALSE)
|
||||
{
|
||||
*ppAdapter = adapter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != pFactory->EnumAdapters1(adapterIndex, &adapter); ++adapterIndex)
|
||||
{
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
adapter->GetDesc1(&desc);
|
||||
|
||||
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
|
||||
{
|
||||
// Don't select the Basic Render Driver adapter.
|
||||
// If you want a software adapter, pass in "/warp" on the command line.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check to see whether the adapter supports Direct3D 12, but don't create the
|
||||
// actual device yet.
|
||||
|
||||
auto result = D3D12CreateDevice(adapter, featureLevel, _uuidof(ID3D12Device), nullptr);
|
||||
|
||||
if (result == S_FALSE)
|
||||
{
|
||||
*ppAdapter = adapter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
std::shared_ptr<Config> MyConfig;
|
||||
|
||||
bool init = false;
|
||||
const NvParameter* CreateFeatureParams;
|
||||
ID3D12Device* Dx12Device = nullptr;
|
||||
ID3D11Device* Dx11Device = nullptr;
|
||||
|
||||
// D3D12 stuff
|
||||
ID3D12Device* Dx12Device = nullptr;
|
||||
|
||||
// D3D11 stuff
|
||||
ID3D11Device5* Dx11Device = nullptr;
|
||||
ID3D11DeviceContext4* Dx11DeviceContext = nullptr;
|
||||
|
||||
// D3D11on12 stuff
|
||||
ID3D12CommandQueue* Dx12CommandQueue = nullptr;
|
||||
ID3D12CommandAllocator* Dx12CommandAllocator[2] = { nullptr, nullptr };
|
||||
ID3D12GraphicsCommandList* Dx12CommandList[2] = { nullptr, nullptr };
|
||||
ID3D12Fence* Dx12Fence = nullptr;
|
||||
|
||||
// Vulkan stuff
|
||||
VkDevice VulkanDevice = nullptr;
|
||||
VkInstance VulkanInstance = nullptr;
|
||||
VkPhysicalDevice VulkanPhysicalDevice = nullptr;
|
||||
|
||||
|
||||
std::shared_ptr<NvParameter> NvParameterInstance = NvParameter::instance();
|
||||
|
||||
ankerl::unordered_dense::map <unsigned int, std::unique_ptr<FeatureContext>> Contexts;
|
||||
@@ -33,13 +117,145 @@ public:
|
||||
static std::shared_ptr<CyberXessContext> INSTANCE{ std::make_shared<CyberXessContext>(CyberXessContext()) };
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
void Shutdown(bool fromDx11 = false, bool shutdownEvent = false) const
|
||||
{
|
||||
if (CyberXessContext::instance()->Dx12Fence != nullptr && fromDx11 && shutdownEvent)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12Fence->Release();
|
||||
CyberXessContext::instance()->Dx12Fence = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandList[0] != nullptr && fromDx11 && shutdownEvent)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandList[0]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandList[0] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandList[1] != nullptr && fromDx11 && shutdownEvent)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandList[1]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandList[1] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandQueue != nullptr && fromDx11 && shutdownEvent)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandQueue->Release();
|
||||
CyberXessContext::instance()->Dx12CommandQueue = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandAllocator[0] != nullptr && fromDx11 && shutdownEvent)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[0]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[0] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandAllocator[1] != nullptr && fromDx11 && shutdownEvent)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[1]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[1] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12Device != nullptr && fromDx11 && shutdownEvent)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12Device->Release();
|
||||
CyberXessContext::instance()->Dx12Device = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->VulkanInstance != nullptr)
|
||||
CyberXessContext::instance()->VulkanInstance = nullptr;
|
||||
|
||||
if (CyberXessContext::instance()->VulkanDevice != nullptr)
|
||||
CyberXessContext::instance()->VulkanDevice = nullptr;
|
||||
|
||||
if (CyberXessContext::instance()->VulkanPhysicalDevice != nullptr)
|
||||
CyberXessContext::instance()->VulkanPhysicalDevice = nullptr;
|
||||
|
||||
}
|
||||
|
||||
HRESULT CreateDx12Device(D3D_FEATURE_LEVEL featureLevel)
|
||||
{
|
||||
if (Dx12Device != nullptr)
|
||||
return S_OK;
|
||||
|
||||
HRESULT result;
|
||||
|
||||
IDXGIFactory4* factory;
|
||||
result = CreateDXGIFactory2(0, IID_PPV_ARGS(&factory));
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG("CreateDx12Device Can't create factory: " + int_to_hex(result), LEVEL_ERROR);
|
||||
return result;
|
||||
}
|
||||
|
||||
IDXGIAdapter* hardwareAdapter = nullptr;
|
||||
GetHardwareAdapter(factory, &hardwareAdapter, featureLevel, true);
|
||||
|
||||
if (hardwareAdapter == nullptr)
|
||||
{
|
||||
LOG("CreateDx12Device Can't get hardwareAdapter!", LEVEL_ERROR);
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
result = D3D12CreateDevice(hardwareAdapter, featureLevel, IID_PPV_ARGS(&Dx12Device));
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG("CreateDx12Device Can't create device: " + int_to_hex(result), LEVEL_ERROR);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandList[0] != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandList[0]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandList[0] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandList[1] != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandList[1]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandList[1] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandQueue != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandQueue->Release();
|
||||
CyberXessContext::instance()->Dx12CommandQueue = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandAllocator[0] != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[0]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[0] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandAllocator[1] != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[1]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[1] = nullptr;
|
||||
}
|
||||
|
||||
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
|
||||
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
queueDesc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_HIGH;
|
||||
|
||||
// CreateCommandQueue
|
||||
result = Dx12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&Dx12CommandQueue));
|
||||
LOG("NVSDK_NGX_D3D11_EvaluateFeature CreateCommandQueue result: " + int_to_hex(result), LEVEL_DEBUG);
|
||||
|
||||
if (result != S_OK || Dx12CommandQueue == nullptr)
|
||||
return NVSDK_NGX_Result_FAIL_PlatformError;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
};
|
||||
|
||||
class FeatureContext
|
||||
{
|
||||
public:
|
||||
NVSDK_NGX_Handle Handle;
|
||||
|
||||
xess_context_handle_t XessContext = nullptr;
|
||||
|
||||
unsigned int Width{}, Height{}, RenderWidth{}, RenderHeight{};
|
||||
@@ -48,3 +264,27 @@ public:
|
||||
float MVScaleX{}, MVScaleY{};
|
||||
float JitterOffsetX{}, JitterOffsetY{};
|
||||
};
|
||||
|
||||
static std::string ResultToString(xess_result_t result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case XESS_RESULT_WARNING_NONEXISTING_FOLDER: return "Warning Nonexistent Folder";
|
||||
case XESS_RESULT_WARNING_OLD_DRIVER: return "Warning Old Driver";
|
||||
case XESS_RESULT_SUCCESS: return "Success";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED_DEVICE: return "Unsupported Device";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED_DRIVER: return "Unsupported Driver";
|
||||
case XESS_RESULT_ERROR_UNINITIALIZED: return "Uninitialized";
|
||||
case XESS_RESULT_ERROR_INVALID_ARGUMENT: return "Invalid Argument";
|
||||
case XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY: return "Device Out of Memory";
|
||||
case XESS_RESULT_ERROR_DEVICE: return "Device Error";
|
||||
case XESS_RESULT_ERROR_NOT_IMPLEMENTED: return "Not Implemented";
|
||||
case XESS_RESULT_ERROR_INVALID_CONTEXT: return "Invalid Context";
|
||||
case XESS_RESULT_ERROR_OPERATION_IN_PROGRESS: return "Operation in Progress";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED: return "Unsupported";
|
||||
case XESS_RESULT_ERROR_CANT_LOAD_LIBRARY: return "Cannot Load Library";
|
||||
case XESS_RESULT_ERROR_UNKNOWN:
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1504
-16
File diff suppressed because it is too large
Load Diff
+98
-103
@@ -3,48 +3,13 @@
|
||||
#include "CyberXess.h"
|
||||
#include "Util.h"
|
||||
|
||||
static int cnt = 0;
|
||||
xess_dump_parameters_t dumpParams = {};
|
||||
|
||||
inline void LogCallback(const char* Message, xess_logging_level_t Level)
|
||||
{
|
||||
std::string s = Message;
|
||||
LOG("XeSS Runtime (" + std::to_string(Level) + ") : " + s, LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
const std::string ResultToString(xess_result_t result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case XESS_RESULT_WARNING_NONEXISTING_FOLDER: return "Warning Nonexistent Folder";
|
||||
case XESS_RESULT_WARNING_OLD_DRIVER: return "Warning Old Driver";
|
||||
case XESS_RESULT_SUCCESS: return "Success";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED_DEVICE: return "Unsupported Device";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED_DRIVER: return "Unsupported Driver";
|
||||
case XESS_RESULT_ERROR_UNINITIALIZED: return "Uninitialized";
|
||||
case XESS_RESULT_ERROR_INVALID_ARGUMENT: return "Invalid Argument";
|
||||
case XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY: return "Device Out of Memory";
|
||||
case XESS_RESULT_ERROR_DEVICE: return "Device Error";
|
||||
case XESS_RESULT_ERROR_NOT_IMPLEMENTED: return "Not Implemented";
|
||||
case XESS_RESULT_ERROR_INVALID_CONTEXT: return "Invalid Context";
|
||||
case XESS_RESULT_ERROR_OPERATION_IN_PROGRESS: return "Operation in Progress";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED: return "Unsupported";
|
||||
case XESS_RESULT_ERROR_CANT_LOAD_LIBRARY: return "Cannot Load Library";
|
||||
case XESS_RESULT_ERROR_UNKNOWN:
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
FeatureContext* CreateContext(NVSDK_NGX_Handle** OutHandle)
|
||||
{
|
||||
auto instance = CyberXessContext::instance();
|
||||
auto deviceContext = instance->CreateContext();
|
||||
*OutHandle = &deviceContext->Handle;
|
||||
|
||||
return deviceContext;
|
||||
}
|
||||
|
||||
bool CreateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle* handle)
|
||||
static bool CreateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle* handle)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature Start!", LEVEL_INFO);
|
||||
|
||||
@@ -65,26 +30,27 @@ bool CreateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle*
|
||||
|
||||
#pragma endregion
|
||||
|
||||
if (InCmdList == nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature InCmdList is null!!!", LEVEL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
#pragma region Check for Dx12Device Device
|
||||
|
||||
if (CyberXessContext::instance()->Dx12Device == nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device is null trying to get from InCmdList!", LEVEL_WARNING);
|
||||
InCmdList->GetDevice(IID_PPV_ARGS(&CyberXessContext::instance()->Dx12Device));
|
||||
if (InCmdList == nullptr && CyberXessContext::instance()->Dx11Device != nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature InCmdList is null!!!", LEVEL_ERROR);
|
||||
auto fl = CyberXessContext::instance()->Dx11Device->GetFeatureLevel();
|
||||
CyberXessContext::instance()->CreateDx12Device(fl);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device is null trying to get from InCmdList!", LEVEL_WARNING);
|
||||
InCmdList->GetDevice(IID_PPV_ARGS(&CyberXessContext::instance()->Dx12Device));
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12Device == nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device can't receive from InCmdList!", LEVEL_ERROR);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device received from InCmdList!", LEVEL_WARNING);
|
||||
}
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device is OK!", LEVEL_DEBUG);
|
||||
@@ -105,18 +71,25 @@ bool CreateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle*
|
||||
if (deviceContext->XessContext != nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature Destrying old XeSSContext", LEVEL_WARNING);
|
||||
auto dStatus = xessDestroyContext(deviceContext->XessContext);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessDestroyContext result -> " + ResultToString(dStatus), LEVEL_WARNING);
|
||||
ret = xessDestroyContext(deviceContext->XessContext);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessDestroyContext result -> " + ResultToString(ret), LEVEL_WARNING);
|
||||
}
|
||||
|
||||
auto status = xessD3D12CreateContext(CyberXessContext::instance()->Dx12Device, &deviceContext->XessContext);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12CreateContext result -> " + ResultToString(status), LEVEL_INFO);
|
||||
if (CyberXessContext::instance()->Dx12Device == nullptr && CyberXessContext::instance()->Dx11Device != nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature InCmdList is null!!!", LEVEL_ERROR);
|
||||
auto fl = CyberXessContext::instance()->Dx11Device->GetFeatureLevel();
|
||||
CyberXessContext::instance()->CreateDx12Device(fl);
|
||||
}
|
||||
|
||||
status = xessSetLoggingCallback(deviceContext->XessContext, XESS_LOGGING_LEVEL_DEBUG, LogCallback);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSetLoggingCallback : " + ResultToString(status), LEVEL_DEBUG);
|
||||
ret = xessD3D12CreateContext(CyberXessContext::instance()->Dx12Device, &deviceContext->XessContext);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12CreateContext result -> " + ResultToString(ret), LEVEL_INFO);
|
||||
|
||||
status = xessSetVelocityScale(deviceContext->XessContext, inParams->MVScaleX, inParams->MVScaleY);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSetVelocityScale : " + ResultToString(status), LEVEL_DEBUG);
|
||||
ret = xessSetLoggingCallback(deviceContext->XessContext, XESS_LOGGING_LEVEL_DEBUG, LogCallback);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSetLoggingCallback : " + ResultToString(ret), LEVEL_DEBUG);
|
||||
|
||||
ret = xessSetVelocityScale(deviceContext->XessContext, inParams->MVScaleX, inParams->MVScaleY);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSetVelocityScale : " + ResultToString(ret), LEVEL_DEBUG);
|
||||
|
||||
#pragma region Create Parameters for XeSS
|
||||
|
||||
@@ -205,11 +178,11 @@ bool CreateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle*
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12BuildPipelines start!", LEVEL_DEBUG);
|
||||
|
||||
status = xessD3D12BuildPipelines(deviceContext->XessContext, NULL, false, initParams.initFlags);
|
||||
ret = xessD3D12BuildPipelines(deviceContext->XessContext, NULL, false, initParams.initFlags);
|
||||
|
||||
if (status != XESS_RESULT_SUCCESS)
|
||||
if (ret != XESS_RESULT_SUCCESS)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12BuildPipelines error : -> " + ResultToString(status), LEVEL_ERROR);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12BuildPipelines error : -> " + ResultToString(ret), LEVEL_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -226,50 +199,58 @@ bool CreateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle*
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSelectNetworkModel trying to set value to " + std::to_string(model), LEVEL_DEBUG);
|
||||
|
||||
status = xessSelectNetworkModel(deviceContext->XessContext, model);
|
||||
ret = xessSelectNetworkModel(deviceContext->XessContext, model);
|
||||
|
||||
if (status == XESS_RESULT_SUCCESS)
|
||||
if (ret == XESS_RESULT_SUCCESS)
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSelectNetworkModel set to " + std::to_string(model), LEVEL_DEBUG);
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSelectNetworkModel(" + std::to_string(model) + ") error : " + ResultToString(status), LEVEL_ERROR);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSelectNetworkModel(" + std::to_string(model) + ") error : " + ResultToString(ret), LEVEL_ERROR);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12Init start!", LEVEL_DEBUG);
|
||||
|
||||
status = xessD3D12Init(deviceContext->XessContext, &initParams);
|
||||
ret = xessD3D12Init(deviceContext->XessContext, &initParams);
|
||||
|
||||
if (status != XESS_RESULT_SUCCESS)
|
||||
if (ret != XESS_RESULT_SUCCESS)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12Init error : -> " + ResultToString(status), LEVEL_ERROR);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12Init error: " + ResultToString(ret), LEVEL_ERROR);
|
||||
CyberXessContext::instance()->init = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature End!", LEVEL_DEBUG);
|
||||
|
||||
CyberXessContext::instance()->init = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FeatureContext* CreateContext(NVSDK_NGX_Handle** OutHandle)
|
||||
{
|
||||
auto deviceContext = CyberXessContext::instance()->CreateContext();
|
||||
*OutHandle = &deviceContext->Handle;
|
||||
return deviceContext;
|
||||
}
|
||||
|
||||
#pragma region DLSS Init Calls
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_Ext(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath,
|
||||
ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion,
|
||||
unsigned long long unknown0)
|
||||
ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion, unsigned long long unknown0)
|
||||
{
|
||||
|
||||
LOG("XeSS DelayedInit : " + std::to_string(CyberXessContext::instance()->MyConfig->DelayedInit.value_or(false)), LEVEL_INFO);
|
||||
LOG("XeSS BuildPipelines : " + std::to_string(CyberXessContext::instance()->MyConfig->BuildPipelines.value_or(true)), LEVEL_INFO);
|
||||
LOG("XeSS NetworkModel : " + std::to_string(CyberXessContext::instance()->MyConfig->NetworkModel.value_or(0)), LEVEL_INFO);
|
||||
LOG("XeSS LogFile : " + CyberXessContext::instance()->MyConfig->LogFile.value_or(""), LEVEL_INFO);
|
||||
LOG("XeSS LogLevel : " + std::to_string(CyberXessContext::instance()->MyConfig->LogLevel.value_or(1)), LEVEL_INFO);
|
||||
LOG("XeSS XeSSLogging : " + std::to_string(CyberXessContext::instance()->MyConfig->XeSSLogging.value_or(true)), LEVEL_INFO);
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext AppId:" + std::to_string(InApplicationId), LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext SDK:" + std::to_string(InSDKVersion), LEVEL_DEBUG);
|
||||
|
||||
LOG("Logger DelayedInit : " + std::to_string(CyberXessContext::instance()->MyConfig->DelayedInit.value_or(false)), LEVEL_INFO);
|
||||
LOG("Logger BuildPipelines : " + std::to_string(CyberXessContext::instance()->MyConfig->BuildPipelines.value_or(true)), LEVEL_INFO);
|
||||
LOG("Logger NetworkModel : " + std::to_string(CyberXessContext::instance()->MyConfig->NetworkModel.value_or(0)), LEVEL_INFO);
|
||||
LOG("Logger LogFile : " + CyberXessContext::instance()->MyConfig->LogFile.value_or(""), LEVEL_INFO);
|
||||
LOG("Logger LogLevel : " + std::to_string(CyberXessContext::instance()->MyConfig->LogLevel.value_or(1)), LEVEL_INFO);
|
||||
LOG("Logger XeSSLogging : " + std::to_string(CyberXessContext::instance()->MyConfig->XeSSLogging.value_or(true)), LEVEL_INFO);
|
||||
|
||||
CyberXessContext::instance()->init = false;
|
||||
CyberXessContext::instance()->Dx12Device = nullptr;
|
||||
CyberXessContext::instance()->Shutdown(true, true);
|
||||
|
||||
if (InDevice)
|
||||
{
|
||||
@@ -277,7 +258,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_Ext(unsigned long long InApp
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext Dx12Device assigned...", LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext Dx12Device is already assigned or InDevice is null!!!!", LEVEL_ERROR);
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext InDevice is null!!!!", LEVEL_ERROR);
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
@@ -319,8 +300,13 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown(void)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_Shutdown", LEVEL_DEBUG);
|
||||
|
||||
CyberXessContext::instance()->Dx12Device = nullptr;
|
||||
CyberXessContext::instance()->Shutdown(false, true);
|
||||
CyberXessContext::instance()->NvParameterInstance->Params.clear();
|
||||
|
||||
for (auto const& [key, val] : CyberXessContext::instance()->Contexts) {
|
||||
NVSDK_NGX_D3D12_ReleaseFeature(&val->Handle);
|
||||
}
|
||||
|
||||
CyberXessContext::instance()->Contexts.clear();
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
@@ -330,10 +316,14 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown1(ID3D12Device* InDevice)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_Shutdown1", LEVEL_DEBUG);
|
||||
|
||||
CyberXessContext::instance()->Dx12Device = nullptr;
|
||||
CyberXessContext::instance()->Shutdown(false, true);
|
||||
CyberXessContext::instance()->NvParameterInstance->Params.clear();
|
||||
CyberXessContext::instance()->Contexts.clear();
|
||||
|
||||
for (auto const& [key, val] : CyberXessContext::instance()->Contexts) {
|
||||
NVSDK_NGX_D3D12_ReleaseFeature(&val->Handle);
|
||||
}
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
@@ -381,8 +371,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_DestroyParameters(NVSDK_NGX_Param
|
||||
|
||||
#pragma region DLSS Feature Calls
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsCommandList* InCmdList, NVSDK_NGX_Feature InFeatureID,
|
||||
NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle)
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsCommandList* InCmdList, NVSDK_NGX_Feature InFeatureID, NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle)
|
||||
{
|
||||
auto context = CreateContext(OutHandle);
|
||||
CyberXessContext::instance()->CreateFeatureParams = static_cast<const NvParameter*>(InParameters);
|
||||
@@ -390,9 +379,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsComma
|
||||
if (CyberXessContext::instance()->MyConfig->DelayedInit.value_or(false))
|
||||
return NVSDK_NGX_Result_Success;
|
||||
|
||||
auto result = CreateFeature(InCmdList, &context->Handle);
|
||||
|
||||
if (result)
|
||||
if (CreateFeature(InCmdList, &context->Handle))
|
||||
return NVSDK_NGX_Result_Success;
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature: CreateFeature failed", LEVEL_ERROR);
|
||||
@@ -404,9 +391,18 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle*
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_ReleaseFeature!", LEVEL_DEBUG);
|
||||
|
||||
auto deviceContext = CyberXessContext::instance()->Contexts[InHandle->Id].get();
|
||||
auto result = xessDestroyContext(deviceContext->XessContext);
|
||||
if (auto deviceContext = CyberXessContext::instance()->Contexts[InHandle->Id].get(); deviceContext->XessContext != nullptr)
|
||||
{
|
||||
auto result = xessDestroyContext(deviceContext->XessContext);
|
||||
deviceContext->XessContext = nullptr;
|
||||
LOG("NVSDK_NGX_D3D11_ReleaseFeature: xessDestroyContext result: " + ResultToString(result), LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
CyberXessContext::instance()->DeleteContext(InHandle);
|
||||
|
||||
if (CyberXessContext::instance()->Contexts.empty())
|
||||
CyberXessContext::instance()->Shutdown(false, true);
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
@@ -423,8 +419,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetFeatureRequirements(IDXGIAdapt
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle* InFeatureHandle,
|
||||
const NVSDK_NGX_Parameter* InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback)
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle* InFeatureHandle, const NVSDK_NGX_Parameter* InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature init!", LEVEL_DEBUG);
|
||||
|
||||
@@ -438,16 +433,15 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature callback exist", LEVEL_WARNING);
|
||||
|
||||
const auto inParams = static_cast<const NvParameter*>(InParameters);
|
||||
const auto instance = CyberXessContext::instance();
|
||||
|
||||
auto instance = CyberXessContext::instance();
|
||||
|
||||
if (!CyberXessContext::instance()->init)
|
||||
if (!instance->init)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature init is false, calling CreateFeature!", LEVEL_WARNING);
|
||||
CyberXessContext::instance()->init = CreateFeature(InCmdList, InFeatureHandle);
|
||||
instance->init = CreateFeature(InCmdList, InFeatureHandle);
|
||||
}
|
||||
|
||||
if (!CyberXessContext::instance()->init)
|
||||
if (!instance->init)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature init still is null CreateFeature failed!", LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
@@ -461,6 +455,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
//xessStartDump(deviceContext->XessContext, &dumpParams);
|
||||
|
||||
// creatimg params for XeSS
|
||||
xess_result_t xessResult;
|
||||
xess_d3d12_execute_params_t params{};
|
||||
|
||||
params.jitterOffsetX = inParams->JitterOffsetX;
|
||||
@@ -474,7 +469,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature inp width: " + std::to_string(inParams->Width) + " height: " + std::to_string(inParams->Height), LEVEL_DEBUG);
|
||||
|
||||
if (inParams->Color)
|
||||
|
||||
if (inParams->Color != nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Color exist..", LEVEL_DEBUG);
|
||||
params.pColorTexture = (ID3D12Resource*)inParams->Color;
|
||||
@@ -507,14 +503,14 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
return NVSDK_NGX_Result_FAIL_InvalidParameter;
|
||||
}
|
||||
|
||||
if (inParams->Depth && !CyberXessContext::instance()->MyConfig->DisplayResolution.value_or(false))
|
||||
if (inParams->Depth)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Depth exist..", LEVEL_INFO);
|
||||
params.pDepthTexture = (ID3D12Resource*)inParams->Depth;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CyberXessContext::instance()->MyConfig->DisplayResolution.value_or(false))
|
||||
if (!instance->MyConfig->DisplayResolution.value_or(false))
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Depth not exist!!", LEVEL_ERROR);
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Using high res motion vectors, depth is not needed!!", LEVEL_INFO);
|
||||
@@ -522,7 +518,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
params.pDepthTexture = nullptr;
|
||||
}
|
||||
|
||||
if (!CyberXessContext::instance()->MyConfig->AutoExposure.value_or(false))
|
||||
if (!instance->MyConfig->AutoExposure.value_or(false))
|
||||
{
|
||||
if (inParams->ExposureTexture == nullptr)
|
||||
{
|
||||
@@ -533,7 +529,6 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature ExposureTexture exist..", LEVEL_INFO);
|
||||
params.pExposureScaleTexture = (ID3D12Resource*)inParams->ExposureTexture;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -542,7 +537,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
params.pExposureScaleTexture = nullptr;
|
||||
}
|
||||
|
||||
if (!CyberXessContext::instance()->MyConfig->DisableReactiveMask.value_or(true))
|
||||
if (!instance->MyConfig->DisableReactiveMask.value_or(true))
|
||||
{
|
||||
if (inParams->TransparencyMask != nullptr)
|
||||
{
|
||||
@@ -561,20 +556,20 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature mvscale x: " + std::to_string(inParams->MVScaleX) + " y: " + std::to_string(inParams->MVScaleY), LEVEL_DEBUG);
|
||||
auto vResult = xessSetVelocityScale(deviceContext->XessContext, inParams->MVScaleX, inParams->MVScaleY);
|
||||
xessResult = xessSetVelocityScale(deviceContext->XessContext, inParams->MVScaleX, inParams->MVScaleY);
|
||||
|
||||
if (vResult != XESS_RESULT_SUCCESS)
|
||||
if (xessResult != XESS_RESULT_SUCCESS)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature xessSetVelocityScale : " + ResultToString(vResult), LEVEL_ERROR);
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature xessSetVelocityScale : " + ResultToString(xessResult), LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Executing!!", LEVEL_INFO);
|
||||
vResult = xessD3D12Execute(deviceContext->XessContext, InCmdList, ¶ms);
|
||||
xessResult = xessD3D12Execute(deviceContext->XessContext, InCmdList, ¶ms);
|
||||
|
||||
if (vResult != XESS_RESULT_SUCCESS)
|
||||
if (xessResult != XESS_RESULT_SUCCESS)
|
||||
{
|
||||
LOG("xessD3D12Execute error : -> " + ResultToString(vResult), LEVEL_ERROR);
|
||||
LOG("xessD3D12Execute error : -> " + ResultToString(xessResult), LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Detours
|
||||
{
|
||||
static_assert(sizeof(uintptr_t) == sizeof(void *));
|
||||
|
||||
const static uint32_t DISASM_MAX_INSTRUCTIONS = 50; // Maximum number of instructions to decode at once
|
||||
|
||||
const static uint32_t OPT_MASK = 0xFFF; // Mask for all options
|
||||
const static uint32_t OPT_NONE = 0x000; // No options
|
||||
const static uint32_t OPT_BREAK_ON_FAIL = 0x001; // Throw INT3 on failure
|
||||
const static uint32_t OPT_DO_NOT_PAD_NOPS = 0x002; // Don't pad replaced instructions with NOPs
|
||||
|
||||
struct JumpTrampolineHeader
|
||||
{
|
||||
uint32_t Magic; // Used to verify the header
|
||||
uint32_t Random; // Variable to change the code/data hash
|
||||
|
||||
uintptr_t CodeOffset; // Offset, in code, that was hooked: "target"
|
||||
uintptr_t DetourOffset; // User function that is called: "destination"
|
||||
|
||||
uintptr_t InstructionLength;// Length of the instructions that were replaced
|
||||
uintptr_t InstructionOffset;// Where the backed-up instructions are
|
||||
|
||||
uintptr_t TrampolineLength; // Length of the trampoline
|
||||
uintptr_t TrampolineOffset; // Code offset where 'jmp (q/d)word ptr <user function>' occurs
|
||||
|
||||
// Anything after this struct is null data or pure code (instructions/trampoline)
|
||||
};
|
||||
|
||||
void SetGlobalOptions(uint32_t Options);
|
||||
uint32_t GetGlobalOptions();
|
||||
|
||||
uint64_t DetourAlignAddress(uint64_t Address, uint8_t Align);
|
||||
|
||||
bool DetourCopyMemory(uintptr_t Target, uintptr_t Memory, size_t Length);
|
||||
bool DetourFlushCache(uintptr_t Target, size_t Length);
|
||||
uintptr_t IATHook(uintptr_t Module, const char *ImportModule, const char *API, uintptr_t Detour);
|
||||
uintptr_t IATDelayedHook(uintptr_t Module, const char *ImportModule, const char *API, uintptr_t Detour);
|
||||
|
||||
#ifdef _M_IX86
|
||||
enum class X86Option
|
||||
{
|
||||
USE_JUMP, // jmp <address>;
|
||||
USE_CALL, // call <address>;
|
||||
USE_PUSH_RET, // push <address>; retn;
|
||||
};
|
||||
|
||||
namespace X86
|
||||
{
|
||||
// Redirects a single static function to another
|
||||
uintptr_t DetourFunction(uintptr_t Target, uintptr_t Detour, X86Option Options = X86Option::USE_JUMP);
|
||||
|
||||
// Redirects a class member function (__thiscall) to another
|
||||
template<typename T>
|
||||
uintptr_t DetourFunctionClass(uintptr_t Target, T Detour, X86Option Options = X86Option::USE_JUMP)
|
||||
{
|
||||
return DetourFunction(Target, *(uintptr_t *)&Detour, Options);
|
||||
}
|
||||
|
||||
// Removes a detoured function (Static or class member)
|
||||
bool DetourRemove(uintptr_t Trampoline);
|
||||
|
||||
// Redirects an index in a virtual table
|
||||
uintptr_t DetourVTable(uintptr_t Target, uintptr_t Detour, uint32_t TableIndex);
|
||||
|
||||
// Redirects a class member virtual function (__thiscall) to another
|
||||
template<typename T>
|
||||
uintptr_t DetourClassVTable(uintptr_t Target, T Detour, uint32_t TableIndex)
|
||||
{
|
||||
return DetourVTable(Target, *(uintptr_t *)&Detour, TableIndex);
|
||||
}
|
||||
|
||||
// Removes a detoured virtual table index
|
||||
bool VTableRemove(uintptr_t Target, uintptr_t Function, uint32_t TableIndex);
|
||||
|
||||
void DetourWriteStub(JumpTrampolineHeader *Header);
|
||||
bool DetourWriteJump(JumpTrampolineHeader *Header);
|
||||
bool DetourWriteCall(JumpTrampolineHeader *Header);
|
||||
bool DetourWritePushRet(JumpTrampolineHeader *Header);
|
||||
|
||||
uint32_t DetourGetHookLength(X86Option Options);
|
||||
}
|
||||
#endif // _M_IX86
|
||||
|
||||
#ifdef _M_AMD64
|
||||
enum class X64Option
|
||||
{
|
||||
USE_PUSH_RET, // push <low 32 address>; [rsp+4h] = <hi 32 addr>; retn;
|
||||
USE_RAX_JUMP, // mov rax, <address>; jmp rax;
|
||||
USE_REL32_JUMP, // jmp <address within +/- 2GB>
|
||||
USE_REL32_CALL, // call <address within +/- 2GB>
|
||||
};
|
||||
|
||||
namespace X64
|
||||
{
|
||||
// Redirects a single static function to another
|
||||
uintptr_t DetourFunction(uintptr_t Target, uintptr_t Detour, X64Option Options = X64Option::USE_REL32_JUMP);
|
||||
|
||||
// Redirects a class member function (__thiscall) to another
|
||||
template<typename T>
|
||||
uintptr_t DetourFunctionClass(uintptr_t Target, T Detour, X64Option Options = X64Option::USE_REL32_JUMP)
|
||||
{
|
||||
return DetourFunction(Target, *(uintptr_t *)&Detour, Options);
|
||||
}
|
||||
|
||||
// Removes a detoured function (Static or class member)
|
||||
bool DetourRemove(uintptr_t Trampoline);
|
||||
|
||||
// Redirects an index in a virtual table
|
||||
uintptr_t DetourVTable(uintptr_t Target, uintptr_t Detour, uint32_t TableIndex);
|
||||
|
||||
// Redirects a class member virtual function (__thiscall) to another
|
||||
template<typename T>
|
||||
uintptr_t DetourClassVTable(uintptr_t Target, T Detour, uint32_t TableIndex)
|
||||
{
|
||||
return DetourVTable(Target, *(uintptr_t *)&Detour, TableIndex);
|
||||
}
|
||||
|
||||
// Removes a detoured virtual table index
|
||||
bool VTableRemove(uintptr_t Target, uintptr_t Function, uint32_t TableIndex);
|
||||
|
||||
void DetourWriteStub(JumpTrampolineHeader *Header);
|
||||
bool DetourWritePushRet(JumpTrampolineHeader *Header);
|
||||
bool DetourWriteRaxJump(JumpTrampolineHeader *Header);
|
||||
bool DetourWriteRel32Jump(JumpTrampolineHeader *Header);
|
||||
bool DetourWriteRel32Call(JumpTrampolineHeader *Header);
|
||||
|
||||
uint32_t DetourGetHookLength(X64Option Options);
|
||||
}
|
||||
#endif // _M_AMD64
|
||||
}
|
||||
+14
-12
@@ -231,6 +231,7 @@ NVSDK_NGX_Result NvParameter::Get_Internal(const char* InName, unsigned long lon
|
||||
auto outValueULL = (unsigned long long*)OutValue;
|
||||
//Includes DirectX Resources
|
||||
auto outValuePtr = (void**)OutValue;
|
||||
const auto params = CyberXessContext::instance()->NvParameterInstance;
|
||||
|
||||
std::string s;
|
||||
s = InName;
|
||||
@@ -284,7 +285,7 @@ NVSDK_NGX_Result NvParameter::Get_Internal(const char* InName, unsigned long lon
|
||||
*outValuePtr = NVSDK_NGX_DLSS_GetStatsCallback;
|
||||
break;
|
||||
case Util::NvParameter::SizeInBytes:
|
||||
*outValueULL = 0x1337; //Dummy value
|
||||
*outValueULL = params->OutHeight * params->OutWidth * 31; //Dummy value
|
||||
break;
|
||||
case Util::NvParameter::OptLevel:
|
||||
*outValueInt = 0; //Dummy value
|
||||
@@ -397,31 +398,32 @@ void NvParameter::EvaluateRenderScale()
|
||||
|
||||
LOG("EvaluateRenderScale Quality : " + std::to_string(PerfQualityValue), LEVEL_DEBUG);
|
||||
|
||||
switch (xessQualityMode)
|
||||
switch (PerfQualityValue)
|
||||
{
|
||||
case XESS_QUALITY_SETTING_PERFORMANCE:
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:
|
||||
OutHeight = (unsigned int)((float)Height / 3.0);
|
||||
OutWidth = (unsigned int)((float)Width / 3.0);
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:
|
||||
OutHeight = (unsigned int)((float)Height / 2.0);
|
||||
OutWidth = (unsigned int)((float)Width / 2.0);
|
||||
break;
|
||||
|
||||
case XESS_QUALITY_SETTING_BALANCED:
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:
|
||||
OutHeight = (unsigned int)((float)Height / 1.699115044247788);
|
||||
OutWidth = (unsigned int)((float)Width / 1.699115044247788);
|
||||
break;
|
||||
|
||||
case XESS_QUALITY_SETTING_QUALITY:
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:
|
||||
OutHeight = (unsigned int)((float)Height / 1.5);
|
||||
OutWidth = (unsigned int)((float)Width / 1.5);
|
||||
break;
|
||||
|
||||
case XESS_QUALITY_SETTING_ULTRA_QUALITY:
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:
|
||||
OutHeight = (unsigned int)((float)Height / 1.299932295192959);
|
||||
OutWidth = (unsigned int)((float)Width / 1.299932295192959);
|
||||
break;
|
||||
|
||||
default:
|
||||
OutHeight = Height;
|
||||
OutWidth = Width;
|
||||
OutHeight = (unsigned int)((float)Height / 1.699115044247788);
|
||||
OutWidth = (unsigned int)((float)Width / 1.699115044247788);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
|
||||
|
||||
HMODULE dllModule;
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define NOMINMAX
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#include <d3d11_4.h>
|
||||
#include <d3d12.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <memory>
|
||||
@@ -30,3 +31,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+37
-2
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
//#define LOGGING_ACTIVE
|
||||
#define LOGGING_ACTIVE
|
||||
|
||||
typedef enum _log_level_t
|
||||
{
|
||||
@@ -12,6 +12,15 @@ typedef enum _log_level_t
|
||||
LEVEL_ERROR = 3
|
||||
} log_level_t;
|
||||
|
||||
#define SAFE_RELEASE(p) \
|
||||
do \
|
||||
{ \
|
||||
if(p) \
|
||||
{ \
|
||||
(p)->Release(); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
} while((void)0, 0)
|
||||
|
||||
#ifdef LOGGING_ACTIVE
|
||||
#define LOG(string, level) logprintf(string, level)
|
||||
@@ -25,7 +34,7 @@ typedef enum _log_level_t
|
||||
#include <fstream>
|
||||
#include "Config.h"
|
||||
|
||||
void logprintf(std::string logMsg, log_level_t level);
|
||||
void logprintf(std::string logMsg, log_level_t level = LEVEL_DEBUG);
|
||||
|
||||
void prepareOfs(std::string fileName, log_level_t level);
|
||||
|
||||
@@ -40,4 +49,30 @@ static inline int64_t GetTicks()
|
||||
return ticks.QuadPart;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
static inline std::string int_to_hex(T i)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << "0x"
|
||||
<< std::setfill('0')
|
||||
<< std::setw(sizeof(T) * 2)
|
||||
<< std::hex << i;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
static inline std::string ToString(REFIID guid)
|
||||
{
|
||||
char guid_string[37]; // 32 hex chars + 4 hyphens + null terminator
|
||||
|
||||
snprintf(
|
||||
guid_string, sizeof(guid_string),
|
||||
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
guid.Data1, guid.Data2, guid.Data3,
|
||||
guid.Data4[0], guid.Data4[1], guid.Data4[2],
|
||||
guid.Data4[3], guid.Data4[4], guid.Data4[5],
|
||||
guid.Data4[6], guid.Data4[7]);
|
||||
|
||||
return guid_string;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,153 @@
|
||||
#include "pch.h"
|
||||
#include "Config.h"
|
||||
#include "Util.h"
|
||||
|
||||
Config::Config(std::wstring fileName)
|
||||
{
|
||||
absoluteFileName = Util::DllPath().parent_path() / fileName;
|
||||
Reload();
|
||||
}
|
||||
|
||||
void Config::Reload()
|
||||
{
|
||||
#ifdef LOGGING_ACTIVE
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
auto str = std::format("{:%d%m%Y_%H%M%OS}", now);
|
||||
|
||||
auto logFile = "./log_xess_" + str + ".log";
|
||||
LogLevel = 1;
|
||||
XeSSLogging = false;
|
||||
#endif
|
||||
|
||||
NetworkModel = 0;
|
||||
BuildPipelines = true;
|
||||
DelayedInit = false;
|
||||
|
||||
if (ini.LoadFile(absoluteFileName.c_str()) == SI_OK)
|
||||
{
|
||||
DelayedInit = readBool("XeSS", "DelayedInit");
|
||||
BuildPipelines = readBool("XeSS", "BuildPipelines");
|
||||
NetworkModel = readInt("XeSS", "NetworkModel");
|
||||
|
||||
#ifdef LOGGING_ACTIVE
|
||||
LogFile = readString("XeSS", "LogFile");
|
||||
|
||||
if (!LogFile.has_value())
|
||||
LogFile = logFile;
|
||||
|
||||
XeSSLogging = readBool("XeSS", "XeSSLogging");
|
||||
LogLevel = readInt("XeSS", "LogLevel");
|
||||
|
||||
if (XeSSLogging.value_or(false))
|
||||
LogLevel = -1;
|
||||
|
||||
prepareOfs(LogFile.value(), (log_level_t)LogLevel.value());
|
||||
#endif
|
||||
|
||||
// Depth
|
||||
DepthInverted = readBool("Depth", "DepthInverted");
|
||||
|
||||
// Color
|
||||
AutoExposure = readBool("Color", "AutoExposure");
|
||||
HDR = readBool("Color", "HDR");
|
||||
|
||||
// MotionVectors
|
||||
JitterCancellation = readBool("MotionVectors", "JitterCancellation");
|
||||
DisplayResolution = readBool("MotionVectors", "DisplayResolution");
|
||||
|
||||
//Upscale Ratio Override
|
||||
UpscaleRatioOverrideEnabled = readBool("UpscaleRatio", "UpscaleRatioOverrideEnabled");
|
||||
UpscaleRatioOverrideValue = readFloat("UpscaleRatio", "UpscaleRatioOverrideValue");
|
||||
|
||||
// Quality Overrides
|
||||
QualityRatioOverrideEnabled = readBool("QualityOverrides", "QualityRatioOverrideEnabled");
|
||||
if (QualityRatioOverrideEnabled) {
|
||||
QualityRatio_UltraQuality = readFloat("QualityOverrides", "QualityRatioUltraQuality");
|
||||
QualityRatio_Quality = readFloat("QualityOverrides", "QualityRatioQuality");
|
||||
QualityRatio_Balanced = readFloat("QualityOverrides", "QualityRatioBalanced");
|
||||
QualityRatio_Performance = readFloat("QualityOverrides", "QualityRatioPerformance");
|
||||
QualityRatio_UltraPerformance = readFloat("QualityOverrides", "QualityRatioUltraPerformance");
|
||||
}
|
||||
|
||||
DisableReactiveMask = readBool("Hotfix", "DisableReactiveMask");
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> Config::readString(std::string section, std::string key, bool lowercase)
|
||||
{
|
||||
std::string value = ini.GetValue(section.c_str(), key.c_str(), "auto");
|
||||
|
||||
std::string lower = value;
|
||||
std::transform(
|
||||
lower.begin(), lower.end(),
|
||||
lower.begin(),
|
||||
[](unsigned char c)
|
||||
{
|
||||
return std::tolower(c);
|
||||
}
|
||||
);
|
||||
|
||||
if (lower == "auto")
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
return lowercase ? lower : value;
|
||||
}
|
||||
|
||||
std::optional<float> Config::readFloat(std::string section, std::string key)
|
||||
{
|
||||
auto value = readString(section, key);
|
||||
try
|
||||
{
|
||||
return std::stof(value.value());
|
||||
}
|
||||
catch (const std::bad_optional_access&) // missing or auto value
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
catch (const std::invalid_argument&) // invalid float string for std::stof
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
catch (const std::out_of_range&) // out of range for 32 bit float
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<int> Config::readInt(std::string section, std::string key)
|
||||
{
|
||||
auto value = readString(section, key);
|
||||
try
|
||||
{
|
||||
return std::stoi(value.value());
|
||||
}
|
||||
catch (const std::bad_optional_access&) // missing or auto value
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
catch (const std::invalid_argument&) // invalid float string for std::stof
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
catch (const std::out_of_range&) // out of range for 32 bit float
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<bool> Config::readBool(std::string section, std::string key)
|
||||
{
|
||||
auto value = readString(section, key, true);
|
||||
if (value == "true")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (value == "false")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
class Config
|
||||
{
|
||||
public:
|
||||
Config(std::wstring fileName);
|
||||
|
||||
// Depth
|
||||
std::optional<bool> DepthInverted;
|
||||
|
||||
// Color
|
||||
std::optional<bool> AutoExposure;
|
||||
std::optional<bool> HDR;
|
||||
|
||||
// Motion
|
||||
std::optional<bool> JitterCancellation;
|
||||
std::optional<bool> DisplayResolution;
|
||||
|
||||
// XeSS
|
||||
std::optional<bool> DelayedInit;
|
||||
std::optional<bool> BuildPipelines;
|
||||
std::optional<bool> XeSSLogging;
|
||||
std::optional<std::string> LogFile;
|
||||
std::optional<int32_t> NetworkModel;
|
||||
std::optional<int> LogLevel;
|
||||
|
||||
// Upscale Ratio Override
|
||||
std::optional<bool> UpscaleRatioOverrideEnabled;
|
||||
std::optional<float> UpscaleRatioOverrideValue;
|
||||
|
||||
// Quality Overrides
|
||||
std::optional<bool> QualityRatioOverrideEnabled;
|
||||
std::optional<float> QualityRatio_UltraQuality;
|
||||
std::optional<float> QualityRatio_Quality;
|
||||
std::optional<float> QualityRatio_Balanced;
|
||||
std::optional<float> QualityRatio_Performance;
|
||||
std::optional<float> QualityRatio_UltraPerformance;
|
||||
|
||||
//Hotfix for Steam Deck
|
||||
std::optional<bool> DisableReactiveMask;
|
||||
|
||||
void Reload();
|
||||
|
||||
private:
|
||||
CSimpleIniA ini;
|
||||
|
||||
std::filesystem::path absoluteFileName;
|
||||
|
||||
std::optional<std::string> readString(std::string section, std::string key, bool lowercase = false);
|
||||
std::optional<float> readFloat(std::string section, std::string key);
|
||||
std::optional<int> readInt(std::string section, std::string key);
|
||||
std::optional<bool> readBool(std::string section, std::string key);
|
||||
};
|
||||
@@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{8d2b73fb-eecd-45ce-b8e5-335610462f58}</ProjectGuid>
|
||||
<RootNamespace>CyberXeSS</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)\external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(VULKAN_SDK)\include;$(XESS_SDK)\inc\xess;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(XESS_SDK)\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)\external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(VULKAN_SDK)\include;$(XESS_SDK)\inc\xess;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(XESS_SDK)\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\vulkan\include;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)external\xess\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>nvngx</TargetName>
|
||||
<OutDir>F:\Games\God of War</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(SolutionDir)external\simpleini;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\vulkan\include;$(IncludePath)</IncludePath>
|
||||
<TargetName>nvngx</TargetName>
|
||||
<LibraryPath>$(SolutionDir)external\xess\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;CYBERXESS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;CYBERXESS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;CYBERXESS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>d3d11.lib;dxgi.lib;d3d12.lib;dxguid.lib;libxess.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;CYBERXESS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>d3d11.lib;dxgi.lib;d3d12.lib;dxguid.lib;libxess.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Config.h" />
|
||||
<ClInclude Include="CyberXess.h" />
|
||||
<ClInclude Include="d3dx12.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="NvParameter.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="Util.h" />
|
||||
<ClInclude Include="WrappedD3D12Device.h" />
|
||||
<ClInclude Include="WrappedDXGIObjects.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Config.cpp" />
|
||||
<ClCompile Include="CyberXess.cpp" />
|
||||
<ClCompile Include="CyberXessDx11.cpp" />
|
||||
<ClCompile Include="CyberXessDx12.cpp" />
|
||||
<ClCompile Include="CyberXessVk.cpp" />
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="NvParameter.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util.cpp" />
|
||||
<ClCompile Include="WrappedD3D12Device.cpp" />
|
||||
<ClCompile Include="WrappedDXGIObjects.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CyberXess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Util.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NvParameter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="WrappedD3D12Device.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="WrappedDXGIObjects.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="d3dx12.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CyberXess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NvParameter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CyberXessDx12.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CyberXessDx11.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CyberXessVk.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="WrappedD3D12Device.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="WrappedDXGIObjects.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "pch.h"
|
||||
#include "Config.h"
|
||||
#include "CyberXess.h"
|
||||
#include "Util.h"
|
||||
|
||||
FeatureContext* CyberXessContext::CreateContext()
|
||||
{
|
||||
auto handleId = rand();
|
||||
Contexts[handleId] = std::make_unique<FeatureContext>();
|
||||
Contexts[handleId]->Handle.Id = handleId;
|
||||
return Contexts[handleId].get();
|
||||
}
|
||||
|
||||
void CyberXessContext::DeleteContext(NVSDK_NGX_Handle* handle)
|
||||
{
|
||||
auto handleId = handle->Id;
|
||||
|
||||
auto it = std::find_if(Contexts.begin(), Contexts.end(),
|
||||
[&handleId](const auto& p) { return p.first == handleId; });
|
||||
Contexts.erase(it);
|
||||
}
|
||||
|
||||
CyberXessContext::CyberXessContext()
|
||||
{
|
||||
MyConfig = std::make_unique<Config>(L"nvngx.ini");
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "NvParameter.h"
|
||||
#include "xess_d3d12.h"
|
||||
#include "xess_debug.h"
|
||||
#include "WrappedD3D12Device.h"
|
||||
#include "d3d11on12.h"
|
||||
#include "d3dx12.h"
|
||||
|
||||
class FeatureContext;
|
||||
|
||||
//Global Context
|
||||
class CyberXessContext
|
||||
{
|
||||
CyberXessContext();
|
||||
|
||||
void GetHardwareAdapter(IDXGIFactory1* pFactory, IDXGIAdapter1** ppAdapter, D3D_FEATURE_LEVEL featureLevel, bool requestHighPerformanceAdapter) const
|
||||
{
|
||||
*ppAdapter = nullptr;
|
||||
|
||||
IDXGIAdapter1* adapter;
|
||||
|
||||
IDXGIFactory6* factory6;
|
||||
if (SUCCEEDED(pFactory->QueryInterface(IID_PPV_ARGS(&factory6))))
|
||||
{
|
||||
for (
|
||||
UINT adapterIndex = 0;
|
||||
DXGI_ERROR_NOT_FOUND != factory6->EnumAdapterByGpuPreference(
|
||||
adapterIndex,
|
||||
requestHighPerformanceAdapter == true ? DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE : DXGI_GPU_PREFERENCE_UNSPECIFIED,
|
||||
IID_PPV_ARGS(&adapter));
|
||||
++adapterIndex)
|
||||
{
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
adapter->GetDesc1(&desc);
|
||||
|
||||
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
|
||||
{
|
||||
// Don't select the Basic Render Driver adapter.
|
||||
// If you want a software adapter, pass in "/warp" on the command line.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check to see whether the adapter supports Direct3D 12, but don't create the
|
||||
// actual device yet.
|
||||
|
||||
|
||||
auto result = D3D12CreateDevice(adapter, featureLevel, _uuidof(ID3D12Device), nullptr);
|
||||
|
||||
if (result == S_FALSE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != pFactory->EnumAdapters1(adapterIndex, &adapter); ++adapterIndex)
|
||||
{
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
adapter->GetDesc1(&desc);
|
||||
|
||||
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
|
||||
{
|
||||
// Don't select the Basic Render Driver adapter.
|
||||
// If you want a software adapter, pass in "/warp" on the command line.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check to see whether the adapter supports Direct3D 12, but don't create the
|
||||
// actual device yet.
|
||||
auto result = D3D12CreateDevice(adapter, featureLevel, _uuidof(ID3D12Device), nullptr);
|
||||
|
||||
if (result == S_FALSE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*ppAdapter = adapter;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
std::shared_ptr<Config> MyConfig;
|
||||
|
||||
bool init = false;
|
||||
const NvParameter* CreateFeatureParams;
|
||||
|
||||
// D3D12 stuff
|
||||
ID3D12Device* Dx12Device = nullptr;
|
||||
WrappedD3D12Device* Dx12ProxyDevice = nullptr;
|
||||
|
||||
// D3D11 stuff
|
||||
ID3D11Device5* Dx11Device = nullptr;
|
||||
ID3D11DeviceContext4* Dx11DeviceContext = nullptr;
|
||||
|
||||
// D3D11on12 stuff
|
||||
ID3D11On12Device2* Dx11on12Device = nullptr;
|
||||
ID3D12CommandQueue* Dx12CommandQueue = nullptr;
|
||||
ID3D12CommandAllocator* Dx12CommandAllocator[2] = { nullptr, nullptr };
|
||||
ID3D12GraphicsCommandList* Dx12CommandList[2] = { nullptr, nullptr };
|
||||
ID3D12Fence* Dx12Fence = nullptr;
|
||||
volatile UINT64 Dx12FenceValueCounter = 0;
|
||||
|
||||
// Vulkan stuff
|
||||
VkDevice VulkanDevice = nullptr;
|
||||
VkInstance VulkanInstance = nullptr;
|
||||
VkPhysicalDevice VulkanPhysicalDevice = nullptr;
|
||||
|
||||
std::shared_ptr<NvParameter> NvParameterInstance = NvParameter::instance();
|
||||
|
||||
ankerl::unordered_dense::map <unsigned int, std::unique_ptr<FeatureContext>> Contexts;
|
||||
FeatureContext* CreateContext();
|
||||
void DeleteContext(NVSDK_NGX_Handle* handle);
|
||||
|
||||
static std::shared_ptr<CyberXessContext> instance()
|
||||
{
|
||||
static std::shared_ptr<CyberXessContext> INSTANCE{ std::make_shared<CyberXessContext>(CyberXessContext()) };
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
void Shutdown() const
|
||||
{
|
||||
CyberXessContext::instance()->Dx12FenceValueCounter = 0;
|
||||
|
||||
if (CyberXessContext::instance()->Dx12Fence != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12Fence->Release();
|
||||
CyberXessContext::instance()->Dx12Fence = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandList[0] != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandList[0]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandList[0] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandList[1] != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandList[1]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandList[1] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandQueue != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandQueue->Release();
|
||||
CyberXessContext::instance()->Dx12CommandQueue = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandAllocator[0] != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[0]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[0] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12CommandAllocator[1] != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[1]->Release();
|
||||
CyberXessContext::instance()->Dx12CommandAllocator[1] = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12ProxyDevice != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12ProxyDevice->Release();
|
||||
CyberXessContext::instance()->Dx12ProxyDevice = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx12Device != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12Device->Release();
|
||||
CyberXessContext::instance()->Dx12Device = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx11on12Device != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx11on12Device->Release();
|
||||
CyberXessContext::instance()->Dx11on12Device = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx11Device != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx11Device->Release();
|
||||
CyberXessContext::instance()->Dx11Device = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->Dx11DeviceContext != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx11DeviceContext->Release();
|
||||
CyberXessContext::instance()->Dx11DeviceContext = nullptr;
|
||||
}
|
||||
|
||||
if (CyberXessContext::instance()->VulkanInstance != nullptr)
|
||||
CyberXessContext::instance()->VulkanInstance = nullptr;
|
||||
|
||||
if (CyberXessContext::instance()->VulkanDevice != nullptr)
|
||||
CyberXessContext::instance()->VulkanDevice = nullptr;
|
||||
|
||||
if (CyberXessContext::instance()->VulkanPhysicalDevice != nullptr)
|
||||
CyberXessContext::instance()->VulkanPhysicalDevice = nullptr;
|
||||
}
|
||||
|
||||
HRESULT CreateDx12Device(D3D_FEATURE_LEVEL featureLevel)
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
IDXGIFactory4* factory;
|
||||
result = CreateDXGIFactory2(0, IID_PPV_ARGS(&factory));
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG("CreateDx12Device Can't create factory: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
IDXGIAdapter1* hardwareAdapter = nullptr;
|
||||
GetHardwareAdapter(factory, &hardwareAdapter, featureLevel, true);
|
||||
|
||||
if (hardwareAdapter == nullptr)
|
||||
{
|
||||
LOG("CreateDx12Device Can't get hardwareAdapter!");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
result = D3D12CreateDevice(hardwareAdapter, featureLevel, IID_PPV_ARGS(&Dx12Device));
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG("CreateDx12Device Can't create device: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
|
||||
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
queueDesc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_HIGH;
|
||||
|
||||
// CreateCommandQueue
|
||||
result = Dx12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&Dx12CommandQueue));
|
||||
LOG("NVSDK_NGX_D3D11_EvaluateFeature CreateCommandQueue result: " + int_to_hex(result));
|
||||
|
||||
if (result != S_OK || Dx12CommandQueue == nullptr)
|
||||
return NVSDK_NGX_Result_FAIL_PlatformError;
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
};
|
||||
|
||||
class FeatureContext
|
||||
{
|
||||
public:
|
||||
NVSDK_NGX_Handle Handle;
|
||||
|
||||
xess_context_handle_t XessContext = nullptr;
|
||||
|
||||
unsigned int Width{}, Height{}, RenderWidth{}, RenderHeight{};
|
||||
NVSDK_NGX_PerfQuality_Value PerfQualityValue = NVSDK_NGX_PerfQuality_Value_Balanced;
|
||||
float Sharpness = 1.0f;
|
||||
float MVScaleX{}, MVScaleY{};
|
||||
float JitterOffsetX{}, JitterOffsetY{};
|
||||
};
|
||||
|
||||
static std::string ResultToString(xess_result_t result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case XESS_RESULT_WARNING_NONEXISTING_FOLDER: return "Warning Nonexistent Folder";
|
||||
case XESS_RESULT_WARNING_OLD_DRIVER: return "Warning Old Driver";
|
||||
case XESS_RESULT_SUCCESS: return "Success";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED_DEVICE: return "Unsupported Device";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED_DRIVER: return "Unsupported Driver";
|
||||
case XESS_RESULT_ERROR_UNINITIALIZED: return "Uninitialized";
|
||||
case XESS_RESULT_ERROR_INVALID_ARGUMENT: return "Invalid Argument";
|
||||
case XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY: return "Device Out of Memory";
|
||||
case XESS_RESULT_ERROR_DEVICE: return "Device Error";
|
||||
case XESS_RESULT_ERROR_NOT_IMPLEMENTED: return "Not Implemented";
|
||||
case XESS_RESULT_ERROR_INVALID_CONTEXT: return "Invalid Context";
|
||||
case XESS_RESULT_ERROR_OPERATION_IN_PROGRESS: return "Operation in Progress";
|
||||
case XESS_RESULT_ERROR_UNSUPPORTED: return "Unsupported";
|
||||
case XESS_RESULT_ERROR_CANT_LOAD_LIBRARY: return "Cannot Load Library";
|
||||
case XESS_RESULT_ERROR_UNKNOWN:
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,827 @@
|
||||
#include "pch.h"
|
||||
#include "Config.h"
|
||||
#include "CyberXess.h"
|
||||
#include "Util.h"
|
||||
|
||||
//static int cnt = 0;
|
||||
|
||||
inline void LogCallback(const char* Message, xess_logging_level_t Level)
|
||||
{
|
||||
std::string s = Message;
|
||||
LOG("XeSS Runtime (" + std::to_string(Level) + ") : " + s, LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
static bool CreateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle* handle)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature Start!", LEVEL_INFO);
|
||||
|
||||
#pragma region Read XeSS Version
|
||||
|
||||
xess_version_t ver;
|
||||
xess_result_t ret = xessGetVersion(&ver);
|
||||
|
||||
if (ret != XESS_RESULT_SUCCESS)
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature error : " + ResultToString(ret), LEVEL_ERROR);
|
||||
|
||||
char buf[128];
|
||||
sprintf_s(buf, "%u.%u.%u", ver.major, ver.minor, ver.patch);
|
||||
|
||||
std::string m_VersionStr = buf;
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature XeSS Version - " + m_VersionStr, LEVEL_WARNING);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Check for Dx12Device Device
|
||||
|
||||
if (CyberXessContext::instance()->Dx12Device == nullptr)
|
||||
{
|
||||
if (InCmdList == nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature InCmdList is null!!!", LEVEL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device is null trying to get from InCmdList!", LEVEL_WARNING);
|
||||
InCmdList->GetDevice(IID_PPV_ARGS(&CyberXessContext::instance()->Dx12Device));
|
||||
|
||||
if (CyberXessContext::instance()->Dx12Device == nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device can't receive from InCmdList!", LEVEL_ERROR);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device received from InCmdList!", LEVEL_WARNING);
|
||||
|
||||
CyberXessContext::instance()->Dx12Device->QueryInterface(__uuidof(ID3D12ProxyDevice), (void**)&CyberXessContext::instance()->Dx12ProxyDevice);
|
||||
|
||||
if (CyberXessContext::instance()->Dx12ProxyDevice != nullptr)
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature Dx12ProxyDevice assigned...", LEVEL_DEBUG);
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature Dx12ProxyDevice not assigned...", LEVEL_DEBUG);
|
||||
}
|
||||
}
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature CyberXessContext::instance()->Dx12Device is OK!", LEVEL_DEBUG);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Check for Dx12ProxyDevice Device
|
||||
//if (CyberXessContext::instance()->Dx12ProxyDevice != nullptr)
|
||||
//{
|
||||
// LOG("NVSDK_NGX_D3D12_CreateFeature Dx12ProxyDevice proxy adapter disabling spoofing...", LEVEL_DEBUG);
|
||||
// IDXGIProxyAdapter* pAdapter = nullptr;
|
||||
|
||||
// if (SUCCEEDED(CyberXessContext::instance()->Dx12ProxyDevice->GetProxyAdapter(&pAdapter)) && pAdapter != nullptr)
|
||||
// {
|
||||
// LOG("NVSDK_NGX_D3D12_CreateFeature Dx12ProxyDevice proxy adapter accuired...", LEVEL_DEBUG);
|
||||
// pAdapter->Spoofing(false);
|
||||
// LOG("NVSDK_NGX_D3D12_CreateFeature Dx12ProxyDevice proxy adapter spoofing disabled...", LEVEL_DEBUG);
|
||||
// }
|
||||
// else
|
||||
// LOG("NVSDK_NGX_D3D12_CreateFeature Dx12ProxyDevice proxy adapter is null!!!", LEVEL_DEBUG);
|
||||
//}
|
||||
#pragma endregion
|
||||
|
||||
auto inParams = CyberXessContext::instance()->CreateFeatureParams;
|
||||
auto deviceContext = CyberXessContext::instance()->Contexts[handle->Id].get();
|
||||
|
||||
if (deviceContext == nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature deviceContext is null!", LEVEL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature deviceContext ok, xessD3D12CreateContext start", LEVEL_DEBUG);
|
||||
|
||||
if (deviceContext->XessContext != nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature Destrying old XeSSContext", LEVEL_WARNING);
|
||||
ret = xessDestroyContext(deviceContext->XessContext);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessDestroyContext result -> " + ResultToString(ret), LEVEL_WARNING);
|
||||
}
|
||||
|
||||
ret = xessD3D12CreateContext(CyberXessContext::instance()->Dx12Device, &deviceContext->XessContext);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12CreateContext result -> " + ResultToString(ret), LEVEL_INFO);
|
||||
|
||||
ret = xessSetLoggingCallback(deviceContext->XessContext, XESS_LOGGING_LEVEL_DEBUG, LogCallback);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSetLoggingCallback : " + ResultToString(ret), LEVEL_DEBUG);
|
||||
|
||||
ret = xessSetVelocityScale(deviceContext->XessContext, inParams->MVScaleX, inParams->MVScaleY);
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSetVelocityScale : " + ResultToString(ret), LEVEL_DEBUG);
|
||||
|
||||
#pragma region Create Parameters for XeSS
|
||||
|
||||
xess_d3d12_init_params_t initParams{};
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature Params Init!", LEVEL_DEBUG);
|
||||
initParams.outputResolution.x = inParams->OutWidth;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.outputResolution.x : " + std::to_string(initParams.outputResolution.x), LEVEL_DEBUG);
|
||||
initParams.outputResolution.y = inParams->OutHeight;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.outputResolution.y : " + std::to_string(initParams.outputResolution.y), LEVEL_DEBUG);
|
||||
|
||||
switch (inParams->PerfQualityValue)
|
||||
{
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:
|
||||
initParams.qualitySetting = XESS_QUALITY_SETTING_PERFORMANCE;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:
|
||||
initParams.qualitySetting = XESS_QUALITY_SETTING_PERFORMANCE;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:
|
||||
initParams.qualitySetting = XESS_QUALITY_SETTING_BALANCED;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:
|
||||
initParams.qualitySetting = XESS_QUALITY_SETTING_QUALITY;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:
|
||||
initParams.qualitySetting = XESS_QUALITY_SETTING_ULTRA_QUALITY;
|
||||
break;
|
||||
default:
|
||||
initParams.qualitySetting = XESS_QUALITY_SETTING_BALANCED; //Set out-of-range value for non-existing fsr ultra quality mode
|
||||
break;
|
||||
}
|
||||
|
||||
initParams.initFlags = XESS_INIT_FLAG_NONE;
|
||||
|
||||
if (CyberXessContext::instance()->MyConfig->DepthInverted.value_or(inParams->DepthInverted))
|
||||
{
|
||||
initParams.initFlags |= XESS_INIT_FLAG_INVERTED_DEPTH;
|
||||
CyberXessContext::instance()->MyConfig->DepthInverted = true;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.initFlags (DepthInverted) " + std::to_string(initParams.initFlags), LEVEL_INFO);
|
||||
}
|
||||
if (CyberXessContext::instance()->MyConfig->AutoExposure.value_or(inParams->AutoExposure))
|
||||
{
|
||||
initParams.initFlags |= XESS_INIT_FLAG_ENABLE_AUTOEXPOSURE;
|
||||
CyberXessContext::instance()->MyConfig->AutoExposure = true;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.initFlags (AutoExposure) " + std::to_string(initParams.initFlags), LEVEL_INFO);
|
||||
}
|
||||
else
|
||||
{
|
||||
initParams.initFlags |= XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.initFlags (!AutoExposure) " + std::to_string(initParams.initFlags), LEVEL_INFO);
|
||||
}
|
||||
|
||||
if (!CyberXessContext::instance()->MyConfig->HDR.value_or(!inParams->Hdr))
|
||||
{
|
||||
initParams.initFlags |= XESS_INIT_FLAG_LDR_INPUT_COLOR;
|
||||
CyberXessContext::instance()->MyConfig->HDR = false;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.initFlags (HDR) " + std::to_string(initParams.initFlags), LEVEL_INFO);
|
||||
}
|
||||
if (CyberXessContext::instance()->MyConfig->JitterCancellation.value_or(inParams->JitterMotion))
|
||||
{
|
||||
initParams.initFlags |= XESS_INIT_FLAG_JITTERED_MV;
|
||||
CyberXessContext::instance()->MyConfig->JitterCancellation = true;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.initFlags (JitterCancellation) " + std::to_string(initParams.initFlags), LEVEL_INFO);
|
||||
}
|
||||
if (CyberXessContext::instance()->MyConfig->DisplayResolution.value_or(!inParams->LowRes))
|
||||
{
|
||||
initParams.initFlags |= XESS_INIT_FLAG_HIGH_RES_MV;
|
||||
CyberXessContext::instance()->MyConfig->DisplayResolution = true;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.initFlags (LowRes) " + std::to_string(initParams.initFlags), LEVEL_INFO);
|
||||
}
|
||||
|
||||
if (!CyberXessContext::instance()->MyConfig->DisableReactiveMask.value_or(true))
|
||||
{
|
||||
initParams.initFlags |= XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK;
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature initParams.initFlags (DisableReactiveMask) " + std::to_string(initParams.initFlags), LEVEL_INFO);
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature Params done!", LEVEL_DEBUG);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Build Pipelines
|
||||
|
||||
if (CyberXessContext::instance()->MyConfig->BuildPipelines.value_or(true))
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12BuildPipelines start!", LEVEL_DEBUG);
|
||||
|
||||
ret = xessD3D12BuildPipelines(deviceContext->XessContext, NULL, false, initParams.initFlags);
|
||||
|
||||
if (ret != XESS_RESULT_SUCCESS)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12BuildPipelines error : -> " + ResultToString(ret), LEVEL_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature skipping xessD3D12BuildPipelines!", LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Select Network Model
|
||||
|
||||
auto model = static_cast<xess_network_model_t>(CyberXessContext::instance()->MyConfig->NetworkModel.value_or(0));
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSelectNetworkModel trying to set value to " + std::to_string(model), LEVEL_DEBUG);
|
||||
|
||||
ret = xessSelectNetworkModel(deviceContext->XessContext, model);
|
||||
|
||||
if (ret == XESS_RESULT_SUCCESS)
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSelectNetworkModel set to " + std::to_string(model), LEVEL_DEBUG);
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessSelectNetworkModel(" + std::to_string(model) + ") error : " + ResultToString(ret), LEVEL_ERROR);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12Init start!", LEVEL_DEBUG);
|
||||
|
||||
ret = xessD3D12Init(deviceContext->XessContext, &initParams);
|
||||
|
||||
if (ret != XESS_RESULT_SUCCESS)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature xessD3D12Init error: " + ResultToString(ret), LEVEL_ERROR);
|
||||
CyberXessContext::instance()->init = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature End!", LEVEL_DEBUG);
|
||||
|
||||
CyberXessContext::instance()->init = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FeatureContext* CreateContext(NVSDK_NGX_Handle** OutHandle)
|
||||
{
|
||||
auto deviceContext = CyberXessContext::instance()->CreateContext();
|
||||
*OutHandle = &deviceContext->Handle;
|
||||
return deviceContext;
|
||||
}
|
||||
|
||||
#pragma region DLSS Init Calls
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_Ext(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath,
|
||||
ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion,
|
||||
unsigned long long unknown0)
|
||||
{
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext AppId:" + std::to_string(InApplicationId), LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext SDK:" + std::to_string(InSDKVersion), LEVEL_DEBUG);
|
||||
|
||||
LOG("Logger DelayedInit : " + std::to_string(CyberXessContext::instance()->MyConfig->DelayedInit.value_or(false)), LEVEL_INFO);
|
||||
LOG("Logger BuildPipelines : " + std::to_string(CyberXessContext::instance()->MyConfig->BuildPipelines.value_or(true)), LEVEL_INFO);
|
||||
LOG("Logger NetworkModel : " + std::to_string(CyberXessContext::instance()->MyConfig->NetworkModel.value_or(0)), LEVEL_INFO);
|
||||
LOG("Logger LogFile : " + CyberXessContext::instance()->MyConfig->LogFile.value_or(""), LEVEL_INFO);
|
||||
LOG("Logger LogLevel : " + std::to_string(CyberXessContext::instance()->MyConfig->LogLevel.value_or(1)), LEVEL_INFO);
|
||||
LOG("Logger XeSSLogging : " + std::to_string(CyberXessContext::instance()->MyConfig->XeSSLogging.value_or(true)), LEVEL_INFO);
|
||||
|
||||
CyberXessContext::instance()->init = false;
|
||||
CyberXessContext::instance()->Dx12Device = nullptr;
|
||||
CyberXessContext::instance()->Dx12ProxyDevice = nullptr;
|
||||
|
||||
if (InDevice)
|
||||
{
|
||||
WrappedD3D12Device* proxyDevice = nullptr;
|
||||
if (InDevice->QueryInterface(__uuidof(ID3D12ProxyDevice), (void**)&proxyDevice) == S_OK && proxyDevice != nullptr)
|
||||
{
|
||||
CyberXessContext::instance()->Dx12Device = proxyDevice->m_device;
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext Proxy Dx12Device assigned...", LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
{
|
||||
CyberXessContext::instance()->Dx12Device = InDevice;
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext Dx12Device assigned...", LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
InDevice->QueryInterface(__uuidof(ID3D12ProxyDevice), (void**)&CyberXessContext::instance()->Dx12ProxyDevice);
|
||||
|
||||
if (CyberXessContext::instance()->Dx12ProxyDevice != nullptr)
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext Dx12ProxyDevice assigned...", LEVEL_DEBUG);
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext Dx12ProxyDevice not assigned...", LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_Init_Ext Dx12Device is already assigned or InDevice is null!!!!", LEVEL_ERROR);
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath,
|
||||
ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_Init AppId:" + std::to_string(InApplicationId), LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_D3D12_Init SDK:" + std::to_string(InSDKVersion), LEVEL_DEBUG);
|
||||
|
||||
return NVSDK_NGX_D3D12_Init_Ext(InApplicationId, InApplicationDataPath, InDevice, InFeatureInfo, InSDKVersion, 0);
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_ProjectID(const char* InProjectId, NVSDK_NGX_EngineType InEngineType,
|
||||
const char* InEngineVersion, const wchar_t* InApplicationDataPath, ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion)
|
||||
{
|
||||
std::string pId = InProjectId;
|
||||
LOG("NVSDK_NGX_D3D12_Init_ProjectID : " + pId, LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_D3D12_Init_ProjectID SDK:" + std::to_string(InSDKVersion), LEVEL_DEBUG);
|
||||
|
||||
return NVSDK_NGX_D3D12_Init_Ext(0x1337, InApplicationDataPath, InDevice, InFeatureInfo, InSDKVersion, 0);
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_with_ProjectID(const char* InProjectId, NVSDK_NGX_EngineType InEngineType, const char* InEngineVersion,
|
||||
const wchar_t* InApplicationDataPath, ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion)
|
||||
{
|
||||
std::string pId = InProjectId;
|
||||
LOG("NVSDK_NGX_D3D12_Init_with_ProjectID : " + pId, LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_D3D12_Init_with_ProjectID SDK:" + std::to_string(InSDKVersion), LEVEL_DEBUG);
|
||||
|
||||
return NVSDK_NGX_D3D12_Init_Ext(0x1337, InApplicationDataPath, InDevice, InFeatureInfo, InSDKVersion, 0);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region DLSS Shutdown Calls
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown(void)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_Shutdown", LEVEL_DEBUG);
|
||||
|
||||
//if (CyberXessContext::instance()->Dx12ProxyDevice != nullptr)
|
||||
//{
|
||||
// LOG("NVSDK_NGX_D3D12_Shutdown Dx12ProxyDevice proxy adapter spoofing enabling...", LEVEL_DEBUG);
|
||||
// IDXGIProxyAdapter* pAdapter = nullptr;
|
||||
// CyberXessContext::instance()->Dx12ProxyDevice->GetProxyAdapter(&pAdapter);
|
||||
// LOG("NVSDK_NGX_D3D12_Shutdown Dx12ProxyDevice proxy adapter accuired...", LEVEL_DEBUG);
|
||||
|
||||
// if (pAdapter != nullptr)
|
||||
// {
|
||||
// pAdapter->Spoofing(true);
|
||||
// LOG("NVSDK_NGX_D3D12_Shutdown Dx12ProxyDevice proxy adapter spoofing enabled...", LEVEL_DEBUG);
|
||||
// }
|
||||
// else
|
||||
// LOG("NVSDK_NGX_D3D12_Shutdown Dx12ProxyDevice proxy adapter is null!!!", LEVEL_DEBUG);
|
||||
//}
|
||||
|
||||
CyberXessContext::instance()->Shutdown();
|
||||
|
||||
CyberXessContext::instance()->NvParameterInstance->Params.clear();
|
||||
CyberXessContext::instance()->Contexts.clear();
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown1(ID3D12Device* InDevice)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_Shutdown1", LEVEL_DEBUG);
|
||||
|
||||
//if (CyberXessContext::instance()->Dx12ProxyDevice != nullptr)
|
||||
//{
|
||||
// LOG("NVSDK_NGX_D3D12_Shutdown1 Dx12ProxyDevice proxy adapter spoofing enabling...", LEVEL_DEBUG);
|
||||
|
||||
// IDXGIProxyAdapter* pAdapter = nullptr;
|
||||
// CyberXessContext::instance()->Dx12ProxyDevice->GetProxyAdapter(&pAdapter);
|
||||
// LOG("NVSDK_NGX_D3D12_Shutdown1 Dx12ProxyDevice proxy adapter accuired...", LEVEL_DEBUG);
|
||||
|
||||
// if (pAdapter != nullptr)
|
||||
// {
|
||||
// pAdapter->Spoofing(true);
|
||||
// LOG("NVSDK_NGX_D3D12_Shutdown1 Dx12ProxyDevice proxy adapter spoofing enabled...", LEVEL_DEBUG);
|
||||
// }
|
||||
// else
|
||||
// LOG("NVSDK_NGX_D3D12_Shutdown1 Dx12ProxyDevice proxy adapter is null!!!", LEVEL_DEBUG);
|
||||
//}
|
||||
|
||||
CyberXessContext::instance()->Shutdown();
|
||||
|
||||
CyberXessContext::instance()->NvParameterInstance->Params.clear();
|
||||
CyberXessContext::instance()->Contexts.clear();
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region DLSS Parameter Calls
|
||||
|
||||
//currently it's kind of hack but better than what it was previously -- External Memory Tracking
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetParameters(NVSDK_NGX_Parameter** OutParameters)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_GetParameters", LEVEL_DEBUG);
|
||||
|
||||
*OutParameters = CyberXessContext::instance()->NvParameterInstance->AllocateParameters();
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
//currently it's kind of hack still needs a proper implementation
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_GetCapabilityParameters", LEVEL_DEBUG);
|
||||
|
||||
*OutParameters = NvParameter::instance()->AllocateParameters();
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
//currently it's kind of hack still needs a proper implementation
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_AllocateParameters(NVSDK_NGX_Parameter** OutParameters)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_AllocateParameters", LEVEL_DEBUG);
|
||||
|
||||
*OutParameters = NvParameter::instance()->AllocateParameters();
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
//currently it's kind of hack still needs a proper implementation
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_DestroyParameters(NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_DestroyParameters", LEVEL_DEBUG);
|
||||
|
||||
NvParameter::instance()->DeleteParameters((NvParameter*)InParameters);
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region DLSS Feature Calls
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsCommandList* InCmdList, NVSDK_NGX_Feature InFeatureID, NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle)
|
||||
{
|
||||
auto context = CreateContext(OutHandle);
|
||||
CyberXessContext::instance()->CreateFeatureParams = static_cast<const NvParameter*>(InParameters);
|
||||
|
||||
if (CyberXessContext::instance()->MyConfig->DelayedInit.value_or(false))
|
||||
return NVSDK_NGX_Result_Success;
|
||||
|
||||
if (CreateFeature(InCmdList, &context->Handle))
|
||||
return NVSDK_NGX_Result_Success;
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_CreateFeature: CreateFeature failed", LEVEL_ERROR);
|
||||
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle* InHandle)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_ReleaseFeature!", LEVEL_DEBUG);
|
||||
|
||||
auto deviceContext = CyberXessContext::instance()->Contexts[InHandle->Id].get();
|
||||
auto result = xessDestroyContext(deviceContext->XessContext);
|
||||
LOG("NVSDK_NGX_D3D12_ReleaseFeature: xessDestroyContext result: " + ResultToString(result), LEVEL_DEBUG);
|
||||
CyberXessContext::instance()->DeleteContext(InHandle);
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetFeatureRequirements(IDXGIAdapter* Adapter, const NVSDK_NGX_FeatureDiscoveryInfo* FeatureDiscoveryInfo,
|
||||
NVSDK_NGX_FeatureRequirement* OutSupported)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_GetFeatureRequirements!", LEVEL_DEBUG);
|
||||
|
||||
*OutSupported = NVSDK_NGX_FeatureRequirement();
|
||||
OutSupported->FeatureSupported = NVSDK_NGX_FeatureSupportResult_Supported;
|
||||
OutSupported->MinHWArchitecture = 0;
|
||||
//Some windows 10 os version
|
||||
strcpy_s(OutSupported->MinOSVersion, "10.0.19045.2728");
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle* InFeatureHandle, const NVSDK_NGX_Parameter* InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature init!", LEVEL_DEBUG);
|
||||
|
||||
if (!InCmdList)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature InCmdList is null!!!", LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
|
||||
if (InCallback)
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature callback exist", LEVEL_WARNING);
|
||||
|
||||
const auto inParams = static_cast<const NvParameter*>(InParameters);
|
||||
const auto instance = CyberXessContext::instance();
|
||||
|
||||
if (!instance->init)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature init is false, calling CreateFeature!", LEVEL_WARNING);
|
||||
instance->init = CreateFeature(InCmdList, InFeatureHandle);
|
||||
}
|
||||
|
||||
if (!instance->init)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature init still is null CreateFeature failed!", LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
|
||||
auto deviceContext = instance->Contexts[InFeatureHandle->Id].get();
|
||||
|
||||
//dumpParams.frame_count = 1;
|
||||
//dumpParams.frame_idx = cnt++;
|
||||
//dumpParams.path = "D:\\dmp\\";
|
||||
//xessStartDump(deviceContext->XessContext, &dumpParams);
|
||||
|
||||
// creatimg params for XeSS
|
||||
xess_result_t xessResult;
|
||||
xess_d3d12_execute_params_t params{};
|
||||
|
||||
params.jitterOffsetX = inParams->JitterOffsetX;
|
||||
params.jitterOffsetY = inParams->JitterOffsetY;
|
||||
|
||||
params.exposureScale = inParams->ExposureScale;
|
||||
params.resetHistory = inParams->ResetRender;
|
||||
|
||||
params.inputWidth = inParams->Width;
|
||||
params.inputHeight = inParams->Height;
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature inp width: " + std::to_string(inParams->Width) + " height: " + std::to_string(inParams->Height), LEVEL_DEBUG);
|
||||
|
||||
|
||||
HRESULT d3d11on11Result;
|
||||
|
||||
if (inParams->Color != nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Color exist..", LEVEL_DEBUG);
|
||||
|
||||
if (instance->Dx11on12Device != nullptr)
|
||||
{
|
||||
params.pColorTexture = nullptr;
|
||||
|
||||
d3d11on11Result = instance->Dx11on12Device->UnwrapUnderlyingResource(
|
||||
(ID3D11Resource*)inParams->Color,
|
||||
instance->Dx12CommandQueue,
|
||||
IID_PPV_ARGS(¶ms.pColorTexture)
|
||||
);
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Color UnwrapUnderlyingResource result: " + int_to_hex(d3d11on11Result), LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
params.pColorTexture = (ID3D12Resource*)inParams->Color;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Color not exist!!", LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_FAIL_InvalidParameter;
|
||||
}
|
||||
|
||||
if (inParams->MotionVectors)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature MotionVectors exist..", LEVEL_DEBUG);
|
||||
|
||||
if (instance->Dx11on12Device != nullptr)
|
||||
{
|
||||
params.pVelocityTexture = nullptr;
|
||||
|
||||
d3d11on11Result = instance->Dx11on12Device->UnwrapUnderlyingResource(
|
||||
(ID3D11Resource*)inParams->MotionVectors,
|
||||
instance->Dx12CommandQueue,
|
||||
IID_PPV_ARGS(¶ms.pVelocityTexture)
|
||||
);
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature MotionVectors UnwrapUnderlyingResource result: " + int_to_hex(d3d11on11Result), LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
params.pVelocityTexture = (ID3D12Resource*)inParams->MotionVectors;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature MotionVectors not exist!!", LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_FAIL_InvalidParameter;
|
||||
}
|
||||
|
||||
if (inParams->Output)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Output exist..", LEVEL_DEBUG);
|
||||
|
||||
if (instance->Dx11on12Device != nullptr)
|
||||
{
|
||||
params.pOutputTexture = nullptr;
|
||||
|
||||
d3d11on11Result = instance->Dx11on12Device->UnwrapUnderlyingResource(
|
||||
(ID3D11Resource*)inParams->Output,
|
||||
instance->Dx12CommandQueue,
|
||||
IID_PPV_ARGS(¶ms.pOutputTexture)
|
||||
);
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Output UnwrapUnderlyingResource result: " + int_to_hex(d3d11on11Result), LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
params.pOutputTexture = (ID3D12Resource*)inParams->Output;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Output not exist!!", LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_FAIL_InvalidParameter;
|
||||
}
|
||||
|
||||
if (inParams->Depth && !instance->MyConfig->DisplayResolution.value_or(false))
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Depth exist..", LEVEL_INFO);
|
||||
|
||||
if (instance->Dx11on12Device != nullptr)
|
||||
{
|
||||
params.pDepthTexture = nullptr;
|
||||
|
||||
d3d11on11Result = instance->Dx11on12Device->UnwrapUnderlyingResource(
|
||||
(ID3D11Resource*)inParams->Depth,
|
||||
instance->Dx12CommandQueue,
|
||||
IID_PPV_ARGS(¶ms.pDepthTexture)
|
||||
);
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Depth UnwrapUnderlyingResource result: " + int_to_hex(d3d11on11Result), LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
params.pDepthTexture = (ID3D12Resource*)inParams->Depth;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!instance->MyConfig->DisplayResolution.value_or(false))
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Depth not exist!!", LEVEL_ERROR);
|
||||
else
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Using high res motion vectors, depth is not needed!!", LEVEL_INFO);
|
||||
|
||||
params.pDepthTexture = nullptr;
|
||||
}
|
||||
|
||||
if (!instance->MyConfig->AutoExposure.value_or(false))
|
||||
{
|
||||
if (inParams->ExposureTexture == nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature AutoExposure disabled but ExposureTexture is not exist, it may cause problems!!", LEVEL_WARNING);
|
||||
params.pExposureScaleTexture = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature ExposureTexture exist..", LEVEL_INFO);
|
||||
|
||||
if (instance->Dx11on12Device != nullptr)
|
||||
{
|
||||
params.pExposureScaleTexture = nullptr;
|
||||
|
||||
d3d11on11Result = instance->Dx11on12Device->UnwrapUnderlyingResource(
|
||||
(ID3D11Resource*)inParams->ExposureTexture,
|
||||
instance->Dx12CommandQueue,
|
||||
IID_PPV_ARGS(¶ms.pExposureScaleTexture)
|
||||
);
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature ExposureTexture UnwrapUnderlyingResource result: " + int_to_hex(d3d11on11Result), LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
params.pExposureScaleTexture = (ID3D12Resource*)inParams->ExposureTexture;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature AutoExposure enabled!", LEVEL_WARNING);
|
||||
params.pExposureScaleTexture = nullptr;
|
||||
}
|
||||
|
||||
if (!instance->MyConfig->DisableReactiveMask.value_or(true))
|
||||
{
|
||||
if (inParams->TransparencyMask != nullptr)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature TransparencyMask exist..", LEVEL_INFO);
|
||||
|
||||
if (instance->Dx11on12Device != nullptr)
|
||||
{
|
||||
params.pResponsivePixelMaskTexture = nullptr;
|
||||
|
||||
d3d11on11Result = instance->Dx11on12Device->UnwrapUnderlyingResource(
|
||||
(ID3D11Resource*)inParams->TransparencyMask,
|
||||
instance->Dx12CommandQueue,
|
||||
IID_PPV_ARGS(¶ms.pResponsivePixelMaskTexture)
|
||||
);
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature TransparencyMask UnwrapUnderlyingResource result: " + int_to_hex(d3d11on11Result), LEVEL_DEBUG);
|
||||
}
|
||||
else
|
||||
params.pResponsivePixelMaskTexture = (ID3D12Resource*)inParams->TransparencyMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature TransparencyMask not exist and its enabled in config, it may cause problems!!", LEVEL_WARNING);
|
||||
params.pResponsivePixelMaskTexture = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
params.pResponsivePixelMaskTexture = nullptr;
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature mvscale x: " + std::to_string(inParams->MVScaleX) + " y: " + std::to_string(inParams->MVScaleY), LEVEL_DEBUG);
|
||||
xessResult = xessSetVelocityScale(deviceContext->XessContext, inParams->MVScaleX, inParams->MVScaleY);
|
||||
|
||||
if (xessResult != XESS_RESULT_SUCCESS)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature xessSetVelocityScale : " + ResultToString(xessResult), LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
|
||||
const UINT64 fence = instance->Dx12FenceValueCounter;
|
||||
|
||||
if (instance->Dx11on12Device != nullptr)
|
||||
{
|
||||
// Transition render targets D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE for XeSS
|
||||
std::vector<CD3DX12_RESOURCE_BARRIER> transitions = {};
|
||||
|
||||
if (params.pColorTexture != nullptr)
|
||||
transitions.push_back(CD3DX12_RESOURCE_BARRIER::Transition(params.pColorTexture,
|
||||
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE));
|
||||
if (params.pVelocityTexture != nullptr)
|
||||
CD3DX12_RESOURCE_BARRIER::Transition(params.pVelocityTexture,
|
||||
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
if (params.pDepthTexture != nullptr)
|
||||
CD3DX12_RESOURCE_BARRIER::Transition(params.pDepthTexture,
|
||||
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
if (params.pExposureScaleTexture != nullptr)
|
||||
CD3DX12_RESOURCE_BARRIER::Transition(params.pExposureScaleTexture,
|
||||
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
if (params.pResponsivePixelMaskTexture != nullptr)
|
||||
CD3DX12_RESOURCE_BARRIER::Transition(params.pResponsivePixelMaskTexture,
|
||||
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
// Transition output D3D12_RESOURCE_STATE_UNORDERED_ACCESS for XeSS
|
||||
if (params.pOutputTexture != nullptr)
|
||||
CD3DX12_RESOURCE_BARRIER::Transition(params.pResponsivePixelMaskTexture,
|
||||
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
|
||||
InCmdList->ResourceBarrier((UINT)transitions.size(), transitions.data());
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Executing!!", LEVEL_INFO);
|
||||
xessResult = xessD3D12Execute(deviceContext->XessContext, InCmdList, ¶ms);
|
||||
|
||||
if (instance->Dx11on12Device != nullptr)
|
||||
{
|
||||
auto bResult = instance->Dx12Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&instance->Dx12Fence));
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature CreateFence result: " + int_to_hex(bResult), LEVEL_DEBUG);
|
||||
|
||||
// Signal the command queue and wait for the fence
|
||||
bResult = instance->Dx12CommandQueue->Signal(instance->Dx12Fence, fence);
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature Signal result: " + int_to_hex(bResult), LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
if (xessResult != XESS_RESULT_SUCCESS)
|
||||
{
|
||||
LOG("xessD3D12Execute error : -> " + ResultToString(xessResult), LEVEL_ERROR);
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
|
||||
if (instance->Dx11DeviceContext != nullptr && params.pOutputTexture)
|
||||
{
|
||||
UINT64 signals[1] = { fence };
|
||||
ID3D12Fence* fences[1] = { CyberXessContext::instance()->Dx12Fence };
|
||||
HRESULT bResult;
|
||||
|
||||
if (params.pOutputTexture != nullptr)
|
||||
{
|
||||
bResult = CyberXessContext::instance()->Dx11on12Device->ReturnUnderlyingResource((ID3D11Resource*)inParams->Output, 1, signals, fences);
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature pOutputTexture ReturnUnderlyingResource Output result: " + int_to_hex(bResult), LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
if (params.pColorTexture != nullptr)
|
||||
{
|
||||
bResult = CyberXessContext::instance()->Dx11on12Device->ReturnUnderlyingResource((ID3D11Resource*)inParams->Color, 1, signals, fences);
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature pOutputTexture ReturnUnderlyingResource Color result: " + int_to_hex(bResult), LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
if (params.pDepthTexture != nullptr)
|
||||
{
|
||||
bResult = CyberXessContext::instance()->Dx11on12Device->ReturnUnderlyingResource((ID3D11Resource*)inParams->Depth, 1, signals, fences);
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature pOutputTexture ReturnUnderlyingResource Depth result: " + int_to_hex(bResult), LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
if (params.pVelocityTexture != nullptr)
|
||||
{
|
||||
bResult = CyberXessContext::instance()->Dx11on12Device->ReturnUnderlyingResource((ID3D11Resource*)inParams->MotionVectors, 1, signals, fences);
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature pOutputTexture ReturnUnderlyingResource MotionVectors result: " + int_to_hex(bResult), LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
if (params.pExposureScaleTexture != nullptr)
|
||||
{
|
||||
bResult = CyberXessContext::instance()->Dx11on12Device->ReturnUnderlyingResource((ID3D11Resource*)inParams->ExposureTexture, 1, signals, fences);
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature pOutputTexture ReturnUnderlyingResource MotionVectors result: " + int_to_hex(bResult), LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
if (params.pResponsivePixelMaskTexture != nullptr)
|
||||
{
|
||||
bResult = CyberXessContext::instance()->Dx11on12Device->ReturnUnderlyingResource((ID3D11Resource*)inParams->TransparencyMask, 1, signals, fences);
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature pOutputTexture ReturnUnderlyingResource MotionVectors result: " + int_to_hex(bResult), LEVEL_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
LOG("NVSDK_NGX_D3D12_EvaluateFeature End!", LEVEL_DEBUG);
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_UpdateFeature(const NVSDK_NGX_Application_Identifier* ApplicationId, const NVSDK_NGX_Feature FeatureID)
|
||||
{
|
||||
LOG("NVSDK_NGX_UpdateFeature -> " + std::to_string(FeatureID), LEVEL_DEBUG);
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region DLSS Buffer Size Call
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter* InParameters, size_t* OutSizeInBytes)
|
||||
{
|
||||
LOG("NVSDK_NGX_D3D12_GetScratchBufferSize -> 52428800", LEVEL_WARNING);
|
||||
|
||||
*OutSizeInBytes = 52428800;
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "pch.h"
|
||||
#include "Config.h"
|
||||
#include "CyberXess.h"
|
||||
#include "Util.h"
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_Init Init!", LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_VULKAN_Init AppId:" + std::to_string(InApplicationId), LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_VULKAN_Init SDK:" + std::to_string(InSDKVersion), LEVEL_DEBUG);
|
||||
|
||||
CyberXessContext::instance()->VulkanInstance = InInstance;
|
||||
CyberXessContext::instance()->VulkanPhysicalDevice = InPD;
|
||||
CyberXessContext::instance()->VulkanDevice = InDevice;
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_ProjectID(const char* InProjectId, NVSDK_NGX_EngineType InEngineType, const char* InEngineVersion, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_Init_ProjectID Init!", LEVEL_DEBUG);
|
||||
std::string pId = InProjectId;
|
||||
LOG("NVSDK_NGX_VULKAN_Init_ProjectID : " + pId, LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_VULKAN_Init_ProjectID SDK:" + std::to_string(InSDKVersion), LEVEL_DEBUG);
|
||||
|
||||
return NVSDK_NGX_VULKAN_Init(0x1337, InApplicationDataPath, InInstance, InPD, InDevice, InGIPA, InGDPA, InFeatureInfo, InSDKVersion);
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_with_ProjectID(const char* InProjectId, NVSDK_NGX_EngineType InEngineType, const char* InEngineVersion, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion)
|
||||
{
|
||||
std::string pId = InProjectId;
|
||||
LOG("NVSDK_NGX_VULKAN_Init_with_ProjectID : " + pId, LEVEL_DEBUG);
|
||||
LOG("NVSDK_NGX_VULKAN_Init_with_ProjectID SDK:" + std::to_string(InSDKVersion), LEVEL_DEBUG);
|
||||
|
||||
return NVSDK_NGX_VULKAN_Init(0x1337, InApplicationDataPath, InInstance, InPD, InDevice, InGIPA, InGDPA, InFeatureInfo, InSDKVersion);
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Shutdown(void)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_Shutdown", LEVEL_DEBUG);
|
||||
|
||||
CyberXessContext::instance()->VulkanDevice = nullptr;
|
||||
CyberXessContext::instance()->VulkanInstance = nullptr;
|
||||
CyberXessContext::instance()->VulkanPhysicalDevice = nullptr;
|
||||
CyberXessContext::instance()->NvParameterInstance->Params.clear();
|
||||
CyberXessContext::instance()->Contexts.clear();
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Shutdown1(VkDevice InDevice)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_Shutdown1", LEVEL_DEBUG);
|
||||
|
||||
CyberXessContext::instance()->VulkanDevice = nullptr;
|
||||
CyberXessContext::instance()->VulkanInstance = nullptr;
|
||||
CyberXessContext::instance()->VulkanPhysicalDevice = nullptr;
|
||||
CyberXessContext::instance()->NvParameterInstance->Params.clear();
|
||||
CyberXessContext::instance()->Contexts.clear();
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NVSDK_NGX_VULKAN_GetParameters(NVSDK_NGX_Parameter** OutParameters)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_GetParameters", LEVEL_DEBUG);
|
||||
|
||||
*OutParameters = CyberXessContext::instance()->NvParameterInstance->AllocateParameters();
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_AllocateParameters(NVSDK_NGX_Parameter** OutParameters)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_AllocateParameters", LEVEL_DEBUG);
|
||||
|
||||
*OutParameters = NvParameter::instance()->AllocateParameters();
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_GetCapabilityParameters", LEVEL_DEBUG);
|
||||
|
||||
*OutParameters = NvParameter::instance()->AllocateParameters();
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_DestroyParameters(NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_DestroyParameters", LEVEL_DEBUG);
|
||||
|
||||
NvParameter::instance()->DeleteParameters((NvParameter*)InParameters);
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter* InParameters, size_t* OutSizeInBytes)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_GetScratchBufferSize -> 52428800", LEVEL_DEBUG);
|
||||
|
||||
*OutSizeInBytes = 52428800;
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_CreateFeature(VkCommandBuffer InCmdBuffer, NVSDK_NGX_Feature InFeatureID, NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle)
|
||||
{
|
||||
return NVSDK_NGX_VULKAN_CreateFeature1(CyberXessContext::instance()->VulkanDevice, InCmdBuffer, InFeatureID, InParameters, OutHandle);
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_CreateFeature1(VkDevice InDevice, VkCommandBuffer InCmdList, NVSDK_NGX_Feature InFeatureID, NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_CreateFeature1 Fail!", LEVEL_DEBUG);
|
||||
return NVSDK_NGX_Result_FAIL_PlatformError;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_ReleaseFeature(NVSDK_NGX_Handle* InHandle)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_ReleaseFeature", LEVEL_DEBUG);
|
||||
|
||||
auto deviceContext = CyberXessContext::instance()->Contexts[InHandle->Id].get();
|
||||
CyberXessContext::instance()->DeleteContext(InHandle);
|
||||
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_EvaluateFeature(VkCommandBuffer InCmdList, const NVSDK_NGX_Handle* InFeatureHandle, const NVSDK_NGX_Parameter* InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback)
|
||||
{
|
||||
LOG("NVSDK_NGX_VULKAN_EvaluateFeature", LEVEL_DEBUG);
|
||||
return NVSDK_NGX_Result_FAIL_PlatformError;
|
||||
}
|
||||
@@ -0,0 +1,444 @@
|
||||
#include "pch.h"
|
||||
#include "Config.h"
|
||||
#include "Util.h"
|
||||
#include "NvParameter.h"
|
||||
#include "CyberXess.h"
|
||||
|
||||
void NvParameter::Set(const char* InName, unsigned long long InValue)
|
||||
{
|
||||
auto value = (unsigned long long*) & InValue;
|
||||
Set_Internal(InName, *value, NvULL);
|
||||
}
|
||||
|
||||
void NvParameter::Set(const char* InName, float InValue)
|
||||
{
|
||||
auto value = (unsigned long long*) & InValue;
|
||||
Set_Internal(InName, *value, NvFloat);
|
||||
}
|
||||
|
||||
void NvParameter::Set(const char* InName, double InValue)
|
||||
{
|
||||
auto value = (unsigned long long*) & InValue;
|
||||
Set_Internal(InName, *value, NvDouble);
|
||||
}
|
||||
|
||||
void NvParameter::Set(const char* InName, unsigned int InValue)
|
||||
{
|
||||
auto value = (unsigned long long*) & InValue;
|
||||
Set_Internal(InName, *value, NvUInt);
|
||||
}
|
||||
|
||||
void NvParameter::Set(const char* InName, int InValue)
|
||||
{
|
||||
auto value = (unsigned long long*) & InValue;
|
||||
Set_Internal(InName, *value, NvInt);
|
||||
}
|
||||
|
||||
void NvParameter::Set(const char* InName, ID3D11Resource* InValue)
|
||||
{
|
||||
auto value = (unsigned long long*) & InValue;
|
||||
Set_Internal(InName, *value, NvD3D11Resource);
|
||||
}
|
||||
|
||||
void NvParameter::Set(const char* InName, ID3D12Resource* InValue)
|
||||
{
|
||||
auto value = (unsigned long long*) & InValue;
|
||||
Set_Internal(InName, *value, NvD3D12Resource);
|
||||
}
|
||||
|
||||
void NvParameter::Set(const char* InName, void* InValue)
|
||||
{
|
||||
auto value = (unsigned long long*) & InValue;
|
||||
Set_Internal(InName, *value, NvVoidPtr);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get(const char* InName, unsigned long long* OutValue) const
|
||||
{
|
||||
return Get_Internal(InName, (unsigned long long*)OutValue, NvULL);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get(const char* InName, float* OutValue) const
|
||||
{
|
||||
return Get_Internal(InName, (unsigned long long*)OutValue, NvFloat);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get(const char* InName, double* OutValue) const
|
||||
{
|
||||
return Get_Internal(InName, (unsigned long long*)OutValue, NvDouble);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get(const char* InName, unsigned int* OutValue) const
|
||||
{
|
||||
return Get_Internal(InName, (unsigned long long*)OutValue, NvUInt);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get(const char* InName, int* OutValue) const
|
||||
{
|
||||
return Get_Internal(InName, (unsigned long long*)OutValue, NvInt);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get(const char* InName, ID3D11Resource** OutValue) const
|
||||
{
|
||||
return Get_Internal(InName, (unsigned long long*)OutValue, NvD3D11Resource);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get(const char* InName, ID3D12Resource** OutValue) const
|
||||
{
|
||||
return Get_Internal(InName, (unsigned long long*)OutValue, NvD3D12Resource);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get(const char* InName, void** OutValue) const
|
||||
{
|
||||
return Get_Internal(InName, (unsigned long long*)OutValue, NvVoidPtr);
|
||||
}
|
||||
|
||||
void NvParameter::Reset()
|
||||
{
|
||||
}
|
||||
|
||||
void NvParameter::Set_Internal(const char* InName, unsigned long long InValue, NvParameterType ParameterType)
|
||||
{
|
||||
auto inValueFloat = (float*)&InValue;
|
||||
auto inValueInt = (int*)&InValue;
|
||||
auto inValueDouble = (double*)&InValue;
|
||||
auto inValueUInt = (unsigned int*)&InValue;
|
||||
//Includes DirectX Resources
|
||||
auto inValuePtr = (void*)InValue;
|
||||
|
||||
std::string s;
|
||||
s = InName;
|
||||
|
||||
LOG("Set_Internal : " + s + " - f:" + std::to_string(*inValueFloat) + " - d:" + std::to_string(*inValueDouble) + " - i:" + std::to_string(*inValueInt) + " - u:" + std::to_string(*inValueUInt), LEVEL_DEBUG);
|
||||
|
||||
switch (Util::NvParameterToEnum(InName))
|
||||
{
|
||||
case Util::NvParameter::MV_Scale_X:
|
||||
MVScaleX = *inValueFloat;
|
||||
break;
|
||||
case Util::NvParameter::MV_Scale_Y:
|
||||
MVScaleY = *inValueFloat;
|
||||
break;
|
||||
case Util::NvParameter::Jitter_Offset_X:
|
||||
JitterOffsetX = *inValueFloat;
|
||||
break;
|
||||
case Util::NvParameter::Jitter_Offset_Y:
|
||||
JitterOffsetY = *inValueFloat;
|
||||
break;
|
||||
case Util::NvParameter::Sharpness:
|
||||
Sharpness = *inValueFloat;
|
||||
break;
|
||||
case Util::NvParameter::Width:
|
||||
Width = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::Height:
|
||||
Height = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Render_Subrect_Dimensions_Width:
|
||||
Width = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Render_Subrect_Dimensions_Height:
|
||||
Height = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::PerfQualityValue:
|
||||
PerfQualityValue = static_cast<NVSDK_NGX_PerfQuality_Value>(*inValueInt);
|
||||
break;
|
||||
case Util::NvParameter::RTXValue:
|
||||
RTXValue = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::FreeMemOnReleaseFeature:
|
||||
FreeMemOnReleaseFeature = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::CreationNodeMask:
|
||||
CreationNodeMask = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::VisibilityNodeMask:
|
||||
VisibilityNodeMask = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::Reset:
|
||||
ResetRender = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::OutWidth:
|
||||
OutWidth = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::OutHeight:
|
||||
OutHeight = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_Balanced:
|
||||
BalancedPreset = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_DLAA:
|
||||
DLAAPreset = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_Performance:
|
||||
PerfPreset = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_Quality:
|
||||
QualityPreset = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_UltraQuality:
|
||||
UltraQualityPreset = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_UltraPerformance:
|
||||
UltraPerfPreset = *inValueInt;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Feature_Create_Flags:
|
||||
Hdr = *inValueInt & NVSDK_NGX_DLSS_Feature_Flags_IsHDR;
|
||||
EnableSharpening = *inValueInt & NVSDK_NGX_DLSS_Feature_Flags_DoSharpening;
|
||||
DepthInverted = *inValueInt & NVSDK_NGX_DLSS_Feature_Flags_DepthInverted;
|
||||
JitterMotion = *inValueInt & NVSDK_NGX_DLSS_Feature_Flags_MVJittered;
|
||||
LowRes = *inValueInt & NVSDK_NGX_DLSS_Feature_Flags_MVLowRes;
|
||||
AutoExposure = *inValueInt & NVSDK_NGX_DLSS_Feature_Flags_AutoExposure;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Input_Bias_Current_Color_Mask:
|
||||
InputBiasCurrentColorMask = inValuePtr;
|
||||
break;
|
||||
case Util::NvParameter::Color:
|
||||
Color = inValuePtr;
|
||||
break;
|
||||
case Util::NvParameter::Depth:
|
||||
Depth = inValuePtr;
|
||||
break;
|
||||
case Util::NvParameter::MotionVectors:
|
||||
MotionVectors = inValuePtr;
|
||||
break;
|
||||
case Util::NvParameter::Output:
|
||||
Output = inValuePtr;
|
||||
break;
|
||||
case Util::NvParameter::TransparencyMask:
|
||||
TransparencyMask = inValuePtr;
|
||||
break;
|
||||
case Util::NvParameter::ExposureTexture:
|
||||
ExposureTexture = inValuePtr;
|
||||
break;
|
||||
case Util::NvParameter::Exposure_Scale:
|
||||
ExposureScale = *inValueFloat;
|
||||
break;
|
||||
default:
|
||||
LOG("Set_Internal Not Implemented : " + s, LEVEL_DEBUG);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetOptimalSettingsCallback(NVSDK_NGX_Parameter* InParams);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetStatsCallback(NVSDK_NGX_Parameter* InParams);
|
||||
|
||||
NVSDK_NGX_Result NvParameter::Get_Internal(const char* InName, unsigned long long* OutValue, NvParameterType ParameterType) const
|
||||
{
|
||||
auto outValueFloat = (float*)OutValue;
|
||||
auto outValueInt = (int*)OutValue;
|
||||
auto outValueDouble = (double*)OutValue;
|
||||
auto outValueUInt = (unsigned int*)OutValue;
|
||||
auto outValueULL = (unsigned long long*)OutValue;
|
||||
//Includes DirectX Resources
|
||||
auto outValuePtr = (void**)OutValue;
|
||||
|
||||
std::string s;
|
||||
s = InName;
|
||||
|
||||
switch (Util::NvParameterToEnum(InName))
|
||||
{
|
||||
case Util::NvParameter::Sharpness:
|
||||
*outValueFloat = Sharpness;
|
||||
break;
|
||||
case Util::NvParameter::SuperSampling_Available:
|
||||
*outValueInt = true;
|
||||
break;
|
||||
case Util::NvParameter::SuperSampling_FeatureInitResult:
|
||||
*outValueInt = NVSDK_NGX_Result_Success;
|
||||
break;
|
||||
case Util::NvParameter::SuperSampling_NeedsUpdatedDriver:
|
||||
*outValueInt = 0;
|
||||
break;
|
||||
case Util::NvParameter::SuperSampling_MinDriverVersionMinor:
|
||||
case Util::NvParameter::SuperSampling_MinDriverVersionMajor:
|
||||
*outValueInt = 0;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Render_Subrect_Dimensions_Width:
|
||||
*outValueInt = Width;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Render_Subrect_Dimensions_Height:
|
||||
*outValueInt = Height;
|
||||
break;
|
||||
case Util::NvParameter::OutWidth:
|
||||
*outValueInt = OutWidth;
|
||||
break;
|
||||
case Util::NvParameter::OutHeight:
|
||||
*outValueInt = OutHeight;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Get_Dynamic_Max_Render_Width:
|
||||
*outValueInt = Width;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Get_Dynamic_Max_Render_Height:
|
||||
*outValueInt = Height;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Get_Dynamic_Min_Render_Width:
|
||||
*outValueInt = OutWidth;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Get_Dynamic_Min_Render_Height:
|
||||
*outValueInt = OutHeight;
|
||||
break;
|
||||
case Util::NvParameter::DLSSOptimalSettingsCallback:
|
||||
*outValuePtr = NVSDK_NGX_DLSS_GetOptimalSettingsCallback;
|
||||
break;
|
||||
case Util::NvParameter::DLSSGetStatsCallback:
|
||||
*outValuePtr = NVSDK_NGX_DLSS_GetStatsCallback;
|
||||
break;
|
||||
case Util::NvParameter::SizeInBytes:
|
||||
*outValueULL = 0x1337; //Dummy value
|
||||
break;
|
||||
case Util::NvParameter::OptLevel:
|
||||
*outValueInt = 0; //Dummy value
|
||||
break;
|
||||
case Util::NvParameter::IsDevSnippetBranch:
|
||||
*outValueInt = 0; //Dummy value
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_Balanced:
|
||||
*outValueInt = BalancedPreset;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_DLAA:
|
||||
*outValueInt = DLAAPreset;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_Performance:
|
||||
*outValueInt = PerfPreset;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_Quality:
|
||||
*outValueInt = QualityPreset;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_UltraQuality:
|
||||
*outValueInt = UltraQualityPreset;
|
||||
break;
|
||||
case Util::NvParameter::DLSS_Hint_Render_Preset_UltraPerformance:
|
||||
*outValueInt = UltraPerfPreset;
|
||||
break;
|
||||
default:
|
||||
LOG("Get_Internal Not Implemented : " + s, LEVEL_DEBUG);
|
||||
return NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
|
||||
LOG("Get_Internal : " + s + " - f:" + std::to_string(*outValueFloat) + " - d:" + std::to_string(*outValueDouble) + " - i:" + std::to_string(*outValueInt) + " - u:" + std::to_string(*outValueUInt) + " - ul:" + std::to_string(*outValueULL), LEVEL_DEBUG);
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
// EvaluateRenderScale helper
|
||||
inline xess_quality_settings_t DLSS2XeSSQualityTable(const NVSDK_NGX_PerfQuality_Value input)
|
||||
{
|
||||
xess_quality_settings_t output;
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:
|
||||
output = XESS_QUALITY_SETTING_PERFORMANCE;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:
|
||||
output = XESS_QUALITY_SETTING_PERFORMANCE;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:
|
||||
output = XESS_QUALITY_SETTING_BALANCED;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:
|
||||
output = XESS_QUALITY_SETTING_QUALITY;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:
|
||||
output = XESS_QUALITY_SETTING_ULTRA_QUALITY;
|
||||
break;
|
||||
default:
|
||||
output = XESS_QUALITY_SETTING_BALANCED; //Set out-of-range value for non-existing fsr ultra quality mode
|
||||
break;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// EvaluateRenderScale helper
|
||||
inline std::optional<float> GetQualityOverrideRatio(const NVSDK_NGX_PerfQuality_Value input)
|
||||
{
|
||||
std::optional<float> output;
|
||||
|
||||
if (!(CyberXessContext::instance()->MyConfig->QualityRatioOverrideEnabled.has_value() && CyberXessContext::instance()->MyConfig->QualityRatioOverrideEnabled))
|
||||
return output; // override not enabled
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:
|
||||
output = CyberXessContext::instance()->MyConfig->QualityRatio_UltraPerformance;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:
|
||||
output = CyberXessContext::instance()->MyConfig->QualityRatio_Performance;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:
|
||||
output = CyberXessContext::instance()->MyConfig->QualityRatio_Balanced;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:
|
||||
output = CyberXessContext::instance()->MyConfig->QualityRatio_Quality;
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:
|
||||
output = CyberXessContext::instance()->MyConfig->QualityRatio_UltraQuality;
|
||||
break;
|
||||
default:
|
||||
LOG("GetQualityOverrideRatio: Unknown quality : " + std::to_string(input), LEVEL_WARNING);
|
||||
output = CyberXessContext::instance()->MyConfig->QualityRatio_Balanced;
|
||||
break;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void NvParameter::EvaluateRenderScale()
|
||||
{
|
||||
LOG("EvaluateRenderScale start :" + std::to_string(Width) + "x" + std::to_string(Height) + " o:" + std::to_string(OutWidth) + "x" + std::to_string(OutHeight), LEVEL_DEBUG);
|
||||
|
||||
const std::optional<float> QualityRatio = GetQualityOverrideRatio(PerfQualityValue);
|
||||
|
||||
if (QualityRatio.has_value()) {
|
||||
OutHeight = (unsigned int)((float)Height / QualityRatio.value());
|
||||
OutWidth = (unsigned int)((float)Width / QualityRatio.value());
|
||||
}
|
||||
else {
|
||||
const xess_quality_settings_t xessQualityMode = DLSS2XeSSQualityTable(PerfQualityValue);
|
||||
|
||||
LOG("EvaluateRenderScale Quality : " + std::to_string(PerfQualityValue), LEVEL_DEBUG);
|
||||
|
||||
switch (PerfQualityValue)
|
||||
{
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:
|
||||
OutHeight = (unsigned int)((float)Height / 3.0);
|
||||
OutWidth = (unsigned int)((float)Width / 3.0);
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:
|
||||
OutHeight = (unsigned int)((float)Height / 2.0);
|
||||
OutWidth = (unsigned int)((float)Width / 2.0);
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:
|
||||
OutHeight = (unsigned int)((float)Height / 1.699115044247788);
|
||||
OutWidth = (unsigned int)((float)Width / 1.699115044247788);
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:
|
||||
OutHeight = (unsigned int)((float)Height / 1.5);
|
||||
OutWidth = (unsigned int)((float)Width / 1.5);
|
||||
break;
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:
|
||||
OutHeight = (unsigned int)((float)Height / 1.299932295192959);
|
||||
OutWidth = (unsigned int)((float)Width / 1.299932295192959);
|
||||
break;
|
||||
default:
|
||||
OutHeight = (unsigned int)((float)Height / 1.699115044247788);
|
||||
OutWidth = (unsigned int)((float)Width / 1.699115044247788);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG("EvaluateRenderScale end :" + std::to_string(Width) + "x" + std::to_string(Height) + " o:" + std::to_string(OutWidth) + "x" + std::to_string(OutHeight), LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetOptimalSettingsCallback(NVSDK_NGX_Parameter* InParams)
|
||||
{
|
||||
auto params = static_cast<NvParameter*>(InParams);
|
||||
params->EvaluateRenderScale();
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetStatsCallback(NVSDK_NGX_Parameter* InParams)
|
||||
{
|
||||
//TODO: Somehow check for allocated memory
|
||||
//Then set values: SizeInBytes, OptLevel, IsDevSnippetBranch
|
||||
return NVSDK_NGX_Result_Success;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
enum NvParameterType {
|
||||
NvInt,
|
||||
NvFloat,
|
||||
NvDouble,
|
||||
NvUInt,
|
||||
NvULL,
|
||||
NvD3D11Resource,
|
||||
NvD3D12Resource,
|
||||
NvVoidPtr
|
||||
};
|
||||
|
||||
struct NvParameter : NVSDK_NGX_Parameter
|
||||
{
|
||||
unsigned int Width{}, Height{}, OutWidth{}, OutHeight{};
|
||||
NVSDK_NGX_PerfQuality_Value PerfQualityValue = NVSDK_NGX_PerfQuality_Value_Balanced;
|
||||
bool RTXValue{}, FreeMemOnReleaseFeature{};
|
||||
int CreationNodeMask{}, VisibilityNodeMask{}, OptLevel{}, IsDevSnippetBranch{};
|
||||
int DLAAPreset{}, UltraQualityPreset{}, QualityPreset{}, BalancedPreset{}, PerfPreset{}, UltraPerfPreset{};
|
||||
float Sharpness = 1.0f;
|
||||
float ExposureScale = 1.0f;
|
||||
int ResetRender = 0;
|
||||
float MVScaleX = 1.0, MVScaleY = 1.0;
|
||||
float JitterOffsetX{}, JitterOffsetY{};
|
||||
|
||||
long long SizeInBytes{};
|
||||
|
||||
bool DepthInverted{}, AutoExposure{}, Hdr{}, EnableSharpening{}, JitterMotion{}, LowRes{};
|
||||
|
||||
//external Resources
|
||||
void* InputBiasCurrentColorMask{};
|
||||
void* Color{};
|
||||
void* Depth{};
|
||||
void* MotionVectors{};
|
||||
void* Output{};
|
||||
void* TransparencyMask{};
|
||||
void* ExposureTexture{};
|
||||
|
||||
virtual void Set(const char* InName, unsigned long long InValue) override;
|
||||
virtual void Set(const char* InName, float InValue) override;
|
||||
virtual void Set(const char* InName, double InValue) override;
|
||||
virtual void Set(const char* InName, unsigned int InValue) override;
|
||||
virtual void Set(const char* InName, int InValue) override;
|
||||
virtual void Set(const char* InName, ID3D11Resource* InValue) override;
|
||||
virtual void Set(const char* InName, ID3D12Resource* InValue) override;
|
||||
virtual void Set(const char* InName, void* InValue) override;
|
||||
virtual NVSDK_NGX_Result Get(const char* InName, unsigned long long* OutValue) const override;
|
||||
virtual NVSDK_NGX_Result Get(const char* InName, float* OutValue) const override;
|
||||
virtual NVSDK_NGX_Result Get(const char* InName, double* OutValue) const override;
|
||||
virtual NVSDK_NGX_Result Get(const char* InName, unsigned int* OutValue) const override;
|
||||
virtual NVSDK_NGX_Result Get(const char* InName, int* OutValue) const override;
|
||||
virtual NVSDK_NGX_Result Get(const char* InName, ID3D11Resource** OutValue) const override;
|
||||
virtual NVSDK_NGX_Result Get(const char* InName, ID3D12Resource** OutValue) const override;
|
||||
virtual NVSDK_NGX_Result Get(const char* InName, void** OutValue) const override;
|
||||
virtual void Reset() override;
|
||||
|
||||
void Set_Internal(const char* InName, unsigned long long InValue, NvParameterType ParameterType);
|
||||
NVSDK_NGX_Result Get_Internal(const char* InName, unsigned long long* OutValue, NvParameterType ParameterType) const;
|
||||
|
||||
void EvaluateRenderScale();
|
||||
|
||||
std::vector<std::shared_ptr<NvParameter>> Params;
|
||||
|
||||
__declspec(noinline) NvParameter* AllocateParameters()
|
||||
{
|
||||
Params.push_back(std::make_shared<NvParameter>());
|
||||
return Params.back().get();
|
||||
}
|
||||
|
||||
__declspec(noinline) void DeleteParameters(NvParameter* param)
|
||||
{
|
||||
auto it = std::find_if(Params.begin(), Params.end(),
|
||||
[param](const auto& p) { return p.get() == param; });
|
||||
Params.erase(it);
|
||||
}
|
||||
|
||||
static std::shared_ptr<NvParameter> instance()
|
||||
{
|
||||
static std::shared_ptr<NvParameter> INSTANCE { std::make_shared<NvParameter>() };
|
||||
return INSTANCE;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,100 @@
|
||||
#include "pch.h"
|
||||
#include "Config.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
extern HMODULE dllModule;
|
||||
|
||||
fs::path Util::DllPath()
|
||||
{
|
||||
static fs::path dll;
|
||||
if (dll.empty())
|
||||
{
|
||||
wchar_t dllPath[MAX_PATH];
|
||||
GetModuleFileNameW(dllModule, dllPath, MAX_PATH);
|
||||
dll = fs::path(dllPath);
|
||||
}
|
||||
return dll;
|
||||
}
|
||||
|
||||
fs::path Util::ExePath()
|
||||
{
|
||||
static fs::path exe;
|
||||
if (exe.empty())
|
||||
{
|
||||
wchar_t exePath[MAX_PATH];
|
||||
GetModuleFileNameW(nullptr, exePath, MAX_PATH);
|
||||
exe = fs::path(exePath);
|
||||
}
|
||||
return exe;
|
||||
}
|
||||
|
||||
Util::NvParameter Util::NvParameterToEnum(const char* name)
|
||||
{
|
||||
static ankerl::unordered_dense::map<std::string, NvParameter> NvParamTranslation = {
|
||||
{"SuperSampling.ScaleFactor", NvParameter::SuperSampling_ScaleFactor},
|
||||
{"SuperSampling.Available", NvParameter::SuperSampling_Available},
|
||||
{"SuperSampling.MinDriverVersionMajor", NvParameter::SuperSampling_MinDriverVersionMajor},
|
||||
{"SuperSampling.MinDriverVersionMinor", NvParameter::SuperSampling_MinDriverVersionMinor},
|
||||
{"SuperSampling.FeatureInitResult", NvParameter::SuperSampling_FeatureInitResult},
|
||||
{"SuperSampling.NeedsUpdatedDriver", NvParameter::SuperSampling_NeedsUpdatedDriver},
|
||||
{"#\x01", NvParameter::SuperSampling_Available},
|
||||
|
||||
{"Width", NvParameter::Width},
|
||||
{"Height", NvParameter::Height},
|
||||
{"PerfQualityValue", NvParameter::PerfQualityValue},
|
||||
{"RTXValue", NvParameter::RTXValue},
|
||||
{"NVSDK_NGX_Parameter_FreeMemOnReleaseFeature", NvParameter::FreeMemOnReleaseFeature},
|
||||
|
||||
{"OutWidth", NvParameter::OutWidth},
|
||||
{"OutHeight", NvParameter::OutHeight},
|
||||
|
||||
{"DLSS.Render.Subrect.Dimensions.Width", NvParameter::DLSS_Render_Subrect_Dimensions_Width},
|
||||
{"DLSS.Render.Subrect.Dimensions.Height", NvParameter::DLSS_Render_Subrect_Dimensions_Height},
|
||||
{"DLSS.Get.Dynamic.Max.Render.Width", NvParameter::DLSS_Get_Dynamic_Max_Render_Width},
|
||||
{"DLSS.Get.Dynamic.Max.Render.Height", NvParameter::DLSS_Get_Dynamic_Max_Render_Height},
|
||||
{"DLSS.Get.Dynamic.Min.Render.Width", NvParameter::DLSS_Get_Dynamic_Min_Render_Width},
|
||||
{"DLSS.Get.Dynamic.Min.Render.Height", NvParameter::DLSS_Get_Dynamic_Min_Render_Height},
|
||||
{"Sharpness", NvParameter::Sharpness},
|
||||
|
||||
{"DLSSOptimalSettingsCallback", NvParameter::DLSSOptimalSettingsCallback},
|
||||
{"DLSSGetStatsCallback", NvParameter::DLSSGetStatsCallback},
|
||||
|
||||
{"CreationNodeMask", NvParameter::CreationNodeMask},
|
||||
{"VisibilityNodeMask", NvParameter::VisibilityNodeMask},
|
||||
{"DLSS.Feature.Create.Flags", NvParameter::DLSS_Feature_Create_Flags},
|
||||
{"DLSS.Enable.Output.Subrects", NvParameter::DLSS_Enable_Output_Subrects},
|
||||
|
||||
{"Color", NvParameter::Color},
|
||||
{"MotionVectors", NvParameter::MotionVectors},
|
||||
{"Depth", NvParameter::Depth},
|
||||
{"Output", NvParameter::Output},
|
||||
{"TransparencyMask", NvParameter::TransparencyMask},
|
||||
{"ExposureTexture", NvParameter::ExposureTexture},
|
||||
{"DLSS.Input.Bias.Current.Color.Mask", NvParameter::DLSS_Input_Bias_Current_Color_Mask},
|
||||
|
||||
{"DLSS.Pre.Exposure", NvParameter::Pre_Exposure},
|
||||
{"DLSS.Exposure.Scale", NvParameter::Exposure_Scale},
|
||||
|
||||
{"Reset", NvParameter::Reset},
|
||||
{"MV.Scale.X", NvParameter::MV_Scale_X},
|
||||
{"MV.Scale.Y", NvParameter::MV_Scale_Y},
|
||||
{"Jitter.Offset.X", NvParameter::Jitter_Offset_X},
|
||||
{"Jitter.Offset.Y", NvParameter::Jitter_Offset_Y},
|
||||
|
||||
{"SizeInBytes", NvParameter::SizeInBytes},
|
||||
{"Snippet.OptLevel", NvParameter::OptLevel},
|
||||
{"#\x44", NvParameter::OptLevel},
|
||||
{"Snippet.IsDevBranch", NvParameter::IsDevSnippetBranch},
|
||||
{"#\x45", NvParameter::IsDevSnippetBranch},
|
||||
{"DLSS.Hint.Render.Preset.DLAA", NvParameter::DLSS_Hint_Render_Preset_DLAA},
|
||||
{"DLSS.Hint.Render.Preset.UltraQuality", NvParameter::DLSS_Hint_Render_Preset_UltraQuality},
|
||||
{"DLSS.Hint.Render.Preset.Quality", NvParameter::DLSS_Hint_Render_Preset_Quality},
|
||||
{"DLSS.Hint.Render.Preset.Balanced", NvParameter::DLSS_Hint_Render_Preset_Balanced},
|
||||
{"DLSS.Hint.Render.Preset.Performance", NvParameter::DLSS_Hint_Render_Preset_Performance},
|
||||
{"DLSS.Hint.Render.Preset.UltraPerformance", NvParameter::DLSS_Hint_Render_Preset_UltraPerformance},
|
||||
};
|
||||
|
||||
return NvParamTranslation[std::string(name)];
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
#include "Config.h"
|
||||
|
||||
namespace Util
|
||||
{
|
||||
std::filesystem::path ExePath();
|
||||
|
||||
std::filesystem::path DllPath();
|
||||
|
||||
enum class NvParameter
|
||||
{
|
||||
Invalid,
|
||||
|
||||
//SuperSampling
|
||||
SuperSampling_ScaleFactor,
|
||||
SuperSampling_Available,
|
||||
SuperSampling_MinDriverVersionMajor,
|
||||
SuperSampling_MinDriverVersionMinor,
|
||||
SuperSampling_FeatureInitResult,
|
||||
SuperSampling_NeedsUpdatedDriver,
|
||||
|
||||
//User settings stuff
|
||||
Width,
|
||||
Height,
|
||||
PerfQualityValue,
|
||||
RTXValue,
|
||||
FreeMemOnReleaseFeature,
|
||||
|
||||
//Resolution stuff
|
||||
OutWidth,
|
||||
OutHeight,
|
||||
|
||||
DLSS_Render_Subrect_Dimensions_Width,
|
||||
DLSS_Render_Subrect_Dimensions_Height,
|
||||
DLSS_Get_Dynamic_Max_Render_Width,
|
||||
DLSS_Get_Dynamic_Max_Render_Height,
|
||||
DLSS_Get_Dynamic_Min_Render_Width,
|
||||
DLSS_Get_Dynamic_Min_Render_Height,
|
||||
Sharpness,
|
||||
|
||||
//Callbacks
|
||||
DLSSGetStatsCallback,
|
||||
DLSSOptimalSettingsCallback,
|
||||
|
||||
//Render stuff
|
||||
CreationNodeMask,
|
||||
VisibilityNodeMask,
|
||||
DLSS_Feature_Create_Flags,
|
||||
DLSS_Enable_Output_Subrects,
|
||||
|
||||
//D3D12 Buffers
|
||||
Color,
|
||||
MotionVectors,
|
||||
Depth,
|
||||
Output,
|
||||
TransparencyMask,
|
||||
ExposureTexture,
|
||||
DLSS_Input_Bias_Current_Color_Mask,
|
||||
Pre_Exposure,
|
||||
Exposure_Scale,
|
||||
|
||||
Reset,
|
||||
MV_Scale_X,
|
||||
MV_Scale_Y,
|
||||
Jitter_Offset_X,
|
||||
Jitter_Offset_Y,
|
||||
|
||||
//Dev Stuff
|
||||
SizeInBytes,
|
||||
OptLevel,
|
||||
IsDevSnippetBranch,
|
||||
|
||||
DLSS_Hint_Render_Preset_DLAA,
|
||||
DLSS_Hint_Render_Preset_UltraQuality,
|
||||
DLSS_Hint_Render_Preset_Quality,
|
||||
DLSS_Hint_Render_Preset_Balanced,
|
||||
DLSS_Hint_Render_Preset_Performance,
|
||||
DLSS_Hint_Render_Preset_UltraPerformance
|
||||
};
|
||||
|
||||
NvParameter NvParameterToEnum(const char* name);
|
||||
};
|
||||
|
||||
inline void ThrowIfFailed(HRESULT hr)
|
||||
{
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// Set a breakpoint on this line to catch DirectX API errors
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,702 @@
|
||||
#include "pch.h"
|
||||
#include "WrappedD3D12Device.h"
|
||||
|
||||
bool RefCountD3D12Object::HandleWrap(const char* ifaceName, REFIID riid, void** ppvObject)
|
||||
{
|
||||
LOG("RefCountD3D12Object.HandleWrap");
|
||||
|
||||
if (ppvObject == NULL || *ppvObject == NULL)
|
||||
{
|
||||
std::string str(ifaceName);
|
||||
LOG("RefCountD3D12Object.HandleWrap called with NULL ppvObject querying " + str);
|
||||
return false;
|
||||
}
|
||||
|
||||
// unknown GUID that we only want to print once to avoid log spam
|
||||
// {79D2046C-22EF-451B-9E74-2245D9C760EA}
|
||||
static const GUID Unknown_uuid = {
|
||||
0x79d2046c, 0x22ef, 0x451b, {0x9e, 0x74, 0x22, 0x45, 0xd9, 0xc7, 0x60, 0xea} };
|
||||
|
||||
// unknown/undocumented internal interface
|
||||
// {7abb6563-02bc-47c4-8ef9-acc4795edbcf}
|
||||
static const GUID ID3D12DeviceInternal2_uuid = {
|
||||
0x7abb6563, 0x02bc, 0x47c4, {0x8e, 0xf9, 0xac, 0xc4, 0x79, 0x5e, 0xdb, 0xcf} };
|
||||
|
||||
if (riid == __uuidof(ID3D12Device))
|
||||
{
|
||||
ID3D12Device* real = (ID3D12Device*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device1))
|
||||
{
|
||||
ID3D12Device1* real = (ID3D12Device1*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device1*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device2))
|
||||
{
|
||||
ID3D12Device2* real = (ID3D12Device2*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device2*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device3))
|
||||
{
|
||||
ID3D12Device3* real = (ID3D12Device3*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device3*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device4))
|
||||
{
|
||||
ID3D12Device4* real = (ID3D12Device4*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device4*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device5))
|
||||
{
|
||||
ID3D12Device5* real = (ID3D12Device5*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device5*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device6))
|
||||
{
|
||||
ID3D12Device6* real = (ID3D12Device6*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device6*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device7))
|
||||
{
|
||||
ID3D12Device7* real = (ID3D12Device7*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device7*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device8))
|
||||
{
|
||||
ID3D12Device8* real = (ID3D12Device8*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device8*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device9))
|
||||
{
|
||||
ID3D12Device9* real = (ID3D12Device9*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device9*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device10))
|
||||
{
|
||||
ID3D12Device10* real = (ID3D12Device10*)(*ppvObject);
|
||||
*ppvObject = (ID3D12Device10*)(new WrappedD3D12Device(real));
|
||||
return true;
|
||||
}
|
||||
else if (riid == Unknown_uuid)
|
||||
{
|
||||
LOG("RefCountDXGIObject.HandleWrap Querying Unknown_uuid, returning false");
|
||||
}
|
||||
else if (riid == ID3D12DeviceInternal2_uuid)
|
||||
{
|
||||
LOG("RefCountDXGIObject.HandleWrap Querying ID3D12DeviceInternal2_uuid, returning false");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string str(ifaceName);
|
||||
LOG("RefCountDXGIObject.HandleWrap Querying " + str + " for unrecognized GUID: " + ToString(riid));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT RefCountD3D12Object::WrapQueryInterface(IUnknown* real, const char* ifaceName, REFIID riid, void** ppvObject)
|
||||
{
|
||||
LOG("RefCountD3D12Object.WrapQueryInterface");
|
||||
|
||||
HRESULT ret = real->QueryInterface(riid, ppvObject);
|
||||
|
||||
if (ret == S_OK && HandleWrap(ifaceName, riid, ppvObject))
|
||||
return ret;
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
WrappedD3D12Device::WrappedD3D12Device(ID3D12Device* device) : RefCountD3D12Object(device), m_device(device)
|
||||
{
|
||||
m_device1 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device1), (void**)&m_device1);
|
||||
m_device2 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device2), (void**)&m_device2);
|
||||
m_device3 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device3), (void**)&m_device3);
|
||||
m_device4 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device4), (void**)&m_device4);
|
||||
m_device5 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device5), (void**)&m_device5);
|
||||
m_device6 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device6), (void**)&m_device6);
|
||||
m_device7 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device7), (void**)&m_device7);
|
||||
m_device8 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device8), (void**)&m_device8);
|
||||
m_device9 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device9), (void**)&m_device9);
|
||||
m_device10 = NULL;
|
||||
device->QueryInterface(__uuidof(ID3D12Device10), (void**)&m_device10);
|
||||
}
|
||||
|
||||
WrappedD3D12Device::~WrappedD3D12Device()
|
||||
{
|
||||
SAFE_RELEASE(m_device);
|
||||
SAFE_RELEASE(m_device1);
|
||||
SAFE_RELEASE(m_device2);
|
||||
SAFE_RELEASE(m_device3);
|
||||
SAFE_RELEASE(m_device4);
|
||||
SAFE_RELEASE(m_device5);
|
||||
SAFE_RELEASE(m_device6);
|
||||
SAFE_RELEASE(m_device7);
|
||||
SAFE_RELEASE(m_device8);
|
||||
SAFE_RELEASE(m_device9);
|
||||
SAFE_RELEASE(m_device10);
|
||||
}
|
||||
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::QueryInterface(REFIID riid, void** ppvObject)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: " + ToString(riid));
|
||||
|
||||
if (ppvObject == nullptr)
|
||||
return E_POINTER;
|
||||
|
||||
if (riid == __uuidof(ID3D12Device))
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
if (riid == __uuidof(ID3D12ProxyDevice))
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12ProxyDevice, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device1))
|
||||
{
|
||||
if (m_device1 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device1 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device1, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device2))
|
||||
{
|
||||
if (m_device2 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device2 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device2, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device3))
|
||||
{
|
||||
if (m_device == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device3 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device3, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device4))
|
||||
{
|
||||
if (m_device4 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device4 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device4, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device5))
|
||||
{
|
||||
if (m_device5 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device5 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device5, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device6))
|
||||
{
|
||||
if (m_device6 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device6 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device6, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device7))
|
||||
{
|
||||
if (m_device7 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device7 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device7, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device8))
|
||||
{
|
||||
if (m_device8 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device8 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device8, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device9))
|
||||
{
|
||||
if (m_device9 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device9 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device9, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Device10))
|
||||
{
|
||||
if (m_device10 == nullptr)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: m_device10 is not available, returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12Device10, returning this");
|
||||
AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12DeviceRemovedExtendedData) ||
|
||||
riid == __uuidof(ID3D12DeviceRemovedExtendedData1) ||
|
||||
riid == __uuidof(ID3D12DeviceRemovedExtendedData2))
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12DeviceRemovedExtendedData");
|
||||
auto ret = m_device->QueryInterface(riid, ppvObject);
|
||||
LOG("D3D12Device.QueryInterface: Looking for ID3D12DeviceRemovedExtendedData result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto hr = m_device->QueryInterface(riid, ppvObject);
|
||||
|
||||
if (hr == S_OK && *ppvObject != nullptr)
|
||||
{
|
||||
auto wrapResult = RefCountD3D12Object::HandleWrap("ID3DDevice", riid, ppvObject);
|
||||
|
||||
if (!wrapResult)
|
||||
{
|
||||
LOG("D3D12Device.QueryInterface: returning E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
LOG("D3D12Device.QueryInterface Unknown interface result: " + int_to_hex(hr));
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE RefCountD3D12Object::SetName(_In_z_ LPCWSTR Name)
|
||||
{
|
||||
return m_pReal->SetName(Name);
|
||||
}
|
||||
|
||||
UINT __stdcall WrappedD3D12Device::GetNodeCount(void)
|
||||
{
|
||||
return m_device->GetNodeCount();
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommandQueue(const D3D12_COMMAND_QUEUE_DESC* pDesc, REFIID riid, void** ppCommandQueue)
|
||||
{
|
||||
return m_device->CreateCommandQueue(pDesc, riid, ppCommandQueue);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE type, REFIID riid, void** ppCommandAllocator)
|
||||
{
|
||||
return m_device->CreateCommandAllocator(type, riid, ppCommandAllocator);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateGraphicsPipelineState(const D3D12_GRAPHICS_PIPELINE_STATE_DESC* pDesc, REFIID riid, void** ppPipelineState)
|
||||
{
|
||||
return m_device->CreateGraphicsPipelineState(pDesc, riid, ppPipelineState);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateComputePipelineState(const D3D12_COMPUTE_PIPELINE_STATE_DESC* pDesc, REFIID riid, void** ppPipelineState)
|
||||
{
|
||||
return m_device->CreateComputePipelineState(pDesc, riid, ppPipelineState);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommandList(UINT nodeMask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator* pCommandAllocator, ID3D12PipelineState* pInitialState, REFIID riid, void** ppCommandList)
|
||||
{
|
||||
return m_device->CreateCommandList(nodeMask, type, pCommandAllocator, pInitialState, riid, ppCommandList);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CheckFeatureSupport(D3D12_FEATURE Feature, void* pFeatureSupportData, UINT FeatureSupportDataSize)
|
||||
{
|
||||
return m_device->CheckFeatureSupport(Feature, pFeatureSupportData, FeatureSupportDataSize);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateDescriptorHeap(const D3D12_DESCRIPTOR_HEAP_DESC* pDescriptorHeapDesc, REFIID riid, void** ppvHeap)
|
||||
{
|
||||
return m_device->CreateDescriptorHeap(pDescriptorHeapDesc, riid, ppvHeap);
|
||||
}
|
||||
|
||||
UINT __stdcall WrappedD3D12Device::GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType)
|
||||
{
|
||||
return m_device->GetDescriptorHandleIncrementSize(DescriptorHeapType);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateRootSignature(UINT nodeMask, const void* pBlobWithRootSignature, SIZE_T blobLengthInBytes, REFIID riid, void** ppvRootSignature)
|
||||
{
|
||||
return m_device->CreateRootSignature(nodeMask, pBlobWithRootSignature, blobLengthInBytes, riid, ppvRootSignature);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CreateConstantBufferView(const D3D12_CONSTANT_BUFFER_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
return m_device->CreateConstantBufferView(pDesc, DestDescriptor);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CreateShaderResourceView(ID3D12Resource* pResource, const D3D12_SHADER_RESOURCE_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
return m_device->CreateShaderResourceView(pResource, pDesc, DestDescriptor);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CreateUnorderedAccessView(ID3D12Resource* pResource, ID3D12Resource* pCounterResource, const D3D12_UNORDERED_ACCESS_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
return m_device->CreateUnorderedAccessView(pResource, pCounterResource, pDesc, DestDescriptor);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CreateRenderTargetView(ID3D12Resource* pResource, const D3D12_RENDER_TARGET_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
return m_device->CreateRenderTargetView(pResource, pDesc, DestDescriptor);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CreateDepthStencilView(ID3D12Resource* pResource, const D3D12_DEPTH_STENCIL_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
return m_device->CreateDepthStencilView(pResource, pDesc, DestDescriptor);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CreateSampler(const D3D12_SAMPLER_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
return m_device->CreateSampler(pDesc, DestDescriptor);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CopyDescriptors(UINT NumDestDescriptorRanges, const D3D12_CPU_DESCRIPTOR_HANDLE* pDestDescriptorRangeStarts, const UINT* pDestDescriptorRangeSizes, UINT NumSrcDescriptorRanges, const D3D12_CPU_DESCRIPTOR_HANDLE* pSrcDescriptorRangeStarts, const UINT* pSrcDescriptorRangeSizes, D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType)
|
||||
{
|
||||
return m_device->CopyDescriptors(NumDestDescriptorRanges, pDestDescriptorRangeStarts, pDestDescriptorRangeSizes, NumSrcDescriptorRanges, pSrcDescriptorRangeStarts, pSrcDescriptorRangeSizes, DescriptorHeapsType);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CopyDescriptorsSimple(UINT NumDescriptors, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType)
|
||||
{
|
||||
return m_device->CopyDescriptorsSimple(NumDescriptors, DestDescriptorRangeStart, SrcDescriptorRangeStart, DescriptorHeapsType);
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_ALLOCATION_INFO __stdcall WrappedD3D12Device::GetResourceAllocationInfo(UINT visibleMask, UINT numResourceDescs, const D3D12_RESOURCE_DESC* pResourceDescs)
|
||||
{
|
||||
return m_device->GetResourceAllocationInfo(visibleMask, numResourceDescs, pResourceDescs);
|
||||
}
|
||||
|
||||
D3D12_HEAP_PROPERTIES __stdcall WrappedD3D12Device::GetCustomHeapProperties(UINT nodeMask, D3D12_HEAP_TYPE heapType)
|
||||
{
|
||||
return m_device->GetCustomHeapProperties(nodeMask, heapType);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommittedResource(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialResourceState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riidResource, void** ppvResource)
|
||||
{
|
||||
return m_device->CreateCommittedResource(pHeapProperties, HeapFlags, pDesc, InitialResourceState, pOptimizedClearValue, riidResource, ppvResource);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateHeap(const D3D12_HEAP_DESC* pDesc, REFIID riid, void** ppvHeap)
|
||||
{
|
||||
return m_device->CreateHeap(pDesc, riid, ppvHeap);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreatePlacedResource(ID3D12Heap* pHeap, UINT64 HeapOffset, const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riid, void** ppvResource)
|
||||
{
|
||||
return m_device->CreatePlacedResource(pHeap, HeapOffset, pDesc, InitialState, pOptimizedClearValue, riid, ppvResource);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateReservedResource(const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riid, void** ppvResource)
|
||||
{
|
||||
return m_device->CreateReservedResource(pDesc, InitialState, pOptimizedClearValue, riid, ppvResource);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateSharedHandle(ID3D12DeviceChild* pObject, const SECURITY_ATTRIBUTES* pAttributes, DWORD Access, LPCWSTR Name, HANDLE* pHandle)
|
||||
{
|
||||
return m_device->CreateSharedHandle(pObject, pAttributes, Access, Name, pHandle);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::OpenSharedHandle(HANDLE NTHandle, REFIID riid, void** ppvObj)
|
||||
{
|
||||
return m_device->OpenSharedHandle(NTHandle, riid, ppvObj);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::OpenSharedHandleByName(LPCWSTR Name, DWORD Access, HANDLE* pNTHandle)
|
||||
{
|
||||
return m_device->OpenSharedHandleByName(Name, Access, pNTHandle);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::MakeResident(UINT NumObjects, ID3D12Pageable* const* ppObjects)
|
||||
{
|
||||
return m_device->MakeResident(NumObjects, ppObjects);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::Evict(UINT NumObjects, ID3D12Pageable* const* ppObjects)
|
||||
{
|
||||
return m_device->Evict(NumObjects, ppObjects);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateFence(UINT64 InitialValue, D3D12_FENCE_FLAGS Flags, REFIID riid, void** ppFence)
|
||||
{
|
||||
return m_device->CreateFence(InitialValue, Flags, riid, ppFence);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::GetDeviceRemovedReason(void)
|
||||
{
|
||||
return m_device->GetDeviceRemovedReason();
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::GetCopyableFootprints(const D3D12_RESOURCE_DESC* pResourceDesc, UINT FirstSubresource, UINT NumSubresources, UINT64 BaseOffset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, UINT* pNumRows, UINT64* pRowSizeInBytes, UINT64* pTotalBytes)
|
||||
{
|
||||
return m_device->GetCopyableFootprints(pResourceDesc, FirstSubresource, NumSubresources, BaseOffset, pLayouts, pNumRows, pRowSizeInBytes, pTotalBytes);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateQueryHeap(const D3D12_QUERY_HEAP_DESC* pDesc, REFIID riid, void** ppvHeap)
|
||||
{
|
||||
return m_device->CreateQueryHeap(pDesc, riid, ppvHeap);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::SetStablePowerState(BOOL Enable)
|
||||
{
|
||||
return m_device->SetStablePowerState(Enable);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommandSignature(const D3D12_COMMAND_SIGNATURE_DESC* pDesc, ID3D12RootSignature* pRootSignature, REFIID riid, void** ppvCommandSignature)
|
||||
{
|
||||
return m_device->CreateCommandSignature(pDesc, pRootSignature, riid, ppvCommandSignature);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::GetResourceTiling(ID3D12Resource* pTiledResource, UINT* pNumTilesForEntireResource, D3D12_PACKED_MIP_INFO* pPackedMipDesc, D3D12_TILE_SHAPE* pStandardTileShapeForNonPackedMips, UINT* pNumSubresourceTilings, UINT FirstSubresourceTilingToGet, D3D12_SUBRESOURCE_TILING* pSubresourceTilingsForNonPackedMips)
|
||||
{
|
||||
return m_device->GetResourceTiling(pTiledResource, pNumTilesForEntireResource, pPackedMipDesc, pStandardTileShapeForNonPackedMips, pNumSubresourceTilings, FirstSubresourceTilingToGet, pSubresourceTilingsForNonPackedMips);
|
||||
}
|
||||
|
||||
LUID __stdcall WrappedD3D12Device::GetAdapterLuid(void)
|
||||
{
|
||||
return LUID{ 0, 56090 };
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreatePipelineLibrary(const void* pLibraryBlob, SIZE_T BlobLength, REFIID riid, void** ppPipelineLibrary)
|
||||
{
|
||||
return m_device1->CreatePipelineLibrary(pLibraryBlob, BlobLength, riid, ppPipelineLibrary);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::SetEventOnMultipleFenceCompletion(ID3D12Fence* const* ppFences, const UINT64* pFenceValues, UINT NumFences, D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, HANDLE hEvent)
|
||||
{
|
||||
return m_device1->SetEventOnMultipleFenceCompletion(ppFences, pFenceValues, NumFences, Flags, hEvent);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::SetResidencyPriority(UINT NumObjects, ID3D12Pageable* const* ppObjects, const D3D12_RESIDENCY_PRIORITY* pPriorities)
|
||||
{
|
||||
return m_device1->SetResidencyPriority(NumObjects, ppObjects, pPriorities);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreatePipelineState(const D3D12_PIPELINE_STATE_STREAM_DESC* pDesc, REFIID riid, void** ppPipelineState)
|
||||
{
|
||||
return m_device2->CreatePipelineState(pDesc, riid, ppPipelineState);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::OpenExistingHeapFromAddress(const void* pAddress, REFIID riid, void** ppvHeap)
|
||||
{
|
||||
return m_device3->OpenExistingHeapFromAddress(pAddress, riid, ppvHeap);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::OpenExistingHeapFromFileMapping(HANDLE hFileMapping, REFIID riid, void** ppvHeap)
|
||||
{
|
||||
return m_device3->OpenExistingHeapFromFileMapping(hFileMapping, riid, ppvHeap);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::EnqueueMakeResident(D3D12_RESIDENCY_FLAGS Flags, UINT NumObjects, ID3D12Pageable* const* ppObjects, ID3D12Fence* pFenceToSignal, UINT64 FenceValueToSignal)
|
||||
{
|
||||
return m_device3->EnqueueMakeResident(Flags, NumObjects, ppObjects, pFenceToSignal, FenceValueToSignal);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommandList1(UINT nodeMask, D3D12_COMMAND_LIST_TYPE type, D3D12_COMMAND_LIST_FLAGS flags, REFIID riid, void** ppCommandList)
|
||||
{
|
||||
return m_device4->CreateCommandList1(nodeMask, type, flags, riid, ppCommandList);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateProtectedResourceSession(const D3D12_PROTECTED_RESOURCE_SESSION_DESC* pDesc, REFIID riid, void** ppSession)
|
||||
{
|
||||
return m_device4->CreateProtectedResourceSession(pDesc, riid, ppSession);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommittedResource1(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialResourceState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, REFIID riidResource, void** ppvResource)
|
||||
{
|
||||
return m_device4->CreateCommittedResource1(pHeapProperties, HeapFlags, pDesc, InitialResourceState, pOptimizedClearValue, pProtectedSession, riidResource, ppvResource);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateHeap1(const D3D12_HEAP_DESC* pDesc, ID3D12ProtectedResourceSession* pProtectedSession, REFIID riid, void** ppvHeap)
|
||||
{
|
||||
return m_device4->CreateHeap1(pDesc, pProtectedSession, riid, ppvHeap);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateReservedResource1(const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, REFIID riid, void** ppvResource)
|
||||
{
|
||||
return m_device4->CreateReservedResource1(pDesc, InitialState, pOptimizedClearValue, pProtectedSession, riid, ppvResource);
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_ALLOCATION_INFO __stdcall WrappedD3D12Device::GetResourceAllocationInfo1(UINT visibleMask, UINT numResourceDescs, const D3D12_RESOURCE_DESC* pResourceDescs, D3D12_RESOURCE_ALLOCATION_INFO1* pResourceAllocationInfo1)
|
||||
{
|
||||
return m_device4->GetResourceAllocationInfo1(visibleMask, numResourceDescs, pResourceDescs, pResourceAllocationInfo1);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateLifetimeTracker(ID3D12LifetimeOwner* pOwner, REFIID riid, void** ppvTracker)
|
||||
{
|
||||
return m_device5->CreateLifetimeTracker(pOwner, riid, ppvTracker);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::RemoveDevice(void)
|
||||
{
|
||||
return m_device5->RemoveDevice();
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::EnumerateMetaCommands(UINT* pNumMetaCommands, D3D12_META_COMMAND_DESC* pDescs)
|
||||
{
|
||||
return m_device5->EnumerateMetaCommands(pNumMetaCommands, pDescs);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::EnumerateMetaCommandParameters(REFGUID CommandId, D3D12_META_COMMAND_PARAMETER_STAGE Stage, UINT* pTotalStructureSizeInBytes, UINT* pParameterCount, D3D12_META_COMMAND_PARAMETER_DESC* pParameterDescs)
|
||||
{
|
||||
return m_device5->EnumerateMetaCommandParameters(CommandId, Stage, pTotalStructureSizeInBytes, pParameterCount, pParameterDescs);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateMetaCommand(REFGUID CommandId, UINT NodeMask, const void* pCreationParametersData, SIZE_T CreationParametersDataSizeInBytes, REFIID riid, void** ppMetaCommand)
|
||||
{
|
||||
return m_device5->CreateMetaCommand(CommandId, NodeMask, pCreationParametersData, CreationParametersDataSizeInBytes, riid, ppMetaCommand);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateStateObject(const D3D12_STATE_OBJECT_DESC* pDesc, REFIID riid, void** ppStateObject)
|
||||
{
|
||||
return m_device5->CreateStateObject(pDesc, riid, ppStateObject);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::GetRaytracingAccelerationStructurePrebuildInfo(const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS* pDesc, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO* pInfo)
|
||||
{
|
||||
return m_device5->GetRaytracingAccelerationStructurePrebuildInfo(pDesc, pInfo);
|
||||
}
|
||||
|
||||
D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS __stdcall WrappedD3D12Device::CheckDriverMatchingIdentifier(D3D12_SERIALIZED_DATA_TYPE SerializedDataType, const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER* pIdentifierToCheck)
|
||||
{
|
||||
return m_device5->CheckDriverMatchingIdentifier(SerializedDataType, pIdentifierToCheck);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::SetBackgroundProcessingMode(D3D12_BACKGROUND_PROCESSING_MODE Mode, D3D12_MEASUREMENTS_ACTION MeasurementsAction, HANDLE hEventToSignalUponCompletion, BOOL* pbFurtherMeasurementsDesired)
|
||||
{
|
||||
return m_device6->SetBackgroundProcessingMode(Mode, MeasurementsAction, hEventToSignalUponCompletion, pbFurtherMeasurementsDesired);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::AddToStateObject(const D3D12_STATE_OBJECT_DESC* pAddition, ID3D12StateObject* pStateObjectToGrowFrom, REFIID riid, void** ppNewStateObject)
|
||||
{
|
||||
return m_device7->AddToStateObject(pAddition, pStateObjectToGrowFrom, riid, ppNewStateObject);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateProtectedResourceSession1(const D3D12_PROTECTED_RESOURCE_SESSION_DESC1* pDesc, REFIID riid, void** ppSession)
|
||||
{
|
||||
return m_device7->CreateProtectedResourceSession1(pDesc, riid, ppSession);
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_ALLOCATION_INFO __stdcall WrappedD3D12Device::GetResourceAllocationInfo2(UINT visibleMask, UINT numResourceDescs, const D3D12_RESOURCE_DESC1* pResourceDescs, D3D12_RESOURCE_ALLOCATION_INFO1* pResourceAllocationInfo1)
|
||||
{
|
||||
return m_device8->GetResourceAllocationInfo2(visibleMask, numResourceDescs, pResourceDescs, pResourceAllocationInfo1);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommittedResource2(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC1* pDesc, D3D12_RESOURCE_STATES InitialResourceState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, REFIID riidResource, void** ppvResource)
|
||||
{
|
||||
return m_device8->CreateCommittedResource2(pHeapProperties, HeapFlags, pDesc, InitialResourceState, pOptimizedClearValue, pProtectedSession, riidResource, ppvResource);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreatePlacedResource1(ID3D12Heap* pHeap, UINT64 HeapOffset, const D3D12_RESOURCE_DESC1* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riid, void** ppvResource)
|
||||
{
|
||||
return m_device8->CreatePlacedResource1(pHeap, HeapOffset, pDesc, InitialState, pOptimizedClearValue, riid, ppvResource);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::CreateSamplerFeedbackUnorderedAccessView(ID3D12Resource* pTargetedResource, ID3D12Resource* pFeedbackResource, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
return m_device8->CreateSamplerFeedbackUnorderedAccessView(pTargetedResource, pFeedbackResource, DestDescriptor);
|
||||
}
|
||||
|
||||
void __stdcall WrappedD3D12Device::GetCopyableFootprints1(const D3D12_RESOURCE_DESC1* pResourceDesc, UINT FirstSubresource, UINT NumSubresources, UINT64 BaseOffset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, UINT* pNumRows, UINT64* pRowSizeInBytes, UINT64* pTotalBytes)
|
||||
{
|
||||
return m_device8->GetCopyableFootprints1(pResourceDesc, FirstSubresource, NumSubresources, BaseOffset, pLayouts, pNumRows, pRowSizeInBytes, pTotalBytes);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateShaderCacheSession(const D3D12_SHADER_CACHE_SESSION_DESC* pDesc, REFIID riid, void** ppvSession)
|
||||
{
|
||||
return m_device9->CreateShaderCacheSession(pDesc, riid, ppvSession);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::ShaderCacheControl(D3D12_SHADER_CACHE_KIND_FLAGS Kinds, D3D12_SHADER_CACHE_CONTROL_FLAGS Control)
|
||||
{
|
||||
return m_device9->ShaderCacheControl(Kinds, Control);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommandQueue1(const D3D12_COMMAND_QUEUE_DESC* pDesc, REFIID CreatorID, REFIID riid, void** ppCommandQueue)
|
||||
{
|
||||
return m_device9->CreateCommandQueue1(pDesc, CreatorID, riid, ppCommandQueue);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateCommittedResource3(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC1* pDesc, D3D12_BARRIER_LAYOUT InitialLayout, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, UINT32 NumCastableFormats, DXGI_FORMAT* pCastableFormats, REFIID riidResource, void** ppvResource)
|
||||
{
|
||||
return m_device10->CreateCommittedResource3(pHeapProperties, HeapFlags, pDesc, InitialLayout, pOptimizedClearValue, pProtectedSession, NumCastableFormats, pCastableFormats, riidResource, ppvResource);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreatePlacedResource2(ID3D12Heap* pHeap, UINT64 HeapOffset, const D3D12_RESOURCE_DESC1* pDesc, D3D12_BARRIER_LAYOUT InitialLayout, const D3D12_CLEAR_VALUE* pOptimizedClearValue, UINT32 NumCastableFormats, DXGI_FORMAT* pCastableFormats, REFIID riid, void** ppvResource)
|
||||
{
|
||||
return m_device10->CreatePlacedResource2(pHeap, HeapOffset, pDesc, InitialLayout, pOptimizedClearValue, NumCastableFormats, pCastableFormats, riid, ppvResource);
|
||||
}
|
||||
|
||||
HRESULT __stdcall WrappedD3D12Device::CreateReservedResource2(const D3D12_RESOURCE_DESC* pDesc, D3D12_BARRIER_LAYOUT InitialLayout, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, UINT32 NumCastableFormats, DXGI_FORMAT* pCastableFormats, REFIID riid, void** ppvResource)
|
||||
{
|
||||
return m_device10->CreateReservedResource2(pDesc, InitialLayout, pOptimizedClearValue, pProtectedSession, NumCastableFormats, pCastableFormats, riid, ppvResource);
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
#pragma once
|
||||
|
||||
#include "WrappedDXGIObjects.h"
|
||||
|
||||
class RefCountD3D12Object : public ID3D12Object
|
||||
{
|
||||
ID3D12Object* m_pReal;
|
||||
unsigned int m_iRefcount;
|
||||
|
||||
public:
|
||||
RefCountD3D12Object(ID3D12Object* real) : m_pReal(real), m_iRefcount(1) {}
|
||||
virtual ~RefCountD3D12Object() {}
|
||||
static bool HandleWrap(const char* ifaceName, REFIID riid, void** ppvObject);
|
||||
static HRESULT WrapQueryInterface(IUnknown* real, const char* ifaceName, REFIID riid, void** ppvObject);
|
||||
|
||||
//////////////////////////////
|
||||
// implement IUnknown
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface( /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ __RPC__deref_out void** ppvObject)
|
||||
{
|
||||
LOG("RefCountD3D12Object.QueryInterface");
|
||||
auto result = QueryInterface("IUnknown", riid, ppvObject);
|
||||
LOG("RefCountD3D12Object.QueryInterface result: " + int_to_hex(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// optional overload that's useful for passing down the name of the current interface to put in
|
||||
// any 'unknown interface' query logs.
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(const char* ifaceName, REFIID riid, void** ppvObject)
|
||||
{
|
||||
if (riid == __uuidof(IUnknown))
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IUnknown*)(ID3D12Object*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ID3D12Object))
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (ID3D12Object*)this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return WrapQueryInterface(m_pReal, ifaceName, riid, ppvObject);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef()
|
||||
{
|
||||
LOG("RefCountD3D12Object.AddRef");
|
||||
InterlockedIncrement(&m_iRefcount);
|
||||
LOG("RefCountD3D12Object.AddRef result: " + int_to_hex(m_iRefcount));
|
||||
return m_iRefcount;
|
||||
}
|
||||
ULONG STDMETHODCALLTYPE Release()
|
||||
{
|
||||
LOG("RefCountD3D12Object.Release");
|
||||
|
||||
unsigned int ret = InterlockedDecrement(&m_iRefcount);
|
||||
|
||||
LOG("RefCountD3D12Object.Release result: " + int_to_hex(m_iRefcount));
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
LOG("RefCountD3D12Object.Release deleting object");
|
||||
delete this;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement ID3D12Object
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetPrivateData( /* [in] */ REFGUID Name, /* [in] */ UINT DataSize, /* [in] */ const void* pData)
|
||||
{
|
||||
LOG("RefCountDXGIObject.SetPrivateData");
|
||||
auto result = m_pReal->SetPrivateData(Name, DataSize, pData);
|
||||
LOG("RefCountDXGIObject.SetPrivateData result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( /* [in] */ REFGUID Name, /* [in] */ const IUnknown* pUnknown)
|
||||
{
|
||||
LOG("RefCountDXGIObject.SetPrivateDataInterface");
|
||||
auto result = m_pReal->SetPrivateDataInterface(Name, pUnknown);
|
||||
LOG("RefCountDXGIObject.SetPrivateDataInterface result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetPrivateData( /* [in] */ REFGUID Name, /* [out][in] */ UINT* pDataSize, /* [out] */ void* pData)
|
||||
{
|
||||
LOG("RefCountDXGIObject.GetPrivateData");
|
||||
auto result = m_pReal->GetPrivateData(Name, pDataSize, pData);
|
||||
LOG("RefCountDXGIObject.GetPrivateData result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetName(_In_z_ LPCWSTR Name);
|
||||
};
|
||||
|
||||
#define IMPLEMENT_ID3D12OBJECT_WITH_REFCOUNTDXGIOBJECT_CUSTOMQUERY \
|
||||
ULONG STDMETHODCALLTYPE AddRef() \
|
||||
{ \
|
||||
return RefCountD3D12Object::AddRef(); \
|
||||
} \
|
||||
ULONG STDMETHODCALLTYPE Release() \
|
||||
{ \
|
||||
return RefCountD3D12Object::Release(); \
|
||||
} \
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData(REFIID Name, UINT DataSize, const void *pData) \
|
||||
{ \
|
||||
return RefCountD3D12Object::SetPrivateData(Name, DataSize, pData); \
|
||||
} \
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFIID Name, const IUnknown *pUnknown) \
|
||||
{ \
|
||||
return RefCountD3D12Object::SetPrivateDataInterface(Name, pUnknown); \
|
||||
} \
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData(REFIID Name, UINT *pDataSize, void *pData) \
|
||||
{ \
|
||||
return RefCountD3D12Object::GetPrivateData(Name, pDataSize, pData); \
|
||||
} \
|
||||
HRESULT STDMETHODCALLTYPE SetName(_In_z_ LPCWSTR Name) \
|
||||
{ \
|
||||
return RefCountD3D12Object::SetName(Name); \
|
||||
}
|
||||
|
||||
MIDL_INTERFACE("fa4994ad-dbe4-44b9-8c5c-bb5cf7188b6e")
|
||||
ID3D12ProxyDevice : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE GetProxyAdapter(IDXGIProxyAdapter** adapter);
|
||||
virtual HRESULT STDMETHODCALLTYPE SetProxyAdapter(IDXGIProxyAdapter* adapter);
|
||||
};
|
||||
|
||||
class WrappedD3D12Device : public ID3D12Device10, public RefCountD3D12Object, public ID3D12ProxyDevice
|
||||
{
|
||||
ID3D12Device1* m_device1;
|
||||
ID3D12Device2* m_device2;
|
||||
ID3D12Device3* m_device3;
|
||||
ID3D12Device4* m_device4;
|
||||
ID3D12Device5* m_device5;
|
||||
ID3D12Device6* m_device6;
|
||||
ID3D12Device7* m_device7;
|
||||
ID3D12Device8* m_device8;
|
||||
ID3D12Device9* m_device9;
|
||||
ID3D12Device10* m_device10;
|
||||
IDXGIProxyAdapter* m_adapter;
|
||||
|
||||
public:
|
||||
ID3D12Device* m_device;
|
||||
WrappedD3D12Device(ID3D12Device* device);
|
||||
|
||||
virtual ~WrappedD3D12Device();
|
||||
|
||||
IMPLEMENT_ID3D12OBJECT_WITH_REFCOUNTDXGIOBJECT_CUSTOMQUERY;
|
||||
|
||||
// Inherited via ID3D12Device10
|
||||
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override;
|
||||
UINT __stdcall GetNodeCount(void) override;
|
||||
HRESULT __stdcall CreateCommandQueue(const D3D12_COMMAND_QUEUE_DESC* pDesc, REFIID riid, void** ppCommandQueue) override;
|
||||
HRESULT __stdcall CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE type, REFIID riid, void** ppCommandAllocator) override;
|
||||
HRESULT __stdcall CreateGraphicsPipelineState(const D3D12_GRAPHICS_PIPELINE_STATE_DESC* pDesc, REFIID riid, void** ppPipelineState) override;
|
||||
HRESULT __stdcall CreateComputePipelineState(const D3D12_COMPUTE_PIPELINE_STATE_DESC* pDesc, REFIID riid, void** ppPipelineState) override;
|
||||
HRESULT __stdcall CreateCommandList(UINT nodeMask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator* pCommandAllocator, ID3D12PipelineState* pInitialState, REFIID riid, void** ppCommandList) override;
|
||||
HRESULT __stdcall CheckFeatureSupport(D3D12_FEATURE Feature, void* pFeatureSupportData, UINT FeatureSupportDataSize) override;
|
||||
HRESULT __stdcall CreateDescriptorHeap(const D3D12_DESCRIPTOR_HEAP_DESC* pDescriptorHeapDesc, REFIID riid, void** ppvHeap) override;
|
||||
UINT __stdcall GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType) override;
|
||||
HRESULT __stdcall CreateRootSignature(UINT nodeMask, const void* pBlobWithRootSignature, SIZE_T blobLengthInBytes, REFIID riid, void** ppvRootSignature) override;
|
||||
void __stdcall CreateConstantBufferView(const D3D12_CONSTANT_BUFFER_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) override;
|
||||
void __stdcall CreateShaderResourceView(ID3D12Resource* pResource, const D3D12_SHADER_RESOURCE_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) override;
|
||||
void __stdcall CreateUnorderedAccessView(ID3D12Resource* pResource, ID3D12Resource* pCounterResource, const D3D12_UNORDERED_ACCESS_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) override;
|
||||
void __stdcall CreateRenderTargetView(ID3D12Resource* pResource, const D3D12_RENDER_TARGET_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) override;
|
||||
void __stdcall CreateDepthStencilView(ID3D12Resource* pResource, const D3D12_DEPTH_STENCIL_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) override;
|
||||
void __stdcall CreateSampler(const D3D12_SAMPLER_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) override;
|
||||
void __stdcall CopyDescriptors(UINT NumDestDescriptorRanges, const D3D12_CPU_DESCRIPTOR_HANDLE* pDestDescriptorRangeStarts, const UINT* pDestDescriptorRangeSizes, UINT NumSrcDescriptorRanges, const D3D12_CPU_DESCRIPTOR_HANDLE* pSrcDescriptorRangeStarts, const UINT* pSrcDescriptorRangeSizes, D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType) override;
|
||||
void __stdcall CopyDescriptorsSimple(UINT NumDescriptors, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType) override;
|
||||
D3D12_RESOURCE_ALLOCATION_INFO __stdcall GetResourceAllocationInfo(UINT visibleMask, UINT numResourceDescs, const D3D12_RESOURCE_DESC* pResourceDescs) override;
|
||||
D3D12_HEAP_PROPERTIES __stdcall GetCustomHeapProperties(UINT nodeMask, D3D12_HEAP_TYPE heapType) override;
|
||||
HRESULT __stdcall CreateCommittedResource(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialResourceState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riidResource, void** ppvResource) override;
|
||||
HRESULT __stdcall CreateHeap(const D3D12_HEAP_DESC* pDesc, REFIID riid, void** ppvHeap) override;
|
||||
HRESULT __stdcall CreatePlacedResource(ID3D12Heap* pHeap, UINT64 HeapOffset, const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riid, void** ppvResource) override;
|
||||
HRESULT __stdcall CreateReservedResource(const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riid, void** ppvResource) override;
|
||||
HRESULT __stdcall CreateSharedHandle(ID3D12DeviceChild* pObject, const SECURITY_ATTRIBUTES* pAttributes, DWORD Access, LPCWSTR Name, HANDLE* pHandle) override;
|
||||
HRESULT __stdcall OpenSharedHandle(HANDLE NTHandle, REFIID riid, void** ppvObj) override;
|
||||
HRESULT __stdcall OpenSharedHandleByName(LPCWSTR Name, DWORD Access, HANDLE* pNTHandle) override;
|
||||
HRESULT __stdcall MakeResident(UINT NumObjects, ID3D12Pageable* const* ppObjects) override;
|
||||
HRESULT __stdcall Evict(UINT NumObjects, ID3D12Pageable* const* ppObjects) override;
|
||||
HRESULT __stdcall CreateFence(UINT64 InitialValue, D3D12_FENCE_FLAGS Flags, REFIID riid, void** ppFence) override;
|
||||
HRESULT __stdcall GetDeviceRemovedReason(void) override;
|
||||
void __stdcall GetCopyableFootprints(const D3D12_RESOURCE_DESC* pResourceDesc, UINT FirstSubresource, UINT NumSubresources, UINT64 BaseOffset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, UINT* pNumRows, UINT64* pRowSizeInBytes, UINT64* pTotalBytes) override;
|
||||
HRESULT __stdcall CreateQueryHeap(const D3D12_QUERY_HEAP_DESC* pDesc, REFIID riid, void** ppvHeap) override;
|
||||
HRESULT __stdcall SetStablePowerState(BOOL Enable) override;
|
||||
HRESULT __stdcall CreateCommandSignature(const D3D12_COMMAND_SIGNATURE_DESC* pDesc, ID3D12RootSignature* pRootSignature, REFIID riid, void** ppvCommandSignature) override;
|
||||
void __stdcall GetResourceTiling(ID3D12Resource* pTiledResource, UINT* pNumTilesForEntireResource, D3D12_PACKED_MIP_INFO* pPackedMipDesc, D3D12_TILE_SHAPE* pStandardTileShapeForNonPackedMips, UINT* pNumSubresourceTilings, UINT FirstSubresourceTilingToGet, D3D12_SUBRESOURCE_TILING* pSubresourceTilingsForNonPackedMips) override;
|
||||
LUID __stdcall GetAdapterLuid(void) override;
|
||||
HRESULT __stdcall CreatePipelineLibrary(const void* pLibraryBlob, SIZE_T BlobLength, REFIID riid, void** ppPipelineLibrary) override;
|
||||
HRESULT __stdcall SetEventOnMultipleFenceCompletion(ID3D12Fence* const* ppFences, const UINT64* pFenceValues, UINT NumFences, D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, HANDLE hEvent) override;
|
||||
HRESULT __stdcall SetResidencyPriority(UINT NumObjects, ID3D12Pageable* const* ppObjects, const D3D12_RESIDENCY_PRIORITY* pPriorities) override;
|
||||
HRESULT __stdcall CreatePipelineState(const D3D12_PIPELINE_STATE_STREAM_DESC* pDesc, REFIID riid, void** ppPipelineState) override;
|
||||
HRESULT __stdcall OpenExistingHeapFromAddress(const void* pAddress, REFIID riid, void** ppvHeap) override;
|
||||
HRESULT __stdcall OpenExistingHeapFromFileMapping(HANDLE hFileMapping, REFIID riid, void** ppvHeap) override;
|
||||
HRESULT __stdcall EnqueueMakeResident(D3D12_RESIDENCY_FLAGS Flags, UINT NumObjects, ID3D12Pageable* const* ppObjects, ID3D12Fence* pFenceToSignal, UINT64 FenceValueToSignal) override;
|
||||
HRESULT __stdcall CreateCommandList1(UINT nodeMask, D3D12_COMMAND_LIST_TYPE type, D3D12_COMMAND_LIST_FLAGS flags, REFIID riid, void** ppCommandList) override;
|
||||
HRESULT __stdcall CreateProtectedResourceSession(const D3D12_PROTECTED_RESOURCE_SESSION_DESC* pDesc, REFIID riid, void** ppSession) override;
|
||||
HRESULT __stdcall CreateCommittedResource1(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialResourceState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, REFIID riidResource, void** ppvResource) override;
|
||||
HRESULT __stdcall CreateHeap1(const D3D12_HEAP_DESC* pDesc, ID3D12ProtectedResourceSession* pProtectedSession, REFIID riid, void** ppvHeap) override;
|
||||
HRESULT __stdcall CreateReservedResource1(const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, REFIID riid, void** ppvResource) override;
|
||||
D3D12_RESOURCE_ALLOCATION_INFO __stdcall GetResourceAllocationInfo1(UINT visibleMask, UINT numResourceDescs, const D3D12_RESOURCE_DESC* pResourceDescs, D3D12_RESOURCE_ALLOCATION_INFO1* pResourceAllocationInfo1) override;
|
||||
HRESULT __stdcall CreateLifetimeTracker(ID3D12LifetimeOwner* pOwner, REFIID riid, void** ppvTracker) override;
|
||||
void __stdcall RemoveDevice(void) override;
|
||||
HRESULT __stdcall EnumerateMetaCommands(UINT* pNumMetaCommands, D3D12_META_COMMAND_DESC* pDescs) override;
|
||||
HRESULT __stdcall EnumerateMetaCommandParameters(REFGUID CommandId, D3D12_META_COMMAND_PARAMETER_STAGE Stage, UINT* pTotalStructureSizeInBytes, UINT* pParameterCount, D3D12_META_COMMAND_PARAMETER_DESC* pParameterDescs) override;
|
||||
HRESULT __stdcall CreateMetaCommand(REFGUID CommandId, UINT NodeMask, const void* pCreationParametersData, SIZE_T CreationParametersDataSizeInBytes, REFIID riid, void** ppMetaCommand) override;
|
||||
HRESULT __stdcall CreateStateObject(const D3D12_STATE_OBJECT_DESC* pDesc, REFIID riid, void** ppStateObject) override;
|
||||
void __stdcall GetRaytracingAccelerationStructurePrebuildInfo(const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS* pDesc, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO* pInfo) override;
|
||||
D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS __stdcall CheckDriverMatchingIdentifier(D3D12_SERIALIZED_DATA_TYPE SerializedDataType, const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER* pIdentifierToCheck) override;
|
||||
HRESULT __stdcall SetBackgroundProcessingMode(D3D12_BACKGROUND_PROCESSING_MODE Mode, D3D12_MEASUREMENTS_ACTION MeasurementsAction, HANDLE hEventToSignalUponCompletion, BOOL* pbFurtherMeasurementsDesired) override;
|
||||
HRESULT __stdcall AddToStateObject(const D3D12_STATE_OBJECT_DESC* pAddition, ID3D12StateObject* pStateObjectToGrowFrom, REFIID riid, void** ppNewStateObject) override;
|
||||
HRESULT __stdcall CreateProtectedResourceSession1(const D3D12_PROTECTED_RESOURCE_SESSION_DESC1* pDesc, REFIID riid, void** ppSession) override;
|
||||
D3D12_RESOURCE_ALLOCATION_INFO __stdcall GetResourceAllocationInfo2(UINT visibleMask, UINT numResourceDescs, const D3D12_RESOURCE_DESC1* pResourceDescs, D3D12_RESOURCE_ALLOCATION_INFO1* pResourceAllocationInfo1) override;
|
||||
HRESULT __stdcall CreateCommittedResource2(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC1* pDesc, D3D12_RESOURCE_STATES InitialResourceState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, REFIID riidResource, void** ppvResource) override;
|
||||
HRESULT __stdcall CreatePlacedResource1(ID3D12Heap* pHeap, UINT64 HeapOffset, const D3D12_RESOURCE_DESC1* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riid, void** ppvResource) override;
|
||||
void __stdcall CreateSamplerFeedbackUnorderedAccessView(ID3D12Resource* pTargetedResource, ID3D12Resource* pFeedbackResource, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) override;
|
||||
void __stdcall GetCopyableFootprints1(const D3D12_RESOURCE_DESC1* pResourceDesc, UINT FirstSubresource, UINT NumSubresources, UINT64 BaseOffset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, UINT* pNumRows, UINT64* pRowSizeInBytes, UINT64* pTotalBytes) override;
|
||||
HRESULT __stdcall CreateShaderCacheSession(const D3D12_SHADER_CACHE_SESSION_DESC* pDesc, REFIID riid, void** ppvSession) override;
|
||||
HRESULT __stdcall ShaderCacheControl(D3D12_SHADER_CACHE_KIND_FLAGS Kinds, D3D12_SHADER_CACHE_CONTROL_FLAGS Control) override;
|
||||
HRESULT __stdcall CreateCommandQueue1(const D3D12_COMMAND_QUEUE_DESC* pDesc, REFIID CreatorID, REFIID riid, void** ppCommandQueue) override;
|
||||
HRESULT __stdcall CreateCommittedResource3(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC1* pDesc, D3D12_BARRIER_LAYOUT InitialLayout, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, UINT32 NumCastableFormats, DXGI_FORMAT* pCastableFormats, REFIID riidResource, void** ppvResource) override;
|
||||
HRESULT __stdcall CreatePlacedResource2(ID3D12Heap* pHeap, UINT64 HeapOffset, const D3D12_RESOURCE_DESC1* pDesc, D3D12_BARRIER_LAYOUT InitialLayout, const D3D12_CLEAR_VALUE* pOptimizedClearValue, UINT32 NumCastableFormats, DXGI_FORMAT* pCastableFormats, REFIID riid, void** ppvResource) override;
|
||||
HRESULT __stdcall CreateReservedResource2(const D3D12_RESOURCE_DESC* pDesc, D3D12_BARRIER_LAYOUT InitialLayout, const D3D12_CLEAR_VALUE* pOptimizedClearValue, ID3D12ProtectedResourceSession* pProtectedSession, UINT32 NumCastableFormats, DXGI_FORMAT* pCastableFormats, REFIID riid, void** ppvResource) override;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetProxyAdapter(IDXGIProxyAdapter** adapter)
|
||||
{
|
||||
*adapter = m_adapter;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetProxyAdapter(IDXGIProxyAdapter* adapter)
|
||||
{
|
||||
m_adapter = adapter;
|
||||
return S_OK;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,542 @@
|
||||
#include "pch.h"
|
||||
#include "dxgi1_6.h"
|
||||
#include "WrappedDXGIObjects.h"
|
||||
|
||||
bool RefCountDXGIObject::HandleWrap(const char* ifaceName, REFIID riid, void** ppvObject)
|
||||
{
|
||||
LOG("RefCountDXGIObject.HandleWrap");
|
||||
|
||||
if (ppvObject == NULL || *ppvObject == NULL)
|
||||
{
|
||||
std::string str(ifaceName);
|
||||
LOG("RefCountDXGIObject.HandleWrap called with NULL ppvObject querying " + str);
|
||||
return false;
|
||||
}
|
||||
|
||||
// unknown GUID that we only want to print once to avoid log spam
|
||||
// {79D2046C-22EF-451B-9E74-2245D9C760EA}
|
||||
static const GUID Unknown_uuid = { 0x79d2046c, 0x22ef, 0x451b, {0x9e, 0x74, 0x22, 0x45, 0xd9, 0xc7, 0x60, 0xea} };
|
||||
|
||||
// ditto
|
||||
// {9B7E4C04-342C-4106-A19F-4F2704F689F0}
|
||||
static const GUID ID3D10Texture2D_uuid = { 0x9b7e4c04, 0x342c, 0x4106, {0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} };
|
||||
|
||||
#ifdef BLOCK_IDXGIAdapterInternal2
|
||||
// unknown/undocumented internal interface
|
||||
// {7abb6563-02bc-47c4-8ef9-acc4795edbcf}
|
||||
static const GUID IDXGIAdapterInternal2_uuid = { 0x7abb6563, 0x02bc, 0x47c4, {0x8e, 0xf9, 0xac, 0xc4, 0x79, 0x5e, 0xdb, 0xcf} };
|
||||
#endif
|
||||
|
||||
|
||||
if (riid == __uuidof(IDXGIDevice) ||
|
||||
riid == __uuidof(IDXGIDevice1))
|
||||
{
|
||||
// should have been handled elsewhere, so we can properly create this device
|
||||
std::string str(ifaceName);
|
||||
LOG("Unexpected uuid in RefCountDXGIObject::HandleWrap querying : " + str);
|
||||
return false;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter))
|
||||
{
|
||||
if (b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter* real = (IDXGIAdapter*)(*ppvObject);
|
||||
*ppvObject = (IDXGIAdapter*)(new WrappedIDXGIAdapter4(real));
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter1))
|
||||
{
|
||||
if (b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter1* real = (IDXGIAdapter1*)(*ppvObject);
|
||||
*ppvObject = (IDXGIAdapter1*)(new WrappedIDXGIAdapter4(real));
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter2))
|
||||
{
|
||||
if (b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter2* real = (IDXGIAdapter2*)(*ppvObject);
|
||||
*ppvObject = (IDXGIAdapter2*)(new WrappedIDXGIAdapter4(real));
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter3))
|
||||
{
|
||||
if (b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter3* real = (IDXGIAdapter3*)(*ppvObject);
|
||||
*ppvObject = (IDXGIAdapter3*)(new WrappedIDXGIAdapter4(real));
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter4))
|
||||
{
|
||||
if (b_spoofEnabled)
|
||||
{
|
||||
IDXGIAdapter4* real = (IDXGIAdapter4*)(*ppvObject);
|
||||
*ppvObject = (IDXGIAdapter4*)(new WrappedIDXGIAdapter4(real));
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory))
|
||||
{
|
||||
// yes I know PRECISELY how fucked up this is. Speak to microsoft - after KB2670838 the internal
|
||||
// D3D11 device creation function will pass in __uuidof(IDXGIFactory) then attempt to call
|
||||
// EnumDevices1 (which is in the IDXGIFactory1 vtable). Doing this *should* be safe as using a
|
||||
// IDXGIFactory1 like a IDXGIFactory should all just work by definition, but there's no way to
|
||||
// know now if someone trying to create a IDXGIFactory really means it or not.
|
||||
IDXGIFactory* real = (IDXGIFactory*)(*ppvObject);
|
||||
*ppvObject = (IDXGIFactory*)(new WrappedIDXGIFactory(real));
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory1))
|
||||
{
|
||||
IDXGIFactory1* real = (IDXGIFactory1*)(*ppvObject);
|
||||
*ppvObject = (IDXGIFactory1*)(new WrappedIDXGIFactory(real));
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory2))
|
||||
{
|
||||
IDXGIFactory2* real = (IDXGIFactory2*)(*ppvObject);
|
||||
*ppvObject = (IDXGIFactory2*)(new WrappedIDXGIFactory(real));
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory3))
|
||||
{
|
||||
IDXGIFactory3* real = (IDXGIFactory3*)(*ppvObject);
|
||||
*ppvObject = (IDXGIFactory3*)(new WrappedIDXGIFactory(real));
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory4))
|
||||
{
|
||||
IDXGIFactory4* real = (IDXGIFactory4*)(*ppvObject);
|
||||
*ppvObject = (IDXGIFactory4*)(new WrappedIDXGIFactory(real));
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory5))
|
||||
{
|
||||
IDXGIFactory5* real = (IDXGIFactory5*)(*ppvObject);
|
||||
*ppvObject = (IDXGIFactory5*)(new WrappedIDXGIFactory(real));
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory6))
|
||||
{
|
||||
IDXGIFactory6* real = (IDXGIFactory6*)(*ppvObject);
|
||||
*ppvObject = (IDXGIFactory6*)(new WrappedIDXGIFactory(real));
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory7))
|
||||
{
|
||||
IDXGIFactory7* real = (IDXGIFactory7*)(*ppvObject);
|
||||
*ppvObject = (IDXGIFactory7*)(new WrappedIDXGIFactory(real));
|
||||
}
|
||||
else if (riid == ID3D10Texture2D_uuid)
|
||||
{
|
||||
static bool printed = false;
|
||||
|
||||
if (!printed)
|
||||
{
|
||||
printed = true;
|
||||
std::string str(ifaceName);
|
||||
LOG("RefCountDXGIObject.HandleWrap Querying " + str + " for unsupported ID3D10Texture2D_uuid interface: " + ToString(riid));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (riid == Unknown_uuid)
|
||||
{
|
||||
static bool printed = false;
|
||||
if (!printed)
|
||||
{
|
||||
printed = true;
|
||||
std::string str(ifaceName);
|
||||
LOG("RefCountDXGIObject.HandleWrap Querying " + str + " for unknown GUID: " + ToString(riid));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef BLOCK_IDXGIAdapterInternal2
|
||||
else if (riid == IDXGIAdapterInternal2_uuid)
|
||||
{
|
||||
static bool printed = false;
|
||||
if (!printed)
|
||||
{
|
||||
printed = true;
|
||||
std::string str(ifaceName);
|
||||
LOG("RefCountDXGIObject.HandleWrap Querying " + str + " for unsupported/undocumented interface: IDXGIAdapterInternal2");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
std::string str(ifaceName);
|
||||
LOG("RefCountDXGIObject.HandleWrap Querying " + str + " for unrecognized GUID: " + ToString(riid));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE RefCountDXGIObject::GetParent(
|
||||
/* [in] */ REFIID riid,
|
||||
/* [retval][out] */ void** ppParent)
|
||||
{
|
||||
LOG("RefCountDXGIObject.GetParent");
|
||||
|
||||
HRESULT ret = m_pReal->GetParent(riid, ppParent);
|
||||
|
||||
if (ret == S_OK)
|
||||
HandleWrap("GetParent", riid, ppParent);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT RefCountDXGIObject::WrapQueryInterface(IUnknown* real, const char* ifaceName, REFIID riid, void** ppvObject)
|
||||
{
|
||||
LOG("RefCountDXGIObject.WrapQueryInterface riid: " + ToString(riid));
|
||||
|
||||
#ifdef BLOCK_IDXGIAdapterInternal2
|
||||
// unknown/undocumented internal interface
|
||||
// {7abb6563-02bc-47c4-8ef9-acc4795edbcf}
|
||||
static const GUID IDXGIAdapterInternal2_uuid = { 0x7abb6563, 0x02bc, 0x47c4, {0x8e, 0xf9, 0xac, 0xc4, 0x79, 0x5e, 0xdb, 0xcf} };
|
||||
|
||||
if (riid == IDXGIAdapterInternal2_uuid)
|
||||
{
|
||||
LOG("RefCountDXGIObject.WrapQueryInterface IDXGIAdapterInternal2 result: " + int_to_hex(E_NOINTERFACE));
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT ret = real->QueryInterface(riid, ppvObject);
|
||||
LOG("RefCountDXGIObject.WrapQueryInterface real->QueryInterface result: " + int_to_hex(ret));
|
||||
|
||||
if (ret == S_OK && HandleWrap(ifaceName, riid, ppvObject))
|
||||
{
|
||||
LOG("RefCountDXGIObject.WrapQueryInterface HandleWrap result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
LOG("RefCountDXGIObject.WrapQueryInterface result: E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
WrappedIDXGIAdapter4::WrappedIDXGIAdapter4(IDXGIAdapter* real)
|
||||
: RefCountDXGIObject(real), m_pReal(real)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.ctor");
|
||||
|
||||
m_pReal1 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIAdapter1), (void**)&m_pReal1);
|
||||
m_pReal2 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIAdapter2), (void**)&m_pReal2);
|
||||
m_pReal3 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIAdapter3), (void**)&m_pReal3);
|
||||
m_pReal4 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIAdapter4), (void**)&m_pReal4);
|
||||
|
||||
b_spoofEnabled = true;
|
||||
}
|
||||
|
||||
WrappedIDXGIAdapter4::~WrappedIDXGIAdapter4()
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.dtor");
|
||||
|
||||
SAFE_RELEASE(m_pReal1);
|
||||
SAFE_RELEASE(m_pReal2);
|
||||
SAFE_RELEASE(m_pReal3);
|
||||
SAFE_RELEASE(m_pReal4);
|
||||
SAFE_RELEASE(m_pReal);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE WrappedIDXGIAdapter4::QueryInterface(REFIID riid, void** ppvObject)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface riid: " + ToString(riid));
|
||||
|
||||
#ifndef BLOCK_IDXGIAdapterInternal2
|
||||
// unknown/undocumented internal interface
|
||||
// {7abb6563-02bc-47c4-8ef9-acc4795edbcf}
|
||||
static const GUID IDXGIAdapterInternal2_uuid = { 0x7abb6563, 0x02bc, 0x47c4, {0x8e, 0xf9, 0xac, 0xc4, 0x79, 0x5e, 0xdb, 0xcf} };
|
||||
#endif
|
||||
|
||||
|
||||
if (riid == __uuidof(IDXGIAdapter))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter");
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIAdapter*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIProxyAdapter))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIProxyAdapter");
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIProxyAdapter*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter1))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter1");
|
||||
|
||||
if (m_pReal1)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIAdapter1*)this;
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter1 result: OK");
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter1 result: E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter2))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter2");
|
||||
|
||||
if (m_pReal2)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIAdapter2*)this;
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter2 result: OK");
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter2 result: E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter3))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter3");
|
||||
|
||||
if (m_pReal3)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIAdapter3*)this;
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter3 result: OK");
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter3 result: E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter4))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter4");
|
||||
|
||||
if (m_pReal4)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIAdapter4*)this;
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter4 result: OK");
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapter4 result: E_NOINTERFACE");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
#ifndef BLOCK_IDXGIAdapterInternal2
|
||||
else if (riid == IDXGIAdapterInternal2_uuid && m_pReal != nullptr)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryInterface for IDXGIAdapterInternal2, returning real adapter");
|
||||
return m_pReal->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
#endif
|
||||
|
||||
return RefCountDXGIObject::QueryInterface("IDXGIAdapter", riid, ppvObject);
|
||||
}
|
||||
|
||||
WrappedIDXGIFactory::WrappedIDXGIFactory(IDXGIFactory* real)
|
||||
: RefCountDXGIObject(real), m_pReal(real)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.ctor");
|
||||
|
||||
m_pReal1 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIFactory1), (void**)&m_pReal1);
|
||||
m_pReal2 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIFactory2), (void**)&m_pReal2);
|
||||
m_pReal3 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIFactory3), (void**)&m_pReal3);
|
||||
m_pReal4 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIFactory4), (void**)&m_pReal4);
|
||||
m_pReal5 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIFactory5), (void**)&m_pReal5);
|
||||
m_pReal6 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIFactory6), (void**)&m_pReal6);
|
||||
m_pReal7 = NULL;
|
||||
real->QueryInterface(__uuidof(IDXGIFactory7), (void**)&m_pReal7);
|
||||
}
|
||||
|
||||
WrappedIDXGIFactory::~WrappedIDXGIFactory()
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.dtor");
|
||||
|
||||
SAFE_RELEASE(m_pReal1);
|
||||
SAFE_RELEASE(m_pReal2);
|
||||
SAFE_RELEASE(m_pReal3);
|
||||
SAFE_RELEASE(m_pReal4);
|
||||
SAFE_RELEASE(m_pReal5);
|
||||
SAFE_RELEASE(m_pReal6);
|
||||
SAFE_RELEASE(m_pReal7);
|
||||
SAFE_RELEASE(m_pReal);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE WrappedIDXGIFactory::QueryInterface(REFIID riid, void** ppvObject)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.QueryInterface");
|
||||
|
||||
// {713f394e-92ca-47e7-ab81-1159c2791e54}
|
||||
static const GUID IDXGIFactoryDWM_uuid = {
|
||||
0x713f394e, 0x92ca, 0x47e7, {0xab, 0x81, 0x11, 0x59, 0xc2, 0x79, 0x1e, 0x54} };
|
||||
|
||||
// {1ddd77aa-9a4a-4cc8-9e55-98c196bafc8f}
|
||||
static const GUID IDXGIFactoryDWM8_uuid = {
|
||||
0x1ddd77aa, 0x9a4a, 0x4cc8, {0x9e, 0x55, 0x98, 0xc1, 0x96, 0xba, 0xfc, 0x8f} };
|
||||
|
||||
if (riid == __uuidof(IDXGIFactory))
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIFactory*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory1))
|
||||
{
|
||||
if (m_pReal1)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIFactory1*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory2))
|
||||
{
|
||||
if (m_pReal2)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIFactory2*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory3))
|
||||
{
|
||||
if (m_pReal3)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIFactory3*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory4))
|
||||
{
|
||||
if (m_pReal4)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIFactory4*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory5))
|
||||
{
|
||||
if (m_pReal5)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIFactory5*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory6))
|
||||
{
|
||||
if (m_pReal6)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIFactory6*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIFactory7))
|
||||
{
|
||||
if (m_pReal7)
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIFactory7*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if (riid == IDXGIFactoryDWM_uuid)
|
||||
{
|
||||
//RDCWARN("Blocking QueryInterface for IDXGIFactoryDWM");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
else if (riid == IDXGIFactoryDWM8_uuid)
|
||||
{
|
||||
//RDCWARN("Blocking QueryInterface for IDXGIFactoryDWM8");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
return RefCountDXGIObject::QueryInterface("IDXGIFactory", riid, ppvObject);
|
||||
}
|
||||
|
||||
HRESULT WrappedIDXGIFactory::CreateSwapChain(IUnknown* pDevice, DXGI_SWAP_CHAIN_DESC* pDesc,
|
||||
IDXGISwapChain** ppSwapChain)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.CreateSwapChain");
|
||||
|
||||
return m_pReal->CreateSwapChain(pDevice, pDesc, ppSwapChain);
|
||||
}
|
||||
|
||||
HRESULT WrappedIDXGIFactory::CreateSwapChainForHwnd(
|
||||
IUnknown* pDevice, HWND hWnd, const DXGI_SWAP_CHAIN_DESC1* pDesc,
|
||||
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, IDXGIOutput* pRestrictToOutput,
|
||||
IDXGISwapChain1** ppSwapChain)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.CreateSwapChainForHwnd");
|
||||
|
||||
return m_pReal2->CreateSwapChainForHwnd(pDevice, hWnd, pDesc, pFullscreenDesc, pRestrictToOutput, ppSwapChain);
|
||||
}
|
||||
|
||||
HRESULT WrappedIDXGIFactory::CreateSwapChainForCoreWindow(IUnknown* pDevice, IUnknown* pWindow,
|
||||
const DXGI_SWAP_CHAIN_DESC1* pDesc,
|
||||
IDXGIOutput* pRestrictToOutput,
|
||||
IDXGISwapChain1** ppSwapChain)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.CreateSwapChainForCoreWindow");
|
||||
|
||||
return m_pReal2->CreateSwapChainForCoreWindow(pDevice, pWindow, pDesc, pRestrictToOutput, ppSwapChain);
|
||||
}
|
||||
|
||||
HRESULT WrappedIDXGIFactory::CreateSwapChainForComposition(IUnknown* pDevice,
|
||||
const DXGI_SWAP_CHAIN_DESC1* pDesc,
|
||||
IDXGIOutput* pRestrictToOutput,
|
||||
IDXGISwapChain1** ppSwapChain)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.CreateSwapChainForComposition");
|
||||
|
||||
return m_pReal2->CreateSwapChainForComposition(pDevice, pDesc, pRestrictToOutput, ppSwapChain);
|
||||
}
|
||||
@@ -0,0 +1,882 @@
|
||||
#include "pch.h"
|
||||
#include "dxgi1_6.h"
|
||||
|
||||
//#define BLOCK_IDXGIAdapterInternal2
|
||||
|
||||
class RefCountDXGIObject : public IDXGIObject
|
||||
{
|
||||
IDXGIObject* m_pReal;
|
||||
unsigned int m_iRefcount;
|
||||
|
||||
public:
|
||||
RefCountDXGIObject(IDXGIObject* real) : m_pReal(real), m_iRefcount(1) {}
|
||||
virtual ~RefCountDXGIObject() {}
|
||||
static bool HandleWrap(const char* ifaceName, REFIID riid, void** ppvObject);
|
||||
static HRESULT WrapQueryInterface(IUnknown* real, const char* ifaceName, REFIID riid, void** ppvObject);
|
||||
|
||||
//////////////////////////////
|
||||
// implement IUnknown
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface( /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ __RPC__deref_out void** ppvObject)
|
||||
{
|
||||
LOG("RefCountDXGIObject.QueryInterface");
|
||||
auto result = QueryInterface("IUnknown", riid, ppvObject);
|
||||
LOG("RefCountDXGIObject.QueryInterface result: " + int_to_hex(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// optional overload that's useful for passing down the name of the current interface to put in
|
||||
// any 'unknown interface' query logs.
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(const char* ifaceName, REFIID riid, void** ppvObject)
|
||||
{
|
||||
if (riid == __uuidof(IUnknown))
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IUnknown*)(IDXGIObject*)this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIObject))
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = (IDXGIObject*)this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return WrapQueryInterface(m_pReal, ifaceName, riid, ppvObject);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef()
|
||||
{
|
||||
LOG("RefCountDXGIObject.AddRef");
|
||||
InterlockedIncrement(&m_iRefcount);
|
||||
LOG("RefCountDXGIObject.AddRef result: " + int_to_hex(m_iRefcount));
|
||||
return m_iRefcount;
|
||||
}
|
||||
ULONG STDMETHODCALLTYPE Release()
|
||||
{
|
||||
LOG("RefCountDXGIObject.Release");
|
||||
|
||||
unsigned int ret = InterlockedDecrement(&m_iRefcount);
|
||||
|
||||
LOG("RefCountDXGIObject.Release result: " + int_to_hex(m_iRefcount));
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
LOG("RefCountDXGIObject.Release deleting object");
|
||||
delete this;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIObject
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetPrivateData(
|
||||
/* [in] */ REFGUID Name,
|
||||
/* [in] */ UINT DataSize,
|
||||
/* [in] */ const void* pData)
|
||||
{
|
||||
LOG("RefCountDXGIObject.SetPrivateData");
|
||||
auto result = m_pReal->SetPrivateData(Name, DataSize, pData);
|
||||
LOG("RefCountDXGIObject.SetPrivateData result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(
|
||||
/* [in] */ REFGUID Name,
|
||||
/* [in] */ const IUnknown* pUnknown)
|
||||
{
|
||||
LOG("RefCountDXGIObject.SetPrivateDataInterface");
|
||||
auto result = m_pReal->SetPrivateDataInterface(Name, pUnknown);
|
||||
LOG("RefCountDXGIObject.SetPrivateDataInterface result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetPrivateData(
|
||||
/* [in] */ REFGUID Name,
|
||||
/* [out][in] */ UINT* pDataSize,
|
||||
/* [out] */ void* pData)
|
||||
{
|
||||
LOG("RefCountDXGIObject.GetPrivateData");
|
||||
auto result = m_pReal->GetPrivateData(Name, pDataSize, pData);
|
||||
LOG("RefCountDXGIObject.GetPrivateData result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetParent(
|
||||
/* [in] */ REFIID riid,
|
||||
/* [retval][out] */ void** ppParent);
|
||||
};
|
||||
|
||||
#define IMPLEMENT_IDXGIOBJECT_WITH_REFCOUNTDXGIOBJECT_CUSTOMQUERY \
|
||||
ULONG STDMETHODCALLTYPE AddRef() \
|
||||
{ \
|
||||
return RefCountDXGIObject::AddRef(); \
|
||||
} \
|
||||
ULONG STDMETHODCALLTYPE Release() \
|
||||
{ \
|
||||
return RefCountDXGIObject::Release(); \
|
||||
} \
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData(REFIID Name, UINT DataSize, const void *pData) \
|
||||
{ \
|
||||
return RefCountDXGIObject::SetPrivateData(Name, DataSize, pData); \
|
||||
} \
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFIID Name, const IUnknown *pUnknown) \
|
||||
{ \
|
||||
return RefCountDXGIObject::SetPrivateDataInterface(Name, pUnknown); \
|
||||
} \
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData(REFIID Name, UINT *pDataSize, void *pData) \
|
||||
{ \
|
||||
return RefCountDXGIObject::GetPrivateData(Name, pDataSize, pData); \
|
||||
} \
|
||||
HRESULT STDMETHODCALLTYPE GetParent(REFIID riid, void **ppvObject) \
|
||||
{ \
|
||||
return RefCountDXGIObject::GetParent(riid, ppvObject); \
|
||||
}
|
||||
|
||||
|
||||
MIDL_INTERFACE("cfdf09b3-a084-4453-a755-7d4e5389b845")
|
||||
IDXGIProxyAdapter : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE Spoofing(bool enable);
|
||||
virtual HRESULT STDMETHODCALLTYPE Wrapping(bool enable);
|
||||
};
|
||||
|
||||
static bool b_spoofEnabled = true;
|
||||
static bool b_wrappingEnabled = true;
|
||||
|
||||
class WrappedIDXGIAdapter4 : public IDXGIAdapter4, public RefCountDXGIObject, public IDXGIProxyAdapter
|
||||
{
|
||||
IDXGIAdapter* m_pReal;
|
||||
IDXGIAdapter1* m_pReal1;
|
||||
IDXGIAdapter2* m_pReal2;
|
||||
IDXGIAdapter3* m_pReal3;
|
||||
IDXGIAdapter4* m_pReal4;
|
||||
|
||||
public:
|
||||
WrappedIDXGIAdapter4(IDXGIAdapter* real);
|
||||
virtual ~WrappedIDXGIAdapter4();
|
||||
|
||||
IMPLEMENT_IDXGIOBJECT_WITH_REFCOUNTDXGIOBJECT_CUSTOMQUERY;
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIAdapter
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE EnumOutputs( /* [in] */ UINT Output, /* [annotation][out][in] */ __out IDXGIOutput** ppOutput)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.EnumOutputs");
|
||||
HRESULT ret = m_pReal->EnumOutputs(Output, ppOutput);
|
||||
LOG("WrappedIDXGIAdapter4.EnumOutputs result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDesc( /* [annotation][out] */ __out DXGI_ADAPTER_DESC* pDesc)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc");
|
||||
|
||||
HRESULT hr;
|
||||
hr = m_pReal->GetDesc(pDesc);
|
||||
|
||||
if (hr == S_OK && b_spoofEnabled && pDesc != nullptr && (pDesc->VendorId == 0x8086 || pDesc->VendorId == 0x1002))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc Spoofing card info");
|
||||
pDesc->VendorId = 0x10de;
|
||||
pDesc->DeviceId = 0x24c9;
|
||||
pDesc->SubSysId = 0x88ac1043;
|
||||
pDesc->Revision = 0x00a1;
|
||||
|
||||
std::wstring name(L"NVIDIA GeForce RTX 3060 Ti");
|
||||
const wchar_t* szName = name.c_str();
|
||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||
std::memcpy(pDesc->Description, szName, 54);
|
||||
|
||||
LUID luid = LUID{ 0, 56090 };
|
||||
std::memcpy(&pDesc->AdapterLuid, &luid, 8);
|
||||
}
|
||||
|
||||
//b_spoofEnabled = true;
|
||||
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc result: " + int_to_hex(hr));
|
||||
return hr;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CheckInterfaceSupport(
|
||||
/* [annotation][in] */
|
||||
__in REFGUID InterfaceName,
|
||||
/* [annotation][out] */
|
||||
__out LARGE_INTEGER* pUMDVersion)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.CheckInterfaceSupport");
|
||||
auto result = m_pReal->CheckInterfaceSupport(InterfaceName, pUMDVersion);
|
||||
LOG("WrappedIDXGIAdapter4.CheckInterfaceSupport result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIAdapter1
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDesc1(
|
||||
/* [out] */ DXGI_ADAPTER_DESC1* pDesc)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc1");
|
||||
|
||||
if (!m_pReal1)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc1 no adapter!");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
HRESULT hr;
|
||||
hr = m_pReal1->GetDesc1(pDesc);
|
||||
|
||||
if (hr == S_OK && b_spoofEnabled && pDesc != nullptr && (pDesc->VendorId == 0x8086 || pDesc->VendorId == 0x1002))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc1 Spoofing card info");
|
||||
|
||||
pDesc->VendorId = 0x10de;
|
||||
pDesc->DeviceId = 0x24c9;
|
||||
pDesc->SubSysId = 0x88ac1043;
|
||||
pDesc->Revision = 0x00a1;
|
||||
|
||||
std::wstring name(L"NVIDIA GeForce RTX 3060 Ti");
|
||||
const wchar_t* szName = name.c_str();
|
||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||
std::memcpy(pDesc->Description, szName, 54);
|
||||
|
||||
LUID luid = LUID{ 0, 56090 };
|
||||
std::memcpy(&pDesc->AdapterLuid, &luid, 8);
|
||||
}
|
||||
|
||||
//b_spoofEnabled = true;
|
||||
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc1 result: " + int_to_hex(hr));
|
||||
return hr;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIAdapter2
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDesc2(
|
||||
/* [annotation][out] */
|
||||
_Out_ DXGI_ADAPTER_DESC2* pDesc)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc2");
|
||||
|
||||
if (!m_pReal2)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc2 no adapter!");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
hr = m_pReal2->GetDesc2(pDesc);
|
||||
|
||||
if (hr == S_OK && b_spoofEnabled && pDesc != nullptr && (pDesc->VendorId == 0x8086 || pDesc->VendorId == 0x1002))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc2 Spoofing card info");
|
||||
|
||||
pDesc->VendorId = 0x10de;
|
||||
pDesc->DeviceId = 0x24c9;
|
||||
pDesc->SubSysId = 0x88ac1043;
|
||||
pDesc->Revision = 0x00a1;
|
||||
|
||||
std::wstring name(L"NVIDIA GeForce RTX 3060 Ti");
|
||||
const wchar_t* szName = name.c_str();
|
||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||
std::memcpy(pDesc->Description, szName, 54);
|
||||
|
||||
LUID luid = LUID{ 0, 56090 };
|
||||
std::memcpy(&pDesc->AdapterLuid, &luid, 8);
|
||||
}
|
||||
|
||||
//b_spoofEnabled = true;
|
||||
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc2 result: " + int_to_hex(hr));
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIAdapter3
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterHardwareContentProtectionTeardownStatusEvent(
|
||||
/* [annotation][in] */
|
||||
_In_ HANDLE hEvent,
|
||||
/* [annotation][out] */
|
||||
_Out_ DWORD* pdwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.RegisterHardwareContentProtectionTeardownStatusEvent");
|
||||
auto result = m_pReal3->RegisterHardwareContentProtectionTeardownStatusEvent(hEvent, pdwCookie);
|
||||
LOG("WrappedIDXGIAdapter4.RegisterHardwareContentProtectionTeardownStatusEvent result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual void STDMETHODCALLTYPE UnregisterHardwareContentProtectionTeardownStatus(
|
||||
/* [annotation][in] */
|
||||
_In_ DWORD dwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.UnregisterHardwareContentProtectionTeardownStatus");
|
||||
m_pReal3->UnregisterHardwareContentProtectionTeardownStatus(dwCookie);
|
||||
LOG("WrappedIDXGIAdapter4.UnregisterHardwareContentProtectionTeardownStatus done");
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryVideoMemoryInfo(
|
||||
/* [annotation][in] */
|
||||
_In_ UINT NodeIndex,
|
||||
/* [annotation][in] */
|
||||
_In_ DXGI_MEMORY_SEGMENT_GROUP MemorySegmentGroup,
|
||||
/* [annotation][out] */
|
||||
_Out_ DXGI_QUERY_VIDEO_MEMORY_INFO* pVideoMemoryInfo)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.QueryVideoMemoryInfo");
|
||||
|
||||
auto result = m_pReal3->QueryVideoMemoryInfo(NodeIndex, MemorySegmentGroup, pVideoMemoryInfo);
|
||||
LOG("WrappedIDXGIAdapter4.QueryVideoMemoryInfo result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetVideoMemoryReservation(
|
||||
/* [annotation][in] */
|
||||
_In_ UINT NodeIndex,
|
||||
/* [annotation][in] */
|
||||
_In_ DXGI_MEMORY_SEGMENT_GROUP MemorySegmentGroup,
|
||||
/* [annotation][in] */
|
||||
_In_ UINT64 Reservation)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.SetVideoMemoryReservation");
|
||||
|
||||
auto result = m_pReal3->SetVideoMemoryReservation(NodeIndex, MemorySegmentGroup, Reservation);
|
||||
LOG("WrappedIDXGIAdapter4.SetVideoMemoryReservation result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterVideoMemoryBudgetChangeNotificationEvent(
|
||||
/* [annotation][in] */
|
||||
_In_ HANDLE hEvent,
|
||||
/* [annotation][out] */
|
||||
_Out_ DWORD* pdwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.RegisterVideoMemoryBudgetChangeNotificationEvent");
|
||||
|
||||
auto result = m_pReal3->RegisterVideoMemoryBudgetChangeNotificationEvent(hEvent, pdwCookie);
|
||||
LOG("WrappedIDXGIAdapter4.RegisterVideoMemoryBudgetChangeNotificationEvent result: " + int_to_hex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual void STDMETHODCALLTYPE UnregisterVideoMemoryBudgetChangeNotification(
|
||||
/* [annotation][in] */
|
||||
_In_ DWORD dwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.UnregisterVideoMemoryBudgetChangeNotification");
|
||||
|
||||
m_pReal3->UnregisterVideoMemoryBudgetChangeNotification(dwCookie);
|
||||
LOG("WrappedIDXGIAdapter4.UnregisterVideoMemoryBudgetChangeNotification done");
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIAdapter4
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDesc3(
|
||||
/* [annotation][out] */
|
||||
_Out_ DXGI_ADAPTER_DESC3* pDesc)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc3");
|
||||
|
||||
if (!m_pReal4)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc3 no adapter!");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
hr = m_pReal4->GetDesc3(pDesc);
|
||||
|
||||
if (hr == S_OK && b_spoofEnabled && pDesc != nullptr && (pDesc->VendorId == 0x8086 || pDesc->VendorId == 0x1002))
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc3 Spoofing card info");
|
||||
|
||||
pDesc->VendorId = 0x10de;
|
||||
pDesc->DeviceId = 0x24c9;
|
||||
pDesc->SubSysId = 0x88ac1043;
|
||||
pDesc->Revision = 0x00a1;
|
||||
|
||||
std::wstring name(L"NVIDIA GeForce RTX 3060 Ti");
|
||||
const wchar_t* szName = name.c_str();
|
||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||
std::memcpy(pDesc->Description, szName, 54);
|
||||
|
||||
LUID luid = LUID{ 0, 56090 };
|
||||
std::memcpy(&pDesc->AdapterLuid, &luid, 8);
|
||||
}
|
||||
|
||||
//b_spoofEnabled = true;
|
||||
|
||||
LOG("WrappedIDXGIAdapter4.GetDesc3 result: " + int_to_hex(hr));
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE Spoofing(bool enable)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.Spoofing : " + std::to_string(enable));
|
||||
b_spoofEnabled = enable;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE Wrapping(bool enable)
|
||||
{
|
||||
LOG("WrappedIDXGIAdapter4.Wrapping : " + std::to_string(enable));
|
||||
b_wrappingEnabled = enable;
|
||||
return S_OK;
|
||||
}
|
||||
};
|
||||
|
||||
class WrappedIDXGIFactory : public IDXGIFactory7, public RefCountDXGIObject
|
||||
{
|
||||
IDXGIFactory* m_pReal;
|
||||
IDXGIFactory1* m_pReal1;
|
||||
IDXGIFactory2* m_pReal2;
|
||||
IDXGIFactory3* m_pReal3;
|
||||
IDXGIFactory4* m_pReal4;
|
||||
IDXGIFactory5* m_pReal5;
|
||||
IDXGIFactory6* m_pReal6;
|
||||
IDXGIFactory7* m_pReal7;
|
||||
|
||||
public:
|
||||
WrappedIDXGIFactory(IDXGIFactory* real);
|
||||
virtual ~WrappedIDXGIFactory();
|
||||
|
||||
IMPLEMENT_IDXGIOBJECT_WITH_REFCOUNTDXGIOBJECT_CUSTOMQUERY;
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIFactory
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE EnumAdapters(
|
||||
/* [in] */ UINT Adapter,
|
||||
/* [annotation][out] */
|
||||
__out IDXGIAdapter** ppAdapter)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.EnumAdapters " + std::to_string(Adapter));
|
||||
|
||||
HRESULT ret = m_pReal->EnumAdapters(Adapter, ppAdapter);
|
||||
|
||||
if (ret == S_OK && b_wrappingEnabled)
|
||||
*ppAdapter = (IDXGIAdapter*)(new WrappedIDXGIAdapter4(*ppAdapter));
|
||||
|
||||
LOG("WrappedIDXGIFactory.EnumAdapters result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE MakeWindowAssociation(HWND WindowHandle, UINT Flags)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.MakeWindowAssociation");
|
||||
|
||||
auto ret = m_pReal->MakeWindowAssociation(WindowHandle, Flags);
|
||||
LOG("WrappedIDXGIFactory.MakeWindowAssociation result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetWindowAssociation(
|
||||
/* [annotation][out] */
|
||||
__out HWND* pWindowHandle)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.GetWindowAssociation");
|
||||
|
||||
auto ret = m_pReal->GetWindowAssociation(pWindowHandle);
|
||||
LOG("WrappedIDXGIFactory.GetWindowAssociation result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateSwapChain(
|
||||
/* [annotation][in] */
|
||||
__in IUnknown* pDevice,
|
||||
/* [annotation][in] */
|
||||
__in DXGI_SWAP_CHAIN_DESC* pDesc,
|
||||
/* [annotation][out] */
|
||||
__out IDXGISwapChain** ppSwapChain);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateSoftwareAdapter(
|
||||
/* [in] */ HMODULE Module,
|
||||
/* [annotation][out] */
|
||||
__out IDXGIAdapter** ppAdapter)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.CreateSoftwareAdapter");
|
||||
|
||||
HRESULT ret = m_pReal->CreateSoftwareAdapter(Module, ppAdapter);
|
||||
|
||||
if (ret == S_OK && b_wrappingEnabled)
|
||||
*ppAdapter = (IDXGIAdapter*)(new WrappedIDXGIAdapter4(*ppAdapter));
|
||||
|
||||
LOG("WrappedIDXGIFactory.CreateSoftwareAdapter result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIFactory1
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE EnumAdapters1(
|
||||
/* [in] */ UINT Adapter,
|
||||
/* [annotation][out] */
|
||||
__out IDXGIAdapter1** ppAdapter)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.EnumAdapters1 " + std::to_string(Adapter));
|
||||
|
||||
IDXGIFactory1* factory = m_pReal1;
|
||||
if (m_pReal1 == NULL)
|
||||
{
|
||||
// see comment in RefCountDXGIObject::HandleWrap for IDXGIFactory
|
||||
//RDCWARN("Calling EnumAdapters1 with no IDXGIFactory1 - assuming weird internal call");
|
||||
factory = (IDXGIFactory1*)m_pReal;
|
||||
}
|
||||
|
||||
HRESULT ret = factory->EnumAdapters1(Adapter, ppAdapter);
|
||||
|
||||
if (ret == S_OK && b_wrappingEnabled)
|
||||
*ppAdapter = (IDXGIAdapter1*)(new WrappedIDXGIAdapter4(*ppAdapter));
|
||||
|
||||
LOG("WrappedIDXGIFactory.EnumAdapters1 result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual BOOL STDMETHODCALLTYPE IsCurrent(void)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.IsCurrent");
|
||||
|
||||
auto ret = m_pReal1->IsCurrent();
|
||||
LOG("WrappedIDXGIFactory.IsCurrent result: " + std::to_string(ret));
|
||||
return ret;
|
||||
}
|
||||
//////////////////////////////
|
||||
// implement IDXGIFactory2
|
||||
|
||||
virtual BOOL STDMETHODCALLTYPE IsWindowedStereoEnabled(void)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.IsWindowedStereoEnabled");
|
||||
|
||||
auto ret = m_pReal2->IsWindowedStereoEnabled();
|
||||
LOG("WrappedIDXGIFactory.IsCurrent result: " + std::to_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(
|
||||
/* [annotation][in] */
|
||||
_In_ IUnknown* pDevice,
|
||||
/* [annotation][in] */
|
||||
_In_ HWND hWnd,
|
||||
/* [annotation][in] */
|
||||
_In_ const DXGI_SWAP_CHAIN_DESC1* pDesc,
|
||||
/* [annotation][in] */
|
||||
_In_opt_ const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc,
|
||||
/* [annotation][in] */
|
||||
_In_opt_ IDXGIOutput* pRestrictToOutput,
|
||||
/* [annotation][out] */
|
||||
_Out_ IDXGISwapChain1** ppSwapChain);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForCoreWindow(
|
||||
/* [annotation][in] */
|
||||
_In_ IUnknown* pDevice,
|
||||
/* [annotation][in] */
|
||||
_In_ IUnknown* pWindow,
|
||||
/* [annotation][in] */
|
||||
_In_ const DXGI_SWAP_CHAIN_DESC1* pDesc,
|
||||
/* [annotation][in] */
|
||||
_In_opt_ IDXGIOutput* pRestrictToOutput,
|
||||
/* [annotation][out] */
|
||||
_Out_ IDXGISwapChain1** ppSwapChain);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetSharedResourceAdapterLuid(
|
||||
/* [annotation] */
|
||||
_In_ HANDLE hResource,
|
||||
/* [annotation] */
|
||||
_Out_ LUID* pLuid)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.GetSharedResourceAdapterLuid");
|
||||
|
||||
auto ret = m_pReal2->GetSharedResourceAdapterLuid(hResource, pLuid);
|
||||
LOG("WrappedIDXGIFactory.GetSharedResourceAdapterLuid result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterStereoStatusWindow(
|
||||
/* [annotation][in] */
|
||||
_In_ HWND WindowHandle,
|
||||
/* [annotation][in] */
|
||||
_In_ UINT wMsg,
|
||||
/* [annotation][out] */
|
||||
_Out_ DWORD* pdwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.RegisterStereoStatusWindow");
|
||||
|
||||
auto ret = m_pReal2->RegisterOcclusionStatusWindow(WindowHandle, wMsg, pdwCookie);
|
||||
LOG("WrappedIDXGIFactory.RegisterStereoStatusWindow result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterStereoStatusEvent(
|
||||
/* [annotation][in] */
|
||||
_In_ HANDLE hEvent,
|
||||
/* [annotation][out] */
|
||||
_Out_ DWORD* pdwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.RegisterStereoStatusEvent");
|
||||
|
||||
auto ret = m_pReal2->RegisterStereoStatusEvent(hEvent, pdwCookie);
|
||||
LOG("WrappedIDXGIFactory.RegisterStereoStatusEvent result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual void STDMETHODCALLTYPE UnregisterStereoStatus(
|
||||
/* [annotation][in] */
|
||||
_In_ DWORD dwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.UnregisterStereoStatus");
|
||||
|
||||
m_pReal2->UnregisterStereoStatus(dwCookie);
|
||||
LOG("WrappedIDXGIFactory.UnregisterStereoStatus done");
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusWindow(
|
||||
/* [annotation][in] */
|
||||
_In_ HWND WindowHandle,
|
||||
/* [annotation][in] */
|
||||
_In_ UINT wMsg,
|
||||
/* [annotation][out] */
|
||||
_Out_ DWORD* pdwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.RegisterOcclusionStatusWindow");
|
||||
|
||||
auto ret = m_pReal2->RegisterOcclusionStatusWindow(WindowHandle, wMsg, pdwCookie);
|
||||
LOG("WrappedIDXGIFactory.RegisterOcclusionStatusWindow result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusEvent(
|
||||
/* [annotation][in] */
|
||||
_In_ HANDLE hEvent,
|
||||
/* [annotation][out] */
|
||||
_Out_ DWORD* pdwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.RegisterOcclusionStatusEvent");
|
||||
|
||||
auto ret = m_pReal2->RegisterOcclusionStatusEvent(hEvent, pdwCookie);
|
||||
LOG("WrappedIDXGIFactory.RegisterOcclusionStatusEvent result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual void STDMETHODCALLTYPE UnregisterOcclusionStatus(
|
||||
/* [annotation][in] */
|
||||
_In_ DWORD dwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.UnregisterOcclusionStatus");
|
||||
|
||||
m_pReal2->UnregisterOcclusionStatus(dwCookie);
|
||||
LOG("WrappedIDXGIFactory.UnregisterOcclusionStatus done");
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForComposition(
|
||||
/* [annotation][in] */
|
||||
_In_ IUnknown* pDevice,
|
||||
/* [annotation][in] */
|
||||
_In_ const DXGI_SWAP_CHAIN_DESC1* pDesc,
|
||||
/* [annotation][in] */
|
||||
_In_opt_ IDXGIOutput* pRestrictToOutput,
|
||||
/* [annotation][out] */
|
||||
_Outptr_ IDXGISwapChain1** ppSwapChain);
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIFactory3
|
||||
|
||||
virtual UINT STDMETHODCALLTYPE GetCreationFlags(void)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.GetCreationFlags");
|
||||
|
||||
auto ret = m_pReal3->GetCreationFlags();
|
||||
LOG("WrappedIDXGIFactory.GetCreationFlags result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
//////////////////////////////
|
||||
// implement IDXGIFactory4
|
||||
|
||||
bool WrapAdapter(REFIID riid, void** ppvAdapter)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.WrapAdapter");
|
||||
|
||||
if (ppvAdapter == NULL || *ppvAdapter == NULL)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.WrapAdapter ppvAdapter is NULL!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(IDXGIAdapter4) && b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter4* adapter = (IDXGIAdapter4*)*ppvAdapter;
|
||||
*ppvAdapter = (IDXGIAdapter4*)(new WrappedIDXGIAdapter4(adapter));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter3) && b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter3* adapter = (IDXGIAdapter3*)*ppvAdapter;
|
||||
*ppvAdapter = (IDXGIAdapter3*)(new WrappedIDXGIAdapter4(adapter));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter2) && b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter2* adapter = (IDXGIAdapter2*)*ppvAdapter;
|
||||
*ppvAdapter = (IDXGIAdapter2*)(new WrappedIDXGIAdapter4(adapter));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter1) && b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter1* adapter = (IDXGIAdapter1*)*ppvAdapter;
|
||||
*ppvAdapter = (IDXGIAdapter1*)(new WrappedIDXGIAdapter4(adapter));
|
||||
return true;
|
||||
}
|
||||
else if (riid == __uuidof(IDXGIAdapter) && b_wrappingEnabled)
|
||||
{
|
||||
IDXGIAdapter* adapter = (IDXGIAdapter*)*ppvAdapter;
|
||||
*ppvAdapter = (IDXGIAdapter*)(new WrappedIDXGIAdapter4(adapter));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RefCountDXGIObject::HandleWrap("IDXGIAdapter", riid, ppvAdapter);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE EnumAdapterByLuid( /* [annotation] */ _In_ LUID AdapterLuid, /* [annotation] */ _In_ REFIID riid, /* [annotation] */ _COM_Outptr_ void** ppvAdapter)
|
||||
|
||||
{
|
||||
#ifdef BLOCK_IDXGIAdapterInternal2
|
||||
// unknown/undocumented internal interface
|
||||
// {7abb6563-02bc-47c4-8ef9-acc4795edbcf}
|
||||
static const GUID IDXGIAdapterInternal2_uuid = {
|
||||
0x7abb6563, 0x02bc, 0x47c4, {0x8e, 0xf9, 0xac, 0xc4, 0x79, 0x5e, 0xdb, 0xcf} };
|
||||
|
||||
if (riid == IDXGIAdapterInternal2_uuid)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.EnumAdapterByLuid IDXGIAdapterInternal2_uuid result: " + int_to_hex(DXGI_ERROR_NOT_FOUND));
|
||||
return DXGI_ERROR_NOT_FOUND;
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG("WrappedIDXGIFactory.EnumAdapterByLuid LUID: " + int_to_hex(AdapterLuid.HighPart) + "-" + int_to_hex(AdapterLuid.LowPart) + " riid: " + ToString(riid));
|
||||
|
||||
HRESULT ret = m_pReal4->EnumAdapterByLuid(AdapterLuid, riid, ppvAdapter);
|
||||
|
||||
if (ret == S_OK && b_wrappingEnabled)
|
||||
{
|
||||
auto wrapResult = this->WrapAdapter(riid, ppvAdapter);
|
||||
|
||||
if (!wrapResult)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.EnumAdapterByLuid wrapResult result: " + int_to_hex(DXGI_ERROR_NOT_FOUND));
|
||||
return DXGI_ERROR_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.EnumAdapterByLuid can't get adapter by LUID, user first adapter");
|
||||
IDXGIAdapter* wrappedAdapter;
|
||||
ret = this->EnumAdapters(0, &wrappedAdapter);
|
||||
|
||||
if (ret == S_OK)
|
||||
*ppvAdapter = wrappedAdapter;
|
||||
}
|
||||
|
||||
LOG("WrappedIDXGIFactory.EnumAdapterByLuid result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE EnumWarpAdapter(
|
||||
/* [annotation] */
|
||||
_In_ REFIID riid,
|
||||
/* [annotation] */
|
||||
_COM_Outptr_ void** ppvAdapter)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.EnumWarpAdapter");
|
||||
|
||||
HRESULT ret = m_pReal4->EnumWarpAdapter(riid, ppvAdapter);
|
||||
|
||||
if (ret == S_OK && b_wrappingEnabled)
|
||||
WrapAdapter(riid, ppvAdapter);
|
||||
|
||||
LOG("WrappedIDXGIFactory.EnumWarpAdapter result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIFactory5
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
CheckFeatureSupport(DXGI_FEATURE Feature,
|
||||
/* [annotation] */
|
||||
_Inout_updates_bytes_(FeatureSupportDataSize) void* pFeatureSupportData,
|
||||
UINT FeatureSupportDataSize)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.CheckFeatureSupport");
|
||||
|
||||
auto ret = m_pReal5->CheckFeatureSupport(Feature, pFeatureSupportData, FeatureSupportDataSize);
|
||||
LOG("WrappedIDXGIFactory.CheckFeatureSupport result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIFactory6
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE EnumAdapterByGpuPreference(
|
||||
/* [annotation] */
|
||||
_In_ UINT Adapter,
|
||||
/* [annotation] */
|
||||
_In_ DXGI_GPU_PREFERENCE GpuPreference,
|
||||
/* [annotation] */
|
||||
_In_ REFIID riid,
|
||||
/* [annotation] */
|
||||
_COM_Outptr_ void** ppvAdapter)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.EnumAdapterByGpuPreference " + std::to_string(Adapter) + ", GpuPreference: " + int_to_hex(GpuPreference));
|
||||
|
||||
HRESULT ret = m_pReal6->EnumAdapterByGpuPreference(Adapter, GpuPreference, riid, ppvAdapter);
|
||||
|
||||
if (ret == S_OK && b_wrappingEnabled)
|
||||
WrapAdapter(riid, ppvAdapter);
|
||||
|
||||
LOG("WrappedIDXGIFactory.EnumAdapterByGpuPreference result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// implement IDXGIFactory7
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterAdaptersChangedEvent(
|
||||
/* [annotation][in] */
|
||||
_In_ HANDLE hEvent,
|
||||
/* [annotation][out] */
|
||||
_Out_ DWORD* pdwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.RegisterAdaptersChangedEvent");
|
||||
|
||||
auto ret = m_pReal7->RegisterAdaptersChangedEvent(hEvent, pdwCookie);
|
||||
LOG("WrappedIDXGIFactory.RegisterAdaptersChangedEvent result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE UnregisterAdaptersChangedEvent(
|
||||
/* [annotation][in] */
|
||||
_In_ DWORD dwCookie)
|
||||
{
|
||||
LOG("WrappedIDXGIFactory.UnregisterAdaptersChangedEvent");
|
||||
|
||||
auto ret = m_pReal7->UnregisterAdaptersChangedEvent(dwCookie);
|
||||
LOG("WrappedIDXGIFactory.UnregisterAdaptersChangedEvent result: " + int_to_hex(ret));
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
#include "pch.h"
|
||||
|
||||
HMODULE dllModule;
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hModule);
|
||||
dllModule = hModule;
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
#ifdef LOGGING_ACTIVE
|
||||
closeOfs();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#include <d3d11_4.h>
|
||||
#include <d3d12.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
#define NV_WINDOWS
|
||||
#define NVSDK_NGX
|
||||
#define NGX_ENABLE_DEPRECATED_GET_PARAMETERS
|
||||
#define NGX_ENABLE_DEPRECATED_SHUTDOWN
|
||||
#include <nvsdk_ngx.h>
|
||||
#include <nvsdk_ngx_vk.h>
|
||||
|
||||
#include <ankerl/unordered_dense.h>
|
||||
#include <SimpleIni.h>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "pch.h"
|
||||
|
||||
#ifdef LOGGING_ACTIVE
|
||||
|
||||
std::ofstream ofs;
|
||||
log_level_t logLevel = LEVEL_NONE;
|
||||
|
||||
void logprintf(std::string logMsg, log_level_t level)
|
||||
{
|
||||
if (level < logLevel)
|
||||
return;
|
||||
|
||||
ofs << GetTicks() << ": " << logMsg << '\n';
|
||||
ofs.flush();
|
||||
}
|
||||
|
||||
void prepareOfs(std::string fileName, log_level_t level)
|
||||
{
|
||||
logLevel = level;
|
||||
ofs = std::ofstream(fileName, std::ios_base::out | std::ios_base::app);
|
||||
}
|
||||
|
||||
void closeOfs()
|
||||
{
|
||||
ofs.close();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
//#define LOGGING_ACTIVE
|
||||
//#define D3D11on12
|
||||
|
||||
typedef enum _log_level_t
|
||||
{
|
||||
LEVEL_NONE = -1,
|
||||
LEVEL_DEBUG = 0,
|
||||
LEVEL_INFO = 1,
|
||||
LEVEL_WARNING = 2,
|
||||
LEVEL_ERROR = 3
|
||||
} log_level_t;
|
||||
|
||||
#define SAFE_RELEASE(p) \
|
||||
do \
|
||||
{ \
|
||||
if(p) \
|
||||
{ \
|
||||
(p)->Release(); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
} while((void)0, 0)
|
||||
|
||||
#ifdef LOGGING_ACTIVE
|
||||
#define LOG(string, ...) logprintf(string, __VA_ARGS__)
|
||||
#else
|
||||
#define LOG(string, level)
|
||||
#endif
|
||||
|
||||
#ifdef LOGGING_ACTIVE
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "Config.h"
|
||||
|
||||
void logprintf(std::string logMsg, log_level_t level = LEVEL_DEBUG);
|
||||
|
||||
void prepareOfs(std::string fileName, log_level_t level);
|
||||
|
||||
void closeOfs();
|
||||
|
||||
static inline int64_t GetTicks()
|
||||
{
|
||||
LARGE_INTEGER ticks;
|
||||
if (!QueryPerformanceCounter(&ticks))
|
||||
return 0;
|
||||
|
||||
return ticks.QuadPart;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
static inline std::string int_to_hex(T i)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << "0x"
|
||||
<< std::setfill('0')
|
||||
<< std::setw(sizeof(T) * 2)
|
||||
<< std::hex << i;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
static inline std::string ToString(REFIID guid)
|
||||
{
|
||||
char guid_string[37]; // 32 hex chars + 4 hyphens + null terminator
|
||||
|
||||
snprintf(
|
||||
guid_string, sizeof(guid_string),
|
||||
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
guid.Data1, guid.Data2, guid.Data3,
|
||||
guid.Data4[0], guid.Data4[1], guid.Data4[2],
|
||||
guid.Data4[3], guid.Data4[4], guid.Data4[5],
|
||||
guid.Data4[6], guid.Data4[7]);
|
||||
|
||||
return guid_string;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user