[Mesa-dev] [Bug 100303] Adding a single, meaningless if-else to a shader source leads to different image

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun Mar 26 00:06:12 UTC 2017


https://bugs.freedesktop.org/show_bug.cgi?id=100303

--- Comment #2 from Roland Scheidegger <sroland at vmware.com> ---
This is the output of glsl_compiler --dump_lir --version=100 original.frag for
the getHardShadow function:
( function getHardShadow
  (signature float
    (parameters
      (declare (in ) vec3 ro)
      (declare (in ) vec3 rd)
    )
    (
      (declare (temporary ) float return_value)
      (declare (temporary ) bool return_flag)
      (assign  (x) (var_ref return_flag)  (constant bool (0)) ) 
      (declare () int i)
      (declare () float depth)
      (assign  (x) (var_ref depth)  (constant float (0.010000)) ) 
      (assign  (x) (var_ref i)  (constant int (0)) ) 
      (loop (
        (if (expression bool >= (var_ref i) (constant int (30)) ) (
          break
        )
        ())

        (declare (temporary ) float sceneDist_retval)
        (call sceneDist (var_ref sceneDist_retval)  ((expression vec3 +
(var_ref ro) (expression vec3 * (var_ref rd) (var_ref depth) ) ) ))

        (if (expression bool < (var_ref sceneDist_retval) (constant float
(0.010000)) ) (
          (assign  (x) (var_ref return_value)  (var_ref shadowIntensity) ) 
          (assign  (x) (var_ref return_flag)  (constant bool (1)) ) 
          break
        )
        ())

        (assign  (x) (var_ref depth)  (expression float + (var_ref depth)
(var_ref sceneDist_retval) ) ) 
        (assign  (x) (var_ref i)  (expression int + (var_ref i) (constant int
(1)) ) ) 
      ))

      (if (expression bool ! (var_ref return_flag) ) (
        (assign  (x) (var_ref return_value)  (constant float (1.000000)) ) 
        (assign  (x) (var_ref return_flag)  (constant bool (1)) ) 
      )
      ())

      (return (var_ref return_value) )
    ))

And for variant.frag:
( function getHardShadow
  (signature float
    (parameters
      (declare (in ) vec3 ro)
      (declare (in ) vec3 rd)
    )
    (
      (declare () float depth)
      (assign  (x) (var_ref depth)  (constant float (0.010000)) ) 
      (if (expression bool <= (swiz x (var_ref injectionSwitch) )(swiz y
(var_ref injectionSwitch) )) (
        (declare () int i)
        (assign  (x) (var_ref i)  (constant int (0)) ) 
        (loop (
          (if (expression bool >= (var_ref i) (constant int (30)) ) (
            break
          )
          ())

          (declare (temporary ) float sceneDist_retval)
          (call sceneDist (var_ref sceneDist_retval)  ((expression vec3 +
(var_ref ro) (expression vec3 * (var_ref rd) (var_ref depth) ) ) ))

          (if (expression bool < (var_ref sceneDist_retval) (constant float
(0.010000)) ) (
            break
          )
          ())

          (assign  (x) (var_ref depth)  (expression float + (var_ref depth)
(var_ref sceneDist_retval) ) ) 
          (assign  (x) (var_ref i)  (expression int + (var_ref i) (constant int
(1)) ) ) 
        ))

      )
      ())

      (return (constant float (1.000000)) )
    ))

)

So, for some reason the compiler completely eliminated the conditional return
in the loop inside the branch and figured it will just unconditionally return
the value corresponding to not meeting that condition in the loop in the
original code. (In fact all code in this function with the exception of the
return statement is now effectively dead.)
Not sure though which lowering stage did this damage...

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170326/aa991d1c/attachment.html>


More information about the mesa-dev mailing list