Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 30957e3

Browse files
committed
Support RDR2
1 parent 39d1e61 commit 30957e3

File tree

11 files changed

+269
-18
lines changed

11 files changed

+269
-18
lines changed

CyberFSR.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.2.32602.215
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CyberFSR", "CyberFSR\CyberFSR.vcxproj", "{8D2B73FB-EECD-45CE-B8E5-335610462F58}"
77
EndProject
8+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvngxLoader", "nvngxLoader\nvngxLoader.vcxproj", "{9033F8A6-879A-4FF1-A374-3F089856B05C}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|x64 = Debug|x64
@@ -21,6 +23,14 @@ Global
2123
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x64.Build.0 = Release|x64
2224
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x86.ActiveCfg = Release|Win32
2325
{8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x86.Build.0 = Release|Win32
26+
{9033F8A6-879A-4FF1-A374-3F089856B05C}.Debug|x64.ActiveCfg = Debug|x64
27+
{9033F8A6-879A-4FF1-A374-3F089856B05C}.Debug|x64.Build.0 = Debug|x64
28+
{9033F8A6-879A-4FF1-A374-3F089856B05C}.Debug|x86.ActiveCfg = Debug|Win32
29+
{9033F8A6-879A-4FF1-A374-3F089856B05C}.Debug|x86.Build.0 = Debug|Win32
30+
{9033F8A6-879A-4FF1-A374-3F089856B05C}.Release|x64.ActiveCfg = Release|x64
31+
{9033F8A6-879A-4FF1-A374-3F089856B05C}.Release|x64.Build.0 = Release|x64
32+
{9033F8A6-879A-4FF1-A374-3F089856B05C}.Release|x86.ActiveCfg = Release|Win32
33+
{9033F8A6-879A-4FF1-A374-3F089856B05C}.Release|x86.Build.0 = Release|Win32
2434
EndGlobalSection
2535
GlobalSection(SolutionProperties) = preSolution
2636
HideSolutionNode = FALSE

CyberFSR/Dx12ParameterImpl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ void Dx12ParameterImpl::Set(const char* InName, float InValue)
2424
JitterOffsetY = InValue;
2525
break;
2626
case Util::NvParameter::Sharpness:
27-
Sharpness = InValue;
27+
if (InValue >= 1.0f) {
28+
Sharpness = 1;
29+
}
30+
else {
31+
Sharpness = (InValue + 0.99f) / 2.0f;
32+
}
2833
break;
2934
}
3035
}

CyberFSR/ViewMatrixHook.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,8 @@
33

44
ViewMatrixHook::ViewMatrixHook()
55
{
6-
//TODO check for different executable versions
7-
8-
/*
9-
Protip for future self to get the offsets, search for the vertical FOV to get the structure, then look for references to that structure and afterwards look for static references
10-
*/
11-
12-
auto mod = (uint64_t)GetModuleHandleW(L"Cyberpunk2077.exe");
13-
auto ptr1 = *((uintptr_t*)(mod + 0x4B6F888));
14-
camParams = ((CameraParams*)(ptr1 + 0x60));
6+
uintptr_t mod = (uintptr_t)GetModuleHandle(NULL);
7+
camParams = (CameraParams*)(mod + 0x3E806E0);
158
}
169

1710
float ViewMatrixHook::GetFov()

CyberFSR/ViewMatrixHook.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
struct CameraParams
44
{
5-
unsigned char unknown0[0x20];
65
float FoV;
7-
unsigned char unknown1[0x1C];
86
float NearPlane;
97
float FarPlane;
108
};

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# FidelityFx Super Resolution 2.0 for Cyberpunk 2077
1+
# FidelityFx Super Resolution 2.0 for Red Dead Redemption 2
22

3-
This mod is a library for Cyberpunk which replaces Nvidia DLSS with AMD FidelityFX Super Resolution 2.0
3+
This mod is a library for RDR2 which replaces Nvidia DLSS with AMD FidelityFX Super Resolution 2.0
44

55
## Compilation
66

77
* Clone this repo including all submodules
88
* Compile the FSR 2.0 submodule in external/FidelityFX-FSR2 like it is described in their Readme 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
99
* Open the CyberFSR.sln with Visual Studio 2022
10-
* Hit Compile
11-
* Copy the compiled DLL, ffx_fsr2_api_dx12_x64.dll and ffx_fsr2_api_x64.dll from the FidelityFX Directory to your Cyberpunk 2077 executable directory.
12-
* Rename the compiled DLL to nvngx.dll
13-
* Run the EnableSignatureOverride.reg to allow Cyberpunks DLSS implementation to load unsigned DLSS versions
10+
* Compile the entire solution
11+
* Copy the compiled DLLs (nvngx.dll & d3d11.dll), ffx_fsr2_api_dx12_x64.dll and ffx_fsr2_api_x64.dll from the FidelityFX Directory to your RDR2 executable directory
12+
* Run the EnableSignatureOverride.reg to allow RDR2s DLSS implementation to load unsigned DLSS versions
1413
* Run the game and set the quality in the DLSS settings
1514
* Play the game with FSR 2.0
15+
16+
## Advisory
17+
* Like all mods for Rockstar games, please avoid using this online as I am unsure if you will get banned.

