qt5base-lts/src/opengl/CMakeLists.txt
Laszlo Agocs 68a4c5da9a Compose render-to-texture widgets through QRhi
QPlatformTextureList holds a QRhiTexture instead of GLuint. A
QPlatformBackingStore now optionally can own a QRhi and a
QRhiSwapChain for the associated window.  Non-GL rendering must use
this QRhi everywhere, whereas GL (QOpenGLWidget) can choose to still
rely on resource sharing between contexts. A widget tells that it
wants QRhi and the desired configuration in a new virtual function in
QWidgetPrivate returning a QPlatformBackingStoreRhiConfig. This is
evaluated (among a top-level's all children) upon create() before
creating the repaint manager and the QWidgetWindow.

In QOpenGLWidget what do request is obvious: it will request an
OpenGL-based QRhi. QQuickWidget (or a potential future QRhiWidget)
will be more interesting: it needs to honor the standard Qt Quick
env.vars. and QQuickWindow APIs (or, in whatever way the user
configured the QRhiWidget), and so will set up the config struct
accordingly.

In addition, the rhiconfig and surface type is (re)evaluated when
(re)parenting a widget to a new tlw. If needed, this will now trigger
a destroy - create on the tlw. This should be be safe to do in
setParent. When multiple child widgets report an enabled rhiconfig,
the first one (the first child encountered) wins. So e.g. attempting
to have a QOpenGLWidget and a Vulkan-based QQuickWidget in the same
top-level window will fail one of the widgets (it likely won't
render).

RasterGLSurface is no longer used by widgets. Rather, the appropriate
surface type is chosen.

The rhi support in the backingstore is usable without widgets as well.
To make rhiFlush() functional, one needs to call setRhiConfig() after
creating the QBackingStore. (like QWidget does to top-level windows)

Most of the QT_NO_OPENGL ifdefs are eliminated all over the place.
Everything with QRhi is unconditional code at compile time, except the
actual initialization.

Having to plumb the widget tlw's shareContext (or, now, the QRhi)
through QWindowPrivate is no longer needed.  The old approach does not
scale: to implement composeAndFlush (now rhiFlush) we need more than
just a QRhi object, and this way we no longer pollute everything
starting from the widget level (QWidget's topextra -> QWidgetWindow ->
QWindowPrivate) just to send data around.

The BackingStoreOpenGLSupport interface and the QtGui - QtOpenGL split
is all gone. Instead, there is a QBackingStoreDefaultCompositor in
QtGui which is what the default implementations of composeAndFlush and
toTexture call. (overriding composeAndFlush and co. f.ex. in eglfs
should continue working mostly as-is, apart from adapting to the
texture list changes and getting the native OpenGL texture id out of
the QRhiTexture)

As QQuickWidget is way too complicated to just port as-is, an rhi
manual test (rhiwidget) is introduced as a first step, in ordewr to
exercise a simple, custom render-to-texture widget that does something
using a (not necessarily OpenGL-backed) QRhi and acts as fully
functional QWidget (modeled after QOpenGLWidget). This can also form
the foundation of a potential future QRhiWidget.

It is also possible to force the QRhi-based flushing always,
regardless of the presence of render-to-texture widgets. To exercise
this, set the env.var. QT_WIDGETS_RHI=1. This picks a
platform-specific default, and can be overridden with
QT_WIDGETS_RHI_BACKEND. (in sync with Qt Quick) This can eventually be
extended to query the platform plugin as well to check if the platform
plugin prefers to always do flushes with a 3D API.

QOpenGLWidget should work like before from the user's perspective, while
internally it has to do some things differently to play nice and prevent
regressions with the new rendering architecture. To exercise this
better, the qopenglwidget example gets a new tab-based view (that could
perhaps replace the example's main window later on?). The openglwidget
manual test is made compatible with Qt 6, and gets a counterpart in form
of the dockedopenglwidget manual test, which is a modified version of
the cube example that features dock widgets. This is relevant in
particular because render-to-texture widgets within a QDockWidget has
its own specific quirks, with logic taking this into account, hence
testing is essential.

For existing applications there are two important consequences with
this patch in place:

- Once the rhi-based composition is enabled, it stays active for the
lifetime of the top-level window.

- Dynamically creating and parenting the first render-to-texture
widget to an already created tlw will destroy and recreate the tlw
(and the underlying window). The visible effects of this depend on the
platform.  (e.g. the window may disappear and reappear on some,
whereas with other windowing systems it is not noticeable at all -
this is not really different from similar situtions with reparenting
or when moving windows between screens, so should be acceptable in
practice)

- On iOS raster windows are flushed with Metal (and rhi) from now on
(previously this was through OpenGL by making flush() call
composeAndFlush().

Change-Id: Id05bd0f7a26fa845f8b7ad8eedda3b0e78ab7a4e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-11 21:25:00 +01:00

110 lines
4.6 KiB
CMake

# Generated from opengl.pro.
#####################################################################
## OpenGL Module:
#####################################################################
qt_internal_add_module(OpenGL
SOURCES
qopengl2pexvertexarray.cpp qopengl2pexvertexarray_p.h
qopenglbuffer.cpp qopenglbuffer.h
qopenglcustomshaderstage.cpp qopenglcustomshaderstage_p.h
qopengldebug.cpp qopengldebug.h
qopenglengineshadermanager.cpp qopenglengineshadermanager_p.h
qopenglengineshadersource_p.h
qopenglframebufferobject.cpp qopenglframebufferobject.h qopenglframebufferobject_p.h
qopenglgradientcache.cpp qopenglgradientcache_p.h
qopenglpaintdevice.cpp qopenglpaintdevice.h qopenglpaintdevice_p.h
qopenglpaintengine.cpp qopenglpaintengine_p.h
qopenglpixeltransferoptions.cpp qopenglpixeltransferoptions.h
qopenglshadercache_p.h
qopenglshaderprogram.cpp qopenglshaderprogram.h
qopengltexture.cpp qopengltexture.h qopengltexture_p.h
qopengltextureblitter.cpp qopengltextureblitter.h
qopengltexturecache.cpp qopengltexturecache_p.h
qopengltextureglyphcache.cpp qopengltextureglyphcache_p.h
qopengltexturehelper.cpp qopengltexturehelper_p.h
qopengltextureuploader.cpp qopengltextureuploader_p.h
qopenglversionfunctions.cpp qopenglversionfunctions.h qopenglversionfunctions_p.h
qopenglversionfunctionsfactory.cpp qopenglversionfunctionsfactory.h
qopenglversionprofile.cpp qopenglversionprofile.h
qopenglvertexarrayobject.cpp qopenglvertexarrayobject.h
qopenglwindow.cpp qopenglwindow.h
qtopenglglobal.h
DEFINES
QT_NO_FOREACH
QT_NO_USING_NAMESPACE
LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
PUBLIC_LIBRARIES
Qt::Core
Qt::Gui
PRIVATE_MODULE_INTERFACE
Qt::CorePrivate
Qt::GuiPrivate
GENERATE_CPP_EXPORTS
)
## Scopes:
#####################################################################
qt_internal_extend_target(OpenGL CONDITION QT_FEATURE_opengles2
SOURCES
qopenglfunctions_es2.cpp qopenglfunctions_es2.h
)
qt_internal_extend_target(OpenGL CONDITION NOT QT_FEATURE_opengles2
SOURCES
qopenglfunctions_1_0.cpp qopenglfunctions_1_0.h
qopenglfunctions_1_1.cpp qopenglfunctions_1_1.h
qopenglfunctions_1_2.cpp qopenglfunctions_1_2.h
qopenglfunctions_1_3.cpp qopenglfunctions_1_3.h
qopenglfunctions_1_4.cpp qopenglfunctions_1_4.h
qopenglfunctions_1_5.cpp qopenglfunctions_1_5.h
qopenglfunctions_2_0.cpp qopenglfunctions_2_0.h
qopenglfunctions_2_1.cpp qopenglfunctions_2_1.h
qopenglfunctions_3_0.cpp qopenglfunctions_3_0.h
qopenglfunctions_3_1.cpp qopenglfunctions_3_1.h
qopenglfunctions_3_2_compatibility.cpp qopenglfunctions_3_2_compatibility.h
qopenglfunctions_3_2_core.cpp qopenglfunctions_3_2_core.h
qopenglfunctions_3_3_compatibility.cpp qopenglfunctions_3_3_compatibility.h
qopenglfunctions_3_3_core.cpp qopenglfunctions_3_3_core.h
qopenglfunctions_4_0_compatibility.cpp qopenglfunctions_4_0_compatibility.h
qopenglfunctions_4_0_core.cpp qopenglfunctions_4_0_core.h
qopenglfunctions_4_1_compatibility.cpp qopenglfunctions_4_1_compatibility.h
qopenglfunctions_4_1_core.cpp qopenglfunctions_4_1_core.h
qopenglfunctions_4_2_compatibility.cpp qopenglfunctions_4_2_compatibility.h
qopenglfunctions_4_2_core.cpp qopenglfunctions_4_2_core.h
qopenglfunctions_4_3_compatibility.cpp qopenglfunctions_4_3_compatibility.h
qopenglfunctions_4_3_core.cpp qopenglfunctions_4_3_core.h
qopenglfunctions_4_4_compatibility.cpp qopenglfunctions_4_4_compatibility.h
qopenglfunctions_4_4_core.cpp qopenglfunctions_4_4_core.h
qopenglfunctions_4_5_compatibility.cpp qopenglfunctions_4_5_compatibility.h
qopenglfunctions_4_5_core.cpp qopenglfunctions_4_5_core.h
qopenglqueryhelper_p.h
qopengltimerquery.cpp qopengltimerquery.h
)
qt_internal_extend_target(OpenGL CONDITION QT_FEATURE_vulkan
SOURCES
qvkconvenience.cpp qvkconvenience_p.h
)
if(QT_FEATURE_vulkan)
qt_internal_add_target_include_dirs_and_optionally_propagate(
OpenGL WrapVulkanHeaders::WrapVulkanHeaders)
endif()
qt_internal_extend_target(OpenGL CONDITION QT_FEATURE_egl
SOURCES
qopenglcompositor.cpp qopenglcompositor_p.h
qopenglcompositorbackingstore.cpp qopenglcompositorbackingstore_p.h
)
qt_internal_create_tracepoints(OpenGL qtopengl.tracepoints)
qt_internal_add_docs(OpenGL
doc/qtopengl.qdocconf
)