Beispiel #1
0
/*!
    Creates a 3D OpenCL image object with the specified \a format,
    \a width, \a height, \a depth, and \a access mode.

    The image memory is created on the device and will not be accessible
    to the host via a direct pointer.  Use createImage3DHost() to
    create a host-accessible image.

    Returns the new 3D OpenCL image object, or a null object
    if the image could not be created.

    \sa createImage3DHost(), createImage3DCopy()
*/
QCLImage3D QCLContext::createImage3DDevice
    (const QCLImageFormat &format, int width, int height, int depth,
     QCLMemoryObject::Access access)
{
    Q_D(QCLContext);
    cl_int error = CL_INVALID_CONTEXT;
    cl_mem_flags flags = cl_mem_flags(access);
    cl_mem mem = clCreateImage3D
        (d->id, flags, &(format.m_format), width, height, depth, 0, 0,
         0, &error);
    reportError("QCLContext::createImage3DDevice:", error);
    if (mem)
        return QCLImage3D(this, mem);
    else
        return QCLImage3D();
}
Beispiel #2
0
/*!
    Creates a 3D OpenCL image object with the specified \a format,
    \a width, \a height, \a depth, and \a access mode.
    If \a bytesPerLine is not zero, it indicates the number of bytes
    between lines in \a data.  If \a bytesPerSlice is not zero,
    it indicates the number of bytes between slices in \a data.

    The image is initialized with a copy of the contents of \a data.
    The application's \a data can be discarded after the image
    is created.

    Returns the new 3D OpenCL image object, or a null object
    if the image could not be created.

    \sa createImage3DDevice(), createImage3DHost()
*/
QCLImage3D QCLContext::createImage3DCopy
    (const QCLImageFormat &format, const void *data,
     int width, int height, int depth,
     QCLMemoryObject::Access access, int bytesPerLine, int bytesPerSlice)
{
    Q_D(QCLContext);
    cl_int error = CL_INVALID_CONTEXT;
    cl_mem_flags flags = cl_mem_flags(access) | CL_MEM_COPY_HOST_PTR;
    cl_mem mem = clCreateImage3D
        (d->id, flags, &(format.m_format),
         width, height, depth, bytesPerLine, bytesPerSlice,
         const_cast<void *>(data), &error);
    reportError("QCLContext::createImage3DCopy:", error);
    if (mem)
        return QCLImage3D(this, mem);
    else
        return QCLImage3D();
}
Beispiel #3
0
/*!
    Creates a 3D OpenCL image object from the specified \a mipmapLevel,
    OpenGL \a texture object, and \a access mode.

    The \a type must be \c{GL_TEXTURE_3D}.  The \a texture does not need
    to be bound to an OpenGL texture target.

    This function will only work if supportsObjectSharing() is true.

    \sa createTexture2D()
*/
QCLImage3D QCLContextGL::createTexture3D
    (GLenum type, GLuint texture, GLint mipmapLevel, QCLMemoryObject::Access access)
{
#ifndef QT_NO_CL_OPENGL
    cl_int error = CL_INVALID_CONTEXT;
    cl_mem_flags flags = cl_mem_flags(access);
    cl_mem mem = clCreateFromGLTexture3D
        (contextId(), flags, type, mipmapLevel, texture, &error);
    reportError("QCLContextGL::createGLTexture3D:", error);
    if (mem)
        return QCLImage3D(this, mem);
    else
        return QCLImage3D();
#else
    Q_UNUSED(type);
    Q_UNUSED(texture);
    Q_UNUSED(mipmapLevel);
    Q_UNUSED(access);
    reportError("QCLContextGL::createGLTexture3D:", CL_INVALID_VALUE);
    return QCLImage3D();
#endif
}