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:
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 - 8.1.1.1634
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 - 7.12.0.7728
Vulkan™ Driver Version - 2.0.49
Vulkan™ API Version - 1.1.77
Hello,
Yes, I am able to see the same problem as you reported using your test application. We will start investigating the problem and keep you updated. Thanks!
Hello @einzuweitesfeld, in your test application render(), you 're going to the bind the texture BeschattungsBild to GL_TEXTURE_2D on the texture unit 5, which will overwrite the previous binding for BMP_Texture2, refer to the line 4 and 5 below. Let me know if any question, thanks.
- glActiveTexture(GL_TEXTURE0 + 4);
- glBindTexture(GL_TEXTURE_2D, BMP_Textur);
- glActiveTexture(GL_TEXTURE0 + 5);
- glBindTexture(GL_TEXTURE_2D, BMP_Textur2);
- glBindTexture(GL_TEXTURE_2D, BeschattungsBild); // this will overwrite the BMP_Texture2 as you activated the texture unit 5
- glBindImageTexture(5, BeschattungsBild, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_R8UI);
Sorry for the late reply. I'm a bit embarrassed by my stupid mistake but that isn't the reason for the delay.