nir: remove and replace underused option pack_varying_options
This will also be used by nir_opt_varyings. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26918>
This commit is contained in:
@@ -3554,14 +3554,17 @@ typedef enum {
|
||||
} nir_divergence_options;
|
||||
|
||||
typedef enum {
|
||||
nir_pack_varying_interp_mode_none = (1 << 0),
|
||||
nir_pack_varying_interp_mode_smooth = (1 << 1),
|
||||
nir_pack_varying_interp_mode_flat = (1 << 2),
|
||||
nir_pack_varying_interp_mode_noperspective = (1 << 3),
|
||||
nir_pack_varying_interp_loc_sample = (1 << 16),
|
||||
nir_pack_varying_interp_loc_centroid = (1 << 17),
|
||||
nir_pack_varying_interp_loc_center = (1 << 18),
|
||||
} nir_pack_varying_options;
|
||||
/**
|
||||
* Whether a fragment shader can interpolate the same input multiple times
|
||||
* with different modes (smooth, noperspective) and locations (pixel,
|
||||
* centroid, sample, at_offset, at_sample), excluding the flat mode.
|
||||
*
|
||||
* This matches AMD GPU flexibility and limitations and is a superset of
|
||||
* the GL4 requirement that each input can be interpolated at its specified
|
||||
* location, and then also as centroid, at_offset, and at_sample.
|
||||
*/
|
||||
nir_io_has_flexible_input_interpolation_except_flat = BITFIELD_BIT(0),
|
||||
} nir_io_options;
|
||||
|
||||
/** An instruction filtering callback
|
||||
*
|
||||
@@ -4009,13 +4012,6 @@ typedef struct nir_shader_compiler_options {
|
||||
nir_lower_doubles_options lower_doubles_options;
|
||||
nir_divergence_options divergence_analysis_options;
|
||||
|
||||
/**
|
||||
* Support pack varyings with different interpolation location
|
||||
* (center, centroid, sample) and mode (flat, noperspective, smooth)
|
||||
* into same slot.
|
||||
*/
|
||||
nir_pack_varying_options pack_varying_options;
|
||||
|
||||
/**
|
||||
* Lower load_deref/store_deref of inputs and outputs into
|
||||
* load_input/store_input intrinsics. This is used by nir_lower_io_passes.
|
||||
@@ -4062,6 +4058,9 @@ typedef struct nir_shader_compiler_options {
|
||||
|
||||
/** Lower VARYING_SLOT_LAYER in FS to SYSTEM_VALUE_LAYER_ID. */
|
||||
bool lower_layer_fs_input_to_sysval;
|
||||
|
||||
/** Options determining lowering and behavior of inputs and outputs. */
|
||||
nir_io_options io_options;
|
||||
} nir_shader_compiler_options;
|
||||
|
||||
typedef struct nir_shader {
|
||||
|
@@ -715,50 +715,16 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer,
|
||||
}
|
||||
|
||||
static bool
|
||||
allow_pack_interp_type(nir_pack_varying_options options, int type)
|
||||
allow_pack_interp_type(nir_io_options options, int type)
|
||||
{
|
||||
int sel;
|
||||
|
||||
switch (type) {
|
||||
case INTERP_MODE_NONE:
|
||||
sel = nir_pack_varying_interp_mode_none;
|
||||
break;
|
||||
case INTERP_MODE_SMOOTH:
|
||||
sel = nir_pack_varying_interp_mode_smooth;
|
||||
break;
|
||||
case INTERP_MODE_FLAT:
|
||||
sel = nir_pack_varying_interp_mode_flat;
|
||||
break;
|
||||
case INTERP_MODE_NOPERSPECTIVE:
|
||||
sel = nir_pack_varying_interp_mode_noperspective;
|
||||
break;
|
||||
return options & nir_io_has_flexible_input_interpolation_except_flat;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return options & sel;
|
||||
}
|
||||
|
||||
static bool
|
||||
allow_pack_interp_loc(nir_pack_varying_options options, int loc)
|
||||
{
|
||||
int sel;
|
||||
|
||||
switch (loc) {
|
||||
case INTERPOLATE_LOC_SAMPLE:
|
||||
sel = nir_pack_varying_interp_loc_sample;
|
||||
break;
|
||||
case INTERPOLATE_LOC_CENTROID:
|
||||
sel = nir_pack_varying_interp_loc_centroid;
|
||||
break;
|
||||
case INTERPOLATE_LOC_CENTER:
|
||||
sel = nir_pack_varying_interp_loc_center;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return options & sel;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -767,7 +733,7 @@ static void
|
||||
struct varying_component *info,
|
||||
unsigned *cursor, unsigned *comp,
|
||||
unsigned max_location,
|
||||
nir_pack_varying_options options)
|
||||
nir_io_options options)
|
||||
{
|
||||
unsigned tmp_cursor = *cursor;
|
||||
unsigned tmp_comp = *comp;
|
||||
@@ -801,8 +767,7 @@ static void
|
||||
* if driver does not support it.
|
||||
*/
|
||||
if (assigned_comps[tmp_cursor].interp_loc != info->interp_loc &&
|
||||
(!allow_pack_interp_loc(options, assigned_comps[tmp_cursor].interp_loc) ||
|
||||
!allow_pack_interp_loc(options, info->interp_loc))) {
|
||||
!(options & nir_io_has_flexible_input_interpolation_except_flat)) {
|
||||
tmp_comp = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -870,8 +835,6 @@ compact_components(nir_shader *producer, nir_shader *consumer,
|
||||
qsort(varying_comp_info, varying_comp_info_size,
|
||||
sizeof(struct varying_component), cmp_varying_component);
|
||||
|
||||
nir_pack_varying_options options = consumer->options->pack_varying_options;
|
||||
|
||||
unsigned cursor = 0;
|
||||
unsigned comp = 0;
|
||||
|
||||
@@ -892,11 +855,11 @@ compact_components(nir_shader *producer, nir_shader *consumer,
|
||||
|
||||
assign_remap_locations(remap, assigned_comps, info,
|
||||
&cursor, &comp, MAX_VARYINGS_INCL_PATCH,
|
||||
options);
|
||||
consumer->options->io_options);
|
||||
} else {
|
||||
assign_remap_locations(remap, assigned_comps, info,
|
||||
&cursor, &comp, MAX_VARYING,
|
||||
options);
|
||||
consumer->options->io_options);
|
||||
|
||||
/* Check if we failed to assign a remap location. This can happen if
|
||||
* for example there are a bunch of unmovable components with
|
||||
@@ -910,7 +873,7 @@ compact_components(nir_shader *producer, nir_shader *consumer,
|
||||
comp = 0;
|
||||
assign_remap_locations(remap, assigned_comps, info,
|
||||
&cursor, &comp, MAX_VARYING,
|
||||
options);
|
||||
consumer->options->io_options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1420,12 +1420,7 @@ void si_init_screen_get_functions(struct si_screen *sscreen)
|
||||
* when execution mode is rtz instead of rtne.
|
||||
*/
|
||||
options->force_f2f16_rtz = true;
|
||||
options->pack_varying_options = nir_pack_varying_interp_mode_none |
|
||||
nir_pack_varying_interp_mode_smooth |
|
||||
nir_pack_varying_interp_mode_noperspective |
|
||||
nir_pack_varying_interp_loc_center |
|
||||
nir_pack_varying_interp_loc_sample |
|
||||
nir_pack_varying_interp_loc_centroid;
|
||||
options->io_options = nir_io_has_flexible_input_interpolation_except_flat;
|
||||
options->lower_io_variables = true;
|
||||
/* HW supports indirect indexing for: | Enabled in driver
|
||||
* -------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user