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