blob: e35cd54ff92d1ec67ccefb069163dfe17228cbe2 [file] [log] [blame]
Stephen Hines5a470202013-05-29 15:36:18 -07001#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 *****************************************************************************/
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 {
Tim Murraye3af53b2014-06-10 09:46:51 -070028#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -070029 char __pad[32];
Tim Murraye3af53b2014-06-10 09:46:51 -070030#else
31 char __pad[56];
32#endif
Stephen Hines5a470202013-05-29 15:36:18 -070033 struct {
34 void * drv;
35 struct {
36 const void *type;
37 uint32_t usageFlags;
38 rs_allocation_mipmap_control mipmapControl;
39 uint32_t yuv;
40 uint32_t elementSizeBytes;
41 bool hasMipmaps;
42 bool hasFaces;
43 bool hasReferences;
44 void * usrPtr;
45 int32_t surfaceTextureID;
Jason Samsddceab92013-08-07 13:02:32 -070046 void * nativeBuffer;
47 int64_t timestamp;
Stephen Hines5a470202013-05-29 15:36:18 -070048 } state;
49
50 struct DrvState {
51 struct LodState {
52 void * mallocPtr;
53 size_t stride;
54 uint32_t dimX;
55 uint32_t dimY;
56 uint32_t dimZ;
57 } lod[16/*android::renderscript::Allocation::MAX_LOD*/];
58 size_t faceOffset;
59 uint32_t lodCount;
60 uint32_t faceCount;
Jason Sams61656a72013-09-03 16:21:18 -070061
62 struct YuvState {
63 uint32_t shift;
64 uint32_t step;
65 } yuv;
Stephen Hines5a470202013-05-29 15:36:18 -070066 } drvState;
67 } mHal;
68} Allocation_t;
69
Jason Sams3ff0fe72014-05-19 15:06:59 -070070#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -070071/*****************************************************************************
72 * CAUTION
73 *
74 * The following structure layout provides a more efficient way to access
75 * internal members of the C++ class ProgramStore owned by librs. Unfortunately,
76 * since this class has virtual members, we can't simply use offsetof() or any
77 * other compiler trickery to dynamically get the appropriate values at
78 * build-time. This layout may need to be updated whenever
79 * frameworks/base/libs/rs/rsProgramStore.h is modified.
80 *
81 * Having the layout information available in this file allows us to
82 * accelerate functionality like rsgProgramStoreGetDepthFunc(). Without this
83 * information, we would not be able to inline the bitcode, thus resulting in
84 * potential runtime performance penalties for tight loops operating on
85 * program store.
86 *
87 *****************************************************************************/
88typedef struct ProgramStore {
89 char __pad[40];
90 struct {
91 struct {
92 bool ditherEnable;
93 bool colorRWriteEnable;
94 bool colorGWriteEnable;
95 bool colorBWriteEnable;
96 bool colorAWriteEnable;
97 rs_blend_src_func blendSrc;
98 rs_blend_dst_func blendDst;
99 bool depthWriteEnable;
100 rs_depth_func depthFunc;
101 } state;
102 } mHal;
103} ProgramStore_t;
104
105/*****************************************************************************
106 * CAUTION
107 *
108 * The following structure layout provides a more efficient way to access
109 * internal members of the C++ class ProgramRaster owned by librs. Unfortunately,
110 * since this class has virtual members, we can't simply use offsetof() or any
111 * other compiler trickery to dynamically get the appropriate values at
112 * build-time. This layout may need to be updated whenever
113 * frameworks/base/libs/rs/rsProgramRaster.h is modified.
114 *
115 * Having the layout information available in this file allows us to
116 * accelerate functionality like rsgProgramRasterGetCullMode(). Without this
117 * information, we would not be able to inline the bitcode, thus resulting in
118 * potential runtime performance penalties for tight loops operating on
119 * program raster.
120 *
121 *****************************************************************************/
122typedef struct ProgramRaster {
123 char __pad[36];
124 struct {
125 void * drv;
126 struct {
127 bool pointSprite;
128 rs_cull_mode cull;
129 } state;
130 } mHal;
131} ProgramRaster_t;
Jason Sams3ff0fe72014-05-19 15:06:59 -0700132#endif //__LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700133
134/*****************************************************************************
135 * CAUTION
136 *
137 * The following structure layout provides a more efficient way to access
138 * internal members of the C++ class Sampler owned by librs. Unfortunately,
139 * since this class has virtual members, we can't simply use offsetof() or any
140 * other compiler trickery to dynamically get the appropriate values at
141 * build-time. This layout may need to be updated whenever
142 * frameworks/base/libs/rs/rsSampler.h is modified.
143 *
144 * Having the layout information available in this file allows us to
145 * accelerate functionality like rsgProgramRasterGetMagFilter(). Without this
146 * information, we would not be able to inline the bitcode, thus resulting in
147 * potential runtime performance penalties for tight loops operating on
148 * samplers.
149 *
150 *****************************************************************************/
151typedef struct Sampler {
Tim Murraye3af53b2014-06-10 09:46:51 -0700152#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700153 char __pad[32];
Tim Murraye3af53b2014-06-10 09:46:51 -0700154#else
155 char __pad[56];
156#endif
Stephen Hines5a470202013-05-29 15:36:18 -0700157 struct {
158 void *drv;
159 struct {
160 rs_sampler_value magFilter;
161 rs_sampler_value minFilter;
162 rs_sampler_value wrapS;
163 rs_sampler_value wrapT;
164 rs_sampler_value wrapR;
165 float aniso;
166 } state;
167 } mHal;
168} Sampler_t;
169
170/*****************************************************************************
171 * CAUTION
172 *
173 * The following structure layout provides a more efficient way to access
174 * internal members of the C++ class Element owned by librs. Unfortunately,
175 * since this class has virtual members, we can't simply use offsetof() or any
176 * other compiler trickery to dynamically get the appropriate values at
177 * build-time. This layout may need to be updated whenever
178 * frameworks/base/libs/rs/rsElement.h is modified.
179 *
180 * Having the layout information available in this file allows us to
181 * accelerate functionality like rsElementGetSubElementCount(). Without this
182 * information, we would not be able to inline the bitcode, thus resulting in
183 * potential runtime performance penalties for tight loops operating on
184 * elements.
185 *
186 *****************************************************************************/
187typedef struct Element {
Tim Murraye3af53b2014-06-10 09:46:51 -0700188#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700189 char __pad[32];
Tim Murraye3af53b2014-06-10 09:46:51 -0700190#else
191 char __pad[56];
192#endif
Stephen Hines5a470202013-05-29 15:36:18 -0700193 struct {
194 void *drv;
195 struct {
196 rs_data_type dataType;
197 rs_data_kind dataKind;
198 uint32_t vectorSize;
199 uint32_t elementSizeBytes;
200
201 // Subelements
202 const void **fields;
203 uint32_t *fieldArraySizes;
204 const char **fieldNames;
205 uint32_t *fieldNameLengths;
206 uint32_t *fieldOffsetBytes;
207 uint32_t fieldsCount;
208 } state;
209 } mHal;
210} Element_t;
211
212/*****************************************************************************
213 * CAUTION
214 *
215 * The following structure layout provides a more efficient way to access
216 * internal members of the C++ class Type owned by librs. Unfortunately,
217 * since this class has virtual members, we can't simply use offsetof() or any
218 * other compiler trickery to dynamically get the appropriate values at
219 * build-time. This layout may need to be updated whenever
220 * frameworks/base/libs/rs/rsType.h is modified.
221 *
222 * Having the layout information available in this file allows us to
223 * accelerate functionality like rsAllocationGetElement(). Without this
224 * information, we would not be able to inline the bitcode, thus resulting in
225 * potential runtime performance penalties for tight loops operating on
226 * types.
227 *
228 *****************************************************************************/
229typedef struct Type {
Tim Murraye3af53b2014-06-10 09:46:51 -0700230#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700231 char __pad[32];
Tim Murraye3af53b2014-06-10 09:46:51 -0700232#else
233 char __pad[56];
234#endif
Stephen Hines5a470202013-05-29 15:36:18 -0700235 struct {
236 void *drv;
237 struct {
238 const void * element;
239 uint32_t dimX;
240 uint32_t dimY;
241 uint32_t dimZ;
242 uint32_t *lodDimX;
243 uint32_t *lodDimY;
244 uint32_t *lodDimZ;
245 uint32_t *lodOffset;
246 uint32_t lodCount;
247 bool faces;
248 } state;
249 } mHal;
250} Type_t;
251
Jason Sams3ff0fe72014-05-19 15:06:59 -0700252#ifndef __LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700253/*****************************************************************************
254 * CAUTION
255 *
256 * The following structure layout provides a more efficient way to access
257 * internal members of the C++ class Mesh owned by librs. Unfortunately,
258 * since this class has virtual members, we can't simply use offsetof() or any
259 * other compiler trickery to dynamically get the appropriate values at
260 * build-time. This layout may need to be updated whenever
261 * frameworks/base/libs/rs/rsMesh.h is modified.
262 *
263 * Having the layout information available in this file allows us to
264 * accelerate functionality like rsMeshGetVertexAllocationCount(). Without this
265 * information, we would not be able to inline the bitcode, thus resulting in
266 * potential runtime performance penalties for tight loops operating on
267 * meshes.
268 *
269 *****************************************************************************/
270typedef struct Mesh {
271 char __pad[32];
272 struct {
273 void *drv;
274 struct {
275 void **vertexBuffers;
276 uint32_t vertexBuffersCount;
277
278 // indexBuffers[i] could be NULL, in which case only primitives[i] is used
279 void **indexBuffers;
280 uint32_t indexBuffersCount;
281 rs_primitive *primitives;
282 uint32_t primitivesCount;
283 } state;
284 } mHal;
285} Mesh_t;
Jason Sams3ff0fe72014-05-19 15:06:59 -0700286#endif //__LP64__
Stephen Hines5a470202013-05-29 15:36:18 -0700287#endif // _RS_CORE_H_