rs_structs.h revision ee883164d3fec165134b17e52c75cc90f3980269
1dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#ifndef _RS_STRUCTS_H_ 2dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#define _RS_STRUCTS_H_ 3dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 4dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen/***************************************************************************** 5dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * CAUTION 6dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * 7dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * The following structure layout provides a more efficient way to access 8dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * internal members of the C++ class Allocation owned by librs. Unfortunately, 9dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * since this class has virtual members, we can't simply use offsetof() or any 10dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * other compiler trickery to dynamically get the appropriate values at 11ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen * build-time. This layout may need to be updated whenever 12ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen * frameworks/base/libs/rs/rsAllocation.h is modified. 13ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen * 14dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * Having the layout information available in this file allows us to 15dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * accelerate functionality like rsAllocationGetDimX(). Without this 16ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen * information, we would not be able to inline the bitcode, thus resulting in 17ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen * potential runtime performance penalties for tight loops operating on 18dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * allocations. 19dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen * 20ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen *****************************************************************************/ 21ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsentypedef enum { 22ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen RS_ALLOCATION_MIPMAP_NONE = 0, 23dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen RS_ALLOCATION_MIPMAP_FULL = 1, 24dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2 25ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} rs_allocation_mipmap_control; 26ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 27dc0f95d653279beabeb9817299e2902918ba123eKristian Monsentypedef struct Allocation { 28dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen char __pad[28]; 29dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen struct { 30dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen void * drv; 31dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen struct { 32dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen const void *type; 33dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen uint32_t usageFlags; 34dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen rs_allocation_mipmap_control mipmapControl; 35dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen uint32_t yuv; 36dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen uint32_t elementSizeBytes; 37dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen bool hasMipmaps; 38dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen bool hasFaces; 39dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen bool hasReferences; 40dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen void * usrPtr; 41ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen int32_t surfaceTextureID; 42ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen void * wndSurface; 43ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen void * surfaceTexture; 44ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen } state; 45ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 46ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen struct DrvState { 47ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen struct LodState { 48ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen void * mallocPtr; 49ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen size_t stride; 50ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen uint32_t dimX; 51ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen uint32_t dimY; 52dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 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 *****************************************************************************/ 78typedef struct ProgramStore { 79 char __pad[36]; 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 *****************************************************************************/ 112typedef struct ProgramRaster { 113 char __pad[36]; 114 struct { 115 struct { 116 bool pointSprite; 117 rs_cull_mode cull; 118 } state; 119 } mHal; 120} ProgramRaster_t; 121 122/***************************************************************************** 123 * CAUTION 124 * 125 * The following structure layout provides a more efficient way to access 126 * internal members of the C++ class Sampler owned by librs. Unfortunately, 127 * since this class has virtual members, we can't simply use offsetof() or any 128 * other compiler trickery to dynamically get the appropriate values at 129 * build-time. This layout may need to be updated whenever 130 * frameworks/base/libs/rs/rsSampler.h is modified. 131 * 132 * Having the layout information available in this file allows us to 133 * accelerate functionality like rsgProgramRasterGetMagFilter(). Without this 134 * information, we would not be able to inline the bitcode, thus resulting in 135 * potential runtime performance penalties for tight loops operating on 136 * samplers. 137 * 138 *****************************************************************************/ 139typedef struct Sampler { 140 char __pad[28]; 141 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 *****************************************************************************/ 172typedef struct Element { 173 char __pad[28]; 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 *****************************************************************************/ 210typedef struct Type { 211 char __pad[28]; 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 *****************************************************************************/ 246typedef struct Mesh { 247 char __pad[28]; 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