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