[Mesa-dev] GLSL IR building helpers

Eric Anholt eric at anholt.net
Mon Mar 26 12:42:36 PDT 2012


However, as is often the case with writing helper functions, we end up
with more code overall and another API to understand.  I'm tempted to
not commit this code unless one either the ARB to GLSL IR work or the
FFVS work finds it to be useful.

Some of the remaining awkward GLSL IR code in ff_fragment_shader:

- making constants.  If all we ever really need is scalar constants,
  making a scalar constant creation helper in ir_builder seems easy.

- swizzling scalars out to vec4s so that they can, for example, be
  treated the same by code that wants to do a .xyz or .a swizzle on a
  value.  I didn't do this in ir_builder because that may not be what
  everyone else wants.

Another thing we'd talked about was how painful dealing with cloning
is.  In ir_validate, we have shown that we can detect un-cloned IR
nodes.  I think if cloning is painful in some IR generation pass, we
should offer a helper that walks the IR tree, detects un-cloned IR,
and clones it for you.  It's more CPU expensive than doing it by hand
at the moment you know you need to clone, but it may be less error
prone.



More information about the mesa-dev mailing list