I have an OpenGL program + a Compute Shader which cause inconsistent behaviour in conjunction with texture access from inside the CS.
I have two textures which are activated and bound with
glActiveTexture(GL_TEXTURE0 + 4); glBindTexture(GL_TEXTURE_2D, BMP_Textur); glActiveTexture(GL_TEXTURE0 + 5); glBindTexture(GL_TEXTURE_2D, BMP_Textur2);
however only the firstly activated/bound texture works in the Compute Shader. Retrieving data from the second texture
uniform usampler2D schtTextur2; uvec4 ts1 = texture( schtTextur2, vec2(GIpos.xy/fsr) );
yields always zero as a result. Switching around the textures or the binding points doesn't matter. Only the first texture works, all successive ones don't.
However, binding the textures with
glBindTextureUnit(4, BMP_Textur); glBindTextureUnit(5, BMP_Textur2);
does the job and works as expected. I don't think that can be correct and must be a bug of the graphics driver.
I have attached a small demonstration program which reproduces the error. I start it with Visual Studio C++ 2015. However, the critical code is very short and located in the following files:
- Quelle1.cpp -- which contains all the loader code and the critical pieces at the very bottom
- Shaders/ComputeShader.comp -- which is a very brief and self-explanatory CS source file
If you manage to run it, then press F3 to get a printout to console for the return value of texture() from inside the CS. There, you can change the ImageStore() argument from ts1 to ts0 to see what the first texture returns.
In the main program you can try to bind the textures with the above mentioned functions glBindTextureUnit() in line 739 and 740 rather than glActiveTexture() annd glBindTexture() to see the difference.
My GPU is a RX480 and my driver version is:
Radeon Settings Version - 2018.0911.1425.25970
Driver Packaging Version - 18.30.17.01-180911a-333150E-RadeonSoftwareAdrenalin
Provider - Advanced Micro Devices, Inc.
2D Driver Version - 22.214.171.1244
Direct3D® Version - 9.14.10.01359
OpenGL® Version - 24.20.11000.13539
OpenCL™ Version - 24.20.13017.1009
AMD Mantle Version - Not Available
AMD Mantle API Version - Not Available
AMD Audio Driver Version - 126.96.36.19928
Vulkan™ Driver Version - 2.0.49
Vulkan™ API Version - 1.1.77