nir: Add nir_foreach_shader_in/out_variable helpers

Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
This commit is contained in:
Jason Ekstrand
2020-07-18 18:24:25 -05:00
committed by Marge Bot
parent 9bf8572222
commit 2956d53400
58 changed files with 125 additions and 116 deletions

View File

@@ -8335,7 +8335,7 @@ brw_compute_flat_inputs(struct brw_wm_prog_data *prog_data,
{
prog_data->flat_inputs = 0;
nir_foreach_variable(var, &shader->inputs) {
nir_foreach_shader_in_variable(var, shader) {
unsigned slots = glsl_count_attribute_slots(var->type, false);
for (unsigned s = 0; s < slots; s++) {
int input_index = prog_data->urb_setup[var->data.location + s];

View File

@@ -59,7 +59,7 @@ fs_visitor::nir_setup_outputs()
* allocating them. With ARB_enhanced_layouts, multiple output variables
* may occupy the same slot, but have different type sizes.
*/
nir_foreach_variable(var, &nir->outputs) {
nir_foreach_shader_out_variable(var, nir) {
const int loc = var->data.driver_location;
const unsigned var_vec4s =
var->data.compact ? DIV_ROUND_UP(glsl_get_length(var->type), 4)

View File

@@ -75,7 +75,7 @@ brw_setup_vue_interpolation(struct brw_vue_map *vue_map, nir_shader *nir,
prog_data->contains_noperspective_varying = true;
}
foreach_list_typed(nir_variable, var, node, &nir->inputs) {
nir_foreach_shader_in_variable(var, nir) {
unsigned location = var->data.location;
unsigned slot_count = glsl_count_attribute_slots(var->type, false);

View File

@@ -163,9 +163,8 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
const uint8_t *vs_attrib_wa_flags)
{
/* Start with the location of the variable's base. */
foreach_list_typed(nir_variable, var, node, &nir->inputs) {
nir_foreach_shader_in_variable(var, nir)
var->data.driver_location = var->data.location;
}
/* Now use nir_lower_io to walk dereference chains. Attribute arrays are
* loaded as one vec4 or dvec4 per element (or matrix column), depending on
@@ -290,9 +289,8 @@ void
brw_nir_lower_vue_inputs(nir_shader *nir,
const struct brw_vue_map *vue_map)
{
foreach_list_typed(nir_variable, var, node, &nir->inputs) {
nir_foreach_shader_in_variable(var, nir)
var->data.driver_location = var->data.location;
}
/* Inputs are stored in vec4 slots, so use type_size_vec4(). */
nir_lower_io(nir, nir_var_shader_in, type_size_vec4,
@@ -343,9 +341,8 @@ brw_nir_lower_vue_inputs(nir_shader *nir,
void
brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue_map)
{
foreach_list_typed(nir_variable, var, node, &nir->inputs) {
nir_foreach_shader_in_variable(var, nir)
var->data.driver_location = var->data.location;
}
nir_lower_io(nir, nir_var_shader_in, type_size_vec4,
nir_lower_io_lower_64bit_to_32);
@@ -372,7 +369,7 @@ brw_nir_lower_fs_inputs(nir_shader *nir,
const struct gen_device_info *devinfo,
const struct brw_wm_prog_key *key)
{
foreach_list_typed(nir_variable, var, node, &nir->inputs) {
nir_foreach_shader_in_variable(var, nir) {
var->data.driver_location = var->data.location;
/* Apply default interpolation mode.
@@ -416,7 +413,7 @@ brw_nir_lower_fs_inputs(nir_shader *nir,
void
brw_nir_lower_vue_outputs(nir_shader *nir)
{
nir_foreach_variable(var, &nir->outputs) {
nir_foreach_shader_out_variable(var, nir) {
var->data.driver_location = var->data.location;
}
@@ -428,7 +425,7 @@ void
brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map,
GLenum tes_primitive_mode)
{
nir_foreach_variable(var, &nir->outputs) {
nir_foreach_shader_out_variable(var, nir) {
var->data.driver_location = var->data.location;
}
@@ -454,7 +451,7 @@ brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map,
void
brw_nir_lower_fs_outputs(nir_shader *nir)
{
nir_foreach_variable(var, &nir->outputs) {
nir_foreach_shader_out_variable(var, nir) {
var->data.driver_location =
SET_FIELD(var->data.index, BRW_NIR_FRAG_OUTPUT_INDEX) |
SET_FIELD(var->data.location, BRW_NIR_FRAG_OUTPUT_LOCATION);

View File

@@ -89,7 +89,7 @@ brw_nir_lower_alpha_to_coverage(nir_shader *shader)
/* Bail out early if we don't have gl_SampleMask */
bool is_sample_mask = false;
nir_foreach_variable(var, &shader->outputs) {
nir_foreach_shader_out_variable(var, shader) {
if (var->data.location == FRAG_RESULT_SAMPLE_MASK) {
is_sample_mask = true;
break;
@@ -115,7 +115,7 @@ brw_nir_lower_alpha_to_coverage(nir_shader *shader)
switch (intr->intrinsic) {
case nir_intrinsic_store_output:
nir_foreach_variable(var, &shader->outputs) {
nir_foreach_shader_out_variable(var, shader) {
int drvloc = var->data.driver_location;
if (nir_intrinsic_base(intr) == drvloc) {
out = var;