blob: 998d6abb0b1ca32058a0ba3bcbe80acabca4d0a4 [file] [log] [blame]
Jason Sams044e2ee2011-08-08 16:52:30 -07001/*
Jason Samsbc0ca6b2013-02-15 18:13:43 -08002 * Copyright (C) 2013 The Android Open Source Project
Jason Sams044e2ee2011-08-08 16:52:30 -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/** @file rs_types.rsh
Jason Sams9df3b2b2011-08-08 14:31:25 -070018 *
Stephen Hinese227f9a2013-05-29 14:48:19 -070019 * Define the standard RenderScript types
Jason Sams9df3b2b2011-08-08 14:31:25 -070020 *
21 * Integers
22 * 8 bit: char, int8_t
23 * 16 bit: short, int16_t
24 * 32 bit: int, in32_t
25 * 64 bit: long, long long, int64_t
26 *
27 * Unsigned Integers
28 * 8 bit: uchar, uint8_t
29 * 16 bit: ushort, uint16_t
30 * 32 bit: uint, uint32_t
31 * 64 bit: ulong, uint64_t
32 *
33 * Floating point
34 * 32 bit: float
35 * 64 bit: double
36 *
37 * Vectors of length 2, 3, and 4 are supported for all the types above.
38 *
39 */
40
Shih-wei Liao9bb32e12010-10-07 18:21:32 -070041#ifndef __RS_TYPES_RSH__
42#define __RS_TYPES_RSH__
Jason Sams717e34a2010-03-16 15:35:57 -070043
Rajeev Sharma20d55302012-07-24 17:16:05 -070044/* Constants */
45#define M_E 2.718281828459045235360287471352662498f /* e */
46#define M_LOG2E 1.442695040888963407359924681001892137f /* log_2 e */
47#define M_LOG10E 0.434294481903251827651128918916605082f /* log_10 e */
48#define M_LN2 0.693147180559945309417232121458176568f /* log_e 2 */
49#define M_LN10 2.302585092994045684017991454684364208f /* log_e 10 */
50#define M_PI 3.141592653589793238462643383279502884f /* pi */
51#define M_PI_2 1.570796326794896619231321691639751442f /* pi/2 */
52#define M_PI_4 0.785398163397448309615660845819875721f /* pi/4 */
53#define M_1_PI 0.318309886183790671537767526745028724f /* 1/pi */
54#define M_2_PIl 0.636619772367581343075535053490057448f /* 2/pi */
55#define M_2_SQRTPI 1.128379167095512573896158903121545172f /* 2/sqrt(pi) */
56#define M_SQRT2 1.414213562373095048801688724209698079f /* sqrt(2) */
57#define M_SQRT1_2 0.707106781186547524400844362104849039f /* 1/sqrt(2) */
Rajeev Sharma75398202012-07-24 16:36:14 -070058
Shih-wei Liaoed2ea272011-01-19 12:17:54 -080059#include "stdbool.h"
Jason Sams9df3b2b2011-08-08 14:31:25 -070060/**
61 * 8 bit integer type
62 */
Jason Sams717e34a2010-03-16 15:35:57 -070063typedef char int8_t;
Jason Sams9df3b2b2011-08-08 14:31:25 -070064/**
65 * 16 bit integer type
66 */
Jason Sams717e34a2010-03-16 15:35:57 -070067typedef short int16_t;
Jason Sams9df3b2b2011-08-08 14:31:25 -070068/**
69 * 32 bit integer type
70 */
Jason Sams717e34a2010-03-16 15:35:57 -070071typedef int int32_t;
Jason Sams9df3b2b2011-08-08 14:31:25 -070072/**
73 * 64 bit integer type
74 */
Jason Samsd8b8f8a2014-08-19 17:53:08 -070075#if (defined(RS_VERSION) && (RS_VERSION >= 21))
76 typedef long int64_t;
77#else
78 typedef long long int64_t;
79#endif
Jason Sams9df3b2b2011-08-08 14:31:25 -070080/**
81 * 8 bit unsigned integer type
82 */
Jason Sams717e34a2010-03-16 15:35:57 -070083typedef unsigned char uint8_t;
Jason Sams9df3b2b2011-08-08 14:31:25 -070084/**
85 * 16 bit unsigned integer type
86 */
Jason Sams717e34a2010-03-16 15:35:57 -070087typedef unsigned short uint16_t;
Jason Sams9df3b2b2011-08-08 14:31:25 -070088/**
89 * 32 bit unsigned integer type
90 */
Jason Sams717e34a2010-03-16 15:35:57 -070091typedef unsigned int uint32_t;
Jason Sams9df3b2b2011-08-08 14:31:25 -070092/**
93 * 64 bit unsigned integer type
94 */
Jason Samsd8b8f8a2014-08-19 17:53:08 -070095#if (defined(RS_VERSION) && (RS_VERSION >= 21))
96 typedef unsigned long uint64_t;
97#else
98 typedef unsigned long long uint64_t;
99#endif
Jason Sams9df3b2b2011-08-08 14:31:25 -0700100/**
101 * 8 bit unsigned integer type
102 */
Jason Sams717e34a2010-03-16 15:35:57 -0700103typedef uint8_t uchar;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700104/**
105 * 16 bit unsigned integer type
106 */
Jason Sams717e34a2010-03-16 15:35:57 -0700107typedef uint16_t ushort;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700108/**
109 * 32 bit unsigned integer type
110 */
Jason Sams717e34a2010-03-16 15:35:57 -0700111typedef uint32_t uint;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700112/**
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700113 * Typedef for unsigned long (use for 64-bit unsigned integers)
Jason Sams9df3b2b2011-08-08 14:31:25 -0700114 */
Jason Sams22fa3712010-05-19 17:22:57 -0700115typedef uint64_t ulong;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700116/**
Tim Murraye3af53b2014-06-10 09:46:51 -0700117 * Typedef for size_t
Jason Sams9df3b2b2011-08-08 14:31:25 -0700118 */
Jason Sams3ff0fe72014-05-19 15:06:59 -0700119#ifndef __LP64__
Tim Murraye3af53b2014-06-10 09:46:51 -0700120typedef uint32_t size_t;
121typedef int32_t ssize_t;
Jason Sams3ff0fe72014-05-19 15:06:59 -0700122#else
Tim Murraye3af53b2014-06-10 09:46:51 -0700123typedef uint64_t size_t;
124typedef int64_t ssize_t;
Jason Sams3ff0fe72014-05-19 15:06:59 -0700125#endif
126
Tim Murrayfa6f90e2014-06-12 14:16:10 -0700127#ifndef __LP64__
Tim Murraye3af53b2014-06-10 09:46:51 -0700128#define RS_BASE_OBJ typedef struct { const int* const p; } __attribute__((packed, aligned(4)))
Tim Murrayfa6f90e2014-06-12 14:16:10 -0700129#else
130#define RS_BASE_OBJ typedef struct { const long* const p; const long* const r; const long* const v1; const long* const v2; }
131#endif
Tim Murraye3af53b2014-06-10 09:46:51 -0700132
Jason Sams9df3b2b2011-08-08 14:31:25 -0700133/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700134 * \brief Opaque handle to a RenderScript element.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700135 *
136 * See: android.renderscript.Element
137 */
Jason Sams3ff0fe72014-05-19 15:06:59 -0700138RS_BASE_OBJ rs_element;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700139/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700140 * \brief Opaque handle to a RenderScript type.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700141 *
142 * See: android.renderscript.Type
143 */
Jason Sams3ff0fe72014-05-19 15:06:59 -0700144RS_BASE_OBJ rs_type;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700145/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700146 * \brief Opaque handle to a RenderScript allocation.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700147 *
148 * See: android.renderscript.Allocation
149 */
Jason Sams3ff0fe72014-05-19 15:06:59 -0700150RS_BASE_OBJ rs_allocation;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700151/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700152 * \brief Opaque handle to a RenderScript sampler object.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700153 *
154 * See: android.renderscript.Sampler
155 */
Jason Sams3ff0fe72014-05-19 15:06:59 -0700156RS_BASE_OBJ rs_sampler;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700157/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700158 * \brief Opaque handle to a RenderScript script object.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700159 *
160 * See: android.renderscript.ScriptC
161 */
Jason Sams3ff0fe72014-05-19 15:06:59 -0700162RS_BASE_OBJ rs_script;
163
164#ifndef __LP64__
Jason Sams9df3b2b2011-08-08 14:31:25 -0700165/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700166 * \brief Opaque handle to a RenderScript mesh object.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700167 *
168 * See: android.renderscript.Mesh
169 */
Jason Samsc0936852010-08-16 12:41:48 -0700170typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_mesh;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700171/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700172 * \brief Opaque handle to a RenderScript Path object.
Jason Sams9e0afb52011-10-31 13:23:43 -0700173 *
174 * See: android.renderscript.Path
175 */
176typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_path;
177/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700178 * \brief Opaque handle to a RenderScript ProgramFragment object.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700179 *
180 * See: android.renderscript.ProgramFragment
181 */
Jason Samsc0936852010-08-16 12:41:48 -0700182typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_fragment;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700183/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700184 * \brief Opaque handle to a RenderScript ProgramVertex object.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700185 *
186 * See: android.renderscript.ProgramVertex
187 */
Jason Samsc0936852010-08-16 12:41:48 -0700188typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_vertex;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700189/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700190 * \brief Opaque handle to a RenderScript ProgramRaster object.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700191 *
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700192 * See: android.renderscript.ProgramRaster
Jason Sams9df3b2b2011-08-08 14:31:25 -0700193 */
Jason Samsc0936852010-08-16 12:41:48 -0700194typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_raster;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700195/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700196 * \brief Opaque handle to a RenderScript ProgramStore object.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700197 *
198 * See: android.renderscript.ProgramStore
199 */
Jason Samsc0936852010-08-16 12:41:48 -0700200typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_store;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700201/**
Stephen Hinese227f9a2013-05-29 14:48:19 -0700202 * \brief Opaque handle to a RenderScript font object.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700203 *
204 * See: android.renderscript.Font
205 */
Jason Samsc0936852010-08-16 12:41:48 -0700206typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_font;
Jason Sams3ff0fe72014-05-19 15:06:59 -0700207#endif // __LP64__
Jason Samsc0936852010-08-16 12:41:48 -0700208
Jason Sams9df3b2b2011-08-08 14:31:25 -0700209/**
210 * Vector version of the basic float type.
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700211 * Provides two float fields packed into a single 64 bit field with 64 bit
Jason Sams9df3b2b2011-08-08 14:31:25 -0700212 * alignment.
213 */
Jason Sams717e34a2010-03-16 15:35:57 -0700214typedef float float2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700215/**
216 * Vector version of the basic float type. Provides three float fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700217 * into a single 128 bit field with 128 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700218 */
Jason Sams717e34a2010-03-16 15:35:57 -0700219typedef float float3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700220/**
221 * Vector version of the basic float type.
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700222 * Provides four float fields packed into a single 128 bit field with 128 bit
Jason Sams9df3b2b2011-08-08 14:31:25 -0700223 * alignment.
224 */
Jason Sams717e34a2010-03-16 15:35:57 -0700225typedef float float4 __attribute__((ext_vector_type(4)));
Jason Sams717e34a2010-03-16 15:35:57 -0700226
Jason Sams9df3b2b2011-08-08 14:31:25 -0700227/**
228 * Vector version of the basic double type. Provides two double fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700229 * into a single 128 bit field with 128 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700230 */
Jason Sams46f2e722011-04-22 17:05:25 -0700231typedef double double2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700232/**
233 * Vector version of the basic double type. Provides three double fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700234 * into a single 256 bit field with 256 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700235 */
Jason Sams46f2e722011-04-22 17:05:25 -0700236typedef double double3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700237/**
238 * Vector version of the basic double type. Provides four double fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700239 * into a single 256 bit field with 256 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700240 */
Jason Sams46f2e722011-04-22 17:05:25 -0700241typedef double double4 __attribute__((ext_vector_type(4)));
242
Jason Sams9df3b2b2011-08-08 14:31:25 -0700243/**
244 * Vector version of the basic uchar type. Provides two uchar fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700245 * into a single 16 bit field with 16 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700246 */
Jason Sams717e34a2010-03-16 15:35:57 -0700247typedef uchar uchar2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700248/**
249 * Vector version of the basic uchar type. Provides three uchar fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700250 * into a single 32 bit field with 32 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700251 */
Jason Sams717e34a2010-03-16 15:35:57 -0700252typedef uchar uchar3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700253/**
254 * Vector version of the basic uchar type. Provides four uchar fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700255 * into a single 32 bit field with 32 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700256 */
Jason Sams717e34a2010-03-16 15:35:57 -0700257typedef uchar uchar4 __attribute__((ext_vector_type(4)));
Jason Sams717e34a2010-03-16 15:35:57 -0700258
Jason Sams9df3b2b2011-08-08 14:31:25 -0700259/**
260 * Vector version of the basic ushort type. Provides two ushort fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700261 * into a single 32 bit field with 32 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700262 */
Jason Sams717e34a2010-03-16 15:35:57 -0700263typedef ushort ushort2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700264/**
265 * Vector version of the basic ushort type. Provides three ushort fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700266 * into a single 64 bit field with 64 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700267 */
Jason Sams717e34a2010-03-16 15:35:57 -0700268typedef ushort ushort3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700269/**
270 * Vector version of the basic ushort type. Provides four ushort fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700271 * into a single 64 bit field with 64 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700272 */
Jason Sams717e34a2010-03-16 15:35:57 -0700273typedef ushort ushort4 __attribute__((ext_vector_type(4)));
Jason Sams717e34a2010-03-16 15:35:57 -0700274
Jason Sams9df3b2b2011-08-08 14:31:25 -0700275/**
276 * Vector version of the basic uint type. Provides two uint fields packed into a
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700277 * single 64 bit field with 64 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700278 */
Jason Sams717e34a2010-03-16 15:35:57 -0700279typedef uint uint2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700280/**
281 * Vector version of the basic uint type. Provides three uint fields packed into
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700282 * a single 128 bit field with 128 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700283 */
Jason Sams717e34a2010-03-16 15:35:57 -0700284typedef uint uint3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700285/**
286 * Vector version of the basic uint type. Provides four uint fields packed into
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700287 * a single 128 bit field with 128 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700288 */
Jason Sams717e34a2010-03-16 15:35:57 -0700289typedef uint uint4 __attribute__((ext_vector_type(4)));
Jason Sams717e34a2010-03-16 15:35:57 -0700290
Jason Sams9df3b2b2011-08-08 14:31:25 -0700291/**
292 * Vector version of the basic ulong type. Provides two ulong fields packed into
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700293 * a single 128 bit field with 128 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700294 */
Jason Sams46f2e722011-04-22 17:05:25 -0700295typedef ulong ulong2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700296/**
297 * Vector version of the basic ulong type. Provides three ulong fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700298 * into a single 256 bit field with 256 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700299 */
Jason Sams46f2e722011-04-22 17:05:25 -0700300typedef ulong ulong3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700301/**
302 * Vector version of the basic ulong type. Provides four ulong fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700303 * into a single 256 bit field with 256 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700304 */
Jason Sams46f2e722011-04-22 17:05:25 -0700305typedef ulong ulong4 __attribute__((ext_vector_type(4)));
306
Jason Sams9df3b2b2011-08-08 14:31:25 -0700307/**
308 * Vector version of the basic char type. Provides two char fields packed into a
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700309 * single 16 bit field with 16 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700310 */
Jason Sams717e34a2010-03-16 15:35:57 -0700311typedef char char2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700312/**
313 * Vector version of the basic char type. Provides three char fields packed into
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700314 * a single 32 bit field with 32 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700315 */
Jason Sams717e34a2010-03-16 15:35:57 -0700316typedef char char3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700317/**
318 * Vector version of the basic char type. Provides four char fields packed into
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700319 * a single 32 bit field with 32 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700320 */
Jason Sams717e34a2010-03-16 15:35:57 -0700321typedef char char4 __attribute__((ext_vector_type(4)));
Jason Sams717e34a2010-03-16 15:35:57 -0700322
Jason Sams9df3b2b2011-08-08 14:31:25 -0700323/**
324 * Vector version of the basic short type. Provides two short fields packed into
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700325 * a single 32 bit field with 32 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700326 */
Jason Sams717e34a2010-03-16 15:35:57 -0700327typedef short short2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700328/**
329 * Vector version of the basic short type. Provides three short fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700330 * into a single 64 bit field with 64 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700331 */
Jason Sams717e34a2010-03-16 15:35:57 -0700332typedef short short3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700333/**
334 * Vector version of the basic short type. Provides four short fields packed
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700335 * into a single 64 bit field with 64 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700336 */
Jason Sams717e34a2010-03-16 15:35:57 -0700337typedef short short4 __attribute__((ext_vector_type(4)));
Jason Sams717e34a2010-03-16 15:35:57 -0700338
Jason Sams9df3b2b2011-08-08 14:31:25 -0700339/**
340 * Vector version of the basic int type. Provides two int fields packed into a
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700341 * single 64 bit field with 64 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700342 */
Jason Sams717e34a2010-03-16 15:35:57 -0700343typedef int int2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700344/**
345 * Vector version of the basic int type. Provides three int fields packed into a
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700346 * single 128 bit field with 128 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700347 */
Jason Sams717e34a2010-03-16 15:35:57 -0700348typedef int int3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700349/**
350 * Vector version of the basic int type. Provides two four fields packed into a
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700351 * single 128 bit field with 128 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700352 */
Jason Sams717e34a2010-03-16 15:35:57 -0700353typedef int int4 __attribute__((ext_vector_type(4)));
Jason Sams717e34a2010-03-16 15:35:57 -0700354
Jason Sams9df3b2b2011-08-08 14:31:25 -0700355/**
356 * Vector version of the basic long type. Provides two long fields packed into a
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700357 * single 128 bit field with 128 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700358 */
Jason Sams46f2e722011-04-22 17:05:25 -0700359typedef long long2 __attribute__((ext_vector_type(2)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700360/**
361 * Vector version of the basic long type. Provides three long fields packed into
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700362 * a single 256 bit field with 256 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700363 */
Jason Sams46f2e722011-04-22 17:05:25 -0700364typedef long long3 __attribute__((ext_vector_type(3)));
Jason Sams9df3b2b2011-08-08 14:31:25 -0700365/**
366 * Vector version of the basic long type. Provides four long fields packed into
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700367 * a single 256 bit field with 256 bit alignment.
Jason Sams9df3b2b2011-08-08 14:31:25 -0700368 */
Jason Sams46f2e722011-04-22 17:05:25 -0700369typedef long long4 __attribute__((ext_vector_type(4)));
Jason Sams717e34a2010-03-16 15:35:57 -0700370
Jason Sams9df3b2b2011-08-08 14:31:25 -0700371/**
372 * \brief 4x4 float matrix
373 *
374 * Native holder for RS matrix. Elements are stored in the array at the
375 * location [row*4 + col]
376 */
Alex Sakhartchouk05f1cb42010-08-11 10:04:21 -0700377typedef struct {
Jason Sams22fa3712010-05-19 17:22:57 -0700378 float m[16];
379} rs_matrix4x4;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700380/**
381 * \brief 3x3 float matrix
382 *
383 * Native holder for RS matrix. Elements are stored in the array at the
384 * location [row*3 + col]
385 */
Alex Sakhartchouk05f1cb42010-08-11 10:04:21 -0700386typedef struct {
Jason Sams7fe6bce2010-06-24 13:54:11 -0700387 float m[9];
388} rs_matrix3x3;
Jason Sams9df3b2b2011-08-08 14:31:25 -0700389/**
390 * \brief 2x2 float matrix
391 *
392 * Native holder for RS matrix. Elements are stored in the array at the
393 * location [row*2 + col]
394 */
Alex Sakhartchouk05f1cb42010-08-11 10:04:21 -0700395typedef struct {
Jason Sams7fe6bce2010-06-24 13:54:11 -0700396 float m[4];
397} rs_matrix2x2;
398
Jason Sams9df3b2b2011-08-08 14:31:25 -0700399/**
400 * quaternion type for use with the quaternion functions
401 */
Alex Sakhartchouk0bd010a2010-08-11 14:41:28 -0700402typedef float4 rs_quaternion;
Jason Sams7fe6bce2010-06-24 13:54:11 -0700403
Jason Sams97589cb2010-06-17 15:55:00 -0700404#define RS_PACKED __attribute__((packed, aligned(4)))
Stephen Hines6a057c32011-12-06 16:47:32 -0800405#define NULL ((void *)0)
Jason Samsc500e742011-07-25 12:58:37 -0700406
Alex Sakhartchouk43253872011-09-28 15:23:18 -0700407#if (defined(RS_VERSION) && (RS_VERSION >= 14))
Jason Sams9df3b2b2011-08-08 14:31:25 -0700408
409/**
410 * \brief Enum for selecting cube map faces
Jason Sams9df3b2b2011-08-08 14:31:25 -0700411 */
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700412typedef enum {
413 RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
414 RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
415 RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
416 RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
417 RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
418 RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
419} rs_allocation_cubemap_face;
420
Jason Sams9df3b2b2011-08-08 14:31:25 -0700421/**
422 * \brief Bitfield to specify the usage types for an allocation.
423 *
424 * These values are ORed together to specify which usages or memory spaces are
425 * relevant to an allocation or an operation on an allocation.
426 */
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700427typedef enum {
428 RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
429 RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
430 RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
431 RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
432 RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010
433} rs_allocation_usage_type;
434
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800435#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
436
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700437// New API's
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -0700438#if (defined(RS_VERSION) && (RS_VERSION >= 16))
439
Jason Sams3ff0fe72014-05-19 15:06:59 -0700440#ifndef __LP64__
Alex Sakhartchouk8d0f59e2011-12-16 14:15:07 -0800441/**
442 * Describes the way mesh vertex data is interpreted when rendering
443 *
444 **/
Alex Sakhartchouk253325d2011-12-15 09:56:10 -0800445typedef enum {
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700446 /**
447 * Vertex data will be rendered as a series of points
448 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800449 RS_PRIMITIVE_POINT = 0,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700450 /**
451 * Vertex pairs will be rendered as lines
452 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800453 RS_PRIMITIVE_LINE = 1,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700454 /**
455 * Vertex data will be rendered as a connected line strip
456 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800457 RS_PRIMITIVE_LINE_STRIP = 2,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700458 /**
459 * Vertices will be rendered as individual triangles
460 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800461 RS_PRIMITIVE_TRIANGLE = 3,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700462 /**
463 * Vertices will be rendered as a connected triangle strip
464 * defined by the first three vertices with each additional
465 * triangle defined by a new vertex
466 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800467 RS_PRIMITIVE_TRIANGLE_STRIP = 4,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700468 /**
469 * Vertices will be rendered as a sequence of triangles that all
470 * share first vertex as the origin
471 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800472 RS_PRIMITIVE_TRIANGLE_FAN = 5,
Alex Sakhartchouk25a59d02011-12-29 11:17:38 -0800473
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700474 /**
475 * Invalid primitive
476 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800477 RS_PRIMITIVE_INVALID = 100,
Alex Sakhartchouk253325d2011-12-15 09:56:10 -0800478} rs_primitive;
Jason Sams3ff0fe72014-05-19 15:06:59 -0700479#endif // __LP64__
Alex Sakhartchouk253325d2011-12-15 09:56:10 -0800480
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800481/**
482 * \brief Enumeration for possible element data types
483 *
484 * DataType represents the basic type information for a basic element. The
485 * naming convention follows. For numeric types it is FLOAT,
486 * SIGNED, or UNSIGNED followed by the _BITS where BITS is the
487 * size of the data. BOOLEAN is a true / false (1,0)
488 * represented in an 8 bit container. The UNSIGNED variants
489 * with multiple bit definitions are for packed graphical data
490 * formats and represent vectors with per vector member sizes
491 * which are treated as a single unit for packing and alignment
492 * purposes.
493 *
494 * MATRIX the three matrix types contain FLOAT_32 elements and are treated
495 * as 32 bits for alignment purposes.
496 *
497 * RS_* objects. 32 bit opaque handles.
498 */
499typedef enum {
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800500 RS_TYPE_NONE = 0,
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800501 RS_TYPE_FLOAT_32 = 2,
502 RS_TYPE_FLOAT_64 = 3,
503 RS_TYPE_SIGNED_8 = 4,
504 RS_TYPE_SIGNED_16 = 5,
505 RS_TYPE_SIGNED_32 = 6,
506 RS_TYPE_SIGNED_64 = 7,
507 RS_TYPE_UNSIGNED_8 = 8,
508 RS_TYPE_UNSIGNED_16 = 9,
509 RS_TYPE_UNSIGNED_32 = 10,
510 RS_TYPE_UNSIGNED_64 = 11,
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800511
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800512 RS_TYPE_BOOLEAN = 12,
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800513
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800514 RS_TYPE_UNSIGNED_5_6_5 = 13,
515 RS_TYPE_UNSIGNED_5_5_5_1 = 14,
516 RS_TYPE_UNSIGNED_4_4_4_4 = 15,
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800517
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800518 RS_TYPE_MATRIX_4X4 = 16,
519 RS_TYPE_MATRIX_3X3 = 17,
520 RS_TYPE_MATRIX_2X2 = 18,
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800521
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800522 RS_TYPE_ELEMENT = 1000,
523 RS_TYPE_TYPE = 1001,
524 RS_TYPE_ALLOCATION = 1002,
525 RS_TYPE_SAMPLER = 1003,
526 RS_TYPE_SCRIPT = 1004,
527 RS_TYPE_MESH = 1005,
528 RS_TYPE_PROGRAM_FRAGMENT = 1006,
529 RS_TYPE_PROGRAM_VERTEX = 1007,
530 RS_TYPE_PROGRAM_RASTER = 1008,
531 RS_TYPE_PROGRAM_STORE = 1009,
Stephen Hinesae8b7952012-04-11 18:09:54 -0700532 RS_TYPE_FONT = 1010,
Alex Sakhartchouk25a59d02011-12-29 11:17:38 -0800533
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800534 RS_TYPE_INVALID = 10000,
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800535} rs_data_type;
536
537/**
538 * \brief Enumeration for possible element data kind
539 *
540 * The special interpretation of the data if required. This is primarly
541 * useful for graphical data. USER indicates no special interpretation is
542 * expected. PIXEL is used in conjunction with the standard data types for
543 * representing texture formats.
544 */
545typedef enum {
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800546 RS_KIND_USER = 0,
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800547
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800548 RS_KIND_PIXEL_L = 7,
549 RS_KIND_PIXEL_A = 8,
550 RS_KIND_PIXEL_LA = 9,
551 RS_KIND_PIXEL_RGB = 10,
552 RS_KIND_PIXEL_RGBA = 11,
553 RS_KIND_PIXEL_DEPTH = 12,
Jason Samsbc0ca6b2013-02-15 18:13:43 -0800554 RS_KIND_PIXEL_YUV = 13,
Alex Sakhartchouk25a59d02011-12-29 11:17:38 -0800555
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800556 RS_KIND_INVALID = 100,
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800557} rs_data_kind;
Alex Sakhartchouk43253872011-09-28 15:23:18 -0700558
Jason Sams3ff0fe72014-05-19 15:06:59 -0700559#ifndef __LP64__
Jean-Luc Brouillet462e62c2014-12-12 13:42:24 -0800560/**
561 * Specifies conditional drawing depending on the comparison of the incoming
562 * depth to that found in the depth buffer.
563 *
564 **/
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800565typedef enum {
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700566 /**
567 * Always drawn
568 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800569 RS_DEPTH_FUNC_ALWAYS = 0,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700570 /**
571 * Drawn if the incoming depth value is less than that in the
572 * depth buffer
573 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800574 RS_DEPTH_FUNC_LESS = 1,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700575 /**
576 * Drawn if the incoming depth value is less or equal to that in
577 * the depth buffer
578 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800579 RS_DEPTH_FUNC_LEQUAL = 2,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700580 /**
581 * Drawn if the incoming depth value is greater than that in the
582 * depth buffer
583 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800584 RS_DEPTH_FUNC_GREATER = 3,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700585 /**
586 * Drawn if the incoming depth value is greater or equal to that
587 * in the depth buffer
588 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800589 RS_DEPTH_FUNC_GEQUAL = 4,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700590 /**
591 * Drawn if the incoming depth value is equal to that in the
592 * depth buffer
593 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800594 RS_DEPTH_FUNC_EQUAL = 5,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700595 /**
596 * Drawn if the incoming depth value is not equal to that in the
597 * depth buffer
598 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800599 RS_DEPTH_FUNC_NOTEQUAL = 6,
Alex Sakhartchouk340d15a2012-04-16 13:50:40 -0700600 /**
601 * Invalid depth function
602 */
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800603 RS_DEPTH_FUNC_INVALID = 100,
604} rs_depth_func;
605
606typedef enum {
607 RS_BLEND_SRC_ZERO = 0,
608 RS_BLEND_SRC_ONE = 1,
609 RS_BLEND_SRC_DST_COLOR = 2,
610 RS_BLEND_SRC_ONE_MINUS_DST_COLOR = 3,
611 RS_BLEND_SRC_SRC_ALPHA = 4,
612 RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA = 5,
613 RS_BLEND_SRC_DST_ALPHA = 6,
614 RS_BLEND_SRC_ONE_MINUS_DST_ALPHA = 7,
615 RS_BLEND_SRC_SRC_ALPHA_SATURATE = 8,
616
617 RS_BLEND_SRC_INVALID = 100,
618} rs_blend_src_func;
619
620typedef enum {
621 RS_BLEND_DST_ZERO = 0,
622 RS_BLEND_DST_ONE = 1,
623 RS_BLEND_DST_SRC_COLOR = 2,
624 RS_BLEND_DST_ONE_MINUS_SRC_COLOR = 3,
625 RS_BLEND_DST_SRC_ALPHA = 4,
626 RS_BLEND_DST_ONE_MINUS_SRC_ALPHA = 5,
627 RS_BLEND_DST_DST_ALPHA = 6,
628 RS_BLEND_DST_ONE_MINUS_DST_ALPHA = 7,
629
630 RS_BLEND_DST_INVALID = 100,
631} rs_blend_dst_func;
632
633typedef enum {
634 RS_CULL_BACK = 0,
635 RS_CULL_FRONT = 1,
636 RS_CULL_NONE = 2,
637
638 RS_CULL_INVALID = 100,
639} rs_cull_mode;
Jason Sams3ff0fe72014-05-19 15:06:59 -0700640#endif //__LP64__
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800641
642typedef enum {
643 RS_SAMPLER_NEAREST = 0,
644 RS_SAMPLER_LINEAR = 1,
645 RS_SAMPLER_LINEAR_MIP_LINEAR = 2,
646 RS_SAMPLER_WRAP = 3,
647 RS_SAMPLER_CLAMP = 4,
648 RS_SAMPLER_LINEAR_MIP_NEAREST = 5,
Tim Murray9e913f42013-02-15 13:29:24 -0800649 RS_SAMPLER_MIRRORED_REPEAT = 6,
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800650
651 RS_SAMPLER_INVALID = 100,
652} rs_sampler_value;
653
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -0700654#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
655
656#endif // __RS_TYPES_RSH__