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