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?
In case someone like me ends up here with a similar or related problem, the issue for me was accessing external texture in compute shader as follows
glBindImageTexture(texture_loc, texture_id, 0, false, 0, GL_READ_ONLY, format); -------------------------------------------------------------- layout(rgba8, binding = 0) uniform readonly image2D inTexture; ... vec4 texColor = imageLoad(inTexture, storePos).rgba;
Instead of this you should access and use them as we do in vertex/fragment shaders as follows
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id); glUniform1i(texture_loc, 0); -------------------------------------------------------------- uniform samplerExternalOES sTexture ... vec4 cameraColor = texture(sTexture, vec2(float(gl_GlobalInvocationID.x)/width,float(gl_GlobalInvocationID.y)/height));
I'm working on a similar issue. Thanks all of you, now everything is almost clear to me. Just 1 thing I'm wondering... Could we output yuv format texture in the compute shader? Of course samplerExternalOES sTexture can't help in this case, so we might have to use image load/store (i.e, image2D...). However, the texture must be immutable and it seems that there is no yuv layout qualifier.
Thus, this seems to be impossible, but I've read the issue 10 on this link
https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external_essl3.txt
and it said that image load/store may be supported.
Could anyone explain this?