blob: 4e5179bc44984c104a7649092bd1f39999cfa9c5 [file] [log] [blame]
Jason Samsbad80742011-03-16 16:29:28 -07001/*
Jason Samsbc0ca6b2013-02-15 18:13:43 -08002 * Copyright (C) 2013 The Android Open Source Project
Jason Samsbad80742011-03-16 16:29:28 -07003 *
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
Jason Samsbad80742011-03-16 16:29:28 -070032typedef void * RsAllocation;
33typedef void * RsAnimation;
Yang Ni1ffd86b2015-01-07 09:16:40 -080034typedef void * RsClosure;
Jason Samsbad80742011-03-16 16:29:28 -070035typedef void * RsContext;
36typedef void * RsDevice;
37typedef void * RsElement;
38typedef void * RsFile;
39typedef void * RsFont;
40typedef void * RsSampler;
41typedef void * RsScript;
Jason Samsdbe66d62012-09-17 13:54:41 -070042typedef void * RsScriptKernelID;
Yang Nieb9aa672015-01-27 14:32:25 -080043typedef void * RsScriptInvokeID;
Jason Samsdbe66d62012-09-17 13:54:41 -070044typedef void * RsScriptFieldID;
45typedef void * RsScriptMethodID;
46typedef void * RsScriptGroup;
Yang Ni1ffd86b2015-01-07 09:16:40 -080047typedef void * RsScriptGroup2;
Jason Samsbad80742011-03-16 16:29:28 -070048typedef void * RsMesh;
Jason Sams9e0afb52011-10-31 13:23:43 -070049typedef void * RsPath;
Jason Samsbad80742011-03-16 16:29:28 -070050typedef void * RsType;
51typedef void * RsObjectBase;
52
53typedef void * RsProgram;
54typedef void * RsProgramVertex;
55typedef void * RsProgramFragment;
56typedef void * RsProgramStore;
57typedef void * RsProgramRaster;
58
Alex Sakhartchouk7257c7e2011-05-17 12:32:47 -070059typedef void * RsNativeWindow;
60
Jason Samsbad80742011-03-16 16:29:28 -070061typedef void (* RsBitmapCallback_t)(void *);
62
Jason Sams87fe59a2011-04-20 15:09:01 -070063typedef 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
Jason Samsbad80742011-03-16 16:29:28 -070075enum RsDeviceParam {
76 RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
77 RS_DEVICE_PARAM_COUNT
78};
79
Jason Sams14982c82013-02-22 18:17:05 -080080enum RsContextType {
81 RS_CONTEXT_TYPE_NORMAL,
82 RS_CONTEXT_TYPE_DEBUG,
83 RS_CONTEXT_TYPE_PROFILE
84};
85
Jason Samsbad80742011-03-16 16:29:28 -070086
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,
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -070092 RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010,
Jason Sams3522f402012-03-23 11:47:26 -070093 RS_ALLOCATION_USAGE_IO_INPUT = 0x0020,
94 RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040,
Tim Murray9e2bda52012-12-18 12:05:46 -080095 RS_ALLOCATION_USAGE_SHARED = 0x0080,
Jason Samsbad80742011-03-16 16:29:28 -070096
Miao Wang47a58812015-07-23 21:59:16 -070097 RS_ALLOCATION_USAGE_INCREMENTAL_SUPPORT = 0x1000,
Jason Samsf82b6262015-05-11 15:02:50 -070098 RS_ALLOCATION_USAGE_OEM = 0x8000,
99 RS_ALLOCATION_USAGE_ALL = 0x80FF
Jason Samsbad80742011-03-16 16:29:28 -0700100};
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 {
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700109 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
Jason Samsbad80742011-03-16 16:29:28 -0700115};
116
117enum RsDataType {
Stephen Hines5aa018c2015-05-20 18:09:57 -0700118 RS_TYPE_NONE = 0,
Jason Samsbad80742011-03-16 16:29:28 -0700119 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,
Stephen Hinesae8b7952012-04-11 18:09:54 -0700151 RS_TYPE_FONT,
Alex Sakhartchouk25a59d02011-12-29 11:17:38 -0800152
153 RS_TYPE_INVALID = 10000,
Jason Samsbad80742011-03-16 16:29:28 -0700154};
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,
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -0700164 RS_KIND_PIXEL_DEPTH,
Jason Samsbc0ca6b2013-02-15 18:13:43 -0800165 RS_KIND_PIXEL_YUV,
Alex Sakhartchouk25a59d02011-12-29 11:17:38 -0800166
167 RS_KIND_INVALID = 100,
Jason Samsbad80742011-03-16 16:29:28 -0700168};
169
Pirama Arumuga Nainar6b387c12015-10-12 14:06:57 -0700170enum 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
Jason Samsbad80742011-03-16 16:29:28 -0700177enum 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,
Tim Murray9e913f42013-02-15 13:29:24 -0800193 RS_SAMPLER_MIRRORED_REPEAT,
Alex Sakhartchouk25a59d02011-12-29 11:17:38 -0800194
195 RS_SAMPLER_INVALID = 100,
Jason Samsbad80742011-03-16 16:29:28 -0700196};
197
Jason Samsbad80742011-03-16 16:29:28 -0700198enum 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
Jason Sams9e0afb52011-10-31 13:23:43 -0700212
Jason Samsbad80742011-03-16 16:29:28 -0700213enum 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
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700221 // Errors that only occur in the debug context.
222 RS_ERROR_FATAL_DEBUG = 0x0800,
223
Jason Samsbad80742011-03-16 16:29:28 -0700224 RS_ERROR_FATAL_UNKNOWN = 0x1000,
225 RS_ERROR_FATAL_DRIVER = 0x1001,
226 RS_ERROR_FATAL_PROGRAM_LINK = 0x1002
227};
228
Stephen Hinesf5988112012-10-16 00:05:46 -0700229enum 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
Jason Samsbad80742011-03-16 16:29:28 -0700238// Script to Script
239typedef struct {
Stephen Hinesf5988112012-10-16 00:05:46 -0700240 enum RsForEachStrategy strategy;
Jason Samsbad80742011-03-16 16:29:28 -0700241 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;
Jason Samsbf2111d2015-01-26 18:13:41 -0800249 uint32_t array2Start;
250 uint32_t array2End;
251 uint32_t array3Start;
252 uint32_t array3End;
253 uint32_t array4Start;
254 uint32_t array4End;
Jason Samsbad80742011-03-16 16:29:28 -0700255
256} RsScriptCall;
257
Tim Murray84e3dea2013-09-09 16:12:51 -0700258enum RsContextFlags {
Jason Samsbfa5a8e2014-05-20 18:16:20 -0700259 RS_CONTEXT_SYNCHRONOUS = 0x0001,
260 RS_CONTEXT_LOW_LATENCY = 0x0002,
Stephen McGroartyd5164d52015-05-08 15:31:49 +0100261 RS_CONTEXT_LOW_POWER = 0x0004,
Stephen McGroarty15c1d062015-09-02 16:03:38 +0100262 RS_CONTEXT_WAIT_FOR_ATTACH = 0x0008
Tim Murray84e3dea2013-09-09 16:12:51 -0700263};
264
Tim Murray64c682b2015-01-09 12:08:43 -0800265enum RsBlasTranspose {
266 RsBlasNoTrans=111,
267 RsBlasTrans=112,
268 RsBlasConjTrans=113
269};
Tim Murray84e3dea2013-09-09 16:12:51 -0700270
Tim Murray64c682b2015-01-09 12:08:43 -0800271enum 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,
Tim Murrayaff74452015-03-30 15:14:36 -0700288 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
Tim Murray2b999882015-04-13 11:42:54 -0700432 RsBlas_bnnm = 1000,
Tim Murray64c682b2015-01-09 12:08:43 -0800433};
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
Tim Murrayaff74452015-03-30 15:14:36 -0700446typedef union {
Tim Murray64c682b2015-01-09 12:08:43 -0800447 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;
Miao Wang06deda32015-06-29 17:29:43 -0700469 uint8_t a_offset;
470 uint8_t b_offset;
471 int32_t c_offset;
472 int32_t c_mult_int;
Tim Murray64c682b2015-01-09 12:08:43 -0800473} RsBlasCall;
Tim Murrayaff74452015-03-30 15:14:36 -0700474
Stephen Hines5aa018c2015-05-20 18:09:57 -0700475enum 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
Jason Samsbad80742011-03-16 16:29:28 -0700506#ifdef __cplusplus
507};
508#endif
509
510#endif // RENDER_SCRIPT_DEFINES_H