nir: Add a discard optimization pass
Many fragment shaders do a discard using relatively little information but still put the discard fairly far down in the shader for no good reason. If the discard is moved higher up, we can possibly avoid doing some or almost all of the work in the shader. When this lets us skip texturing operations, it's an especially high win. One of the biggest offenders here is DXVK. The D3D APIs have different rules for discards than OpenGL and Vulkan. One effective way (which is what DXVK uses) to implement DX behavior on top of GL or Vulkan is to wait until the very end of the shader to discard. This ends up in the pessimal case where we always do all of the work before discarding. This pass helps some DXVK shaders significantly. v2 (Jason Ekstrand): - Fix a couple of typos (Grazvydas, Ian) - Use the new nir_instr_move helper - Find all movable discards before moving anything so we don't accidentally re-order anything and break dependencies v3 (Pierre-Eric): remove the call to nir_opt_conditional_discard based on Daniel Schürmann comment. v4 (Pierre-Eric): - handle demote intrinsics and drop derivatives_safe_after_discard - add early return if discards/demotes aren't used v5 (Pierre-Eric): - use pass_flags instead of instr set (Daniel Schürmann) v6 (Daniel Schürmann): - cleanup and fix pass_flags handling Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10522>
This commit is contained in:

committed by
Marge Bot

parent
3033410b10
commit
b447f5049b
@@ -230,6 +230,7 @@ files_libnir = files(
|
||||
'nir_opt_loop_unroll.c',
|
||||
'nir_opt_memcpy.c',
|
||||
'nir_opt_move.c',
|
||||
'nir_opt_move_discards_to_top.c',
|
||||
'nir_opt_offsets.c',
|
||||
'nir_opt_peephole_select.c',
|
||||
'nir_opt_rematerialize_compares.c',
|
||||
|
Reference in New Issue
Block a user