rs_types.rsh
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 The Android Open Source Project
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00041 #ifndef __RS_TYPES_RSH__
00042 #define __RS_TYPES_RSH__
00043 
00044 #define M_PI        3.14159265358979323846264338327950288f   /* pi */
00045 
00046 #include "stdbool.h"
00050 typedef char int8_t;
00054 typedef short int16_t;
00058 typedef int int32_t;
00062 typedef long long int64_t;
00066 typedef unsigned char uint8_t;
00070 typedef unsigned short uint16_t;
00074 typedef unsigned int uint32_t;
00078 typedef unsigned long long uint64_t;
00082 typedef uint8_t uchar;
00086 typedef uint16_t ushort;
00090 typedef uint32_t uint;
00094 typedef uint64_t ulong;
00098 typedef uint32_t size_t;
00102 typedef int32_t ssize_t;
00103 
00109 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_element;
00115 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_type;
00121 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_allocation;
00127 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_sampler;
00133 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_script;
00139 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_mesh;
00145 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_path;
00151 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_fragment;
00157 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_vertex;
00163 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_raster;
00169 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_store;
00175 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_font;
00176 
00182 typedef float float2 __attribute__((ext_vector_type(2)));
00187 typedef float float3 __attribute__((ext_vector_type(3)));
00193 typedef float float4 __attribute__((ext_vector_type(4)));
00194 
00199 typedef double double2 __attribute__((ext_vector_type(2)));
00204 typedef double double3 __attribute__((ext_vector_type(3)));
00209 typedef double double4 __attribute__((ext_vector_type(4)));
00210 
00215 typedef uchar uchar2 __attribute__((ext_vector_type(2)));
00220 typedef uchar uchar3 __attribute__((ext_vector_type(3)));
00225 typedef uchar uchar4 __attribute__((ext_vector_type(4)));
00226 
00231 typedef ushort ushort2 __attribute__((ext_vector_type(2)));
00236 typedef ushort ushort3 __attribute__((ext_vector_type(3)));
00241 typedef ushort ushort4 __attribute__((ext_vector_type(4)));
00242 
00247 typedef uint uint2 __attribute__((ext_vector_type(2)));
00252 typedef uint uint3 __attribute__((ext_vector_type(3)));
00257 typedef uint uint4 __attribute__((ext_vector_type(4)));
00258 
00263 typedef ulong ulong2 __attribute__((ext_vector_type(2)));
00268 typedef ulong ulong3 __attribute__((ext_vector_type(3)));
00273 typedef ulong ulong4 __attribute__((ext_vector_type(4)));
00274 
00279 typedef char char2 __attribute__((ext_vector_type(2)));
00284 typedef char char3 __attribute__((ext_vector_type(3)));
00289 typedef char char4 __attribute__((ext_vector_type(4)));
00290 
00295 typedef short short2 __attribute__((ext_vector_type(2)));
00300 typedef short short3 __attribute__((ext_vector_type(3)));
00305 typedef short short4 __attribute__((ext_vector_type(4)));
00306 
00311 typedef int int2 __attribute__((ext_vector_type(2)));
00316 typedef int int3 __attribute__((ext_vector_type(3)));
00321 typedef int int4 __attribute__((ext_vector_type(4)));
00322 
00327 typedef long long2 __attribute__((ext_vector_type(2)));
00332 typedef long long3 __attribute__((ext_vector_type(3)));
00337 typedef long long4 __attribute__((ext_vector_type(4)));
00338 
00345 typedef struct {
00346     float m[16];
00347 } rs_matrix4x4;
00354 typedef struct {
00355     float m[9];
00356 } rs_matrix3x3;
00363 typedef struct {
00364     float m[4];
00365 } rs_matrix2x2;
00366 
00370 typedef float4 rs_quaternion;
00371 
00372 #define RS_PACKED __attribute__((packed, aligned(4)))
00373 #define NULL ((void *)0)
00374 
00375 #if (defined(RS_VERSION) && (RS_VERSION >= 14))
00376 
00380 typedef enum {
00381     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
00382     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
00383     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
00384     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
00385     RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
00386     RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
00387 } rs_allocation_cubemap_face;
00388 
00395 typedef enum {
00396     RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
00397     RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
00398     RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
00399     RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
00400     RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010
00401 } rs_allocation_usage_type;
00402 
00403 #endif //defined(RS_VERSION) && (RS_VERSION >= 14)
00404 
00405 // New API's
00406 #if (defined(RS_VERSION) && (RS_VERSION >= 16))
00407 
00412 typedef enum {
00416     RS_PRIMITIVE_POINT              = 0,
00420     RS_PRIMITIVE_LINE               = 1,
00424     RS_PRIMITIVE_LINE_STRIP         = 2,
00428     RS_PRIMITIVE_TRIANGLE           = 3,
00434     RS_PRIMITIVE_TRIANGLE_STRIP     = 4,
00439     RS_PRIMITIVE_TRIANGLE_FAN       = 5,
00440 
00444     RS_PRIMITIVE_INVALID            = 100,
00445 } rs_primitive;
00446 
00465 typedef enum {
00466     RS_TYPE_NONE             = 0,
00467     RS_TYPE_FLOAT_32         = 2,
00468     RS_TYPE_FLOAT_64         = 3,
00469     RS_TYPE_SIGNED_8         = 4,
00470     RS_TYPE_SIGNED_16        = 5,
00471     RS_TYPE_SIGNED_32        = 6,
00472     RS_TYPE_SIGNED_64        = 7,
00473     RS_TYPE_UNSIGNED_8       = 8,
00474     RS_TYPE_UNSIGNED_16      = 9,
00475     RS_TYPE_UNSIGNED_32      = 10,
00476     RS_TYPE_UNSIGNED_64      = 11,
00477 
00478     RS_TYPE_BOOLEAN          = 12,
00479 
00480     RS_TYPE_UNSIGNED_5_6_5   = 13,
00481     RS_TYPE_UNSIGNED_5_5_5_1 = 14,
00482     RS_TYPE_UNSIGNED_4_4_4_4 = 15,
00483 
00484     RS_TYPE_MATRIX_4X4       = 16,
00485     RS_TYPE_MATRIX_3X3       = 17,
00486     RS_TYPE_MATRIX_2X2       = 18,
00487 
00488     RS_TYPE_ELEMENT          = 1000,
00489     RS_TYPE_TYPE             = 1001,
00490     RS_TYPE_ALLOCATION       = 1002,
00491     RS_TYPE_SAMPLER          = 1003,
00492     RS_TYPE_SCRIPT           = 1004,
00493     RS_TYPE_MESH             = 1005,
00494     RS_TYPE_PROGRAM_FRAGMENT = 1006,
00495     RS_TYPE_PROGRAM_VERTEX   = 1007,
00496     RS_TYPE_PROGRAM_RASTER   = 1008,
00497     RS_TYPE_PROGRAM_STORE    = 1009,
00498     RS_TYPE_FONT             = 1010,
00499 
00500     RS_TYPE_INVALID          = 10000,
00501 } rs_data_type;
00502 
00511 typedef enum {
00512     RS_KIND_USER         = 0,
00513 
00514     RS_KIND_PIXEL_L      = 7,
00515     RS_KIND_PIXEL_A      = 8,
00516     RS_KIND_PIXEL_LA     = 9,
00517     RS_KIND_PIXEL_RGB    = 10,
00518     RS_KIND_PIXEL_RGBA   = 11,
00519     RS_KIND_PIXEL_DEPTH  = 12,
00520 
00521     RS_KIND_INVALID      = 100,
00522 } rs_data_kind;
00523 
00524 typedef enum {
00528     RS_DEPTH_FUNC_ALWAYS        = 0,
00533     RS_DEPTH_FUNC_LESS          = 1,
00538     RS_DEPTH_FUNC_LEQUAL        = 2,
00543     RS_DEPTH_FUNC_GREATER       = 3,
00548     RS_DEPTH_FUNC_GEQUAL        = 4,
00553     RS_DEPTH_FUNC_EQUAL         = 5,
00558     RS_DEPTH_FUNC_NOTEQUAL      = 6,
00562     RS_DEPTH_FUNC_INVALID       = 100,
00563 } rs_depth_func;
00564 
00565 typedef enum {
00566     RS_BLEND_SRC_ZERO                   = 0,
00567     RS_BLEND_SRC_ONE                    = 1,
00568     RS_BLEND_SRC_DST_COLOR              = 2,
00569     RS_BLEND_SRC_ONE_MINUS_DST_COLOR    = 3,
00570     RS_BLEND_SRC_SRC_ALPHA              = 4,
00571     RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA    = 5,
00572     RS_BLEND_SRC_DST_ALPHA              = 6,
00573     RS_BLEND_SRC_ONE_MINUS_DST_ALPHA    = 7,
00574     RS_BLEND_SRC_SRC_ALPHA_SATURATE     = 8,
00575 
00576     RS_BLEND_SRC_INVALID                = 100,
00577 } rs_blend_src_func;
00578 
00579 typedef enum {
00580     RS_BLEND_DST_ZERO                   = 0,
00581     RS_BLEND_DST_ONE                    = 1,
00582     RS_BLEND_DST_SRC_COLOR              = 2,
00583     RS_BLEND_DST_ONE_MINUS_SRC_COLOR    = 3,
00584     RS_BLEND_DST_SRC_ALPHA              = 4,
00585     RS_BLEND_DST_ONE_MINUS_SRC_ALPHA    = 5,
00586     RS_BLEND_DST_DST_ALPHA              = 6,
00587     RS_BLEND_DST_ONE_MINUS_DST_ALPHA    = 7,
00588 
00589     RS_BLEND_DST_INVALID                = 100,
00590 } rs_blend_dst_func;
00591 
00592 typedef enum {
00593     RS_CULL_BACK     = 0,
00594     RS_CULL_FRONT    = 1,
00595     RS_CULL_NONE     = 2,
00596 
00597     RS_CULL_INVALID  = 100,
00598 } rs_cull_mode;
00599 
00600 typedef enum {
00601     RS_SAMPLER_NEAREST              = 0,
00602     RS_SAMPLER_LINEAR               = 1,
00603     RS_SAMPLER_LINEAR_MIP_LINEAR    = 2,
00604     RS_SAMPLER_WRAP                 = 3,
00605     RS_SAMPLER_CLAMP                = 4,
00606     RS_SAMPLER_LINEAR_MIP_NEAREST   = 5,
00607 
00608     RS_SAMPLER_INVALID              = 100,
00609 } rs_sampler_value;
00610 
00611 #endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
00612 
00613 #endif // __RS_TYPES_RSH__