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