Exemplo n.º 1
0
JNIEXPORT jint JNICALL Java_org_lwjgl_opencl_CL10GL_nclGetGLTextureInfo(JNIEnv *env, jclass clazz, jlong memobj, jint param_name, jlong param_value_size, jlong param_value, jlong param_value_size_ret, jlong function_pointer) {
	cl_void *param_value_address = (cl_void *)(intptr_t)param_value;
	size_t *param_value_size_ret_address = (size_t *)(intptr_t)param_value_size_ret;
	clGetGLTextureInfoPROC clGetGLTextureInfo = (clGetGLTextureInfoPROC)((intptr_t)function_pointer);
	cl_int __result = clGetGLTextureInfo((cl_mem)(intptr_t)memobj, param_name, param_value_size, param_value_address, param_value_size_ret_address);
	return __result;
}
Exemplo n.º 2
0
/// 
// Demonstrate usage of the GL Object querying capabilities
//
void performQueries() {
	cl_int errNum;
	std::cout << "Performing queries on OpenGL objects:" << std::endl;
	// example usage of getting information about a GL memory object
	cl_gl_object_type obj_type;
	GLuint objname;
	errNum = clGetGLObjectInfo(cl_tex_mem, &obj_type, &objname);
	if (errNum != CL_SUCCESS) {
		std::cerr << "Failed to get object information" << std::endl;
	}
	else {
		if (obj_type == CL_GL_OBJECT_TEXTURE2D) {
			std::cout << "Queried a texture object succesfully." << std::endl;
			std::cout << "Object name is: " << objname << std::endl;
		}
	}

	// Example usage of how to get information about the texture object
	GLenum param;
	size_t param_ret_size;
	errNum = clGetGLTextureInfo(cl_tex_mem, CL_GL_TEXTURE_TARGET, sizeof(GLenum), &param, &param_ret_size);
	if (errNum != CL_SUCCESS) {
		std::cerr << "Failed to get texture information" << std::endl;
	}
	else {
		// we have set it to use GL_TEXTURE_RECTANGLE_ARB.  We expect it to be reflectedin the query here
		if (param == GL_TEXTURE_2D) {//GL_TEXTURE_RECTANGLE_ARB
			std::cout << "Texture rectangle ARB is being used." << std::endl;
		}
	}
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opencl_CL10GL_nclGetGLTextureInfo(JNIEnv *__env, jclass clazz, jlong memobjAddress, jint param_name, jlong param_value_size, jlong param_valueAddress, jlong param_value_size_retAddress, jlong __functionAddress) {
	cl_mem memobj = (cl_mem)(intptr_t)memobjAddress;
	void *param_value = (void *)(intptr_t)param_valueAddress;
	size_t *param_value_size_ret = (size_t *)(intptr_t)param_value_size_retAddress;
	clGetGLTextureInfoPROC clGetGLTextureInfo = (clGetGLTextureInfoPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	return (jint)clGetGLTextureInfo(memobj, param_name, (size_t)param_value_size, param_value, param_value_size_ret);
}
Exemplo n.º 4
0
/* static */
cl_int MemoryObjectWrapper::GLTextureInfo (Wrapper const* aInstance, int aName,
                                           size_t aSize, void* aValueOut, size_t* aSizeOut) {
#ifdef CL_WRAPPER_ENABLE_OPENGL_SUPPORT
    cl_int err = CL_SUCCESS;
    MemoryObjectWrapper const* instance = dynamic_cast<MemoryObjectWrapper const*>(aInstance);
    VALIDATE_ARG_POINTER (instance, &err, err);
    return clGetGLTextureInfo (instance->getWrapped (), aName, aSize, aValueOut, aSizeOut);
#else //CL_WRAPPER_ENABLE_OPENGL_SUPPORT
    (void)aInstance; (void)aName; (void)aSize; (void)aValueOut; (void)aSizeOut;
    D_LOG (LOG_LEVEL_ERROR,
           "CLWrapper support for OpenCL/OpenGL interoperability API was not enabled at build time.");
    return CL_INVALID_VALUE;
#endif //CL_WRAPPER_ENABLE_OPENGL_SUPPORT
}
Exemplo n.º 5
0
int WebCLImage::getGLtextureInfo(int paramNameobj, ExceptionState& ec)
{
      cl_int err = 0;
      
      if (m_cl_mem == NULL) {
		printf("Error: Invalid CL Context\n");
		ec.throwDOMException(WebCLException::INVALID_MEM_OBJECT, "WebCLException::INVALID_MEM_OBJECT");
		return NULL;
	  }
	  cl_int int_units = 0;
	  
	  switch(paramNameobj)
	  {
            case WebCL::TEXTURE_TARGET:
			err = clGetGLTextureInfo(m_cl_mem, CL_GL_TEXTURE_TARGET, sizeof(cl_int), &int_units, NULL);
			if (err == CL_SUCCESS)
			return ((int)int_units);
			break;
		
            case WebCL::MIPMAP_LEVEL:
			err = clGetGLTextureInfo(m_cl_mem, CL_GL_MIPMAP_LEVEL, sizeof(cl_int), &int_units, NULL);
			if (err == CL_SUCCESS)
			return ((int)int_units);
			break;
			
	     default:
			printf("Error: Unsupported paramName Info type = %d ",paramNameobj);
			return (NULL);
                          
      }
      if(err != CL_SUCCESS)
	  {
        	switch (err) {
        		case CL_INVALID_MEM_OBJECT:
        			ec.throwDOMException(WebCLException::INVALID_MEM_OBJECT, "WebCLException::INVALID_MEM_OBJECT");
        			printf("Error: CL_INVALID_MEM_OBJECT  \n");
        			break;
        		case CL_INVALID_GL_OBJECT:
        			ec.throwDOMException(WebCLException::INVALID_GL_OBJECT, "WebCLException::INVALID_GL_OBJECT");
        			printf("Error: CL_INVALID_GL_OBJECT \n");
        			break;
        		case CL_INVALID_VALUE:
        			ec.throwDOMException(WebCLException::INVALID_VALUE, "WebCLException::INVALID_VALUE");
        			printf("Error: CL_INVALID_VALUE \n");
        			break;
       			case CL_OUT_OF_RESOURCES:
        			ec.throwDOMException(WebCLException::OUT_OF_RESOURCES, "WebCLException::OUT_OF_RESOURCES");
        			printf("Error: CL_OUT_OF_RESOURCES \n");
        			break;
        		case CL_OUT_OF_HOST_MEMORY:
        			ec.throwDOMException(WebCLException::OUT_OF_HOST_MEMORY, "WebCLException::OUT_OF_HOST_MEMORY");
        			printf("Error: CL_OUT_OF_HOST_MEMORY  \n");
        			break;
        		default:
        			ec.throwDOMException(WebCLException::FAILURE, "WebCLException::FAILURE");
        			printf("Invaild Error Type\n");
        			break;
        	}
	  }
	  
      return (NULL);
      //clGetGLObjectInfo (cl_mem memobj,cl_gl_object_type *gl_object_type,GLuint *gl_object_name)
      
      
}