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
+5 -5
View File
@@ -1517,7 +1517,7 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
* from the start of the attribute to the number of components we
* declare we need in c->vattr_sizes[].
*/
nir_foreach_variable(var, &c->s->inputs) {
nir_foreach_shader_in_variable(var, c->s) {
/* No VS attribute array support. */
assert(MAX2(glsl_get_length(var->type), 1) == 1);
@@ -1582,7 +1582,7 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
static bool
program_reads_point_coord(struct v3d_compile *c)
{
nir_foreach_variable(var, &c->s->inputs) {
nir_foreach_shader_in_variable(var, c->s) {
if (util_varying_is_point_coord(var->data.location,
c->fs_key->point_sprite_mask)) {
return true;
@@ -1598,13 +1598,13 @@ get_sorted_input_variables(struct v3d_compile *c,
nir_variable ***vars)
{
*num_entries = 0;
nir_foreach_variable(var, &c->s->inputs)
nir_foreach_shader_in_variable(var, c->s)
(*num_entries)++;
*vars = ralloc_array(c, nir_variable *, *num_entries);
unsigned i = 0;
nir_foreach_variable(var, &c->s->inputs)
nir_foreach_shader_in_variable(var, c->s)
(*vars)[i++] = var;
/* Sort the variables so that we emit the input setup in
@@ -1687,7 +1687,7 @@ ntq_setup_outputs(struct v3d_compile *c)
if (c->s->info.stage != MESA_SHADER_FRAGMENT)
return;
nir_foreach_variable(var, &c->s->outputs) {
nir_foreach_shader_out_variable(var, c->s) {
unsigned array_len = MAX2(glsl_get_length(var->type), 1);
unsigned loc = var->data.driver_location * 4;
+2 -2
View File
@@ -173,7 +173,7 @@ v3d_nir_lower_vpm_output(struct v3d_compile *c, nir_builder *b,
nir_ssa_def *src = nir_ssa_for_src(b, intr->src[0],
intr->num_components);
nir_variable *var = NULL;
nir_foreach_variable(scan_var, &c->s->outputs) {
nir_foreach_shader_out_variable(scan_var, c->s) {
int components = scan_var->data.compact ?
glsl_get_length(scan_var->type) :
glsl_get_components(scan_var->type);
@@ -368,7 +368,7 @@ static void
v3d_nir_lower_io_update_output_var_base(struct v3d_compile *c,
struct v3d_nir_lower_io_state *state)
{
nir_foreach_variable_safe(var, &c->s->outputs) {
nir_foreach_shader_out_variable_safe(var, c->s) {
if (var->data.location == VARYING_SLOT_POS &&
state->pos_vpm_offset != -1) {
var->data.driver_location = state->pos_vpm_offset;
@@ -352,7 +352,7 @@ v3d_nir_lower_logic_ops_block(nir_block *block, struct v3d_compile *c)
if (intr->intrinsic != nir_intrinsic_store_output)
continue;
nir_foreach_variable(var, &c->s->outputs) {
nir_foreach_shader_out_variable(var, c->s) {
const int driver_loc = var->data.driver_location;
if (driver_loc != nir_intrinsic_base(intr))
continue;
+1 -1
View File
@@ -859,7 +859,7 @@ v3d_nir_lower_gs_early(struct v3d_compile *c)
static void
v3d_fixup_fs_output_types(struct v3d_compile *c)
{
nir_foreach_variable(var, &c->s->outputs) {
nir_foreach_shader_out_variable(var, c->s) {
uint32_t mask = 0;
switch (var->data.location) {