summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorJøger Hansegård <joger.hansegard@qt.io>2024-04-12 09:42:02 +0200
committerJøger Hansegård <joger.hansegard@qt.io>2024-04-16 20:59:39 +0200
commit30eb2b2417c2658fb324452d1fc76043157ada23 (patch)
tree82ea2077bef8a8ff82666c10df9f8a7664d9d03b /src/multimedia
parent36fd680942e73f77523215a4516986508ba953d2 (diff)
Prevent lost D3D11 device with QVideoFrame::toImage() with Qt Quick
This patch ensures that QFFmpeg::TextureConverter is only used to convert frames when the destination QRhi instance is the same as the one it was initialized on. If QVideoFrame::toImage() is called from the main thread while the frame is also being rendered in the Qt Quick render thread, QVideoFrame::toImage() will create its own QRhi instance. In this case we need to disable direct texture transfer of the QFFmpeg textures, and instead fall back to mapping the texture data through CPU memory. Task-number: QTBUG-113627 Pick-to: 6.7 6.5 Change-Id: I3184796d05627fcac1a069400e8a6a5879fcd5bc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/video/qabstractvideobuffer_p.h2
-rw-r--r--src/multimedia/video/qvideotexturehelper.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/multimedia/video/qabstractvideobuffer_p.h b/src/multimedia/video/qabstractvideobuffer_p.h
index 19637147a..2004e25f7 100644
--- a/src/multimedia/video/qabstractvideobuffer_p.h
+++ b/src/multimedia/video/qabstractvideobuffer_p.h
@@ -60,7 +60,7 @@ public:
virtual void unmap() = 0;
virtual std::unique_ptr<QVideoFrameTextures> mapTextures(QRhi *) { return {}; }
- virtual quint64 textureHandle(int /*plane*/) const { return 0; }
+ virtual quint64 textureHandle(QRhi *, int /*plane*/) const { return 0; }
virtual QMatrix4x4 externalTextureMatrix() const { return {}; }
diff --git a/src/multimedia/video/qvideotexturehelper.cpp b/src/multimedia/video/qvideotexturehelper.cpp
index 8e2e6e796..937ff33cb 100644
--- a/src/multimedia/video/qvideotexturehelper.cpp
+++ b/src/multimedia/video/qvideotexturehelper.cpp
@@ -650,7 +650,7 @@ static std::unique_ptr<QRhiTexture> createTextureFromHandle(const QVideoFrame &f
#endif
}
- if (quint64 handle = frame.videoBuffer()->textureHandle(plane); handle) {
+ if (quint64 handle = frame.videoBuffer()->textureHandle(rhi, plane); handle) {
std::unique_ptr<QRhiTexture> tex(rhi->newTexture(texDesc.textureFormat[plane], planeSize, 1, textureFlags));
if (tex->createFrom({handle, 0}))
return tex;