[go: nahoru, domu]

1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef RENDER_SCRIPT_DEFINES_H
18#define RENDER_SCRIPT_DEFINES_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27//////////////////////////////////////////////////////
28//
29
30typedef void * RsAsyncVoidPtr;
31
32typedef void * RsAllocation;
33typedef void * RsAnimation;
34typedef void * RsClosure;
35typedef void * RsContext;
36typedef void * RsDevice;
37typedef void * RsElement;
38typedef void * RsFile;
39typedef void * RsFont;
40typedef void * RsSampler;
41typedef void * RsScript;
42typedef void * RsScriptKernelID;
43typedef void * RsScriptInvokeID;
44typedef void * RsScriptFieldID;
45typedef void * RsScriptMethodID;
46typedef void * RsScriptGroup;
47typedef void * RsScriptGroup2;
48typedef void * RsMesh;
49typedef void * RsPath;
50typedef void * RsType;
51typedef void * RsObjectBase;
52
53typedef void * RsProgram;
54typedef void * RsProgramVertex;
55typedef void * RsProgramFragment;
56typedef void * RsProgramStore;
57typedef void * RsProgramRaster;
58
59typedef void * RsNativeWindow;
60
61typedef void (* RsBitmapCallback_t)(void *);
62
63typedef struct {
64    float m[16];
65} rs_matrix4x4;
66
67typedef struct {
68    float m[9];
69} rs_matrix3x3;
70
71typedef struct {
72    float m[4];
73} rs_matrix2x2;
74
75enum RsDeviceParam {
76    RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
77    RS_DEVICE_PARAM_COUNT
78};
79
80enum RsContextType {
81    RS_CONTEXT_TYPE_NORMAL,
82    RS_CONTEXT_TYPE_DEBUG,
83    RS_CONTEXT_TYPE_PROFILE
84};
85
86
87enum RsAllocationUsageType {
88    RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
89    RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
90    RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
91    RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
92    RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010,
93    RS_ALLOCATION_USAGE_IO_INPUT = 0x0020,
94    RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040,
95    RS_ALLOCATION_USAGE_SHARED = 0x0080,
96
97    RS_ALLOCATION_USAGE_INCREMENTAL_SUPPORT = 0x1000,
98    RS_ALLOCATION_USAGE_OEM = 0x8000,
99    RS_ALLOCATION_USAGE_ALL = 0x80FF
100};
101
102enum RsAllocationMipmapControl {
103    RS_ALLOCATION_MIPMAP_NONE = 0,
104    RS_ALLOCATION_MIPMAP_FULL = 1,
105    RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2
106};
107
108enum RsAllocationCubemapFace {
109    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
110    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
111    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
112    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
113    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
114    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
115};
116
117enum RsDataType {
118    RS_TYPE_NONE = 0,
119    RS_TYPE_FLOAT_16,
120    RS_TYPE_FLOAT_32,
121    RS_TYPE_FLOAT_64,
122    RS_TYPE_SIGNED_8,
123    RS_TYPE_SIGNED_16,
124    RS_TYPE_SIGNED_32,
125    RS_TYPE_SIGNED_64,
126    RS_TYPE_UNSIGNED_8,
127    RS_TYPE_UNSIGNED_16,
128    RS_TYPE_UNSIGNED_32,
129    RS_TYPE_UNSIGNED_64,
130
131    RS_TYPE_BOOLEAN,
132
133    RS_TYPE_UNSIGNED_5_6_5,
134    RS_TYPE_UNSIGNED_5_5_5_1,
135    RS_TYPE_UNSIGNED_4_4_4_4,
136
137    RS_TYPE_MATRIX_4X4,
138    RS_TYPE_MATRIX_3X3,
139    RS_TYPE_MATRIX_2X2,
140
141    RS_TYPE_ELEMENT = 1000,
142    RS_TYPE_TYPE,
143    RS_TYPE_ALLOCATION,
144    RS_TYPE_SAMPLER,
145    RS_TYPE_SCRIPT,
146    RS_TYPE_MESH,
147    RS_TYPE_PROGRAM_FRAGMENT,
148    RS_TYPE_PROGRAM_VERTEX,
149    RS_TYPE_PROGRAM_RASTER,
150    RS_TYPE_PROGRAM_STORE,
151    RS_TYPE_FONT,
152
153    RS_TYPE_INVALID = 10000,
154};
155
156enum RsDataKind {
157    RS_KIND_USER,
158
159    RS_KIND_PIXEL_L = 7,
160    RS_KIND_PIXEL_A,
161    RS_KIND_PIXEL_LA,
162    RS_KIND_PIXEL_RGB,
163    RS_KIND_PIXEL_RGBA,
164    RS_KIND_PIXEL_DEPTH,
165    RS_KIND_PIXEL_YUV,
166
167    RS_KIND_INVALID = 100,
168};
169
170enum RsYuvFormat {
171    RS_YUV_NONE    = 0,
172    RS_YUV_YV12    = 0x32315659, // HAL_PIXEL_FORMAT_YV12 in system/graphics.h
173    RS_YUV_NV21    = 0x11,       // HAL_PIXEL_FORMAT_YCrCb_420_SP
174    RS_YUV_420_888 = 0x23,       // HAL_PIXEL_FORMAT_YCbCr_420_888
175};
176
177enum RsSamplerParam {
178    RS_SAMPLER_MIN_FILTER,
179    RS_SAMPLER_MAG_FILTER,
180    RS_SAMPLER_WRAP_S,
181    RS_SAMPLER_WRAP_T,
182    RS_SAMPLER_WRAP_R,
183    RS_SAMPLER_ANISO
184};
185
186enum RsSamplerValue {
187    RS_SAMPLER_NEAREST,
188    RS_SAMPLER_LINEAR,
189    RS_SAMPLER_LINEAR_MIP_LINEAR,
190    RS_SAMPLER_WRAP,
191    RS_SAMPLER_CLAMP,
192    RS_SAMPLER_LINEAR_MIP_NEAREST,
193    RS_SAMPLER_MIRRORED_REPEAT,
194
195    RS_SAMPLER_INVALID = 100,
196};
197
198enum RsDimension {
199    RS_DIMENSION_X,
200    RS_DIMENSION_Y,
201    RS_DIMENSION_Z,
202    RS_DIMENSION_LOD,
203    RS_DIMENSION_FACE,
204
205    RS_DIMENSION_ARRAY_0 = 100,
206    RS_DIMENSION_ARRAY_1,
207    RS_DIMENSION_ARRAY_2,
208    RS_DIMENSION_ARRAY_3,
209    RS_DIMENSION_MAX = RS_DIMENSION_ARRAY_3
210};
211
212
213enum RsError {
214    RS_ERROR_NONE = 0,
215    RS_ERROR_BAD_SHADER = 1,
216    RS_ERROR_BAD_SCRIPT = 2,
217    RS_ERROR_BAD_VALUE = 3,
218    RS_ERROR_OUT_OF_MEMORY = 4,
219    RS_ERROR_DRIVER = 5,
220
221    // Errors that only occur in the debug context.
222    RS_ERROR_FATAL_DEBUG = 0x0800,
223
224    RS_ERROR_FATAL_UNKNOWN = 0x1000,
225    RS_ERROR_FATAL_DRIVER = 0x1001,
226    RS_ERROR_FATAL_PROGRAM_LINK = 0x1002
227};
228
229enum RsForEachStrategy {
230    RS_FOR_EACH_STRATEGY_SERIAL = 0,
231    RS_FOR_EACH_STRATEGY_DONT_CARE = 1,
232    RS_FOR_EACH_STRATEGY_DST_LINEAR = 2,
233    RS_FOR_EACH_STRATEGY_TILE_SMALL = 3,
234    RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4,
235    RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
236};
237
238// Script to Script
239typedef struct {
240    enum RsForEachStrategy strategy;
241    uint32_t xStart;
242    uint32_t xEnd;
243    uint32_t yStart;
244    uint32_t yEnd;
245    uint32_t zStart;
246    uint32_t zEnd;
247    uint32_t arrayStart;
248    uint32_t arrayEnd;
249    uint32_t array2Start;
250    uint32_t array2End;
251    uint32_t array3Start;
252    uint32_t array3End;
253    uint32_t array4Start;
254    uint32_t array4End;
255
256} RsScriptCall;
257
258enum RsContextFlags {
259    RS_CONTEXT_SYNCHRONOUS      = 0x0001,
260    RS_CONTEXT_LOW_LATENCY      = 0x0002,
261    RS_CONTEXT_LOW_POWER        = 0x0004,
262    RS_CONTEXT_WAIT_FOR_ATTACH  = 0x0008
263};
264
265enum RsBlasTranspose {
266    RsBlasNoTrans=111,
267    RsBlasTrans=112,
268    RsBlasConjTrans=113
269};
270
271enum RsBlasUplo {
272    RsBlasUpper=121,
273    RsBlasLower=122
274};
275
276enum RsBlasDiag {
277    RsBlasNonUnit=131,
278    RsBlasUnit=132
279};
280
281enum RsBlasSide {
282    RsBlasLeft=141,
283    RsBlasRight=142
284};
285
286enum RsBlasFunction {
287    RsBlas_nop = 0,
288    RsBlas_sdsdot = 1,
289    RsBlas_dsdot = 2,
290    RsBlas_sdot = 3,
291    RsBlas_ddot = 4,
292    RsBlas_cdotu_sub = 5,
293    RsBlas_cdotc_sub = 6,
294    RsBlas_zdotu_sub = 7,
295    RsBlas_zdotc_sub = 8,
296    RsBlas_snrm2 = 9,
297    RsBlas_sasum = 10,
298    RsBlas_dnrm2 = 11,
299    RsBlas_dasum = 12,
300    RsBlas_scnrm2 = 13,
301    RsBlas_scasum = 14,
302    RsBlas_dznrm2 = 15,
303    RsBlas_dzasum = 16,
304    RsBlas_isamax = 17,
305    RsBlas_idamax = 18,
306    RsBlas_icamax = 19,
307    RsBlas_izamax = 20,
308    RsBlas_sswap = 21,
309    RsBlas_scopy = 22,
310    RsBlas_saxpy = 23,
311    RsBlas_dswap = 24,
312    RsBlas_dcopy = 25,
313    RsBlas_daxpy = 26,
314    RsBlas_cswap = 27,
315    RsBlas_ccopy = 28,
316    RsBlas_caxpy = 29,
317    RsBlas_zswap = 30,
318    RsBlas_zcopy = 31,
319    RsBlas_zaxpy = 32,
320    RsBlas_srotg = 33,
321    RsBlas_srotmg = 34,
322    RsBlas_srot = 35,
323    RsBlas_srotm = 36,
324    RsBlas_drotg = 37,
325    RsBlas_drotmg = 38,
326    RsBlas_drot = 39,
327    RsBlas_drotm = 40,
328    RsBlas_sscal = 41,
329    RsBlas_dscal = 42,
330    RsBlas_cscal = 43,
331    RsBlas_zscal = 44,
332    RsBlas_csscal = 45,
333    RsBlas_zdscal = 46,
334    RsBlas_sgemv = 47,
335    RsBlas_sgbmv = 48,
336    RsBlas_strmv = 49,
337    RsBlas_stbmv = 50,
338    RsBlas_stpmv = 51,
339    RsBlas_strsv = 52,
340    RsBlas_stbsv = 53,
341    RsBlas_stpsv = 54,
342    RsBlas_dgemv = 55,
343    RsBlas_dgbmv = 56,
344    RsBlas_dtrmv = 57,
345    RsBlas_dtbmv = 58,
346    RsBlas_dtpmv = 59,
347    RsBlas_dtrsv = 60,
348    RsBlas_dtbsv = 61,
349    RsBlas_dtpsv = 62,
350    RsBlas_cgemv = 63,
351    RsBlas_cgbmv = 64,
352    RsBlas_ctrmv = 65,
353    RsBlas_ctbmv = 66,
354    RsBlas_ctpmv = 67,
355    RsBlas_ctrsv = 68,
356    RsBlas_ctbsv = 69,
357    RsBlas_ctpsv = 70,
358    RsBlas_zgemv = 71,
359    RsBlas_zgbmv = 72,
360    RsBlas_ztrmv = 73,
361    RsBlas_ztbmv = 74,
362    RsBlas_ztpmv = 75,
363    RsBlas_ztrsv = 76,
364    RsBlas_ztbsv = 77,
365    RsBlas_ztpsv = 78,
366    RsBlas_ssymv = 79,
367    RsBlas_ssbmv = 80,
368    RsBlas_sspmv = 81,
369    RsBlas_sger = 82,
370    RsBlas_ssyr = 83,
371    RsBlas_sspr = 84,
372    RsBlas_ssyr2 = 85,
373    RsBlas_sspr2 = 86,
374    RsBlas_dsymv = 87,
375    RsBlas_dsbmv = 88,
376    RsBlas_dspmv = 89,
377    RsBlas_dger = 90,
378    RsBlas_dsyr = 91,
379    RsBlas_dspr = 92,
380    RsBlas_dsyr2 = 93,
381    RsBlas_dspr2 = 94,
382    RsBlas_chemv = 95,
383    RsBlas_chbmv = 96,
384    RsBlas_chpmv = 97,
385    RsBlas_cgeru = 98,
386    RsBlas_cgerc = 99,
387    RsBlas_cher = 100,
388    RsBlas_chpr = 101,
389    RsBlas_cher2 = 102,
390    RsBlas_chpr2 = 103,
391    RsBlas_zhemv = 104,
392    RsBlas_zhbmv = 105,
393    RsBlas_zhpmv = 106,
394    RsBlas_zgeru = 107,
395    RsBlas_zgerc = 108,
396    RsBlas_zher = 109,
397    RsBlas_zhpr = 110,
398    RsBlas_zher2 = 111,
399    RsBlas_zhpr2 = 112,
400    RsBlas_sgemm = 113,
401    RsBlas_ssymm = 114,
402    RsBlas_ssyrk = 115,
403    RsBlas_ssyr2k = 116,
404    RsBlas_strmm = 117,
405    RsBlas_strsm = 118,
406    RsBlas_dgemm = 119,
407    RsBlas_dsymm = 120,
408    RsBlas_dsyrk = 121,
409    RsBlas_dsyr2k = 122,
410    RsBlas_dtrmm = 123,
411    RsBlas_dtrsm = 124,
412    RsBlas_cgemm = 125,
413    RsBlas_csymm = 126,
414    RsBlas_csyrk = 127,
415    RsBlas_csyr2k = 128,
416    RsBlas_ctrmm = 129,
417    RsBlas_ctrsm = 130,
418    RsBlas_zgemm = 131,
419    RsBlas_zsymm = 132,
420    RsBlas_zsyrk = 133,
421    RsBlas_zsyr2k = 134,
422    RsBlas_ztrmm = 135,
423    RsBlas_ztrsm = 136,
424    RsBlas_chemm = 137,
425    RsBlas_cherk = 138,
426    RsBlas_cher2k = 139,
427    RsBlas_zhemm = 140,
428    RsBlas_zherk = 141,
429    RsBlas_zher2k = 142,
430
431    // BLAS extensions start here
432    RsBlas_bnnm = 1000,
433};
434
435// custom complex types because of NDK support
436typedef struct {
437    float r;
438    float i;
439} RsFloatComplex;
440
441typedef struct {
442    double r;
443    double i;
444} RsDoubleComplex;
445
446typedef union {
447    float f;
448    RsFloatComplex c;
449    double d;
450    RsDoubleComplex z;
451} RsBlasScalar;
452
453typedef struct {
454    RsBlasFunction func;
455    RsBlasTranspose transA;
456    RsBlasTranspose transB;
457    RsBlasUplo uplo;
458    RsBlasDiag diag;
459    RsBlasSide side;
460    int M;
461    int N;
462    int K;
463    RsBlasScalar alpha;
464    RsBlasScalar beta;
465    int incX;
466    int incY;
467    int KL;
468    int KU;
469    uint8_t a_offset;
470    uint8_t b_offset;
471    int32_t c_offset;
472    int32_t c_mult_int;
473} RsBlasCall;
474
475enum RsGlobalProperty {
476    RS_GLOBAL_TYPE     = 0x0000FFFF,
477    RS_GLOBAL_CONSTANT = 0x00010000,
478    RS_GLOBAL_STATIC   = 0x00020000,
479    RS_GLOBAL_POINTER  = 0x00040000
480};
481
482// Special symbols embedded into a shared object compiled by bcc.
483static const char kRoot[] = "root";
484static const char kInit[] = "init";
485static const char kRsDtor[] = ".rs.dtor";
486static const char kRsInfo[] = ".rs.info";
487static const char kRsGlobalEntries[] = ".rs.global_entries";
488static const char kRsGlobalNames[] = ".rs.global_names";
489static const char kRsGlobalAddresses[] = ".rs.global_addresses";
490static const char kRsGlobalSizes[] = ".rs.global_sizes";
491static const char kRsGlobalProperties[] = ".rs.global_properties";
492
493static inline uint32_t getGlobalRsType(uint32_t properties) {
494    return properties & RS_GLOBAL_TYPE;
495}
496static inline bool isGlobalConstant(uint32_t properties) {
497    return properties & RS_GLOBAL_CONSTANT;
498}
499static inline bool isGlobalStatic(uint32_t properties) {
500    return properties & RS_GLOBAL_STATIC;
501}
502static inline bool isGlobalPointer(uint32_t properties) {
503    return properties & RS_GLOBAL_POINTER;
504}
505
506#ifdef __cplusplus
507};
508#endif
509
510#endif // RENDER_SCRIPT_DEFINES_H
511