I have a problem regarding storageImages in compute shaders on android devices. The following compute shader should produce an image where r/g magnitudes vary linear with respect to x/y coordinate. The dispatch dimensions are 8x8. The code works fine on most devices, but on a number of devices it produces wrong output. It looks as if the imageStores write to the wrong location within the image. The first 10 pixels in the first row are:
[0, 0, 0, 255]
[4, 0, 0, 255]
[8, 0, 0, 255]
[12, 0, 0, 255]
[64, 0, 0, 255]
[68, 0, 0, 255]
[72, 0, 0, 255]
[76, 0, 0, 255]
[0, 0, 0, 255]
[4, 0, 0, 255],
instead of the expected output:
[0, 0, 0, 255]
[4, 0, 0, 255]
[8, 0, 0, 255]
[12, 0, 0, 255]
[16, 0, 0, 255]
[20, 0, 0, 255]
[24, 0, 0, 255]
[28, 0, 0, 255]
[32, 0, 0, 255]
[36, 0, 0, 255]
the shader
#version 450
layout (binding=0, rgba8) uniform writeonly image2D myStorageImage;
layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
void main()
{
ivec2 index = ivec2(gl_GlobalInvocationID.xy);
vec3 IDColor = vec3(index, 0.0) / (gl_NumWorkGroups * gl_WorkGroupSize);
imageStore(myStorageImage, index, vec4(IDColor, 1.0));
}
One device on which the result is incorrect:
Nexus 5X
GPU – Adreno ™ 418
Vulkan API Version – 1.0.38
Android Version – 8.0.0
One device on which the shader works just fine:
Pixel
GPU – Adreno ™ 530
Vulkan API Version – 1.1.66
Android Version – 9
my problem
I do not know where the source of this difference between devices lies and I need to be able to handle it somehow in my application.