Skip to content

Commit

Permalink
Integrate FSR2 automatic building to the project
Browse files Browse the repository at this point in the history
Integrate FSR2 automatic building to the project

Better automated FSR2 building

Forgot part of the call structure, update the bat to be more verbose
  • Loading branch information
CompulsiveComputing committed Jul 1, 2023
1 parent bfe95a1 commit 21abf07
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 3 deletions.
74 changes: 74 additions & 0 deletions BuildFSR2.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
+@echo off
setlocal
set "origin=%cd%\"
set "buildPath=..\external\FidelityFX-FSR2\build"
set "slnDX12=FSR2_Sample_DX12.sln"
set "slnVK=FSR2_Sample_VK.sln"

echo Script started on %date% %time%
echo Current working directory: %origin%

REM Clear old artifacts
echo Clearing old artifacts...
cd /d "%origin%%buildPath%"
if exist "DX12" (
echo Removing old DX12 artifacts...
rd /s /q "DX12" > nul 2>&1
if errorlevel 1 (
echo Failed to remove old DX12 artifacts.
) else (
echo Successfully removed old DX12 artifacts.
)
)
if exist "VK" (
echo Removing old VK artifacts...
rd /s /q "VK" > nul 2>&1
if errorlevel 1 (
echo Failed to remove old VK artifacts.
) else (
echo Successfully removed old VK artifacts.
)
)

REM Regenerate artifacts
echo Regenerating artifacts...
cd /d "%origin%%buildPath%"
call GenerateSolutions.bat > nul 2>&1
if errorlevel 1 (
echo Failed to regenerate artifacts.
) else (
echo Successfully regenerated artifacts.
)

REM Build FSR2_Sample_DX12.sln
call :BuildSolution "%origin%%buildPath%\DX12\%slnDX12%" "Debug" "DX12"
call :BuildSolution "%origin%%buildPath%\DX12\%slnDX12%" "RelWithDebInfo" "DX12"

REM Build FSR2_Sample_VK.sln
call :BuildSolution "%origin%%buildPath%\VK\%slnVK%" "Debug" "VK"
call :BuildSolution "%origin%%buildPath%\VK\%slnVK%" "RelWithDebInfo" "VK"

cd /d "%origin%"
goto :endofBuildFSR2

REM Function to build a solution file
:BuildSolution
set "solutionPath=%~1"
set "configuration=%~2"
if exist "%solutionPath%" (
echo Building %solutionPath%...
cd /d "%origin%%buildPath%\%~3"
MSBUILD.exe "%solutionPath%" /t:Build /p:Configuration=%configuration%
if errorlevel 1 (
echo Failed to build %solutionPath%.
) else (
echo Successfully built %solutionPath%.
)
) else (
echo %solutionPath% not found. Skipping build.
)
exit /b

:endofBuildFSR2
echo FSR2 build-script finished on %date% %time%
endlocal
140 changes: 140 additions & 0 deletions Build_FSR2/Build_FSR2.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?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>{e61bcfc0-bc33-46d1-a144-9021fef7f6bc}</ProjectGuid>
<RootNamespace>BuildFSR2</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</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" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PreBuildEvent>
<Command>call "..\BuildFSR2.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Build / rebuild FSR2 artifacts</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
17 changes: 17 additions & 0 deletions Build_FSR2/Build_FSR2.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<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="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</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>
</Project>
33 changes: 33 additions & 0 deletions CyberFSR.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,56 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.2.32602.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CyberFSR", "CyberFSR\CyberFSR.vcxproj", "{8D2B73FB-EECD-45CE-B8E5-335610462F58}"
ProjectSection(ProjectDependencies) = postProject
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC} = {E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Build_FSR2", "Build_FSR2\Build_FSR2.vcxproj", "{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
MinSizeRel|x64 = MinSizeRel|x64
MinSizeRel|x86 = MinSizeRel|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
RelWithDebInfo|x64 = RelWithDebInfo|x64
RelWithDebInfo|x86 = RelWithDebInfo|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Debug|x64.ActiveCfg = Debug|x64
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Debug|x64.Build.0 = Debug|x64
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Debug|x86.ActiveCfg = Debug|Win32
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Debug|x86.Build.0 = Debug|Win32
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.MinSizeRel|x64.ActiveCfg = Release|x64
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.MinSizeRel|x64.Build.0 = Release|x64
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.MinSizeRel|x86.ActiveCfg = Release|Win32
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.MinSizeRel|x86.Build.0 = Release|Win32
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x64.ActiveCfg = Release|x64
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x64.Build.0 = Release|x64
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x86.ActiveCfg = Release|Win32
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x86.Build.0 = Release|Win32
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.RelWithDebInfo|x64.Build.0 = Release|x64
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.RelWithDebInfo|x86.Build.0 = Release|Win32
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.Debug|x64.ActiveCfg = Debug|x64
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.Debug|x64.Build.0 = Debug|x64
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.Debug|x86.ActiveCfg = Debug|Win32
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.Debug|x86.Build.0 = Debug|Win32
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.MinSizeRel|x64.ActiveCfg = Debug|x64
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.MinSizeRel|x64.Build.0 = Debug|x64
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.MinSizeRel|x86.ActiveCfg = Debug|Win32
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.MinSizeRel|x86.Build.0 = Debug|Win32
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.Release|x64.ActiveCfg = Release|x64
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.Release|x64.Build.0 = Release|x64
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.Release|x86.ActiveCfg = Release|Win32
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.Release|x86.Build.0 = Release|Win32
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.RelWithDebInfo|x64.Build.0 = Release|x64
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{E61BCFC0-BC33-46D1-A144-9021FEF7F6BC}.RelWithDebInfo|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions CyberFSR/CyberFSR.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@
<AdditionalDependencies>vulkan-1.lib;ffx_fsr2_api_x64.lib;ffx_fsr2_api_dx12_x64.lib;ffx_fsr2_api_vk_x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
<PreBuildEvent>
<Command>call "..\BuildFSR2.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Clear and rebuildall FSR2 artifacts</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Config.h" />
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ WINEPREFIX=/path/where/the/steam/library/is/steamapps/compatdata/1091500/pfx /bi

### Instructions
* Clone this repo with all of its submodules.
* Compile the FSR 2.0 submodule in external/FidelityFX-FSR2 as instructed in [official documentation](https://github.com/GPUOpen-Effects/FidelityFX-FSR2#quick-start-checklist). Note: I used the GenerateSolutionsDLL.bat but I am sure static libraries will work fine too.
* Open the CyberFSR.sln with Visual Studio 2022.
* Hit Compile in VS2022, if you compiled the FSR2 in Debug mode, compile CyberFSR in Debug mode, and if you compiled the FSR2 DLLs in Release mode, do the same in CyberFSR. This will result in a DLL in either `[root]/x64/Debug/CyberFSR.dll` or `[root]/x64/Release/nvngx.dll`.
* Copy the compiled `ffx_fsr2_api_dx12_x64.dll` and `ffx_fsr2_api_x64.dll` from the FidelityFX Directory to your Cyberpunk 2077 executable directory.
* Hit Compile in VS2022. This will result in a DLL in either `[root]/x64/Debug/CyberFSR.dll` or `[root]/x64/Release/nvngx.dll`.
* Rename the compiled DLL from two steps ago to `nvngx.dll` if it is `CyberFSR.dll`.
* Copy `nvngx.dll` to your Cyberpunk 2077 executable directory.
* Run the `EnableSignatureOverride.reg` to allow Cyberpunks DLSS implementation to load unsigned DLSS versions
Expand Down

0 comments on commit 21abf07

Please sign in to comment.