[Mesa-dev] glsl/linker: attempt to match anonymous structures at link

Submitted by Dave Airlie on May 17, 2016, 12:33 a.m.

Details

Message ID 1463445223-5102-1-git-send-email-airlied@gmail.com
State Accepted
Series "glsl/linker: attempt to match anonymous structures at link"
Commit 61b67892522c89800541ed4f266ab88e5f1db620
Headers show

Commit Message

Dave Airlie May 17, 2016, 12:33 a.m.
From: Dave Airlie <airlied@redhat.com>

This is my attempt at fixing at least one of the UE4 bugs with GL4.3.

If we are doing intrastage matching and hit anonymous structs, then
we should do a record comparison instead of using the names.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 src/compiler/glsl/link_varyings.cpp | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 003b9d4..9ae5791 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -226,15 +226,21 @@  cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
        *     fragment language."
        */
       if (!output->type->is_array() || !is_gl_identifier(output->name)) {
-         linker_error(prog,
-                      "%s shader output `%s' declared as type `%s', "
-                      "but %s shader input declared as type `%s'\n",
-                      _mesa_shader_stage_to_string(producer_stage),
-                      output->name,
-                      output->type->name,
-                      _mesa_shader_stage_to_string(consumer_stage),
-                      input->type->name);
-         return;
+         bool anon_matches = output->type->is_anonymous() &&
+            type_to_match->is_anonymous() &&
+            type_to_match->record_compare(output->type);
+
+         if (!anon_matches) {
+            linker_error(prog,
+                         "%s shader output `%s' declared as type `%s', "
+                         "but %s shader input declared as type `%s'\n",
+                         _mesa_shader_stage_to_string(producer_stage),
+                         output->name,
+                         output->type->name,
+                         _mesa_shader_stage_to_string(consumer_stage),
+                         input->type->name);
+            return;
+         }
       }
    }
 

Comments

Ian Romanick May 18, 2016, 9:43 p.m.
This patch is

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>

On 05/16/2016 05:33 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This is my attempt at fixing at least one of the UE4 bugs with GL4.3.
> 
> If we are doing intrastage matching and hit anonymous structs, then
> we should do a record comparison instead of using the names.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  src/compiler/glsl/link_varyings.cpp | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
> index 003b9d4..9ae5791 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -226,15 +226,21 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
>         *     fragment language."
>         */
>        if (!output->type->is_array() || !is_gl_identifier(output->name)) {
> -         linker_error(prog,
> -                      "%s shader output `%s' declared as type `%s', "
> -                      "but %s shader input declared as type `%s'\n",
> -                      _mesa_shader_stage_to_string(producer_stage),
> -                      output->name,
> -                      output->type->name,
> -                      _mesa_shader_stage_to_string(consumer_stage),
> -                      input->type->name);
> -         return;
> +         bool anon_matches = output->type->is_anonymous() &&
> +            type_to_match->is_anonymous() &&
> +            type_to_match->record_compare(output->type);
> +
> +         if (!anon_matches) {
> +            linker_error(prog,
> +                         "%s shader output `%s' declared as type `%s', "
> +                         "but %s shader input declared as type `%s'\n",
> +                         _mesa_shader_stage_to_string(producer_stage),
> +                         output->name,
> +                         output->type->name,
> +                         _mesa_shader_stage_to_string(consumer_stage),
> +                         input->type->name);
> +            return;
> +         }
>        }
>     }
>  
>