Module: Mesa
Branch: main
Commit: 56d61d9a644a9f3f6be55a424fc911fef051d8b5
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=56d61d9a644a9f3f6be55a424fc911fef051d8b5

Author: Alyssa Rosenzweig <[email protected]>
Date:   Thu Jun  8 09:24:13 2023 -0400

nir: Add fence_{pbe,mem}_to_tex(_pixel)_agx intrinsics

Read-after-write hazards require special handling on AGX, since image loads are
implemented with texturing. Add intrinsics to handle these hazards.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24148>

---

 src/compiler/nir/nir_intrinsics.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/compiler/nir/nir_intrinsics.py 
b/src/compiler/nir/nir_intrinsics.py
index 1f77528c922..aa31c81ff65 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -1749,6 +1749,19 @@ system_value("api_sample_mask_agx", 1, bit_sizes=[16])
 # Loads the sample position array as fixed point packed into a 32-bit word
 system_value("sample_positions_agx", 1, bit_sizes=[32])
 
+# Image loads go through the texture cache, which is not coherent with the PBE
+# or memory access, so fencing is necessary for writes to become visible.
+
+# Make writes via main memory (image atomics) visible for texturing.
+barrier("fence_pbe_to_tex_agx")
+
+# Make writes from global memory instructions (atomics) visible for texturing.
+barrier("fence_mem_to_tex_agx")
+
+# Variant of fence_pbe_to_tex_agx specialized to stores in pixel shaders that
+# act like render target writes, in conjunction with fragment interlock.
+barrier("fence_pbe_to_tex_pixel_agx")
+
 # Intel-specific query for loading from the brw_image_param struct passed
 # into the shader as a uniform.  The variable is a deref to the image
 # variable. The const index specifies which of the six parameters to load.

Reply via email to