mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
pan/bi: rework memory barriers
The MEMORY_BARRIER instruction has some issues, where we end up dead-code eliminating it before it gets to do what it's supposed to do. But even if we fix that, we have issues where we can end up inserting flow control into it, which isn't going to work because we have nothing to emit here either. So let's rework this to a special-cased NOP instruction, which is marked as a scheduling barrier. The beneft here is that NOPs are already properly handled when it comes to flow control. Note that this isn't perfect either; this only prevents memory operations from crossing the scheduling barrier. We should really prevent any operation with observable side effects from crossing the barrier. This includes things like reading clocks etc. But that's a larger change, and it's a step in the right direction to get this to no longer be dead-code eliminated. So let's put this band-aid on for now. Fixes:f77a50e45e("pan/bi: add a MEMORY_BARRIER pseudo-instruction") Reviewed-by: Caterina Shablia <caterina.shablia@collabora.com> Reviewed-by: Olivia Lee <olivia.lee@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35502> (cherry picked from commit18893a250f)
This commit is contained in:
parent
33f6a87b75
commit
653f9e1239
6 changed files with 19 additions and 6 deletions
|
|
@ -10784,7 +10784,7 @@
|
|||
"description": "pan/bi: rework memory barriers",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "f77a50e45e5070c7dfdc081e4dc9acfd206f863d",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -191,6 +191,4 @@
|
|||
<src start="0"/>
|
||||
</ins>
|
||||
|
||||
<ins name="MEMORY_BARRIER" pseudo="true" unit="NONE"/>
|
||||
|
||||
</bifrost>
|
||||
|
|
|
|||
|
|
@ -154,8 +154,13 @@ create_dag(bi_context *ctx, bi_block *block, void *memctx)
|
|||
coverage = node;
|
||||
}
|
||||
if (I->op == BI_OPCODE_DISCARD_F32 ||
|
||||
I->op == BI_OPCODE_MEMORY_BARRIER) {
|
||||
/* Serialize against memory operations and barriers */
|
||||
bi_is_scheduling_barrier(I)) {
|
||||
/* Serialize against memory operations and barriers.
|
||||
*
|
||||
* TODO: This is *not* quite sufficient in the case of a scheduling
|
||||
* barrier. We need to serialize against *all* operations with
|
||||
* side-effects in that case.
|
||||
*/
|
||||
add_dep(node, memory_load);
|
||||
add_dep(node, memory_store);
|
||||
memory_load = node;
|
||||
|
|
|
|||
|
|
@ -2018,7 +2018,7 @@ bi_emit_intrinsic(bi_builder *b, nir_intrinsic_instr *instr)
|
|||
* scheduler from reordering memory operations around the barrier.
|
||||
* Avail and vis are trivially established.
|
||||
*/
|
||||
bi_memory_barrier(b);
|
||||
bi_nop(b)->scheduling_barrier = true;
|
||||
break;
|
||||
|
||||
case SCOPE_WORKGROUP:
|
||||
|
|
|
|||
|
|
@ -188,6 +188,9 @@ bi_side_effects(const bi_instr *I)
|
|||
if (bi_get_opcode_props(I)->last)
|
||||
return true;
|
||||
|
||||
if (bi_is_scheduling_barrier(I))
|
||||
return true;
|
||||
|
||||
switch (I->op) {
|
||||
case BI_OPCODE_DISCARD_F32:
|
||||
case BI_OPCODE_DISCARD_B32:
|
||||
|
|
|
|||
|
|
@ -520,6 +520,7 @@ typedef struct {
|
|||
bool combine; /* BRANCHC */
|
||||
bool format; /* LEA_TEX */
|
||||
bool z_stencil; /* LD_TILE */
|
||||
bool scheduling_barrier; /* NOP */
|
||||
|
||||
struct {
|
||||
enum bi_special special; /* FADD_RSCALE, FMA_RSCALE */
|
||||
|
|
@ -633,6 +634,12 @@ bi_is_staging_src(const bi_instr *I, unsigned s)
|
|||
return (s == 0 || s == 4) && bi_get_opcode_props(I)->sr_read;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
bi_is_scheduling_barrier(const bi_instr *I)
|
||||
{
|
||||
return I->op == BI_OPCODE_NOP && I->scheduling_barrier;
|
||||
}
|
||||
|
||||
/*
|
||||
* Safe helpers to remove destinations/sources at the end of the
|
||||
* destination/source array when changing opcodes. Unlike adding
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue