anv/brw/iris: move VS VUE computation to backend

Drivers can provide the inputs required for the backend to call the
compute function.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34872>
This commit is contained in:
Lionel Landwerlin 2025-05-05 11:23:16 +03:00 committed by Marge Bot
parent 8dee4813b0
commit a18835a9ca
6 changed files with 41 additions and 20 deletions

View file

@ -1884,10 +1884,6 @@ iris_compile_vs(struct iris_screen *screen,
brw_nir_analyze_ubo_ranges(screen->brw, nir, brw_prog_data->base.base.ubo_ranges); brw_nir_analyze_ubo_ranges(screen->brw, nir, brw_prog_data->base.base.ubo_ranges);
brw_compute_vue_map(devinfo,
&brw_prog_data->base.vue_map, nir->info.outputs_written,
key->vue.layout, /* pos_slots */ 1);
struct brw_vs_prog_key brw_key = iris_to_brw_vs_key(screen, key); struct brw_vs_prog_key brw_key = iris_to_brw_vs_key(screen, key);
struct brw_compile_vs_params params = { struct brw_compile_vs_params params = {

View file

@ -163,6 +163,16 @@ brw_compile_gs(const struct brw_compiler *compiler,
&input_vue_map, inputs_read, &input_vue_map, inputs_read,
key->base.vue_layout, 1); key->base.vue_layout, 1);
const uint32_t pos_slots =
(nir->info.per_view_outputs & VARYING_BIT_POS) ?
MAX2(1, util_bitcount(key->base.view_mask)) : 1;
brw_compute_vue_map(compiler->devinfo,
&prog_data->base.vue_map,
nir->info.outputs_written,
key->base.vue_layout,
pos_slots);
brw_nir_apply_key(nir, compiler, &key->base, dispatch_width); brw_nir_apply_key(nir, compiler, &key->base, dispatch_width);
brw_nir_lower_vue_inputs(nir, &input_vue_map); brw_nir_lower_vue_inputs(nir, &input_vue_map);
brw_nir_lower_vue_outputs(nir); brw_nir_lower_vue_outputs(nir);

View file

@ -82,9 +82,13 @@ brw_compile_tes(const struct brw_compiler *compiler,
brw_postprocess_nir(nir, compiler, debug_enabled, brw_postprocess_nir(nir, compiler, debug_enabled,
key->base.robust_flags); key->base.robust_flags);
const uint32_t pos_slots =
(nir->info.per_view_outputs & VARYING_BIT_POS) ?
MAX2(1, util_bitcount(key->base.view_mask)) : 1;
brw_compute_vue_map(devinfo, &prog_data->base.vue_map, brw_compute_vue_map(devinfo, &prog_data->base.vue_map,
nir->info.outputs_written, nir->info.outputs_written,
key->base.vue_layout, 1); key->base.vue_layout, pos_slots);
unsigned output_size_bytes = prog_data->base.vue_map.num_slots * 4 * 4; unsigned output_size_bytes = prog_data->base.vue_map.num_slots * 4 * 4;

View file

@ -248,6 +248,20 @@ brw_compile_vs(const struct brw_compiler *compiler,
brw_prog_data_init(&prog_data->base.base, &params->base); brw_prog_data_init(&prog_data->base.base, &params->base);
/* When using Primitive Replication for multiview, each view gets its own
* position slot.
*/
const uint32_t pos_slots =
(nir->info.per_view_outputs & VARYING_BIT_POS) ?
MAX2(1, util_bitcount(key->base.view_mask)) : 1;
/* Only position is allowed to be per-view */
assert(!(nir->info.per_view_outputs & ~VARYING_BIT_POS));
brw_compute_vue_map(compiler->devinfo,
&prog_data->base.vue_map, nir->info.outputs_written,
key->base.vue_layout, pos_slots);
brw_nir_apply_key(nir, compiler, &key->base, dispatch_width); brw_nir_apply_key(nir, compiler, &key->base, dispatch_width);
prog_data->inputs_read = nir->info.inputs_read; prog_data->inputs_read = nir->info.inputs_read;

View file

@ -219,6 +219,12 @@ enum brw_robustness_flags {
struct brw_base_prog_key { struct brw_base_prog_key {
unsigned program_string_id; unsigned program_string_id;
/** Multiview mask
*
* Used to compute the number of position slots in the VUE
*/
uint32_t view_mask;
enum brw_robustness_flags robust_flags:2; enum brw_robustness_flags robust_flags:2;
bool uses_inline_push_addr:1; bool uses_inline_push_addr:1;
@ -232,7 +238,7 @@ struct brw_base_prog_key {
*/ */
bool limit_trig_input_range:1; bool limit_trig_input_range:1;
unsigned padding:26; uint64_t padding:58;
}; };
/** /**
@ -294,7 +300,7 @@ struct brw_vs_prog_key {
*/ */
bool no_vf_slot_compaction : 1; bool no_vf_slot_compaction : 1;
uint32_t padding : 30; uint64_t padding : 62;
}; };
/** The program key for Tessellation Control Shaders. */ /** The program key for Tessellation Control Shaders. */
@ -421,7 +427,7 @@ struct brw_cs_prog_key {
*/ */
bool lower_unaligned_dispatch:1; bool lower_unaligned_dispatch:1;
uint32_t padding:31; uint64_t padding:63;
}; };
struct brw_bs_prog_key { struct brw_bs_prog_key {
@ -432,6 +438,8 @@ struct brw_bs_prog_key {
* shader. * shader.
*/ */
uint32_t pipeline_ray_flags; uint32_t pipeline_ray_flags;
uint32_t padding;
}; };
/* brw_any_prog_key is any of the keys that map to an API stage */ /* brw_any_prog_key is any of the keys that map to an API stage */

View file

@ -1244,21 +1244,10 @@ anv_pipeline_compile_vs(const struct brw_compiler *compiler,
uint32_t view_mask, uint32_t view_mask,
char **error_str) char **error_str)
{ {
/* When using Primitive Replication for multiview, each view gets its own
* position slot.
*/
uint32_t pos_slots =
(vs_stage->nir->info.per_view_outputs & VARYING_BIT_POS) ?
MAX2(1, util_bitcount(view_mask)) : 1;
/* Only position is allowed to be per-view */ /* Only position is allowed to be per-view */
assert(!(vs_stage->nir->info.per_view_outputs & ~VARYING_BIT_POS)); assert(!(vs_stage->nir->info.per_view_outputs & ~VARYING_BIT_POS));
brw_compute_vue_map(compiler->devinfo, vs_stage->key.vs.base.view_mask = view_mask;
&vs_stage->prog_data.vs.base.vue_map,
vs_stage->nir->info.outputs_written,
vs_stage->key.base.vue_layout,
pos_slots);
vs_stage->num_stats = 1; vs_stage->num_stats = 1;