summaryrefslogtreecommitdiffstats
path: root/src/plugins/multimedia/windows
diff options
context:
space:
mode:
authorPiotr Srebrny <piotr.srebrny@qt.io>2022-02-11 14:17:20 +0100
committerPiotr Srebrny <piotr.srebrny@qt.io>2022-02-15 10:07:04 +0100
commit3893a5b88349f4086e003c3f51cffdf538131c6c (patch)
tree02e0c9b86ca1a17e8cd9a6df10408a25ce8a50b6 /src/plugins/multimedia/windows
parent04f380a38c67ba8fc1ae71e27aa7b4db1f316e4c (diff)
Do not access NV_DX_interop functions out of OpenGL context
An attempt to use NV_DX_interop functions out of OpenGL context results in an exception. Thus, we do not unregister the D3D9 texture from the OpenGL context when it is gone. This patch also clears m_glHandle variable after it has been unregister in some rare case when we cannot lock it. Pick-to: 6.2 6.3 Fixes: QTBUG-100665 Change-Id: Ie4bc02dbaccec12d92f8e274eeb420482a5f2d58 Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins/multimedia/windows')
-rw-r--r--src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp b/src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp
index 5b760d5cf..25797998a 100644
--- a/src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp
+++ b/src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp
@@ -181,26 +181,27 @@ public:
~OpenGlVideoBuffer() override
{
- if (m_d3dglHandle) {
+ if (!m_d3dglHandle)
+ return;
+
+ if (QOpenGLContext::currentContext()) {
if (m_glHandle) {
if (!m_wgl.wglDXUnlockObjectsNV(m_d3dglHandle, 1, &m_glHandle))
qCDebug(qLcEvrD3DPresentEngine) << "Failed to unlock OpenGL texture";
if (!m_wgl.wglDXUnregisterObjectNV(m_d3dglHandle, m_glHandle))
qCDebug(qLcEvrD3DPresentEngine) << "Failed to unregister OpenGL texture";
- if (QOpenGLContext::currentContext()) {
- QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
- if (funcs)
- funcs->glDeleteTextures(1, &m_glTextureName);
- else
- qCDebug(qLcEvrD3DPresentEngine) << "Could not delete texture, OpenGL context functions missing";
- } else {
- qCDebug(qLcEvrD3DPresentEngine) << "Could not delete texture, OpenGL context missing";
- }
+ QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
+ if (funcs)
+ funcs->glDeleteTextures(1, &m_glTextureName);
+ else
+ qCDebug(qLcEvrD3DPresentEngine) << "Could not delete texture, OpenGL context functions missing";
}
-
if (!m_wgl.wglDXCloseDeviceNV(m_d3dglHandle))
qCDebug(qLcEvrD3DPresentEngine) << "Failed to close D3D-GL device";
+
+ } else {
+ qCDebug(qLcEvrD3DPresentEngine) << "Could not release texture, OpenGL context missing";
}
}
@@ -245,6 +246,7 @@ public:
qCDebug(qLcEvrD3DPresentEngine) << "Failed to lock OpenGL texture";
m_wgl.wglDXUnregisterObjectNV(m_d3dglHandle, m_glHandle);
+ m_glHandle = nullptr;
} else {
qCDebug(qLcEvrD3DPresentEngine) << "Could not register D3D9 texture in OpenGL";
}