nouveau: Skip cctl for atomic counters in tgsi
authorM Henning <drawoc@darkrefraction.com>
Sun, 30 Jan 2022 03:20:58 +0000 (22:20 -0500)
committerMarge Bot <emma+marge@anholt.net>
Tue, 19 Apr 2022 16:33:36 +0000 (16:33 +0000)
The tgsi path already marked all aliasing loads of atomic counters with
CACHE_CG, so we don't need to emit a cctl. This patch uses the cache
flag on the atomic to model whether the L1 cache needs the stale
values to be flushed or not.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14386>

src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp

index 20b9ca8..d843d67 100644 (file)
@@ -2962,6 +2962,10 @@ Converter::handleATOM(Value *dst0[4], DataType ty, uint16_t subOp)
          if (ind)
             insn->setIndirect(0, 1, ind);
          insn->subOp = subOp;
+
+         if (tgsi.getSrc(0).getFile() == TGSI_FILE_BUFFER &&
+             code->bufferAtomics[tgsi.getSrc(0).getIndex(0)])
+            insn->cache = nv50_ir::CACHE_CG;
       }
       for (int c = 0; c < 4; ++c)
          if (dst0[c])
index fbdc1b8..18e2192 100644 (file)
@@ -1708,6 +1708,10 @@ bool
 NVC0LoweringPass::handleATOMCctl(Instruction *atom) {
    // Flush L1 cache manually since atomics go directly to L2. This ensures
    // that any later CA reads retrieve the updated data.
+
+   if (atom->cache != nv50_ir::CACHE_CA)
+      return false;
+
    bld.setPosition(atom, true);
 
    Instruction *cctl = bld.mkOp1(OP_CCTL, TYPE_NONE, NULL, atom->getSrc(0));