I would like to declare a function which reads from an image2D and modifies the output.
My shader is written like so:
...
layout(binding = 1, rg32f) uniform readonly image2D uVelocity;
vec2 loadVelocity(image2D velocity, ivec2 index) {
...
}
void main() {
...
vec2 v = loadVelocity(uVelocity, coord);
...
}
When I try to compile this shader to SPIRV, I get the following errors:
'readonly' : argument cannot drop memory qualifier when passed to formal parameter
'format' : image formats must match
So it seems that the function declaration is not specific enough to allow this image to be used.
I have tried adding readonly
to the function arg declaration, and this silences the first error, but how can I declare the format?