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