Skip to content

glsl: rework gl_ClipVertex / gl_CullDistance checks

The GLSL spec says it's an error if a shader statically writes to these 2 variables.

Until this commit, Mesa refused to link a shader if it had an unused function writing to one of these variables while another (used) function wrote to the other.

This commit changes Mesa's behavior and perform dead function elimination after the intra-stage linking step but before performing these checks.

I'm not sure a write from an unused function should be qualified as a static write to this variable but:

  • the amdgpu-pro driver tolerates this and doesn't emit an error
  • Mesa already does something similar: if the write to one of these var is considered dead code, it gets removed before the check and doesn't cause an error

This fixes one application.

(piglit MR: piglit!585)

Merge request reports