OpenGL shader introspection/interface queries for images I've been looking at Interface queries in order to prevent common mistakes that are time consuming to debug, such as forgetting to bind a buffer, binding the wrong resource type, etc.
However, I wasn't able to find what I wanted for images. I'd like to make sure that the type of the texture, the memory qualifier and the texture format are the same in the c++ code and in the shader :
glBindImageTexture(index, texture, 0, true, 0, GL_READ_ONLY, GL_RGBA32F);

layout(binding = 0, rgba32f) uniform writeonly iimage2D _heightmap;

Using glGetProgramResourceiv with GL_UNIFORM and GL_TYPE, I was able to get the type of the image, iimage2D. But nothing for the memory qualifier and the image format.
Is there a way to do that, other than parsing the shader?
Those are not accessible via introspection. It should also be pointed out that some of them don't have to &quot;match&quot;.
The shader-defined format doesn't have to be the same as the image-bound format. The image-bound format defines how writing from the image interprets the data provided by the shader. The shader-defined format determines how reading from the image interprets the data in the image. So the two values are fundamentally doing different things and need not match either each other or the texture's internal format. There are rules for how conversion works between these and the image's actual format.
For the access type, you could just pass GL_READ_WRITE for everything and let the shader decide how it's going to access the storage. Given that Vulkan has no equivalent to this value, it probably doesn't matter performance-wise. Also, note that the multibind function glBindImageTextures, which binds multiple images in one call, always uses GL_READ_WRITE (and doesn't have a specified format). Since the whole point of that function is performance, it almost certainly doesn't matter if you always use read-write from the binding side.