[Mesa-dev] [PATCH 2/2] linker: Eliminate more dead code after demoting shader inputs and outputs
Kenneth Graunke
kenneth at whitecape.org
Fri Oct 21 12:05:51 PDT 2011
On 10/21/2011 11:49 AM, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Consider the following vertex shader and fragment shader:
>
> // vertex shader
> varying vec4 v;
> uniform vec4 u;
>
> void main() { gl_Position = vec4(0.0); v = u; }
>
> // fragment shader
> void main() { gl_FragColor = vec4(0.0); }
>
> Since the fragment shader does not use 'v', it is demoted from a
> varying to a simple global variable. Once that happens, the
> assignment to 'v' is useless, and it should be removed. In addition,
> 'u' is no longer active, and it should also be removed.
>
> Performing extra dead code elimination after demoting shader inputs
> and outputs takes care of this. This elimination must occur before
> assigning uniform locations, or the declaration of 'u' cannot be
> removed.
>
> This change *breaks* the piglit test getuniform-01, but that test is
> already incorrect. The test uses a vertex shader that assigns to a
> user-defined varying, but it has no fragment shader. Since Mesa does
> not support ARB_separate_shader_objects (we only support the EXT
> version), the linker correctly eliminates the user-defined varying.
> The cascading effect is that the uniform queried by the C code of the
> test is also (correctly) eliminated.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41980
> Cc: Brian Paul <brianp at vmware.com>
> Cc: Bryan Cain <bryancain3 at gmail.com>
> Cc: Vinson Lee <vlee at vmware.com>
> Cc: José Fonseca <jfonseca at vmware.com>
For this patch (2/2):
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
More information about the mesa-dev
mailing list