Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

feat(xess): port OptiScaler multi-frame unlock with provider identity and rollback

Veyra Goal Agent4124a9d855e6
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11612f89..df55bb88 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,6 +74,7 @@ add_library(veyra_gfx STATIC
src/gfx/CommandSlotRing.cpp
src/gfx/PresentSink.cpp
src/gfx/XessPresenter.cpp
+ src/gfx/XessMfgUnlock.cpp
)
veyra_apply_warnings(veyra_gfx)
target_compile_features(veyra_gfx PUBLIC cxx_std_20)
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index 4d325375..95b7f1d2 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -3,6 +3,7 @@
#include "ui/SettingHelp.h"
#include "veyra/engine/PresetStore.h"
#include "veyra/RuntimePaths.h"
+#include "veyra/gfx/XessMfgUnlock.h"
#include <filesystem>
#include <sstream>
#include <iomanip>
@@ -61,7 +62,17 @@ void selectDiscrete(int group,int value){for(int j=0;j<(group==0?3:2);++j){auto
// full list; the engine gate rejects an unsupported request with a message.
int multiplierChoiceCount(engine::FrameGenerationBackend backend){
int cap=6;
- if(backend==engine::FrameGenerationBackend::XeSS)cap=2; // raised by the MFG unlock path
+ if(backend==engine::FrameGenerationBackend::XeSS){
+ // Stock provider is 2X only; the audited OptiScaler unlock raises it to
+ // 4X. Hash the provider once, and prefer the ceiling an actual session
+ // already reported.
+ static const bool providerAudited=[](){
+ const auto path=veyra::runtime::localDataDirectory()/L"intel"/L"experimental"/L"libxess_fg.dll";
+ return veyra::gfx::XessMfgUnlock::providerIsAudited(path.wstring());
+ }();
+ cap=providerAudited?4:2;
+ if(controller){const auto snapshot=controller->snapshot();if(snapshot.xessMaxInterpolatedFrames>1)cap=std::clamp(snapshot.xessMaxInterpolatedFrames+1,2,4);}
+ }
else if(controller){const auto snapshot=controller->snapshot();if(snapshot.fgMultiFrameMax>0)cap=std::clamp(snapshot.fgMultiFrameMax+1,2,6);}
int count=1;
for(size_t i=1;i<engine::kFgMultiplierChoiceCount;++i)if(int(engine::kFgMultiplierChoices[i])<=cap)++count;
@@ -104,7 +115,11 @@ bool read(engine::EnhancementSettings& s,bool allPages=false){s=enhancementEnabl
wchar_t offset[32]{};GetWindowTextW(item(217),offset,32);wchar_t* offsetEnd=nullptr;const auto parsed=wcstol(offset,&offsetEnd,10);
if(offsetEnd==offset||*offsetEnd||parsed<-250||parsed>250){message(L"声音偏移须为 -250 至 250 ms");return false;}s.audioOffsetMs=int(parsed);
for(int j=0;j<3;++j)if(GetPropW(item(730+j),L"veyra.selected")){s.srTarget=static_cast<pipeline::SrTarget>(j);break;}
- if(s.frameGenerationBackend==engine::FrameGenerationBackend::XeSS)s.multiplier=std::min(s.multiplier,2u);
+ if(s.frameGenerationBackend==engine::FrameGenerationBackend::XeSS){
+ const int choices=multiplierChoiceCount(engine::FrameGenerationBackend::XeSS);
+ const size_t index=size_t(std::clamp(choices-1,1,int(engine::kFgMultiplierChoiceCount)-1));
+ s.multiplier=std::min(s.multiplier,engine::kFgMultiplierChoices[index]);
+ }
}if(!s.validate().empty()){message(L"参数越界,未提交。悬停数值框查看允许范围。");return false;}return true;}
// Each notification changes one field on the latest desired settings. Hidden
@@ -129,7 +144,7 @@ bool liveField(int id){
case 203:s.nrPolicy=static_cast<pipeline::NrSizePolicy>(send(id,CB_GETCURSEL));break;
case 204:s.flow=static_cast<engine::FlowQuality>(send(id,CB_GETCURSEL));break;
case 205:s.content=static_cast<engine::ContentRate>(send(id,CB_GETCURSEL));break;
- case 208:s.frameGenerationBackend=static_cast<engine::FrameGenerationBackend>(send(id,CB_GETCURSEL));if(s.frameGenerationBackend==engine::FrameGenerationBackend::XeSS)s.multiplier=std::min(s.multiplier,2u);break;
+ case 208:{s.frameGenerationBackend=static_cast<engine::FrameGenerationBackend>(send(id,CB_GETCURSEL));if(s.frameGenerationBackend==engine::FrameGenerationBackend::XeSS){const int choices=multiplierChoiceCount(engine::FrameGenerationBackend::XeSS);const size_t index=size_t(std::clamp(choices-1,1,int(engine::kFgMultiplierChoiceCount)-1));s.multiplier=std::min(s.multiplier,engine::kFgMultiplierChoices[index]);}break;}
case 209:s.opticalFlowBackend=static_cast<engine::OpticalFlowBackend>(send(id,CB_GETCURSEL));break;
case 220:s.lowLatency=checked(id)==BST_CHECKED;break;
case 215:s.amdFlowHalfResolution=checked(id)==BST_CHECKED;break;
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index 35655fbf..d08c5244 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -563,7 +563,7 @@ int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<a
// The legacy argument clamp caps --fg-multiplier at 4X. Re-read the flag here so
// 6X (and 2X/3X/4X) can be exercised from the command line for diagnostics and
// smoke tests; the interactive UI uses the capability-driven list instead.
-{int fgArgc=0;auto fgArgv=CommandLineToArgvW(GetCommandLineW(),&fgArgc);for(int i=1;i+1<fgArgc;++i)if(!_wcsicmp(fgArgv[i],L"--fg-multiplier")){const int value=_wtoi(fgArgv[i+1]);if(value>=2&&value<=6){initialOptions.fgMultiplier=uint32_t(value);initialOptions.fg=true;}else if(value==1){initialOptions.fg=false;initialOptions.fgMultiplier=2;}}if(fgArgv)LocalFree(fgArgv);}
+{int fgArgc=0;auto fgArgv=CommandLineToArgvW(GetCommandLineW(),&fgArgc);for(int i=1;i<fgArgc;++i){if(!_wcsicmp(fgArgv[i],L"--fg-multiplier")&&i+1<fgArgc){const int value=_wtoi(fgArgv[i+1]);if(value>=2&&value<=6){initialOptions.fgMultiplier=uint32_t(value);initialOptions.fg=true;}else if(value==1){initialOptions.fg=false;initialOptions.fgMultiplier=2;}}else if(!_wcsicmp(fgArgv[i],L"--fg-xess")){initialOptions.settings.frameGenerationBackend=veyra::engine::FrameGenerationBackend::XeSS;if(initialOptions.fgMultiplier<2)initialOptions.fgMultiplier=2;initialOptions.fg=true;}else if(!_wcsicmp(fgArgv[i],L"--fg-dlss")){initialOptions.settings.frameGenerationBackend=veyra::engine::FrameGenerationBackend::Dlss;}}if(fgArgv)LocalFree(fgArgv);}
if(workerMapping){const int code=veyra::engine::runExportWorker(workerMapping);CoUninitialize();return code;}
if(smokeSeconds<=0&&exportOutput.empty()){uiPreferences=preferences.load();initialOptions=veyra::engine::PlayerOptions::from(preferences.startup(initialOptions.snapshot()));engine.setVolume(uiPreferences.volume,uiPreferences.muted);uiState.subtitles=uiPreferences.subtitles;subtitlePixels=uiPreferences.subtitleSize;}
engine.requestSettings(initialOptions.snapshot());
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index b5b80264..83fcc5f8 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -62,6 +62,10 @@ struct PlayerSnapshot {
// multipliers the active GPU can actually honour.
int fgMultiFrameMax=0;
bool fgCapabilityKnown=false;
+ // XeSS frame-generation ceiling (generated frames; 1 = stock 2X, 3 = 4X).
+ // 0 = no XeSS session has reported yet; the settings UI then falls back to
+ // the audited-provider probe.
+ int xessMaxInterpolatedFrames=0;
bool running=false,failed=false,image=false,capture=false,remotePlay=false;
int remotePlayState=0; uint64_t remotePlaySkipped=0;
bool remoteRecovering=false;unsigned remoteReconnectAttempts=0;std::wstring remoteRecoveryMessage;
@@ -112,5 +116,7 @@ private:
std::atomic<int> comparisonMode_{0};std::atomic<bool> comparisonBase_{false};std::atomic<float> comparisonSplit_{.5f};
// Guarded by mutex_: DLSSG MultiFrameCountMax of the active session.
int fgMultiFrameMaxCap_=0;
+ // Guarded by mutex_: XeSS provider ceiling of the active session (0 = unknown).
+ int xessMaxInterpolatedFramesCap_=0;
};
}
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index 3a3f5fed..bb6f8910 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -114,7 +114,10 @@ struct EnhancementSettings {
if(model.style<0||model.style>2||model.autoMask<0||model.autoMask>1||model.uiCorrection<0||model.uiCorrection>1)return "invalid experimental parameter";
for(float v:{residual.total,residual.darken,residual.brighten,residual.color,residual.luminance})if(!range(v,2))return "residual parameter out of range";
if(frameGenerationBackend<FrameGenerationBackend::Dlss||frameGenerationBackend>FrameGenerationBackend::XeSS)return "invalid frame generation backend";
- if(frameGenerationBackend==FrameGenerationBackend::XeSS&&multiplier>2)return "XeSS preview currently supports 2X only";
+ // The XeSS provider reports its own generated-frame ceiling at session
+ // start; the engine clamps/rejects above it, so validation only guards
+ // the absolute API range here.
+ if(frameGenerationBackend==FrameGenerationBackend::XeSS&&multiplier>4)return "XeSS frame generation supports up to 4X";
if(videoSrQuality>4)return "invalid video SR quality";
if(!pipeline::validSrTarget(srTarget))return "invalid SR target";
if(opticalFlowBackend!=OpticalFlowBackend::Nvidia&&opticalFlowBackend!=OpticalFlowBackend::AmdFidelityFx&&opticalFlowBackend!=OpticalFlowBackend::GpuDis)return "invalid optical flow backend";
diff --git a/include/veyra/gfx/PresentSink.h b/include/veyra/gfx/PresentSink.h
index a08b808f..7d94d54f 100644
--- a/include/veyra/gfx/PresentSink.h
+++ b/include/veyra/gfx/PresentSink.h
@@ -39,6 +39,9 @@ public:
bool captureCompatible = false;
bool hdr = false;
bool hdr10 = false;
+ // Requested frame-generation multiplier (2 = one generated frame).
+ // Only the XeSS path consumes it today; >2 requires the provider unlock.
+ uint32_t fgMultiplier = 1;
// Probe runs create their own window class name per process.
std::wstring title = L"Veyra";
HWND targetWindow = nullptr; // borrowed UI-owned child HWND; never destroyed by sink
diff --git a/include/veyra/gfx/XessMfgUnlock.h b/include/veyra/gfx/XessMfgUnlock.h
new file mode 100644
index 00000000..f1b8b668
--- /dev/null
+++ b/include/veyra/gfx/XessMfgUnlock.h
@@ -0,0 +1,62 @@
+#pragma once
+
+#include <windows.h>
+
+#include <cstdint>
+#include <string>
+
+namespace veyra::gfx {
+
+// Process-memory unlock for Intel XeSS frame-generation multi-frame support on
+// non-Intel GPUs.
+//
+// Ported from Coldwood1026/OptiScaler (GPL-3.0,
+// commit 70676c5f037c8c26f1ec355b250a72303cd268da, proxies/XeFGUnlock.h) and
+// adapted for Veyra: strict provider identity (path + size + SHA-256) before any
+// write, transactional install with read-back verification, and full rollback
+// when the frame-generation session ends.
+//
+// Only the already-mapped image is modified. The DLL on disk is never touched,
+// never re-signed and never renamed; if the provider build does not match the
+// audited identity the unlock refuses to run and the caller keeps the stock
+// 2X behaviour.
+class XessMfgUnlock {
+public:
+ // Generated frames the UI may request: 1 = 2X, 2 = 3X, 3 = 4X.
+ static constexpr uint32_t kMaxGeneratedFrames = 3;
+ // Audited provider identity (Intel libxess_fg.dll 1.3.1.78 shipped with Veyra).
+ static constexpr uint64_t kKnownProviderSize = 22957432ull;
+ static constexpr const char* kKnownProviderSha256 =
+ "EC5E0C65E075570C6EDE72618BB666D0BE0C2E10B2EA9762C0FE8CB8E375AB27";
+ static constexpr uint32_t kKnownTimeDateStamp = 0x69CB0F4Du;
+ static constexpr uint32_t kKnownSizeOfImage = 0x015ED000u;
+
+ struct State {
+ bool providerLoaded = false; // a module handle was supplied
+ bool identityVerified = false; // size + SHA-256 matched the audited build
+ bool recognisedBuild = false; // PE TimeDateStamp + SizeOfImage matched
+ bool applied = false; // every requested patch is installed
+ uint32_t generatedFrames = 1; // patched ceiling (1 = stock 2X)
+ uint32_t maxInterpolations = 1; // runtime-reported ceiling after patching
+ std::wstring detail; // last outcome, safe to log and display
+ };
+
+ // Installs the unlock into the mapped provider image. Idempotent. Passing
+ // generatedFrames <= 1 leaves the provider untouched (stock 2X).
+ static State apply(HMODULE provider, uint32_t generatedFrames);
+ // Records the runtime-reported interpolation ceiling after the XeFG context
+ // exists, so the settings UI can offer exactly what is supported.
+ static void reportRuntimeCeiling(uint32_t maxInterpolations);
+ // Restores every patched byte. Safe to call repeatedly and when nothing was
+ // applied.
+ static void release();
+
+ static State snapshot();
+ static bool applied();
+ // Read-only identity check: true when the provider file at `path` is the
+ // audited build these byte tables apply to. Never patches anything, so the
+ // settings UI can offer 3X/4X before a session has run.
+ static bool providerIsAudited(const std::wstring& path);
+};
+
+} // namespace veyra::gfx
diff --git a/include/veyra/gfx/XessPresenter.h b/include/veyra/gfx/XessPresenter.h
index f0a871c4..d75193f9 100644
--- a/include/veyra/gfx/XessPresenter.h
+++ b/include/veyra/gfx/XessPresenter.h
@@ -9,7 +9,9 @@ class XessPresenter {
public:
XessPresenter();
~XessPresenter();
- bool initialize(ID3D12Device*,ID3D12CommandQueue*,IDXGIFactory2*,HWND,const DXGI_SWAP_CHAIN_DESC1&,IDXGISwapChain3**);
+ // fgMultiplier is the requested output multiplier (2 = one generated frame,
+ // 3 = two, 4 = three). >2 requires the audited provider unlock.
+ bool initialize(ID3D12Device*,ID3D12CommandQueue*,IDXGIFactory2*,HWND,const DXGI_SWAP_CHAIN_DESC1&,IDXGISwapChain3**,uint32_t fgMultiplier=1);
bool beginFrame();
bool tag(ID3D12GraphicsCommandList*,ID3D12Resource* color,ID3D12Resource* motion,ID3D12Resource* depth,
RECT region,bool enabled,bool reset,float elapsedMs);
@@ -17,6 +19,9 @@ public:
bool afterPresent();
uint64_t generatedCount() const;
uint64_t presentedCount() const;
+ // Runtime-reported ceiling of generated frames (1 = 2X) after the provider
+ // capability query; 1 until the context exists.
+ uint32_t maxInterpolatedFrames() const;
private:
struct Impl;
std::unique_ptr<Impl> p_;
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index 55b6fd9a..20f70b8d 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -201,6 +201,9 @@ public:
DXGI_FORMAT outputFormat() const { return hdr10Output()?DXGI_FORMAT_R10G10B10A2_UNORM:desc_.hdrOutput?DXGI_FORMAT_R16G16B16A16_FLOAT:DXGI_FORMAT_R8G8B8A8_UNORM; }
bool highQualityPresentation() const { return desc_.highQualityPresentation; }
bool xessEnabled() const { return desc_.enableFg && !desc_.noFeatures && !desc_.stillImage && desc_.frameGenerationBackend==engine::FrameGenerationBackend::XeSS; }
+ // Requested output multiplier (2 = one generated frame). Consumed by the
+ // present sink so the XeSS provider knows how many frames to generate.
+ uint32_t fgMultiplier() const { return desc_.fgMultiplier; }
ID3D12Resource* presentMotion(uint32_t slot) const { return presentMotion_[slot%2].Get(); }
ID3D12Resource* presentDepth() const { return depthTex_.Get(); }
bool presentMotionValid(uint32_t slot) const { return presentMotionValid_[slot%2]; }
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 42789d01..6af29957 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -20,6 +20,7 @@
#endif
#include "veyra/pipeline/EnhanceGraph.h"
#include "veyra/pipeline/ResetCoordinator.h"
+#include "veyra/gfx/XessMfgUnlock.h"
#include "veyra/diagnostics/ResetCause.h"
#include "veyra/sink/WasapiAudioSink.h"
#include "veyra/sink/ImageExportSink.h"
@@ -61,7 +62,7 @@ bool EngineController::idle()const{std::lock_guard lock(mutex_);return !busy_&&!
void EngineController::open(HWND video,const std::wstring& path,PlayerOptions opts){
const bool captureReplay=opts.captureReplayForTest;
const bool disableAdmission=opts.captureReplayDisableFgAdmissionForTest;
- {std::lock_guard lock(mutex_);snapshot_={};activeFlow_.reset();previewView_={};fgMultiFrameMaxCap_=0;snapshot_.sessionId=++sessionId_;snapshot_.transport=TransportState::Opening;savePath_.clear();desired_=opts.snapshot();desired_.revision=++nextRevision_;snapshot_.desired=desired_;opts=PlayerOptions::from(desired_);}
+ {std::lock_guard lock(mutex_);snapshot_={};activeFlow_.reset();previewView_={};fgMultiFrameMaxCap_=0;xessMaxInterpolatedFramesCap_=0;snapshot_.sessionId=++sessionId_;snapshot_.transport=TransportState::Opening;savePath_.clear();desired_=opts.snapshot();desired_.revision=++nextRevision_;snapshot_.desired=desired_;opts=PlayerOptions::from(desired_);}
opts.captureReplayForTest=captureReplay;
opts.captureReplayDisableFgAdmissionForTest=disableAdmission;
post([this,video,path,opts]{paused_=false;seekSeconds_=-1;run(video,path,opts);});
@@ -69,7 +70,7 @@ void EngineController::open(HWND video,const std::wstring& path,PlayerOptions op
#ifdef VEYRA_ENABLE_REMOTEPLAY
void EngineController::openRemotePlay(HWND window,source::RemotePlayConnectDesc desc,PlayerOptions opts){
auto request=std::make_shared<source::RemotePlayConnectDesc>(std::move(desc));
- {std::lock_guard lock(mutex_);snapshot_={};activeFlow_.reset();previewView_={};fgMultiFrameMaxCap_=0;snapshot_.sessionId=++sessionId_;snapshot_.transport=TransportState::Opening;snapshot_.remotePlay=true;snapshot_.capture=true;savePath_.clear();desired_=opts.snapshot();desired_.revision=++nextRevision_;snapshot_.desired=desired_;opts=PlayerOptions::from(desired_);}
+ {std::lock_guard lock(mutex_);snapshot_={};activeFlow_.reset();previewView_={};fgMultiFrameMaxCap_=0;xessMaxInterpolatedFramesCap_=0;snapshot_.sessionId=++sessionId_;snapshot_.transport=TransportState::Opening;snapshot_.remotePlay=true;snapshot_.capture=true;savePath_.clear();desired_=opts.snapshot();desired_.revision=++nextRevision_;snapshot_.desired=desired_;opts=PlayerOptions::from(desired_);}
post([this,window,request,opts]{paused_=false;seekSeconds_=-1;run(window,L"remoteplay:",opts,request);});
}
remoteplay::ControllerFeedback EngineController::remotePlayFeedback(){std::lock_guard lock(mutex_);return activeRemote_?activeRemote_->takeFeedback():remoteplay::ControllerFeedback{};}
@@ -92,6 +93,13 @@ bool EngineController::requestSettings(EnhancementSettings s){
veyra::log::info("settings",std::format("multiplier gate: requested={} maxGeneratedFrames={} applied=unchanged",s.multiplier,fgMultiFrameMaxCap_));
return false;
}
+ if(s.multiplier>1&&s.frameGenerationBackend==FrameGenerationBackend::XeSS&&xessMaxInterpolatedFramesCap_>0&&
+ int(s.multiplier)-1>xessMaxInterpolatedFramesCap_){
+ snapshot_.status=std::format(L"XeSS 帧生成上限为 {}X;请求未应用",xessMaxInterpolatedFramesCap_+1);
+ snapshot_.failed=false;
+ veyra::log::info("settings",std::format("xess multiplier gate: requested={} maxInterpolatedFrames={} applied=unchanged",s.multiplier,xessMaxInterpolatedFramesCap_));
+ return false;
+ }
// Revision partitions GPU history and measurements. Audio-only edits must
// not invalidate in-flight video, and identical notifications are no-ops.
s.revision=desired_.revision;if(s==desired_)return true;
@@ -258,14 +266,21 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
// generation entirely (the old behaviour users saw as "选了 4X
// 之后补帧直接没了").
bool clampedOverCapability=false;
- if(failure==FailedBackend::Fg&&reduced.multiplier>1&&graph.fgMultiFrameCountMax()>0&&
- int(reduced.multiplier)-1>graph.fgMultiFrameCountMax()){
- const uint32_t clamped=uint32_t(graph.fgMultiFrameCountMax()+1);
- veyra::log::warn("backend-recovery",std::format("requested multiplier {} exceeds GPU capability maxGeneratedFrames={}; applying {}X with frame generation kept",reduced.multiplier,graph.fgMultiFrameCountMax(),clamped));
+ int capabilityGeneratedFrames=-1;
+ if(failure==FailedBackend::Fg&&reduced.multiplier>1){
+ if(reduced.frameGenerationBackend==FrameGenerationBackend::Dlss)capabilityGeneratedFrames=graph.fgMultiFrameCountMax();
+ else if(reduced.frameGenerationBackend==FrameGenerationBackend::XeSS){
+ const auto xessState=gfx::XessMfgUnlock::snapshot();
+ if(xessState.applied)capabilityGeneratedFrames=int(xessState.maxInterpolations);
+ }
+ }
+ if(capabilityGeneratedFrames>0&&int(reduced.multiplier)-1>capabilityGeneratedFrames){
+ const uint32_t clamped=uint32_t(capabilityGeneratedFrames+1);
+ veyra::log::warn("backend-recovery",std::format("requested multiplier {} exceeds capability maxGeneratedFrames={}; applying {}X with frame generation kept",reduced.multiplier,capabilityGeneratedFrames,clamped));
reduced.multiplier=clamped;
clampedOverCapability=true;
if(!backendRecoveryWarning.empty())backendRecoveryWarning+=L";";
- backendRecoveryWarning+=std::format(L"此显卡最多支持 {}X 帧生成,已按 {}X 应用",clamped,clamped);
+ backendRecoveryWarning+=std::format(L"当前最多支持 {}X 帧生成,已按 {}X 应用",clamped,clamped);
}
if(FAILED(ctx.device()->GetDeviceRemovedReason()))return false;
if(!clampedOverCapability&&!disableFailedBackend(reduced,failure))return false;
@@ -292,7 +307,13 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
fgMultiFrameMaxCap_=graph.fgMultiFrameCountMax();
snapshot_.fgMultiFrameMax=fgMultiFrameMaxCap_;
snapshot_.fgCapabilityKnown=fgMultiFrameMaxCap_>0;
+ const auto xessState=gfx::XessMfgUnlock::snapshot();
+ // Unknown until the XeSS provider actually ran: a DLSS-only
+ // session must not restrict the XeSS choices in the UI.
+ xessMaxInterpolatedFramesCap_=xessState.providerLoaded?(xessState.applied&&xessState.maxInterpolations>0?int(xessState.maxInterpolations):1):0;
+ snapshot_.xessMaxInterpolatedFrames=xessMaxInterpolatedFramesCap_;
if(fgMultiFrameMaxCap_>0)veyra::log::info("settings",std::format("frame-generation capability: maxGeneratedFrames={} maxMultiplier={}",fgMultiFrameMaxCap_,fgMultiFrameMaxCap_+1));
+ veyra::log::info("settings",std::format("xess capability: maxInterpolatedFrames={} unlockApplied={} => maxMultiplier={}",xessState.maxInterpolations,xessState.applied,xessMaxInterpolatedFramesCap_+1));
}
if(!previewInitialized){status(L"视频初始化失败,请查看对应组件的诊断日志",true);break;}
if(!backendRecoveryWarning.empty()){
diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cpp
index c8dedc58..490518d7 100644
--- a/src/engine/VideoPresenter.cpp
+++ b/src/engine/VideoPresenter.cpp
@@ -7,7 +7,7 @@ namespace veyra::engine {
bool VideoPresenter::open(gfx::D3D12DeviceContext& ctx,HWND window,pipeline::EnhanceGraph& graph,bool captureCompatible) {
gpuTimer_.initialize(ctx.device(),ctx.directQueue());window_=window;RECT rc{};GetClientRect(window,&rc);
gfx::PresentSink::Desc d;d.targetWindow=window;d.width=std::max(1L,rc.right);d.height=std::max(1L,rc.bottom);d.vsync=false;
- d.hdr=graph.hdrOutput();d.hdr10=graph.hdr10Output();d.xess=graph.xessEnabled();d.captureCompatible=captureCompatible;lastXessFrame_={};lastXessIdentity_={};xessWasEnabled_=false;
+ d.hdr=graph.hdrOutput();d.hdr10=graph.hdr10Output();d.xess=graph.xessEnabled();d.captureCompatible=captureCompatible;d.fgMultiplier=graph.fgMultiplier();lastXessFrame_={};lastXessIdentity_={};xessWasEnabled_=false;
Status st=Status::Ok;if(!sink_.initialize(ctx.device(),ctx.directQueue(),d,st))return false;
std::vector<uint8_t> vs,ps;
// SRV layout: 0..1 video frames, 2..11 generated frames (2 parities x 5
diff --git a/src/gfx/PresentSink.cpp b/src/gfx/PresentSink.cpp
index ef97c48a..dd8baf02 100644
--- a/src/gfx/PresentSink.cpp
+++ b/src/gfx/PresentSink.cpp
@@ -123,7 +123,7 @@ bool PresentSink::initialize(ID3D12Device* device, ID3D12CommandQueue* queue,
ComPtr<IDXGISwapChain1> swapChain1;
if(desc.xess){
xess_=std::make_unique<XessPresenter>();
- if(!xess_->initialize(device,queue,factory_.Get(),hwnd_,scd,swapChain_.GetAddressOf())){
+ if(!xess_->initialize(device,queue,factory_.Get(),hwnd_,scd,swapChain_.GetAddressOf(),desc.fgMultiplier)){
// XeSS is an optional experimental presenter. A missing or
// incompatible local runtime must not prevent basic playback.
log::warn("present", "XeSS FG initialization failed; falling back to native presentation");
diff --git a/src/gfx/XessMfgUnlock.cpp b/src/gfx/XessMfgUnlock.cpp
new file mode 100644
index 00000000..7b3653c6
--- /dev/null
+++ b/src/gfx/XessMfgUnlock.cpp
@@ -0,0 +1,289 @@
+#include "veyra/gfx/XessMfgUnlock.h"
+
+#include <format>
+#include <cstring>
+#include <iterator>
+#include <mutex>
+#include <vector>
+
+#include "veyra/FileIdentity.h"
+#include "veyra/Log.h"
+
+namespace veyra::gfx {
+
+namespace {
+
+// Byte tables ported from OptiScaler XeFGUnlock.h (GPL-3.0, commit 70676c5f).
+// U1 removes the "XeLL too old for multi-frame" fallback to 2X, U2 keeps the
+// multi-frame model from being downgraded, U3 raises the default ceiling, U4
+// stops the provider from pinning the override to a single frame and U5 makes
+// xefgSwapChainGetProperties report the real ceiling instead of 1.
+struct PatchSpec {
+ const char* name;
+ uint32_t rva;
+ const uint8_t* expected;
+ uint32_t size;
+ const uint8_t* replacement;
+ int32_t immediateOffset; // -1: fixed replacement, otherwise LE imm32 slot
+ bool enabled;
+};
+
+const uint8_t kU1Old[] = {0x0F, 0x85, 0xCC, 0x00, 0x00, 0x00};
+const uint8_t kU1New[] = {0xE9, 0xCD, 0x00, 0x00, 0x00, 0x90};
+const uint8_t kU2Old[] = {0x74, 0x09};
+const uint8_t kU2New[] = {0xEB, 0x06};
+const uint8_t kU3Old[] = {0xBB, 0x03, 0x00, 0x00, 0x00};
+const uint8_t kU3New[] = {0xBB, 0x00, 0x00, 0x00, 0x00};
+const uint8_t kU4Old[] = {0xC7, 0x87, 0x6C, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};
+const uint8_t kU4New[] = {0xC7, 0x87, 0x6C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+const uint8_t kU5Old[] = {0xB8, 0x01, 0x00, 0x00, 0x00};
+const uint8_t kU5New[] = {0xB8, 0x00, 0x00, 0x00, 0x00};
+
+const PatchSpec kPatches[] = {
+ {"U1/frame-count-fallback", 0x20DA4F, kU1Old, sizeof(kU1Old), kU1New, -1, true},
+ {"U2/model-downgrade", 0x1A5DE4, kU2Old, sizeof(kU2Old), kU2New, -1, true},
+ {"U3/default-ceiling", 0x1A517D, kU3Old, sizeof(kU3Old), kU3New, 1, true},
+ {"U4/override-clamp", 0x1A45C2, kU4Old, sizeof(kU4Old), kU4New, 6, true},
+ {"U5/reported-maximum", 0x20973B, kU5Old, sizeof(kU5Old), kU5New, 1, true},
+};
+
+struct AppliedPatch {
+ uint8_t* address = nullptr;
+ uint8_t original[16]{};
+ uint32_t size = 0;
+ const char* name = "";
+};
+
+std::mutex g_mutex;
+XessMfgUnlock::State g_state;
+std::vector<AppliedPatch> g_applied;
+
+const IMAGE_DOS_HEADER* dosHeader(uint8_t* base) {
+ if (base == nullptr) return nullptr;
+ auto* dos = reinterpret_cast<const IMAGE_DOS_HEADER*>(base);
+ if (dos->e_magic != IMAGE_DOS_SIGNATURE) return nullptr;
+ if (dos->e_lfanew <= 0 || dos->e_lfanew > 0x1000) return nullptr;
+ return dos;
+}
+
+const IMAGE_NT_HEADERS* ntHeaders(uint8_t* base) {
+ const auto* dos = dosHeader(base);
+ if (dos == nullptr) return nullptr;
+ auto* nt = reinterpret_cast<const IMAGE_NT_HEADERS*>(base + dos->e_lfanew);
+ if (nt->Signature != IMAGE_NT_SIGNATURE) return nullptr;
+ return nt;
+}
+
+const IMAGE_SECTION_HEADER* findSection(uint8_t* base, const char* name) {
+ const auto* nt = ntHeaders(base);
+ if (nt == nullptr) return nullptr;
+ const auto* section = IMAGE_FIRST_SECTION(nt);
+ for (WORD i = 0; i < nt->FileHeader.NumberOfSections; ++i, ++section) {
+ char sectionName[9]{};
+ memcpy(sectionName, section->Name, 8);
+ if (strcmp(sectionName, name) == 0) return section;
+ }
+ return nullptr;
+}
+
+bool insideSection(const IMAGE_SECTION_HEADER* section, uint32_t rva, uint32_t size) {
+ if (section == nullptr) return false;
+ const uint32_t start = section->VirtualAddress;
+ const uint32_t end = start + section->Misc.VirtualSize;
+ return rva >= start && rva + size <= end;
+}
+
+std::string toHex(const uint8_t* data, uint32_t size) {
+ std::string text;
+ text.reserve(size * 3);
+ for (uint32_t i = 0; i < size; ++i) {
+ if (i) text.push_back(' ');
+ text += std::format("{:02X}", data[i]);
+ }
+ return text;
+}
+
+bool writeVerified(uint8_t* address, const uint8_t* bytes, uint32_t size) {
+ DWORD previous = 0;
+ if (!VirtualProtect(address, size, PAGE_EXECUTE_READWRITE, &previous)) return false;
+ memcpy(address, bytes, size);
+ FlushInstructionCache(GetCurrentProcess(), address, size);
+ VirtualProtect(address, size, previous, &previous);
+ return memcmp(address, bytes, size) == 0;
+}
+
+} // namespace
+
+XessMfgUnlock::State XessMfgUnlock::apply(HMODULE provider, uint32_t generatedFrames) {
+ std::lock_guard lock(g_mutex);
+ State state = g_state;
+ state.providerLoaded = provider != nullptr;
+ if (generatedFrames < 1) generatedFrames = 1;
+ if (generatedFrames > kMaxGeneratedFrames) generatedFrames = kMaxGeneratedFrames;
+
+ if (provider == nullptr) {
+ state.detail = L"XeSS frame-generation provider is not loaded";
+ g_state = state;
+ return state;
+ }
+
+ // Stock 2X: nothing to patch, and a previously applied unlock must not leak
+ // into a 2X session.
+ if (generatedFrames <= 1) {
+ state.detail = L"2X requested; provider left untouched";
+ state.generatedFrames = 1;
+ g_state = state;
+ return state;
+ }
+
+ if (state.applied && g_state.generatedFrames == generatedFrames) return state;
+
+ // Provider identity: absolute path, size and SHA-256 must match the audited
+ // build. A different provider version simply keeps stock 2X behaviour.
+ wchar_t modulePath[MAX_PATH * 2]{};
+ if (GetModuleFileNameW(provider, modulePath, static_cast<DWORD>(std::size(modulePath))) == 0) {
+ state.detail = L"provider path unavailable";
+ g_state = state;
+ return state;
+ }
+ FileIdentity identity{};
+ IdentityError identityError = IdentityError::None;
+ if (!computeFileIdentity(modulePath, identity, identityError)) {
+ state.detail = std::format(L"provider identity failed (code {})", static_cast<int>(identityError));
+ g_state = state;
+ return state;
+ }
+ state.identityVerified = identity.sizeBytes == kKnownProviderSize && identity.sha256Upper == kKnownProviderSha256;
+
+ auto* base = reinterpret_cast<uint8_t*>(provider);
+ const auto* nt = ntHeaders(base);
+ const auto* text = findSection(base, ".text");
+ state.recognisedBuild = nt != nullptr && text != nullptr &&
+ nt->FileHeader.TimeDateStamp == kKnownTimeDateStamp &&
+ nt->OptionalHeader.SizeOfImage == kKnownSizeOfImage;
+
+ if (!state.identityVerified) {
+ state.detail = std::format(L"unaudited provider (size={} sha256={})", identity.sizeBytes,
+ std::wstring(identity.sha256Upper.begin(), identity.sha256Upper.end()));
+ veyra::log::warn("xess-mfg", std::format("unlock refused: unaudited provider size={} sha256={} recognisedBuild={}",
+ identity.sizeBytes, identity.sha256Upper, state.recognisedBuild));
+ g_state = state;
+ return state;
+ }
+ if (!state.recognisedBuild) {
+ state.detail = L"provider PE identity does not match the audited build";
+ veyra::log::warn("xess-mfg", "unlock refused: PE timestamp/image size mismatch");
+ g_state = state;
+ return state;
+ }
+
+ // Build the replacement bytes for every enabled patch first (transactional:
+ // all positions are validated before the first write).
+ struct Planned {
+ const PatchSpec* spec;
+ uint8_t bytes[16]{};
+ };
+ std::vector<Planned> planned;
+ planned.reserve(std::size(kPatches));
+ for (const auto& patch : kPatches) {
+ if (!patch.enabled || patch.size > sizeof(Planned::bytes)) continue;
+ if (!insideSection(text, patch.rva, patch.size)) {
+ state.detail = std::format(L"{} outside .text", std::wstring(patch.name, patch.name + strlen(patch.name)));
+ g_state = state;
+ return state;
+ }
+ uint8_t* destination = base + patch.rva;
+ if (memcmp(destination, patch.expected, patch.size) != 0) {
+ state.detail = std::format(L"{} has unexpected bytes ({})", std::wstring(patch.name, patch.name + strlen(patch.name)),
+ std::wstring(toHex(destination, patch.size).begin(), toHex(destination, patch.size).end()));
+ veyra::log::error("xess-mfg", std::format("unlock aborted: {} at 0x{:X} expected [{}] found [{}]", patch.name, patch.rva,
+ toHex(patch.expected, patch.size), toHex(destination, patch.size)));
+ g_state = state;
+ return state;
+ }
+ Planned plan{};
+ plan.spec = &patch;
+ memcpy(plan.bytes, patch.replacement, patch.size);
+ if (patch.immediateOffset >= 0) {
+ plan.bytes[patch.immediateOffset + 0] = static_cast<uint8_t>(generatedFrames & 0xFF);
+ plan.bytes[patch.immediateOffset + 1] = static_cast<uint8_t>((generatedFrames >> 8) & 0xFF);
+ plan.bytes[patch.immediateOffset + 2] = static_cast<uint8_t>((generatedFrames >> 16) & 0xFF);
+ plan.bytes[patch.immediateOffset + 3] = static_cast<uint8_t>((generatedFrames >> 24) & 0xFF);
+ }
+ planned.push_back(plan);
+ }
+
+ size_t installed = 0;
+ for (const auto& plan : planned) {
+ auto* destination = reinterpret_cast<uint8_t*>(provider) + plan.spec->rva;
+ if (!writeVerified(destination, plan.bytes, plan.spec->size)) {
+ state.detail = std::format(L"{} write verification failed", std::wstring(plan.spec->name, plan.spec->name + strlen(plan.spec->name)));
+ veyra::log::error("xess-mfg", std::format("unlock aborted at {} (0x{:X}); rolling back {} patch(es)", plan.spec->name, plan.spec->rva, installed));
+ for (auto it = g_applied.rbegin(); it != g_applied.rend(); ++it) {
+ writeVerified(it->address, it->original, it->size);
+ }
+ g_applied.clear();
+ state.applied = false;
+ g_state = state;
+ return state;
+ }
+ AppliedPatch record{};
+ record.address = destination;
+ memcpy(record.original, plan.spec->expected, plan.spec->size);
+ record.size = plan.spec->size;
+ record.name = plan.spec->name;
+ g_applied.push_back(record);
+ ++installed;
+ veyra::log::info("xess-mfg", std::format("unlock patch {} applied at 0x{:X} -> [{}]", plan.spec->name, plan.spec->rva,
+ toHex(plan.bytes, plan.spec->size)));
+ }
+
+ state.applied = true;
+ state.generatedFrames = generatedFrames;
+ state.detail = std::format(L"unlock applied: {} patches, ceiling {}X", installed, generatedFrames + 1);
+ veyra::log::info("xess-mfg", std::format("unlock applied: {}/{} patches, maxInterpolatedFrames={} => {}X",
+ installed, std::size(kPatches), generatedFrames, generatedFrames + 1));
+ g_state = state;
+ return state;
+}
+
+void XessMfgUnlock::reportRuntimeCeiling(uint32_t maxInterpolations) {
+ std::lock_guard lock(g_mutex);
+ g_state.maxInterpolations = maxInterpolations == 0 ? 1 : maxInterpolations;
+ veyra::log::info("xess-mfg", std::format("runtime reports maxInterpolations={} => {}X", g_state.maxInterpolations,
+ g_state.maxInterpolations + 1));
+}
+
+void XessMfgUnlock::release() {
+ std::lock_guard lock(g_mutex);
+ if (!g_applied.empty()) {
+ size_t restored = 0;
+ for (auto it = g_applied.rbegin(); it != g_applied.rend(); ++it) {
+ if (writeVerified(it->address, it->original, it->size)) ++restored;
+ else veyra::log::error("xess-mfg", std::format("rollback failed for {} at {:p}", it->name, static_cast<void*>(it->address)));
+ }
+ veyra::log::info("xess-mfg", std::format("unlock rolled back {}/{} patch(es)", restored, g_applied.size()));
+ g_applied.clear();
+ }
+ g_state.applied = false;
+ g_state.detail = L"released";
+}
+
+XessMfgUnlock::State XessMfgUnlock::snapshot() {
+ std::lock_guard lock(g_mutex);
+ return g_state;
+}
+
+bool XessMfgUnlock::applied() {
+ std::lock_guard lock(g_mutex);
+ return g_state.applied;
+}
+
+bool XessMfgUnlock::providerIsAudited(const std::wstring& path) {
+ FileIdentity identity{};
+ IdentityError error = IdentityError::None;
+ if (!computeFileIdentity(path, identity, error)) return false;
+ return identity.sizeBytes == kKnownProviderSize && identity.sha256Upper == kKnownProviderSha256;
+}
+
+} // namespace veyra::gfx
diff --git a/src/gfx/XessPresenter.cpp b/src/gfx/XessPresenter.cpp
index bc900ea5..37a57b5f 100644
--- a/src/gfx/XessPresenter.cpp
+++ b/src/gfx/XessPresenter.cpp
@@ -1,6 +1,7 @@
#include "veyra/gfx/XessPresenter.h"
#include "veyra/Log.h"
#include "veyra/RuntimePaths.h"
+#include "veyra/gfx/XessMfgUnlock.h"
#ifdef VEYRA_HAS_XESS
#include <xess_fg/xefg_swapchain_d3d12.h>
#include <xell/xell_d3d12.h>
@@ -9,6 +10,8 @@
namespace veyra::gfx {
struct XessPresenter::Impl {
uint64_t generated=0,presented=0;
+ uint32_t requestedGenerated=0; // generated frames requested by the user (0 = 2X stock)
+ uint32_t maxInterpolations=1; // runtime-reported ceiling after the unlock
#ifdef VEYRA_HAS_XESS
HMODULE fgDll=nullptr,llDll=nullptr;
xefg_swapchain_handle_t fg=nullptr;
@@ -17,6 +20,8 @@ struct XessPresenter::Impl {
#define XESS_PROC(name) decltype(&name) name##Fn=nullptr
XESS_PROC(xefgSwapChainD3D12CreateContext);
XESS_PROC(xefgSwapChainD3D12GetProperties);
+ XESS_PROC(xefgSwapChainGetProperties);
+ XESS_PROC(xefgSwapChainSetNumInterpolatedFrames);
XESS_PROC(xefgSwapChainD3D12InitFromSwapChainDesc);
XESS_PROC(xefgSwapChainD3D12GetSwapChainPtr);
XESS_PROC(xefgSwapChainD3D12TagFrameResource);
@@ -40,13 +45,15 @@ struct XessPresenter::Impl {
~Impl(){
if(fg&&xefgSwapChainDestroyFn)check(xefgSwapChainDestroyFn(fg),"Destroy",true);
if(ll&&xellDestroyContextFn)check(xellDestroyContextFn(ll),"XeLL destroy",true);
+ // Restore the provider bytes only after every XeFG/XeLL context is gone.
+ XessMfgUnlock::release();
if(fgDll)FreeLibrary(fgDll);if(llDll)FreeLibrary(llDll);
}
#endif
};
XessPresenter::XessPresenter():p_(std::make_unique<Impl>()){}
XessPresenter::~XessPresenter()=default;
-bool XessPresenter::initialize(ID3D12Device* device,ID3D12CommandQueue* queue,IDXGIFactory2* factory,HWND window,const DXGI_SWAP_CHAIN_DESC1& desc,IDXGISwapChain3** swapchain){
+bool XessPresenter::initialize(ID3D12Device* device,ID3D12CommandQueue* queue,IDXGIFactory2* factory,HWND window,const DXGI_SWAP_CHAIN_DESC1& desc,IDXGISwapChain3** swapchain,uint32_t fgMultiplier){
if(GetEnvironmentVariableW(L"VEYRA_TEST_XESS_INIT_FAILURE",nullptr,0)){
log::warn("xess-fg","test-only initialization rejection; runtime not loaded");return false;
}
@@ -60,6 +67,8 @@ bool XessPresenter::initialize(ID3D12Device* device,ID3D12CommandQueue* queue,ID
#define LOAD(module,name) p.name##Fn=reinterpret_cast<decltype(p.name##Fn)>(GetProcAddress(p.module,#name));if(!p.name##Fn){log::error("xess-fg","missing export " #name);return false;}
LOAD(fgDll,xefgSwapChainD3D12CreateContext)
LOAD(fgDll,xefgSwapChainD3D12GetProperties)
+ LOAD(fgDll,xefgSwapChainGetProperties)
+ LOAD(fgDll,xefgSwapChainSetNumInterpolatedFrames)
LOAD(fgDll,xefgSwapChainD3D12InitFromSwapChainDesc)
LOAD(fgDll,xefgSwapChainD3D12GetSwapChainPtr)
LOAD(fgDll,xefgSwapChainD3D12TagFrameResource)
@@ -75,18 +84,45 @@ bool XessPresenter::initialize(ID3D12Device* device,ID3D12CommandQueue* queue,ID
LOAD(llDll,xellSleep)
LOAD(llDll,xellAddMarkerData)
#undef LOAD
+ // Multi-frame generation needs the audited OptiScaler unlock before the
+ // first XeFG context exists; 2X deliberately leaves the provider untouched.
+ p.requestedGenerated=fgMultiplier>1?fgMultiplier-1:0;
+ if(p.requestedGenerated>0){
+ const auto unlock=XessMfgUnlock::apply(p.fgDll,p.requestedGenerated);
+ p.maxInterpolations=unlock.maxInterpolations;
+ veyra::log::info("xess-mfg",std::format("unlock requestedGenerated={} applied={} identityVerified={} recognisedBuild={}",
+ p.requestedGenerated,unlock.applied,unlock.identityVerified,unlock.recognisedBuild));
+ if(!unlock.applied){
+ log::error("xess-mfg",std::format("unlock unavailable for {}X request; keeping stock presentation",p.requestedGenerated+1));
+ return false;
+ }
+ }
if(!p.check(p.xellD3D12CreateContextFn(device,&p.ll),"XeLL create",true)||!p.check(p.xefgSwapChainD3D12CreateContextFn(device,&p.fg),"Create",true))return false;
if(!p.check(p.xefgSwapChainSetLatencyReductionFn(p.fg,p.ll),"Attach XeLL",true))return false;
xell_sleep_params_t sleep{};sleep.bLowLatencyMode=1;
if(!p.check(p.xellSetSleepModeFn(p.ll,&sleep),"XeLL sleep mode",true))return false;
- xefg_swapchain_d3d12_init_params_t init{};init.maxInterpolatedFrames=1;init.uiMode=XEFG_SWAPCHAIN_UI_MODE_AUTO;
+ // Query the real ceiling before deciding what to request. The unlock (U5)
+ // is what makes this report more than 1 on a non-Intel GPU.
+ {
+ xefg_swapchain_properties_t runtimeProperties{};
+ if(p.check(p.xefgSwapChainGetPropertiesFn(p.fg,&runtimeProperties),"GetProperties(runtime)",true)){
+ p.maxInterpolations=runtimeProperties.maxSupportedInterpolations>0?runtimeProperties.maxSupportedInterpolations:1;
+ XessMfgUnlock::reportRuntimeCeiling(p.maxInterpolations);
+ }
+ if(p.requestedGenerated>0&&p.maxInterpolations<p.requestedGenerated){
+ log::error("xess-mfg",std::format("requested {}X but the runtime reports maxInterpolatedFrames={}",p.requestedGenerated+1,p.maxInterpolations));
+ return false;
+ }
+ }
+ xefg_swapchain_d3d12_init_params_t init{};init.maxInterpolatedFrames=p.requestedGenerated>0?p.requestedGenerated:1;init.uiMode=XEFG_SWAPCHAIN_UI_MODE_AUTO;
xefg_swapchain_properties_t properties{};
if(!p.check(p.xefgSwapChainD3D12GetPropertiesFn(p.fg,&init,desc.Width,desc.Height,desc.Format,&properties),"Properties",true)||properties.maxSupportedInterpolations<1)return false;
log::info("xess-fg",std::format("swapchain={}x{} maxInterpolations={} bufferHeap={} textureHeap={} estimated-motion constant-depth experimental",desc.Width,desc.Height,properties.maxSupportedInterpolations,properties.tempBufferHeapSize,properties.tempTextureHeapSize));
if(!p.check(p.xefgSwapChainD3D12InitFromSwapChainDescFn(p.fg,window,&desc,nullptr,queue,factory,&init),"Init",true))return false;
+ if(p.requestedGenerated>0&&!p.check(p.xefgSwapChainSetNumInterpolatedFramesFn(p.fg,p.requestedGenerated),"SetNumInterpolatedFrames",true))return false;
return p.check(p.xefgSwapChainD3D12GetSwapChainPtrFn(p.fg,__uuidof(IDXGISwapChain3),reinterpret_cast<void**>(swapchain)),"GetSwapChain",true);
#else
- (void)device;(void)queue;(void)factory;(void)window;(void)desc;(void)swapchain;
+ (void)device;(void)queue;(void)factory;(void)window;(void)desc;(void)swapchain;(void)fgMultiplier;
log::error("xess-fg","Intel XeSS SDK unavailable at build time");return false;
#endif
}
@@ -147,4 +183,5 @@ bool XessPresenter::afterPresent(){
}
uint64_t XessPresenter::generatedCount()const{return p_->generated;}
uint64_t XessPresenter::presentedCount()const{return p_->presented;}
+uint32_t XessPresenter::maxInterpolatedFrames()const{return p_->maxInterpolations;}
}