Inconvenience: Errors upon unused shader uniforms

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
cmakris
Prole
Posts: 1
Joined: Sat Aug 25, 2018 4:18 pm

Inconvenience: Errors upon unused shader uniforms

Post 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
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Inconvenience: Errors upon unused shader uniforms

Post 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.
User avatar
pgimeno
Party member
Posts: 3673
Joined: Sun Oct 18, 2015 2:58 pm

Re: Inconvenience: Errors upon unused shader uniforms

Post by pgimeno »

I've pushed to stop that being an error, see viewtopic.php?p=207865#p207865

At least there is Shader:hasUniform now.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Inconvenience: Errors upon unused shader uniforms

Post 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.
User avatar
pgimeno
Party member
Posts: 3673
Joined: Sun Oct 18, 2015 2:58 pm

Re: Inconvenience: Errors upon unused shader uniforms

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests