简体   繁体   中英

How to let a vertex shader in OpenGL ES 2.0 perform GPGPU computing?

I'm doing a project using OpenCL and thought it can work on Mali 400 GPU. But I recently found that Mali 400 GPU only support OpenGL ES 2.0 standard.

I still have to use this GPU, So is there any way to let a shader act nearly the same as OpenCL kernel or CUDA kernel?

There are some main features I expect but not sure glsl will support:

  • For example, I created a global memory for GPU, and I want to read/write the global memory in shader, how should I pass the variable from host to vertex shader, can I expect that data be both 'in and out' like this?
layout (location = 0) inout vec3 a_Data;
  • I want to fetch a_Data as 64 float values, is there a easy way to declare it like vec64 or float[64] , or I have to use multiple vec4 to assemble it?

So is there any way to let a vertex shader act nearly the same as OpenCL kernel or CUDA kernel?

No.

In ES 2.0, vertex shaders have no mechanism to write to memory. At all. All of their output variables go to the rasterizer to generate fragments to be processed by the fragment shader.

The only way to do GPGPU processing on such hardware is to use the fragment shader to write data. That means you have to manipulate your data to look like a rendering operation. Your vertex positions needs to set up your fragment shader to be able to write values to the appropriate places. And your fragment shader needs to be able to acquire whatever information it needs based on what the VS provides (which is at a per-vertex granularity and interpolated for each fragment).

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