rs_structs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. #ifndef _RS_STRUCTS_H_
  2. #define _RS_STRUCTS_H_
  3. #include "rs_core.rsh"
  4. #include "rs_graphics.rsh"
  5. /*****************************************************************************
  6. * CAUTION
  7. *
  8. * The following structure layout provides a more efficient way to access
  9. * internal members of the C++ class Allocation owned by librs. Unfortunately,
  10. * since this class has virtual members, we can't simply use offsetof() or any
  11. * other compiler trickery to dynamically get the appropriate values at
  12. * build-time. This layout may need to be updated whenever
  13. * frameworks/base/libs/rs/rsAllocation.h is modified.
  14. *
  15. * Having the layout information available in this file allows us to
  16. * accelerate functionality like rsAllocationGetDimX(). Without this
  17. * information, we would not be able to inline the bitcode, thus resulting in
  18. * potential runtime performance penalties for tight loops operating on
  19. * allocations.
  20. *
  21. *****************************************************************************/
  22. typedef enum {
  23. RS_ALLOCATION_MIPMAP_NONE = 0,
  24. RS_ALLOCATION_MIPMAP_FULL = 1,
  25. RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2
  26. } rs_allocation_mipmap_control;
  27. typedef struct Allocation {
  28. #ifndef __LP64__
  29. char __pad[32];
  30. #else
  31. char __pad[56];
  32. #endif
  33. struct {
  34. void * drv;
  35. struct {
  36. const void *type;
  37. uint32_t usageFlags;
  38. rs_allocation_mipmap_control mipmapControl;
  39. uint32_t yuv;
  40. uint32_t elementSizeBytes;
  41. bool hasMipmaps;
  42. bool hasFaces;
  43. bool hasReferences;
  44. void * usrPtr;
  45. int32_t surfaceTextureID;
  46. void * nativeBuffer;
  47. int64_t timestamp;
  48. // Allocation adapter state
  49. const void *baseAlloc;
  50. uint32_t originX;
  51. uint32_t originY;
  52. uint32_t originZ;
  53. uint32_t originLOD;
  54. uint32_t originFace;
  55. uint32_t originArray[4/*Type::mMaxArrays*/];
  56. } state;
  57. struct DrvState {
  58. struct LodState {
  59. void * mallocPtr;
  60. size_t stride;
  61. uint32_t dimX;
  62. uint32_t dimY;
  63. uint32_t dimZ;
  64. } lod[16/*android::renderscript::Allocation::MAX_LOD*/];
  65. size_t faceOffset;
  66. uint32_t lodCount;
  67. uint32_t faceCount;
  68. struct YuvState {
  69. uint32_t shift;
  70. uint32_t step;
  71. } yuv;
  72. int grallocFlags;
  73. uint32_t dimArray[4/*Type::mMaxArrays*/];
  74. } drvState;
  75. } mHal;
  76. } Allocation_t;
  77. #ifndef __LP64__
  78. /*****************************************************************************
  79. * CAUTION
  80. *
  81. * The following structure layout provides a more efficient way to access
  82. * internal members of the C++ class ProgramStore owned by librs. Unfortunately,
  83. * since this class has virtual members, we can't simply use offsetof() or any
  84. * other compiler trickery to dynamically get the appropriate values at
  85. * build-time. This layout may need to be updated whenever
  86. * frameworks/base/libs/rs/rsProgramStore.h is modified.
  87. *
  88. * Having the layout information available in this file allows us to
  89. * accelerate functionality like rsgProgramStoreGetDepthFunc(). Without this
  90. * information, we would not be able to inline the bitcode, thus resulting in
  91. * potential runtime performance penalties for tight loops operating on
  92. * program store.
  93. *
  94. *****************************************************************************/
  95. typedef struct ProgramStore {
  96. char __pad[40];
  97. struct {
  98. struct {
  99. bool ditherEnable;
  100. bool colorRWriteEnable;
  101. bool colorGWriteEnable;
  102. bool colorBWriteEnable;
  103. bool colorAWriteEnable;
  104. rs_blend_src_func blendSrc;
  105. rs_blend_dst_func blendDst;
  106. bool depthWriteEnable;
  107. rs_depth_func depthFunc;
  108. } state;
  109. } mHal;
  110. } ProgramStore_t;
  111. /*****************************************************************************
  112. * CAUTION
  113. *
  114. * The following structure layout provides a more efficient way to access
  115. * internal members of the C++ class ProgramRaster owned by librs. Unfortunately,
  116. * since this class has virtual members, we can't simply use offsetof() or any
  117. * other compiler trickery to dynamically get the appropriate values at
  118. * build-time. This layout may need to be updated whenever
  119. * frameworks/base/libs/rs/rsProgramRaster.h is modified.
  120. *
  121. * Having the layout information available in this file allows us to
  122. * accelerate functionality like rsgProgramRasterGetCullMode(). Without this
  123. * information, we would not be able to inline the bitcode, thus resulting in
  124. * potential runtime performance penalties for tight loops operating on
  125. * program raster.
  126. *
  127. *****************************************************************************/
  128. typedef struct ProgramRaster {
  129. char __pad[36];
  130. struct {
  131. void * drv;
  132. struct {
  133. bool pointSprite;
  134. rs_cull_mode cull;
  135. } state;
  136. } mHal;
  137. } ProgramRaster_t;
  138. #endif //__LP64__
  139. /*****************************************************************************
  140. * CAUTION
  141. *
  142. * The following structure layout provides a more efficient way to access
  143. * internal members of the C++ class Sampler owned by librs. Unfortunately,
  144. * since this class has virtual members, we can't simply use offsetof() or any
  145. * other compiler trickery to dynamically get the appropriate values at
  146. * build-time. This layout may need to be updated whenever
  147. * frameworks/base/libs/rs/rsSampler.h is modified.
  148. *
  149. * Having the layout information available in this file allows us to
  150. * accelerate functionality like rsgProgramRasterGetMagFilter(). Without this
  151. * information, we would not be able to inline the bitcode, thus resulting in
  152. * potential runtime performance penalties for tight loops operating on
  153. * samplers.
  154. *
  155. *****************************************************************************/
  156. typedef struct Sampler {
  157. #ifndef __LP64__
  158. char __pad[32];
  159. #else
  160. char __pad[56];
  161. #endif
  162. struct {
  163. void *drv;
  164. struct {
  165. rs_sampler_value magFilter;
  166. rs_sampler_value minFilter;
  167. rs_sampler_value wrapS;
  168. rs_sampler_value wrapT;
  169. rs_sampler_value wrapR;
  170. float aniso;
  171. } state;
  172. } mHal;
  173. } Sampler_t;
  174. /*****************************************************************************
  175. * CAUTION
  176. *
  177. * The following structure layout provides a more efficient way to access
  178. * internal members of the C++ class Element owned by librs. Unfortunately,
  179. * since this class has virtual members, we can't simply use offsetof() or any
  180. * other compiler trickery to dynamically get the appropriate values at
  181. * build-time. This layout may need to be updated whenever
  182. * frameworks/base/libs/rs/rsElement.h is modified.
  183. *
  184. * Having the layout information available in this file allows us to
  185. * accelerate functionality like rsElementGetSubElementCount(). Without this
  186. * information, we would not be able to inline the bitcode, thus resulting in
  187. * potential runtime performance penalties for tight loops operating on
  188. * elements.
  189. *
  190. *****************************************************************************/
  191. typedef struct Element {
  192. #ifndef __LP64__
  193. char __pad[32];
  194. #else
  195. char __pad[56];
  196. #endif
  197. struct {
  198. void *drv;
  199. struct {
  200. rs_data_type dataType;
  201. rs_data_kind dataKind;
  202. uint32_t vectorSize;
  203. uint32_t elementSizeBytes;
  204. // Subelements
  205. const void **fields;
  206. uint32_t *fieldArraySizes;
  207. const char **fieldNames;
  208. uint32_t *fieldNameLengths;
  209. uint32_t *fieldOffsetBytes;
  210. uint32_t fieldsCount;
  211. } state;
  212. } mHal;
  213. } Element_t;
  214. /*****************************************************************************
  215. * CAUTION
  216. *
  217. * The following structure layout provides a more efficient way to access
  218. * internal members of the C++ class Type owned by librs. Unfortunately,
  219. * since this class has virtual members, we can't simply use offsetof() or any
  220. * other compiler trickery to dynamically get the appropriate values at
  221. * build-time. This layout may need to be updated whenever
  222. * frameworks/base/libs/rs/rsType.h is modified.
  223. *
  224. * Having the layout information available in this file allows us to
  225. * accelerate functionality like rsAllocationGetElement(). Without this
  226. * information, we would not be able to inline the bitcode, thus resulting in
  227. * potential runtime performance penalties for tight loops operating on
  228. * types.
  229. *
  230. *****************************************************************************/
  231. typedef struct Type {
  232. #ifndef __LP64__
  233. char __pad[32];
  234. #else
  235. char __pad[56];
  236. #endif
  237. struct {
  238. void *drv;
  239. struct {
  240. const void * element;
  241. uint32_t dimX;
  242. uint32_t dimY;
  243. uint32_t dimZ;
  244. uint32_t *lodDimX;
  245. uint32_t *lodDimY;
  246. uint32_t *lodDimZ;
  247. uint32_t *arrays;
  248. uint32_t lodCount;
  249. uint32_t dimYuv;
  250. uint32_t arrayCount;
  251. bool faces;
  252. } state;
  253. } mHal;
  254. } Type_t;
  255. #ifndef __LP64__
  256. /*****************************************************************************
  257. * CAUTION
  258. *
  259. * The following structure layout provides a more efficient way to access
  260. * internal members of the C++ class Mesh owned by librs. Unfortunately,
  261. * since this class has virtual members, we can't simply use offsetof() or any
  262. * other compiler trickery to dynamically get the appropriate values at
  263. * build-time. This layout may need to be updated whenever
  264. * frameworks/base/libs/rs/rsMesh.h is modified.
  265. *
  266. * Having the layout information available in this file allows us to
  267. * accelerate functionality like rsMeshGetVertexAllocationCount(). Without this
  268. * information, we would not be able to inline the bitcode, thus resulting in
  269. * potential runtime performance penalties for tight loops operating on
  270. * meshes.
  271. *
  272. *****************************************************************************/
  273. typedef struct Mesh {
  274. char __pad[32];
  275. struct {
  276. void *drv;
  277. struct {
  278. void **vertexBuffers;
  279. uint32_t vertexBuffersCount;
  280. // indexBuffers[i] could be nullptr, in which case only primitives[i] is used
  281. void **indexBuffers;
  282. uint32_t indexBuffersCount;
  283. rs_primitive *primitives;
  284. uint32_t primitivesCount;
  285. } state;
  286. } mHal;
  287. } Mesh_t;
  288. #endif //__LP64__
  289. // Null version of _RS_OBJECT_DECL defined in script_api/rs_object_types.spec
  290. #ifndef __LP64__
  291. #define RS_NULL_OBJ {0}
  292. #else
  293. #define RS_NULL_OBJ {0, 0, 0, 0}
  294. #endif //__LP64__
  295. #endif // _RS_CORE_H_