blob: 2d66190127c6537dc63b3408bd203ffdeac05ec4 [file] [log] [blame]
Stephen Hines5a470202013-05-29 15:36:18 -07001#ifndef _RS_STRUCTS_H_
2#define _RS_STRUCTS_H_
3
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07004#include "rs_core.rsh"
5#include "rs_graphics.rsh"
6
Stephen Hines5a470202013-05-29 15:36:18 -07007/*****************************************************************************
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 *****************************************************************************/
24typedef 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
30typedef struct Allocation {
Tim Murraye3af53b2014-06-10 09:46:51 -070031#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -070032 char __pad[32];
Tim Murraye3af53b2014-06-10 09:46:51 -070033#else
34 char __pad[56];
35#endif
Stephen Hines5a470202013-05-29 15:36:18 -070036 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 Samsddceab92013-08-07 13:02:32 -070049 void * nativeBuffer;
50 int64_t timestamp;
Jason Samsbc9dc272015-02-09 12:50:22 -080051
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 Hines5a470202013-05-29 15:36:18 -070060 } 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 Sams61656a72013-09-03 16:21:18 -070073
74 struct YuvState {
75 uint32_t shift;
76 uint32_t step;
77 } yuv;
Jason Samsbc9dc272015-02-09 12:50:22 -080078
79 int grallocFlags;
80 uint32_t dimArray[4/*Type::mMaxArrays*/];
Stephen Hines5a470202013-05-29 15:36:18 -070081 } drvState;
82 } mHal;
83} Allocation_t;
84
Jason Sams3ff0fe72014-05-19 15:06:59 -070085#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -070086/*****************************************************************************
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 *****************************************************************************/
103typedef 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 *****************************************************************************/
137typedef 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 Sams3ff0fe72014-05-19 15:06:59 -0700147#endif //__LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700148
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 *****************************************************************************/
166typedef struct Sampler {
Tim Murraye3af53b2014-06-10 09:46:51 -0700167#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700168 char __pad[32];
Tim Murraye3af53b2014-06-10 09:46:51 -0700169#else
170 char __pad[56];
171#endif
Stephen Hines5a470202013-05-29 15:36:18 -0700172 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 *****************************************************************************/
202typedef struct Element {
Tim Murraye3af53b2014-06-10 09:46:51 -0700203#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700204 char __pad[32];
Tim Murraye3af53b2014-06-10 09:46:51 -0700205#else
206 char __pad[56];
207#endif
Stephen Hines5a470202013-05-29 15:36:18 -0700208 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 *****************************************************************************/
244typedef struct Type {
Tim Murraye3af53b2014-06-10 09:46:51 -0700245#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700246 char __pad[32];
Tim Murraye3af53b2014-06-10 09:46:51 -0700247#else
248 char __pad[56];
249#endif
Stephen Hines5a470202013-05-29 15:36:18 -0700250 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 Samsc7968a02014-11-11 16:24:36 -0800260 uint32_t *arrays;
Stephen Hines5a470202013-05-29 15:36:18 -0700261 uint32_t lodCount;
Jason Samsc7968a02014-11-11 16:24:36 -0800262 uint32_t dimYuv;
263 uint32_t arrayCount;
Stephen Hines5a470202013-05-29 15:36:18 -0700264 bool faces;
265 } state;
266 } mHal;
267} Type_t;
268
Jason Sams3ff0fe72014-05-19 15:06:59 -0700269#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700270/*****************************************************************************
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 *****************************************************************************/
287typedef struct Mesh {
288 char __pad[32];
289 struct {
290 void *drv;
291 struct {
292 void **vertexBuffers;
293 uint32_t vertexBuffersCount;
294
Chris Wailes44bef6f2014-08-12 13:51:10 -0700295 // indexBuffers[i] could be nullptr, in which case only primitives[i] is used
Stephen Hines5a470202013-05-29 15:36:18 -0700296 void **indexBuffers;
297 uint32_t indexBuffersCount;
298 rs_primitive *primitives;
299 uint32_t primitivesCount;
300 } state;
301 } mHal;
302} Mesh_t;
Jason Sams3ff0fe72014-05-19 15:06:59 -0700303#endif //__LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700304#endif // _RS_CORE_H_