radv: fix computing the pervertex LDS size with NGG streamout
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 17 Nov 2022 07:07:25 +0000 (08:07 +0100)
committerEric Engestrom <eric@engestrom.ch>
Wed, 23 Nov 2022 19:12:00 +0000 (19:12 +0000)
The NGG streamout lowering pass allocates space for all outputs which
means we have to align our computation. Otherwise, the maximum number
of vertices is incorrect and we end up by reaching the maximum allowed
LDS size. This code could be shared instead of being duplicated but
that's for later.

Fixes some transform feedback tests with Zink and
RADV_PERFTEST=ngg_streamout on GFX10.3.

Cc: 22.3 mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19801>
(cherry picked from commit ba81dcf9715e8422b403fa79de4d8726a71eddbb)

.pick_status.json
src/amd/vulkan/radv_shader_info.c

index 6aae7e4..3fa2b1c 100644 (file)
         "description": "radv: fix computing the pervertex LDS size with NGG streamout",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
index 979dd28..e40570d 100644 (file)
@@ -1048,8 +1048,13 @@ gfx10_get_ngg_info(const struct radv_device *device, struct radv_pipeline_stage
       /* LDS size for passing data from GS to ES. */
       struct radv_streamout_info *so_info = &es_info->so;
 
-      if (so_info->num_outputs)
-         esvert_lds_size = 4 * so_info->num_outputs + 1;
+      if (so_info->num_outputs) {
+         /* Compute the same pervertex LDS size as the NGG streamout lowering pass which allocates
+          * space for all outputs.
+          * TODO: only alloc space for outputs that really need streamout.
+          */
+         esvert_lds_size = 4 * es_stage->nir->num_outputs + 1;
+      }
 
       /* GS stores Primitive IDs (one DWORD) into LDS at the address
        * corresponding to the ES thread of the provoking vertex. All