mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-08 20:40:35 +02:00
nir: add nir_move_only_convergent/divergent
This will be needed by nir_opt_move_reorder_loads, which will use the move flags. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36357>
This commit is contained in:
parent
35bbc8405b
commit
d61edf079b
3 changed files with 24 additions and 1 deletions
|
|
@ -6219,6 +6219,10 @@ typedef enum {
|
|||
nir_move_load_uniform = BITFIELD_BIT(20),
|
||||
nir_move_load_buffer_amd = BITFIELD_BIT(21),
|
||||
nir_move_load_frag_coord = BITFIELD_BIT(22),
|
||||
|
||||
/* The following options only impact load_global/ubo/ssbo/smem_amd. */
|
||||
nir_move_only_convergent = BITFIELD_BIT(30),
|
||||
nir_move_only_divergent = BITFIELD_BIT(31),
|
||||
} nir_move_options;
|
||||
|
||||
bool nir_can_move_instr(nir_instr *instr, nir_move_options options);
|
||||
|
|
|
|||
|
|
@ -138,6 +138,9 @@ nir_opt_move(nir_shader *shader, nir_move_options options)
|
|||
bool progress = false;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (options & (nir_move_only_convergent | nir_move_only_divergent))
|
||||
nir_metadata_require(impl, nir_metadata_divergence);
|
||||
|
||||
bool impl_progress = false;
|
||||
nir_foreach_block(block, impl) {
|
||||
if (nir_opt_move_block(block, options))
|
||||
|
|
|
|||
|
|
@ -147,6 +147,19 @@ can_sink_instr(nir_instr *instr, nir_move_options options, bool *can_mov_out_of_
|
|||
if (!nir_intrinsic_can_reorder(intrin))
|
||||
return false;
|
||||
|
||||
if (intrin->intrinsic == nir_intrinsic_load_global ||
|
||||
intrin->intrinsic == nir_intrinsic_load_ubo ||
|
||||
intrin->intrinsic == nir_intrinsic_load_ssbo ||
|
||||
intrin->intrinsic == nir_intrinsic_load_smem_amd) {
|
||||
if (intrin->def.divergent) {
|
||||
if (options & nir_move_only_convergent)
|
||||
return false;
|
||||
} else {
|
||||
if (options & nir_move_only_divergent)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*can_mov_out_of_loop = false;
|
||||
|
||||
switch (intrin->intrinsic) {
|
||||
|
|
@ -345,7 +358,10 @@ nir_opt_sink(nir_shader *shader, nir_move_options options)
|
|||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_metadata_require(impl,
|
||||
nir_metadata_control_flow);
|
||||
nir_metadata_control_flow |
|
||||
(options & (nir_move_only_convergent |
|
||||
nir_move_only_divergent) ?
|
||||
nir_metadata_divergence : 0));
|
||||
|
||||
nir_foreach_block_reverse(block, impl) {
|
||||
nir_foreach_instr_reverse_safe(instr, block) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue