1
$\begingroup$

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?

$\endgroup$
2
  • 1
    $\begingroup$ did you try adding layout(rg32f) to the function argument? There has been bugs around passing images as parameters and the spec (still?) contradicts itself. So the full prototype would be something like vec2 loadVelocity( readonly layout(rg32f) image2D velocity... $\endgroup$
    – pmw1234
    Jun 19, 2022 at 18:26
  • $\begingroup$ If I try this, I get the following error: cannot use layout qualifiers on a function parameter $\endgroup$
    – sak
    Jun 22, 2022 at 6:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.