Post

Replies

Boosts

Views

Activity

Reply to Issue with the GLSL Compiler on M1 OpenGL driver?
Hi! If it's not too late, I think I figured out what all this means and it does appear to be real and not just some garbage being thrown by the M1 GPU. unit 2 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) This error is thrown whenever the shader does not know where to access texture data. Basically, you have to make two calls for things to work out correctly. you need to call glUniform1i(glGetUniformLocation(programID, "u_Textures[" + std::to_string(i) + "]"), slot), where that string is the name of the variable with some index i (u_Texture[i]), and the "slot" is one of the 16 locations where OpenGL can temporarily load textures to be accessed by the shader you need to call glActiveTexture(GL_TEXTURE0 + slot), where slot is the same slot as in step one. If the slots don't match, the above error will be thrown. Most of the time when I get this error it is because I somehow messed up the coordination of those two calls, because it can get a little messy sometimes. It can also be called if you didn't set up your texture correctly (maybe forgot to bind when you were setting up the filter and wrapper or something), but I have a feeling this was not the case here. What I think happened here has to do with the fact that you are declaring an array of textures and we are seeing "unit 2" as opposed to "unit 0." From what I have personally tested, the "unit" is not the same as the texture object id we get from openGL's glGenTextures(1, &textureID) nor the same as the "slot" from above. Instead, my hypothesis is that it is simply a stack created by openGL keeping track of the textures that have been bound. Assuming that is correct, the reason why your program works is that the 0th and 1st units are properly accessible to the shader but the 2nd one isn't. My assumption here is that at the time this error was thrown, you weren't actually using all 16 of the textures in that array and didn't set the uniform data for them either, instead just binding the first 2 slot uniforms. When the shader tried to load textures 2+, it failed and threw the above error once ("log once"). Even if that doesn't affect your shader code, the error will be thrown anyway when a draw function is called on the shader. If you are bothered by this, I have had similar issues in the past and it is apparently good enough to just set the empty sampler slots to a different, already used slot, even though that probably wouldn't work if you tried to use them for anything. Alternatively, you could create an empty texture and bind the unused textures to that.
Mar ’23