[Beignet] [PATCH] Add samplerless read image functions for 2D and 3D images.

Dag Lem dag at nimrod.no
Thu May 16 14:07:34 PDT 2013


Signed-off-by: Dag Lem <dag at nimrod.no>
---
 backend/src/ocl_stdlib.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/backend/src/ocl_stdlib.h b/backend/src/ocl_stdlib.h
index c184156..d72bdf6 100644
--- a/backend/src/ocl_stdlib.h
+++ b/backend/src/ocl_stdlib.h
@@ -806,6 +806,13 @@ OVERLOADABLE void __gen_ocl_write_imagef(uint surface_id, float u, float v, floa
     return __gen_ocl_read_image ##suffix(surface_id, sampler, coord.s0, coord.s1);\
   }
 
+#define DECL_READ_IMAGE_NOSAMPLER(type, suffix, coord_type) \
+  INLINE_OVERLOADABLE type read_image ##suffix(image2d_t cl_image, coord_type coord) \
+  {\
+    GET_IMAGE(cl_image, surface_id);\
+    return __gen_ocl_read_image ##suffix(surface_id, CLK_NORMALIZED_COORDS_FALSE|CLK_ADDRESS_NONE|CLK_FILTER_NEAREST, coord.s0, coord.s1);\
+  }
+
 #define DECL_WRITE_IMAGE(type, suffix, coord_type) \
   INLINE_OVERLOADABLE void write_image ##suffix(image2d_t cl_image, coord_type coord, type color)\
   {\
@@ -816,6 +823,7 @@ OVERLOADABLE void __gen_ocl_write_imagef(uint surface_id, float u, float v, floa
 #define DECL_IMAGE(type, suffix)        \
   DECL_READ_IMAGE(type, suffix, int2)   \
   DECL_READ_IMAGE(type, suffix, float2) \
+  DECL_READ_IMAGE_NOSAMPLER(type, suffix, int2) \
   DECL_WRITE_IMAGE(type, suffix, int2)   \
   DECL_WRITE_IMAGE(type, suffix, float2)
 
@@ -825,6 +833,7 @@ DECL_IMAGE(float4, f)
 
 #undef DECL_IMAGE
 #undef DECL_READ_IMAGE
+#undef DECL_READ_IMAGE_NOSAMPLER
 #undef DECL_WRITE_IMAGE
 
 #define DECL_READ_IMAGE(type, suffix, coord_type) \
@@ -834,6 +843,13 @@ DECL_IMAGE(float4, f)
     return __gen_ocl_read_image ## suffix(surface_id, (uint)sampler, coord.s0, coord.s1, coord.s2);\
   }
 
+#define DECL_READ_IMAGE_NOSAMPLER(type, suffix, coord_type) \
+  INLINE_OVERLOADABLE type read_image ## suffix(image3d_t cl_image, coord_type coord) \
+  {\
+    GET_IMAGE(cl_image, surface_id);\
+    return __gen_ocl_read_image ## suffix(surface_id, CLK_NORMALIZED_COORDS_FALSE|CLK_ADDRESS_NONE|CLK_FILTER_NEAREST, coord.s0, coord.s1, coord.s2);\
+  }
+
 #define DECL_WRITE_IMAGE(type, suffix, coord_type) \
   INLINE_OVERLOADABLE void write_image ## suffix(image3d_t cl_image, coord_type coord, type color)\
   {\
@@ -844,6 +860,7 @@ DECL_IMAGE(float4, f)
 #define DECL_IMAGE(type, suffix)        \
   DECL_READ_IMAGE(type, suffix, int4)   \
   DECL_READ_IMAGE(type, suffix, float4) \
+  DECL_READ_IMAGE_NOSAMPLER(type, suffix, int4) \
   DECL_WRITE_IMAGE(type, suffix, int4)   \
   DECL_WRITE_IMAGE(type, suffix, float4)
 
@@ -853,6 +870,7 @@ DECL_IMAGE(float4, f)
 
 #undef DECL_IMAGE
 #undef DECL_READ_IMAGE
+#undef DECL_READ_IMAGE_NOSAMPLER
 #undef DECL_WRITE_IMAGE
 
 #undef GET_IMAGE
-- 
1.8.1.4



More information about the Beignet mailing list