OSDN Git Service

glsl: Copy function out to temp if we don't directly ref a variable
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 9 Apr 2018 04:40:40 +0000 (14:40 +1000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 31 Jan 2019 12:05:54 +0000 (12:05 +0000)
commitf2c1d7acd0ca56a020a982425523ec8f7fade966
treed154f158ff9513a0d8fcfa5572ca48aacfdf5c23
parent5e8af9e609632f7062bf9dc81b44c6877a7d8ee4
glsl: Copy function out to temp if we don't directly ref a variable

Otherwise we can end up with IR that looks like this:

    (
      (declare (temporary ) vec4 f@8)
      (assign  (xyzw) (var_ref f@8)  (var_ref f) )
      (call f16  ((swiz y (var_ref f@8) )))

      (assign  (xyzw) (var_ref f)  (var_ref f@8) )
    ))

When we really need:

      (declare (temporary ) float inout_tmp)
      (assign  (x) (var_ref inout_tmp)  (swiz y (var_ref f) ))
      (call f16  ((var_ref inout_tmp) ))

      (assign  (y) (var_ref f)  (swiz y (swiz xxxx (var_ref inout_tmp) )))
      (declare (temporary ) void void_var)

The GLSL IR function inlining code seemed to produce correct code
even without this but we need the correct IR for GLSL IR -> NIR to
be able to understand whats going on.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 76c27e47b90647df047e785d6b3ab5d0d979a1ee)
Nominated-by: Matt Turner <mattst88@gmail.com>
src/compiler/glsl/ast_function.cpp