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