nvngxLoader/dllmain.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// dllmain.cpp : Defines the entry point for the DLL application.
2+
#include "pch.h"
3+
#include <Windows.h>
4+
5+
void Patch() {
6+
DWORD jzAddress = 0x26C4CCD;
7+
uintptr_t base = (uintptr_t)GetModuleHandle(NULL);
8+
*(BYTE*)(base + jzAddress) = 0x85; //JZ > JNZ
9+
}
10+
11+
BOOL APIENTRY DllMain( HMODULE hModule,
12+
DWORD ul_reason_for_call,
13+
LPVOID lpReserved
14+
)
15+
{
16+
switch (ul_reason_for_call)
17+
{
18+
case DLL_PROCESS_ATTACH:
19+
Patch();
20+
case DLL_THREAD_ATTACH:
21+
case DLL_THREAD_DETACH:
22+
case DLL_PROCESS_DETACH:
23+
break;
24+
}
25+
return TRUE;
26+
}
27+

nvngxLoader/framework.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
3+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
4+
// Windows Header Files
5+
#include <windows.h>

nvngxLoader/nvngxLoader.vcxproj

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{9033f8a6-879a-4ff1-a374-3f089856b05c}</ProjectGuid>
25+
<RootNamespace>nvngxLoader</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>DynamicLibrary</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>DynamicLibrary</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>DynamicLibrary</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v143</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>DynamicLibrary</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
74+
<TargetName>d3d11</TargetName>
75+
</PropertyGroup>
76+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
77+
<ClCompile>
78+
<WarningLevel>Level3</WarningLevel>
79+
<SDLCheck>true</SDLCheck>
80+
<PreprocessorDefinitions>WIN32;_DEBUG;NVNGXLOADER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
81+
<ConformanceMode>true</ConformanceMode>
82+
<PrecompiledHeader>Use</PrecompiledHeader>
83+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
84+
</ClCompile>
85+
<Link>
86+
<SubSystem>Windows</SubSystem>
87+
<GenerateDebugInformation>true</GenerateDebugInformation>
88+
<EnableUAC>false</EnableUAC>
89+
</Link>
90+
</ItemDefinitionGroup>
91+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
92+
<ClCompile>
93+
<WarningLevel>Level3</WarningLevel>
94+
<FunctionLevelLinking>true</FunctionLevelLinking>
95+
<IntrinsicFunctions>true</IntrinsicFunctions>
96+
<SDLCheck>true</SDLCheck>
97+
<PreprocessorDefinitions>WIN32;NDEBUG;NVNGXLOADER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
98+
<ConformanceMode>true</ConformanceMode>
99+
<PrecompiledHeader>Use</PrecompiledHeader>
100+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
101+
</ClCompile>
102+
<Link>
103+
<SubSystem>Windows</SubSystem>
104+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
105+
<OptimizeReferences>true</OptimizeReferences>
106+
<GenerateDebugInformation>true</GenerateDebugInformation>
107+
<EnableUAC>false</EnableUAC>
108+
</Link>
109+
</ItemDefinitionGroup>
110+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
111+
<ClCompile>
112+
<WarningLevel>Level3</WarningLevel>
113+
<SDLCheck>true</SDLCheck>
114+
<PreprocessorDefinitions>_DEBUG;NVNGXLOADER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
115+
<ConformanceMode>true</ConformanceMode>
116+
<PrecompiledHeader>Use</PrecompiledHeader>
117+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
118+
</ClCompile>
119+
<Link>
120+
<SubSystem>Windows</SubSystem>
121+
<GenerateDebugInformation>true</GenerateDebugInformation>
122+
<EnableUAC>false</EnableUAC>
123+
</Link>
124+
</ItemDefinitionGroup>
125+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
126+
<ClCompile>
127+
<WarningLevel>Level3</WarningLevel>
128+
<FunctionLevelLinking>true</FunctionLevelLinking>
129+
<IntrinsicFunctions>true</IntrinsicFunctions>
130+
<SDLCheck>true</SDLCheck>
131+
<PreprocessorDefinitions>NDEBUG;NVNGXLOADER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
132+
<ConformanceMode>true</ConformanceMode>
133+
<PrecompiledHeader>Use</PrecompiledHeader>
134+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
135+
</ClCompile>
136+
<Link>
137+
<SubSystem>Windows</SubSystem>
138+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
139+
<OptimizeReferences>true</OptimizeReferences>
140+
<GenerateDebugInformation>true</GenerateDebugInformation>
141+
<EnableUAC>false</EnableUAC>
142+
</Link>
143+
</ItemDefinitionGroup>
144+
<ItemGroup>
145+
<ClInclude Include="framework.h" />
146+
<ClInclude Include="pch.h" />
147+
</ItemGroup>
148+
<ItemGroup>
149+
<ClCompile Include="dllmain.cpp" />
150+
<ClCompile Include="pch.cpp">
151+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
152+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
153+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
154+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
155+
</ClCompile>
156+
</ItemGroup>
157+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
158+
<ImportGroup Label="ExtensionTargets">
159+
</ImportGroup>
160+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="framework.h">
19+
<Filter>Header Files</Filter>
20+
</ClInclude>
21+
<ClInclude Include="pch.h">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
</ItemGroup>
25+
<ItemGroup>
26+
<ClCompile Include="dllmain.cpp">
27+
<Filter>Source Files</Filter>
28+
</ClCompile>
29+
<ClCompile Include="pch.cpp">
30+
<Filter>Source Files</Filter>
31+
</ClCompile>
32+
</ItemGroup>
33+
</Project>

nvngxLoader/pch.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// pch.cpp: source file corresponding to the pre-compiled header
2+
3+
#include "pch.h"
4+
5+
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

0 commit comments

Comments
 (0)