I am trying to home in on an error in my shader by commented out code, but as I do this the unused shader variables are then not found by my glUniform location variables, and this makes it difficult to proceed.
Is there a way to turn off this shader optimization for debugging? I was hoping #pragma optimize(off) would do it, but I am still getting the same issue…
but as I do this the unused shader variables are then not found by my glUniform location variables, and this makes it difficult to proceed.
Calling glUniform with -1 (the value returned from glGetUniformLocation if the uniform does not exist) is not considered an error. The command will execute and do nothing.
So there’s really no problem. Unless you have code detecting a -1 and creating an error based on that.
Or you can use a condition which is always true or false, but which can be optimized directly by the compiler.
Unless the compiler recompiles the code when you set a uniform (and apparently, they don’t do that anymore), there is no way for the compiler to know whether the branch will be taken or not. So nothing will be “optimized directly by the compiler.”
Unless the compiler recompiles the code when you set a uniform (and apparently, they don’t do that anymore), there is no way for the compiler to know whether the branch will be taken or not. So nothing will be “optimized directly by the compiler.”
Good point. I do, indeed throw an exception here, which is the problem. I could just log an error instead. The trouble here is that I ?probably? then need to track down all my glUniform calls setting these variables? I haven’t tried to see what happens if I try to set a variable at location -1, but I am (perhaps wrongly) assuming it isn’t good!
In fact, my driver does not seem to care about setting variables at location -1 (at least it continues onward), so just logging the ‘not found’ error rather than throwing out seems to be a reasonable compromise!