I am writing a compute shader, that should run on PC and Android. It works fine on PC, but it does not compile on Android.
This is the shader:
#version 310 es
uniform vec2 lightPos; // passed from the app
layout (local_size_x = 512, local_size_y = 1) in;
layout (rgba8, binding = 0) uniform image2D img_output;
layout (rgba8, binding = 1) uniform readonly image2D colorTex;
layout (rgba8, binding = 2) uniform readonly image2D transpTex;
void main () {
imageStore(img_output, ivec2(3, 6), vec4(0.3 ,0.2 ,0.5 ,0.9));
}
And the error is:
Shader compile error: ERROR: '' : unsupported format on read/write image
If I change the last parameter to ivec4
or uvec4
I get:
ERROR: 'imageStore' : no matching overloaded function found
GL.GetString(StringName.Version);
returns
GL version:OpenGL ES 3.1 [email protected] (GIT@I0bc8e21cf2)
This is on a Sony Xperia Z5 (Android emulator does not seem to support OpenGL ES 3.1).
This is specified in the GLSL ES 3.10 spec, on page 72 in section "4.9 Memory Access Qualifiers":
Except for image variables qualified with the format qualifiers r32f, r32i, and r32ui, image variables must specify either memory qualifier readonly or the memory qualifier writeonly.
This restriction still applies in GLSL ES 3.20.