aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcl/qquickclitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quickcl/qquickclitem.cpp')
-rw-r--r--src/quickcl/qquickclitem.cpp111
1 files changed, 3 insertions, 108 deletions
diff --git a/src/quickcl/qquickclitem.cpp b/src/quickcl/qquickclitem.cpp
index 6c88b5d..6947fed 100644
--- a/src/quickcl/qquickclitem.cpp
+++ b/src/quickcl/qquickclitem.cpp
@@ -122,42 +122,16 @@ QQuickCLItem::QQuickCLItem(QQuickItem *parent)
}
/*!
- \return the selected OpenCL platform. Matches the OpenGL context in use.
+ \return the associated QQuickCLContext.
\note The value is only available after the item is first rendered. It is
always safe to call this function from QQuickCLRunnable's constructor,
destructor and \l{QQuickCLRunnable::update()}{update()} function.
*/
-cl_platform_id QQuickCLItem::platform() const
+QQuickCLContext *QQuickCLItem::context() const
{
Q_D(const QQuickCLItem);
- return d->clctx ? d->clctx->platform() : 0;
-}
-
-/*!
- \return the selected OpenCL device. Matches the OpenGL context in use.
-
- \note The value is only available after the item is first rendered. It is
- always safe to call this function from QQuickCLRunnable's constructor,
- destructor and \l{QQuickCLRunnable::update()}{update()} function.
- */
-cl_device_id QQuickCLItem::device() const
-{
- Q_D(const QQuickCLItem);
- return d->clctx ? d->clctx->device() : 0;
-}
-
-/*!
- \return the OpenCL context.
-
- \note The value is only available after the item is first rendered. It is
- always safe to call this function from QQuickCLRunnable's constructor,
- destructor and \l{QQuickCLRunnable::update()}{update()} function.
- */
-cl_context QQuickCLItem::context() const
-{
- Q_D(const QQuickCLItem);
- return d->clctx ? d->clctx->context() : 0;
+ return d->clctx;
}
QSGNode *QQuickCLItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
@@ -253,85 +227,6 @@ void QQuickCLItem::scheduleUpdate()
QCoreApplication::postEvent(this, new QEvent(QEvent::Type(EV_UPDATE)));
}
-/*!
- \return the name of the current platform in use.
-
- \note This function can only be called from a QQuickCLRunnable's
- constructor, destructor and \l{QQuickCLRunnable::update()}{update()}
- function, or after the item has been rendered at least once.
- */
-QByteArray QQuickCLItem::platformName() const
-{
- QByteArray name(1024, '\0');
- clGetPlatformInfo(platform(), CL_PLATFORM_NAME, name.size(), name.data(), 0);
- name.resize(int(strlen(name.constData())));
- return name;
-}
-
-/*!
- \return the list of device extensions.
-
- \note This function can only be called from a QQuickCLRunnable's
- constructor, destructor and \l{QQuickCLRunnable::update()}{update()}
- function, or after the item has been rendered at least once.
- */
-QByteArray QQuickCLItem::deviceExtensions() const
-{
- QByteArray ext(8192, '\0');
- clGetDeviceInfo(device(), CL_DEVICE_EXTENSIONS, ext.size(), ext.data(), 0);
- ext.resize(int(strlen(ext.constData())));
- return ext;
-}
-
-/*!
- Creates and builds an OpenCL program from the source code in \a src.
-
- \return the cl_program or \c 0 when failed. Errors and build logs are
- printed to the warning output.
-
- \note This function can only be called from a QQuickCLRunnable's
- constructor, destructor and \l{QQuickCLRunnable::update()}{update()}
- function, or after the item has been rendered at least once.
- */
-cl_program QQuickCLItem::buildProgram(const QByteArray &src)
-{
- cl_int err;
- const char *str = src.constData();
- cl_program prog = clCreateProgramWithSource(context(), 1, &str, 0, &err);
- if (!prog) {
- qWarning("Failed to create OpenCL program: %d", err);
- qWarning("Source was:\n%s", str);
- return 0;
- }
- cl_device_id dev = device();
- err = clBuildProgram(prog, 1, &dev, 0, 0, 0);
- if (err != CL_SUCCESS) {
- qWarning("Failed to build OpenCL program: %d", err);
- qWarning("Source was:\n%s", str);
- QByteArray log;
- log.resize(8192);
- clGetProgramBuildInfo(prog, dev, CL_PROGRAM_BUILD_LOG, log.size(), log.data(), 0);
- qWarning("Build log:\n%s", log.constData());
- return 0;
- }
- return prog;
-}
-
-/*!
- Creates and builds an OpenCL program from the source file \a filename.
-
- \sa buildProgram()
- */
-cl_program QQuickCLItem::buildProgramFromFile(const QString &filename)
-{
- QFile f(filename);
- if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
- qWarning("Failed to open OpenCL program source file %s", qPrintable(filename));
- return 0;
- }
- return buildProgram(f.readAll());
-}
-
struct EventCallbackParam
{
EventCallbackParam(QQuickCLItem *item) : item(item) { }