summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multimedia/video')
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/README5
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/main.cpp32
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro7
3 files changed, 19 insertions, 25 deletions
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/README b/examples/multimedia/video/qmlvideofilter_opencl/README
index 96b812b8e..cc351e430 100644
--- a/examples/multimedia/video/qmlvideofilter_opencl/README
+++ b/examples/multimedia/video/qmlvideofilter_opencl/README
@@ -3,14 +3,11 @@ which is assumed to be provided in RGB format. The OpenCL operation is done on
an OpenGL texture using CL-GL interop, without any further readbacks or copies
(except for the initial texture upload, when necessary).
-Currently OS X, Windows with real OpenGL (opengl32.dll) and Linux (GLX only) are
+Currently OS X, Windows with real OpenGL (opengl32.dll) and Linux (GLX) are
supported. Note that an OpenCL implementation with GPU support is required. The
platform and device selection logic supports NVIDIA, AMD and Intel. Porting to
other platforms is probably simple, see clCreateContextFromType.
-On Windows you may need to edit testplugin.pro to specify the location of the
-OpenCL headers and libraries.
-
YUV formats are not supported in this example. This is probably not an issue an
OS X and Windows, but will most likely disable the example on Linux.
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/main.cpp b/examples/multimedia/video/qmlvideofilter_opencl/main.cpp
index af5aa8f65..0ca5e35e8 100644
--- a/examples/multimedia/video/qmlvideofilter_opencl/main.cpp
+++ b/examples/multimedia/video/qmlvideofilter_opencl/main.cpp
@@ -181,8 +181,6 @@ CLFilterRunnable::CLFilterRunnable(CLFilter *filter) :
CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(),
0 };
#elif defined(Q_OS_LINUX)
- // An elegant alternative to glXGetCurrentContext. This will even survive
- // (without interop) when using something other than GLX.
QVariant nativeGLXHandle = QOpenGLContext::currentContext()->nativeHandle();
QGLXNativeContext nativeGLXContext;
if (!nativeGLXHandle.isNull() && nativeGLXHandle.canConvert<QGLXNativeContext>())
@@ -191,6 +189,7 @@ CLFilterRunnable::CLFilterRunnable(CLFilter *filter) :
qWarning("Failed to get the underlying GLX context from the current QOpenGLContext");
cl_context_properties contextProps[] = { CL_CONTEXT_PLATFORM, (cl_context_properties) platform,
CL_GL_CONTEXT_KHR, (cl_context_properties) nativeGLXContext.context(),
+ CL_GLX_DISPLAY_KHR, (cl_context_properties) glXGetCurrentDisplay(),
0 };
#endif
@@ -203,16 +202,22 @@ CLFilterRunnable::CLFilterRunnable(CLFilter *filter) :
// Get the GPU device id
#if defined(Q_OS_OSX)
// On OS X, get the "online" device/GPU. This is required for OpenCL/OpenGL context sharing.
- if (clGetGLContextInfoAPPLE(m_clContext, CGLGetCurrentContext(),
- CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE,
- sizeof(cl_device_id), &m_clDeviceId, NULL) != CL_SUCCESS) {
+ err = clGetGLContextInfoAPPLE(m_clContext, CGLGetCurrentContext(),
+ CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE,
+ sizeof(cl_device_id), &m_clDeviceId, 0);
+ if (err != CL_SUCCESS) {
qWarning("Failed to get OpenCL device for current screen: %d", err);
return;
}
#else
- if (clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &m_clDeviceId, 0) != CL_SUCCESS) {
- qWarning("Failed to get OpenCL device");
- return;
+ clGetGLContextInfoKHR_fn getGLContextInfo = (clGetGLContextInfoKHR_fn) clGetExtensionFunctionAddress("clGetGLContextInfoKHR");
+ if (!getGLContextInfo || getGLContextInfo(contextProps, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR,
+ sizeof(cl_device_id), &m_clDeviceId, 0) != CL_SUCCESS) {
+ err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &m_clDeviceId, 0);
+ if (err != CL_SUCCESS) {
+ qWarning("Failed to get OpenCL device: %d", err);
+ return;
+ }
}
#endif
@@ -291,15 +296,9 @@ QVideoFrame CLFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat
Q_UNUSED(flags);
// This example supports RGB data only, either in system memory (typical with cameras on all
- // platforms) or as an OpenGL texture (e.g. video playback on OS X or on Windows with ANGLE).
+ // platforms) or as an OpenGL texture (e.g. video playback on OS X).
// The latter is the fast path where everything happens on GPU. THe former involves a texture upload.
- // ANGLE is not compatible with this example since we only do CL-GL interop, not D3D9/11.
- if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
- qWarning("ANGLE is not supported");
- return *input;
- }
-
if (!input->isValid()
|| (input->handleType() != QAbstractVideoBuffer::NoHandle
&& input->handleType() != QAbstractVideoBuffer::GLTextureHandle)) {
@@ -483,6 +482,9 @@ QVideoFrame InfoFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceForma
int main(int argc, char **argv)
{
+#ifdef Q_OS_WIN // avoid ANGLE on Windows
+ QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
+#endif
QGuiApplication app(argc, argv);
qmlRegisterType<CLFilter>("qmlvideofilter.cl.test", 1, 0, "CLFilter");
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro b/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro
index c83929f72..f7f191d2b 100644
--- a/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro
+++ b/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro
@@ -14,9 +14,4 @@ INSTALLS += target
osx: LIBS += -framework OpenCL
unix: !osx: LIBS += -lOpenCL
-win32:!winrt {
- # Edit these as necessary
- INCLUDEPATH += c:/cuda/include
- LIBPATH += c:/cuda/lib/x64
- LIBS += -lopengl32 -lOpenCL
-}
+win32:!winrt: LIBS += -lopengl32 -lOpenCL