i965/fs: Use NIR for handling forced per-sample interpolation
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
ed65e6ef49
commit
246db0063e
|
@ -6378,8 +6378,7 @@ move_interpolation_to_top(nir_shader *nir)
|
||||||
static void
|
static void
|
||||||
brw_nir_set_default_interpolation(const struct gen_device_info *devinfo,
|
brw_nir_set_default_interpolation(const struct gen_device_info *devinfo,
|
||||||
struct nir_shader *nir,
|
struct nir_shader *nir,
|
||||||
bool api_flat_shade,
|
bool api_flat_shade)
|
||||||
bool per_sample_interpolation)
|
|
||||||
{
|
{
|
||||||
assert(nir->stage == MESA_SHADER_FRAGMENT);
|
assert(nir->stage == MESA_SHADER_FRAGMENT);
|
||||||
|
|
||||||
|
@ -6398,13 +6397,6 @@ brw_nir_set_default_interpolation(const struct gen_device_info *devinfo,
|
||||||
: INTERP_MODE_SMOOTH;
|
: INTERP_MODE_SMOOTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply 'sample' if necessary for API state. */
|
|
||||||
if (per_sample_interpolation &&
|
|
||||||
var->data.interpolation != INTERP_MODE_FLAT) {
|
|
||||||
var->data.centroid = false;
|
|
||||||
var->data.sample = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* On Ironlake and below, there is only one interpolation mode.
|
/* On Ironlake and below, there is only one interpolation mode.
|
||||||
* Centroid interpolation doesn't mean anything on this hardware --
|
* Centroid interpolation doesn't mean anything on this hardware --
|
||||||
* there is no multisampling.
|
* there is no multisampling.
|
||||||
|
@ -6414,32 +6406,6 @@ brw_nir_set_default_interpolation(const struct gen_device_info *devinfo,
|
||||||
var->data.sample = false;
|
var->data.sample = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (per_sample_interpolation) {
|
|
||||||
nir_foreach_block(block, nir_shader_get_entrypoint(nir)) {
|
|
||||||
nir_foreach_instr(instr, block) {
|
|
||||||
if (instr->type != nir_instr_type_intrinsic)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
|
||||||
if (intrin->intrinsic != nir_intrinsic_interp_var_at_centroid)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
nir_variable *var = intrin->variables[0]->var;
|
|
||||||
if (var->data.interpolation == INTERP_MODE_FLAT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* The description of the interpolateAtCentroid intrinsic is that
|
|
||||||
* it interpolates the variable as if it had the "centroid"
|
|
||||||
* qualifier. When executing with per_sample_interpolation, this
|
|
||||||
* is equivalent to having the "sample" qualifier. Just convert
|
|
||||||
* it to a load_var instead.
|
|
||||||
*/
|
|
||||||
assert(var->data.sample);
|
|
||||||
intrin->intrinsic = nir_intrinsic_load_var;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6500,8 +6466,8 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
|
||||||
shader = brw_nir_apply_sampler_key(shader, compiler->devinfo, &key->tex,
|
shader = brw_nir_apply_sampler_key(shader, compiler->devinfo, &key->tex,
|
||||||
true);
|
true);
|
||||||
brw_nir_set_default_interpolation(compiler->devinfo, shader,
|
brw_nir_set_default_interpolation(compiler->devinfo, shader,
|
||||||
key->flat_shade, key->persample_interp);
|
key->flat_shade);
|
||||||
brw_nir_lower_fs_inputs(shader);
|
brw_nir_lower_fs_inputs(shader, key);
|
||||||
brw_nir_lower_fs_outputs(shader);
|
brw_nir_lower_fs_outputs(shader);
|
||||||
if (!key->multisample_fbo)
|
if (!key->multisample_fbo)
|
||||||
NIR_PASS_V(shader, demote_sample_qualifiers);
|
NIR_PASS_V(shader, demote_sample_qualifiers);
|
||||||
|
|
|
@ -281,13 +281,18 @@ brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue_map)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
brw_nir_lower_fs_inputs(nir_shader *nir)
|
brw_nir_lower_fs_inputs(nir_shader *nir,
|
||||||
|
const struct brw_wm_prog_key *key)
|
||||||
{
|
{
|
||||||
foreach_list_typed(nir_variable, var, node, &nir->inputs) {
|
foreach_list_typed(nir_variable, var, node, &nir->inputs) {
|
||||||
var->data.driver_location = var->data.location;
|
var->data.driver_location = var->data.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_lower_io(nir, nir_var_shader_in, type_size_vec4, 0);
|
nir_lower_io_options lower_io_options = 0;
|
||||||
|
if (key->persample_interp)
|
||||||
|
lower_io_options |= nir_lower_io_force_sample_interpolation;
|
||||||
|
|
||||||
|
nir_lower_io(nir, nir_var_shader_in, type_size_vec4, lower_io_options);
|
||||||
|
|
||||||
/* This pass needs actual constants */
|
/* This pass needs actual constants */
|
||||||
nir_opt_constant_folding(nir);
|
nir_opt_constant_folding(nir);
|
||||||
|
|
|
@ -106,7 +106,8 @@ void brw_nir_lower_vs_inputs(nir_shader *nir,
|
||||||
void brw_nir_lower_vue_inputs(nir_shader *nir, bool is_scalar,
|
void brw_nir_lower_vue_inputs(nir_shader *nir, bool is_scalar,
|
||||||
const struct brw_vue_map *vue_map);
|
const struct brw_vue_map *vue_map);
|
||||||
void brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue);
|
void brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue);
|
||||||
void brw_nir_lower_fs_inputs(nir_shader *nir);
|
void brw_nir_lower_fs_inputs(nir_shader *nir,
|
||||||
|
const struct brw_wm_prog_key *key);
|
||||||
void brw_nir_lower_vue_outputs(nir_shader *nir, bool is_scalar);
|
void brw_nir_lower_vue_outputs(nir_shader *nir, bool is_scalar);
|
||||||
void brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue);
|
void brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue);
|
||||||
void brw_nir_lower_fs_outputs(nir_shader *nir);
|
void brw_nir_lower_fs_outputs(nir_shader *nir);
|
||||||
|
|
Loading…
Reference in New Issue