rs_hal.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. /*
  2. * Copyright (C) 2011-2012 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 RS_HAL_H
  17. #define RS_HAL_H
  18. #include <rsInternalDefines.h>
  19. /*
  20. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  21. * !! Major version number of the driver. This is used to ensure that
  22. * !! the driver (e.g., libRSDriver) is compatible with the shell
  23. * !! (i.e., libRS_internal) responsible for loading the driver.
  24. * !! There is no notion of backwards compatibility -- the driver and
  25. * !! the shell must agree on the major version number.
  26. * !!
  27. * !! The version number must change whenever there is a semantic change
  28. * !! to the HAL such as adding or removing an entry point or changing
  29. * !! the meaning of an entry point. By convention it is monotonically
  30. * !! increasing across all branches (e.g., aosp/master and all internal
  31. * !! branches).
  32. * !!
  33. * !! Be very careful when merging or cherry picking between branches!
  34. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  35. */
  36. #define RS_HAL_VERSION 200
  37. /**
  38. * The interface for loading RenderScript drivers
  39. *
  40. * The startup sequence is
  41. *
  42. * 1: dlopen driver
  43. * 2: Query driver version with rsdHalQueryVersion() and verify
  44. * that the driver (e.g., libRSDriver) is compatible with the shell
  45. * (i.e., libRS_internal) responsible for loading the driver
  46. * 3: Fill in HAL pointer table with calls to rsdHalQueryHAL()
  47. * 4: Initialize the context with rsdHalInit()
  48. *
  49. * If any of these functions return false, the loading of the
  50. * driver will abort and the reference driver will be used.
  51. * rsdHalAbort() will be called to clean up any partially
  52. * allocated state.
  53. *
  54. * A driver should return FALSE for any conditions that will
  55. * prevent the driver from working normally.
  56. *
  57. *
  58. * If these are successful, the driver will be loaded and used
  59. * normally. Teardown will use the normal
  60. * context->mHal.funcs.shutdown() path. There will be no call
  61. * to rsdHalAbort().
  62. *
  63. *
  64. */
  65. struct ANativeWindow;
  66. namespace android {
  67. namespace renderscript {
  68. class Context;
  69. class ObjectBase;
  70. class Element;
  71. class Type;
  72. class Allocation;
  73. class Script;
  74. class ScriptKernelID;
  75. class ScriptFieldID;
  76. class ScriptMethodID;
  77. class ScriptC;
  78. class ScriptGroup;
  79. class ScriptGroupBase;
  80. class Path;
  81. class Program;
  82. class ProgramStore;
  83. class ProgramRaster;
  84. class ProgramVertex;
  85. class ProgramFragment;
  86. class Mesh;
  87. class Sampler;
  88. class FBOCache;
  89. /**
  90. * Define the internal object types. This ia a mirror of the
  91. * definition in rs_types.rsh except with the p value typed
  92. * correctly.
  93. *
  94. * p = pointer to internal object implementation
  95. * unused1, unused2, unused3 = reserved for ABI compatibility
  96. */
  97. // RS_BASE_OBJ must have the same layout as _RS_OBJECT_DECL defined in
  98. // script_api/rs_object_types.spec.
  99. // TODO(jeanluc) Look at unifying.
  100. #ifndef __LP64__
  101. #define RS_BASE_OBJ(_t_) typedef struct { const _t_* p; } __attribute__((packed, aligned(4)))
  102. #define RS_BASE_NULL_OBJ {0}
  103. #else
  104. #define RS_BASE_OBJ(_t_) typedef struct { const _t_* p; const void* unused1; const void* unused2; const void* unused3; }
  105. #define RS_BASE_NULL_OBJ {0, 0, 0, 0}
  106. #endif
  107. RS_BASE_OBJ(ObjectBase) rs_object_base;
  108. RS_BASE_OBJ(Element) rs_element;
  109. RS_BASE_OBJ(Type) rs_type;
  110. RS_BASE_OBJ(Allocation) rs_allocation;
  111. RS_BASE_OBJ(Sampler) rs_sampler;
  112. RS_BASE_OBJ(Script) rs_script;
  113. RS_BASE_OBJ(ScriptGroup) rs_script_group;
  114. #ifndef __LP64__
  115. typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_mesh;
  116. typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_fragment;
  117. typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_vertex;
  118. typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_raster;
  119. typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_store;
  120. typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_font;
  121. #endif // __LP64__
  122. typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
  123. /**
  124. * Script management functions
  125. */
  126. typedef struct {
  127. int (*initGraphics)(const Context *);
  128. void (*shutdownGraphics)(const Context *);
  129. bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
  130. void (*swap)(const Context *);
  131. void (*shutdownDriver)(Context *);
  132. void (*setPriority)(const Context *, int32_t priority);
  133. void* (*allocRuntimeMem)(size_t size, uint32_t flags);
  134. void (*freeRuntimeMem)(void* ptr);
  135. struct {
  136. bool (*init)(const Context *rsc, ScriptC *s,
  137. char const *resName,
  138. char const *cacheDir,
  139. uint8_t const *bitcode,
  140. size_t bitcodeSize,
  141. uint32_t flags);
  142. bool (*initIntrinsic)(const Context *rsc, Script *s,
  143. RsScriptIntrinsicID iid,
  144. Element *e);
  145. void (*invokeFunction)(const Context *rsc, Script *s,
  146. uint32_t slot,
  147. const void *params,
  148. size_t paramLength);
  149. int (*invokeRoot)(const Context *rsc, Script *s);
  150. void (*invokeForEach)(const Context *rsc,
  151. Script *s,
  152. uint32_t slot,
  153. const Allocation * ain,
  154. Allocation * aout,
  155. const void * usr,
  156. size_t usrLen,
  157. const RsScriptCall *sc);
  158. void (*invokeReduce)(const Context *rsc, Script *s,
  159. uint32_t slot,
  160. const Allocation ** ains, size_t inLen,
  161. Allocation *aout,
  162. const RsScriptCall *sc);
  163. void (*invokeInit)(const Context *rsc, Script *s);
  164. void (*invokeFreeChildren)(const Context *rsc, Script *s);
  165. void (*setGlobalVar)(const Context *rsc, const Script *s,
  166. uint32_t slot,
  167. void *data,
  168. size_t dataLength);
  169. void (*getGlobalVar)(const Context *rsc, const Script *s,
  170. uint32_t slot,
  171. void *data,
  172. size_t dataLength);
  173. void (*setGlobalVarWithElemDims)(const Context *rsc, const Script *s,
  174. uint32_t slot,
  175. void *data,
  176. size_t dataLength,
  177. const Element *e,
  178. const uint32_t *dims,
  179. size_t dimLength);
  180. void (*setGlobalBind)(const Context *rsc, const Script *s,
  181. uint32_t slot,
  182. Allocation *data);
  183. void (*setGlobalObj)(const Context *rsc, const Script *s,
  184. uint32_t slot,
  185. ObjectBase *data);
  186. void (*destroy)(const Context *rsc, Script *s);
  187. void (*invokeForEachMulti)(const Context *rsc,
  188. Script *s,
  189. uint32_t slot,
  190. const Allocation ** ains,
  191. size_t inLen,
  192. Allocation * aout,
  193. const void * usr,
  194. size_t usrLen,
  195. const RsScriptCall *sc);
  196. void (*updateCachedObject)(const Context *rsc, const Script *, rs_script *obj);
  197. } script;
  198. struct {
  199. bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
  200. bool (*initOem)(const Context *rsc, Allocation *alloc, bool forceZero, void *usrPtr);
  201. bool (*initAdapter)(const Context *rsc, Allocation *alloc);
  202. void (*destroy)(const Context *rsc, Allocation *alloc);
  203. uint32_t (*grallocBits)(const Context *rsc, Allocation *alloc);
  204. void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
  205. bool zeroNew);
  206. void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
  207. void (*markDirty)(const Context *rsc, const Allocation *alloc);
  208. void (*setSurface)(const Context *rsc, Allocation *alloc, ANativeWindow *sur);
  209. void (*ioSend)(const Context *rsc, Allocation *alloc);
  210. /**
  211. * A new gralloc buffer is in use. The pointers and strides in
  212. * mHal.drvState.lod[0-2] will be updated with the new values.
  213. *
  214. * The new gralloc handle is provided in mHal.state.nativeBuffer
  215. *
  216. */
  217. void (*ioReceive)(const Context *rsc, Allocation *alloc);
  218. void (*data1D)(const Context *rsc, const Allocation *alloc,
  219. uint32_t xoff, uint32_t lod, size_t count,
  220. const void *data, size_t sizeBytes);
  221. void (*data2D)(const Context *rsc, const Allocation *alloc,
  222. uint32_t xoff, uint32_t yoff, uint32_t lod,
  223. RsAllocationCubemapFace face, uint32_t w, uint32_t h,
  224. const void *data, size_t sizeBytes, size_t stride);
  225. void (*data3D)(const Context *rsc, const Allocation *alloc,
  226. uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
  227. uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes,
  228. size_t stride);
  229. void (*read1D)(const Context *rsc, const Allocation *alloc,
  230. uint32_t xoff, uint32_t lod, size_t count,
  231. void *data, size_t sizeBytes);
  232. void (*read2D)(const Context *rsc, const Allocation *alloc,
  233. uint32_t xoff, uint32_t yoff, uint32_t lod,
  234. RsAllocationCubemapFace face, uint32_t w, uint32_t h,
  235. void *data, size_t sizeBytes, size_t stride);
  236. void (*read3D)(const Context *rsc, const Allocation *alloc,
  237. uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
  238. uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes,
  239. size_t stride);
  240. // Lock and unlock make a 1D region of memory available to the CPU
  241. // for direct access by pointer. Once unlock is called control is
  242. // returned to the SOC driver.
  243. void * (*lock1D)(const Context *rsc, const Allocation *alloc);
  244. void (*unlock1D)(const Context *rsc, const Allocation *alloc);
  245. // Allocation to allocation copies
  246. void (*allocData1D)(const Context *rsc,
  247. const Allocation *dstAlloc,
  248. uint32_t dstXoff, uint32_t dstLod, size_t count,
  249. const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
  250. void (*allocData2D)(const Context *rsc,
  251. const Allocation *dstAlloc,
  252. uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
  253. RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
  254. const Allocation *srcAlloc,
  255. uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
  256. RsAllocationCubemapFace srcFace);
  257. void (*allocData3D)(const Context *rsc,
  258. const Allocation *dstAlloc,
  259. uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
  260. uint32_t dstLod,
  261. uint32_t w, uint32_t h, uint32_t d,
  262. const Allocation *srcAlloc,
  263. uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
  264. uint32_t srcLod);
  265. void (*elementData)(const Context *rsc, const Allocation *alloc,
  266. uint32_t x, uint32_t y, uint32_t z,
  267. const void *data, uint32_t elementOff, size_t sizeBytes);
  268. void (*elementRead)(const Context *rsc, const Allocation *alloc,
  269. uint32_t x, uint32_t y, uint32_t z,
  270. void *data, uint32_t elementOff, size_t sizeBytes);
  271. void (*generateMipmaps)(const Context *rsc, const Allocation *alloc);
  272. void (*updateCachedObject)(const Context *rsc, const Allocation *alloc, rs_allocation *obj);
  273. void (*adapterOffset)(const Context *rsc, const Allocation *alloc);
  274. void (*getPointer)(const Context *rsc, const Allocation *alloc,
  275. uint32_t lod, RsAllocationCubemapFace face,
  276. uint32_t z, uint32_t array);
  277. #ifdef RS_COMPATIBILITY_LIB
  278. bool (*initStrided)(const Context *rsc, Allocation *alloc, bool forceZero, size_t requiredAlignment);
  279. #endif
  280. } allocation;
  281. struct {
  282. bool (*init)(const Context *rsc, const ProgramStore *ps);
  283. void (*setActive)(const Context *rsc, const ProgramStore *ps);
  284. void (*destroy)(const Context *rsc, const ProgramStore *ps);
  285. } store;
  286. struct {
  287. bool (*init)(const Context *rsc, const ProgramRaster *ps);
  288. void (*setActive)(const Context *rsc, const ProgramRaster *ps);
  289. void (*destroy)(const Context *rsc, const ProgramRaster *ps);
  290. } raster;
  291. struct {
  292. bool (*init)(const Context *rsc, const ProgramVertex *pv,
  293. const char* shader, size_t shaderLen,
  294. const char** textureNames, size_t textureNamesCount,
  295. const size_t *textureNamesLength);
  296. void (*setActive)(const Context *rsc, const ProgramVertex *pv);
  297. void (*destroy)(const Context *rsc, const ProgramVertex *pv);
  298. } vertex;
  299. struct {
  300. bool (*init)(const Context *rsc, const ProgramFragment *pf,
  301. const char* shader, size_t shaderLen,
  302. const char** textureNames, size_t textureNamesCount,
  303. const size_t *textureNamesLength);
  304. void (*setActive)(const Context *rsc, const ProgramFragment *pf);
  305. void (*destroy)(const Context *rsc, const ProgramFragment *pf);
  306. } fragment;
  307. struct {
  308. bool (*init)(const Context *rsc, const Mesh *m);
  309. void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
  310. void (*destroy)(const Context *rsc, const Mesh *m);
  311. } mesh;
  312. struct {
  313. bool (*init)(const Context *rsc, const Sampler *m);
  314. void (*destroy)(const Context *rsc, const Sampler *m);
  315. void (*updateCachedObject)(const Context *rsc, const Sampler *s, rs_sampler *obj);
  316. } sampler;
  317. struct {
  318. bool (*init)(const Context *rsc, const FBOCache *fb);
  319. void (*setActive)(const Context *rsc, const FBOCache *fb);
  320. void (*destroy)(const Context *rsc, const FBOCache *fb);
  321. } framebuffer;
  322. struct {
  323. bool (*init)(const Context *rsc, ScriptGroupBase *sg);
  324. void (*setInput)(const Context *rsc, const ScriptGroup *sg,
  325. const ScriptKernelID *kid, Allocation *);
  326. void (*setOutput)(const Context *rsc, const ScriptGroup *sg,
  327. const ScriptKernelID *kid, Allocation *);
  328. void (*execute)(const Context *rsc, const ScriptGroupBase *sg);
  329. void (*destroy)(const Context *rsc, const ScriptGroupBase *sg);
  330. void (*updateCachedObject)(const Context *rsc, const ScriptGroup *sg, rs_script_group *obj);
  331. } scriptgroup;
  332. struct {
  333. bool (*init)(const Context *rsc, const Type *m);
  334. void (*destroy)(const Context *rsc, const Type *m);
  335. void (*updateCachedObject)(const Context *rsc, const Type *s, rs_type *obj);
  336. } type;
  337. struct {
  338. bool (*init)(const Context *rsc, const Element *m);
  339. void (*destroy)(const Context *rsc, const Element *m);
  340. void (*updateCachedObject)(const Context *rsc, const Element *s, rs_element *obj);
  341. } element;
  342. void (*finish)(const Context *rsc);
  343. } RsdHalFunctions;
  344. enum RsHalInitEnums {
  345. RS_HAL_CORE_SHUTDOWN = 1,
  346. RS_HAL_CORE_SET_PRIORITY = 2,
  347. RS_HAL_CORE_ALLOC_RUNTIME_MEM = 3,
  348. RS_HAL_CORE_FREE_RUNTIME_MEM = 4,
  349. RS_HAL_CORE_FINISH = 5,
  350. RS_HAL_SCRIPT_INIT = 1000,
  351. RS_HAL_SCRIPT_INIT_INTRINSIC = 1001,
  352. RS_HAL_SCRIPT_INVOKE_FUNCTION = 1002,
  353. RS_HAL_SCRIPT_INVOKE_ROOT = 1003,
  354. RS_HAL_SCRIPT_INVOKE_FOR_EACH = 1004,
  355. RS_HAL_SCRIPT_INVOKE_INIT = 1005,
  356. RS_HAL_SCRIPT_INVOKE_FREE_CHILDREN = 1006,
  357. RS_HAL_SCRIPT_SET_GLOBAL_VAR = 1007,
  358. RS_HAL_SCRIPT_GET_GLOBAL_VAR = 1008,
  359. RS_HAL_SCRIPT_SET_GLOBAL_VAR_WITH_ELEMENT_DIM = 1009,
  360. RS_HAL_SCRIPT_SET_GLOBAL_BIND = 1010,
  361. RS_HAL_SCRIPT_SET_GLOBAL_OBJECT = 1011,
  362. RS_HAL_SCRIPT_DESTROY = 1012,
  363. RS_HAL_SCRIPT_INVOKE_FOR_EACH_MULTI = 1013,
  364. RS_HAL_SCRIPT_UPDATE_CACHED_OBJECT = 1014,
  365. RS_HAL_SCRIPT_INVOKE_REDUCE = 1015,
  366. RS_HAL_ALLOCATION_INIT = 2000,
  367. RS_HAL_ALLOCATION_INIT_ADAPTER = 2001,
  368. RS_HAL_ALLOCATION_DESTROY = 2002,
  369. RS_HAL_ALLOCATION_GET_GRALLOC_BITS = 2003,
  370. RS_HAL_ALLOCATION_RESIZE = 2004,
  371. RS_HAL_ALLOCATION_SYNC_ALL = 2005,
  372. RS_HAL_ALLOCATION_MARK_DIRTY = 2006,
  373. RS_HAL_ALLOCATION_SET_SURFACE = 2007,
  374. RS_HAL_ALLOCATION_IO_SEND = 2008,
  375. RS_HAL_ALLOCATION_IO_RECEIVE = 2009,
  376. RS_HAL_ALLOCATION_DATA_1D = 2010,
  377. RS_HAL_ALLOCATION_DATA_2D = 2011,
  378. RS_HAL_ALLOCATION_DATA_3D = 2012,
  379. RS_HAL_ALLOCATION_READ_1D = 2013,
  380. RS_HAL_ALLOCATION_READ_2D = 2014,
  381. RS_HAL_ALLOCATION_READ_3D = 2015,
  382. RS_HAL_ALLOCATION_LOCK_1D = 2016,
  383. RS_HAL_ALLOCATION_UNLOCK_1D = 2017,
  384. RS_HAL_ALLOCATION_COPY_1D = 2018,
  385. RS_HAL_ALLOCATION_COPY_2D = 2019,
  386. RS_HAL_ALLOCATION_COPY_3D = 2020,
  387. RS_HAL_ALLOCATION_ELEMENT_DATA = 2021,
  388. RS_HAL_ALLOCATION_ELEMENT_READ = 2022,
  389. RS_HAL_ALLOCATION_GENERATE_MIPMAPS = 2023,
  390. RS_HAL_ALLOCATION_UPDATE_CACHED_OBJECT = 2024,
  391. RS_HAL_ALLOCATION_ADAPTER_OFFSET = 2025,
  392. RS_HAL_ALLOCATION_INIT_OEM = 2026,
  393. RS_HAL_ALLOCATION_GET_POINTER = 2027,
  394. #ifdef RS_COMPATIBILITY_LIB
  395. RS_HAL_ALLOCATION_INIT_STRIDED = 2999,
  396. #endif
  397. RS_HAL_SAMPLER_INIT = 3000,
  398. RS_HAL_SAMPLER_DESTROY = 3001,
  399. RS_HAL_SAMPLER_UPDATE_CACHED_OBJECT = 3002,
  400. RS_HAL_TYPE_INIT = 4000,
  401. RS_HAL_TYPE_DESTROY = 4001,
  402. RS_HAL_TYPE_UPDATE_CACHED_OBJECT = 4002,
  403. RS_HAL_ELEMENT_INIT = 5000,
  404. RS_HAL_ELEMENT_DESTROY = 5001,
  405. RS_HAL_ELEMENT_UPDATE_CACHED_OBJECT = 5002,
  406. RS_HAL_SCRIPT_GROUP_INIT = 6000,
  407. RS_HAL_SCRIPT_GROUP_DESTROY = 6001,
  408. RS_HAL_SCRIPT_GROUP_UPDATE_CACHED_OBJECT = 6002,
  409. RS_HAL_SCRIPT_GROUP_SET_INPUT = 6003,
  410. RS_HAL_SCRIPT_GROUP_SET_OUTPUT = 6004,
  411. RS_HAL_SCRIPT_GROUP_EXECUTE = 6005,
  412. RS_HAL_GRAPHICS_INIT = 100001,
  413. RS_HAL_GRAPHICS_SHUTDOWN = 100002,
  414. RS_HAL_GRAPHICS_SWAP = 100003,
  415. RS_HAL_GRAPHICS_SET_SURFACE = 100004,
  416. RS_HAL_GRAPHICS_RASTER_INIT = 101000,
  417. RS_HAL_GRAPHICS_RASTER_SET_ACTIVE = 101001,
  418. RS_HAL_GRAPHICS_RASTER_DESTROY = 101002,
  419. RS_HAL_GRAPHICS_VERTEX_INIT = 102000,
  420. RS_HAL_GRAPHICS_VERTEX_SET_ACTIVE = 102001,
  421. RS_HAL_GRAPHICS_VERTEX_DESTROY = 102002,
  422. RS_HAL_GRAPHICS_FRAGMENT_INIT = 103000,
  423. RS_HAL_GRAPHICS_FRAGMENT_SET_ACTIVE = 103001,
  424. RS_HAL_GRAPHICS_FRAGMENT_DESTROY = 103002,
  425. RS_HAL_GRAPHICS_MESH_INIT = 104000,
  426. RS_HAL_GRAPHICS_MESH_DRAW = 104001,
  427. RS_HAL_GRAPHICS_MESH_DESTROY = 104002,
  428. RS_HAL_GRAPHICS_FB_INIT = 105000,
  429. RS_HAL_GRAPHICS_FB_SET_ACTIVE = 105001,
  430. RS_HAL_GRAPHICS_FB_DESTROY = 105002,
  431. RS_HAL_GRAPHICS_STORE_INIT = 106000,
  432. RS_HAL_GRAPHICS_STORE_SET_ACTIVE = 106001,
  433. RS_HAL_GRAPHICS_STORE_DESTROY = 106002,
  434. };
  435. } // namespace renderscript
  436. } // namespace android
  437. #ifdef __cplusplus
  438. extern "C" {
  439. #endif
  440. /**
  441. * Get the major version number of the driver. The major
  442. * version should be the RS_HAL_VERSION against which the
  443. * driver was built
  444. *
  445. * The Minor version number is vendor specific
  446. *
  447. * The caller should ensure that *version_major is the same as
  448. * RS_HAL_VERSION -- i.e., that the driver (e.g., libRSDriver)
  449. * is compatible with the shell (i.e., libRS_internal) responsible
  450. * for loading the driver
  451. *
  452. * return: False will abort loading the driver, true indicates
  453. * success
  454. */
  455. bool rsdHalQueryVersion(uint32_t *version_major, uint32_t *version_minor);
  456. /**
  457. * Get an entry point in the driver HAL
  458. *
  459. * The driver should set the function pointer to its
  460. * implementation of the function. If it does not have an entry
  461. * for an enum, its should set the function pointer to NULL
  462. *
  463. * Returning NULL is expected in cases during development as new
  464. * entry points are added that a driver may not understand. If
  465. * the runtime receives a NULL it will decide if the function is
  466. * required and will either continue loading or abort as needed.
  467. *
  468. *
  469. * return: False will abort loading the driver, true indicates
  470. * success
  471. *
  472. */
  473. bool rsdHalQueryHal(android::renderscript::RsHalInitEnums entry, void **fnPtr);
  474. /**
  475. * Called to initialize the context for use with a driver.
  476. *
  477. * return: False will abort loading the driver, true indicates
  478. * success
  479. */
  480. bool rsdHalInit(RsContext, uint32_t version_major, uint32_t version_minor);
  481. /**
  482. * Called if one of the loading functions above returns false.
  483. * This is to clean up any resources allocated during an error
  484. * condition. If this path is called it means the normal
  485. * context->mHal.funcs.shutdown() will not be called.
  486. */
  487. void rsdHalAbort(RsContext);
  488. #ifdef __cplusplus
  489. }
  490. #endif
  491. #endif