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