Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fa48c11
feat: added streamline
doodlum Sep 2, 2024
b17f83c
feat: streamline partial cmakelist
doodlum Sep 2, 2024
28e68b8
feat: streamline swapchain
doodlum Sep 2, 2024
fd043ec
style: 🎨 apply clang-format changes
doodlum Sep 2, 2024
2faab5b
feat: init streamline
doodlum Sep 2, 2024
c09191d
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 2, 2024
d85e04e
fix: typo
doodlum Sep 2, 2024
55b7c69
feat: more streamline setup
doodlum Sep 2, 2024
9c63c93
style: 🎨 apply clang-format changes
doodlum Sep 2, 2024
0510a05
feat: frame generation working but still broken
doodlum Sep 3, 2024
b1c9573
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 3, 2024
1625a02
style: 🎨 apply clang-format changes
doodlum Sep 3, 2024
14ad555
feat: functional DLSSG
doodlum Sep 3, 2024
e20a7ee
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 3, 2024
0290b3a
style: 🎨 apply clang-format changes
doodlum Sep 3, 2024
cee79c3
chore: disable reflex sleep since not needed
doodlum Sep 3, 2024
7824321
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 3, 2024
2311366
chore: streamline cleanup and fixes
doodlum Sep 3, 2024
73f6037
style: 🎨 apply clang-format changes
doodlum Sep 3, 2024
05ff3ad
feat: include streamline dll files with licence
doodlum Sep 3, 2024
6291690
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 3, 2024
285d663
chore: cleanup streamline files, auto dlssg
doodlum Sep 3, 2024
ef7045d
style: 🎨 apply clang-format changes
doodlum Sep 3, 2024
63bc30f
fix: try to prevent memory leak
doodlum Sep 3, 2024
5bc4a1a
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 3, 2024
c781171
fix: remove accidentally included files
doodlum Sep 3, 2024
7a57116
fix: detect DLSSG compatibility
doodlum Sep 3, 2024
70c29cf
style: 🎨 apply clang-format changes
doodlum Sep 3, 2024
2b28271
fix: motion vectors when the game is paused
doodlum Sep 3, 2024
2409b72
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 3, 2024
29175b5
feat: RCAS sharpening
doodlum Sep 5, 2024
3b53ee9
fix: incorrect hooking behaviour
doodlum Sep 5, 2024
36f662f
style: 🎨 apply clang-format changes
doodlum Sep 5, 2024
cf9bb89
fix: detect if the DLSSG feature is loaded before querying it further
doodlum Sep 5, 2024
5e6358b
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 5, 2024
2624e19
fix: typo
doodlum Sep 5, 2024
dcc9485
style: 🎨 apply clang-format changes
doodlum Sep 5, 2024
c281214
fix: RCAS color space and intensity
doodlum Sep 5, 2024
b646ffc
feat: DLSS menu following guidelines
doodlum Sep 5, 2024
e2bc799
style: 🎨 apply clang-format changes
doodlum Sep 5, 2024
d563888
feat: FSR 2.2.1
doodlum Sep 6, 2024
b29a874
Merge branch 'streamline' of https://github.com/doodlum/skyrim-commun…
doodlum Sep 6, 2024
0380fea
style: 🎨 apply clang-format changes
doodlum Sep 6, 2024
47053f3
feat: remove FSR, separate frame generation to a feature, upscaler co…
doodlum Sep 7, 2024
91fb7de
chore: remove unused submodules
doodlum Sep 7, 2024
6d0efb5
fix: do not apply d3d hooks to VR
doodlum Sep 8, 2024
bf9da03
fix: only show streamline menu on flatrim
doodlum Sep 8, 2024
caf6f4f
fix: missing streamline shader
doodlum Sep 8, 2024
667d208
refactor: move streamline includes to forked submodule (#507)
FlayaN Sep 9, 2024
46ea029
fix: vr menu hook
doodlum Sep 11, 2024
a66b49e
style: 🎨 apply clang-format changes
doodlum Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[submodule "extern/CommonLibSSE-NG"]
path = extern/CommonLibSSE-NG
url = https://github.com/alandtse/CommonLibVR.git
[submodule "extern/NVAPI"]
path = extern/NVAPI
url = https://github.com/NVIDIA/nvapi.git

[submodule "extern/Streamline"]
path = extern/Streamline
url = https://github.com/FlayaN/Streamline.git
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ find_package(cppwinrt CONFIG REQUIRED)
find_package(unordered_dense CONFIG REQUIRED)
find_package(efsw CONFIG REQUIRED)
find_package(Tracy CONFIG REQUIRED)

set(NVAPI_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/extern/nvapi/" CACHE STRING "Path to NVAPI include headers/shaders" )
set(NVAPI_LIBRARY "${CMAKE_SOURCE_DIR}/extern/nvapi/amd64/nvapi64.lib" CACHE STRING "Path to NVAPI .lib file")
add_subdirectory(${CMAKE_SOURCE_DIR}/cmake/Streamline)

target_compile_definitions(
${PROJECT_NAME}
Expand All @@ -58,7 +56,6 @@ target_include_directories(
PRIVATE
${BSHOSHANY_THREAD_POOL_INCLUDE_DIRS}
${CLIB_UTIL_INCLUDE_DIRS}
${NVAPI_INCLUDE_DIR}
)

target_link_libraries(
Expand All @@ -78,7 +75,7 @@ target_link_libraries(
unordered_dense::unordered_dense
efsw::efsw
Tracy::TracyClient
${NVAPI_LIBRARY}
Streamline
)

# https://gitlab.kitware.com/cmake/cmake/-/issues/24922#note_1371990
Expand Down
10 changes: 10 additions & 0 deletions cmake/Streamline/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.21)

add_library(Streamline INTERFACE)

target_include_directories(
Streamline INTERFACE ${CMAKE_SOURCE_DIR}/extern/Streamline/include)

if(MSVC)
target_compile_options(Streamline INTERFACE /wd5103)
endif()
1 change: 0 additions & 1 deletion extern/NVAPI
Submodule NVAPI deleted from 3a83ef
1 change: 1 addition & 0 deletions extern/Streamline
Submodule Streamline added at f465f4

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2022 NVIDIA CORPORATION. All rights reserved
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
21 changes: 21 additions & 0 deletions package/SKSE/Plugins/Streamline/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2022 NVIDIA CORPORATION. All rights reserved
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Binary file added package/SKSE/Plugins/Streamline/sl.common.dll
Binary file not shown.
Binary file not shown.
Binary file added package/SKSE/Plugins/Streamline/sl.reflex.dll
Binary file not shown.
7 changes: 7 additions & 0 deletions package/Shaders/Streamline/CopyDepthToSharedBufferCS.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Texture2D<float> InputTexture : register(t0);
RWTexture2D<float> OutputTexture : register(u0);

[numthreads(8, 8, 1)] void main(uint3 DTid
: SV_DispatchThreadID) {
OutputTexture[DTid.xy] = InputTexture[DTid.xy];
}
65 changes: 47 additions & 18 deletions src/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "ShaderTools/BSShaderHooks.h"

#include "Streamline.h"

std::unordered_map<void*, std::pair<std::unique_ptr<uint8_t[]>, size_t>> ShaderBytecodeMap;

void RegisterShaderBytecode(void* Shader, const void* Bytecode, size_t BytecodeLength)
Expand Down Expand Up @@ -148,6 +150,7 @@ HRESULT WINAPI hk_IDXGISwapChain_Present(IDXGISwapChain* This, UINT SyncInterval
{
State::GetSingleton()->Reset();
Menu::GetSingleton()->DrawOverlay();
Streamline::GetSingleton()->Present();
auto retval = (This->*ptr_IDXGISwapChain_Present)(SyncInterval, Flags);
TracyD3D11Collect(State::GetSingleton()->tracyCtx);
return retval;
Expand Down Expand Up @@ -186,43 +189,65 @@ HRESULT STDMETHODCALLTYPE hk_CreatePixelShader(ID3D11Device* This, const void* p
return hr;
}

decltype(&CreateDXGIFactory) ptrCreateDXGIFactory;

HRESULT WINAPI hk_CreateDXGIFactory(REFIID, void** ppFactory)
{
logger::info("Creating DXGI factory");

return Streamline::GetSingleton()->CreateDXGIFactory(__uuidof(IDXGIFactory1), ppFactory);
}

decltype(&D3D11CreateDeviceAndSwapChain) ptrD3D11CreateDeviceAndSwapChain;

HRESULT WINAPI hk_D3D11CreateDeviceAndSwapChain(
IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
[[maybe_unused]] const D3D_FEATURE_LEVEL* pFeatureLevels,
[[maybe_unused]] UINT FeatureLevels,
const D3D_FEATURE_LEVEL* pFeatureLevels,
UINT FeatureLevels,
UINT SDKVersion,
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IDXGISwapChain** ppSwapChain,
ID3D11Device** ppDevice,
[[maybe_unused]] D3D_FEATURE_LEVEL* pFeatureLevel,
D3D_FEATURE_LEVEL* pFeatureLevel,
ID3D11DeviceContext** ppImmediateContext)
{
logger::info("Upgrading D3D11 feature level to 11.1");
//Flags |= D3D11_CREATE_DEVICE_DEBUG;
Comment thread
doodlum marked this conversation as resolved.

const D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_1; // Create a device with only the latest feature level
bool streamlineProxy = false;

#ifndef NDEBUG
Flags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

HRESULT hr = (*ptrD3D11CreateDeviceAndSwapChain)(
auto hr = Streamline::GetSingleton()->CreateDeviceAndSwapChain(
pAdapter,
DriverType,
Software,
Flags,
&featureLevel,
1,
pFeatureLevels,
FeatureLevels,
SDKVersion,
pSwapChainDesc,
ppSwapChain,
ppDevice,
nullptr,
ppImmediateContext);
pFeatureLevel,
ppImmediateContext,
streamlineProxy);

if (!streamlineProxy) {
hr = (*ptrD3D11CreateDeviceAndSwapChain)(
pAdapter,
DriverType,
Software,
Flags,
pFeatureLevels,
FeatureLevels,
SDKVersion,
pSwapChainDesc,
ppSwapChain,
ppDevice,
pFeatureLevel,
ppImmediateContext);
}

return hr;
}
Expand Down Expand Up @@ -575,10 +600,6 @@ namespace Hooks
logger::info("Hooking WndProcHandler");
stl::write_thunk_call_6<RegisterClassA_Hook>(REL::VariantID(75591, 77226, 0xDC4B90).address() + REL::VariantOffset(0x8E, 0x15C, 0x99).offset());

//logger::info("Hooking D3D11CreateDeviceAndSwapChain");
//*(FARPROC*)&ptrD3D11CreateDeviceAndSwapChain = GetProcAddress(GetModuleHandleA("d3d11.dll"), "D3D11CreateDeviceAndSwapChain");
//SKSE::PatchIAT(hk_D3D11CreateDeviceAndSwapChain, "d3d11.dll", "D3D11CreateDeviceAndSwapChain");

logger::info("Hooking BSShaderRenderTargets::Create");
*(uintptr_t*)&ptr_BSShaderRenderTargets_Create = Detours::X64::DetourFunction(REL::RelocationID(100458, 107175).address(), (uintptr_t)&hk_BSShaderRenderTargets_Create);

Expand All @@ -604,4 +625,12 @@ namespace Hooks
logger::info("Hooking Renderer::DispatchCSShader");
*(uintptr_t*)&CSShadersSupport::ptr_Renderer_DispatchCSShader = Detours::X64::DetourFunction(REL::RelocationID(75532, 77329).address(), (uintptr_t)&CSShadersSupport::hk_Renderer_DispatchCSShader);
}
void InstallD3DHooks()
{
logger::info("Hooking D3D11CreateDeviceAndSwapChain");
*(uintptr_t*)&ptrD3D11CreateDeviceAndSwapChain = SKSE::PatchIAT(hk_D3D11CreateDeviceAndSwapChain, "d3d11.dll", "D3D11CreateDeviceAndSwapChain");

logger::info("Hooking CreateDXGIFactory");
*(uintptr_t*)&ptrCreateDXGIFactory = SKSE::PatchIAT(hk_CreateDXGIFactory, "dxgi.dll", "CreateDXGIFactory");
}
}
1 change: 1 addition & 0 deletions src/Hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ namespace Hooks
{
bool hk_BSShader_BeginTechnique(RE::BSShader* shader, uint32_t vertexDescriptor, uint32_t pixelDescriptor, bool skipPixelShader);
void Install();
void InstallD3DHooks();
}
7 changes: 5 additions & 2 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "Deferred.h"
#include "TruePBR.h"

#include "VariableRateShading.h"
#include "Streamline.h"

#define SETTING_MENU_TOGGLEKEY "Toggle Key"
#define SETTING_MENU_SKIPKEY "Skip Compilation Key"
Expand Down Expand Up @@ -166,7 +166,6 @@ void Menu::DrawSettings()
if (ImGui::Button("Clear Shader Cache", { -1, 0 })) {
shaderCache.Clear();
Deferred::GetSingleton()->ClearShaderCache();
VariableRateShading::GetSingleton()->ClearShaderCache();
for (auto* feature : Feature::GetFeatureList()) {
if (feature->loaded) {
feature->ClearShaderCache();
Expand Down Expand Up @@ -457,6 +456,10 @@ void Menu::DrawSettings()

ImGui::Separator();

Streamline::GetSingleton()->DrawSettings();

ImGui::Separator();

if (ImGui::BeginTable("Feature Table", 2, ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_Resizable)) {
ImGui::TableSetupColumn("##ListOfFeatures", 0, 3);
ImGui::TableSetupColumn("##FeatureConfig", 0, 7);
Expand Down
7 changes: 3 additions & 4 deletions src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Features/TerrainBlending.h"
#include "TruePBR.h"

#include "VariableRateShading.h"
#include "Streamline.h"

void State::Draw()
{
Expand All @@ -38,7 +38,6 @@ void State::Draw()
}
}

VariableRateShading::GetSingleton()->UpdateViews(type != RE::BSShader::Type::ImageSpace && type != RE::BSShader::Type::Sky && type != RE::BSShader::Type::Water);
if (type > 0 && type < RE::BSShader::Type::Total) {
if (enabledClasses[type - 1]) {
// Only check against non-shader bits
Expand Down Expand Up @@ -91,7 +90,6 @@ void State::Reset()
feature->Reset();
if (!RE::UI::GetSingleton()->GameIsPaused())
timer += RE::GetSecondsSinceLastFrame();
VariableRateShading::GetSingleton()->UpdateVRS();
lastModifiedPixelDescriptor = 0;
lastModifiedVertexDescriptor = 0;
lastPixelDescriptor = 0;
Expand All @@ -107,9 +105,9 @@ void State::Setup()
if (feature->loaded)
feature->SetupResources();
Deferred::GetSingleton()->SetupResources();
Streamline::GetSingleton()->SetupFrameGeneration();
if (initialized)
return;
VariableRateShading::GetSingleton()->Setup();
initialized = true;
}

Expand Down Expand Up @@ -273,6 +271,7 @@ void State::PostPostLoad()
logger::info("Skyrim Upscaler not detected");
Deferred::Hooks::Install();
TruePBR::GetSingleton()->PostPostLoad();
Streamline::InstallHooks();
}

bool State::ValidateCache(CSimpleIniA& a_ini)
Expand Down
Loading