broadcom/compiler: force a last thrsw for spilling

As we don't know if we are going to have spilling or not, emit always a
last thrsw at the end of the shader.

If later we don't have spillings and we don't need that last thrsw, we
remove it and switch back to the previous one.

This way we ensure all the spilling happens always before the last
thrsw.

v2 (Juan):
 - Rework the code to force a last thrsw and remove later if no spilling

v3:
 - Merge functionality inside vir_emit_last_thrsw (Iago)
 - Add vir_restore_last_thrsw (Juan)

v4 (Iago):
 - Fix/add new comments
 - Rename variables/parameters

v5 (Iago):
 - Fix comments
 - Add assertion

Cc: mesa-stable
Fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4760
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12322>
This commit is contained in:
Juan A. Suarez Romero
2021-09-08 10:04:45 +02:00
committed by Marge Bot
parent 53c8b4c093
commit c98ddc778a
2 changed files with 59 additions and 21 deletions

View File

@@ -261,7 +261,7 @@ v3d_spill_reg(struct v3d_compile *c, int spill_temp)
}
struct qinst *last_thrsw = c->last_thrsw;
assert(!last_thrsw || last_thrsw->is_last_thrsw);
assert(last_thrsw && last_thrsw->is_last_thrsw);
int start_num_temps = c->num_temps;
@@ -347,29 +347,13 @@ v3d_spill_reg(struct v3d_compile *c, int spill_temp)
spill_offset);
}
}
/* If we didn't have a last-thrsw inserted by nir_to_vir and
* we've been inserting thrsws, then insert a new last_thrsw
* right before we start the vpm/tlb sequence for the last
* thread segment.
*/
if (!is_uniform && !last_thrsw && c->last_thrsw &&
(v3d_qpu_writes_vpm(&inst->qpu) ||
v3d_qpu_uses_tlb(&inst->qpu))) {
c->cursor = vir_before_inst(inst);
vir_emit_thrsw(c);
last_thrsw = c->last_thrsw;
last_thrsw->is_last_thrsw = true;
}
}
}
/* Make sure c->last_thrsw is the actual last thrsw, not just one we
* inserted in our most recent unspill.
*/
if (last_thrsw)
c->last_thrsw = last_thrsw;
c->last_thrsw = last_thrsw;
/* Don't allow spilling of our spilling instructions. There's no way
* they can help get things colored.