rs_structs.h revision c7968a0ac24f05d978616a79a5068b6b16dbbda6
1#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 {
28#ifndef __LP64__
29    char __pad[32];
30#else
31    char __pad[56];
32#endif
33    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;
46            void * nativeBuffer;
47            int64_t timestamp;
48        } 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;
61
62            struct YuvState {
63                uint32_t shift;
64                uint32_t step;
65            } yuv;
66        } drvState;
67    } mHal;
68} Allocation_t;
69
70#ifndef __LP64__
71/*****************************************************************************
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;
132#endif //__LP64__
133
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 {
152#ifndef __LP64__
153    char __pad[32];
154#else
155    char __pad[56];
156#endif
157    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 {
188#ifndef __LP64__
189    char __pad[32];
190#else
191    char __pad[56];
192#endif
193    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 {
230#ifndef __LP64__
231    char __pad[32];
232#else
233    char __pad[56];
234#endif
235    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 *arrays;
246            uint32_t lodCount;
247            uint32_t dimYuv;
248            uint32_t arrayCount;
249            bool faces;
250        } state;
251    } mHal;
252} Type_t;
253
254#ifndef __LP64__
255/*****************************************************************************
256 * CAUTION
257 *
258 * The following structure layout provides a more efficient way to access
259 * internal members of the C++ class Mesh owned by librs. Unfortunately,
260 * since this class has virtual members, we can't simply use offsetof() or any
261 * other compiler trickery to dynamically get the appropriate values at
262 * build-time. This layout may need to be updated whenever
263 * frameworks/base/libs/rs/rsMesh.h is modified.
264 *
265 * Having the layout information available in this file allows us to
266 * accelerate functionality like rsMeshGetVertexAllocationCount(). Without this
267 * information, we would not be able to inline the bitcode, thus resulting in
268 * potential runtime performance penalties for tight loops operating on
269 * meshes.
270 *
271 *****************************************************************************/
272typedef struct Mesh {
273    char __pad[32];
274    struct {
275        void *drv;
276        struct {
277            void **vertexBuffers;
278            uint32_t vertexBuffersCount;
279
280            // indexBuffers[i] could be nullptr, in which case only primitives[i] is used
281            void **indexBuffers;
282            uint32_t indexBuffersCount;
283            rs_primitive *primitives;
284            uint32_t primitivesCount;
285        } state;
286    } mHal;
287} Mesh_t;
288#endif //__LP64__
289#endif // _RS_CORE_H_
290