简体   繁体   中英

Using OpenCL buffer To draw texture in OpenGL 2.0 ES

I am working with ARM mali 72 on my Android smartphonne.

I would like to use the output buffer fron OpenCL to render it into OpenGL like a texture.

I have no problem with openCL alone.nether openGL alone.

I got no cloud to how to use both in the same application.

The goal is to use mY output OpenCL and send it to openGL.

Some peice of code step by step would be very nice.

I can use openCL 2.0 and opengl ES 3.0 on my smartphonne.

************** ADDED THE 30/09/2020 ************

It Look like I need more information on how to manage my problem.

So my configuration is. I got Java OpenGL ES Application to already develloped. I retreive the camera frame from Camera.OnPreviousFrame then a send it to OpenCL using JNI.

So i would like to Get the EGL display from Java OpenGL ES Send it through JNI and then Compute my openCL kernel send It back to java OpenGL ES.

I know how to retreive data from OpenCL, transform it to bitmap and use SurfaceTexture and GL_TEXTURE_EXTERNAL_OES to display it into openGL ES.

My problem is how to Retreive EGL display from java OpenGL ES. How to send it to C++, this i can manage to find out using JNI. But i do not know how to implement the C++ part using EGL and OpenCL.

The Answer from BenMark is interresting concerning the processing but I am missing some part. It is possible to use my configuration, using java openGL ES or do i nedd to do all the EGL, openGL, openCL code in native?

Thanks a lot for help me to anderstand the problem and try to find a solution. ;))

I haven't code a code example but -

Using the EGL API makes interoperability between the GLES and OpenCL APIs easier.

This page provides some tips: https://developer.arm.com/documentation/101574/0400/Using-OpenCL-extensions/Inter-operation-with-EGL/EGL-images

From that page, amongst other things:

  • You'll want the EGL_KHR_image_base extension to share EGL images.
  • In OpenCL you'll want cl_khr_egl_image to use the EGL image, and then you must flush in OpenCL with clFinish or clWaitForEvents to be sure that the image is then ready for use by OpenGL ES.
  • The start and end of the EGL image accesses by OpenCL applications must be signaled by enqueuing clEnqueueAcquireEGLObjectsKHR and clEnqueueReleaseEGLObjectsKHR commands.

I hope that helps get you going.

It was a long anderstanding problem;))

So the solution are:

It is not possible to Share Context from other thread. So JAVA/OpenCL C++ cannot share data. So depending on GLSL version they is different possibility.

GLES 2.0: need to rewrite SurfaceTexture.cpp to acces (EGL IMAGE) surface form C++ and i even do not know if it is possible due to context nono thread. so Forget it at the moment;)). But you can still use camera onPrevious to get Data, then send it through JNI to C++ OpenCL, that is what i am doing a this time. Then send back the OpenCL output to the Display View and cath it using Canvas and GL_TEXTURE_EXTERNAL_OES. It works but it is eavy. ;)) And you cannot get nothing from GLSL texture back to C++.

GLSL 3.1: Use Compute shader rather than OpenCL in JAVA. ;)) Have a look at What is the difference between OpenCL and OpenGL's compute shader?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM