Mesa (main): intel/compiler: add primitive rate output support

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 2 17:39:54 UTC 2022


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

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Tue Nov 10 18:08:31 2020 +0200

intel/compiler: add primitive rate output support

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13739>

---

 src/intel/compiler/brw_compiler.h     |  2 +-
 src/intel/compiler/brw_fs_visitor.cpp | 15 +++++++++++++--
 src/intel/compiler/brw_vue_map.c      |  9 +++++----
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index 094b0ef69c4..43cba2b30d7 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -1981,7 +1981,7 @@ static inline int
 brw_compute_first_urb_slot_required(uint64_t inputs_read,
                                     const struct brw_vue_map *prev_stage_vue_map)
 {
-   if ((inputs_read & (VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT)) == 0) {
+   if ((inputs_read & (VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT | VARYING_BIT_PRIMITIVE_SHADING_RATE)) == 0) {
       for (int i = 0; i < prev_stage_vue_map->num_slots; i++) {
          int varying = prev_stage_vue_map->slot_to_varying[i];
          if (varying > 0 && (inputs_read & BITFIELD64_BIT(varying)) != 0)
diff --git a/src/intel/compiler/brw_fs_visitor.cpp b/src/intel/compiler/brw_fs_visitor.cpp
index e19f487a7ce..5da019bf938 100644
--- a/src/intel/compiler/brw_fs_visitor.cpp
+++ b/src/intel/compiler/brw_fs_visitor.cpp
@@ -763,7 +763,7 @@ fs_visitor::emit_urb_writes(const fs_reg &gs_vertex_count)
    const struct brw_vs_prog_key *vs_key =
       (const struct brw_vs_prog_key *) this->key;
    const GLbitfield64 psiz_mask =
-      VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT | VARYING_BIT_PSIZ;
+      VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT | VARYING_BIT_PSIZ | VARYING_BIT_PRIMITIVE_SHADING_RATE;
    const struct brw_vue_map *vue_map = &vue_prog_data->vue_map;
    bool flush;
    fs_reg sources[8];
@@ -844,7 +844,18 @@ fs_visitor::emit_urb_writes(const fs_reg &gs_vertex_count)
          fs_reg zero(VGRF, alloc.allocate(1), BRW_REGISTER_TYPE_UD);
          bld.MOV(zero, brw_imm_ud(0u));
 
-         sources[length++] = zero;
+         if (vue_map->slots_valid & VARYING_BIT_PRIMITIVE_SHADING_RATE &&
+             this->outputs[VARYING_SLOT_PRIMITIVE_SHADING_RATE].file != BAD_FILE) {
+            sources[length++] = this->outputs[VARYING_SLOT_PRIMITIVE_SHADING_RATE];
+         } else if (devinfo->has_coarse_pixel_primitive_and_cb) {
+            uint32_t one_fp16 = 0x3C00;
+            fs_reg one_by_one_fp16(VGRF, alloc.allocate(1), BRW_REGISTER_TYPE_UD);
+            bld.MOV(one_by_one_fp16, brw_imm_ud((one_fp16 << 16) | one_fp16));
+            sources[length++] = one_by_one_fp16;
+         } else {
+            sources[length++] = zero;
+         }
+
          if (vue_map->slots_valid & VARYING_BIT_LAYER)
             sources[length++] = this->outputs[VARYING_SLOT_LAYER];
          else
diff --git a/src/intel/compiler/brw_vue_map.c b/src/intel/compiler/brw_vue_map.c
index d478ed4387d..b7f379d2e5a 100644
--- a/src/intel/compiler/brw_vue_map.c
+++ b/src/intel/compiler/brw_vue_map.c
@@ -86,10 +86,11 @@ brw_compute_vue_map(const struct intel_device_info *devinfo,
    vue_map->slots_valid = slots_valid;
    vue_map->separate = separate;
 
-   /* gl_Layer and gl_ViewportIndex don't get their own varying slots -- they
-    * are stored in the first VUE slot (VARYING_SLOT_PSIZ).
+   /* gl_Layer, gl_ViewportIndex & gl_PrimitiveShadingRateEXT don't get their
+    * own varying slots -- they are stored in the first VUE slot
+    * (VARYING_SLOT_PSIZ).
     */
-   slots_valid &= ~(VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT);
+   slots_valid &= ~(VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT | VARYING_BIT_PRIMITIVE_SHADING_RATE);
 
    /* Make sure that the values we store in vue_map->varying_to_slot and
     * vue_map->slot_to_varying won't overflow the signed chars that are used
@@ -126,7 +127,7 @@ brw_compute_vue_map(const struct intel_device_info *devinfo,
       assign_vue_slot(vue_map, VARYING_SLOT_POS, slot++);
    } else {
       /* There are 8 or 16 DWs (D0-D15) in VUE header on Sandybridge:
-       * dword 0-3 of the header is indices, point width, clip flags.
+       * dword 0-3 of the header is shading rate, indices, point width, clip flags.
        * dword 4-7 is the 4D space position
        * dword 8-15 of the vertex header is the user clip distance if
        * enabled.



More information about the mesa-commit mailing list