diff --git a/src/intel/compiler/brw_compile_fs.cpp b/src/intel/compiler/brw_compile_fs.cpp index bc694032c6c..d7591a4cc3d 100644 --- a/src/intel/compiler/brw_compile_fs.cpp +++ b/src/intel/compiler/brw_compile_fs.cpp @@ -995,6 +995,8 @@ brw_nir_populate_wm_prog_data(nir_shader *shader, const unsigned offset_bary_modes = brw_compute_offset_barycentric_interp_modes(key, shader); + prog_data->vertex_attributes_bypass = brw_needs_vertex_attributes_bypass(shader); + prog_data->uses_npc_bary_coefficients = offset_bary_modes & INTEL_BARYCENTRIC_NONPERSPECTIVE_BITS; prog_data->uses_pc_bary_coefficients = diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h index c5fa20ca105..af4385b531e 100644 --- a/src/intel/compiler/brw_compiler.h +++ b/src/intel/compiler/brw_compiler.h @@ -722,6 +722,13 @@ struct brw_wm_prog_data { bool contains_flat_varying; bool contains_noperspective_varying; + /** Fragment shader barycentrics + * + * Request that the HW delta computation of attributes be turned off. This is needed + * when the FS has per-vertex inputs or reads BaryCoordKHR/BaryCoordNoPerspKHR. + */ + bool vertex_attributes_bypass; + /** True if the shader wants sample shading * * This corresponds to whether or not a gl_SampleId, gl_SamplePosition, or diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 90d172617f9..80a42401335 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -675,6 +675,25 @@ lower_indirect_primitive_id(nir_builder *b, return true; } +bool +brw_needs_vertex_attributes_bypass(const nir_shader *shader) +{ + /* Even if there are no actual per-vertex inputs, if the fragment + * shader uses BaryCoord*, we need to set everything accordingly + * so the barycentrics don't get reordered. + */ + if (BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_LINEAR_COORD) || + BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_PERSP_COORD)) + return true; + + nir_foreach_shader_in_variable(var, shader) { + if (var->data.per_vertex) + return true; + } + + return false; +} + void brw_nir_lower_fs_inputs(nir_shader *nir, const struct intel_device_info *devinfo, diff --git a/src/intel/compiler/brw_nir.h b/src/intel/compiler/brw_nir.h index 41a55c9e2e8..7fbc1871c07 100644 --- a/src/intel/compiler/brw_nir.h +++ b/src/intel/compiler/brw_nir.h @@ -181,6 +181,7 @@ bool brw_nir_lower_cs_intrinsics(nir_shader *nir, const struct intel_device_info *devinfo, struct brw_cs_prog_data *prog_data); bool brw_nir_lower_alpha_to_coverage(nir_shader *shader); +bool brw_needs_vertex_attributes_bypass(const nir_shader *shader); bool brw_nir_lower_fs_msaa(nir_shader *shader, const struct brw_wm_prog_key *key);