rsDefines.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. /*
  2. * Copyright (C) 2013 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef RENDER_SCRIPT_DEFINES_H
  17. #define RENDER_SCRIPT_DEFINES_H
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. //////////////////////////////////////////////////////
  24. //
  25. typedef void * RsAsyncVoidPtr;
  26. typedef void * RsAllocation;
  27. typedef void * RsAnimation;
  28. typedef void * RsClosure;
  29. typedef void * RsContext;
  30. typedef void * RsDevice;
  31. typedef void * RsElement;
  32. typedef void * RsFile;
  33. typedef void * RsFont;
  34. typedef void * RsSampler;
  35. typedef void * RsScript;
  36. typedef void * RsScriptKernelID;
  37. typedef void * RsScriptInvokeID;
  38. typedef void * RsScriptFieldID;
  39. typedef void * RsScriptMethodID;
  40. typedef void * RsScriptGroup;
  41. typedef void * RsScriptGroup2;
  42. typedef void * RsMesh;
  43. typedef void * RsPath;
  44. typedef void * RsType;
  45. typedef void * RsObjectBase;
  46. typedef void * RsProgram;
  47. typedef void * RsProgramVertex;
  48. typedef void * RsProgramFragment;
  49. typedef void * RsProgramStore;
  50. typedef void * RsProgramRaster;
  51. typedef void * RsNativeWindow;
  52. typedef void (* RsBitmapCallback_t)(void *);
  53. typedef struct {
  54. float m[16];
  55. } rs_matrix4x4;
  56. typedef struct {
  57. float m[9];
  58. } rs_matrix3x3;
  59. typedef struct {
  60. float m[4];
  61. } rs_matrix2x2;
  62. enum RsDeviceParam {
  63. RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
  64. RS_DEVICE_PARAM_COUNT
  65. };
  66. enum RsContextType {
  67. RS_CONTEXT_TYPE_NORMAL,
  68. RS_CONTEXT_TYPE_DEBUG,
  69. RS_CONTEXT_TYPE_PROFILE
  70. };
  71. enum RsAllocationUsageType {
  72. RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
  73. RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
  74. RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
  75. RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
  76. RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010,
  77. RS_ALLOCATION_USAGE_IO_INPUT = 0x0020,
  78. RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040,
  79. RS_ALLOCATION_USAGE_SHARED = 0x0080,
  80. RS_ALLOCATION_USAGE_INCREMENTAL_SUPPORT = 0x1000,
  81. RS_ALLOCATION_USAGE_OEM = 0x8000,
  82. RS_ALLOCATION_USAGE_ALL = 0x80FF
  83. };
  84. enum RsAllocationMipmapControl {
  85. RS_ALLOCATION_MIPMAP_NONE = 0,
  86. RS_ALLOCATION_MIPMAP_FULL = 1,
  87. RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2
  88. };
  89. enum RsAllocationCubemapFace {
  90. RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
  91. RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
  92. RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
  93. RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
  94. RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
  95. RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
  96. };
  97. enum RsDataType {
  98. RS_TYPE_NONE = 0,
  99. RS_TYPE_FLOAT_16,
  100. RS_TYPE_FLOAT_32,
  101. RS_TYPE_FLOAT_64,
  102. RS_TYPE_SIGNED_8,
  103. RS_TYPE_SIGNED_16,
  104. RS_TYPE_SIGNED_32,
  105. RS_TYPE_SIGNED_64,
  106. RS_TYPE_UNSIGNED_8,
  107. RS_TYPE_UNSIGNED_16,
  108. RS_TYPE_UNSIGNED_32,
  109. RS_TYPE_UNSIGNED_64,
  110. RS_TYPE_BOOLEAN,
  111. RS_TYPE_UNSIGNED_5_6_5,
  112. RS_TYPE_UNSIGNED_5_5_5_1,
  113. RS_TYPE_UNSIGNED_4_4_4_4,
  114. RS_TYPE_MATRIX_4X4,
  115. RS_TYPE_MATRIX_3X3,
  116. RS_TYPE_MATRIX_2X2,
  117. RS_TYPE_ELEMENT = 1000,
  118. RS_TYPE_TYPE,
  119. RS_TYPE_ALLOCATION,
  120. RS_TYPE_SAMPLER,
  121. RS_TYPE_SCRIPT,
  122. RS_TYPE_MESH,
  123. RS_TYPE_PROGRAM_FRAGMENT,
  124. RS_TYPE_PROGRAM_VERTEX,
  125. RS_TYPE_PROGRAM_RASTER,
  126. RS_TYPE_PROGRAM_STORE,
  127. RS_TYPE_FONT,
  128. RS_TYPE_INVALID = 10000,
  129. };
  130. enum RsDataKind {
  131. RS_KIND_USER,
  132. RS_KIND_PIXEL_L = 7,
  133. RS_KIND_PIXEL_A,
  134. RS_KIND_PIXEL_LA,
  135. RS_KIND_PIXEL_RGB,
  136. RS_KIND_PIXEL_RGBA,
  137. RS_KIND_PIXEL_DEPTH,
  138. RS_KIND_PIXEL_YUV,
  139. RS_KIND_INVALID = 100,
  140. };
  141. enum RsYuvFormat {
  142. RS_YUV_NONE = 0,
  143. RS_YUV_YV12 = 0x32315659, // HAL_PIXEL_FORMAT_YV12 in system/graphics.h
  144. RS_YUV_NV21 = 0x11, // HAL_PIXEL_FORMAT_YCrCb_420_SP
  145. RS_YUV_420_888 = 0x23, // HAL_PIXEL_FORMAT_YCbCr_420_888
  146. };
  147. enum RsSamplerParam {
  148. RS_SAMPLER_MIN_FILTER,
  149. RS_SAMPLER_MAG_FILTER,
  150. RS_SAMPLER_WRAP_S,
  151. RS_SAMPLER_WRAP_T,
  152. RS_SAMPLER_WRAP_R,
  153. RS_SAMPLER_ANISO
  154. };
  155. enum RsSamplerValue {
  156. RS_SAMPLER_NEAREST,
  157. RS_SAMPLER_LINEAR,
  158. RS_SAMPLER_LINEAR_MIP_LINEAR,
  159. RS_SAMPLER_WRAP,
  160. RS_SAMPLER_CLAMP,
  161. RS_SAMPLER_LINEAR_MIP_NEAREST,
  162. RS_SAMPLER_MIRRORED_REPEAT,
  163. RS_SAMPLER_INVALID = 100,
  164. };
  165. enum RsDimension {
  166. RS_DIMENSION_X,
  167. RS_DIMENSION_Y,
  168. RS_DIMENSION_Z,
  169. RS_DIMENSION_LOD,
  170. RS_DIMENSION_FACE,
  171. RS_DIMENSION_ARRAY_0 = 100,
  172. RS_DIMENSION_ARRAY_1,
  173. RS_DIMENSION_ARRAY_2,
  174. RS_DIMENSION_ARRAY_3,
  175. RS_DIMENSION_MAX = RS_DIMENSION_ARRAY_3
  176. };
  177. enum RsError {
  178. RS_ERROR_NONE = 0,
  179. RS_ERROR_BAD_SHADER = 1,
  180. RS_ERROR_BAD_SCRIPT = 2,
  181. RS_ERROR_BAD_VALUE = 3,
  182. RS_ERROR_OUT_OF_MEMORY = 4,
  183. RS_ERROR_DRIVER = 5,
  184. // Errors that only occur in the debug context.
  185. RS_ERROR_FATAL_DEBUG = 0x0800,
  186. RS_ERROR_FATAL_UNKNOWN = 0x1000,
  187. RS_ERROR_FATAL_DRIVER = 0x1001,
  188. RS_ERROR_FATAL_PROGRAM_LINK = 0x1002
  189. };
  190. enum RsForEachStrategy {
  191. RS_FOR_EACH_STRATEGY_SERIAL = 0,
  192. RS_FOR_EACH_STRATEGY_DONT_CARE = 1,
  193. RS_FOR_EACH_STRATEGY_DST_LINEAR = 2,
  194. RS_FOR_EACH_STRATEGY_TILE_SMALL = 3,
  195. RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4,
  196. RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
  197. };
  198. // Script to Script
  199. typedef struct {
  200. enum RsForEachStrategy strategy;
  201. uint32_t xStart;
  202. uint32_t xEnd;
  203. uint32_t yStart;
  204. uint32_t yEnd;
  205. uint32_t zStart;
  206. uint32_t zEnd;
  207. uint32_t arrayStart;
  208. uint32_t arrayEnd;
  209. uint32_t array2Start;
  210. uint32_t array2End;
  211. uint32_t array3Start;
  212. uint32_t array3End;
  213. uint32_t array4Start;
  214. uint32_t array4End;
  215. } RsScriptCall;
  216. enum RsContextFlags {
  217. RS_CONTEXT_SYNCHRONOUS = 0x0001,
  218. RS_CONTEXT_LOW_LATENCY = 0x0002,
  219. RS_CONTEXT_LOW_POWER = 0x0004,
  220. RS_CONTEXT_WAIT_FOR_ATTACH = 0x0008
  221. };
  222. enum RsBlasTranspose {
  223. RsBlasNoTrans=111,
  224. RsBlasTrans=112,
  225. RsBlasConjTrans=113
  226. };
  227. enum RsBlasUplo {
  228. RsBlasUpper=121,
  229. RsBlasLower=122
  230. };
  231. enum RsBlasDiag {
  232. RsBlasNonUnit=131,
  233. RsBlasUnit=132
  234. };
  235. enum RsBlasSide {
  236. RsBlasLeft=141,
  237. RsBlasRight=142
  238. };
  239. enum RsBlasFunction {
  240. RsBlas_nop = 0,
  241. RsBlas_sdsdot = 1,
  242. RsBlas_dsdot = 2,
  243. RsBlas_sdot = 3,
  244. RsBlas_ddot = 4,
  245. RsBlas_cdotu_sub = 5,
  246. RsBlas_cdotc_sub = 6,
  247. RsBlas_zdotu_sub = 7,
  248. RsBlas_zdotc_sub = 8,
  249. RsBlas_snrm2 = 9,
  250. RsBlas_sasum = 10,
  251. RsBlas_dnrm2 = 11,
  252. RsBlas_dasum = 12,
  253. RsBlas_scnrm2 = 13,
  254. RsBlas_scasum = 14,
  255. RsBlas_dznrm2 = 15,
  256. RsBlas_dzasum = 16,
  257. RsBlas_isamax = 17,
  258. RsBlas_idamax = 18,
  259. RsBlas_icamax = 19,
  260. RsBlas_izamax = 20,
  261. RsBlas_sswap = 21,
  262. RsBlas_scopy = 22,
  263. RsBlas_saxpy = 23,
  264. RsBlas_dswap = 24,
  265. RsBlas_dcopy = 25,
  266. RsBlas_daxpy = 26,
  267. RsBlas_cswap = 27,
  268. RsBlas_ccopy = 28,
  269. RsBlas_caxpy = 29,
  270. RsBlas_zswap = 30,
  271. RsBlas_zcopy = 31,
  272. RsBlas_zaxpy = 32,
  273. RsBlas_srotg = 33,
  274. RsBlas_srotmg = 34,
  275. RsBlas_srot = 35,
  276. RsBlas_srotm = 36,
  277. RsBlas_drotg = 37,
  278. RsBlas_drotmg = 38,
  279. RsBlas_drot = 39,
  280. RsBlas_drotm = 40,
  281. RsBlas_sscal = 41,
  282. RsBlas_dscal = 42,
  283. RsBlas_cscal = 43,
  284. RsBlas_zscal = 44,
  285. RsBlas_csscal = 45,
  286. RsBlas_zdscal = 46,
  287. RsBlas_sgemv = 47,
  288. RsBlas_sgbmv = 48,
  289. RsBlas_strmv = 49,
  290. RsBlas_stbmv = 50,
  291. RsBlas_stpmv = 51,
  292. RsBlas_strsv = 52,
  293. RsBlas_stbsv = 53,
  294. RsBlas_stpsv = 54,
  295. RsBlas_dgemv = 55,
  296. RsBlas_dgbmv = 56,
  297. RsBlas_dtrmv = 57,
  298. RsBlas_dtbmv = 58,
  299. RsBlas_dtpmv = 59,
  300. RsBlas_dtrsv = 60,
  301. RsBlas_dtbsv = 61,
  302. RsBlas_dtpsv = 62,
  303. RsBlas_cgemv = 63,
  304. RsBlas_cgbmv = 64,
  305. RsBlas_ctrmv = 65,
  306. RsBlas_ctbmv = 66,
  307. RsBlas_ctpmv = 67,
  308. RsBlas_ctrsv = 68,
  309. RsBlas_ctbsv = 69,
  310. RsBlas_ctpsv = 70,
  311. RsBlas_zgemv = 71,
  312. RsBlas_zgbmv = 72,
  313. RsBlas_ztrmv = 73,
  314. RsBlas_ztbmv = 74,
  315. RsBlas_ztpmv = 75,
  316. RsBlas_ztrsv = 76,
  317. RsBlas_ztbsv = 77,
  318. RsBlas_ztpsv = 78,
  319. RsBlas_ssymv = 79,
  320. RsBlas_ssbmv = 80,
  321. RsBlas_sspmv = 81,
  322. RsBlas_sger = 82,
  323. RsBlas_ssyr = 83,
  324. RsBlas_sspr = 84,
  325. RsBlas_ssyr2 = 85,
  326. RsBlas_sspr2 = 86,
  327. RsBlas_dsymv = 87,
  328. RsBlas_dsbmv = 88,
  329. RsBlas_dspmv = 89,
  330. RsBlas_dger = 90,
  331. RsBlas_dsyr = 91,
  332. RsBlas_dspr = 92,
  333. RsBlas_dsyr2 = 93,
  334. RsBlas_dspr2 = 94,
  335. RsBlas_chemv = 95,
  336. RsBlas_chbmv = 96,
  337. RsBlas_chpmv = 97,
  338. RsBlas_cgeru = 98,
  339. RsBlas_cgerc = 99,
  340. RsBlas_cher = 100,
  341. RsBlas_chpr = 101,
  342. RsBlas_cher2 = 102,
  343. RsBlas_chpr2 = 103,
  344. RsBlas_zhemv = 104,
  345. RsBlas_zhbmv = 105,
  346. RsBlas_zhpmv = 106,
  347. RsBlas_zgeru = 107,
  348. RsBlas_zgerc = 108,
  349. RsBlas_zher = 109,
  350. RsBlas_zhpr = 110,
  351. RsBlas_zher2 = 111,
  352. RsBlas_zhpr2 = 112,
  353. RsBlas_sgemm = 113,
  354. RsBlas_ssymm = 114,
  355. RsBlas_ssyrk = 115,
  356. RsBlas_ssyr2k = 116,
  357. RsBlas_strmm = 117,
  358. RsBlas_strsm = 118,
  359. RsBlas_dgemm = 119,
  360. RsBlas_dsymm = 120,
  361. RsBlas_dsyrk = 121,
  362. RsBlas_dsyr2k = 122,
  363. RsBlas_dtrmm = 123,
  364. RsBlas_dtrsm = 124,
  365. RsBlas_cgemm = 125,
  366. RsBlas_csymm = 126,
  367. RsBlas_csyrk = 127,
  368. RsBlas_csyr2k = 128,
  369. RsBlas_ctrmm = 129,
  370. RsBlas_ctrsm = 130,
  371. RsBlas_zgemm = 131,
  372. RsBlas_zsymm = 132,
  373. RsBlas_zsyrk = 133,
  374. RsBlas_zsyr2k = 134,
  375. RsBlas_ztrmm = 135,
  376. RsBlas_ztrsm = 136,
  377. RsBlas_chemm = 137,
  378. RsBlas_cherk = 138,
  379. RsBlas_cher2k = 139,
  380. RsBlas_zhemm = 140,
  381. RsBlas_zherk = 141,
  382. RsBlas_zher2k = 142,
  383. // BLAS extensions start here
  384. RsBlas_bnnm = 1000,
  385. };
  386. // custom complex types because of NDK support
  387. typedef struct {
  388. float r;
  389. float i;
  390. } RsFloatComplex;
  391. typedef struct {
  392. double r;
  393. double i;
  394. } RsDoubleComplex;
  395. typedef union {
  396. float f;
  397. RsFloatComplex c;
  398. double d;
  399. RsDoubleComplex z;
  400. } RsBlasScalar;
  401. typedef struct {
  402. RsBlasFunction func;
  403. RsBlasTranspose transA;
  404. RsBlasTranspose transB;
  405. RsBlasUplo uplo;
  406. RsBlasDiag diag;
  407. RsBlasSide side;
  408. int M;
  409. int N;
  410. int K;
  411. RsBlasScalar alpha;
  412. RsBlasScalar beta;
  413. int incX;
  414. int incY;
  415. int KL;
  416. int KU;
  417. uint8_t a_offset;
  418. uint8_t b_offset;
  419. int32_t c_offset;
  420. int32_t c_mult_int;
  421. } RsBlasCall;
  422. enum RsGlobalProperty {
  423. RS_GLOBAL_TYPE = 0x0000FFFF,
  424. RS_GLOBAL_CONSTANT = 0x00010000,
  425. RS_GLOBAL_STATIC = 0x00020000,
  426. RS_GLOBAL_POINTER = 0x00040000
  427. };
  428. // Special symbols embedded into a shared object compiled by bcc.
  429. static const char kRoot[] = "root";
  430. static const char kInit[] = "init";
  431. static const char kRsDtor[] = ".rs.dtor";
  432. static const char kRsInfo[] = ".rs.info";
  433. static const char kRsGlobalEntries[] = ".rs.global_entries";
  434. static const char kRsGlobalNames[] = ".rs.global_names";
  435. static const char kRsGlobalAddresses[] = ".rs.global_addresses";
  436. static const char kRsGlobalSizes[] = ".rs.global_sizes";
  437. static const char kRsGlobalProperties[] = ".rs.global_properties";
  438. static inline uint32_t getGlobalRsType(uint32_t properties) {
  439. return properties & RS_GLOBAL_TYPE;
  440. }
  441. static inline bool isGlobalConstant(uint32_t properties) {
  442. return properties & RS_GLOBAL_CONSTANT;
  443. }
  444. static inline bool isGlobalStatic(uint32_t properties) {
  445. return properties & RS_GLOBAL_STATIC;
  446. }
  447. static inline bool isGlobalPointer(uint32_t properties) {
  448. return properties & RS_GLOBAL_POINTER;
  449. }
  450. #ifdef __cplusplus
  451. };
  452. #endif
  453. #endif // RENDER_SCRIPT_DEFINES_H