nir: Track per-view outputs in shader_info

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17602>
This commit is contained in:
Jason Ekstrand 2022-07-15 15:36:33 -05:00 committed by Marge Bot
parent 30251aaca2
commit 5937660067
3 changed files with 17 additions and 8 deletions

View file

@ -1056,14 +1056,19 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
ralloc_free(dead_ctx);
shader->info.per_primitive_outputs = 0;
if (shader->info.stage == MESA_SHADER_MESH) {
nir_foreach_shader_out_variable(var, shader) {
if (var->data.per_primitive) {
assert(nir_is_arrayed_io(var, shader->info.stage));
const unsigned slots =
glsl_count_attribute_slots(glsl_get_array_element(var->type), false);
shader->info.per_primitive_outputs |= BITFIELD64_RANGE(var->data.location, slots);
}
shader->info.per_view_outputs = 0;
nir_foreach_shader_out_variable(var, shader) {
if (var->data.per_primitive) {
assert(shader->info.stage == MESA_SHADER_MESH);
assert(nir_is_arrayed_io(var, shader->info.stage));
const unsigned slots =
glsl_count_attribute_slots(glsl_get_array_element(var->type), false);
shader->info.per_primitive_outputs |= BITFIELD64_RANGE(var->data.location, slots);
}
if (var->data.per_view) {
const unsigned slots =
glsl_count_attribute_slots(glsl_get_array_element(var->type), false);
shader->info.per_view_outputs |= BITFIELD64_RANGE(var->data.location, slots);
}
}

View file

@ -239,6 +239,7 @@ nir_lower_multiview(nir_shader *shader, uint32_t view_mask)
assert(var->type == glsl_vec4_type());
var->type = glsl_array_type(glsl_vec4_type(), view_count, 0);
var->data.per_view = true;
shader->info.per_view_outputs |= VARYING_BIT_POS;
pos_var = var;
break;
}

View file

@ -172,6 +172,9 @@ typedef struct shader_info {
uint64_t per_primitive_inputs;
uint64_t per_primitive_outputs;
/* Which I/O is per-view */
uint64_t per_view_outputs;
/* Which 16-bit inputs and outputs are used corresponding to
* VARYING_SLOT_VARn_16BIT.
*/