summaryrefslogtreecommitdiffstats
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-16 16:34:13 +0100
commite7142bab89d05fdca0477027404705e06ec68984 (patch)
treecc3d07f0cdf976f54c8dcb539663510d4125d15a
parentdc879d2ad2e6f5224f8d87e98b5fc96323cc8c70 (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. Fixes: QTBUG-100665 Change-Id: Ie4bc02dbaccec12d92f8e274eeb420482a5f2d58 Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 3893a5b88349f4086e003c3f51cffdf538131c6c)
-rw-r--r--src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp
index 9cf4846a7..f6a502af2 100644
--- a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp
+++ b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp
@@ -181,26 +181,28 @@ 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 +247,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";
}