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