Mesa (main): intel/fs: Set NonPerspectiveBarycentricEnable when the interpolator needs it.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 19 01:53:48 UTC 2022


Module: Mesa
Branch: main
Commit: 2d1f021e16204e28cec374258c1e3497e916ab6b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d1f021e16204e28cec374258c1e3497e916ab6b

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Thu Jul  7 12:24:38 2022 +0300

intel/fs: Set NonPerspectiveBarycentricEnable when the interpolator needs it.

[anholt: changed to make all drivers do the right thing by moving the
payload barycentric check into the compiler]

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17381>

---

 src/gallium/drivers/crocus/crocus_state.c | 4 +---
 src/gallium/drivers/iris/iris_state.c     | 4 +---
 src/intel/compiler/brw_compiler.h         | 9 ++++++++-
 src/intel/compiler/brw_fs.cpp             | 3 +++
 src/intel/compiler/brw_fs_nir.cpp         | 9 ++++++++-
 src/intel/vulkan/genX_pipeline.c          | 3 +--
 6 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/crocus/crocus_state.c b/src/gallium/drivers/crocus/crocus_state.c
index 6c4b6b0fb7f..910183b4564 100644
--- a/src/gallium/drivers/crocus/crocus_state.c
+++ b/src/gallium/drivers/crocus/crocus_state.c
@@ -6732,9 +6732,7 @@ crocus_upload_dirty_render_state(struct crocus_context *ice,
          cl.UserClipDistanceCullTestEnableBitmask =
             brw_vue_prog_data(ice->shaders.prog[MESA_SHADER_VERTEX]->prog_data)->cull_distance_mask;
 
-         if (wm_prog_data->barycentric_interp_modes &
-             BRW_BARYCENTRIC_NONPERSPECTIVE_BITS)
-            cl.NonPerspectiveBarycentricEnable = true;
+         cl.NonPerspectiveBarycentricEnable = wm_prog_data->uses_nonperspective_interp_modes;
 
          cl.ForceZeroRTAIndexEnable = cso_fb->layers <= 1;
          cl.MaximumVPIndex = ice->state.num_viewports - 1;
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 0dee74d082a..9e5c49ed094 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -6332,9 +6332,7 @@ iris_upload_dirty_render_state(struct iris_context *ice,
          cl.PerspectiveDivideDisable = ice->state.window_space_position;
          cl.ViewportXYClipTestEnable = !points_or_lines;
 
-         if (wm_prog_data->barycentric_interp_modes &
-             BRW_BARYCENTRIC_NONPERSPECTIVE_BITS)
-            cl.NonPerspectiveBarycentricEnable = true;
+         cl.NonPerspectiveBarycentricEnable = wm_prog_data->uses_nonperspective_interp_modes;
 
          cl.ForceZeroRTAIndexEnable = cso_fb->layers <= 1;
          cl.MaximumVPIndex = ice->state.num_viewports - 1;
diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index fec0a0a5bdc..148da906f1c 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -889,10 +889,17 @@ struct brw_wm_prog_data {
 
    /**
     * Mask of which interpolation modes are required by the fragment shader.
-    * Used in hardware setup on gfx6+.
+    * Those interpolations are delivered as part of the thread payload. Used
+    * in hardware setup on gfx6+.
     */
    uint32_t barycentric_interp_modes;
 
+   /**
+    * Whether nonperspective interpolation modes are used by the
+    * barycentric_interp_modes or fragment shader through interpolator messages.
+    */
+   bool uses_nonperspective_interp_modes;
+
    /**
     * Mask of which FS inputs are marked flat by the shader source.  This is
     * needed for setting up 3DSTATE_SF/SBE.
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 373f4f5975a..87d2394190e 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -7277,6 +7277,9 @@ brw_nir_populate_wm_prog_data(const nir_shader *shader,
 
    prog_data->barycentric_interp_modes =
       brw_compute_barycentric_interp_modes(devinfo, shader);
+   prog_data->uses_nonperspective_interp_modes |=
+      (prog_data->barycentric_interp_modes &
+      BRW_BARYCENTRIC_NONPERSPECTIVE_BITS) != 0;
 
    /* You can't be coarse and per-sample */
    assert(!key->coarse_pixel || !key->persample_interp);
diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp
index fabc46afb51..43bfc39d2f8 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -2168,7 +2168,14 @@ emit_pixel_interpolater_send(const fs_builder &bld,
    fs_inst *inst = bld.emit(opcode, dst, src, desc);
    /* 2 floats per slot returned */
    inst->size_written = 2 * dst.component_size(inst->exec_size);
-   inst->pi_noperspective = interpolation == INTERP_MODE_NOPERSPECTIVE;
+   if (interpolation == INTERP_MODE_NOPERSPECTIVE) {
+      inst->pi_noperspective = true;
+      /* TGL BSpec says:
+       *     This field cannot be set to "Linear Interpolation"
+       *     unless Non-Perspective Barycentric Enable in 3DSTATE_CLIP is enabled"
+       */
+      wm_prog_data->uses_nonperspective_interp_modes = true;
+   }
 
    wm_prog_data->pulls_bary = true;
 
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index bdce88f2ce2..38b76f2686b 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -1543,8 +1543,7 @@ emit_3dstate_clip(struct anv_graphics_pipeline *pipeline,
    clip.ViewportZClipTestEnable = pipeline->depth_clip_enable;
 #else
    clip.NonPerspectiveBarycentricEnable = wm_prog_data ?
-      (wm_prog_data->barycentric_interp_modes &
-       BRW_BARYCENTRIC_NONPERSPECTIVE_BITS) != 0 : 0;
+      wm_prog_data->uses_nonperspective_interp_modes : 0;
 #endif
 
    GENX(3DSTATE_CLIP_pack)(NULL, pipeline->gfx7.clip, &clip);



More information about the mesa-commit mailing list