Add an initial rhi implementation that mimics the opengl implementation

This commit is contained in:
luisangelsm
2026-01-17 22:46:27 +01:00
parent 91b8a31727
commit 3381754c12
25 changed files with 2739 additions and 21 deletions

View File

@ -20,8 +20,18 @@ include (../dependencies/pdf_backend.pri)
INCLUDEPATH += ../common/gl
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
INCLUDEPATH += ../common/rhi
DEFINES += YACREADER_USE_RHI
}
win32 {
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -luser32
LIBS += -loleaut32 -lole32 -lshell32 -luser32
# When using RHI (Qt 6.7+), don't link OpenGL directly - QRhiWidget handles graphics APIs
message("RHI mode: not linking opengl32 (using QRhiWidget)")
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
} else {
LIBS += -lopengl32
}
msvc {
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
@ -51,6 +61,10 @@ QT += sql network widgets svg quickcontrols2
greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
QT += gui-private
}
# Input
HEADERS += comic_flow.h \
../common/concurrent_queue.h \
@ -140,6 +154,10 @@ HEADERS += comic_flow.h \
!CONFIG(no_opengl) {
HEADERS += ../common/gl/yacreader_flow_gl.h
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
HEADERS += ../common/rhi/yacreader_flow_rhi.h
}
}
SOURCES += comic_flow.cpp \
@ -228,6 +246,11 @@ SOURCES += comic_flow.cpp \
!CONFIG(no_opengl) {
SOURCES += ../common/gl/yacreader_flow_gl.cpp
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
SOURCES += ../common/rhi/yacreader_flow_rhi.cpp
RESOURCES += ../common/rhi/shaders/shaders.qrc
}
}
macx {

View File

@ -158,10 +158,15 @@ void ComicFlowWidgetSW::resortCovers(QList<int> newOrder)
ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget *parent)
: ComicFlowWidget(parent)
{
flow = new YACReaderComicFlowGL(parent);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
qDebug() << "ComicFlowWidgetGL: Creating YACReaderComicFlow3D (RHI implementation)";
#else
qDebug() << "ComicFlowWidgetGL: Creating YACReaderComicFlowGL (OpenGL implementation)";
#endif
flow = new YACReaderComicFlowImpl(this);
connect(flow, &YACReaderFlowGL::centerIndexChanged, this, &ComicFlowWidget::centerIndexChanged);
connect(flow, &YACReaderFlowGL::selected, this, &ComicFlowWidget::selected);
connect(flow, &YACReaderComicFlowImpl::centerIndexChanged, this, &ComicFlowWidget::centerIndexChanged);
connect(flow, &YACReaderComicFlowImpl::selected, this, &ComicFlowWidget::selected);
auto l = new QVBoxLayout;
l->addWidget(flow);

View File

@ -6,7 +6,14 @@
#include "pictureflow.h"
#include "comic_flow.h"
#ifndef NO_OPENGL
// Conditional include based on Qt version and RHI availability
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
#include "yacreader_flow_rhi.h"
using YACReaderComicFlowImpl = YACReaderComicFlow3D;
#else
#include "yacreader_flow_gl.h"
using YACReaderComicFlowImpl = YACReaderComicFlowGL;
#endif
#endif
class ComicFlowWidget : public QWidget
{
@ -83,7 +90,7 @@ class ComicFlowWidgetGL : public ComicFlowWidget
{
Q_OBJECT
private:
YACReaderComicFlowGL *flow;
YACReaderComicFlowImpl *flow;
public:
ComicFlowWidgetGL(QWidget *parent = nullptr);

View File

@ -17,10 +17,10 @@ ComicsView::ComicsView(QWidget *parent)
view = new QQuickWidget();
// QQuickWidget requires rendering into OpenGL framebuffer objects
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
view->quickWindow()->setGraphicsApi(QSGRendererInterface::OpenGL);
#endif
// In Qt 6, QQuickWidget supports Qt RHI and can use any graphics backend
// (Vulkan, Metal, Direct3D, OpenGL, or software rendering).
// The backend can be configured via QQuickWindow::setGraphicsApi() or QSG_RHI_BACKEND env var.
// Note: All widgets in the same top-level window must use the same graphics API.
view->setResizeMode(QQuickWidget::SizeRootObjectToView);
connect(

View File

@ -26,10 +26,10 @@ FolderContentView::FolderContentView(QAction *toogleRecentVisibilityAction, QWid
view = new QQuickWidget();
// QQuickWidget requires rendering into OpenGL framebuffer objects
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
view->quickWindow()->setGraphicsApi(QSGRendererInterface::OpenGL);
#endif
// In Qt 6, QQuickWidget supports Qt RHI and can use any graphics backend
// (Vulkan, Metal, Direct3D, OpenGL, or software rendering).
// The backend can be configured via QQuickWindow::setGraphicsApi() or QSG_RHI_BACKEND env var.
// Note: All widgets in the same top-level window must use the same graphics API.
view->setResizeMode(QQuickWidget::SizeRootObjectToView);
connect(

View File

@ -204,6 +204,12 @@ void LibraryWindow::setupOpenglSetting()
// FLOW-----------------------------------------------------------------------
//---------------------------------------------------------------------------
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
// When using RHI, assume hardware acceleration is available
bool openGLAvailable = true;
if (!settings->contains(USE_OPEN_GL))
settings->setValue(USE_OPEN_GL, 2);
#else
OpenGLChecker openGLChecker;
bool openGLAvailable = openGLChecker.hasCompatibleOpenGLVersion();
@ -212,6 +218,7 @@ void LibraryWindow::setupOpenglSetting()
else if (!openGLAvailable)
settings->setValue(USE_OPEN_GL, 0);
#endif
#endif
}
void LibraryWindow::setupUI()

View File

@ -83,8 +83,12 @@ void logSystemAndConfig()
else
QLOG_INFO() << "OpenGL : disabled";
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
QLOG_INFO() << "Using RHI (Qt Rendering Hardware Interface) - graphics backend will be auto-selected";
#else
OpenGLChecker checker;
QLOG_INFO() << "OpenGL version : " << checker.textVersionDescription();
#endif
auto libraries = DBHelper::getLibraries().getLibraries();
QLOG_INFO() << "Libraries: ";
@ -200,6 +204,8 @@ int main(int argc, char **argv)
#endif
parser.process(app);
// When using RHI (Qt 6.7+), don't allow OpenGL attribute overrides
#if !defined(YACREADER_USE_RHI) || QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
#ifdef Q_OS_WIN
if (parser.isSet("opengl")) {
QTextStream qout(stdout);
@ -216,6 +222,7 @@ int main(int argc, char **argv)
parser.showHelp();
}
}
#endif
#endif
if (parser.isSet("loglevel")) {