Bug 102021

Summary: ir validation assert on valid GLSL
Product: Mesa Reporter: Dave Airlie <airlied>
Component: glsl-compilerAssignee: mesa-dev
Status: RESOLVED MOVED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: test to demonstrate error.
hacky attempt at fixing it.

Description Dave Airlie 2017-08-03 07:08:19 UTC
Created attachment 133219 [details]
test to demonstrate error.

I've written a cut down test that shows a problem virgl hits.

It triggers an assert in the validation that the ir->type and ir->operands[0]->type for an abs op are the same and they aren't.

  temp0[1].x = float(inversesqrt( abs(temp0[0]).x));
  temp0[1].y = float(inversesqrt( abs(temp0[0]).y));

is the construct that the compiler squashes incorrectly.

Not sure what pass is responsible for this yet.
Comment 1 Dave Airlie 2017-08-03 07:22:28 UTC
ah looks like do_vectorize

START GLSL optimization do_vectorize
(
(declare (location=0 shader_out ) vec4 gl_Position)
(declare (shader_in ) (array vec4 3) vertex)
(declare (shader_out ) vec4 temp)
(declare (temporary ) vec4 temp0_0)
(declare (temporary ) vec4 temp0_1)
( function main
  (signature void
    (parameters
    )
    (
      (assign  (xyzw) (var_ref temp0_0)  (array_ref (var_ref vertex) (constant int (0)) ) ) 
      (assign  (xy) (var_ref temp0_1)  (expression vec2 rsq (swiz xy (expression vec2 abs (var_ref temp0_0) ) )) ) 
      (assign  (xyzw) (var_ref gl_Position)  (array_ref (var_ref vertex) (constant int (0)) ) ) 
      (assign  (xyzw) (var_ref temp)  (var_ref temp0_1) ) 
      (emit-vertex (constant int (0)) )

    ))

)
Comment 2 Dave Airlie 2017-08-03 07:25:22 UTC
START GLSL optimization optimize_split_arrays
(
(declare (location=0 shader_out ) vec4 gl_Position)
(declare (shader_in ) (array vec4 3) vertex)
(declare (shader_out ) vec4 temp)
(declare (temporary ) vec4 temp0_0)
(declare (temporary ) vec4 temp0_1)
( function main
  (signature void
    (parameters
    )
    (
      (assign  (xyzw) (var_ref temp0_0)  (array_ref (var_ref vertex) (constant int (0)) ) ) 
      (assign  (x) (var_ref temp0_1)  (expression float rsq (swiz x (expression vec4 abs (var_ref temp0_0) ) )) ) 
      (assign  (y) (var_ref temp0_1)  (expression float rsq (swiz y (expression vec4 abs (var_ref temp0_0) ) )) ) 
      (assign  (xyzw) (var_ref gl_Position)  (array_ref (var_ref vertex) (constant int (0)) ) ) 
      (assign  (xyzw) (var_ref temp)  (var_ref temp0_1) ) 
      (emit-vertex (constant int (0)) )

    ))

previous IR before bad opt.
Comment 3 Dave Airlie 2017-08-03 07:38:41 UTC
Created attachment 133221 [details] [review]
hacky attempt at fixing it.
Comment 4 GitLab Migration User 2019-09-18 19:45:55 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/813.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.