1

I want to read and write from an image that stores unsigned integers. How can I read and write? The standard way to read and write to an image is using imageLoad/imageStore, but when using the format qualifier r32ui, the compiler errors with no matching overloaded function found.

This fails to compile:

#version 450

layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 0, r32ui) uniform writeonly uimage3D img;

void main() {
    imageStore(img, ivec3(1,2,3), uint(4));
}

This compiles fine:

#version 450

layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 0, rgba8ui) uniform writeonly uimage3D img;

void main() {
    imageStore(img, ivec3(1,2,3), uvec4(4,5,6,7));
}

I have tried using uvec3 for coordinates instead of ivec3, and uvec4 for the data to write in case I am misunderstanding what the format is storing. Using 2 dimensional images also made no difference.

Zobia Kanwal
  • 4,085
  • 4
  • 15
  • 38
terepy
  • 79
  • 5

1 Answers1

2

The error message you get is correct, there simply is no overloaded version of imageStore that takes a single unsigned integer (see specs).

So when using the r32ui qualifier, you still need to pass a 4-component unsigned vector just like in your second example, but instead construct it from a single value:

void main() 
{
    imageStore(img, ivec3(1,2,3), uvec4(4));
}
Sascha Willems
  • 5,280
  • 1
  • 14
  • 21