Skip to content

NIR: Add a new nir_jump_halt instruction

Faith Ekstrand requested to merge gfxstrand/mesa:review/nir-jump-halt into master

This is something that is useful for something I'm doing in a private branch at the moment. However, it seems like it could be fairly useful in general. In particular, as seen in the last patch, this can be used to implement OpenGL-style discard semantics in a way that NIR can then dead-code everything dominated by the discard. This maps (as you can see in the last patch) fairly directly to something we have in Intel hardware. Even though our hardware is structured, a goto-like thing to the end of the program is easily implementable. This is not to be confused with function returns which have slightly different properties that mean they're basically an arbitrary forward goto and aren't really implementable unless they're a return in the main function itself. A return in the main function is functionally identical to a halt instruction.

I'd like feedback on the general idea. I think the first two patches are worth landing independently of the new instruction. The new instruction may be useful for some of the discard stuff that @idr has been playing with.

cc: @karolherbst @robclark @anholt @cwabbott0 @alyssa @kwg

Edited by Faith Ekstrand

Merge request reports