diff options
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir.h | 10 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_io.c | 20 |
2 files changed, 23 insertions, 7 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 94eae6d3037..6f0597200e9 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2397,9 +2397,17 @@ void nir_assign_var_locations(struct exec_list *var_list, unsigned *size, unsigned base_offset, int (*type_size)(const struct glsl_type *)); +typedef enum { + /* If set, this forces all non-flat fragment shader inputs to be + * interpolated as if with the "sample" qualifier. This requires + * nir_shader_compiler_options::use_interpolated_input_intrinsics. + */ + nir_lower_io_force_sample_interpolation = (1 << 1), +} nir_lower_io_options; void nir_lower_io(nir_shader *shader, nir_variable_mode modes, - int (*type_size)(const struct glsl_type *)); + int (*type_size)(const struct glsl_type *), + nir_lower_io_options); nir_src *nir_get_io_offset_src(nir_intrinsic_instr *instr); nir_src *nir_get_io_vertex_index_src(nir_intrinsic_instr *instr); diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index b36836f6f76..d469b6180f8 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -39,6 +39,7 @@ struct lower_io_state { void *mem_ctx; int (*type_size)(const struct glsl_type *type); nir_variable_mode modes; + nir_lower_io_options options; }; void @@ -205,7 +206,8 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state, assert(vertex_index == NULL); nir_intrinsic_op bary_op; - if (var->data.sample) + if (var->data.sample || + (state->options & nir_lower_io_force_sample_interpolation)) bary_op = nir_intrinsic_load_barycentric_sample; else if (var->data.centroid) bary_op = nir_intrinsic_load_barycentric_centroid; @@ -347,7 +349,9 @@ lower_interpolate_at(nir_intrinsic_instr *intrin, struct lower_io_state *state, nir_intrinsic_op bary_op; switch (intrin->intrinsic) { case nir_intrinsic_interp_var_at_centroid: - bary_op = nir_intrinsic_load_barycentric_centroid; + bary_op = (state->options & nir_lower_io_force_sample_interpolation) ? + nir_intrinsic_load_barycentric_sample : + nir_intrinsic_load_barycentric_centroid; break; case nir_intrinsic_interp_var_at_sample: bary_op = nir_intrinsic_load_barycentric_at_sample; @@ -505,7 +509,8 @@ nir_lower_io_block(nir_block *block, static void nir_lower_io_impl(nir_function_impl *impl, nir_variable_mode modes, - int (*type_size)(const struct glsl_type *)) + int (*type_size)(const struct glsl_type *), + nir_lower_io_options options) { struct lower_io_state state; @@ -513,6 +518,7 @@ nir_lower_io_impl(nir_function_impl *impl, state.mem_ctx = ralloc_parent(impl); state.modes = modes; state.type_size = type_size; + state.options = options; nir_foreach_block(block, impl) { nir_lower_io_block(block, &state); @@ -524,11 +530,13 @@ nir_lower_io_impl(nir_function_impl *impl, void nir_lower_io(nir_shader *shader, nir_variable_mode modes, - int (*type_size)(const struct glsl_type *)) + int (*type_size)(const struct glsl_type *), + nir_lower_io_options options) { nir_foreach_function(function, shader) { - if (function->impl) - nir_lower_io_impl(function->impl, modes, type_size); + if (function->impl) { + nir_lower_io_impl(function->impl, modes, type_size, options); + } } } |