Page 1 of 1

Inconvenience: Errors upon unused shader uniforms

Posted: Sat Aug 25, 2018 4:36 pm
by cmakris
Hey Love2D Team. I LOVE Love2D, first of all, and want to convey my gratitude to those who design and maintain it!

My issue has to do with errors thrown upon Love2D discovering unused shader uniforms. It occurs in cases where either the uniform is defined (and updated from the main program) and not used anywhere in the shader body, but also when it IS used in the shader body, only not contributing to the final output. The uniform data must contribute to the output or else Love2D throws the error. I've repeatedly found this to be frustrating as it is common to explore various ideas while writing shaders, sometimes requiring temporary commenting-out of variables, lines of code, etc. Is there a reason the shader system has been designed this way? Could this behavior be removed for future releases? Or perhaps made into an option configurable in conf.lua?

Chris

Re: Inconvenience: Errors upon unused shader uniforms

Posted: Sat Aug 25, 2018 5:33 pm
by grump
It's not a matter of what LÖVE does. Is a matter of how shader programs are specified. Unused uniforms means a shader is invalid with regard to that specification.

What exactly do you think should happen when you try to use an invalid shader?
You can catch errors using pcall if you need a certain behavior when an error occurs, no matter the context.

Re: Inconvenience: Errors upon unused shader uniforms

Posted: Sun Aug 26, 2018 2:20 am
by pgimeno
I've pushed to stop that being an error, see viewtopic.php?p=207865#p207865

At least there is Shader:hasUniform now.

Re: Inconvenience: Errors upon unused shader uniforms

Posted: Sun Aug 26, 2018 8:17 am
by bartbes
The graphics driver does this optimisation, without love being able to affect it, so the uniforms are gone either way. So now the option is to either ignore all uniform errors, or error for all of them, and love chooses the safest option.

Re: Inconvenience: Errors upon unused shader uniforms

Posted: Sun Aug 26, 2018 11:58 am
by pgimeno
bartbes wrote: Sun Aug 26, 2018 8:17 am The graphics driver does this optimisation, without love being able to affect it, so the uniforms are gone either way. So now the option is to either ignore all uniform errors, or error for all of them, and love chooses the safest option.
Safest in what sense? Such an error can remain undetected (if the developer's graphics driver does not optimize away the uniform) until the game is released, and crash on the players' computers. Which was my point all the time.

It's a bit like saying that the safest way to release a program is with assertions enabled.