1

I use the GL_OES_EGL_image_external_essl3 extension to access camera pictures in GLSL. For fragment shaders it works fine. Here is my simple fragment shader:

#version 320 es
#extension GL_OES_EGL_image_external_essl3 : require

precision mediump float;

uniform samplerExternalOES cameraTexture;

in vec2 v_TexCoordinate;
out vec4 fragmentColor;

void main() {
    fragmentColor = texture(cameraTexture, v_TexCoordinate);
}

I can see the picture from the camera.

However when I insert a simple compute shader stage in pipeline that only copies data from that external image to a new texture which I display, I can see only black screen. I also generate a red line in the compute shader for debugging.

Here is the code of that compute shader:

#version 320 es
#extension GL_OES_EGL_image_external_essl3 : require

precision mediump float;

layout(local_size_x = LOCAL_SIZE, local_size_y = LOCAL_SIZE) in;
layout(binding=1, rgba8) uniform mediump writeonly image2D outputImage;

uniform samplerExternalOES cameraTexture;

void main() {
    ivec2 position = ivec2(gl_GlobalInvocationID.xy);

    vec4 cameraColor = texture(cameraTexture, vec2(gl_GlobalInvocationID.xy)/1024.);
    imageStore(outputImage, position, cameraColor);

    // generate a red line to see that in general the texture
    // that is produced by the compute shader is displayed on the
    // screen
    if (position.x == 100) imageStore(outputImage, position, vec4(1,0,0,1));
}

So it seems like it accesses the texture in the same way, but vec(0,0,0,1) is returned by texture() instead. So the screen is black.

In both cases I bind the texture like this:

glActiveTexture(GL_TEXTURE0)
glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mCameraTextureId)
glUniform1i(cameraUniformHandle, 0)

Why does this extension not work properly in my compute shader? Is it supposed to work in compute shaders at all?

My platform is Samsung Galaxy S7 (Mali GPU).

Alexander Ponomarev
  • 2,598
  • 3
  • 24
  • 31

0 Answers0