OSDN Git Service

glsl: give all unnamed structs the same name
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 12 May 2017 10:22:45 +0000 (12:22 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 13 Jun 2017 07:35:36 +0000 (09:35 +0200)
commit77ea2ada5ae4b72c43598f3faa518526cb36b822
tree8cbd9adb01421c2fa5bd1d77db740a5d276c9035
parent597b2486b8d1bce7b373bcace37866a83faa3e7a
glsl: give all unnamed structs the same name

As a result, unnamed structs defined in different places of the program
are considered the same types if they have the same fields in the same
order.

This will simplify matching of global variables whose type is an unnamed
struct.

It also fixes a memory leak when the same shader containing unnamed
structs is compiled over and over again: instead of creating a new type
each time, the existing type is re-used.

Finally, this does have the effect that some previously rejected programs
are now accepted, such as:

   struct {
      float a;
   } s1;

   struct {
      float a;
   } s2;

   s2 = s1;

C/C++ do not allow that, but GLSL does seem to want to treat unnamed
structs with the same fields as the same type at least during linking
(and apparently, some applications require it), so it seems odd to treat
them as different types elsewhere.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/glsl_parser_extras.cpp