aco/gfx10: NGG zero output workaround for conservative rasterization.

Navi 1x GPUs have an issue: they can hang when the output vertex
and primitive counts are zero. The workaround is exporting a dummy
triangle.

This commit changes the dummy triangle's vertex so its positions
are all NaN. This should make sure the triangle is never rendered.

Cc: mesa-stable
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10837>
This commit is contained in:
Timur Kristóf 2021-05-17 12:28:15 +02:00 committed by Marge Bot
parent 25314996d0
commit f9447abb36

View file

@ -11215,7 +11215,9 @@ void ngg_emit_sendmsg_gs_alloc_req(isel_context *ctx, Temp vtx_cnt, Temp prm_cnt
bld.sopp(aco_opcode::s_sendmsg, bld.m0(tmp), -1, sendmsg_gs_alloc_req);
if (prm_cnt_0.id()) {
/* Navi 1x workaround: export a zero-area triangle when GS has no output. */
/* Navi 1x workaround: export a triangle with NaN coordinates when GS has no output.
* It can't have all-zero positions because that would render an undesired pixel with conservative rasterization.
*/
Temp first_lane = bld.sop1(Builder::s_ff1_i32, bld.def(s1), Operand(exec, bld.lm));
Temp cond = bld.sop2(Builder::s_lshl, bld.def(bld.lm), bld.def(s1, scc),
Operand(1u, ctx->program->wave_size == 64), first_lane);
@ -11226,11 +11228,15 @@ void ngg_emit_sendmsg_gs_alloc_req(isel_context *ctx, Temp vtx_cnt, Temp prm_cnt
bld.reset(ctx->block);
ctx->block->kind |= block_kind_export_end;
/* Use zero: means that it's a triangle whose every vertex index is 0. */
Temp zero = bld.copy(bld.def(v1), Operand(0u));
/* Use NaN for the coordinates, so that the rasterizer allways culls it. */
Temp nan_coord = bld.copy(bld.def(v1), Operand(-1u));
bld.exp(aco_opcode::exp, zero, Operand(v1), Operand(v1), Operand(v1),
1 /* enabled mask */, V_008DFC_SQ_EXP_PRIM /* dest */,
false /* compressed */, true /* done */, false /* valid mask */);
bld.exp(aco_opcode::exp, zero, zero, zero, zero,
bld.exp(aco_opcode::exp, nan_coord, nan_coord, nan_coord, nan_coord,
0xf /* enabled mask */, V_008DFC_SQ_EXP_POS /* dest */,
false /* compressed */, true /* done */, true /* valid mask */);