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