DLSS fails to enable for D3D11 / NGX DLSS Context cannot run

Hi,

I am trying to implement DLSS (not DLSSG, so ignore those parts!) for Skyrim Community Shaders and I struggle to make Streamline DLSS work.

I would love some assistance in deciphering the streamline log more, as I am at my wits end on how to investigate this further. I have attached the log and also the cpp code (which is currently a tad messy).

Running on a 4090, drivers 2 weeks old. So DLSS support is there.

This post is a bit of a hailmary - otherwise we might drop dlss and just stick with the frame generation, I am happy to provide further details. Thanks in adance for anyone who takes the time.

[2024-09-22 10:31:53.917] [info] [41392] [Hooks.cpp:196] Creating DXGI factory
[2024-09-22 10:31:53.941] [info] [41392] [Streamline.cpp:199] [Streamline] Succeeded to verify digital signature of sl.interposer.dll
[2024-09-22 10:31:53.943] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]pluginmanager.cpp:99[setHostSDKVersion] Streamline v2.0.1.c7f40186 - built on Wed Apr 19 22:02:52 2023 - host SDK v2.0.1

[2024-09-22 10:31:53.943] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]pluginmanager.cpp:461[findPlugins] Looking for plugins in Data/SKSE/Plugins/Streamline ...

[2024-09-22 10:31:53.949] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]commoninterface.cpp:140[getSystemCaps] Enumerating up to 8 adapters but only one of them can be used to create a device - no mGPU support in this SDK

[2024-09-22 10:31:53.966] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]commoninterface.cpp:258[getSystemCaps] >-----------------------------------------

[2024-09-22 10:31:53.966] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]commoninterface.cpp:261[getSystemCaps] NVIDIA driver 561.9

[2024-09-22 10:31:53.969] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]commoninterface.cpp:286[getSystemCaps] Adapter 0 architecture 0x190 implementation 0x2 revision 0xa1 - bit 0x1 - LUID 0.66200

[2024-09-22 10:31:53.969] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]commoninterface.cpp:292[getSystemCaps] -----------------------------------------<

[2024-09-22 10:31:53.970] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]commonentry.cpp:1486[getOSVersionAndUpdateTimerResolution] Changed high resolution timer resolution to 5000 [100 ns units]

[2024-09-22 10:31:53.970] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]commonentry.cpp:1560[updateEmbeddedJSON] Detected Windows OS version 10.0.22631

[2024-09-22 10:31:53.970] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-53][streamline][info]pluginmanager.cpp:657[mapPlugins] Loaded plugin 'sl.common' - version 2.0.1.c7f40186 - id 4294967295 - priority 0 - adapter mask 0x3 - interposer 'no'

[2024-09-22 10:31:54.484] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:710[getNGXFeatureRequirements] NGX feature 1 requirements - minOS 10.0.0 minHW 0x160

[2024-09-22 10:31:54.484] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:1015[updateCommonEmbeddedJSONConfig] Registering required tag 'kBufferTypeDepth' life-cycle 'ResourceLifecycle::eValidUntilEvaluate' for feature `kFeatureDLSS`

[2024-09-22 10:31:54.484] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:1015[updateCommonEmbeddedJSONConfig] Registering required tag 'kBufferTypeMotionVectors' life-cycle 'ResourceLifecycle::eValidUntilEvaluate' for feature `kFeatureDLSS`

[2024-09-22 10:31:54.484] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:1015[updateCommonEmbeddedJSONConfig] Registering required tag 'kBufferTypeScalingInputColor' life-cycle 'ResourceLifecycle::eValidUntilEvaluate' for feature `kFeatureDLSS`

[2024-09-22 10:31:54.484] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:1015[updateCommonEmbeddedJSONConfig] Registering required tag 'kBufferTypeScalingOutputColor' life-cycle 'ResourceLifecycle::eValidUntilEvaluate' for feature `kFeatureDLSS`

[2024-09-22 10:31:54.484] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]pluginmanager.cpp:657[mapPlugins] Loaded plugin 'sl.dlss' - version 2.0.1.c7f40186 - id 0 - priority 100 - adapter mask 0x1 - interposer 'no'

[2024-09-22 10:31:54.831] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:710[getNGXFeatureRequirements] NGX feature 11 requirements - minOS 10.0.19041 minHW 0x190

[2024-09-22 10:31:54.831] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:1015[updateCommonEmbeddedJSONConfig] Registering required tag 'kBufferTypeDepth' life-cycle 'ResourceLifecycle::eValidUntilPresent' for feature `kFeatureDLSS_G`

[2024-09-22 10:31:54.831] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:1015[updateCommonEmbeddedJSONConfig] Registering required tag 'kBufferTypeMotionVectors' life-cycle 'ResourceLifecycle::eValidUntilPresent' for feature `kFeatureDLSS_G`

[2024-09-22 10:31:54.831] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:1015[updateCommonEmbeddedJSONConfig] Registering required tag 'kBufferTypeHUDLessColor' life-cycle 'ResourceLifecycle::eValidUntilPresent' for feature `kFeatureDLSS_G`

[2024-09-22 10:31:54.831] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]commonentry.cpp:1015[updateCommonEmbeddedJSONConfig] Registering required tag 'kBufferTypeUIColorAndAlpha' life-cycle 'ResourceLifecycle::eValidUntilPresent' for feature `kFeatureDLSS_G`

[2024-09-22 10:31:54.832] [warning] [47328] [Streamline.cpp:23] [22.09.2024 10-31-54][streamline][warn]pluginmanager.cpp:602[mapPlugins] Ignoring plugin 'sl.dlss_g' since it is was not requested by the host

[2024-09-22 10:31:54.837] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]pluginmanager.cpp:657[mapPlugins] Loaded plugin 'sl.reflex' - version 2.0.1.c7f40186 - id 3 - priority 100 - adapter mask 0x3 - interposer 'no'

[2024-09-22 10:31:54.837] [info] [41392] [Streamline.cpp:242] [Streamline] Successfully initialized Streamline
[2024-09-22 10:31:54.837] [info] [41392] [Streamline.cpp:339] [Streamline] Proxying CreateDXGIFactory
[2024-09-22 10:31:54.837] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]pluginmanager.cpp:865[loadPlugins] Plugin execution order based on priority:

[2024-09-22 10:31:54.837] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]pluginmanager.cpp:868[loadPlugins] P0 - sl.common

[2024-09-22 10:31:54.837] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]pluginmanager.cpp:868[loadPlugins] P100 - sl.dlss

[2024-09-22 10:31:54.837] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]pluginmanager.cpp:868[loadPlugins] P100 - sl.reflex

