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

revert(capture): remove ineffective OBS Qt frame and RHI gate

Veyra Goal Agent9403521cc4d0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5134b02b..0b36528d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -940,9 +940,7 @@ if(VEYRA_BUILD_QML_UI AND Qt6_FOUND)
qt_add_resources(veyra_qml_ui "veyra_i18n" PREFIX "/i18n" BASE "${CMAKE_CURRENT_SOURCE_DIR}/i18n" FILES i18n/catalog.json)
target_compile_features(veyra_qml_ui PRIVATE cxx_std_20)
# Qt6::CorePrivate only for QUnifiedTimer's slow mode behind --slow-animations.
- # GuiPrivate exposes QRhiSwapChain::currentPixelSize for OBS resize ordering;
- # this uses the same pinned Qt 6.8.3 Gui runtime already in the portable pack.
- target_link_libraries(veyra_qml_ui PRIVATE veyra_qml_bridge veyra_engine Qt6::CorePrivate Qt6::GuiPrivate dbghelp ole32)
+ target_link_libraries(veyra_qml_ui PRIVATE veyra_qml_bridge veyra_engine Qt6::CorePrivate dbghelp ole32)
add_executable(veyra_qml_data_tests tests/unit/QmlDataDirectoryTests.cpp src/ui/QmlDataDirectory.cpp)
target_compile_features(veyra_qml_data_tests PRIVATE cxx_std_20)
diff --git a/apps/veyra-qml/main.cpp b/apps/veyra-qml/main.cpp
index e6d59377..4f6462ff 100644
--- a/apps/veyra-qml/main.cpp
+++ b/apps/veyra-qml/main.cpp
@@ -20,8 +20,6 @@
#include <QQmlContext>
#include <QQuickItem>
#include <QQuickWindow>
-#include "veyra/gfx/ObsQtFrameGate.h"
-#include <rhi/qrhi.h>
#include <QSGRendererInterface>
#include <QKeyEvent>
#include <QTimer>
@@ -758,24 +756,6 @@ static int runApplication(int argc, char** argv, QString& restartProgram, QStrin
return 1;
}
if (testSize.isValid()) window->resize(testSize);
- if(!softwareUi){
- auto windows=window->findChildren<QQuickWindow*>();windows.prepend(window);
- for(auto* quick:windows){
- auto gate=veyra::gfx::registerObsQtFrameGate(reinterpret_cast<HWND>(quick->winId()));
- QObject::connect(quick,&QQuickWindow::beforeFrameBegin,quick,[gate]{
- gate->beginFrame(GetModuleHandleW(L"graphics-hook64.dll")!=nullptr);
- },Qt::DirectConnection);
- QObject::connect(quick,&QQuickWindow::frameSwapped,quick,[gate,quick]{
- if(auto* chain=quick->swapChain()){
- const auto actual=chain->currentPixelSize();
- if(actual.width()>0&&actual.height()>0)gate->presented(unsigned(actual.width()),unsigned(actual.height()));
- }
- },Qt::DirectConnection);
- QObject::connect(quick,&QQuickWindow::afterFrameEnd,quick,[gate]{gate->endFrame();},Qt::DirectConnection);
- QObject::connect(quick,&QQuickWindow::sceneGraphInvalidated,quick,[gate]{gate->abortFrame();},Qt::DirectConnection);
- }
- veyra::log::info("qml-window",std::format("OBS resize frame gates registered windows={}",windows.size()));
- }
// Fullscreen must own the whole monitor. Without telling the shell, the taskbar
// stayed above the fullscreen picture on some systems (field report with the
diff --git a/include/veyra/gfx/ObsQtFrameGate.h b/include/veyra/gfx/ObsQtFrameGate.h
deleted file mode 100644
index 8d707684..00000000
--- a/include/veyra/gfx/ObsQtFrameGate.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#pragma once
-#include <Windows.h>
-#include <atomic>
-#include <cstdint>
-#include <memory>
-#include <mutex>
-#include <vector>
-
-namespace veyra::gfx {
-// Qt 6.8.3 resizes BEFORE beforeFrameBegin; OBS 32.1.2 clears its single
-// process-wide capture on ANY ResizeBuffers. Require a completed Qt frame
-// at the current window extent, then keep Qt Presents outside native resize.
-class ObsQtFrameGate {
-public:
- explicit ObsQtFrameGate(HWND window):window_(window){}
- void beginFrame(bool hookActive){
- if(hookActive&&!held_){
- mutex_.lock();held_=true;presented_=false;frameExtent_=0;
- }
- }
- void presented(unsigned width,unsigned height){
- if(held_&&width&&height){frameExtent_=(uint64_t(width)<<32)|height;presented_=true;}
- }
- void endFrame(){
- if(held_){
- if(presented_)completedExtent_.store(frameExtent_,std::memory_order_release);
- abortFrame();
- }
- }
- void abortFrame(){if(held_){held_=false;mutex_.unlock();}}
- bool readyForCurrentWindow()const{
- if(!IsWindow(window_)||!IsWindowVisible(window_)||IsIconic(window_))return true;
- const auto extent=clientExtent();
- return extent!=0&&completedExtent_.load(std::memory_order_acquire)==extent;
- }
- std::mutex& mutex(){return mutex_;}
-private:
- uint64_t clientExtent()const{
- RECT rc{};
- if(!GetClientRect(window_,&rc)||rc.right<1||rc.bottom<1)return 0;
- return (uint64_t(uint32_t(rc.right))<<32)|uint32_t(rc.bottom);
- }
- HWND window_=nullptr;
- std::mutex mutex_;
- std::atomic<uint64_t> completedExtent_{0};
- uint64_t frameExtent_=0;
- bool held_=false,presented_=false; // this window's render thread only
-};
-inline std::mutex obsQtRegistryMutex;
-inline std::vector<std::weak_ptr<ObsQtFrameGate>> obsQtFrameGates;
-inline std::shared_ptr<ObsQtFrameGate> registerObsQtFrameGate(HWND window){
- auto gate=std::make_shared<ObsQtFrameGate>(window);
- const std::lock_guard lock(obsQtRegistryMutex);
- std::erase_if(obsQtFrameGates,[](const auto& existing){return existing.expired();});
- obsQtFrameGates.push_back(gate);
- return gate;
-}
-class ObsNativeResizeHold {
-public:
- ObsNativeResizeHold(){
- {
- const std::lock_guard lock(obsQtRegistryMutex);
- for(auto& entry:obsQtFrameGates)if(auto gate=entry.lock())gates_.push_back(std::move(gate));
- }
- for(auto& gate:gates_){
- locks_.emplace_back(gate->mutex(),std::try_to_lock);
- if(!locks_.back().owns_lock()||!gate->readyForCurrentWindow()){
- locks_.clear();ready_=false;break;
- }
- }
- }
- bool ready()const{return ready_;}
- size_t windows()const{return gates_.size();}
-private:
- std::vector<std::shared_ptr<ObsQtFrameGate>> gates_;
- std::vector<std::unique_lock<std::mutex>> locks_;
- bool ready_=true;
-};
-}
diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cpp
index e993c7f7..bd38b54f 100644
--- a/src/engine/VideoPresenter.cpp
+++ b/src/engine/VideoPresenter.cpp
@@ -3,7 +3,6 @@
#include "veyra/pipeline/EnhanceGraph.h"
#include "veyra/gfx/D3D12DeviceContext.h"
#include "veyra/gfx/CommandSlotRing.h"
-#include "veyra/gfx/ObsQtFrameGate.h"
#include "veyra/sink/ImageExportSink.h"
namespace veyra::engine {
bool VideoPresenter::beginSourceInput(){
@@ -138,14 +137,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.
- bool resizeReady=!windowChanging&&(targetWidth!=sink_.width()||targetHeight!=sink_.height())&&GetTickCount64()>=deferUntil&&now-lastResize_>=std::chrono::milliseconds(100)&&sink_.resizeDue();
- std::optional<gfx::ObsNativeResizeHold> captureResizeHold;
- if(resizeReady&&GetModuleHandleW(L"graphics-hook64.dll")){
- captureResizeHold.emplace();resizeReady=captureResizeHold->ready();
- if(!resizeReady)captureResizeHold.reset(); // no native wait; retry next frame
- else veyra::log::info("capture-resize",std::format("Qt current extent complete; native resize target={}x{} qtWindows={}",targetWidth,targetHeight,captureResizeHold->windows()));
- }
- if(resizeReady) {
+ if(!windowChanging&&(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
@@ -283,7 +275,6 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
const auto dxgiStart=std::chrono::steady_clock::now();
reflex_.mark(reflexFrame_,3);reflex_.mark(reflexFrame_,4);
const bool presented=sink_.present(st);
- captureResizeHold.reset();
reflex_.mark(reflexFrame_,5);reflexFrame_=0;
const auto presentEnd=std::chrono::steady_clock::now();
const auto ms=[](auto d){return std::chrono::duration<double,std::milli>(d).count();};