[Mesa-dev] [PATCH 04/13] nir: add load/store_global intrinsics

Rob Clark robdclark at gmail.com
Wed Feb 28 19:51:34 UTC 2018


From: Karol Herbst <kherbst at redhat.com>

OpenCL kernels have raw pointers to global memory, so we need
instructions to load/store in order to dereference these pointers.
In some ways similar to other load/store intrinsics, but rather
than taking an offset as a src argument, they take a raw pointer
value (which can be 32b or 64b depending on the memory model).

Signed-off-by: Rob Clark <robdclark at gmail.com>
---
 src/compiler/nir/nir_intrinsics.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
index 0915c5e809f..fb58271931e 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -453,6 +453,8 @@ LOAD(shared, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
 /* src[] = { offset }. const_index[] = { base, range } */
 LOAD(push_constant, 1, 2, BASE, RANGE, xx,
      NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+/* src[] = { address }. No const_index */
+LOAD(global, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
 
 /*
  * Stores work the same way as loads, except now the first source is the value
@@ -474,8 +476,10 @@ STORE(per_vertex_output, 3, 3, BASE, WRMASK, COMPONENT, 0)
 STORE(ssbo, 3, 1, WRMASK, xx, xx, 0)
 /* src[] = { value, offset }. const_index[] = { base, write_mask } */
 STORE(shared, 2, 2, BASE, WRMASK, xx, 0)
+/* src[] = { value, address }. const_index[] = { write_mask } */
+STORE(global, 2, 2, BASE, WRMASK, xx, 0)
 
-LAST_INTRINSIC(store_shared)
+LAST_INTRINSIC(store_global)
 
 #undef DEFINE_SYSTEM_VALUE
 #undef INTRINSIC
-- 
2.14.3



More information about the mesa-dev mailing list