[2024-09-22 10:31:54.838] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-54][streamline][info]dxgi.cpp:323[CreateDXGIFactoryInternal] Injecting hooks into DXGI proxy virtual table

[2024-09-22 10:31:54.839] [info] [41392] [Streamline.cpp:360] [Streamline] Proxying D3D11CreateDeviceAndSwapChain
[2024-09-22 10:31:55.003] [warning] [47328] [Streamline.cpp:23] [22.09.2024 10-31-55][streamline][warn]d3d11.cpp:85[D3D11CreateDeviceAndSwapChain] Automatically assigning d3d11 device, if this is not desired please use `D3D11CreateDevice` followed by `slSetD3DDevice`

[2024-09-22 10:31:55.004] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1053[initializePlugins] Initializing plugins - api 0.0.1 - application ID 100721531

[2024-09-22 10:31:55.004] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]d3d11.cpp:334[init] GPU nodes 1 - visible node mask 1

[2024-09-22 10:31:55.005] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]d3d11.cpp:561[createKernel] Creating DXBC kernel copy.cs:main hash 16359366160719394762

[2024-09-22 10:31:55.005] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]d3d12.cpp:698[init] Detected DX11 on DX12 scenario

[2024-09-22 10:31:55.112] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]d3d12.cpp:1080[createKernel] Creating DXBC kernel copy_to_buffer.cs:main hash 12564409127886710297

[2024-09-22 10:31:55.112] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:1121[slOnPluginStartup] At least one plugin requires NGX, trying to initialize ...

[2024-09-22 10:31:55.112] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  App logging hooks successfully initialized

[2024-09-22 10:31:55.114] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Found matching adapter with NVAPI physical GPU handle: 0x100 and LUID: { 0x0, 0x10298 }

[2024-09-22 10:31:55.114] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Checking for key: NVSupportNGX, in the INF for GPU with physical handle: 0x100 and LUID: { 0x0, 0x10298 }

[2024-09-22 10:31:55.126] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  using path for models: C:\ProgramData/NVIDIA/NGX/models/

[2024-09-22 10:31:55.126] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  security attributes generated successfully

[2024-09-22 10:31:55.126] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  using generated security descriptor for creating folder at: C:\ProgramData\NVIDIA\NGX\models

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  updated access control list for NGX cache (NGX cache should now be usable by all authenticated users)

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  model folder created: C:\ProgramData/NVIDIA/NGX/models/

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [dlss]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_E658702=0.0.0

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_E658701=0.0.0

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9FEB50=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9FF4BC=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9FD524=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9DF510=1.3.106

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9CB0B8=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9E26B0=2.1.28

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9D48D0=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_E99B5EC=1.2.109

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9DFA64=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9FD6C0=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9CF688=2.2.15

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9D6F08=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9BF564=2.1.28

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9DB4F4=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9D2F5C=1.2.110

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9D7388=1.0.108

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9F5618=2.1.29

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9DAE68=1.2.109

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9D8C54=1.2.109

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_3AC09EF=2.5.1

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9D3EF0=2.1.28

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9FACDC=2.1.28

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_F7361DC=2.1.28

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9C3560=2.1.19

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9B0430=2.1.28

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_E658703=0.0.0

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_86DF0A0=3.1.11

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_8615228=2.4.2

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_8627C04=2.3.5

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9393FC=2.2.6

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_87D97FC=3.5.0

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_876232C=3.7.0

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_86AA7B4=2.3.11

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_86C2DA8=3.7.10

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9DB490=3.5.10

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_8708384=2.3.1

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [nvbcast_afx_rec_v0_7]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_E658703=0.7.1

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [dlisp]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9CF688=2.1.15

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_E99B5EC=1.2.102

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_E658703=1.0.101

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9D8C54=1.2.106

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9D2F5C=1.2.106

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9DF510=1.3.101

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9DAE68=1.2.106

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [nvbcast]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [nvbcast_vfx_gs_v0_7]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [sl_pcl_0]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [nvbcast_ar_fd_v0_7]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [nvbcast_afx_bnr_v0_7]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [dlssg]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_876232C=3.6.0

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_3AC09EF=3.5.0

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [nvbcast_afx_bnrrec_v0_7]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [dlssd]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app_B9DB490=3.5.0

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [nvbcast_vfx_lld_v0_7]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [nvbcast_ar_gw_v0_7]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [sl_reflex_0]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [sl_dlss_0]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [sl_common_0]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [sl_dlss_g_0]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  [sl_dlss_d_0]

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  listItem.engineVersion .* listItem.genericCMSId 86aa7b4

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]   project id 3F9D696D4363312194B0ECB2671E899F cms id B9FBD50

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  listItem.engineVersion .* listItem.genericCMSId 8618954

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  listItem.engineVersion .* listItem.genericCMSId b9b05cc

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  listItem.engineVersion .* listItem.genericCMSId 876232c

[2024-09-22 10:31:55.138] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  Found cms id 876232c for engine: custom engineVersion 1.0.0 projectID f8776929-c969-43bd-ac2b-294b4de58aac

[2024-09-22 10:31:55.204] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  DRS PROFILE FOUND : ProfileName "The Elder Scrolls V: Skyrim Special Edition", AppName "skyrimse.exe"

[2024-09-22 10:31:55.215] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  called from module sl.common.dll at G:\Lorerim\Stock Game\data\SKSE\Plugins\Streamline

[2024-09-22 10:31:55.227] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dldenoiser.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.238] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  nvLoadSignedLibraryW() failed on snippet 'Data/SKSE/Plugins/Streamline/nvngx_dlss.dll' missing or corrupted - last error One or more arguments are not correct.


[2024-09-22 10:31:55.239] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Validating snippet Data/SKSE/Plugins/Streamline/nvngx_dlss.dll

[2024-09-22 10:31:55.239] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  NGX CORE API version : 0x15, Snippet requires at least : 0x13

[2024-09-22 10:31:55.239] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  GPU architecture : 0x190, Snippet expects at least : 0x160

[2024-09-22 10:31:55.239] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Driver support flags : 0xF(SEAMLESS_OTA|LINUX_EXTENDED_DRIVER_VERSIONS|API_SPECIFIC_POPULATE_PARAMS|REQUIRE_CMSID), Snippet required flags : 0x0()

[2024-09-22 10:31:55.239] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Driver version : 561.9, Snippet expects at least : 512.15

[2024-09-22 10:31:55.239] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Snippet version : 3.1.11, Embedded app Id : E658703 (0)

[2024-09-22 10:31:55.239] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  unable to read the deny list. Assuming that the feature is allowed.

