radeonsi: fix max scrach lds size calculation when ngg
authorQiang Yu <yuq825@gmail.com>
Tue, 4 Apr 2023 01:42:24 +0000 (09:42 +0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 7 Apr 2023 03:42:25 +0000 (03:42 +0000)
Fixes: 028d0590f85 ("radeonsi: replace llvm ngg vs/tes with nir lowering")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22304>

src/gallium/drivers/radeonsi/gfx10_shader_ngg.c

index 2880f32..923dc79 100644 (file)
@@ -107,7 +107,9 @@ bool gfx10_ngg_calculate_subgroup_info(struct si_shader *shader)
    const unsigned min_verts_per_prim = gs_stage == MESA_SHADER_GEOMETRY ? max_verts_per_prim : 1;
 
    /* All these are in dwords. The maximum is 16K dwords (64KB) of LDS per workgroup. */
-   const unsigned max_lds_size = 16 * 1024 - gfx10_ngg_get_scratch_dw_size(shader);
+   const unsigned scratch_lds_size = gfx10_ngg_get_scratch_dw_size(shader);
+   /* Scrach is at last of LDS space and 2 dwords aligned, so it may cost more for alignment. */
+   const unsigned max_lds_size = 16 * 1024 - ALIGN(scratch_lds_size, 2);
    const unsigned target_lds_size = max_lds_size;
    unsigned esvert_lds_size = 0;
    unsigned gsprim_lds_size = 0;