v3dv/pipeline: use derefs for ubo/ssbo
There are some potential advantages for that. Even if we are not taking advantage of them, it would be interesting to be using this path now, specially as non-deref path could be removed at some point. Note that instead of returning for both resource_index and vulkan_descriptor a vec2, we return a scalar for the first one, as it is what the v3d backend expect (like for get_ssbo_size). For this to work, we reconfigure the vec2 at vulkan_descriptor using the index and an unused 0 value. As far as I see turnip avoids that by lowering too load_ssbo/ubo, so it just gets the index lowered (that in their case it is a vec3 with a fixed 0 on the third component), but for now it is easier doing this. v2: return a single-component for the index, to avoid the backend needing to handle it (Eric, Jason). Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
parent
17c5a09c85
commit
8f0696781f
|
@ -366,6 +366,10 @@ preprocess_nir(nir_shader *nir,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NIR_PASS_V(nir, nir_lower_explicit_io,
|
||||||
|
nir_var_mem_ubo | nir_var_mem_ssbo,
|
||||||
|
nir_address_format_32bit_index_offset);
|
||||||
|
|
||||||
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in |
|
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in |
|
||||||
nir_var_shader_out | nir_var_system_value | nir_var_mem_shared,
|
nir_var_shader_out | nir_var_system_value | nir_var_mem_shared,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -611,6 +615,12 @@ lower_vulkan_resource_index(nir_builder *b,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Since we use the deref pass, both vulkan_resource_index and
|
||||||
|
* vulkan_load_descriptor returns a vec2. But for the index the backend
|
||||||
|
* expect just one scalar (like with get_ssbo_size), so lets return here
|
||||||
|
* just it. Then on load_descriptor we would recreate the vec2, keeping the
|
||||||
|
* second component (unused right now) to zero.
|
||||||
|
*/
|
||||||
nir_ssa_def_rewrite_uses(&instr->dest.ssa,
|
nir_ssa_def_rewrite_uses(&instr->dest.ssa,
|
||||||
nir_src_for_ssa(nir_imm_int(b, index)));
|
nir_src_for_ssa(nir_imm_int(b, index)));
|
||||||
nir_instr_remove(&instr->instr);
|
nir_instr_remove(&instr->instr);
|
||||||
|
@ -861,6 +871,17 @@ lower_intrinsic(nir_builder *b, nir_intrinsic_instr *instr,
|
||||||
lower_vulkan_resource_index(b, instr, pipeline, layout);
|
lower_vulkan_resource_index(b, instr, pipeline, layout);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case nir_intrinsic_load_vulkan_descriptor: {
|
||||||
|
/* We are not using it, as loading the descriptor happens as part of the
|
||||||
|
* load/store instruction, so the simpler is just doing a no-op. We just
|
||||||
|
* lower the desc back to a vec2, as it is what load_ssbo/ubo expects.
|
||||||
|
*/
|
||||||
|
nir_ssa_def *desc = nir_vec2(b, instr->src[0].ssa, nir_imm_int(b, 0));
|
||||||
|
nir_ssa_def_rewrite_uses(&instr->dest.ssa, nir_src_for_ssa(desc));
|
||||||
|
nir_instr_remove(&instr->instr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case nir_intrinsic_image_deref_load:
|
case nir_intrinsic_image_deref_load:
|
||||||
case nir_intrinsic_image_deref_store:
|
case nir_intrinsic_image_deref_store:
|
||||||
case nir_intrinsic_image_deref_atomic_add:
|
case nir_intrinsic_image_deref_atomic_add:
|
||||||
|
|
Loading…
Reference in New Issue