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++

fix(capture): defer video resize until Qt resize settles under active OBS hook

Veyra Goal Agent89ba070e2420
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 7c43b2cb..8806d935 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -8352,3 +8352,5 @@ OBS正常功能R0发现阻塞:v1 API207未ready修正有界重试;v3软件
R0-obs-candidate 92a181f/bundle708e4834c19078b50d33203ea0963255f3c1425fe9edae41413e93dba48d4f27已归档。最小恢复c593679暂停呈现生产部分:移除RetainedFrame/跳过Present/提前取view,回到resize后取view及50ms重复呈现;恢复ProPage旧动画并移除相关测试hook。退出取消/借用queue修复、限定3c、NR残差复用及Auto均保留。退役仅服务此候选的nr-present/PausedPresentExperiment和CMake target,完整源码可从c593679及既有before/candidate/accepted tags回放。此为待验证恢复候选,不提前把OBS标通过、不复用旧0.011%收益。
5ede7f6恢复候选build-r0-idle-revert-v1成功12步,但R0-obs-idle-revert-v1仍GPU全屏黑,R0-obs-residual-off-v1明确关闭NR残差复用亦失败。因此不能说暂停呈现/NR残差缓存已经被证实为根因,恢复候选无效,先拒绝封存后恢复92a181f生产部分(保留完整回退记录)。官方OBS32.1.2 dxgi-capture.cpp源码确认单进程全局data.swap,任意ResizeBuffers会清空它并由随后首次Present重选;16连续不匹配才再择。当前日志resize后捕获到Qt暗背景,多DIRECT队列被记入同一采集候选。两交换链重建次序是新定位方向(推断,待实验),不改OBS或运行库。下一最小候选仅在实际graphics-hook64.dll存在、视频目标尺寸变更时先保留旧buffer伸展,让UI resize完成后视频再resize;普通播放/未注入保持原行为。
+
+恢复9a30cf8/bundle8f5d35dd7c8e1a3531bb9b49389c15d7e82e6a21ed29fb8b9df192fe6f135a86。新最小候选仅VideoPresenter在实际OBS graphics-hook64.dll已加载且目标尺寸变更时记录250ms截止,期间沿用已有buffer伸展,随后视频resize在Qt resize之后执行;每个新尺寸只设一次截止,失败重试保留旧backoff,close清空。未注入/尺寸不变没有额外等待,无CPU sleep/fence增加,无自动配置或重启提示。仍待真实OBS对照,不先称修复。
diff --git a/include/veyra/engine/VideoPresenter.h b/include/veyra/engine/VideoPresenter.h
index b9fde910..db5f6ee4 100644
--- a/include/veyra/engine/VideoPresenter.h
+++ b/include/veyra/engine/VideoPresenter.h
@@ -98,6 +98,8 @@ private:
std::optional<RetainedFrame> retainedFrame_;
HWND window_=nullptr;
std::chrono::steady_clock::time_point lastResize_{};
+ std::chrono::steady_clock::time_point captureResizeAfter_{};
+ unsigned captureResizeWidth_=0,captureResizeHeight_=0;
unsigned viewWidth_=0,viewHeight_=0;
HMONITOR bufferMonitor_=nullptr;
unsigned monitorWidth_=0,monitorHeight_=0;
diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cpp
index bd38b54f..b1cce528 100644
--- a/src/engine/VideoPresenter.cpp
+++ b/src/engine/VideoPresenter.cpp
@@ -28,6 +28,7 @@ bool VideoPresenter::open(gfx::D3D12DeviceContext& ctx,HWND window,pipeline::Enh
return false;
}
viewWidth_=viewHeight_=0;bufferMonitor_=nullptr;monitorWidth_=monitorHeight_=0;
+ captureResizeAfter_={};captureResizeWidth_=captureResizeHeight_=0;
++generation_;
Status st=Status::Ok;
if((graph.fgEnabled()||graph.usesComputeQueue())&&!graph.xessEnabled()){
@@ -125,6 +126,19 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
// stretch current buffers there instead of repeatedly draining the GPU
// and rebuilding provider resources at monitor/DPI boundaries.
const bool windowChanging=GetPropW(window_,L"Veyra.InteractiveMove")||GetPropW(window_,L"Veyra.DpiTransition");
+ bool captureResizeDeferred=false;
+ if((targetWidth!=sink_.width()||targetHeight!=sink_.height())&&GetModuleHandleW(L"graphics-hook64.dll")){
+ // OBS 32.1.2 resets one process-wide capture on any ResizeBuffers.
+ // Rebuild the video after Qt has resized its UI swapchain, retaining
+ // the old video buffers meanwhile instead of selecting the UI surface.
+ // Source: obsproject/obs-studio 32.1.2 graphics-hook/dxgi-capture.cpp.
+ if(captureResizeWidth_!=targetWidth||captureResizeHeight_!=targetHeight){
+ captureResizeWidth_=targetWidth;captureResizeHeight_=targetHeight;
+ captureResizeAfter_=now+std::chrono::milliseconds(250);
+ veyra::log::info("capture-resize",std::format("defer video buffer resize target={}x{} delayMs=250 activeObsHook=true",targetWidth,targetHeight));
+ }
+ captureResizeDeferred=now<captureResizeAfter_;
+ }else{captureResizeWidth_=captureResizeHeight_=0;captureResizeAfter_={};}
view=filmPixelAlignedView(window_,rc.right,rc.bottom,graph.workWidth(),graph.workHeight(),view);
const RetainedFrame retained{graph.presentationReadyFenceObject(slot,generated),graph.presentationReadyFence(slot,generated),
slot,unsigned(rc.right),unsigned(rc.bottom),generated,referencesValid,baseReference,IsWindowVisible(window_)!=FALSE,
@@ -137,7 +151,7 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
SUCCEEDED(ctx.device()->GetDeviceRemovedReason())&&
!GetEnvironmentVariableW(L"VEYRA_TEST_DISABLE_PAUSED_PRESENT_REUSE",nullptr,0))return true;
retainedFrame_.reset(); // A failed present never seeds an idle cache.
- if(!windowChanging&&(targetWidth!=sink_.width()||targetHeight!=sink_.height())&&GetTickCount64()>=deferUntil&&now-lastResize_>=std::chrono::milliseconds(100)&&sink_.resizeDue()) {
+ if(!windowChanging&&!captureResizeDeferred&&(targetWidth!=sink_.width()||targetHeight!=sink_.height())&&GetTickCount64()>=deferUntil&&now-lastResize_>=std::chrono::milliseconds(100)&&sink_.resizeDue()) {
resized=true;
if(!ring.drainQueue())return false;sink_.resize(targetWidth,targetHeight);
// A capture hook may temporarily retain a DXGI buffer. Keep the old
@@ -304,6 +318,7 @@ bool VideoPresenter::readPresentedFrameForTest(gfx::D3D12DeviceContext& ctx,gfx:
}
void VideoPresenter::close(){
retainedFrame_.reset();
+ captureResizeWidth_=captureResizeHeight_=0;captureResizeAfter_={};
xessInputId_=0;xessWork_={};xessWorkPosition_=0;
reflex_.close();reflexFrame_=0;
if(presentationRing_.initialized())presentationRing_.drainQueue();