-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv0.9.4.patch
More file actions
1918 lines (1790 loc) · 92.3 KB
/
Copy pathv0.9.4.patch
File metadata and controls
1918 lines (1790 loc) · 92.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0e84099a..839b7f45 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -6,7 +6,7 @@
name: Scheduled Build
on:
- schedule:
+# schedule:
# - cron: '0 4 * * *'
workflow_dispatch:
diff --git a/OptiScaler.ini b/OptiScaler.ini
index bfac4824..a9b7a88a 100644
--- a/OptiScaler.ini
+++ b/OptiScaler.ini
@@ -560,10 +560,14 @@ DlssReactiveMaskBias=auto
; true or false - Default (auto) depends on GPU - true for RDNA4
Fsr4Update=auto
-; Select FSR4 model to use
+; Enables INT8 model for all GPUs
+; true or false - Default (auto) is false
+Fsr4ForceEnableInt8=auto
+
+; Select internal FSR4 preset to use
; 0 = For FSR Native AA, 1 = Ultra Quality/Quality, 2 = Balanced, 3 = Performance, 4 = DRS, 5 = Ultra Performance
; From 0 to 5 - Default (auto) is game's default
-Fsr4Model=auto
+Fsr4Preset=auto
; Enable FSR4 Debug View visualization
; Might consume more VRAM
diff --git a/OptiScaler/Config.cpp b/OptiScaler/Config.cpp
index a1449dd3..d0265c4d 100644
--- a/OptiScaler/Config.cpp
+++ b/OptiScaler/Config.cpp
@@ -229,12 +229,13 @@ bool Config::Reload(std::filesystem::path iniPath)
FsrUseMaskForTransparency.set_from_config(readBool("FSR", "UseReactiveMaskForTransparency"));
DlssReactiveMaskBias.set_from_config(readFloat("FSR", "DlssReactiveMaskBias"));
Fsr4Update.set_from_config(readBool("FSR", "Fsr4Update"));
+ Fsr4ForceEnableInt8.set_from_config(readBool("FSR", "Fsr4ForceEnableInt8"));
Fsr4EnableDebugView.set_from_config(readBool("FSR", "Fsr4EnableDebugView"));
Fsr4EnableWatermark.set_from_config(readBool("FSR", "Fsr4EnableWatermark"));
Fsr4DoNotLoadAmdxc64.set_from_config(readBool("FSR", "Fsr4DoNotLoadAmdxc64"));
- if (auto setting = readInt("FSR", "Fsr4Model"); setting.has_value() && setting >= 0 && setting <= 5)
- Fsr4Model.set_from_config(setting);
+ if (auto setting = readInt("FSR", "Fsr4Preset"); setting.has_value() && setting >= 0 && setting <= 5)
+ Fsr4Preset.set_from_config(setting);
FsrNonLinearColorSpace.set_from_config(readBool("FSR", "FsrNonLinearColorSpace"));
FsrNonLinearPQ.set_from_config(readBool("FSR", "FsrNonLinearPQ"));
@@ -970,7 +971,9 @@ bool Config::SaveIni()
GetFloatValue(Instance()->DlssReactiveMaskBias.value_for_config()).c_str());
ini.SetValue("FSR", "Fsr4Update",
GetBoolValue(Instance()->Fsr4Update.value_for_config_ignore_default()).c_str());
- ini.SetValue("FSR", "Fsr4Model", GetIntValue(Instance()->Fsr4Model.value_for_config()).c_str());
+ ini.SetValue("FSR", "Fsr4ForceEnableInt8",
+ GetBoolValue(Instance()->Fsr4ForceEnableInt8.value_for_config_ignore_default()).c_str());
+ ini.SetValue("FSR", "Fsr4Preset", GetIntValue(Instance()->Fsr4Preset.value_for_config()).c_str());
ini.SetValue("FSR", "Fsr4EnableDebugView",
GetBoolValue(Instance()->Fsr4EnableDebugView.value_for_config()).c_str());
ini.SetValue("FSR", "Fsr4EnableWatermark",
diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h
index be8b5be7..d7909b76 100644
--- a/OptiScaler/Config.h
+++ b/OptiScaler/Config.h
@@ -406,6 +406,8 @@ class Config
CustomOptional<bool> FsrNonLinearSRGB { false };
CustomOptional<bool> FsrNonLinearPQ { false };
CustomOptional<bool> FsrAgilitySDKUpgrade { false };
+
+ // These default values will be overwritten at upscaler init time with optimized values
CustomOptional<float> FsrVelocity { 1.0f };
CustomOptional<float> FsrReactiveScale { 1.0f };
CustomOptional<float> FsrShadingScale { 1.0f };
@@ -414,7 +416,8 @@ class Config
// FSR4
CustomOptional<bool> Fsr4Update { false };
- CustomOptional<uint32_t, NoDefault> Fsr4Model;
+ CustomOptional<bool> Fsr4ForceEnableInt8 { false };
+ CustomOptional<uint32_t, NoDefault> Fsr4Preset;
CustomOptional<bool> Fsr4EnableDebugView { false };
CustomOptional<bool> Fsr4EnableWatermark { false };
CustomOptional<bool> Fsr4DoNotLoadAmdxc64 { false };
diff --git a/OptiScaler/State.h b/OptiScaler/State.h
index c748bcfe..f2064148 100644
--- a/OptiScaler/State.h
+++ b/OptiScaler/State.h
@@ -234,7 +234,7 @@ class State
std::vector<uint64_t> ffxUpscalerVersionIds {};
std::vector<const char*> ffxFGVersionNames {};
std::vector<uint64_t> ffxFGVersionIds {};
- std::optional<uint32_t> currentFsr4Model {};
+ std::optional<uint32_t> currentFsr4Preset {};
// Linux checks
bool isRunningOnLinux = false;
@@ -243,6 +243,7 @@ class State
// Other checks
bool isRunningOnNvidia = false;
std::optional<bool> isRunningOnRDNA4;
+ std::optional<bool> isRunningOnRDNA3;
bool isPascalOrOlder = false;
WorkingMode workingMode = WorkingMode::Other;
diff --git a/OptiScaler/dllmain.cpp b/OptiScaler/dllmain.cpp
index 03565fde..7580c65c 100644
--- a/OptiScaler/dllmain.cpp
+++ b/OptiScaler/dllmain.cpp
@@ -1337,6 +1337,9 @@ static void printQuirks(flag_set<GameQuirk>& quirks)
if (quirks & GameQuirk::IgnoreValidUntilEvaluateForFG)
stringQuirks.push_back("Ignore ValidUntilEvaluate resources for FG");
+ if (quirks & GameQuirk::ForceFGRenderSizeMVs)
+ stringQuirks.push_back("Force FG render size motion vectors");
+
state->detectedQuirks.append_range(stringQuirks);
for (auto& stringQuirk : stringQuirks)
spdlog::info("Quirk: {}", stringQuirk);
@@ -1385,7 +1388,6 @@ static void CheckQuirks()
quirks.reset(GameQuirk::DisableDxgiSpoofing);
if (quirks & GameQuirk::RestoreComputeSigOnNonNvidia && !State::Instance().isRunningOnNvidia &&
- !Config::Instance()->DxgiSpoofing.value_or_default() &&
!Config::Instance()->RestoreComputeSignature.has_value())
{
Config::Instance()->RestoreComputeSignature.set_volatile_value(true);
diff --git a/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp b/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp
index 9df4a540..07b9b528 100644
--- a/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp
+++ b/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp
@@ -378,6 +378,11 @@ bool FSRFG_Dx12::Dispatch()
fgConfig.HUDLessColor = ffxApiGetResourceDX12(hudless->GetResource(), GetFfxApiState(hudless->state));
+ // Because of HudlessTransfer hudless will be always in SC format
+ // Quick fix for typeless Hudless formats
+ fgConfig.HUDLessColor.description.format =
+ (FfxApiSurfaceFormat) ffxApiGetSurfaceFormatDX12(State::Instance().currentSwapchainDesc.BufferDesc.Format);
+
// Reset of _paramHudless[fIndex] happens in DispatchCallback
// as we might use it in Preset to remove hud from swapchain
}
@@ -490,7 +495,17 @@ bool FSRFG_Dx12::Dispatch()
ffxDispatchDescFrameGenerationPrepare dfgPrepare {};
dfgPrepare.header.type = FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION_PREPARE;
- dfgPrepare.header.pNext = &dfgCameraData.header;
+
+ // Hacky way but should do
+ const float* cameraDataRaw = dfgCameraData.cameraPosition;
+ bool cameraDataIsZeroed = std::all_of(cameraDataRaw, cameraDataRaw + 12, [](float v) { return v == 0.0f; });
+
+ // Don't link the camera struct if it's just all zeros
+ // Specifically the driver upgrade dll is looking at this and falling back to FSR 3 FG
+ if (cameraDataIsZeroed)
+ dfgPrepare.header.pNext = &backendDesc.header;
+ else
+ dfgPrepare.header.pNext = &dfgCameraData.header;
// Prepare command list
auto allocator = _fgCommandAllocator[fIndex];
@@ -1066,8 +1081,11 @@ void FSRFG_Dx12::CreateContext(ID3D12Device* device, FG_Constants& fgConstants)
if (fgConstants.flags & FG_Flags::JitteredMVs)
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION;
- if (fgConstants.flags & FG_Flags::DisplayResolutionMVs)
+ if ((fgConstants.flags & FG_Flags::DisplayResolutionMVs) &&
+ !(State::Instance().gameQuirks & GameQuirk::ForceFGRenderSizeMVs))
+ {
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS;
+ }
if (fgConstants.flags & FG_Flags::Async)
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_ASYNC_WORKLOAD_SUPPORT;
diff --git a/OptiScaler/framegen/xefg/XeFG_Dx12.cpp b/OptiScaler/framegen/xefg/XeFG_Dx12.cpp
index c9a30abe..edf83ba5 100644
--- a/OptiScaler/framegen/xefg/XeFG_Dx12.cpp
+++ b/OptiScaler/framegen/xefg/XeFG_Dx12.cpp
@@ -609,7 +609,8 @@ void XeFG_Dx12::Activate()
nativeAA = currentFeature->RenderWidth() == currentFeature->DisplayWidth();
if (_swapChainContext != nullptr && _fgContext != nullptr && !_isActive &&
- (IsLowResMV() || nativeAA || Config::Instance()->FGXeFGIgnoreInitChecks.value_or_default()))
+ (IsLowResMV() || nativeAA || (State::Instance().gameQuirks & GameQuirk::ForceFGRenderSizeMVs) ||
+ Config::Instance()->FGXeFGIgnoreInitChecks.value_or_default()))
{
auto result = XeFGProxy::SetEnabled()(_swapChainContext, true);
diff --git a/OptiScaler/fsr4/FSR4ModelSelection.cpp b/OptiScaler/fsr4/FSR4ModelSelection.cpp
index 3634c8c6..d923af7f 100644
--- a/OptiScaler/fsr4/FSR4ModelSelection.cpp
+++ b/OptiScaler/fsr4/FSR4ModelSelection.cpp
@@ -7,6 +7,8 @@ PFN_getModelBlob FSR4ModelSelection::o_getModelBlobSDK = nullptr;
PFN_getModelBlob FSR4ModelSelection::o_getModelBlobDriver = nullptr;
PFN_createModel FSR4ModelSelection::o_createModelSDK = nullptr;
PFN_createModel FSR4ModelSelection::o_createModelDriver = nullptr;
+PFN_createModel2 FSR4ModelSelection::o_createModelDriver2 = nullptr;
+PFN_createModel2 FSR4ModelSelection::o_createModelSDK2 = nullptr;
uint32_t getCorrectedPreset(uint32_t preset)
{
@@ -24,12 +26,12 @@ uint32_t getCorrectedPreset(uint32_t preset)
correctedPreset = 1;
}
- if (Config::Instance()->Fsr4Model.has_value())
+ if (Config::Instance()->Fsr4Preset.has_value())
{
- correctedPreset = Config::Instance()->Fsr4Model.value();
+ correctedPreset = Config::Instance()->Fsr4Preset.value();
}
- State::Instance().currentFsr4Model = correctedPreset;
+ State::Instance().currentFsr4Preset = correctedPreset;
return correctedPreset;
}
@@ -67,6 +69,17 @@ uint64_t FSR4ModelSelection::hkcreateModelSDK(void* context, uint32_t preset)
return result;
}
+uint64_t FSR4ModelSelection::hkcreateModelSDK2(void* context, uint32_t preset, void** model)
+{
+ LOG_FUNC();
+
+ preset = getCorrectedPreset(preset);
+
+ auto result = o_createModelSDK2(context, preset, model);
+
+ return result;
+}
+
uint64_t FSR4ModelSelection::hkcreateModelDriver(void* context, uint32_t preset)
{
LOG_FUNC();
@@ -78,6 +91,17 @@ uint64_t FSR4ModelSelection::hkcreateModelDriver(void* context, uint32_t preset)
return result;
}
+uint64_t FSR4ModelSelection::hkcreateModelDriver2(void* context, uint32_t preset, void** model)
+{
+ LOG_FUNC();
+
+ preset = getCorrectedPreset(preset);
+
+ auto result = o_createModelDriver2(context, preset, model);
+
+ return result;
+}
+
void FSR4ModelSelection::Hook(HMODULE module, FSR4Source source)
{
if (module == nullptr)
@@ -122,6 +146,8 @@ void FSR4ModelSelection::Hook(HMODULE module, FSR4Source source)
}
}
+ /// Hooks for getModelBlob
+
// Older SDK and Driver use this
const char* modelBlobPattern = "83 F9 05 0F 87";
if (!o_getModelBlobSDK && source == FSR4Source::SDK)
@@ -167,6 +193,8 @@ void FSR4ModelSelection::Hook(HMODULE module, FSR4Source source)
}
}
+ /// Hooks for createModel
+
// From amd_fidelityfx_upscaler_dx12 4.0.3.604 from FFX 2.1 SDK
// Used by some versions of SDK and Driver
const char* pattern403 =
@@ -177,6 +205,15 @@ void FSR4ModelSelection::Hook(HMODULE module, FSR4Source source)
{
o_createModelSDK = (PFN_createModel) scanner::GetAddress(module, pattern403);
+ if (!o_createModelSDK)
+ {
+ // From amd_fidelityfx_upscaler_dx12 4.1.0 from FFX 2.2 SDK
+ const char* pattern410 =
+ "48 8B C4 48 89 58 18 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 28 F2 FF FF 48 81 EC A0 "
+ "0E 00 00 0F 29 70 B8 0F 29 78 A8 48 8B ? ? ? ? ? 48 33 C4 48 89 85 78 0D 00 00 44 8B F2";
+ o_createModelSDK = (PFN_createModel) scanner::GetAddress(module, pattern410);
+ }
+
LOG_DEBUG("Hooking model selection, o_createModelSDK: {:X}", (uintptr_t) o_createModelSDK);
if (o_createModelSDK)
@@ -193,36 +230,32 @@ void FSR4ModelSelection::Hook(HMODULE module, FSR4Source source)
o_createModelSDK = nullptr;
}
}
- else
- LOG_ERROR("Couldn't hook model selection");
}
- // From amd_fidelityfx_upscaler_dx12 4.1.0 from FFX 2.2 SDK
- const char* pattern410 = "48 8B C4 48 89 58 18 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 28 F2 FF FF 48 81 EC A0 "
- "0E 00 00 0F 29 70 B8 0F 29 78 A8 48 8B ? ? ? ? ? 48 33 C4 48 89 85 78 0D 00 00 44 8B F2";
-
- if (!o_createModelSDK && source == FSR4Source::SDK)
+ if (!o_createModelSDK && !o_createModelSDK2 && source == FSR4Source::SDK)
{
- o_createModelSDK = (PFN_createModel) scanner::GetAddress(module, pattern410);
-
- LOG_DEBUG("Hooking model selection, o_createModelSDK: {:X}", (uintptr_t) o_createModelSDK);
+ // From amd_fidelityfx_upscaler_dx12 4.1.1.2740 from FFX 2.3 SDK
+ const char* pattern411 =
+ "48 8B C4 48 89 58 20 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 08 F2 FF FF 48 81 EC C0 0E 00 00 0F 29 70 "
+ "B8 0F 29 78 A8 48 8B ? ? ? ? ? 48 33 C4 48 89 85 90 0D 00 00 4D 8B E8 8B FA 48 8B F1";
+ o_createModelSDK2 = (PFN_createModel2) scanner::GetAddress(module, pattern411);
- if (o_createModelSDK)
+ if (o_createModelSDK2)
{
+ LOG_DEBUG("Hooking model selection, o_createModelSDK2: {:X}", (uintptr_t) o_createModelSDK2);
+
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
- DetourAttach(&(PVOID&) o_createModelSDK, hkcreateModelSDK);
+ DetourAttach(&(PVOID&) o_createModelSDK2, hkcreateModelSDK2);
auto detourResult = DetourTransactionCommit();
if (detourResult != NO_ERROR)
{
LOG_ERROR("Failed to attach detour: {:X}", detourResult);
- o_createModelSDK = nullptr;
+ o_createModelSDK2 = nullptr;
}
}
- else
- LOG_ERROR("Couldn't hook model selection");
}
else if (!o_createModelDriver && source == FSR4Source::DriverDll)
@@ -254,11 +287,35 @@ void FSR4ModelSelection::Hook(HMODULE module, FSR4Source source)
o_createModelDriver = nullptr;
}
}
- else
- LOG_ERROR("Couldn't hook model selection");
}
- else
+
+ if (!o_createModelDriver && !o_createModelDriver2 && source == FSR4Source::DriverDll)
{
- LOG_DEBUG("Didn't rehook");
+ // From amdxcffx64 2.3.0.2740
+ const char* pattern = "48 8B C4 48 89 58 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? "
+ "0F 29 70 ? 0F 29 78 ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4D 8B E8 8B FA 48 8B";
+ o_createModelDriver2 = (PFN_createModel2) scanner::GetAddress(module, pattern);
+
+ if (o_createModelDriver2)
+ {
+ LOG_DEBUG("Hooking model selection, o_createModelDriver2: {:X}", (uintptr_t) o_createModelDriver2);
+
+ DetourTransactionBegin();
+ DetourUpdateThread(GetCurrentThread());
+
+ DetourAttach(&(PVOID&) o_createModelDriver2, hkcreateModelDriver2);
+
+ auto detourResult = DetourTransactionCommit();
+ if (detourResult != NO_ERROR)
+ {
+ LOG_ERROR("Failed to attach detour: {:X}", detourResult);
+ o_createModelDriver2 = nullptr;
+ }
+ }
}
+
+ if (!o_createModelDriver && !o_getModelBlobDriver && !o_createModelDriver2 && source == FSR4Source::DriverDll)
+ LOG_ERROR("Couldn't hook model selection from the driver dll");
+ else if (!o_createModelSDK && !o_getModelBlobSDK && !o_createModelSDK2 && source == FSR4Source::SDK)
+ LOG_ERROR("Couldn't hook model selection from the SDK dll");
}
diff --git a/OptiScaler/fsr4/FSR4ModelSelection.h b/OptiScaler/fsr4/FSR4ModelSelection.h
index 7dc8e6ac..5de8f709 100644
--- a/OptiScaler/fsr4/FSR4ModelSelection.h
+++ b/OptiScaler/fsr4/FSR4ModelSelection.h
@@ -4,6 +4,7 @@
typedef uint64_t (*PFN_getModelBlob)(uint32_t preset, uint64_t unknown, uint64_t* source, uint64_t* size);
typedef uint64_t (*PFN_createModel)(void* context, uint32_t preset);
+typedef uint64_t (*PFN_createModel2)(void* context, uint32_t preset, void** model);
enum class FSR4Source
{
@@ -21,7 +22,12 @@ class FSR4ModelSelection
static uint64_t hkcreateModelDriver(void* context, uint32_t preset);
static PFN_createModel o_createModelSDK;
static PFN_createModel o_createModelDriver;
+ static uint64_t hkcreateModelDriver2(void* context, uint32_t preset, void** model);
+ static PFN_createModel2 o_createModelDriver2;
+ static uint64_t hkcreateModelSDK2(void* context, uint32_t preset, void** model);
+ static PFN_createModel2 o_createModelSDK2;
public:
static void Hook(HMODULE module, FSR4Source source);
+ static bool IsInt8FsrHooked() { return o_createModelDriver2 || o_createModelSDK2; };
};
diff --git a/OptiScaler/fsr4/FSR4Upgrade.cpp b/OptiScaler/fsr4/FSR4Upgrade.cpp
index 3a4825d4..3e461ea6 100644
--- a/OptiScaler/fsr4/FSR4Upgrade.cpp
+++ b/OptiScaler/fsr4/FSR4Upgrade.cpp
@@ -136,7 +136,7 @@ std::vector<std::filesystem::path> GetDriverStore()
void CheckForGPU()
{
// CheckForGPU already ran before, no need to run it again
- if (State::Instance().isRunningOnRDNA4.has_value())
+ if (State::Instance().isRunningOnRDNA4.has_value() || State::Instance().isRunningOnRDNA3.has_value())
return;
// Call init for any case
@@ -170,6 +170,9 @@ void CheckForGPU()
if (!State::Instance().isRunningOnRDNA4.has_value() || !State::Instance().isRunningOnRDNA4.value())
State::Instance().isRunningOnRDNA4 = false;
+ if (!State::Instance().isRunningOnRDNA3.has_value() || !State::Instance().isRunningOnRDNA3.value())
+ State::Instance().isRunningOnRDNA3 = false;
+
std::wstring szName(adapterDesc.Description);
std::string descStr = std::format("Adapter: {}, VRAM: {} MB", wstring_to_string(szName),
adapterDesc.DedicatedVideoMemory / (1024.0 * 1024.0));
@@ -205,6 +208,35 @@ void CheckForGPU()
}
}
}
+
+ // Don't look, checks for RDNA 3
+ if (szName.contains(L"7900") || szName.contains(L"7800") || szName.contains(L"7700") ||
+ szName.contains(L"7600") || szName.find(L" GFX110") != std::wstring::npos)
+ {
+ LOG_DEBUG("RDNA3 GPU detected");
+ State::Instance().isRunningOnRDNA3 = true;
+
+ if (!Config::Instance()->Dx12Upscaler.has_value())
+ {
+ if (State::Instance().WindowsVer == WindowsVersion::Windows11)
+ {
+ LOG_INFO("Setting Dx12Upscaler to fsr31 because RDNA3 GPU is detected");
+ Config::Instance()->Dx12Upscaler.set_volatile_value("fsr31");
+ }
+ else
+ {
+ if (KernelBaseProxy::GetModuleHandleW_()(L"D3D12Core.dll") != nullptr)
+ {
+ LOG_INFO("Setting Dx12Upscaler to fsr31 because RDNA3 GPU is detected");
+ Config::Instance()->Dx12Upscaler.set_volatile_value("fsr31");
+ }
+ else
+ {
+ LOG_WARN("RDNA3 GPU is detected but Agility SDK is not detected!");
+ }
+ }
+ }
+ }
}
}
else
@@ -220,12 +252,13 @@ void CheckForGPU()
factory->Release();
factory = nullptr;
- // If not set at Config enable/disable Fsr4Update according to GPU detection
+ // If not set at Config, enable/disable Fsr4Update according to GPU detection
if (!Config::Instance()->Fsr4Update.has_value())
- Config::Instance()->Fsr4Update.set_volatile_value(State::Instance().isRunningOnRDNA4.value());
+ Config::Instance()->Fsr4Update.set_volatile_value(State::Instance().isRunningOnRDNA4.value() ||
+ State::Instance().isRunningOnRDNA3.value());
- LOG_INFO("RNDA4: {}, Fsr4Update: {}", State::Instance().isRunningOnRDNA4.value(),
- Config::Instance()->Fsr4Update.value_or_default());
+ LOG_INFO("RDNA4: {}, RDNA3: {}, Fsr4Update: {}", State::Instance().isRunningOnRDNA4.value(),
+ State::Instance().isRunningOnRDNA3.value(), Config::Instance()->Fsr4Update.value_or_default());
}
struct ffxProviderInterface
@@ -326,6 +359,17 @@ struct AmdExtFfxApi : public IAmdExtFfxApi
}
}
+ // Prevent RDNA3 from running MLFG when not on Linux
+ if (effectType == FFXStructType::FG && State::Instance().isRunningOnRDNA3 &&
+ State::Instance().isRunningOnRDNA3.value())
+ {
+ const char* envvar = getenv("DXIL_SPIRV_CONFIG");
+ bool rdna3fp8 = envvar && strstr(envvar, "wmma_rdna3_workaround");
+
+ if (!rdna3fp8)
+ return E_NOINTERFACE;
+ }
+
// Result 0x80004002 (E_NOINTERFACE) basically means that amdxcffx64 doesn't have a provider for that effect
if ((effectType == FFXStructType::FG || effectType == FFXStructType::Upscaling ||
effectType == FFXStructType::SwapchainDX12) &&
@@ -427,6 +471,19 @@ struct AmdExtD3DDevice8 : public IAmdExtD3DDevice8
waveMatrixProperties->saturatingAccumulation = false;
+ if (State::Instance().isRunningOnRDNA3 && State::Instance().isRunningOnRDNA3.value())
+ {
+ const char* envvar = getenv("DXIL_SPIRV_CONFIG");
+ bool rdna3fp8 = envvar && strstr(envvar, "wmma_rdna3_workaround");
+
+ // Try to allow for MLFG on Rdna3 on Linux while forcing int8 for the upscaler
+ if (!Util::WhoIsTheCaller(_ReturnAddress()).starts_with("amd_fidelityfx_framegeneration_dx12") || !rdna3fp8)
+ {
+ if (!rdna3fp8 || FSR4ModelSelection::IsInt8FsrHooked())
+ waveMatrixProperties->aType = float16; // Anything to fail the check
+ }
+ }
+
return S_OK;
}
diff --git a/OptiScaler/hooks/Gdi32_Hooks.h b/OptiScaler/hooks/Gdi32_Hooks.h
index 1182d9fb..39e620ef 100644
--- a/OptiScaler/hooks/Gdi32_Hooks.h
+++ b/OptiScaler/hooks/Gdi32_Hooks.h
@@ -16,7 +16,7 @@ static NTSTATUS hkD3DKMTQueryAdapterInfo(const D3DKMT_QUERYADAPTERINFO* data)
auto result = o_D3DKMTQueryAdapterInfo(data);
// LOG_INFO("Adapter into type: {}", (uint32_t)data->Type);
- if (data->Type == KMTQAITYPE_WDDM_2_7_CAPS)
+ if (data->Type == KMTQAITYPE_WDDM_2_7_CAPS && Config::Instance()->SpoofHAGS.value_or_default())
{
LOG_INFO("Spoofing HAGS 2.7");
@@ -33,7 +33,7 @@ static NTSTATUS hkD3DKMTQueryAdapterInfo(const D3DKMT_QUERYADAPTERINFO* data)
return 0;
}
- else if (data->Type == KMTQAITYPE_WDDM_2_9_CAPS)
+ else if (data->Type == KMTQAITYPE_WDDM_2_9_CAPS && Config::Instance()->SpoofHAGS.value_or_default())
{
LOG_INFO("Spoofing HAGS 2.9");
@@ -48,6 +48,36 @@ static NTSTATUS hkD3DKMTQueryAdapterInfo(const D3DKMT_QUERYADAPTERINFO* data)
d3dkmt_wddm_2_9_caps->HwSchEnabled = 1;
return 0;
}
+ else if (data->Type == KMTQAITYPE_UMDRIVERPRIVATE && data->PrivateDriverDataSize == 608 &&
+ Util::WhoIsTheCaller(_ReturnAddress()).starts_with("amd"))
+ {
+ LOG_DEBUG("Likely FSR 4 GPU Check");
+
+ auto amd_gpu_info = static_cast<uint32_t*>(data->pPrivateDriverData);
+
+ if (Config::Instance()->Fsr4Update.value_or_default() || State::Instance().isRunningOnLinux)
+ {
+ // Values as per https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/amd/addrlib/src/amdgpu_asic_addr.h
+ // Seem to be asic family and asic revision
+ if (State::Instance().isRunningOnRDNA3.has_value() && State::Instance().isRunningOnRDNA3.value())
+ {
+ amd_gpu_info[12] = 145; // gfx11
+ amd_gpu_info[13] = 1;
+
+ return 1;
+ }
+ if (State::Instance().isRunningOnRDNA4.has_value() && State::Instance().isRunningOnRDNA4.value())
+ {
+ // Based on 9070xt
+ amd_gpu_info[12] = 152; // gfx12
+ amd_gpu_info[13] = 81;
+
+ return 1;
+ }
+ }
+
+ return result;
+ }
return result;
}
@@ -57,24 +87,21 @@ static void hookGdi32()
{
LOG_FUNC();
- if (Config::Instance()->SpoofHAGS.value_or_default())
- {
- o_D3DKMTQueryAdapterInfo =
- reinterpret_cast<PFN_D3DKMTQueryAdapterInfo>(DetourFindFunction("gdi32.dll", "D3DKMTQueryAdapterInfo"));
+ o_D3DKMTQueryAdapterInfo =
+ reinterpret_cast<PFN_D3DKMTQueryAdapterInfo>(DetourFindFunction("gdi32.dll", "D3DKMTQueryAdapterInfo"));
- if (o_D3DKMTQueryAdapterInfo != nullptr)
- {
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
+ if (o_D3DKMTQueryAdapterInfo != nullptr)
+ {
+ DetourTransactionBegin();
+ DetourUpdateThread(GetCurrentThread());
- DetourAttach(&(PVOID&) o_D3DKMTQueryAdapterInfo, hkD3DKMTQueryAdapterInfo);
+ DetourAttach(&(PVOID&) o_D3DKMTQueryAdapterInfo, hkD3DKMTQueryAdapterInfo);
- auto detourResult = DetourTransactionCommit();
- if (detourResult != NO_ERROR)
- {
- LOG_ERROR("DetourTransactionCommit error: {:X}", detourResult);
- o_D3DKMTQueryAdapterInfo = nullptr;
- }
+ auto detourResult = DetourTransactionCommit();
+ if (detourResult != NO_ERROR)
+ {
+ LOG_ERROR("DetourTransactionCommit error: {:X}", detourResult);
+ o_D3DKMTQueryAdapterInfo = nullptr;
}
}
}
diff --git a/OptiScaler/menu/menu_common.cpp b/OptiScaler/menu/menu_common.cpp
index ae427804..8e60cb7f 100644
--- a/OptiScaler/menu/menu_common.cpp
+++ b/OptiScaler/menu/menu_common.cpp
@@ -123,6 +123,7 @@ static std::vector<std::string> splashText = { "Cope smarter, not harder",
"Neural Slop Sampling with DLSS5",
"DLSS 5 - the way it's meant to be slopped",
"Just when I think I'm out, they scale me back in",
+ "How to remove those corny messages?!",
"<Your funny text goes here>" };
static ImVec2 updateNoticePosition(-1000.0f, -1000.0f);
@@ -1220,7 +1221,10 @@ void MenuCommon::AddDx11Backends(std::string* code, std::string* name)
{
std::string selectedUpscalerName = "";
bool fsr4Possible =
- Config::Instance()->Fsr4Update.value_or_default() || State::Instance().isRunningOnRDNA4.value_or(false);
+ Config::Instance()->Fsr4Update.value_or_default() || State::Instance().isRunningOnRDNA4.value_or(false) ||
+ (Config::Instance()->Fsr4ForceEnableInt8.value_or_default() && FfxApiProxy::Dx12Module_SR() != nullptr &&
+ FfxApiProxy::VersionDx12_SR() >= feature_version { 4, 1, 1 });
+
std::string fsr3xName = fsr4Possible ? "FSR 3.X/4 w/Dx12" : "FSR 3.X w/Dx12";
if (State::Instance().newBackend == "fsr22" || (State::Instance().newBackend == "" && *code == "fsr22"))
@@ -1275,7 +1279,10 @@ void MenuCommon::AddDx12Backends(std::string* code, std::string* name)
{
std::string selectedUpscalerName = "";
bool fsr4Possible =
- Config::Instance()->Fsr4Update.value_or_default() || State::Instance().isRunningOnRDNA4.value_or(false);
+ Config::Instance()->Fsr4Update.value_or_default() || State::Instance().isRunningOnRDNA4.value_or(false) ||
+ (Config::Instance()->Fsr4ForceEnableInt8.value_or_default() && FfxApiProxy::Dx12Module_SR() != nullptr &&
+ FfxApiProxy::VersionDx12_SR() >= feature_version { 4, 1, 1 });
+
std::string fsr3xName = fsr4Possible ? "FSR 3.X/4" : "FSR 3.X";
if (State::Instance().newBackend == "fsr21" || (State::Instance().newBackend == "" && *code == "fsr21"))
@@ -1315,7 +1322,10 @@ void MenuCommon::AddVulkanBackends(std::string* code, std::string* name)
{
std::string selectedUpscalerName = "";
bool fsr4Possible =
- Config::Instance()->Fsr4Update.value_or_default() || State::Instance().isRunningOnRDNA4.value_or(false);
+ Config::Instance()->Fsr4Update.value_or_default() || State::Instance().isRunningOnRDNA4.value_or(false) ||
+ (Config::Instance()->Fsr4ForceEnableInt8.value_or_default() && FfxApiProxy::Dx12Module_SR() != nullptr &&
+ FfxApiProxy::VersionDx12_SR() >= feature_version { 4, 1, 1 });
+
std::string fsr3xName = fsr4Possible ? "FSR 3.X/4 w/Dx12" : "FSR 3.X w/Dx12";
if (State::Instance().newBackend == "fsr21" || (State::Instance().newBackend == "" && *code == "fsr21"))
@@ -2139,7 +2149,7 @@ bool MenuCommon::RenderMenu()
refreshRate = Util::GetActiveRefreshRate(_handle);
config->ReloadFakenvapi();
- auto dllPath = Util::DllPath().parent_path() / "dlssg_to_fsr3_amd_is_better.dll";
+ auto dllPath = std::filesystem::path(config->MainDllPath.value()) / L"dlssg_to_fsr3_amd_is_better.dll";
state.NukemsFilesAvailable = gExists.Get(dllPath);
if (State::Instance().currentFeature != nullptr)
@@ -3292,170 +3302,101 @@ bool MenuCommon::RenderMenu()
{
ImGui::Spacing();
- ImGui::BeginDisabled(config->FsrNonLinearSRGB.value_or_default() ||
- config->FsrNonLinearPQ.value_or_default());
-
- if (bool nlCS = config->FsrNonLinearColorSpace.value_or_default();
- ImGui::Checkbox("Non-Linear Color Space", &nlCS))
- {
- config->FsrNonLinearColorSpace = nlCS;
- state.newBackend = currentBackend;
- MARK_ALL_BACKENDS_CHANGED();
- }
-
- ImGui::EndDisabled();
-
- ShowHelpMarker("Indicates input color resource uses Non-Linear color space\n"
- "Might improve upscaling quality of FSR4\n"
- "Might increase ghosting");
-
- if (ImGui::BeginTable("nonLinear", 2, ImGuiTableFlags_SizingStretchProp))
+ // Colorspaces
+ const char* colorSpaces[] = { "Linear (Default)", "Non-Linear", "Non-Linear sRGB",
+ "Non-Linear PQ" };
+ int currentColorSpace = 0;
+ if (config->FsrNonLinearPQ.value_or_default())
+ currentColorSpace = 3;
+ else if (config->FsrNonLinearSRGB.value_or_default())
+ currentColorSpace = 2;
+ else if (config->FsrNonLinearColorSpace.value_or_default())
+ currentColorSpace = 1;
+
+ ImGui::SetNextItemWidth(150.0f * menuResScale);
+ if (ImGui::Combo("Input Colour Space", ¤tColorSpace, colorSpaces,
+ IM_ARRAYSIZE(colorSpaces)))
{
+ bool isSrgb = (currentColorSpace == 2);
+ bool isPq = (currentColorSpace == 3);
- ImGui::TableNextColumn();
+ config->FsrNonLinearSRGB = isSrgb;
+ config->FsrNonLinearPQ = isPq;
- if (bool nlSRGB = config->FsrNonLinearSRGB.value_or_default();
- ImGui::Checkbox("Non-Linear sRGB Input", &nlSRGB))
+ if (isSrgb || isPq)
{
- config->FsrNonLinearSRGB = nlSRGB;
-
- if (nlSRGB)
- {
- config->FsrNonLinearPQ = false;
- config->FsrNonLinearColorSpace.set_volatile_value(true);
- }
- else
- {
- // If has config value revert back to it, otherwise reset
- if (config->FsrNonLinearColorSpace.value_for_config().has_value())
- {
- config->FsrNonLinearColorSpace =
- config->FsrNonLinearColorSpace.value_for_config();
- }
- else
- {
- config->FsrNonLinearColorSpace.reset();
- }
- }
-
- state.newBackend = currentBackend;
- MARK_ALL_BACKENDS_CHANGED();
+ config->FsrNonLinearColorSpace.set_volatile_value(true);
}
- ShowHelpMarker("Indicates input color resource contains perceptual sRGB colors\n"
- "Might improve upscaling quality of FSR4\n"
- "Might increase ghosting");
-
- ImGui::TableNextColumn();
-
- if (bool nlPQ = config->FsrNonLinearPQ.value_or_default();
- ImGui::Checkbox("Non-Linear PQ Input", &nlPQ))
+ else if (currentColorSpace == 1) // Just non-Linear
{
- config->FsrNonLinearPQ = nlPQ;
-
- if (nlPQ)
- {
- config->FsrNonLinearSRGB = false;
- config->FsrNonLinearColorSpace.set_volatile_value(true);
- }
- else
- {
- // If has config value revert back to it othervise reset
- if (config->FsrNonLinearColorSpace.value_for_config().has_value())
- {
- config->FsrNonLinearColorSpace =
- config->FsrNonLinearColorSpace.value_for_config();
- }
- else
- {
- config->FsrNonLinearColorSpace.reset();
- }
- }
-
- state.newBackend = currentBackend;
- MARK_ALL_BACKENDS_CHANGED();
+ config->FsrNonLinearColorSpace = true;
}
- ShowHelpMarker("Indicates input color resource contains perceptual PQ colors\n"
- "Might improve upscaling quality of FSR4\n"
- "Rarest, might increase ghosting and break lights");
-
- ImGui::EndTable();
- }
-
- std::array<const char*, 7> models = { "Default", "Model 0", "Model 1", "Model 2",
- "Model 3", "Model 4", "Model 5" };
-
- // Conversion from 0 -> 6 into nullopt + 0 -> 5 is required
- uint32_t configModes = 0;
-
- if (config->Fsr4Model.has_value())
- configModes = config->Fsr4Model.value_or(0) + 1;
-
- if (configModes < 0 || configModes >= models.size())
- configModes = 0;
-
- const char* selectedModel = models[configModes];
-
- if (ImGui::BeginTable("nonLinear", 2, ImGuiTableFlags_SizingStretchProp))
- {
-
- ImGui::TableNextColumn();
-
- if (ImGui::BeginCombo("Models", selectedModel))
+ else // Linear
{
- for (int n = 0; n < models.size(); n++)
- {
- uint32_t selection = 0;
-
- if (config->Fsr4Model.has_value())
- selection = config->Fsr4Model.value_or(0) + 1;
-
- if (ImGui::Selectable(models[n], selection == n))
- {
- if (n < 1)
- config->Fsr4Model.reset();
- else
- config->Fsr4Model = n - 1;
-
- state.newBackend = currentBackend;
- MARK_ALL_BACKENDS_CHANGED();
- }
- }
-
- ImGui::EndCombo();
+ config->FsrNonLinearColorSpace = false;
}
- ShowHelpMarker("Each FSR4 preset uses its own model.\n"
- "Selecting a model won't change the upscaler preset!\n\n"
- "Model 0 is meant for FSR Native AA\n"
- "Model 1 is meant for Quality/Ultra Quality\n"
- "Model 2 is meant for Balanced\n"
- "Model 3 is meant for Performance\n"
- "Model 5 is meant for Ultra Performance");
- // ImGui::PopItemWidth();
-
- // ImGui::SameLine(0.0f, 6.0f);
-
- ImGui::TableNextColumn();
-
- if (state.currentFsr4Model.has_value())
- ImGui::Text("Current model: %d", state.currentFsr4Model.value());
+ state.newBackend = currentBackend;
+ MARK_ALL_BACKENDS_CHANGED();
+ }
+ ShowHelpMarker("Select the input colour space that the game uses.\n"
+ "Non-Linear / sRGB: Might improve FSR4 upscaling quality, might "
+ "increase ghosting.\n"
+ "PQ: Rarest, might increase ghosting and break lights.");
+
+ // FSR 4 Presets
+ const char* presets[] = { "Default", "Preset 0", "Preset 1", "Preset 2",
+ "Preset 3", "Preset 4", "Preset 5" };
+ int currentPresetIdx =
+ config->Fsr4Preset.has_value() ? config->Fsr4Preset.value() + 1 : 0;
+
+ if (currentPresetIdx < 0 || currentPresetIdx >= IM_ARRAYSIZE(presets))
+ currentPresetIdx = 0;
+
+ ImGui::SetNextItemWidth(150.0f * menuResScale);
+ if (ImGui::Combo("FSR4 Preset", ¤tPresetIdx, presets, IM_ARRAYSIZE(presets)))
+ {
+ if (currentPresetIdx == 0)
+ config->Fsr4Preset.reset();
else
- ImGui::Text("Failed to hook");
+ config->Fsr4Preset = currentPresetIdx - 1;
- ImGui::EndTable();
+ state.newBackend = currentBackend;
+ MARK_ALL_BACKENDS_CHANGED();
}
+ ShowHelpMarker(
+ "Each internal FSR4 preset is tuned for a specific resolution.\n"
+ "Selecting an FSR4 preset won't change the in-game\nupscaler preset!!!\n\n"
+ "Preset 0 is meant for FSR Native AA\n"
+ "Preset 1 is meant for Quality/Ultra Quality\n"
+ "Preset 2 is meant for Balanced\n"
+ "Preset 3 is meant for Performance\n"
+ "Preset 4 is meant for DRS\n"
+ "Preset 5 is meant for Ultra Performance");
+
+ // Display the active preset right next to the combo box instead of using a table
+ ImGui::SameLine();
+ if (state.currentFsr4Preset.has_value())
+ ImGui::TextDisabled("(Active: %d)", state.currentFsr4Preset.value());
+ else if (FSR4ModelSelection::IsInt8FsrHooked())
+ ImGui::TextColored(toneMapColor(ImVec4(1.f, 0.8f, 0.f, 1.f)),
+ "(Potential FSR3 fallback)");
+ else
+ ImGui::TextDisabled("(Failed to hook)");
}
if (majorFsrVersion >= 3)
{
- if (bool dView = config->FsrDebugView.value_or_default();
- ImGui::Checkbox("Upscaler Debug View", &dView))
+ ImGui::Spacing();
+
+ bool debugView = config->FsrDebugView.value_or_default();
+ if (ImGui::Checkbox("Upscaler Debug View", &debugView))
{
- config->FsrDebugView = dView;
+ config->FsrDebugView = debugView;
if (majorFsrVersion > 3)
{
- config->Fsr4EnableDebugView = dView;
+ config->Fsr4EnableDebugView = debugView;
state.newBackend = currentBackend;
MARK_ALL_BACKENDS_CHANGED();
}
@@ -3479,10 +3420,9 @@ bool MenuCommon::RenderMenu()
if (majorFsrVersion > 3)
{
- ImGui::SameLine(0.0f, 6.0f);
-
- if (bool fsr4wm = config->Fsr4EnableWatermark.value_or_default();
- ImGui::Checkbox("Upscaler Watermark", &fsr4wm))
+ ImGui::SameLine(0.0f, 20.0f * menuResScale);
+ bool fsr4wm = config->Fsr4EnableWatermark.value_or_default();
+ if (ImGui::Checkbox("Watermark", &fsr4wm))
{
LOG_DEBUG("FSR4 Watermark set to {}", fsr4wm);
config->Fsr4EnableWatermark = fsr4wm;
@@ -3496,7 +3436,70 @@ bool MenuCommon::RenderMenu()
if (currentFeature->Version() >= feature_version { 3, 1, 1 } &&
currentFeature->Version() < feature_version { 4, 0, 0 })
{
- if (auto ch = ScopedCollapsingHeader("FSR 3 Upscaler Fine Tuning"); ch.IsHeaderOpen())
+ ImGui::Spacing();
+
+ if (currentFeature != nullptr)
+ {
+ ImGui::Text("FSR 3.1 Presets:");
+
+ ImGui::SameLine(0.0f, 6.0f);
+
+ // This wiill be applied by default
+ if (ImGui::Button("Stability"))
+ {
+ auto const scaleRatioX = (float) currentFeature->TargetWidth() /
+ (float) currentFeature->RenderWidth();
+ auto const scaleRatioY = (float) currentFeature->TargetHeight() /
+ (float) currentFeature->RenderHeight();
+ auto const scaleRatio = std::max(scaleRatioX, scaleRatioY);
+
+ config->FsrVelocity = 0.5f;
+ config->FsrReactiveScale = 0.25f;
+
+ config->FsrShadingScale.reset();
+ config->FsrAccAddPerFrame.reset();
+ config->FsrMinDisOccAcc.reset();
+ config->FsrShadingScale.set_volatile_value(0.5f / scaleRatio);
+ config->FsrAccAddPerFrame.set_volatile_value(scaleRatio / 10.0f);
+ config->FsrMinDisOccAcc.set_volatile_value(scaleRatio / 20.0f);
+ }
+
+ ImGui::SameLine(0.0f, 6.0f);
+
+ if (ImGui::Button("Motion"))
+ {
+ auto const scaleRatioX = (float) currentFeature->TargetWidth() /
+ (float) currentFeature->RenderWidth();
+ auto const scaleRatioY = (float) currentFeature->TargetHeight() /
+ (float) currentFeature->RenderHeight();
+ auto const scaleRatio = std::max(scaleRatioX, scaleRatioY);
+
+ config->FsrVelocity = 1.0f;
+ config->FsrReactiveScale = 0.5f;
+
+ config->FsrShadingScale.reset();
+ config->FsrAccAddPerFrame.reset();
+ config->FsrMinDisOccAcc.reset();
+ config->FsrShadingScale.set_volatile_value(1.0f / scaleRatio);
+ config->FsrAccAddPerFrame.set_volatile_value(scaleRatio / 10.0f);
+ config->FsrMinDisOccAcc.set_volatile_value(scaleRatio / 20.0f);
+ }
+
+ ImGui::SameLine(0.0f, 6.0f);
+
+ if (ImGui::Button("Default"))
+ {
+ config->FsrVelocity = 1.0f;
+ config->FsrReactiveScale = 1.0f;
+ config->FsrShadingScale = 1.0f;
+ config->FsrAccAddPerFrame = 0.333f;
+ config->FsrMinDisOccAcc = -0.333f;
+ }
+ }
+
+ ImGui::Spacing();
+