简体   繁体   English

在 OpenGL 2.0 ES 中使用 OpenCL 缓冲区绘制纹理

[英]Using OpenCL buffer To draw texture in OpenGL 2.0 ES

I am working with ARM mali 72 on my Android smartphonne.我在我的 Android 智能手机上使用 ARM mali 72。

I would like to use the output buffer fron OpenCL to render it into OpenGL like a texture.我想使用来自 OpenCL 的 output 缓冲区将其渲染为 OpenGL,就像纹理一样。

I have no problem with openCL alone.nether openGL alone.我单独使用openCL没问题。单独使用nether openGL。

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.目标是使用我的 output OpenCL 并将其发送到 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.我可以在我的智能手机上使用 openCL 2.0 和 opengl ES 3.0。

************** ADDED THE 30/09/2020 ************ ************** 添加于 2020 年 9 月 30 日 ************

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.我已经开发了 Java OpenGL ES 应用程序。 I retreive the camera frame from Camera.OnPreviousFrame then a send it to OpenCL using JNI.我从 Camera.OnPreviousFrame 中检索相机帧,然后使用 JNI 将其发送到 OpenCL。

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.所以我想从 Java OpenGL ES 获取 EGL 显示通过 JNI 发送它然后计算我的 openCL kernel 将它发送回 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.我知道如何从 OpenCL 中检索数据,将其转换为 bitmap 并使用 SurfaceTexture 和 GL_TEXTURE_EXTERNAL_OES 将其显示为 openGL ES。

My problem is how to Retreive EGL display from java OpenGL ES.我的问题是如何从 java OpenGL ES 中检索 EGL 显示。 How to send it to C++, this i can manage to find out using JNI.如何将它发送到 C++,我可以设法使用 JNI 找到它。 But i do not know how to implement the C++ part using EGL and OpenCL.但我不知道如何使用 EGL 和 OpenCL 实现 C++ 部分。

The Answer from BenMark is interresting concerning the processing but I am missing some part. BenMark 的回答对处理过程很感兴趣,但我遗漏了一些部分。 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?可以使用我的配置,使用 java openGL ES 还是我需要做所有的 EGL,openGL,原生的 openCL 代码?

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.使用EGL API 可以更轻松地实现 GLES 和 OpenCL API 之间的互操作性。

This page provides some tips: https://developer.arm.com/documentation/101574/0400/Using-OpenCL-extensions/Inter-operation-with-EGL/EGL-images此页面提供了一些提示: 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.您需要 EGL_KHR_image_base 扩展来共享 EGL 图像。
  • 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.在 OpenCL 中,您需要 cl_khr_egl_image 使用 EGL 图像,然后您必须使用 clFinish 或 clWaitForEvents 在 OpenCL 中进行刷新,以确保图像随后可供 OpenGL ES 使用。
  • The start and end of the EGL image accesses by OpenCL applications must be signaled by enqueuing clEnqueueAcquireEGLObjectsKHR and clEnqueueReleaseEGLObjectsKHR commands. OpenCL 应用程序访问 EGL 图像的开始和结束必须通过排队 clEnqueueAcquireEGLObjectsKHR 和 clEnqueueReleaseEGLObjectsKHR 命令来发出信号。

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.所以JAVA/OpenCL C++无法共享数据。 So depending on GLSL version they is different possibility.因此,根据 GLSL 版本,它们有不同的可能性。

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. GLES 2.0:需要重写 SurfaceTexture.cpp 以访问 (EGL IMAGE) 表面形式 C++,我什至不知道是否可能由于上下文 nono 线程。 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.但是您仍然可以使用相机 onPrevious 获取数据,然后通过 JNI 将其发送到 C++ OpenCL,这就是我这次所做的。 Then send back the OpenCL output to the Display View and cath it using Canvas and GL_TEXTURE_EXTERNAL_OES.然后将 OpenCL output 发送回显示视图,并使用 Canvas 和 GL_TEXTURE_EXTERNAL_OES 对其进行传输。 It works but it is eavy.它有效,但很麻烦。 ;)) And you cannot get nothing from GLSL texture back to C++. ;)) 而且你无法从 GLSL 纹理返回到 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? GLSL 3.1:在 JAVA 中使用计算着色器而不是 OpenCL。;))看看OpenCL 和 OpenGL 的计算着色器有什么区别?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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