/*! Copies the contents of \a rect within this buffer to \a dest, starting at \a destPoint. The source and destination line pitch values are given by \a bufferBytesPerLine and \a destBytesPerLine respectively. 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(). This function is only supported in OpenCL 1.1 and higher. \sa copyToRect() */ QCLEvent QCLBuffer::copyToRectAsync (const QRect &rect, const QCLBuffer &dest, const QPoint &destPoint, size_t bufferBytesPerLine, size_t destBytesPerLine, const QCLEventList &after) { #ifdef QT_OPENCL_1_1 const size_t src_origin[3] = {rect.x(), rect.y(), 0}; const size_t dst_origin[3] = {destPoint.x(), destPoint.y(), 0}; const size_t region[3] = {rect.width(), rect.height(), 1}; cl_event event; cl_int error = clEnqueueCopyBufferRect (context()->activeQueue(), memoryId(), dest.memoryId(), src_origin, dst_origin, region, bufferBytesPerLine, 0, destBytesPerLine, 0, after.size(), after.eventData(), &event); context()->reportError("QCLBuffer::copyToRectAsync:", error); if (error == CL_SUCCESS) return QCLEvent(event); else return QCLEvent(); #else context()->reportError("QCLBuffer::copyToRectAsync:", CL_INVALID_OPERATION); Q_UNUSED(rect); Q_UNUSED(dest); Q_UNUSED(destPoint); Q_UNUSED(bufferBytesPerLine); Q_UNUSED(destBytesPerLine); Q_UNUSED(after); return false; #endif }
/*! Copies the 3D rectangle defined by \a origin and \a size within this buffer to \a destOrigin within \a dest. The source and destination pitch values are given by \a bufferBytesPerLine, \a bufferBytesPerSlice, \a destBytesPerLine, and \a destBytesPerSlice. 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(). This function is only supported in OpenCL 1.1 and higher. \sa copyToRectAsync() */ QCLEvent QCLBuffer::copyToRectAsync (const size_t origin[3], const size_t size[3], const QCLBuffer &dest, const size_t destOrigin[3], size_t bufferBytesPerLine, size_t bufferBytesPerSlice, size_t destBytesPerLine, size_t destBytesPerSlice, const QCLEventList &after) { #ifdef QT_OPENCL_1_1 cl_event event; cl_int error = clEnqueueCopyBufferRect (context()->activeQueue(), memoryId(), dest.memoryId(), origin, destOrigin, size, bufferBytesPerLine, bufferBytesPerSlice, destBytesPerLine, destBytesPerSlice, after.size(), after.eventData(), &event); context()->reportError("QCLBuffer::copyToRectAsync(3D):", error); if (error == CL_SUCCESS) return QCLEvent(event); else return QCLEvent(); #else context()->reportError("QCLBuffer::copyToRectAsync(3D):", CL_INVALID_OPERATION); Q_UNUSED(origin); Q_UNUSED(size); Q_UNUSED(dest); Q_UNUSED(destOrigin); Q_UNUSED(bufferBytesPerLine); Q_UNUSED(bufferBytesPerSlice); Q_UNUSED(destBytesPerLine); Q_UNUSED(destBytesPerSlice); Q_UNUSED(after); return false; #endif }
/*! Writes the bytes at \a data, with a line pitch of \a hostBytesPerLine, and a slice pitch of \a hostBytesPerSlice, to the 3D region defined by \a origin, \a size, \a bufferBytesPerLine, and \a bufferBytesPerSlice in this buffer. This function will queue the request and return immediately. 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(). This function is only supported in OpenCL 1.1 and higher. \sa writeRect(), readRectAsync() */ QCLEvent QCLBuffer::writeRectAsync (const size_t origin[3], const size_t size[3], const void *data, size_t bufferBytesPerLine, size_t bufferBytesPerSlice, size_t hostBytesPerLine, size_t hostBytesPerSlice, const QCLEventList &after) { #ifdef QT_OPENCL_1_1 static size_t const hostOrigin[3] = {0, 0, 0}; cl_event event; cl_int error = clEnqueueWriteBufferRect (context()->activeQueue(), memoryId(), CL_FALSE, origin, hostOrigin, size, bufferBytesPerLine, bufferBytesPerSlice, hostBytesPerLine, hostBytesPerSlice, data, after.size(), after.eventData(), &event); context()->reportError("QCLBuffer::writeRectAsync(3D):", error); if (error != CL_SUCCESS) return QCLEvent(); else return QCLEvent(event); #else context()->reportError("QCLBuffer::writeRectAsync(3D):", CL_INVALID_OPERATION); Q_UNUSED(origin); Q_UNUSED(size); Q_UNUSED(data); Q_UNUSED(bufferBytesPerLine); Q_UNUSED(bufferBytesPerSlice); Q_UNUSED(hostBytesPerLine); Q_UNUSED(hostBytesPerSlice); Q_UNUSED(after); return QCLEvent(); #endif }
/*! Writes the bytes at \a data, with a line pitch of \a hostBytesPerLine to the region of this buffer defined by \a rect and \a bufferBytesPerLine. Returns true if the write was successful; false otherwise. This function will queue the request and return immediately. 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(). This function is only supported in OpenCL 1.1 and higher. \sa writeRect(), readRectAsync() */ QCLEvent QCLBuffer::writeRectAsync (const QRect &rect, const void *data, size_t bufferBytesPerLine, size_t hostBytesPerLine, const QCLEventList &after) { #ifdef QT_OPENCL_1_1 size_t bufferOrigin[3] = {rect.x(), rect.y(), 0}; size_t bufferRegion[3] = {rect.width(), rect.height(), 1}; static size_t const hostOrigin[3] = {0, 0, 0}; cl_event event; cl_int error = clEnqueueWriteBufferRect (context()->activeQueue(), memoryId(), CL_FALSE, bufferOrigin, hostOrigin, bufferRegion, bufferBytesPerLine, 0, hostBytesPerLine, 0, data, after.size(), after.eventData(), &event); context()->reportError("QCLBuffer::writeRectAsync:", error); if (error != CL_SUCCESS) return QCLEvent(); else return QCLEvent(event); #else context()->reportError("QCLBuffer::writeRectAsync:", CL_INVALID_OPERATION); Q_UNUSED(rect); Q_UNUSED(data); Q_UNUSED(bufferBytesPerLine); Q_UNUSED(hostBytesPerLine); Q_UNUSED(after); return QCLEvent(); #endif }
/*! \overload Adds a barrier to the active command queue that will prevent future commands from being executed until after all members of \a events have been signalled. \sa marker() */ void QCLContext::barrier(const QCLEventList &events) { if (events.isEmpty()) return; cl_int error = clEnqueueWaitForEvents (activeQueue(), events.size(), events.eventData()); reportError("QCLContext::barrier(QCLEventList):", error); }
/*! Writes \a size bytes to this buffer, starting at \a offset, from the supplied \a data array. This function will queue the request and return immediately. 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 write(), readAsync() */ QCLEvent QCLBuffer::writeAsync(size_t offset, const void *data, size_t size, const QCLEventList &after) { cl_event event; cl_int error = clEnqueueWriteBuffer (context()->activeQueue(), memoryId(), CL_FALSE, offset, size, data, after.size(), after.eventData(), &event); context()->reportError("QCLBuffer::writeAsync:", error); if (error != CL_SUCCESS) return QCLEvent(); else return QCLEvent(event); }
/*! Requests that the \a size bytes at \a offset in this buffer be copied to \a destOffset in the buffer \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, size_t size, const QCLBuffer &dest, size_t destOffset, const QCLEventList &after) { cl_event event; cl_int error = clEnqueueCopyBuffer (context()->activeQueue(), memoryId(), dest.memoryId(), offset, destOffset, size, after.size(), after.eventData(), &event); context()->reportError("QCLBuffer::copyToAsync:", error); if (error != CL_SUCCESS) return QCLEvent(); else return QCLEvent(event); }
/*! \overload Requests that this kernel instance be run on globalWorkSize() items, optionally subdivided into work groups of localWorkSize() items. If \a after is not an empty list, it indicates the events that must be signaled as finished before this kernel instance can begin executing. Returns an event object that can be used to wait for the kernel to finish execution. The request is executed on the active command queue for context(). */ QCLEvent QCLKernel::run(const QCLEventList &after) { Q_D(const QCLKernel); cl_event event; cl_int error = clEnqueueNDRangeKernel (d->context->activeQueue(), m_kernelId, d->globalWorkSize.dimensions(), 0, d->globalWorkSize.sizes(), (d->localWorkSize.width() ? d->localWorkSize.sizes() : 0), after.size(), after.eventData(), &event); d->context->reportError("QCLKernel::run:", error); if (error != CL_SUCCESS) return QCLEvent(); else return QCLEvent(event); }
/*! Copies the contents of this buffer, starting at \a offset to \a origin within \a dest, extending for \a size. 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 QCLImage3D &dest, const size_t origin[3], const size_t size[3], const QCLEventList &after) { cl_event event; cl_int error = clEnqueueCopyBufferToImage (context()->activeQueue(), memoryId(), dest.memoryId(), offset, origin, size, after.size(), after.eventData(), &event); context()->reportError("QCLBuffer::copyToAsync(QCLImage3D):", error); if (error == CL_SUCCESS) return QCLEvent(event); else return QCLEvent(); }
/*! Maps the \a size bytes starting at \a offset in this buffer into host memory for the specified \a access mode. Returns a pointer to the mapped region in \a ptr, which will be valid only after the request finishes. This function will queue the request and return immediately. 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 map(), unmapAsync() */ QCLEvent QCLBuffer::mapAsync (void **ptr, size_t offset, size_t size, QCLMemoryObject::Access access, const QCLEventList &after) { cl_int error; cl_event event; *ptr = clEnqueueMapBuffer (context()->activeQueue(), memoryId(), CL_FALSE, qt_cl_map_flags(access), offset, size, after.size(), after.eventData(), &event, &error); context()->reportError("QCLBuffer::mapAsync:", error); if (error == CL_SUCCESS) return QCLEvent(event); else return QCLEvent(); }
/*! \overload Releases access to the OpenGL object behind the OpenCL memory object \a mem. This function must be called after performing an OpenCL operation on any OpenGL memory object, and before performing OpenGL operations on the object. The request will not start until all of the events in \a after have been signaled as finished. Returns an event object that can be used to wait for the request to finish. The request is executed on the active command queue for this context. \sa acquire() */ QCLEvent QCLContextGL::release (const QCLMemoryObject &mem, const QCLEventList &after) { #ifndef QT_NO_CL_OPENGL cl_event event; cl_mem id = mem.memoryId(); cl_int error = clEnqueueReleaseGLObjects (commandQueue().queueId(), 1, &id, after.size(), after.eventData(), &event); reportError("QCLContextGL::release(after):", error); if (error == CL_SUCCESS) return QCLEvent(event); else return QCLEvent(); #else Q_UNUSED(mem); Q_UNUSED(after); return QCLEvent(); #endif }
/*! 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(); }