コード例 #1
0
JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL10GL_nclCreateFromGLRenderbuffer(JNIEnv *__env, jclass clazz, jlong contextAddress, jlong flags, jint renderbuffer, jlong errcode_retAddress, jlong __functionAddress) {
	cl_context context = (cl_context)(intptr_t)contextAddress;
	cl_int *errcode_ret = (cl_int *)(intptr_t)errcode_retAddress;
	clCreateFromGLRenderbufferPROC clCreateFromGLRenderbuffer = (clCreateFromGLRenderbufferPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	return (jlong)(intptr_t)clCreateFromGLRenderbuffer(context, flags, renderbuffer, errcode_ret);
}
コード例 #2
0
ファイル: liboi.cpp プロジェクト: bkloppenborg/liboi
/// Tells LibOI that the image source is located in OpenGL device memory at the location
/// specified.  You must also indicate whether the OpenGL location is a
///  OPENGL_FRAMEBUFFER | OPENGL_TEXTUREBUFFER
/// All subsequent CopyImageToBuffer commands will read from this location.
void CLibOI::SetImageSource(GLuint gl_device_memory, LibOIEnums::ImageTypes type)
{
	mImageType = type;

	int status = CL_SUCCESS;
	unsigned int CLVersion = mOCL->GetOpenCLVersion();

	switch(type)
	{
	case LibOIEnums::OPENGL_FRAMEBUFFER:
		mImage_gl = clCreateFromGLBuffer(mOCL->GetContext(), CL_MEM_READ_ONLY, gl_device_memory, &status);
		CHECK_OPENCL_ERROR(status, "clCreateFromGLBuffer failed.");

		break;

	case LibOIEnums::OPENGL_TEXTUREBUFFER:

		// OpenCL's support for texture buffers changed between v1.0 and v1.2,
		// but we might be linking with an older library, hence we use both
		// runtime version detection and compile-time detection
		if(CLVersion == 100 || CLVersion == 110 || CLVersion == 000)
		{
			mImage_gl = clCreateFromGLTexture2D(mOCL->GetContext(), CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, gl_device_memory, &status);
		}
#if MAX_OPENCL_VERSION >= 120
//#if MAX_OPENCL_VERSION_MAJOR >= 1 && MAX_OPENCL_VERSION_MAJOR >= 2
		else if(CLVersion == 120)
		{
			mImage_gl = clCreateFromGLTexture(mOCL->GetContext(), CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, gl_device_memory, &status);
		}
#endif // MAX_OPENCL_VERSION >= 1.2
		else // mImage_gl == NULL
		{
			throw runtime_error("No function for accessing OpenGL memory is defined for this OpenCL context!");
		}
		CHECK_OPENCL_ERROR(status, "clCreateFromGLTexture failed.");

		break;

	case LibOIEnums::OPENGL_RENDERBUFFER:
		// TODO: note that the clCreateFromGLTexture2D was depreciated in the OpenCL 1.2 specifications.
		mImage_gl = clCreateFromGLRenderbuffer(mOCL->GetContext(), CL_MEM_READ_ONLY, gl_device_memory, &status);
		CHECK_OPENCL_ERROR(status, "clCreateFromGLRenderbuffer failed.");

		break;

	default:
		// We don't know what type of image this is!
		assert(false);
		break;
	}
}
コード例 #3
0
    /// Creates a new OpenGL renderbuffer object in \p context for
    /// \p renderbuffer with \p flags.
    ///
    /// \see_opencl_ref{clCreateFromGLRenderbuffer}
    opengl_renderbuffer(const context &context,
                        GLuint renderbuffer,
                        cl_mem_flags flags = read_write)
    {
        cl_int error = 0;

        m_mem = clCreateFromGLRenderbuffer(
            context, flags, renderbuffer, &error
        );

        if(!m_mem){
            BOOST_THROW_EXCEPTION(opencl_error(error));
        }
    }
コード例 #4
0
ファイル: qclcontextgl.cpp プロジェクト: Dem0n3D/qt-opencl
/*!
    Creates a 2D OpenCL image object from the specified OpenGL
    \a renderbuffer object, and the \a access mode.

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

    \sa createTexture2D()
*/
QCLImage2D QCLContextGL::createRenderbuffer
    (GLuint renderbuffer, 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 = clCreateFromGLRenderbuffer
        (contextId(), flags, renderbuffer, &error);
    reportError("QCLContextGL::createGLRenderbuffer:", error);
    if (mem)
        return QCLImage2D(this, mem);
    else
        return QCLImage2D();
#else
    Q_UNUSED(renderbuffer);
    Q_UNUSED(access);
    reportError("QCLContextGL::createRenderbuffer:", CL_INVALID_VALUE);
    return QCLImage2D();
#endif
}
コード例 #5
0
ファイル: liboi.cpp プロジェクト: matdander/liboi
/// Tells LibOI that the image source is located in OpenGL device memory at the location
/// specified.  You must also indicate whether the OpenGL location is a
///  OPENGL_FRAMEBUFFER | OPENGL_TEXTUREBUFFER
/// All subsequent CopyImageToBuffer commands will read from this location.
void CLibOI::SetImageSource(GLuint gl_device_memory, LibOIEnums::ImageTypes type)
{
	mImageType = type;

	int status = CL_SUCCESS;

	switch(type)
	{
	case LibOIEnums::OPENGL_FRAMEBUFFER:
		mImage_gl = clCreateFromGLBuffer(mOCL->GetContext(), CL_MEM_READ_ONLY, gl_device_memory, &status);
		CHECK_OPENCL_ERROR(status, "clCreateFromGLBuffer failed.");

		break;

	case LibOIEnums::OPENGL_TEXTUREBUFFER:
#if defined(DETECTED_OPENCL_1_0) || defined(DETECTED_OPENCL_1_1) || defined(DETECTED_OPENCL_UNKNOWN_VERSION)
		mImage_gl = clCreateFromGLTexture3D(mOCL->GetContext(), CL_MEM_READ_ONLY, GL_TEXTURE_3D, 0, gl_device_memory, &status);
#else
		mImage_gl = clCreateFromGLTexture(mOCL->GetContext(), CL_MEM_READ_ONLY, GL_TEXTURE_2D_ARRAY, 0, gl_device_memory, &status);
#endif // defined(DETECTED_OPENCL_1_0) || defined(DETECTED_OPENCL_1_1)
		CHECK_OPENCL_ERROR(status, "clCreateFromGLTexture failed.");

		break;

	case LibOIEnums::OPENGL_RENDERBUFFER:
		// TODO: note that the clCreateFromGLTexture2D was depreciated in the OpenCL 1.2 specifications.
		mImage_gl = clCreateFromGLRenderbuffer(mOCL->GetContext(), CL_MEM_READ_ONLY, gl_device_memory, &status);
		CHECK_OPENCL_ERROR(status, "clCreateFromGLRenderbuffer failed.");

		break;

	default:
		// We don't know what type of image this is!
		assert(false);
		break;
	}
}
コード例 #6
0
JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL10GL_nclCreateFromGLRenderbuffer(JNIEnv *env, jclass clazz, jlong context, jlong flags, jint renderbuffer, jlong errcode_ret, jlong function_pointer) {
	cl_int *errcode_ret_address = (cl_int *)(intptr_t)errcode_ret;
	clCreateFromGLRenderbufferPROC clCreateFromGLRenderbuffer = (clCreateFromGLRenderbufferPROC)((intptr_t)function_pointer);
	cl_mem __result = clCreateFromGLRenderbuffer((cl_context)(intptr_t)context, flags, renderbuffer, errcode_ret_address);
	return (intptr_t)__result;
}