[2024-09-22 10:31:55.251] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlinpainting.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.262] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlisr.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.274] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlslowmo.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.285] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlvsr.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.296] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlcolorize.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.308] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlstyletransfer.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.319] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlvdenoiser.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.330] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlisp.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.342] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlresolve.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.353] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  nvLoadSignedLibraryW() failed on snippet 'Data/SKSE/Plugins/Streamline/nvngx_dlssg.dll' missing or corrupted - last error One or more arguments are not correct.


[2024-09-22 10:31:55.354] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  Querying GPU Architecture Failed - snippet 'Data/SKSE/Plugins/Streamline/nvngx_dlssg.dll' missing or corrupted

[2024-09-22 10:31:55.354] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  error: unable to load DLL metadata via FileVersionInfo for snippet 'Data/SKSE/Plugins/Streamline/nvngx_dlssg.dll'

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Loaded NGXCore from path (G:\Lorerim\Stock Game\data\SKSE\Plugins\Streamline/nvngx_dlssg.dll)

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Validating snippet G:\Lorerim\Stock Game\data\SKSE\Plugins\Streamline/nvngx_dlssg.dll

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  GPU architecture : 0x190, Snippet expects at least : 0x190

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Driver version : 561.9, Snippet expects at least : 520.0

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Snippet version : 3.6.0, Embedded app Id : E658703 (0)

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: skipping downloaded snippet due to lower version 3.6.0 < 3.6.0

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  app 876232C feature dlssg snippet: G:\Lorerim\Stock Game\data\SKSE\Plugins\Streamline/nvngx_dlssg.dll version: 3.6.0

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Setting show info tip callback for dlssg

[2024-09-22 10:31:55.367] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Setting telemetry callback for dlssg [schema 3.0+]

[2024-09-22 10:31:55.379] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_deepdvc.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.391] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_dlssd.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.402] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_truehdr.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.414] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: ModuleName - nvngx_vsr.dll doesn't exist in any of the search paths!

[2024-09-22 10:31:55.425] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Detected Windows Version 10.0.22621.4036

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Sending Telemetry Init Data

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  FeatureInitResult = NvNGXFeatureInitSuccess

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  appExeName = sl.common.dll

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  drsProfileName = The Elder Scrolls V: Skyrim Special Edition

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  drsName = skyrimse.exe

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  AppIdType = RENDERING_ENGINE

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  ProjectId = f8776929-c969-43bd-ac2b-294b4de58aac

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  EngineVersion = 1.0.0

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  EngineType = custom

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  cmsId = 0

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  featureType = FrameGeneration

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  gpuDeviceId = 9860

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  gpuVendorId = 4318

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  gpuSubSys = 1086264408

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  gpuRev = 161

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  ngxSDKVersion = 1.5

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  ngxCoreVersion = 1.4.0.1

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  ngxFeatureVersion = 3.6.0

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  displayDriverVersion = 561.9

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  osVersion = 10.0.22621.4036

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  APIType = 0

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  GpuAPI = 1

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  -- END telemetry init data --

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  NGXCore not found next to the application

[2024-09-22 10:31:55.426] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Checking for path to NGX using QueryAdapterInfo

[2024-09-22 10:31:55.427] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog]  Path to driverStore found using QAI: C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_dcf94619172aceb0

[2024-09-22 10:31:55.435] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  Loaded NGXCore from path (C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_dcf94619172aceb0\_nvngx.dll)

[2024-09-22 10:31:55.738] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  warning: attempted to initialize telemetry while already initialized

[2024-09-22 10:31:55.858] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog] [NGXInitLog:219] App logging hooks successfully initialized

[2024-09-22 10:31:55.858] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog] [NGXInitLog:226] Built with APP_NAME = default

[2024-09-22 10:31:55.858] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog] [NGXDLSSG::InitCommon:687] Calling debug config init!

[2024-09-22 10:31:55.858] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog] [NgxDlssgDebug::LoadKeyConfigJson:24] KeyConfigJson - not found at: ngx_keybinds.json
Using default hardcoded config...

[2024-09-22 10:31:55.858] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:891[ngxLog] [NGXDLSSG::InitCommon:691] Get snippet file version!

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:892[ngxLog]  GpuAPI = 2

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]commonentry.cpp:1247[slOnPluginStartup] NGX loaded - app id 100721531 - application data path C:\Users\simon\AppData\Local\Temp\

[2024-09-22 10:31:55.860] [warning] [47328] [Streamline.cpp:23] [22.09.2024 10-31-55][streamline][warn]commonentry.cpp:1251[slOnPluginStartup] Valid application id is required in production builds - allowing for now but please fix this

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1141[mapPluginCallbacks] Callback sl.common:slSetData:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1142[mapPluginCallbacks] Callback sl.common:slGetData:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1143[mapPluginCallbacks] Callback sl.common:slAllocateResources:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1144[mapPluginCallbacks] Callback sl.common:slFreeResources:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1145[mapPluginCallbacks] Callback sl.common:slEvaluateFeature:0x7ff8a2dc7400

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1146[mapPluginCallbacks] Callback sl.common:slSetTag:0x7ff8a2dc68b0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1147[mapPluginCallbacks] Callback sl.common:slSetConsts:0x7ff8a2dc7170

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:941[processPluginHooks] Hook sl.common:slHookVkPresent:before - skipped

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:941[processPluginHooks] Hook sl.common:slHookVkCmdBindPipeline:after - skipped

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:941[processPluginHooks] Hook sl.common:slHookVkCmdBindDescriptorSets:after - skipped

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:941[processPluginHooks] Hook sl.common:slHookVkBeginCommandBuffer:after - skipped

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:965[processPluginHooks] Hook sl.common:slHookResizeSwapChainPre:before - OK

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:965[processPluginHooks] Hook sl.common:slHookPresent:before - OK

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:965[processPluginHooks] Hook sl.common:slHookPresent1:before - OK

[2024-09-22 10:31:55.860] [error] [47328] [Streamline.cpp:26] [22.09.2024 10-31-55][streamline][error]dlssentry.cpp:898[slOnPluginStartup] NGX parameter indicating DLSSContext support cannot be found (0xbad00010) - DLSSContext cannot run

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1141[mapPluginCallbacks] Callback sl.reflex:slSetData:0x7ff89fea03a0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1142[mapPluginCallbacks] Callback sl.reflex:slGetData:0x7ff89fea0970

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1143[mapPluginCallbacks] Callback sl.reflex:slAllocateResources:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1144[mapPluginCallbacks] Callback sl.reflex:slFreeResources:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1145[mapPluginCallbacks] Callback sl.reflex:slEvaluateFeature:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1146[mapPluginCallbacks] Callback sl.reflex:slSetTag:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:1147[mapPluginCallbacks] Callback sl.reflex:slSetConsts:0x0

