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