Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Laszlo Agocs
qtrhi
Commits
2ae78fee
Commit
2ae78fee
authored
Jan 23, 2019
by
Laszlo Agocs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assume CrossThreadRsh is always supported and drop the flag
parent
57d9fb00
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
7 additions
and
70 deletions
+7
-70
src/rhi/qrhi.cpp
src/rhi/qrhi.cpp
+2
-42
src/rhi/qrhi.h
src/rhi/qrhi.h
+1
-2
src/rhi/qrhid3d11.cpp
src/rhi/qrhid3d11.cpp
+1
-9
src/rhi/qrhigles2.cpp
src/rhi/qrhigles2.cpp
+1
-6
src/rhi/qrhimetal.mm
src/rhi/qrhimetal.mm
+0
-2
src/rhi/qrhirsh_p.h
src/rhi/qrhirsh_p.h
+0
-3
src/rhi/qrhivulkan.cpp
src/rhi/qrhivulkan.cpp
+1
-6
todo.txt
todo.txt
+1
-0
No files found.
src/rhi/qrhi.cpp
View file @
2ae78fee
...
...
@@ -313,20 +313,6 @@ QT_BEGIN_NAMESPACE
identically across backends, as long as this feature is reported as
supported, are \l{QRhiGraphicsPipeline::LineStrip}{LineStrip} and
\l{QRhiGraphicsPipeline::TriangleStrip}{TriangleStrip}.
\value CrossThreadResourceSharing Indicates that creating QRhi instances on
different threads with QRhiResourceSharingHost set is allowed. Backends
where the underlying graphics API cannot safely support using the same
device or context from multiple threads will report this feature as
unsupported. When not supported, creating a QRhi with a
QRhiResourceSharingHost when there are already other QRhi instances on
other threads associated with the same QRhiResourceSharingHost will behave
as if the QRhiResourceSharingHost was not set at all. Application and
framework design may need to take support for this feature into account:
making resources like textures visible to multiple QRhi instances is not
neccessarily possible, so the design should be flexible enough to allow
functioning in that case as well (by using per-QRhi resources instead of a
single shared one, and possibly duplicating work).
*/
/*!
...
...
@@ -1178,7 +1164,7 @@ void QRhiResource::setName(const QByteArray &name)
and renderbuffers. Most backends will not support other type of shareable
resources.
\sa QRhiResourceSharingHost
, QRhi::CrossThreadResourceSharing
\sa QRhiResourceSharingHost
*/
bool
QRhiResource
::
isShareable
()
const
{
...
...
@@ -2615,14 +2601,6 @@ quint32 QRhiImplementation::approxByteSizeForTexture(QRhiTexture::Format format,
then; if there are new QRhi instances created for the same resource sharing
host later on then there is no issue, as long as, again, those are alive).
\note When creating QRhi instances on different threads, using
QRhiResourceSharingHost may not be supported, depending on the backend and
the underlying graphics API. Support for this is indicated by the
QRhi::CrossThreadResourceSharing flag. When not supported, attempting to
create a QRhi in such a threaded scenario with a QRhiResourceSharingHost
will lead to a warning and ignoring resource sharing altogether (as if
QRhiInitParams::resourceSharingHost was not set).
\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
...
...
@@ -2696,8 +2674,7 @@ quint32 QRhiImplementation::approxByteSizeForTexture(QRhiTexture::Format format,
\note Moving the \c{tex->releaseAndDestroy()} call between the \c{delete
rhi2} and \c{delete rsh} statements would be incorrect.
\sa QRhiResource::isShareable(), QRhi::CrossThreadResourceSharing,
QRhiInitParams, QRhi::create()
\sa QRhiResource::isShareable(), QRhiInitParams, QRhi::create()
*/
/*!
...
...
@@ -2719,23 +2696,6 @@ QRhiResourceSharingHost::~QRhiResourceSharingHost()
delete
d
;
}
bool
QRhiResourceSharingHostPrivate
::
crossThreadDisallowCheck
()
const
{
bool
otherThreads
=
false
;
for
(
QThread
*
t
:
qAsConst
(
rhiThreads
))
{
if
(
t
!=
QThread
::
currentThread
())
{
otherThreads
=
true
;
break
;
}
}
if
(
otherThreads
)
{
qWarning
(
"Attempted to set a QRhiResourceSharingHost with QRhi instances on different threads when "
"QRhi::CrossThreadResourceSharing is not supported. Resource sharing will be disabled."
);
return
false
;
}
return
true
;
}
/*!
\internal
*/
...
...
src/rhi/qrhi.h
View file @
2ae78fee
...
...
@@ -1164,8 +1164,7 @@ public:
Timestamps
,
Instancing
,
CustomInstanceStepRate
,
PrimitiveRestart
,
CrossThreadResourceSharing
PrimitiveRestart
};
enum
ResourceSizeLimit
{
...
...
src/rhi/qrhid3d11.cpp
View file @
2ae78fee
...
...
@@ -164,9 +164,6 @@ bool QRhiD3D11::create(QRhi::Flags flags)
QMutexLocker
lock
(
rsh
?
&
rsh
->
mtx
:
nullptr
);
// if (!rsh->crossThreadDisallowCheck())
// rsh = nullptr;
uint
devFlags
=
0
;
if
(
debugLayer
)
devFlags
|=
D3D11_CREATE_DEVICE_DEBUG
;
...
...
@@ -241,7 +238,6 @@ bool QRhiD3D11::create(QRhi::Flags flags)
qDebug
(
"Attached to QRhiResourceSharingHost %p, currently %d other QRhi instances on ID3D11Device %p"
,
rsh
,
rsh
->
rhiCount
,
dev
);
rsh
->
rhiCount
+=
1
;
rsh
->
rhiThreads
.
append
(
QThread
::
currentThread
());
}
return
true
;
...
...
@@ -272,9 +268,7 @@ void QRhiD3D11::destroy()
}
if
(
rsh
)
{
rsh
->
rhiCount
-=
1
;
rsh
->
rhiThreads
.
removeOne
(
QThread
::
currentThread
());
if
(
rsh
->
rhiCount
==
0
)
{
if
(
--
rsh
->
rhiCount
==
0
)
{
if
(
rsh
->
d_d3d11
.
context
)
{
reinterpret_cast
<
ID3D11DeviceContext1
*>
(
rsh
->
d_d3d11
.
context
)
->
Release
();
rsh
->
d_d3d11
.
context
=
nullptr
;
...
...
@@ -392,8 +386,6 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
return
true
;
case
QRhi
::
PrimitiveRestart
:
return
true
;
case
QRhi
::
CrossThreadResourceSharing
:
return
true
;
default:
Q_UNREACHABLE
();
return
false
;
...
...
src/rhi/qrhigles2.cpp
View file @
2ae78fee
...
...
@@ -295,7 +295,6 @@ bool QRhiGles2::create(QRhi::Flags flags)
if
(
rsh
)
{
qDebug
(
"Attached to QRhiResourceSharingHost %p, currently %d other QRhi instances"
,
rsh
,
rsh
->
rhiCount
);
rsh
->
rhiCount
+=
1
;
rsh
->
rhiThreads
.
append
(
QThread
::
currentThread
());
}
return
true
;
...
...
@@ -319,9 +318,7 @@ void QRhiGles2::destroy()
}
if
(
rsh
)
{
rsh
->
rhiCount
-=
1
;
rsh
->
rhiThreads
.
removeOne
(
QThread
::
currentThread
());
if
(
rsh
->
rhiCount
==
0
)
{
if
(
--
rsh
->
rhiCount
==
0
)
{
delete
rsh
->
d_gles2
.
dummyShareContext
;
rsh
->
d_gles2
.
dummyShareContext
=
nullptr
;
}
...
...
@@ -466,8 +463,6 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
return
false
;
case
QRhi
::
PrimitiveRestart
:
return
false
;
// say no to madness
case
QRhi
::
CrossThreadResourceSharing
:
return
true
;
default:
Q_UNREACHABLE
();
return
false
;
...
...
src/rhi/qrhimetal.mm
View file @
2ae78fee
...
...
@@ -453,8 +453,6 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
return
true
;
case
QRhi
::
PrimitiveRestart
:
return
true
;
case
QRhi
::
CrossThreadResourceSharing
:
return
true
;
default:
Q_UNREACHABLE
();
return
false
;
...
...
src/rhi/qrhirsh_p.h
View file @
2ae78fee
...
...
@@ -57,7 +57,6 @@
#include "qrhimetal.h"
#endif
#include <QThread>
#include <QMutex>
QT_BEGIN_NAMESPACE
...
...
@@ -66,11 +65,9 @@ class Q_RHI_PRIVATE_EXPORT QRhiResourceSharingHostPrivate
{
public:
static
QRhiResourceSharingHostPrivate
*
get
(
QRhiResourceSharingHost
*
h
)
{
return
h
->
d
;
}
bool
crossThreadDisallowCheck
()
const
;
QMutex
mtx
;
int
rhiCount
=
0
;
QVector
<
QThread
*>
rhiThreads
;
#ifndef QT_NO_OPENGL
struct
{
...
...
src/rhi/qrhivulkan.cpp
View file @
2ae78fee
...
...
@@ -518,7 +518,6 @@ bool QRhiVulkan::create(QRhi::Flags flags)
qDebug
(
"Attached to QRhiResourceSharingHost %p, currently %d other QRhi instances on VkDevice %p"
,
rsh
,
rsh
->
rhiCount
,
dev
);
rsh
->
rhiCount
+=
1
;
rsh
->
rhiThreads
.
append
(
QThread
::
currentThread
());
if
(
rshWantsDevice
)
{
rsh
->
d_vulkan
.
physDev
=
physDev
;
rsh
->
d_vulkan
.
dev
=
dev
;
...
...
@@ -591,9 +590,7 @@ void QRhiVulkan::destroy()
df
=
nullptr
;
if
(
rsh
)
{
rsh
->
rhiCount
-=
1
;
rsh
->
rhiThreads
.
removeOne
(
QThread
::
currentThread
());
if
(
rsh
->
rhiCount
==
0
)
{
if
(
--
rsh
->
rhiCount
==
0
)
{
// all associated QRhi instances are gone for the rsh, time to clean up
rsh
->
d_vulkan
.
df
->
vkDeviceWaitIdle
(
rsh
->
d_vulkan
.
dev
);
if
(
rsh
->
d_vulkan
.
releaseQueue
)
{
...
...
@@ -3007,8 +3004,6 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
return
vertexAttribDivisorAvailable
;
case
QRhi
::
PrimitiveRestart
:
return
true
;
case
QRhi
::
CrossThreadResourceSharing
:
return
true
;
default:
Q_UNREACHABLE
();
return
false
;
...
...
todo.txt
View file @
2ae78fee
res.sh.: gl
res.sh.: mtl
res.sh.: example to show read/write same texture
threading with rsh with resource - more external sync needed
advanced blend modes
gl: tex formats (texture, readback)
gl: srgb
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment