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