Commit 76638c61 authored by Laszlo Agocs's avatar Laszlo Agocs

Add sharedresource example

Won't yet work, obviously.
parent 55af90ad
......@@ -553,11 +553,6 @@ int main(int argc, char **argv)
qDebug("Selected graphics API is %s", qPrintable(graphicsApiName()));
qDebug("This is a multi-api example, use command line arguments to override:\n%s", qPrintable(cmdLineParser.helpText()));
QSurfaceFormat fmt;
fmt.setDepthBufferSize(24);
fmt.setStencilBufferSize(8);
QSurfaceFormat::setDefaultFormat(fmt);
#if QT_CONFIG(vulkan)
r.instance = new QVulkanInstance;
if (graphicsApi == Vulkan) {
......
......@@ -760,8 +760,8 @@ int main(int argc, char **argv)
QVBoxLayout *layout = new QVBoxLayout(&w);
QPlainTextEdit *info = new QPlainTextEdit(
QLatin1String("This application tests rendering on a separate thread per window, with dedicated QRhi instances. " // ### still sharing the same graphics device where applicable
"No resources are shared across windows here. "
QLatin1String("This application tests rendering on a separate thread per window, with dedicated QRhi instances. "
"No resources are shared across windows here. (QRhiResourceSharingHost is not used) "
"\n\nThis is the same concept as the Qt Quick Scenegraph's threaded render loop. This should allow rendering to the different windows "
"without unintentionally throttling each other's threads."
"\n\nUsing API: ") + graphicsApiName());
......
......@@ -12,6 +12,7 @@ SUBDIRS += \
multiwindow_threaded \
imguidemo \
triquadcube \
sharedresource \
offscreen
qtConfig(vulkan) {
......
......@@ -417,7 +417,7 @@ void Window::render()
#ifdef Q_OS_DARWIN
if (!scFlags.testFlag(QRhiSwapChain::NoVSync))
requestUpdate(); // CVDisplayLink (not strictly needed on macOS with Metal)
requestUpdate(); // CVDisplayLink
else
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
#else
......
This diff is collapsed.
TEMPLATE = app
QT += shadertools rhi
SOURCES = \
sharedresource.cpp
RESOURCES = sharedresource.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/rhi/sharedresource
INSTALLS += target
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file alias="texture.vert.qsb">../shared/texture.vert.qsb</file>
<file alias="texture.frag.qsb">../shared/texture.frag.qsb</file>
<file alias="qt256.png">../shared/qt256.png</file>
</qresource>
</RCC>
......@@ -227,8 +227,8 @@ QT_BEGIN_NAMESPACE
A QRhi instance can be created and used on any thread but all usage must be
limited to that one single thread. When it comes to native objects, such as
OpenGL contexts, passed in in QRhiInitParams, it is up to the application
to ensure they are not misused by other threads.
OpenGL contexts, passed in via a QRhiNativeHandles subclass, it is up to
the application to ensure they are not misused by other threads.
\sa {Qt Shader Tools}
*/
......@@ -2536,11 +2536,6 @@ quint32 QRhiImplementation::approxByteSizeForTexture(QRhiTexture::Format format,
it also performs synchronizing submission to the device context (of which
there is only one, regardless of the number of threads submitting to it).
\note There is no further synchronization performed for resources like
buffers or textures. If the QRhi instances operate on different threads, it
is up to those threads to ensure the QRhiResource usages on the threads
are done as appropriate for the underlying graphics APIs.
\note The QRhiResourceSharingHost can be created on a thread that is
different than the threads on which the associated QRhi instances will be
created. It is however up to the application to organize those threads in a
......
multiple qrhis on threads with shared resources - how
res.sh.: reuse device / create sharing context
res.sh.: example to show using same texture
res.sh.: example to show read/write same texture
res.sh.: d3d context sync
res.sh.: exercise it in multiwindow_threaded too
advanced blend modes
gl: tex formats (texture, readback)
gl: srgb
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment