Exemplo n.º 1
0
/*!
    Returns true if the 2D OpenCL \a image object is also an OpenGL
    renderbuffer object; false otherwise.

    \sa isTexture2D()
*/
bool QCLContextGL::isRenderbuffer(const QCLImage2D &image)
{
#ifndef QT_NO_CL_OPENGL
    cl_gl_object_type objectType;
    if (clGetGLObjectInfo
            (image.memoryId(), &objectType, 0) != CL_SUCCESS)
        return false;
    return objectType == CL_GL_OBJECT_RENDERBUFFER;
#else
    Q_UNUSED(image);
    return false;
#endif
}
Exemplo n.º 2
0
/*!
    Copies the contents of this buffer, starting at \a offset to
    \a rect within \a dest.  Returns true if the copy was successful;
    false otherwise.

    This function will block until the request finishes.
    The request is executed on the active command queue for context().

    \sa copyToAsync()
*/
bool QCLBuffer::copyTo
(size_t offset, const QCLImage2D &dest, const QRect &rect)
{
    const size_t dst_origin[3] = {static_cast<size_t>(rect.x()),
                                  static_cast<size_t>(rect.y()), 0
                                 };
    const size_t region[3] = {static_cast<size_t>(rect.width()),
                              static_cast<size_t>(rect.height()), 1
                             };
    cl_event event;
    cl_int error = clEnqueueCopyBufferToImage
                   (context()->activeQueue(), memoryId(), dest.memoryId(),
                    offset, dst_origin, region, 0, 0, &event);
    context()->reportError("QCLBuffer::copyTo(QCLImage2D):", error);
    if (error == CL_SUCCESS) {
        clWaitForEvents(1, &event);
        clReleaseEvent(event);
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 3
0
/*!
    Copies the contents of this buffer, starting at \a offset to
    \a rect within \a dest.  Returns an event object that can be used
    to wait for the request to finish.

    The request will not start until all of the events in \a after
    have been signaled as finished.  The request is executed on
    the active command queue for context().

    \sa copyTo()
*/
QCLEvent QCLBuffer::copyToAsync
(size_t offset, const QCLImage2D &dest, const QRect &rect,
 const QCLEventList &after)
{
//    const size_t dst_origin[3] = {rect.x(), rect.y(), 0};
//    const size_t region[3] = {rect.width(), rect.height(), 1};
    const size_t dst_origin[3] = {static_cast<size_t>(rect.x()),
                                  static_cast<size_t>(rect.y()), 0
                                 };
    const size_t region[3] = {static_cast<size_t>(rect.width()),
                              static_cast<size_t>(rect.height()), 1
                             };
    cl_event event;
    cl_int error = clEnqueueCopyBufferToImage
                   (context()->activeQueue(), memoryId(), dest.memoryId(),
                    offset, dst_origin, region,
                    after.size(), after.eventData(), &event);
    context()->reportError("QCLBuffer::copyToAsync(QCLImage2D):", error);
    if (error == CL_SUCCESS)
        return QCLEvent(event);
    else
        return QCLEvent();
}