[2024-09-22 10:31:55.860] [info] [47328] [Streamline.cpp:20] [22.09.2024 10-31-55][streamline][info]pluginmanager.cpp:926[processPluginHooks] Plugin 'sl.reflex' has no registered hooks

[2024-09-22 10:31:55.870] [error] [41392] [Streamline.cpp:289] [Streamline] DLSS is not supported on this adapter: eErrorFeatureMissing
#define _WIN32_WINNT 0x0A00 // Windows 10 and later
#define NV_WINDOWS

#include <windows.h>
#include <wintrust.h>
#include <softpub.h>

#include "Streamline.h"
#include "sl.h"
#include "sl_result.h"
#include "sl_security.h"
#include <dxgi.h>

#include "Util.h"

void LoggingCallback(sl::LogType type, const char* msg)
{
    switch (type) {
    case sl::LogType::eInfo:
        logger::info("{}", msg);
        break;
    case sl::LogType::eWarn:
        logger::warn("{}", msg);
        break;
    case sl::LogType::eError:
        logger::error("{}", msg);
        break;
    }
}

void Streamline::DrawSettings()
{
    if (!REL::Module::IsVR()) {
        if (ImGui::CollapsingHeader("NVIDIA DLSS", ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) {
            if (streamlineActive) {
                ImGui::Text("Streamline uses a D3D11 to D3D12 proxy");
                ImGui::Text("Frame Generation always defaults to Auto");
                ImGui::Text("To disable Frame Generation, disable it in your mod manager");

                // const char* frameGenerationModes[] = { "Off", "On", "Auto" };
                // frameGenerationMode = (sl::DLSSGMode)std::min(2u, (uint)frameGenerationMode);
                // ImGui::SliderInt("Frame Generation", (int*)&frameGenerationMode, 0, 2, std::format("{}", frameGenerationModes[(uint)frameGenerationMode]).c_str());

                // Add DLSS mode selection
                const char* dlssModes[] = { "Off", "Ultra Performance", "Performance", "Balanced", "Quality", "Ultra Quality", "DLAA" };
                int dlssModeCount = sizeof(dlssModes) / sizeof(dlssModes[0]);
                int currentDlssMode = (int)dlssMode;
                ImGui::Combo("DLSS Mode", &currentDlssMode, dlssModes, dlssModeCount);
                dlssMode = (sl::DLSSMode)currentDlssMode;
            } else {
                ImGui::Text("Streamline uses a D3D11 to D3D12 proxy");
                ImGui::Text("Streamline is not active due to no available plugins");
                ImGui::Text("To enable Frame Generation, enable it in your mod manager");
            }
        }
    }
}

void Streamline::Shutdown()
{
    if (SL_FAILED(res, slShutdown())) {
        logger::error("[Streamline] Failed to shutdown Streamline");
    } else {
        logger::info("[Streamline] Successfully shutdown Streamline");
    }
}

#include "sl_result.h" // Ensure this header is included

const char* GetSLResultString(sl::Result result) {
    switch (result) {
        case sl::Result::eOk:
            return "eOk";
        case sl::Result::eErrorIO:
            return "eErrorIO";
        case sl::Result::eErrorDriverOutOfDate:
            return "eErrorDriverOutOfDate";
        case sl::Result::eErrorOSOutOfDate:
            return "eErrorOSOutOfDate";
        case sl::Result::eErrorOSDisabledHWS:
            return "eErrorOSDisabledHWS";
        case sl::Result::eErrorDeviceNotCreated:
            return "eErrorDeviceNotCreated";
        case sl::Result::eErrorNoSupportedAdapterFound:
            return "eErrorNoSupportedAdapterFound";
        case sl::Result::eErrorAdapterNotSupported:
            return "eErrorAdapterNotSupported";
        case sl::Result::eErrorNoPlugins:
            return "eErrorNoPlugins";
        case sl::Result::eErrorVulkanAPI:
            return "eErrorVulkanAPI";
        case sl::Result::eErrorDXGIAPI:
            return "eErrorDXGIAPI";
        case sl::Result::eErrorD3DAPI:
            return "eErrorD3DAPI";
        case sl::Result::eErrorNRDAPI:
            return "eErrorNRDAPI";
        case sl::Result::eErrorNVAPI:
            return "eErrorNVAPI";
        case sl::Result::eErrorReflexAPI:
            return "eErrorReflexAPI";
        case sl::Result::eErrorNGXFailed:
            return "eErrorNGXFailed";
        case sl::Result::eErrorJSONParsing:
            return "eErrorJSONParsing";
        case sl::Result::eErrorMissingProxy:
            return "eErrorMissingProxy";
        case sl::Result::eErrorMissingResourceState:
            return "eErrorMissingResourceState";
        case sl::Result::eErrorInvalidIntegration:
            return "eErrorInvalidIntegration";
        case sl::Result::eErrorMissingInputParameter:
            return "eErrorMissingInputParameter";
        case sl::Result::eErrorNotInitialized:
            return "eErrorNotInitialized";
        case sl::Result::eErrorComputeFailed:
            return "eErrorComputeFailed";
        case sl::Result::eErrorInitNotCalled:
            return "eErrorInitNotCalled";
        case sl::Result::eErrorExceptionHandler:
            return "eErrorExceptionHandler";
        case sl::Result::eErrorInvalidParameter:
            return "eErrorInvalidParameter";
        case sl::Result::eErrorMissingConstants:
            return "eErrorMissingConstants";
        case sl::Result::eErrorDuplicatedConstants:
            return "eErrorDuplicatedConstants";
        case sl::Result::eErrorMissingOrInvalidAPI:
            return "eErrorMissingOrInvalidAPI";
        case sl::Result::eErrorCommonConstantsMissing:
            return "eErrorCommonConstantsMissing";
        case sl::Result::eErrorUnsupportedInterface:
            return "eErrorUnsupportedInterface";
        case sl::Result::eErrorFeatureMissing:
            return "eErrorFeatureMissing";
        case sl::Result::eErrorFeatureNotSupported:
            return "eErrorFeatureNotSupported";
        case sl::Result::eErrorFeatureMissingHooks:
            return "eErrorFeatureMissingHooks";
        case sl::Result::eErrorFeatureFailedToLoad:
            return "eErrorFeatureFailedToLoad";
        case sl::Result::eErrorFeatureWrongPriority:
            return "eErrorFeatureWrongPriority";
        case sl::Result::eErrorFeatureMissingDependency:
            return "eErrorFeatureMissingDependency";
        case sl::Result::eErrorFeatureManagerInvalidState:
            return "eErrorFeatureManagerInvalidState";
        case sl::Result::eErrorInvalidState:
            return "eErrorInvalidState";
        case sl::Result::eWarnOutOfVRAM:
            return "eWarnOutOfVRAM";
        default:
            return "Unknown error";
    }
}

void Streamline::Initialize_postInit()
{
    // Retrieve other function pointers from the interposer
    slInit = (PFun_slInit*)GetProcAddress(interposer, "slInit");
    slShutdown = (PFun_slShutdown*)GetProcAddress(interposer, "slShutdown");
    slIsFeatureSupported = (PFun_slIsFeatureSupported*)GetProcAddress(interposer, "slIsFeatureSupported");
    slIsFeatureLoaded = (PFun_slIsFeatureLoaded*)GetProcAddress(interposer, "slIsFeatureLoaded");
    slSetFeatureLoaded = (PFun_slSetFeatureLoaded*)GetProcAddress(interposer, "slSetFeatureLoaded");
    slEvaluateFeature = (PFun_slEvaluateFeature*)GetProcAddress(interposer, "slEvaluateFeature");
    slAllocateResources = (PFun_slAllocateResources*)GetProcAddress(interposer, "slAllocateResources");
    slFreeResources = (PFun_slFreeResources*)GetProcAddress(interposer, "slFreeResources");
    slSetTag = (PFun_slSetTag*)GetProcAddress(interposer, "slSetTag");
    slGetFeatureRequirements = (PFun_slGetFeatureRequirements*)GetProcAddress(interposer, "slGetFeatureRequirements");
    slGetFeatureVersion = (PFun_slGetFeatureVersion*)GetProcAddress(interposer, "slGetFeatureVersion");
    slUpgradeInterface = (PFun_slUpgradeInterface*)GetProcAddress(interposer, "slUpgradeInterface");
    slSetConstants = (PFun_slSetConstants*)GetProcAddress(interposer, "slSetConstants");
    slGetNativeInterface = (PFun_slGetNativeInterface*)GetProcAddress(interposer, "slGetNativeInterface");
    slGetFeatureFunction = (PFun_slGetFeatureFunction*)GetProcAddress(interposer, "slGetFeatureFunction");
    slGetNewFrameToken = (PFun_slGetNewFrameToken*)GetProcAddress(interposer, "slGetNewFrameToken");
    slSetD3DDevice = (PFun_slSetD3DDevice*)GetProcAddress(interposer, "slSetD3DDevice");

    // Check for null pointers and handle errors
    if (!slShutdown || !slSetD3DDevice || !slIsFeatureLoaded || !slIsFeatureSupported || !slGetFeatureFunction) {
        logger::error("[Streamline] Failed to retrieve function pointers from interposer");
        streamlineActive = false;
        return;
    }
}

void Streamline::Initialize_preDevice()
{
    logger::debug("[Streamline] Initializing Streamline");

    // Securely load the interposer DLL

    std::wstring slInterposerPath = L"Data/SKSE/Plugins/Streamline/sl.interposer.dll";

    if (!sl::security::verifyEmbeddedSignature(slInterposerPath.c_str())) {
        logger::error("[Streamline] Failed to verify digital signature of sl.interposer.dll");
        streamlineActive = false;
        return;
    } else {
        logger::info("[Streamline] Succeeded to verify digital signature of sl.interposer.dll");
    }

    this->interposer = LoadLibraryW(slInterposerPath.c_str());
    if (!interposer) {
        logger::error("[Streamline] Failed to load sl.interposer.dll");
        streamlineActive = false;
        return;
    }


    // Proceed to initialize Streamline
    sl::Preferences pref{};

    // Set up preferences (features to load, logging, paths, etc.)
    sl::Feature featuresToLoad[] = { sl::kFeatureDLSS, sl::kFeatureReflex };
    pref.featuresToLoad = featuresToLoad;
    pref.numFeaturesToLoad = _countof(featuresToLoad);
    pref.logLevel = sl::LogLevel::eVerbose;
    pref.logMessageCallback = LoggingCallback;
    const wchar_t* pathsToPlugins[] = { L"Data/SKSE/Plugins/Streamline" };
    pref.pathsToPlugins = pathsToPlugins;
    pref.numPathsToPlugins = _countof(pathsToPlugins);
    pref.engine = sl::EngineType::eCustom;
    pref.engineVersion = "1.0.0";
    pref.projectId = "f8776929-c969-43bd-ac2b-294b4de58aac";
    pref.applicationId = 0; // For development, although NGX may require a valid ID
    pref.renderAPI = sl::RenderAPI::eD3D11;

    // Initialize Streamline
    slInit = (PFun_slInit*)GetProcAddress(interposer, "slInit");
    if (!slInit) {
        logger::error("[Streamline] Failed to get slInit function from interposer");
        streamlineActive = false;
        return;
    }

    sl::Result res = slInit(pref, sl::kSDKVersion);
    if (res != sl::Result::eOk) {
        logger::error("[Streamline] slInit failed: {}", GetSLResultString(res));
        streamlineActive = false;
        return;
    } else {
        logger::info("[Streamline] Successfully initialized Streamline");
        streamlineActive = true;
    }

    initialized = true;

    // Hook up interposer
    Initialize_postInit();
}

    // pref.engine = sl::EngineType::eCustom
    // pref.engineVersion = "1.0.0";
    // pref.projectId = "f8776929-c969-43bd-ac2b-294b4de58aac";
    // pref.applicationId = 0; // Replace with valid application ID
    // pref.renderAPI = sl::RenderAPI::eD3D11;
    // // Hook up all of the functions exported by the SL Interposer Library
    // slInit = (PFun_slInit*)GetProcAddress(interposer, "slInit");
    // slShutdown = (PFun_slShutdown*)GetProcAddress(interposer, "slShutdown");
    // slIsFeatureSupported = (PFun_slIsFeatureSupported*)GetProcAddress(interposer, "slIsFeatureSupported");
    // slIsFeatureLoaded = (PFun_slIsFeatureLoaded*)GetProcAddress(interposer, "slIsFeatureLoaded");
    // slSetFeatureLoaded = (PFun_slSetFeatureLoaded*)GetProcAddress(interposer, "slSetFeatureLoaded");
    // slEvaluateFeature = (PFun_slEvaluateFeature*)GetProcAddress(interposer, "slEvaluateFeature");
    // slAllocateResources = (PFun_slAllocateResources*)GetProcAddress(interposer, "slAllocateResources");
    // slFreeResources = (PFun_slFreeResources*)GetProcAddress(interposer, "slFreeResources");
    // slSetTag = (PFun_slSetTag*)GetProcAddress(interposer, "slSetTag");
    // slGetFeatureRequirements = (PFun_slGetFeatureRequirements*)GetProcAddress(interposer, "slGetFeatureRequirements");
    // slGetFeatureVersion = (PFun_slGetFeatureVersion*)GetProcAddress(interposer, "slGetFeatureVersion");
    // slUpgradeInterface = (PFun_slUpgradeInterface*)GetProcAddress(interposer, "slUpgradeInterface");
    // slSetConstants = (PFun_slSetConstants*)GetProcAddress(interposer, "slSetConstants");
    // slGetNativeInterface = (PFun_slGetNativeInterface*)GetProcAddress(interposer, "slGetNativeInterface");
    // slGetFeatureFunction = (PFun_slGetFeatureFunction*)GetProcAddress(interposer, "slGetFeatureFunction");
    // slGetNewFrameToken = (PFun_slGetNewFrameToken*)GetProcAddress(interposer, "slGetNewFrameToken");
    // slSetD3DDevice = (PFun_slSetD3DDevice*)GetProcAddress(interposer, "slSetD3DDevice");

void Streamline::Initialize_postDevice(IDXGIAdapter* pAdapter)
{
    // Check if DLSS is supported
    DXGI_ADAPTER_DESC adapterDesc;
    pAdapter->GetDesc(&adapterDesc);
    sl::AdapterInfo adapterInfo{};
    adapterInfo.deviceLUID = (uint8_t*)&adapterDesc.AdapterLuid;
	adapterInfo.deviceLUIDSizeInBytes = sizeof(LUID);

    sl::Result res = slIsFeatureSupported(sl::kFeatureDLSS, adapterInfo);
    if (res == sl::Result::eOk) {
        logger::info("[Streamline] DLSS is supported on this adapter");
    } else {
        logger::error("[Streamline] DLSS is not supported on this adapter: {}", GetSLResultString(res));
        streamlineActive = false;
        return;
    }

    // Check if DLSS is loaded
    bool dlssFeatureLoaded = false;
    res = slIsFeatureLoaded(sl::kFeatureDLSS, dlssFeatureLoaded);
    if (res == sl::Result::eOk && dlssFeatureLoaded) {
        logger::info("[Streamline] DLSS feature is loaded");
    } else {
        logger::error("[Streamline] DLSS feature is not loaded");
        streamlineActive = false;
        return;
    }

    // Hook up all of the feature functions using the sl function slGetFeatureFunction
    slGetFeatureFunction(sl::kFeatureDLSS_G, "slDLSSGGetState", (void*&)slDLSSGGetState);
    slGetFeatureFunction(sl::kFeatureDLSS_G, "slDLSSGSetOptions", (void*&)slDLSSGSetOptions);

    // Get DLSS functions
    slGetFeatureFunction(sl::kFeatureDLSS, "slDLSSGetOptimalSettings", (void*&)slDLSSGetOptimalSettings);
    slGetFeatureFunction(sl::kFeatureDLSS, "slDLSSSetOptions", (void*&)slDLSSSetOptions);
    slGetFeatureFunction(sl::kFeatureDLSS, "slDLSSGetState", (void*&)slDLSSGetState);

    slGetFeatureFunction(sl::kFeatureReflex, "slReflexGetState", (void*&)slReflexGetState);
    slGetFeatureFunction(sl::kFeatureReflex, "slReflexSetMarker", (void*&)slReflexSetMarker);
    slGetFeatureFunction(sl::kFeatureReflex, "slReflexSleep", (void*&)slReflexSleep);
    slGetFeatureFunction(sl::kFeatureReflex, "slReflexSetOptions", (void*&)slReflexSetOptions);

    // We set reflex consts to a default config. This can be changed at runtime in the UI.
    auto reflexOptions = sl::ReflexOptions{};
    reflexOptions.mode = sl::ReflexMode::eLowLatencyWithBoost;
    reflexOptions.useMarkersToOptimize = false;
    reflexOptions.virtualKey = 0;
    reflexOptions.frameLimitUs = 0;

    res = slReflexSetOptions(reflexOptions);
    if (res == sl::Result::eOk) {
        logger::error("[Streamline] Failed to set reflex options");
    } else {
        logger::info("[Streamline] Successfully set reflex options");
    }
}

HRESULT Streamline::CreateDXGIFactory(REFIID riid, void** ppFactory)
{
    if (!initialized)
        Initialize_preDevice();

    logger::info("[Streamline] Proxying CreateDXGIFactory");

    auto slCreateDXGIFactory1 = reinterpret_cast<decltype(&CreateDXGIFactory1)>(GetProcAddress(interposer, "CreateDXGIFactory1"));

    return slCreateDXGIFactory1(riid, ppFactory);
}

HRESULT Streamline::CreateDeviceAndSwapChain(IDXGIAdapter* pAdapter,
    D3D_DRIVER_TYPE DriverType,
    HMODULE Software,
    UINT Flags,
    const D3D_FEATURE_LEVEL* pFeatureLevels,
    UINT FeatureLevels,
    UINT SDKVersion,
    const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
    IDXGISwapChain** ppSwapChain,
    ID3D11Device** ppDevice,
    D3D_FEATURE_LEVEL* pFeatureLevel,
    ID3D11DeviceContext** ppImmediateContext,
    bool& o_streamlineProxy)
{
    logger::info("[Streamline] Proxying D3D11CreateDeviceAndSwapChain");
    
    // Create the D3D11 device and swap chain
    auto slD3D11CreateDeviceAndSwapChain = reinterpret_cast<decltype(&D3D11CreateDeviceAndSwapChain)>(
        GetProcAddress(interposer, "D3D11CreateDeviceAndSwapChain"));

    auto hr = slD3D11CreateDeviceAndSwapChain(
        pAdapter,
        DriverType,
        Software,
        Flags,
        pFeatureLevels,
        FeatureLevels,
        SDKVersion,
        pSwapChainDesc,
        ppSwapChain,
        ppDevice,
        pFeatureLevel,
        ppImmediateContext);

    if (FAILED(hr)) {
        logger::error("[Streamline] Failed to create D3D11 device and swap chain: 0x{:X}", hr);
        return hr;
    }

    this->pDevice = *ppDevice;
    // Proceed with the rest of the initialization
    Initialize_postDevice(pAdapter);

    viewport = { 0 };

    o_streamlineProxy = true;

    return hr;
}

void Streamline::CreateFrameGenerationResources()
{
    logger::info("[Streamline] Creating frame generation resources");

    auto renderer = RE::BSGraphics::Renderer::GetSingleton();
    auto& main = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGETS::kMAIN];

    D3D11_TEXTURE2D_DESC texDesc{};
    D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
    D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {};
    D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};

    main.texture->GetDesc(&texDesc);
    main.SRV->GetDesc(&srvDesc);
    main.RTV->GetDesc(&rtvDesc);
    main.UAV->GetDesc(&uavDesc);

    texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    srvDesc.Format = texDesc.Format;
    rtvDesc.Format = texDesc.Format;
    uavDesc.Format = texDesc.Format;

    texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_NTHANDLE;

    colorBufferShared = new Texture2D(texDesc);
    colorBufferShared->CreateSRV(srvDesc);
    colorBufferShared->CreateRTV(rtvDesc);
    colorBufferShared->CreateUAV(uavDesc);

    // Create output color buffer for DLSS
    // TODO: Check is this goes where it should
    colorBufferDLSSOutput = new Texture2D(texDesc);
    colorBufferDLSSOutput->CreateSRV(srvDesc);
    colorBufferDLSSOutput->CreateRTV(rtvDesc);
    colorBufferDLSSOutput->CreateUAV(uavDesc);

    texDesc.Format = DXGI_FORMAT_R32_FLOAT;
    srvDesc.Format = texDesc.Format;
    rtvDesc.Format = texDesc.Format;
    uavDesc.Format = texDesc.Format;

    depthBufferShared = new Texture2D(texDesc);
    depthBufferShared->CreateSRV(srvDesc);
    depthBufferShared->CreateRTV(rtvDesc);
    depthBufferShared->CreateUAV(uavDesc);

    copyDepthToSharedBufferCS = (ID3D11ComputeShader*)Util::CompileShader(L"Data\\Shaders\\Streamline\\CopyDepthToSharedBufferCS.hlsl", {}, "cs_5_0");
}

