[Mesa-dev] [PATCH 00/19] glsl: Support redeclaration of gl_PerVertex interface blck.

Paul Berry stereotype441 at gmail.com
Wed Oct 2 17:45:13 PDT 2013


This patch series adds the necessary machinery to the GLSL compiler to
allow shaders to redeclare the gl_PerVertex interface block.  Although
the precise rules for how to redeclare gl_PerVertex were not published
until GLSL 4.10, it seems clear from context that this was intended as
a clarification rather than a change in behaviour, so it makes sense
to implement the rules now.  Also, redeclaration of gl_PerVertex is
required in order to get some corner cases of gl_ClipDistance working
with geometry shaders.

This patch series represents the last of the "scary" geometry shader
tasks.  Everything that's left after this is bug fixing and a lot more
testing.  Once this series lands, I plan to turn on geometry shader
support for i965 so people can start trying it out.

Patches 1-2 make some minor corrections to previous work I've done.
Patches 3-4 create the built-in gl_PerVertex output block (previously
we only created gl_PerVertex for geometry shader inputs).  Patch 5
fixes the interface block comparison code to properly account for the
location field (without this, there would be subtle bugs in later
patches).

Patches 6-11 implement the rules for what's allowed to be declared in
an interface block and what's not, including fixing a bunch of
loopholes where we allowed identifiers starting with "gl_" where we
shouldn't.

Patches 12-15 set up the groundwork for allowing gl_PerVertex to be
redeclared.  Patch 16 adds the ability to redeclare the gl_PerVertex
output interface block.  Patch 17 closes a loophole in detecting
compile-time errors.  Patch 18 adds the ability to redeclare the
gl_PerVertex input interface block.

Finally, patch 19 implements the rule that gl_PerVertex is not allowed
to be redeclared after a shader has used it.

Note: I recently published a piglit series containing the tests that I
used to validate this series.  A few minor corner cases still don't
pass yet:

- gs-redeclares-pervertex-out-after-global-redeclaration.geom
- gs-redeclares-pervertex-out-after-other-global-redeclaration.geom
- gs-redeclares-pervertex-out-before-global-redeclaration.geom
- vs-redeclares-pervertex-out-after-global-redeclaration.vert
- vs-redeclares-pervertex-out-after-other-global-redeclaration.vert
- vs-redeclares-pervertex-out-before-global-redeclaration.vert
- interstage-pervertex-redeclaration-unneeded
- intrastage-pervertex-in-redeclaration-unneeded
- intrastage-pervertex-out-redeclaration-unneeded

I plan to address these corner cases in forthcoming patches once this
series lands.

This series depends on two other patch series that have not yet landed:

- the series starting with "glsl: Keep track of location for interface
  block fields." (partially reviewed by Ian)

- the series called "glsl: Support unsized arrays in interface
  blocks." (not yet reviewed)

To see the series in its proper context, check out branch "gs-phase-5"
of https://github.com/stereotype441/mesa.git.

[PATCH 01/19] glsl: Construct gl_in with a location of -1.
[PATCH 02/19] glsl: Fix block name of built-in gl_PerVertex interface block.
[PATCH 03/19] glsl: Refactor code for creating gl_PerVertex interface block.
[PATCH 04/19] glsl: Construct gl_PerVertex interfaces for GS and VS outputs.
[PATCH 05/19] glsl: Account for location field when comparing interface blocks.
[PATCH 06/19] glsl: Refactor code to check that identifier names are valid.
[PATCH 07/19] glsl: Don't allow unnamed interface blocks to redeclare variables.
[PATCH 08/19] glsl: Don't allow invalid identifiers as interface block names.
[PATCH 09/19] glsl: Don't allow invalid identifier names in struct/interface fields.
[PATCH 10/19] glsl: Don't allow invalid identifiers as interface block instance names.
[PATCH 11/19] glsl: Don't allow invalid identifiers as struct names.
[PATCH 12/19] glsl: Generalize processing of variable redeclarations.
[PATCH 13/19] glsl: Add an ir_variable::reinit_interface_type() function.
[PATCH 14/19] glsl: Make it possible to remove a variable from the symbol table.
[PATCH 15/19] glsl: Error check redeclarations of gl_PerVertex.
[PATCH 16/19] glsl: Support redeclaration of VS and GS gl_PerVertex output.
[PATCH 17/19] glsl: Catch redeclaration of interface block instance names at compile time.
[PATCH 18/19] glsl: Support redeclaration of GS gl_PerVertex input.
[PATCH 19/19] glsl: Don't allow gl_PerVertex to be redeclared after it's been used.


More information about the mesa-dev mailing list