23#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_SURFACE_FUNCTIONS_H
24#define HIP_INCLUDE_HIP_AMD_DETAIL_SURFACE_FUNCTIONS_H
26#if defined(__cplusplus)
28#if !defined(__HIPCC_RTC__)
31#include <hip/amd_detail/texture_fetch_functions.h>
32#include <hip/amd_detail/ockl_image.h>
35#if defined(__HIPCC_RTC__)
36#define __HOST_DEVICE__ __device__
38#define __HOST_DEVICE__ __host__ __device__
41#define __HIP_SURFACE_OBJECT_PARAMETERS_INIT \
42 unsigned int ADDRESS_SPACE_CONSTANT* i = (unsigned int ADDRESS_SPACE_CONSTANT*)surfObj;
41#define __HIP_SURFACE_OBJECT_PARAMETERS_INIT \ …
50static __HOST_DEVICE__ __forceinline__
int __hipGetPixelAddr(
int x,
int format,
int order) {
72 static const int FormatLUT[] = { 0, 1, 0, 1, 3, 1, 1, 1, 0, 1, 2, 0, 1, 2, 1, 2 };
73 x = FormatLUT[format] == 3 ? x / FormatLUT[format] : x >> FormatLUT[format];
100 static const int OrderLUT[] = { 0, 0, 1, 1, 3, 1, 3, 2, 2, 2, 2, 2, 3, 2, 2, 2, 0, 0, 0, 0 };
101 return x = OrderLUT[order] == 3 ? x / OrderLUT[order] : x >> OrderLUT[order];
114 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
115static __device__ __hip_img_chk__
void surf1Dread(T* data,
hipSurfaceObject_t surfObj,
int x,
118 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_1D(i), __ockl_image_channel_order_1D(i));
119 auto tmp = __ockl_image_load_1D(i, x);
120 *data = __hipMapFrom<T>(tmp);
132 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
133static __device__ __hip_img_chk__
void surf1Dwrite(T data,
hipSurfaceObject_t surfObj,
int x) {
135 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_1D(i), __ockl_image_channel_order_1D(i));
136 auto tmp = __hipMapTo<float4::Native_vec_>(data);
137 __ockl_image_store_1D(i, x, tmp);
151 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
152static __device__ __hip_img_chk__
void surf2Dread(T* data,
hipSurfaceObject_t surfObj,
int x,
int y) {
154 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_2D(i), __ockl_image_channel_order_2D(i));
155 auto tmp = __ockl_image_load_2D(i, int2(x, y).data);
156 *data = __hipMapFrom<T>(tmp);
170 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
171static __device__ __hip_img_chk__
void surf2Dwrite(T data,
hipSurfaceObject_t surfObj,
int x,
int y) {
173 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_2D(i), __ockl_image_channel_order_2D(i));
174 auto tmp = __hipMapTo<float4::Native_vec_>(data);
175 __ockl_image_store_2D(i, int2(x, y).data, tmp);
190 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
191static __device__ __hip_img_chk__
void surf3Dread(T* data,
hipSurfaceObject_t surfObj,
int x,
int y,
int z) {
193 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_3D(i), __ockl_image_channel_order_3D(i));
194 auto tmp = __ockl_image_load_3D(i, int4(x, y, z, 0).data);
195 *data = __hipMapFrom<T>(tmp);
210 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
211static __device__ __hip_img_chk__
void surf3Dwrite(T data,
hipSurfaceObject_t surfObj,
int x,
int y,
int z) {
213 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_3D(i), __ockl_image_channel_order_3D(i));
214 auto tmp = __hipMapTo<float4::Native_vec_>(data);
215 __ockl_image_store_3D(i, int4(x, y, z, 0).data, tmp);
229 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
230static __device__ __hip_img_chk__
void surf1DLayeredread(T* data,
hipSurfaceObject_t surfObj,
int x,
int layer) {
232 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_1D(i), __ockl_image_channel_order_1D(i));
233 auto tmp = __ockl_image_load_lod_1D(i, x, layer);
234 *data = __hipMapFrom<T>(tmp);
248 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
249static __device__ __hip_img_chk__
void surf1DLayeredwrite(T data,
hipSurfaceObject_t surfObj,
int x,
int layer) {
251 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_1D(i), __ockl_image_channel_order_1D(i));
252 auto tmp = __hipMapTo<float4::Native_vec_>(data);
253 __ockl_image_store_lod_1D(i, x, layer, tmp);
268 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
269static __device__ __hip_img_chk__
void surf2DLayeredread(T* data,
hipSurfaceObject_t surfObj,
int x,
int y,
int layer) {
271 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_2D(i), __ockl_image_channel_order_2D(i));
272 auto tmp = __ockl_image_load_lod_2D(i, int2(x, y).data, layer);
273 *data = __hipMapFrom<T>(tmp);
288 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
289static __device__ __hip_img_chk__
void surf2DLayeredwrite(T data,
hipSurfaceObject_t surfObj,
int x,
int y,
int layer) {
291 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_2D(i), __ockl_image_channel_order_2D(i));
292 auto tmp = __hipMapTo<float4::Native_vec_>(data);
293 __ockl_image_store_lod_2D(i, int2(x, y).data, layer, tmp);
308 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
309static __device__ __hip_img_chk__
void surfCubemapread(T* data,
hipSurfaceObject_t surfObj,
int x,
int y,
int face) {
311 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_2D(i), __ockl_image_channel_order_2D(i));
312 auto tmp = __ockl_image_load_CM(i, int2(x, y).data, face);
313 *data = __hipMapFrom<T>(tmp);
328 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
329static __device__ __hip_img_chk__
void surfCubemapwrite(T data,
hipSurfaceObject_t surfObj,
int x,
int y,
int face) {
331 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_2D(i), __ockl_image_channel_order_2D(i));
332 auto tmp = __hipMapTo<float4::Native_vec_>(data);
333 __ockl_image_store_CM(i, int2(x, y).data, face, tmp);
349 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
350static __device__ __hip_img_chk__
void surfCubemapLayeredread(T* data,
hipSurfaceObject_t surfObj,
int x,
int y,
int face,
353 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_2D(i), __ockl_image_channel_order_2D(i));
354 auto tmp = __ockl_image_load_lod_CM(i, int2(x, y).data, face, layer);
355 *data = __hipMapFrom<T>(tmp);
371 typename std::enable_if<__hip_is_tex_surf_channel_type<T>::value>::type* =
nullptr>
372static __device__ __hip_img_chk__
void surfCubemapLayeredwrite(T* data,
hipSurfaceObject_t surfObj,
int x,
int y,
int face,
375 x = __hipGetPixelAddr(x, __ockl_image_channel_data_type_2D(i), __ockl_image_channel_order_2D(i));
376 auto tmp = __hipMapTo<float4::Native_vec_>(data);
377 __ockl_image_store_lod_CM(i, int2(x, y).data, face, layer, tmp);
#define __HIP_SURFACE_OBJECT_PARAMETERS_INIT
Definition amd_surface_functions.h:41
#define __HOST_DEVICE__
Definition amd_surface_functions.h:38
Defines surface types for HIP runtime.
@ hipBoundaryModeZero
Definition surface_types.h:54
struct __hip_surface * hipSurfaceObject_t
Definition surface_types.h:41