hsa_ext_image.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2014-2020 Advanced Micro Devices Inc. All rights reserved.
  4. //
  5. // Permission is hereby granted, free of charge, to any person or organization
  6. // obtaining a copy of the software and accompanying documentation covered by
  7. // this license (the "Software") to use, reproduce, display, distribute,
  8. // execute, and transmit the Software, and to prepare derivative works of the
  9. // Software, and to permit third-parties to whom the Software is furnished to
  10. // do so, all subject to the following:
  11. //
  12. // The copyright notices in the Software and this entire statement, including
  13. // the above license grant, this restriction and the following disclaimer,
  14. // must be included in all copies of the Software, in whole or in part, and
  15. // all derivative works of the Software, unless such copies or derivative
  16. // works are solely in the form of machine-executable object code generated by
  17. // a source language processor.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  22. // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  23. // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  24. // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. // DEALINGS IN THE SOFTWARE.
  26. //
  27. ////////////////////////////////////////////////////////////////////////////////
  28. #ifndef HSA_EXT_IMAGE_H
  29. #define HSA_EXT_IMAGE_H
  30. #include "hsa.h"
  31. #undef HSA_API
  32. #ifdef HSA_EXPORT_IMAGES
  33. #define HSA_API HSA_API_EXPORT
  34. #else
  35. #define HSA_API HSA_API_IMPORT
  36. #endif
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif /*__cplusplus*/
  40. /** \defgroup ext-images Images and Samplers
  41. * @{
  42. */
  43. /**
  44. * @brief Enumeration constants added to ::hsa_status_t by this extension.
  45. *
  46. * @remark Additions to hsa_status_t
  47. */
  48. enum {
  49. /**
  50. * Image format is not supported.
  51. */
  52. HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED = 0x3000,
  53. /**
  54. * Image size is not supported.
  55. */
  56. HSA_EXT_STATUS_ERROR_IMAGE_SIZE_UNSUPPORTED = 0x3001,
  57. /**
  58. * Image pitch is not supported or invalid.
  59. */
  60. HSA_EXT_STATUS_ERROR_IMAGE_PITCH_UNSUPPORTED = 0x3002,
  61. /**
  62. * Sampler descriptor is not supported or invalid.
  63. */
  64. HSA_EXT_STATUS_ERROR_SAMPLER_DESCRIPTOR_UNSUPPORTED = 0x3003
  65. };
  66. /**
  67. * @brief Enumeration constants added to ::hsa_agent_info_t by this
  68. * extension.
  69. *
  70. * @remark Additions to hsa_agent_info_t
  71. */
  72. enum {
  73. /**
  74. * Maximum number of elements in 1D images. Must be at least 16384. The type
  75. * of this attribute is size_t.
  76. */
  77. HSA_EXT_AGENT_INFO_IMAGE_1D_MAX_ELEMENTS = 0x3000,
  78. /**
  79. * Maximum number of elements in 1DA images. Must be at least 16384. The type
  80. * of this attribute is size_t.
  81. */
  82. HSA_EXT_AGENT_INFO_IMAGE_1DA_MAX_ELEMENTS = 0x3001,
  83. /**
  84. * Maximum number of elements in 1DB images. Must be at least 65536. The type
  85. * of this attribute is size_t.
  86. */
  87. HSA_EXT_AGENT_INFO_IMAGE_1DB_MAX_ELEMENTS = 0x3002,
  88. /**
  89. * Maximum dimensions (width, height) of 2D images, in image elements. The X
  90. * and Y maximums must be at least 16384. The type of this attribute is
  91. * size_t[2].
  92. */
  93. HSA_EXT_AGENT_INFO_IMAGE_2D_MAX_ELEMENTS = 0x3003,
  94. /**
  95. * Maximum dimensions (width, height) of 2DA images, in image elements. The X
  96. * and Y maximums must be at least 16384. The type of this attribute is
  97. * size_t[2].
  98. */
  99. HSA_EXT_AGENT_INFO_IMAGE_2DA_MAX_ELEMENTS = 0x3004,
  100. /**
  101. * Maximum dimensions (width, height) of 2DDEPTH images, in image
  102. * elements. The X and Y maximums must be at least 16384. The type of this
  103. * attribute is size_t[2].
  104. */
  105. HSA_EXT_AGENT_INFO_IMAGE_2DDEPTH_MAX_ELEMENTS = 0x3005,
  106. /**
  107. * Maximum dimensions (width, height) of 2DADEPTH images, in image
  108. * elements. The X and Y maximums must be at least 16384. The type of this
  109. * attribute is size_t[2].
  110. */
  111. HSA_EXT_AGENT_INFO_IMAGE_2DADEPTH_MAX_ELEMENTS = 0x3006,
  112. /**
  113. * Maximum dimensions (width, height, depth) of 3D images, in image
  114. * elements. The maximum along any dimension must be at least 2048. The type
  115. * of this attribute is size_t[3].
  116. */
  117. HSA_EXT_AGENT_INFO_IMAGE_3D_MAX_ELEMENTS = 0x3007,
  118. /**
  119. * Maximum number of image layers in a image array. Must be at least 2048. The
  120. * type of this attribute is size_t.
  121. */
  122. HSA_EXT_AGENT_INFO_IMAGE_ARRAY_MAX_LAYERS = 0x3008,
  123. /**
  124. * Maximum number of read-only image handles that can be created for an agent at any one
  125. * time. Must be at least 128. The type of this attribute is size_t.
  126. */
  127. HSA_EXT_AGENT_INFO_MAX_IMAGE_RD_HANDLES = 0x3009,
  128. /**
  129. * Maximum number of write-only and read-write image handles (combined) that
  130. * can be created for an agent at any one time. Must be at least 64. The type of this
  131. * attribute is size_t.
  132. */
  133. HSA_EXT_AGENT_INFO_MAX_IMAGE_RORW_HANDLES = 0x300A,
  134. /**
  135. * Maximum number of sampler handlers that can be created for an agent at any one
  136. * time. Must be at least 16. The type of this attribute is size_t.
  137. */
  138. HSA_EXT_AGENT_INFO_MAX_SAMPLER_HANDLERS = 0x300B,
  139. /**
  140. * Image pitch alignment. The agent only supports linear image data
  141. * layouts with a row pitch that is a multiple of this value. Must be
  142. * a power of 2. The type of this attribute is size_t.
  143. */
  144. HSA_EXT_AGENT_INFO_IMAGE_LINEAR_ROW_PITCH_ALIGNMENT = 0x300C
  145. };
  146. /**
  147. * @brief Image handle, populated by ::hsa_ext_image_create or
  148. * ::hsa_ext_image_create_with_layout. Image
  149. * handles are only unique within an agent, not across agents.
  150. *
  151. */
  152. typedef struct hsa_ext_image_s {
  153. /**
  154. * Opaque handle. For a given agent, two handles reference the same object of
  155. * the enclosing type if and only if they are equal.
  156. */
  157. uint64_t handle;
  158. } hsa_ext_image_t;
  159. /**
  160. * @brief Geometry associated with the image. This specifies the
  161. * number of image dimensions and whether the image is an image
  162. * array. See the <em>Image Geometry</em> section in the <em>HSA
  163. * Programming Reference Manual</em> for definitions on each
  164. * geometry. The enumeration values match the BRIG type @p
  165. * hsa_ext_brig_image_geometry_t.
  166. */
  167. typedef enum {
  168. /**
  169. * One-dimensional image addressed by width coordinate.
  170. */
  171. HSA_EXT_IMAGE_GEOMETRY_1D = 0,
  172. /**
  173. * Two-dimensional image addressed by width and height coordinates.
  174. */
  175. HSA_EXT_IMAGE_GEOMETRY_2D = 1,
  176. /**
  177. * Three-dimensional image addressed by width, height, and depth coordinates.
  178. */
  179. HSA_EXT_IMAGE_GEOMETRY_3D = 2,
  180. /**
  181. * Array of one-dimensional images with the same size and format. 1D arrays
  182. * are addressed by width and index coordinate.
  183. */
  184. HSA_EXT_IMAGE_GEOMETRY_1DA = 3,
  185. /**
  186. * Array of two-dimensional images with the same size and format. 2D arrays
  187. * are addressed by width, height, and index coordinates.
  188. */
  189. HSA_EXT_IMAGE_GEOMETRY_2DA = 4,
  190. /**
  191. * One-dimensional image addressed by width coordinate. It has
  192. * specific restrictions compared to ::HSA_EXT_IMAGE_GEOMETRY_1D. An
  193. * image with an opaque image data layout will always use a linear
  194. * image data layout, and one with an explicit image data layout
  195. * must specify ::HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR.
  196. */
  197. HSA_EXT_IMAGE_GEOMETRY_1DB = 5,
  198. /**
  199. * Two-dimensional depth image addressed by width and height coordinates.
  200. */
  201. HSA_EXT_IMAGE_GEOMETRY_2DDEPTH = 6,
  202. /**
  203. * Array of two-dimensional depth images with the same size and format. 2D
  204. * arrays are addressed by width, height, and index coordinates.
  205. */
  206. HSA_EXT_IMAGE_GEOMETRY_2DADEPTH = 7
  207. } hsa_ext_image_geometry_t;
  208. /**
  209. * @brief Channel type associated with the elements of an image. See
  210. * the <em>Channel Type</em> section in the <em>HSA Programming Reference
  211. * Manual</em> for definitions on each channel type. The
  212. * enumeration values and definition match the BRIG type @p
  213. * hsa_ext_brig_image_channel_type_t.
  214. */
  215. typedef enum {
  216. HSA_EXT_IMAGE_CHANNEL_TYPE_SNORM_INT8 = 0,
  217. HSA_EXT_IMAGE_CHANNEL_TYPE_SNORM_INT16 = 1,
  218. HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_INT8 = 2,
  219. HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_INT16 = 3,
  220. HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_INT24 = 4,
  221. HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555 = 5,
  222. HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565 = 6,
  223. HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_SHORT_101010 = 7,
  224. HSA_EXT_IMAGE_CHANNEL_TYPE_SIGNED_INT8 = 8,
  225. HSA_EXT_IMAGE_CHANNEL_TYPE_SIGNED_INT16 = 9,
  226. HSA_EXT_IMAGE_CHANNEL_TYPE_SIGNED_INT32 = 10,
  227. HSA_EXT_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8 = 11,
  228. HSA_EXT_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16 = 12,
  229. HSA_EXT_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32 = 13,
  230. HSA_EXT_IMAGE_CHANNEL_TYPE_HALF_FLOAT = 14,
  231. HSA_EXT_IMAGE_CHANNEL_TYPE_FLOAT = 15
  232. } hsa_ext_image_channel_type_t;
  233. /**
  234. * @brief A fixed-size type used to represent ::hsa_ext_image_channel_type_t constants.
  235. */
  236. typedef uint32_t hsa_ext_image_channel_type32_t;
  237. /**
  238. *
  239. * @brief Channel order associated with the elements of an image. See
  240. * the <em>Channel Order</em> section in the <em>HSA Programming Reference
  241. * Manual</em> for definitions on each channel order. The
  242. * enumeration values match the BRIG type @p
  243. * hsa_ext_brig_image_channel_order_t.
  244. */
  245. typedef enum {
  246. HSA_EXT_IMAGE_CHANNEL_ORDER_A = 0,
  247. HSA_EXT_IMAGE_CHANNEL_ORDER_R = 1,
  248. HSA_EXT_IMAGE_CHANNEL_ORDER_RX = 2,
  249. HSA_EXT_IMAGE_CHANNEL_ORDER_RG = 3,
  250. HSA_EXT_IMAGE_CHANNEL_ORDER_RGX = 4,
  251. HSA_EXT_IMAGE_CHANNEL_ORDER_RA = 5,
  252. HSA_EXT_IMAGE_CHANNEL_ORDER_RGB = 6,
  253. HSA_EXT_IMAGE_CHANNEL_ORDER_RGBX = 7,
  254. HSA_EXT_IMAGE_CHANNEL_ORDER_RGBA = 8,
  255. HSA_EXT_IMAGE_CHANNEL_ORDER_BGRA = 9,
  256. HSA_EXT_IMAGE_CHANNEL_ORDER_ARGB = 10,
  257. HSA_EXT_IMAGE_CHANNEL_ORDER_ABGR = 11,
  258. HSA_EXT_IMAGE_CHANNEL_ORDER_SRGB = 12,
  259. HSA_EXT_IMAGE_CHANNEL_ORDER_SRGBX = 13,
  260. HSA_EXT_IMAGE_CHANNEL_ORDER_SRGBA = 14,
  261. HSA_EXT_IMAGE_CHANNEL_ORDER_SBGRA = 15,
  262. HSA_EXT_IMAGE_CHANNEL_ORDER_INTENSITY = 16,
  263. HSA_EXT_IMAGE_CHANNEL_ORDER_LUMINANCE = 17,
  264. HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH = 18,
  265. HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH_STENCIL = 19
  266. } hsa_ext_image_channel_order_t;
  267. /**
  268. * @brief A fixed-size type used to represent ::hsa_ext_image_channel_order_t constants.
  269. */
  270. typedef uint32_t hsa_ext_image_channel_order32_t;
  271. /**
  272. * @brief Image format.
  273. */
  274. typedef struct hsa_ext_image_format_s {
  275. /**
  276. * Channel type.
  277. */
  278. hsa_ext_image_channel_type32_t channel_type;
  279. /**
  280. * Channel order.
  281. */
  282. hsa_ext_image_channel_order32_t channel_order;
  283. } hsa_ext_image_format_t;
  284. /**
  285. * @brief Implementation independent image descriptor.
  286. */
  287. typedef struct hsa_ext_image_descriptor_s {
  288. /**
  289. * Image geometry.
  290. */
  291. hsa_ext_image_geometry_t geometry;
  292. /**
  293. * Width of the image, in components.
  294. */
  295. size_t width;
  296. /**
  297. * Height of the image, in components. Only used if the geometry is
  298. * ::HSA_EXT_IMAGE_GEOMETRY_2D, ::HSA_EXT_IMAGE_GEOMETRY_3D,
  299. * HSA_EXT_IMAGE_GEOMETRY_2DA, HSA_EXT_IMAGE_GEOMETRY_2DDEPTH, or
  300. * HSA_EXT_IMAGE_GEOMETRY_2DADEPTH, otherwise must be 0.
  301. */
  302. size_t height;
  303. /**
  304. * Depth of the image, in components. Only used if the geometry is
  305. * ::HSA_EXT_IMAGE_GEOMETRY_3D, otherwise must be 0.
  306. */
  307. size_t depth;
  308. /**
  309. * Number of image layers in the image array. Only used if the geometry is
  310. * ::HSA_EXT_IMAGE_GEOMETRY_1DA, ::HSA_EXT_IMAGE_GEOMETRY_2DA, or
  311. * HSA_EXT_IMAGE_GEOMETRY_2DADEPTH, otherwise must be 0.
  312. */
  313. size_t array_size;
  314. /**
  315. * Image format.
  316. */
  317. hsa_ext_image_format_t format;
  318. } hsa_ext_image_descriptor_t;
  319. /**
  320. * @brief Image capability.
  321. */
  322. typedef enum {
  323. /**
  324. * Images of this geometry, format, and layout are not supported by
  325. * the agent.
  326. */
  327. HSA_EXT_IMAGE_CAPABILITY_NOT_SUPPORTED = 0x0,
  328. /**
  329. * Read-only images of this geometry, format, and layout are
  330. * supported by the agent.
  331. */
  332. HSA_EXT_IMAGE_CAPABILITY_READ_ONLY = 0x1,
  333. /**
  334. * Write-only images of this geometry, format, and layout are
  335. * supported by the agent.
  336. */
  337. HSA_EXT_IMAGE_CAPABILITY_WRITE_ONLY = 0x2,
  338. /**
  339. * Read-write images of this geometry, format, and layout are
  340. * supported by the agent.
  341. */
  342. HSA_EXT_IMAGE_CAPABILITY_READ_WRITE = 0x4,
  343. /**
  344. * @deprecated Images of this geometry, format, and layout can be accessed from
  345. * read-modify-write atomic operations in the agent.
  346. */
  347. HSA_EXT_IMAGE_CAPABILITY_READ_MODIFY_WRITE = 0x8,
  348. /**
  349. * Images of this geometry, format, and layout are guaranteed to
  350. * have a consistent data layout regardless of how they are
  351. * accessed by the associated agent.
  352. */
  353. HSA_EXT_IMAGE_CAPABILITY_ACCESS_INVARIANT_DATA_LAYOUT = 0x10
  354. } hsa_ext_image_capability_t;
  355. /**
  356. * @brief Image data layout.
  357. *
  358. * @details An image data layout denotes such aspects of image data
  359. * layout as tiling and organization of channels in memory. Some image
  360. * data layouts may only apply to specific image geometries, formats,
  361. * and access permissions. Different agents may support different
  362. * image layout identifiers, including vendor specific layouts. Note
  363. * that an agent may not support the same image data layout for
  364. * different access permissions to images with the same image
  365. * geometry, size, and format. If multiple agents support the same
  366. * image data layout then it is possible to use separate image handles
  367. * for each agent that references the same image data.
  368. */
  369. typedef enum {
  370. /**
  371. * An implementation specific opaque image data layout which can
  372. * vary depending on the agent, geometry, image format, image size,
  373. * and access permissions.
  374. */
  375. HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE = 0x0,
  376. /**
  377. * The image data layout is specified by the following rules in
  378. * ascending byte address order. For a 3D image, 2DA image array,
  379. * or 1DA image array, the image data is stored as a linear sequence
  380. * of adjacent 2D image slices, 2D images, or 1D images
  381. * respectively, spaced according to the slice pitch. Each 2D image
  382. * is stored as a linear sequence of adjacent image rows, spaced
  383. * according to the row pitch. Each 1D or 1DB image is stored as a
  384. * single image row. Each image row is stored as a linear sequence
  385. * of image elements. Each image element is stored as a linear
  386. * sequence of image components specified by the left to right
  387. * channel order definition. Each image component is stored using
  388. * the memory type specified by the channel type.
  389. *
  390. * The 1DB image geometry always uses the linear image data layout.
  391. */
  392. HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR = 0x1
  393. } hsa_ext_image_data_layout_t;
  394. /**
  395. * @brief Retrieve the supported image capabilities for a given combination of
  396. * agent, geometry, and image format for an image created with an opaque image
  397. * data layout.
  398. *
  399. * @param[in] agent Agent to be associated with the image handle.
  400. *
  401. * @param[in] geometry Geometry.
  402. *
  403. * @param[in] image_format Pointer to an image format. Must not be NULL.
  404. *
  405. * @param[out] capability_mask Pointer to a memory location where the HSA
  406. * runtime stores a bit-mask of supported image capability
  407. * (::hsa_ext_image_capability_t) values. Must not be NULL.
  408. *
  409. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  410. *
  411. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  412. * initialized.
  413. *
  414. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  415. *
  416. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p image_format is
  417. * NULL, or @p capability_mask is NULL.
  418. */
  419. hsa_status_t HSA_API hsa_ext_image_get_capability(
  420. hsa_agent_t agent,
  421. hsa_ext_image_geometry_t geometry,
  422. const hsa_ext_image_format_t *image_format,
  423. uint32_t *capability_mask);
  424. /**
  425. * @brief Retrieve the supported image capabilities for a given combination of
  426. * agent, geometry, image format, and image layout for an image created with
  427. * an explicit image data layout.
  428. *
  429. * @param[in] agent Agent to be associated with the image handle.
  430. *
  431. * @param[in] geometry Geometry.
  432. *
  433. * @param[in] image_format Pointer to an image format. Must not be NULL.
  434. *
  435. * @param[in] image_data_layout The image data layout.
  436. * It is invalid to use ::HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE; use
  437. * ::hsa_ext_image_get_capability instead.
  438. *
  439. * @param[out] capability_mask Pointer to a memory location where the HSA
  440. * runtime stores a bit-mask of supported image capability
  441. * (::hsa_ext_image_capability_t) values. Must not be NULL.
  442. *
  443. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  444. *
  445. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  446. * initialized.
  447. *
  448. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  449. *
  450. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p image_format is
  451. * NULL, @p image_data_layout is ::HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE,
  452. * or @p capability_mask is NULL.
  453. */
  454. hsa_status_t HSA_API hsa_ext_image_get_capability_with_layout(
  455. hsa_agent_t agent,
  456. hsa_ext_image_geometry_t geometry,
  457. const hsa_ext_image_format_t *image_format,
  458. hsa_ext_image_data_layout_t image_data_layout,
  459. uint32_t *capability_mask);
  460. /**
  461. * @brief Agent specific image size and alignment requirements, populated by
  462. * ::hsa_ext_image_data_get_info and ::hsa_ext_image_data_get_info_with_layout.
  463. */
  464. typedef struct hsa_ext_image_data_info_s {
  465. /**
  466. * Image data size, in bytes.
  467. */
  468. size_t size;
  469. /**
  470. * Image data alignment, in bytes. Must always be a power of 2.
  471. */
  472. size_t alignment;
  473. } hsa_ext_image_data_info_t;
  474. /**
  475. * @brief Retrieve the image data requirements for a given combination of agent, image
  476. * descriptor, and access permission for an image created with an opaque image
  477. * data layout.
  478. *
  479. * @details The optimal image data size and alignment requirements may
  480. * vary depending on the image attributes specified in @p
  481. * image_descriptor, the @p access_permission, and the @p agent. Also,
  482. * different implementations of the HSA runtime may return different
  483. * requirements for the same input values.
  484. *
  485. * The implementation must return the same image data requirements for
  486. * different access permissions with matching image descriptors as long
  487. * as ::hsa_ext_image_get_capability reports
  488. * ::HSA_EXT_IMAGE_CAPABILITY_ACCESS_INVARIANT_DATA_LAYOUT. Image
  489. * descriptors match if they have the same values, with the exception
  490. * that s-form channel orders match the corresponding non-s-form
  491. * channel order and vice versa.
  492. *
  493. * @param[in] agent Agent to be associated with the image handle.
  494. *
  495. * @param[in] image_descriptor Pointer to an image descriptor. Must not be NULL.
  496. *
  497. * @param[in] access_permission Access permission of the image when
  498. * accessed by @p agent. The access permission defines how the agent
  499. * is allowed to access the image and must match the corresponding
  500. * HSAIL image handle type. The @p agent must support the image format
  501. * specified in @p image_descriptor for the given @p
  502. * access_permission.
  503. *
  504. * @param[out] image_data_info Memory location where the runtime stores the
  505. * size and alignment requirements. Must not be NULL.
  506. *
  507. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  508. *
  509. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  510. * initialized.
  511. *
  512. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  513. *
  514. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED The @p
  515. * agent does not support the image format specified by @p
  516. * image_descriptor with the specified @p access_permission.
  517. *
  518. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_SIZE_UNSUPPORTED The agent
  519. * does not support the image dimensions specified by @p
  520. * image_descriptor with the specified @p access_permission.
  521. *
  522. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p image_descriptor is NULL, @p
  523. * access_permission is not a valid access permission value, or @p
  524. * image_data_info is NULL.
  525. */
  526. hsa_status_t HSA_API hsa_ext_image_data_get_info(
  527. hsa_agent_t agent,
  528. const hsa_ext_image_descriptor_t *image_descriptor,
  529. hsa_access_permission_t access_permission,
  530. hsa_ext_image_data_info_t *image_data_info);
  531. /**
  532. * @brief Retrieve the image data requirements for a given combination of
  533. * image descriptor, access permission, image data layout, image data row pitch,
  534. * and image data slice pitch for an image created with an explicit image
  535. * data layout.
  536. *
  537. * @details The image data size and alignment requirements may vary
  538. * depending on the image attributes specified in @p image_descriptor,
  539. * the @p access_permission, and the image layout. However, different
  540. * implementations of the HSA runtime will return the same
  541. * requirements for the same input values.
  542. *
  543. * The implementation must return the same image data requirements for
  544. * different access permissions with matching image descriptors and
  545. * matching image layouts as long as ::hsa_ext_image_get_capability
  546. * reports
  547. * ::HSA_EXT_IMAGE_CAPABILITY_ACCESS_INVARIANT_DATA_LAYOUT. Image
  548. * descriptors match if they have the same values, with the exception
  549. * that s-form channel orders match the corresponding non-s-form
  550. * channel order and vice versa. Image layouts match if they are the
  551. * same image data layout and use the same image row and slice pitch
  552. * values.
  553. *
  554. * @param[in] image_descriptor Pointer to an image descriptor. Must not be NULL.
  555. *
  556. * @param[in] access_permission Access permission of the image when
  557. * accessed by an agent. The access permission defines how the agent
  558. * is allowed to access the image and must match the corresponding
  559. * HSAIL image handle type.
  560. *
  561. * @param[in] image_data_layout The image data layout to use.
  562. * It is invalid to use ::HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE; use
  563. * ::hsa_ext_image_data_get_info instead.
  564. *
  565. * @param[in] image_data_row_pitch The size in bytes for a single row
  566. * of the image in the image data. If 0 is specified then the default
  567. * row pitch value is used: image width * image element byte size.
  568. * The value used must be greater than or equal to the default row
  569. * pitch, and be a multiple of the image element byte size. For the
  570. * linear image layout it must also be a multiple of the image linear
  571. * row pitch alignment for the agents that will access the image data
  572. * using image instructions.
  573. *
  574. * @param[in] image_data_slice_pitch The size in bytes of a single
  575. * slice of a 3D image, or the size in bytes of each image layer in an
  576. * image array in the image data. If 0 is specified then the default
  577. * slice pitch value is used: row pitch * height if geometry is
  578. * ::HSA_EXT_IMAGE_GEOMETRY_3D, ::HSA_EXT_IMAGE_GEOMETRY_2DA, or
  579. * ::HSA_EXT_IMAGE_GEOMETRY_2DADEPTH; row pitch if geometry is
  580. * ::HSA_EXT_IMAGE_GEOMETRY_1DA; and 0 otherwise. The value used must
  581. * be 0 if the default slice pitch is 0, be greater than or equal to
  582. * the default slice pitch, and be a multiple of the row pitch.
  583. *
  584. * @param[out] image_data_info Memory location where the runtime stores the
  585. * size and alignment requirements. Must not be NULL.
  586. *
  587. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  588. *
  589. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  590. * initialized.
  591. *
  592. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED The image
  593. * format specified by @p image_descriptor is not supported for the
  594. * @p access_permission and @p image_data_layout specified.
  595. *
  596. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_SIZE_UNSUPPORTED The image
  597. * dimensions specified by @p image_descriptor are not supported for
  598. * the @p access_permission and @p image_data_layout specified.
  599. *
  600. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_PITCH_UNSUPPORTED The row and
  601. * slice pitch specified by @p image_data_row_pitch and @p
  602. * image_data_slice_pitch are invalid or not supported.
  603. *
  604. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p image_descriptor is
  605. * NULL, @p image_data_layout is ::HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE,
  606. * or @p image_data_info is NULL.
  607. */
  608. hsa_status_t HSA_API hsa_ext_image_data_get_info_with_layout(
  609. hsa_agent_t agent,
  610. const hsa_ext_image_descriptor_t *image_descriptor,
  611. hsa_access_permission_t access_permission,
  612. hsa_ext_image_data_layout_t image_data_layout,
  613. size_t image_data_row_pitch,
  614. size_t image_data_slice_pitch,
  615. hsa_ext_image_data_info_t *image_data_info);
  616. /**
  617. * @brief Creates an agent specific image handle to an image with an
  618. * opaque image data layout.
  619. *
  620. * @details Images with an opaque image data layout created with
  621. * different access permissions but matching image descriptors and
  622. * same agent can share the same image data if
  623. * ::HSA_EXT_IMAGE_CAPABILITY_ACCESS_INVARIANT_DATA_LAYOUT is reported
  624. * by ::hsa_ext_image_get_capability for the image format specified in
  625. * the image descriptor. Image descriptors match if they have the same
  626. * values, with the exception that s-form channel orders match the
  627. * corresponding non-s-form channel order and vice versa.
  628. *
  629. * If necessary, an application can use image operations (import,
  630. * export, copy, clear) to prepare the image for the intended use
  631. * regardless of the access permissions.
  632. *
  633. * @param[in] agent agent to be associated with the image handle created.
  634. *
  635. * @param[in] image_descriptor Pointer to an image descriptor. Must not be NULL.
  636. *
  637. * @param[in] image_data Image data buffer that must have been allocated
  638. * according to the size and alignment requirements dictated by
  639. * ::hsa_ext_image_data_get_info. Must not be NULL.
  640. *
  641. * Any previous memory contents are preserved upon creation. The application is
  642. * responsible for ensuring that the lifetime of the image data exceeds that of
  643. * all the associated images.
  644. *
  645. * @param[in] access_permission Access permission of the image when
  646. * accessed by agent. The access permission defines how the agent
  647. * is allowed to access the image using the image handle created and
  648. * must match the corresponding HSAIL image handle type. The agent
  649. * must support the image format specified in @p image_descriptor for
  650. * the given @p access_permission.
  651. *
  652. * @param[out] image Pointer to a memory location where the HSA runtime stores
  653. * the newly created image handle. Must not be NULL.
  654. *
  655. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  656. *
  657. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  658. * initialized.
  659. *
  660. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  661. *
  662. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED The agent
  663. * does not have the capability to support the image format contained
  664. * in @p image_descriptor using the specified @p access_permission.
  665. *
  666. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_SIZE_UNSUPPORTED The agent
  667. * does not support the image dimensions specified by @p
  668. * image_descriptor using the specified @p access_permission.
  669. *
  670. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  671. * the required resources.
  672. *
  673. * support the creation of more image handles with the given @p access_permission).
  674. *
  675. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p image_descriptor is NULL, @p
  676. * image_data is NULL, @p image_data does not have a valid alignment,
  677. * @p access_permission is not a valid access permission
  678. * value, or @p image is NULL.
  679. */
  680. hsa_status_t HSA_API hsa_ext_image_create(
  681. hsa_agent_t agent,
  682. const hsa_ext_image_descriptor_t *image_descriptor,
  683. const void *image_data,
  684. hsa_access_permission_t access_permission,
  685. hsa_ext_image_t *image);
  686. /**
  687. * @brief Creates an agent specific image handle to an image with an explicit
  688. * image data layout.
  689. *
  690. * @details Images with an explicit image data layout created with
  691. * different access permissions but matching image descriptors and
  692. * matching image layout can share the same image data if
  693. * ::HSA_EXT_IMAGE_CAPABILITY_ACCESS_INVARIANT_DATA_LAYOUT is reported
  694. * by ::hsa_ext_image_get_capability_with_layout for the image format
  695. * specified in the image descriptor and specified image data
  696. * layout. Image descriptors match if they have the same values, with
  697. * the exception that s-form channel orders match the corresponding
  698. * non-s-form channel order and vice versa. Image layouts match if
  699. * they are the same image data layout and use the same image row and
  700. * slice values.
  701. *
  702. * If necessary, an application can use image operations (import, export, copy,
  703. * clear) to prepare the image for the intended use regardless of the access
  704. * permissions.
  705. *
  706. * @param[in] agent agent to be associated with the image handle created.
  707. *
  708. * @param[in] image_descriptor Pointer to an image descriptor. Must not be NULL.
  709. *
  710. * @param[in] image_data Image data buffer that must have been allocated
  711. * according to the size and alignment requirements dictated by
  712. * ::hsa_ext_image_data_get_info_with_layout. Must not be NULL.
  713. *
  714. * Any previous memory contents are preserved upon creation. The application is
  715. * responsible for ensuring that the lifetime of the image data exceeds that of
  716. * all the associated images.
  717. *
  718. * @param[in] access_permission Access permission of the image when
  719. * accessed by the agent. The access permission defines how the agent
  720. * is allowed to access the image and must match the corresponding
  721. * HSAIL image handle type. The agent must support the image format
  722. * specified in @p image_descriptor for the given @p access_permission
  723. * and @p image_data_layout.
  724. *
  725. * @param[in] image_data_layout The image data layout to use for the
  726. * @p image_data. It is invalid to use
  727. * ::HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE; use ::hsa_ext_image_create
  728. * instead.
  729. *
  730. * @param[in] image_data_row_pitch The size in bytes for a single row
  731. * of the image in the image data. If 0 is specified then the default
  732. * row pitch value is used: image width * image element byte size.
  733. * The value used must be greater than or equal to the default row
  734. * pitch, and be a multiple of the image element byte size. For the
  735. * linear image layout it must also be a multiple of the image linear
  736. * row pitch alignment for the agents that will access the image data
  737. * using image instructions.
  738. *
  739. * @param[in] image_data_slice_pitch The size in bytes of a single
  740. * slice of a 3D image, or the size in bytes of each image layer in an
  741. * image array in the image data. If 0 is specified then the default
  742. * slice pitch value is used: row pitch * height if geometry is
  743. * ::HSA_EXT_IMAGE_GEOMETRY_3D, ::HSA_EXT_IMAGE_GEOMETRY_2DA, or
  744. * ::HSA_EXT_IMAGE_GEOMETRY_2DADEPTH; row pitch if geometry is
  745. * ::HSA_EXT_IMAGE_GEOMETRY_1DA; and 0 otherwise. The value used must
  746. * be 0 if the default slice pitch is 0, be greater than or equal to
  747. * the default slice pitch, and be a multiple of the row pitch.
  748. *
  749. * @param[out] image Pointer to a memory location where the HSA runtime stores
  750. * the newly created image handle. Must not be NULL.
  751. *
  752. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  753. *
  754. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  755. * initialized.
  756. *
  757. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  758. *
  759. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED The agent does
  760. * not have the capability to support the image format contained in the image
  761. * descriptor using the specified @p access_permission and @p image_data_layout.
  762. *
  763. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_SIZE_UNSUPPORTED The agent
  764. * does not support the image dimensions specified by @p
  765. * image_descriptor using the specified @p access_permission and @p
  766. * image_data_layout.
  767. *
  768. * @retval ::HSA_EXT_STATUS_ERROR_IMAGE_PITCH_UNSUPPORTED The agent does
  769. * not support the row and slice pitch specified by @p image_data_row_pitch
  770. * and @p image_data_slice_pitch, or the values are invalid.
  771. *
  772. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  773. * the required resources.
  774. *
  775. * support the creation of more image handles with the given @p access_permission).
  776. *
  777. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p image_descriptor is NULL, @p
  778. * image_data is NULL, @p image_data does not have a valid alignment,
  779. * @p image_data_layout is ::HSA_EXT_IMAGE_DATA_LAYOUT_OPAQUE,
  780. * or @p image is NULL.
  781. */
  782. hsa_status_t HSA_API hsa_ext_image_create_with_layout(
  783. hsa_agent_t agent,
  784. const hsa_ext_image_descriptor_t *image_descriptor,
  785. const void *image_data,
  786. hsa_access_permission_t access_permission,
  787. hsa_ext_image_data_layout_t image_data_layout,
  788. size_t image_data_row_pitch,
  789. size_t image_data_slice_pitch,
  790. hsa_ext_image_t *image);
  791. /**
  792. * @brief Destroy an image handle previously created using ::hsa_ext_image_create or
  793. * ::hsa_ext_image_create_with_layout.
  794. *
  795. * @details Destroying the image handle does not free the associated image data,
  796. * or modify its contents. The application should not destroy an image handle while
  797. * there are references to it queued for execution or currently being used in a
  798. * kernel dispatch.
  799. *
  800. * @param[in] agent Agent associated with the image handle.
  801. *
  802. * @param[in] image Image handle to destroy.
  803. *
  804. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  805. *
  806. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  807. * initialized.
  808. *
  809. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  810. */
  811. hsa_status_t HSA_API hsa_ext_image_destroy(
  812. hsa_agent_t agent,
  813. hsa_ext_image_t image);
  814. /**
  815. * @brief Copies a portion of one image (the source) to another image (the
  816. * destination).
  817. *
  818. * @details The source and destination image formats should be the
  819. * same, with the exception that s-form channel orders match the
  820. * corresponding non-s-form channel order and vice versa. For example,
  821. * it is allowed to copy a source image with a channel order of
  822. * HSA_EXT_IMAGE_CHANNEL_ORDER_SRGB to a destination image with a
  823. * channel order of HSA_EXT_IMAGE_CHANNEL_ORDER_RGB.
  824. *
  825. * The source and destination images do not have to be of the same geometry and
  826. * appropriate scaling is performed by the HSA runtime. It is possible to copy
  827. * subregions between any combinations of source and destination geometries, provided
  828. * that the dimensions of the subregions are the same. For example, it is
  829. * allowed to copy a rectangular region from a 2D image to a slice of a 3D
  830. * image.
  831. *
  832. * If the source and destination image data overlap, or the combination of
  833. * offset and range references an out-out-bounds element in any of the images,
  834. * the behavior is undefined.
  835. *
  836. * @param[in] agent Agent associated with both the source and destination image handles.
  837. *
  838. * @param[in] src_image Image handle of source image. The agent associated with the source
  839. * image handle must be identical to that of the destination image.
  840. *
  841. * @param[in] src_offset Pointer to the offset within the source image where to
  842. * copy the data from. Must not be NULL.
  843. *
  844. * @param[in] dst_image Image handle of destination image.
  845. *
  846. * @param[in] dst_offset Pointer to the offset within the destination
  847. * image where to copy the data. Must not be NULL.
  848. *
  849. * @param[in] range Dimensions of the image portion to be copied. The HSA
  850. * runtime computes the size of the image data to be copied using this
  851. * argument. Must not be NULL.
  852. *
  853. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  854. *
  855. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  856. * initialized.
  857. *
  858. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  859. *
  860. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p src_offset is
  861. * NULL, @p dst_offset is NULL, or @p range is NULL.
  862. */
  863. hsa_status_t HSA_API hsa_ext_image_copy(
  864. hsa_agent_t agent,
  865. hsa_ext_image_t src_image,
  866. const hsa_dim3_t* src_offset,
  867. hsa_ext_image_t dst_image,
  868. const hsa_dim3_t* dst_offset,
  869. const hsa_dim3_t* range);
  870. /**
  871. * @brief Image region.
  872. */
  873. typedef struct hsa_ext_image_region_s {
  874. /**
  875. * Offset within an image (in coordinates).
  876. */
  877. hsa_dim3_t offset;
  878. /**
  879. * Dimension size of the image range (in coordinates). The x, y, and z dimensions
  880. * correspond to width, height, and depth or index respectively.
  881. */
  882. hsa_dim3_t range;
  883. } hsa_ext_image_region_t;
  884. /**
  885. * @brief Import a linearly organized image data from memory directly to an
  886. * image handle.
  887. *
  888. * @details This operation updates the image data referenced by the image handle
  889. * from the source memory. The size of the data imported from memory is
  890. * implicitly derived from the image region.
  891. *
  892. * It is the application's responsibility to avoid out of bounds memory access.
  893. *
  894. * None of the source memory or destination image data memory can
  895. * overlap. Overlapping of any of the source and destination image
  896. * data memory within the import operation produces undefined results.
  897. *
  898. * @param[in] agent Agent associated with the image handle.
  899. *
  900. * @param[in] src_memory Source memory. Must not be NULL.
  901. *
  902. * @param[in] src_row_pitch The size in bytes of a single row of the image in the
  903. * source memory. If the value is smaller than the destination image region
  904. * width * image element byte size, then region width * image element byte
  905. * size is used.
  906. *
  907. * @param[in] src_slice_pitch The size in bytes of a single 2D slice of a 3D image,
  908. * or the size in bytes of each image layer in an image array in the source memory.
  909. * If the geometry is ::HSA_EXT_IMAGE_GEOMETRY_1DA and the value is smaller than the
  910. * value used for @p src_row_pitch, then the value used for @p src_row_pitch is used.
  911. * If the geometry is ::HSA_EXT_IMAGE_GEOMETRY_3D, ::HSA_EXT_IMAGE_GEOMETRY_2DA, or
  912. * HSA_EXT_IMAGE_GEOMETRY_2DADEPTH and the value is smaller than the value used for
  913. * @p src_row_pitch * destination image region height, then the value used for
  914. * @p src_row_pitch * destination image region height is used.
  915. * Otherwise, the value is not used.
  916. *
  917. * @param[in] dst_image Image handle of destination image.
  918. *
  919. * @param[in] image_region Pointer to the image region to be updated. Must not
  920. * be NULL.
  921. *
  922. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  923. *
  924. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  925. * initialized.
  926. *
  927. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  928. *
  929. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p src_memory is NULL, or @p
  930. * image_region is NULL.
  931. *
  932. */
  933. hsa_status_t HSA_API hsa_ext_image_import(
  934. hsa_agent_t agent,
  935. const void *src_memory,
  936. size_t src_row_pitch,
  937. size_t src_slice_pitch,
  938. hsa_ext_image_t dst_image,
  939. const hsa_ext_image_region_t *image_region);
  940. /**
  941. * @brief Export the image data to linearly organized memory.
  942. *
  943. * @details The operation updates the destination memory with the image data of
  944. * @p src_image. The size of the data exported to memory is implicitly derived
  945. * from the image region.
  946. *
  947. * It is the application's responsibility to avoid out of bounds memory access.
  948. *
  949. * None of the destination memory or source image data memory can
  950. * overlap. Overlapping of any of the source and destination image
  951. * data memory within the export operation produces undefined results.
  952. *
  953. * @param[in] agent Agent associated with the image handle.
  954. *
  955. * @param[in] src_image Image handle of source image.
  956. *
  957. * @param[in] dst_memory Destination memory. Must not be NULL.
  958. *
  959. * @param[in] dst_row_pitch The size in bytes of a single row of the image in the
  960. * destination memory. If the value is smaller than the source image region
  961. * width * image element byte size, then region width * image element byte
  962. * size is used.
  963. *
  964. * @param[in] dst_slice_pitch The size in bytes of a single 2D slice of a 3D image,
  965. * or the size in bytes of each image in an image array in the destination memory.
  966. * If the geometry is ::HSA_EXT_IMAGE_GEOMETRY_1DA and the value is smaller than the
  967. * value used for @p dst_row_pitch, then the value used for @p dst_row_pitch is used.
  968. * If the geometry is ::HSA_EXT_IMAGE_GEOMETRY_3D, ::HSA_EXT_IMAGE_GEOMETRY_2DA, or
  969. * HSA_EXT_IMAGE_GEOMETRY_2DADEPTH and the value is smaller than the value used for
  970. * @p dst_row_pitch * source image region height, then the value used for
  971. * @p dst_row_pitch * source image region height is used.
  972. * Otherwise, the value is not used.
  973. *
  974. * @param[in] image_region Pointer to the image region to be exported. Must not
  975. * be NULL.
  976. *
  977. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  978. *
  979. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  980. * initialized.
  981. *
  982. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  983. *
  984. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p dst_memory is NULL, or @p
  985. * image_region is NULL.
  986. */
  987. hsa_status_t HSA_API hsa_ext_image_export(
  988. hsa_agent_t agent,
  989. hsa_ext_image_t src_image,
  990. void *dst_memory,
  991. size_t dst_row_pitch,
  992. size_t dst_slice_pitch,
  993. const hsa_ext_image_region_t *image_region);
  994. /**
  995. * @brief Clear a region of an image so that every image element has
  996. * the specified value.
  997. *
  998. * @param[in] agent Agent associated with the image handle.
  999. *
  1000. * @param[in] image Image handle for image to be cleared.
  1001. *
  1002. * @param[in] data The value to which to set each image element being
  1003. * cleared. It is specified as an array of image component values. The
  1004. * number of array elements must match the number of access components
  1005. * for the image channel order. The type of each array element must
  1006. * match the image access type of the image channel type. When the
  1007. * value is used to set the value of an image element, the conversion
  1008. * method corresponding to the image channel type is used. See the
  1009. * <em>Channel Order</em> section and <em>Channel Type</em> section in
  1010. * the <em>HSA Programming Reference Manual</em> for more
  1011. * information. Must not be NULL.
  1012. *
  1013. * @param[in] image_region Pointer to the image region to clear. Must not be
  1014. * NULL. If the region references an out-out-bounds element, the behavior is
  1015. * undefined.
  1016. *
  1017. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1018. *
  1019. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1020. * initialized.
  1021. *
  1022. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  1023. *
  1024. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p data is NULL, or @p
  1025. * image_region is NULL.
  1026. */
  1027. hsa_status_t HSA_API hsa_ext_image_clear(
  1028. hsa_agent_t agent,
  1029. hsa_ext_image_t image,
  1030. const void* data,
  1031. const hsa_ext_image_region_t *image_region);
  1032. /**
  1033. * @brief Sampler handle. Samplers are populated by
  1034. * ::hsa_ext_sampler_create. Sampler handles are only unique within an
  1035. * agent, not across agents.
  1036. */
  1037. typedef struct hsa_ext_sampler_s {
  1038. /**
  1039. * Opaque handle. For a given agent, two handles reference the same object of
  1040. * the enclosing type if and only if they are equal.
  1041. */
  1042. uint64_t handle;
  1043. } hsa_ext_sampler_t;
  1044. /**
  1045. * @brief Sampler address modes. The sampler address mode describes
  1046. * the processing of out-of-range image coordinates. See the
  1047. * <em>Addressing Mode</em> section in the <em>HSA Programming Reference
  1048. * Manual</em> for definitions on each address mode. The values
  1049. * match the BRIG type @p hsa_ext_brig_sampler_addressing_t.
  1050. */
  1051. typedef enum {
  1052. /**
  1053. * Out-of-range coordinates are not handled.
  1054. */
  1055. HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED = 0,
  1056. /**
  1057. * Clamp out-of-range coordinates to the image edge.
  1058. */
  1059. HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE = 1,
  1060. /**
  1061. * Clamp out-of-range coordinates to the image border color.
  1062. */
  1063. HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER = 2,
  1064. /**
  1065. * Wrap out-of-range coordinates back into the valid coordinate
  1066. * range so the image appears as repeated tiles.
  1067. */
  1068. HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT = 3,
  1069. /**
  1070. * Mirror out-of-range coordinates back into the valid coordinate
  1071. * range so the image appears as repeated tiles with every other
  1072. * tile a reflection.
  1073. */
  1074. HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT = 4
  1075. } hsa_ext_sampler_addressing_mode_t;
  1076. /**
  1077. * @brief A fixed-size type used to represent ::hsa_ext_sampler_addressing_mode_t constants.
  1078. */
  1079. typedef uint32_t hsa_ext_sampler_addressing_mode32_t;
  1080. /**
  1081. * @brief Sampler coordinate normalization modes. See the
  1082. * <em>Coordinate Normalization Mode</em> section in the <em>HSA
  1083. * Programming Reference Manual</em> for definitions on each
  1084. * coordinate normalization mode. The values match the BRIG type @p
  1085. * hsa_ext_brig_sampler_coord_normalization_t.
  1086. */
  1087. typedef enum {
  1088. /**
  1089. * Coordinates are used to directly address an image element.
  1090. */
  1091. HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED = 0,
  1092. /**
  1093. * Coordinates are scaled by the image dimension size before being
  1094. * used to address an image element.
  1095. */
  1096. HSA_EXT_SAMPLER_COORDINATE_MODE_NORMALIZED = 1
  1097. } hsa_ext_sampler_coordinate_mode_t;
  1098. /**
  1099. * @brief A fixed-size type used to represent ::hsa_ext_sampler_coordinate_mode_t constants.
  1100. */
  1101. typedef uint32_t hsa_ext_sampler_coordinate_mode32_t;
  1102. /**
  1103. * @brief Sampler filter modes. See the <em>Filter Mode</em> section
  1104. * in the <em>HSA Programming Reference Manual</em> for definitions
  1105. * on each address mode. The enumeration values match the BRIG type @p
  1106. * hsa_ext_brig_sampler_filter_t.
  1107. */
  1108. typedef enum {
  1109. /**
  1110. * Filter to the image element nearest (in Manhattan distance) to the
  1111. * specified coordinate.
  1112. */
  1113. HSA_EXT_SAMPLER_FILTER_MODE_NEAREST = 0,
  1114. /**
  1115. * Filter to the image element calculated by combining the elements in a 2x2
  1116. * square block or 2x2x2 cube block around the specified coordinate. The
  1117. * elements are combined using linear interpolation.
  1118. */
  1119. HSA_EXT_SAMPLER_FILTER_MODE_LINEAR = 1
  1120. } hsa_ext_sampler_filter_mode_t;
  1121. /**
  1122. * @brief A fixed-size type used to represent ::hsa_ext_sampler_filter_mode_t constants.
  1123. */
  1124. typedef uint32_t hsa_ext_sampler_filter_mode32_t;
  1125. /**
  1126. * @brief Implementation independent sampler descriptor.
  1127. */
  1128. typedef struct hsa_ext_sampler_descriptor_s {
  1129. /**
  1130. * Sampler coordinate mode describes the normalization of image coordinates.
  1131. */
  1132. hsa_ext_sampler_coordinate_mode32_t coordinate_mode;
  1133. /**
  1134. * Sampler filter type describes the type of sampling performed.
  1135. */
  1136. hsa_ext_sampler_filter_mode32_t filter_mode;
  1137. /**
  1138. * Sampler address mode describes the processing of out-of-range image
  1139. * coordinates.
  1140. */
  1141. hsa_ext_sampler_addressing_mode32_t address_mode;
  1142. } hsa_ext_sampler_descriptor_t;
  1143. /**
  1144. * @brief Create an agent specific sampler handle for a given agent
  1145. * independent sampler descriptor and agent.
  1146. *
  1147. * @param[in] agent Agent to be associated with the sampler handle created.
  1148. *
  1149. * @param[in] sampler_descriptor Pointer to a sampler descriptor. Must not be
  1150. * NULL.
  1151. *
  1152. * @param[out] sampler Memory location where the HSA runtime stores the newly
  1153. * created sampler handle. Must not be NULL.
  1154. *
  1155. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1156. *
  1157. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1158. * initialized.
  1159. *
  1160. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  1161. *
  1162. * @retval ::HSA_EXT_STATUS_ERROR_SAMPLER_DESCRIPTOR_UNSUPPORTED The
  1163. * @p agent does not have the capability to support the properties
  1164. * specified by @p sampler_descriptor or it is invalid.
  1165. *
  1166. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  1167. * the required resources.
  1168. *
  1169. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p sampler_descriptor is NULL, or
  1170. * @p sampler is NULL.
  1171. */
  1172. hsa_status_t HSA_API hsa_ext_sampler_create(
  1173. hsa_agent_t agent,
  1174. const hsa_ext_sampler_descriptor_t *sampler_descriptor,
  1175. hsa_ext_sampler_t *sampler);
  1176. /**
  1177. * @brief Destroy a sampler handle previously created using ::hsa_ext_sampler_create.
  1178. *
  1179. * @details The sampler handle should not be destroyed while there are
  1180. * references to it queued for execution or currently being used in a
  1181. * kernel dispatch.
  1182. *
  1183. * @param[in] agent Agent associated with the sampler handle.
  1184. *
  1185. * @param[in] sampler Sampler handle to destroy.
  1186. *
  1187. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1188. *
  1189. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1190. * initialized.
  1191. *
  1192. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  1193. */
  1194. hsa_status_t HSA_API hsa_ext_sampler_destroy(
  1195. hsa_agent_t agent,
  1196. hsa_ext_sampler_t sampler);
  1197. #define hsa_ext_images_1_00
  1198. /**
  1199. * @brief The function pointer table for the images v1.00 extension. Can be returned by ::hsa_system_get_extension_table or ::hsa_system_get_major_extension_table.
  1200. */
  1201. typedef struct hsa_ext_images_1_00_pfn_s {
  1202. hsa_status_t (*hsa_ext_image_get_capability)(
  1203. hsa_agent_t agent,
  1204. hsa_ext_image_geometry_t geometry,
  1205. const hsa_ext_image_format_t *image_format,
  1206. uint32_t *capability_mask);
  1207. hsa_status_t (*hsa_ext_image_data_get_info)(
  1208. hsa_agent_t agent,
  1209. const hsa_ext_image_descriptor_t *image_descriptor,
  1210. hsa_access_permission_t access_permission,
  1211. hsa_ext_image_data_info_t *image_data_info);
  1212. hsa_status_t (*hsa_ext_image_create)(
  1213. hsa_agent_t agent,
  1214. const hsa_ext_image_descriptor_t *image_descriptor,
  1215. const void *image_data,
  1216. hsa_access_permission_t access_permission,
  1217. hsa_ext_image_t *image);
  1218. hsa_status_t (*hsa_ext_image_destroy)(
  1219. hsa_agent_t agent,
  1220. hsa_ext_image_t image);
  1221. hsa_status_t (*hsa_ext_image_copy)(
  1222. hsa_agent_t agent,
  1223. hsa_ext_image_t src_image,
  1224. const hsa_dim3_t* src_offset,
  1225. hsa_ext_image_t dst_image,
  1226. const hsa_dim3_t* dst_offset,
  1227. const hsa_dim3_t* range);
  1228. hsa_status_t (*hsa_ext_image_import)(
  1229. hsa_agent_t agent,
  1230. const void *src_memory,
  1231. size_t src_row_pitch,
  1232. size_t src_slice_pitch,
  1233. hsa_ext_image_t dst_image,
  1234. const hsa_ext_image_region_t *image_region);
  1235. hsa_status_t (*hsa_ext_image_export)(
  1236. hsa_agent_t agent,
  1237. hsa_ext_image_t src_image,
  1238. void *dst_memory,
  1239. size_t dst_row_pitch,
  1240. size_t dst_slice_pitch,
  1241. const hsa_ext_image_region_t *image_region);
  1242. hsa_status_t (*hsa_ext_image_clear)(
  1243. hsa_agent_t agent,
  1244. hsa_ext_image_t image,
  1245. const void* data,
  1246. const hsa_ext_image_region_t *image_region);
  1247. hsa_status_t (*hsa_ext_sampler_create)(
  1248. hsa_agent_t agent,
  1249. const hsa_ext_sampler_descriptor_t *sampler_descriptor,
  1250. hsa_ext_sampler_t *sampler);
  1251. hsa_status_t (*hsa_ext_sampler_destroy)(
  1252. hsa_agent_t agent,
  1253. hsa_ext_sampler_t sampler);
  1254. } hsa_ext_images_1_00_pfn_t;
  1255. #define hsa_ext_images_1
  1256. /**
  1257. * @brief The function pointer table for the images v1 extension. Can be returned by ::hsa_system_get_extension_table or ::hsa_system_get_major_extension_table.
  1258. */
  1259. typedef struct hsa_ext_images_1_pfn_s {
  1260. hsa_status_t (*hsa_ext_image_get_capability)(
  1261. hsa_agent_t agent,
  1262. hsa_ext_image_geometry_t geometry,
  1263. const hsa_ext_image_format_t *image_format,
  1264. uint32_t *capability_mask);
  1265. hsa_status_t (*hsa_ext_image_data_get_info)(
  1266. hsa_agent_t agent,
  1267. const hsa_ext_image_descriptor_t *image_descriptor,
  1268. hsa_access_permission_t access_permission,
  1269. hsa_ext_image_data_info_t *image_data_info);
  1270. hsa_status_t (*hsa_ext_image_create)(
  1271. hsa_agent_t agent,
  1272. const hsa_ext_image_descriptor_t *image_descriptor,
  1273. const void *image_data,
  1274. hsa_access_permission_t access_permission,
  1275. hsa_ext_image_t *image);
  1276. hsa_status_t (*hsa_ext_image_destroy)(
  1277. hsa_agent_t agent,
  1278. hsa_ext_image_t image);
  1279. hsa_status_t (*hsa_ext_image_copy)(
  1280. hsa_agent_t agent,
  1281. hsa_ext_image_t src_image,
  1282. const hsa_dim3_t* src_offset,
  1283. hsa_ext_image_t dst_image,
  1284. const hsa_dim3_t* dst_offset,
  1285. const hsa_dim3_t* range);
  1286. hsa_status_t (*hsa_ext_image_import)(
  1287. hsa_agent_t agent,
  1288. const void *src_memory,
  1289. size_t src_row_pitch,
  1290. size_t src_slice_pitch,
  1291. hsa_ext_image_t dst_image,
  1292. const hsa_ext_image_region_t *image_region);
  1293. hsa_status_t (*hsa_ext_image_export)(
  1294. hsa_agent_t agent,
  1295. hsa_ext_image_t src_image,
  1296. void *dst_memory,
  1297. size_t dst_row_pitch,
  1298. size_t dst_slice_pitch,
  1299. const hsa_ext_image_region_t *image_region);
  1300. hsa_status_t (*hsa_ext_image_clear)(
  1301. hsa_agent_t agent,
  1302. hsa_ext_image_t image,
  1303. const void* data,
  1304. const hsa_ext_image_region_t *image_region);
  1305. hsa_status_t (*hsa_ext_sampler_create)(
  1306. hsa_agent_t agent,
  1307. const hsa_ext_sampler_descriptor_t *sampler_descriptor,
  1308. hsa_ext_sampler_t *sampler);
  1309. hsa_status_t (*hsa_ext_sampler_destroy)(
  1310. hsa_agent_t agent,
  1311. hsa_ext_sampler_t sampler);
  1312. hsa_status_t (*hsa_ext_image_get_capability_with_layout)(
  1313. hsa_agent_t agent,
  1314. hsa_ext_image_geometry_t geometry,
  1315. const hsa_ext_image_format_t *image_format,
  1316. hsa_ext_image_data_layout_t image_data_layout,
  1317. uint32_t *capability_mask);
  1318. hsa_status_t (*hsa_ext_image_data_get_info_with_layout)(
  1319. hsa_agent_t agent,
  1320. const hsa_ext_image_descriptor_t *image_descriptor,
  1321. hsa_access_permission_t access_permission,
  1322. hsa_ext_image_data_layout_t image_data_layout,
  1323. size_t image_data_row_pitch,
  1324. size_t image_data_slice_pitch,
  1325. hsa_ext_image_data_info_t *image_data_info);
  1326. hsa_status_t (*hsa_ext_image_create_with_layout)(
  1327. hsa_agent_t agent,
  1328. const hsa_ext_image_descriptor_t *image_descriptor,
  1329. const void *image_data,
  1330. hsa_access_permission_t access_permission,
  1331. hsa_ext_image_data_layout_t image_data_layout,
  1332. size_t image_data_row_pitch,
  1333. size_t image_data_slice_pitch,
  1334. hsa_ext_image_t *image);
  1335. } hsa_ext_images_1_pfn_t;
  1336. /** @} */
  1337. #ifdef __cplusplus
  1338. } // end extern "C" block
  1339. #endif /*__cplusplus*/
  1340. #endif