void Streamline::SetupFrameGeneration()
{
    if (!streamlineActive)
        return;

    CreateFrameGenerationResources();

    // sl::DLSSGOptions options{};
    // options.mode = sl::DLSSGMode::eAuto;
    // options.flags = sl::DLSSGFlags::eRetainResourcesWhenOff;

    // if (SL_FAILED(res, slDLSSGSetOptions(viewport, options))) {
    //     logger::error("[Streamline] Could not enable DLSSG");
    // }
}

void Streamline::CopyResourcesToSharedBuffers()
{
    // if (!streamlineActive || frameGenerationMode == sl::DLSSGMode::eOff)
    //     return;

    auto& context = State::GetSingleton()->context;
    auto renderer = RE::BSGraphics::Renderer::GetSingleton();

    if (RE::UI::GetSingleton()->GameIsPaused()) {
        float clearColor[4] = { 0, 0, 0, 0 };
        auto& motionVectorsBuffer = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGETS::RENDER_TARGET::kMOTION_VECTOR];
        context->ClearRenderTargetView(motionVectorsBuffer.RTV, clearColor);
    }

    ID3D11RenderTargetView* backupViews[8];
    ID3D11DepthStencilView* backupDsv;
    context->OMGetRenderTargets(8, backupViews, &backupDsv);  // Backup bound render targets
    context->OMSetRenderTargets(0, nullptr, nullptr);         // Unbind all bound render targets

    auto& swapChain = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGET::kFRAMEBUFFER];

    ID3D11Resource* swapChainResource;
    swapChain.SRV->GetResource(&swapChainResource);

    context->CopyResource(colorBufferShared->resource.get(), swapChainResource);

    {
        auto& depth = renderer->GetDepthStencilData().depthStencils[RE::RENDER_TARGETS_DEPTHSTENCIL::kMAIN];

        {
            auto dispatchCount = Util::GetScreenDispatchCount();

            ID3D11ShaderResourceView* views[1] = { depth.depthSRV };
            context->CSSetShaderResources(0, ARRAYSIZE(views), views);

            ID3D11UnorderedAccessView* uavs[1] = { depthBufferShared->uav.get() };
            context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);

            context->CSSetShader(copyDepthToSharedBufferCS, nullptr, 0);

            context->Dispatch(dispatchCount.x, dispatchCount.y, 1);
        }

        ID3D11ShaderResourceView* views[1] = { nullptr };
        context->CSSetShaderResources(0, ARRAYSIZE(views), views);

        ID3D11UnorderedAccessView* uavs[1] = { nullptr };
        context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);

        ID3D11ComputeShader* shader = nullptr;
        context->CSSetShader(shader, nullptr, 0);
    }

    context->OMSetRenderTargets(8, backupViews, backupDsv);  // Restore all bound render targets

    for (int i = 0; i < 8; i++) {
        if (backupViews[i])
            backupViews[i]->Release();
    }

    if (backupDsv)
        backupDsv->Release();
}

