I found that my fragment or compute shader cannot imageStore anything to the multi-channel image texture initialized in this way.
Method A:
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, imgWidth, imgHeight, 0, GL_RGBA, GL_FLOAT, NULL);
I got an all zero buffer when I read back using glGetTextureImage.
However, when I changed the initialization to this:
Method B:
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, imgWidth, imgHeight);
The problem was fixed.
(For both, I bind the texture to the image unit by
glBindImageTexture(1, tex, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
)
The weird thing is that method A works when I use single channel texture (e.g. GL32F).
Is that incorrect use of API or is it the driver’s problem?
Thanks.