Reputation: 1946
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).
Upvotes: 2
Views: 1815
Reputation: 54642
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.
Upvotes: 3
Reputation: 1946
The shader compiles if the output image is declared write only:
layout (rgba8, binding = 0) uniform writeonly image2D img_output;
No idea why this is needed, does anyone have a link to the spec which discusses this?
Upvotes: 1