void Streamline::Present()
{
    if (!streamlineActive)
        return;

    // static auto currentFrameGenerationMode = frameGenerationMode;

    // if (currentFrameGenerationMode != frameGenerationMode) {
    //     currentFrameGenerationMode = frameGenerationMode;

    //     sl::DLSSGOptions options{};
    //     options.mode = frameGenerationMode;
    //     options.flags = sl::DLSSGFlags::eRetainResourcesWhenOff;

    //     if (SL_FAILED(res, slDLSSGSetOptions(viewport, options))) {
    //         logger::error("[Streamline] Could not set DLSSG");
    //     }
    // }

    // Handle DLSS mode
    static auto currentDLSSMode = dlssMode;

    if (currentDLSSMode != dlssMode) {
        currentDLSSMode = dlssMode;

        sl::DLSSOptions dlssOptions = {};
        dlssOptions.mode = dlssMode;
        dlssOptions.outputWidth = (uint)State::GetSingleton()->screenSize.x;
        dlssOptions.outputHeight = (uint)State::GetSingleton()->screenSize.y;
        dlssOptions.sharpness = 0.0f; // adjust as needed
        dlssOptions.colorBuffersHDR = sl::Boolean::eFalse;

        sl::DLSSOptimalSettings dlssSettings = {};
        if (SL_FAILED(res, slDLSSGetOptimalSettings(dlssOptions, dlssSettings))) {
            logger::error("[Streamline] Could not get DLSS optimal settings");
        } else {
            // Adjust render resolution if possible
        }

        if (SL_FAILED(res, slDLSSSetOptions(viewport, dlssOptions))) {
            logger::error("[Streamline] Could not set DLSS options");
        }
    }

    // Tag resources for DLSS
    auto renderer = RE::BSGraphics::Renderer::GetSingleton();
    auto& motionVectorsBuffer = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGETS::RENDER_TARGET::kMOTION_VECTOR];

    sl::Extent fullExtent{ 0, 0, (uint)State::GetSingleton()->screenSize.x, (uint)State::GetSingleton()->screenSize.y };
    float2 dynamicScreenSize = Util::ConvertToDynamic(State::GetSingleton()->screenSize);
    sl::Extent dynamicExtent{ 0, 0, (uint)dynamicScreenSize.x, (uint)dynamicScreenSize.y };

    sl::Resource depth = { sl::ResourceType::eTex2d, depthBufferShared->resource.get(), 0 };
    sl::ResourceTag depthTag = sl::ResourceTag{ &depth, sl::kBufferTypeDepth, sl::ResourceLifecycle::eValidUntilPresent, &dynamicExtent };

    sl::Resource mvec = { sl::ResourceType::eTex2d, motionVectorsBuffer.texture, 0 };
    sl::ResourceTag mvecTag = sl::ResourceTag{ &mvec, sl::kBufferTypeMotionVectors, sl::ResourceLifecycle::eValidUntilPresent, &dynamicExtent };

    sl::Resource colorIn = { sl::ResourceType::eTex2d, colorBufferShared->resource.get(), 0 };
    sl::ResourceTag colorInTag = sl::ResourceTag{ &colorIn, sl::kBufferTypeScalingInputColor, sl::ResourceLifecycle::eOnlyValidNow, &dynamicExtent };

    sl::Resource colorOut = { sl::ResourceType::eTex2d, colorBufferDLSSOutput->resource.get(), 0 };
    sl::ResourceTag colorOutTag = sl::ResourceTag{ &colorOut, sl::kBufferTypeScalingOutputColor, sl::ResourceLifecycle::eOnlyValidNow, &fullExtent };

    sl::ResourceTag inputs[] = { depthTag, mvecTag, colorInTag, colorOutTag };
    slSetTag(viewport, inputs, _countof(inputs), nullptr);

    // Evaluate DLSS
    EvaluateDLSS();

    // Fake NVIDIA Reflex to prevent DLSSG errors
    slReflexSetMarker(sl::ReflexMarker::eInputSample, *currentFrame);
    slReflexSetMarker(sl::ReflexMarker::eSimulationStart, *currentFrame);
    slReflexSetMarker(sl::ReflexMarker::eSimulationEnd, *currentFrame);
    slReflexSetMarker(sl::ReflexMarker::eRenderSubmitStart, *currentFrame);
    slReflexSetMarker(sl::ReflexMarker::eRenderSubmitEnd, *currentFrame);
    slReflexSetMarker(sl::ReflexMarker::ePresentStart, *currentFrame);
    slReflexSetMarker(sl::ReflexMarker::ePresentEnd, *currentFrame);
}

