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

Author: Timur Kristóf <timur.kris...@gmail.com>
Date:   Fri Feb 17 12:59:08 2023 +0100

radv: Add extra offset to per-prim params.

Signed-off-by: Timur Kristóf <timur.kris...@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21409>

---

 src/amd/vulkan/radv_shader_info.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/amd/vulkan/radv_shader_info.c 
b/src/amd/vulkan/radv_shader_info.c
index 5fd2f46b2dd..c890dfcaa7c 100644
--- a/src/amd/vulkan/radv_shader_info.c
+++ b/src/amd/vulkan/radv_shader_info.c
@@ -319,20 +319,20 @@ gather_xfb_info(const nir_shader *nir, struct 
radv_shader_info *info)
 
 static void
 assign_outinfo_param(struct radv_vs_output_info *outinfo, gl_varying_slot idx,
-                     unsigned *total_param_exports)
+                     unsigned *total_param_exports, unsigned extra_offset)
 {
    if (outinfo->vs_output_param_offset[idx] == AC_EXP_PARAM_UNDEFINED)
-      outinfo->vs_output_param_offset[idx] = (*total_param_exports)++;
+      outinfo->vs_output_param_offset[idx] = extra_offset + 
(*total_param_exports)++;
 }
 
 static void
 assign_outinfo_params(struct radv_vs_output_info *outinfo, uint64_t mask,
-                      unsigned *total_param_exports)
+                      unsigned *total_param_exports, unsigned extra_offset)
 {
    u_foreach_bit64(idx, mask) {
       if (idx >= VARYING_SLOT_VAR0 || idx == VARYING_SLOT_LAYER ||
           idx == VARYING_SLOT_PRIMITIVE_ID || idx == VARYING_SLOT_VIEWPORT)
-         assign_outinfo_param(outinfo, idx, total_param_exports);
+         assign_outinfo_param(outinfo, idx, total_param_exports, extra_offset);
    }
 }
 
@@ -802,12 +802,18 @@ radv_nir_shader_info_pass(struct radv_device *device, 
const struct nir_shader *n
       unsigned total_param_exports = 0;
 
       /* Per-vertex outputs */
-      assign_outinfo_params(outinfo, per_vtx_mask, &total_param_exports);
+      assign_outinfo_params(outinfo, per_vtx_mask, &total_param_exports, 0);
 
       outinfo->param_exports = total_param_exports;
 
+      /* The HW always assumes that there is at least 1 per-vertex param.
+       * so if there aren't any, we have to offset per-primitive params by 1.
+       */
+      const unsigned extra_offset =
+         !!(total_param_exports == 0 && 
device->physical_device->rad_info.gfx_level >= GFX11);
+
       /* Per-primitive outputs: the HW needs these to be last. */
-      assign_outinfo_params(outinfo, per_prim_mask, &total_param_exports);
+      assign_outinfo_params(outinfo, per_prim_mask, &total_param_exports, 
extra_offset);
 
       outinfo->prim_param_exports = total_param_exports - 
outinfo->param_exports;
    }

Reply via email to