i965: Split nir_emit_intrinsic by stage with a general fallback.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 5 Nov 2015 07:05:07 +0000 (23:05 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 11 Nov 2015 19:57:37 +0000 (11:57 -0800)
commit918bda23dda36004c95f6441328ecc892e068886
tree3d1d922a1a11be18a6f14d37a1bd4b5b5d1a8bbe
parent912babba7bf1abd3caa49f6372d581ae1afe7e84
i965: Split nir_emit_intrinsic by stage with a general fallback.

Many intrinsics only apply to a particular stage (such as discard).
In other cases, we may want to interpret them differently based on
the stage (such as load_primitive_id or load_input).

The current method isn't that pretty - we handle all intrinsics in
one giant function.  Sometimes we assert on stage, sometimes we forget.
Different behaviors are handled via if-ladders based on stage.

This commit introduces new nir_emit_<stage>_intrinsic() functions,
and makes nir_emit_instr() call those.  In turn, those fall back to
the generic nir_emit_intrinsic() function for cases they don't want
to handle specially.

This makes it clear which intrinsics only exist in one stage, and makes
it easy to handle inputs/outputs differently for various stages.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_nir.cpp