Hi there,
I'm trying to implement different image processing algorithms like grayscaling, filtering, quantizing etc. on Android smartphones. I've got the camera preview rendered to a quadas an external texture, it works fine with grayscaling in fragment shader. But when I try to do the same in OpenGL ES 3.1 with compute shaders, I get invalid operation error,when calling glBindImageTexture(...) before dispatch compute. According to https://www.khronos.org/registry/gles/extensions/OES/OES_EGL_image_external_essl3.txt
if I bind an external texture like GL_TEXTURE_EXTERNAL_OES and bind it with glBindImageTexture, I should be able to access the image via image2D sampler in GLSL.What am I doing wrong?
Eventually I managed to figure it out. First render the external texture to a normal GL_TEXTURE_2D using a frame buffer (to set up a frame buffer, check this out: http://stackoverflow.com/questions/29003414/render-camera-preview-on-a-texture-with-target-gl-texture-2d). Then you can bind the normal (immutable) texture to the compute shader, just be aware if the bindings (because GL_TEXTURE0 is occupied by the external, the input and the output texture bindings of the compute shader is 1 and 2 respectively). Then do the image processing by reading from GL_TEXTURE1 to GL_TEXTURE2 (both are created as immutable, and the first one is which was bound to the frame buffer to render the external texture into it), then finally use the 3rd texture (GL_TEXTURE2) to display the results on the screen.
Glad you got it working - it's a shame you needed a copy the external surface to an internal surface though - half defeats the point of zero copy external imports. I'll keep digging to see if I can find a way of avoiding that ...
Cheers, Pete