void Streamline::EvaluateDLSS()
{
    if (!streamlineActive || dlssMode == sl::DLSSMode::eOff)
        return;

    const sl::BaseStructure* evaluateInputs[] = { &viewport };
    auto& context = State::GetSingleton()->context;

    if (SL_FAILED(res, slEvaluateFeature(sl::kFeatureDLSS, *currentFrame, evaluateInputs, _countof(evaluateInputs), context))) {
        logger::error("[Streamline] Could not evaluate DLSS");
    } else {
        // Restore state if necessary
    }
}

void Streamline::SetConstants()
{
    if (!streamlineActive)
        return;

    auto state = State::GetSingleton();

    auto cameraData = Util::GetCameraData(0);
    auto eyePosition = Util::GetEyePosition(0);

    auto clipToCameraView = cameraData.viewMat.Invert();
    auto cameraToWorld = cameraData.viewProjMatrixUnjittered.Invert();
    auto cameraToWorldPrev = cameraData.previousViewProjMatrixUnjittered.Invert();

    float4x4 cameraToPrevCamera;

    calcCameraToPrevCamera(*(sl::float4x4*)&cameraToPrevCamera, *(sl::float4x4*)&cameraToWorld, *(sl::float4x4*)&cameraToWorldPrev);

    float4x4 prevCameraToCamera = cameraToPrevCamera;

    prevCameraToCamera.Invert();

    sl::Constants slConstants = {};

    slConstants.cameraAspectRatio = state->screenSize.x / state->screenSize.y;
    slConstants.cameraFOV = Util::GetVerticalFOVRad();
    slConstants.cameraFar = (*(float*)(REL::RelocationID(517032, 403540).address() + 0x44));
    slConstants.cameraMotionIncluded = sl::Boolean::eTrue;
    slConstants.cameraNear = (*(float*)(REL::RelocationID(517032, 403540).address() + 0x40));
    slConstants.cameraPinholeOffset = { 0.f, 0.f };
    slConstants.cameraPos = *(sl::float3*)&eyePosition;
    slConstants.cameraFwd = *(sl::float3*)&cameraData.viewForward;
    slConstants.cameraUp = *(sl::float3*)&cameraData.viewUp;
    slConstants.cameraRight = *(sl::float3*)&cameraData.viewRight;
    slConstants.cameraViewToClip = *(sl::float4x4*)&cameraData.viewMat;
    slConstants.clipToCameraView = *(sl::float4x4*)&clipToCameraView;
    slConstants.clipToPrevClip = *(sl::float4x4*)&cameraToPrevCamera;
    slConstants.depthInverted = sl::Boolean::eFalse;
    slConstants.jitterOffset = { 0, 0 };
    slConstants.mvecScale = { 1, 1 }; // Adjust based on motion vector scale
    slConstants.prevClipToClip = *(sl::float4x4*)&prevCameraToCamera;
    slConstants.reset = sl::Boolean::eFalse;
    slConstants.motionVectors3D = sl::Boolean::eFalse;
    slConstants.motionVectorsInvalidValue = FLT_MIN;
    slConstants.orthographicProjection = sl::Boolean::eFalse;
    slConstants.motionVectorsDilated = sl::Boolean::eFalse;
    slConstants.motionVectorsJittered = sl::Boolean::eFalse;

    if (SL_FAILED(res, slGetNewFrameToken(currentFrame, nullptr))) {
        logger::error("[Streamline] Could not get frame token");
    }

    if (SL_FAILED(res, slSetConstants(slConstants, *currentFrame, viewport))) {
        logger::error("[Streamline] Could not set constants");
    }
}