Compatible Android

This commit is contained in:
Andros Fenollosa
2016-11-03 00:05:36 +01:00
parent 7cb6af1390
commit 8ec8327e5e
1793 changed files with 440698 additions and 7 deletions

View File

@ -0,0 +1,378 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_allocation.rsh
* \brief Allocation routines
*
*
*/
#ifndef __RS_ALLOCATION_RSH__
#define __RS_ALLOCATION_RSH__
/**
* Returns the Allocation for a given pointer. The pointer should point within
* a valid allocation. The results are undefined if the pointer is not from a
* valid allocation.
*
* This function is deprecated and will be removed in the SDK from a future
* release.
*/
extern rs_allocation __attribute__((overloadable))
rsGetAllocation(const void *);
/**
* Query the dimension of an allocation.
*
* @return uint32_t The X dimension of the allocation.
*/
extern uint32_t __attribute__((overloadable))
rsAllocationGetDimX(rs_allocation);
/**
* Query the dimension of an allocation.
*
* @return uint32_t The Y dimension of the allocation.
*/
extern uint32_t __attribute__((overloadable))
rsAllocationGetDimY(rs_allocation);
/**
* Query the dimension of an allocation.
*
* @return uint32_t The Z dimension of the allocation.
*/
extern uint32_t __attribute__((overloadable))
rsAllocationGetDimZ(rs_allocation);
/**
* Query an allocation for the presence of more than one LOD.
*
* @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
*/
extern uint32_t __attribute__((overloadable))
rsAllocationGetDimLOD(rs_allocation);
/**
* Query an allocation for the presence of more than one face.
*
* @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
*/
extern uint32_t __attribute__((overloadable))
rsAllocationGetDimFaces(rs_allocation);
#if (defined(RS_VERSION) && (RS_VERSION >= 14))
/**
* Copy part of an allocation from another allocation.
*
* @param dstAlloc Allocation to copy data into.
* @param dstOff The offset of the first element to be copied in
* the destination allocation.
* @param dstMip Mip level in the destination allocation.
* @param count The number of elements to be copied.
* @param srcAlloc The source data allocation.
* @param srcOff The offset of the first element in data to be
* copied in the source allocation.
* @param srcMip Mip level in the source allocation.
*/
extern void __attribute__((overloadable))
rsAllocationCopy1DRange(rs_allocation dstAlloc,
uint32_t dstOff, uint32_t dstMip,
uint32_t count,
rs_allocation srcAlloc,
uint32_t srcOff, uint32_t srcMip);
/**
* Copy a rectangular region into the allocation from another
* allocation.
*
* @param dstAlloc allocation to copy data into.
* @param dstXoff X offset of the region to update in the
* destination allocation.
* @param dstYoff Y offset of the region to update in the
* destination allocation.
* @param dstMip Mip level in the destination allocation.
* @param dstFace Cubemap face of the destination allocation,
* ignored for allocations that aren't cubemaps.
* @param width Width of the incoming region to update.
* @param height Height of the incoming region to update.
* @param srcAlloc The source data allocation.
* @param srcXoff X offset in data of the source allocation.
* @param srcYoff Y offset in data of the source allocation.
* @param srcMip Mip level in the source allocation.
* @param srcFace Cubemap face of the source allocation,
* ignored for allocations that aren't cubemaps.
*/
extern void __attribute__((overloadable))
rsAllocationCopy2DRange(rs_allocation dstAlloc,
uint32_t dstXoff, uint32_t dstYoff,
uint32_t dstMip,
rs_allocation_cubemap_face dstFace,
uint32_t width, uint32_t height,
rs_allocation srcAlloc,
uint32_t srcXoff, uint32_t srcYoff,
uint32_t srcMip,
rs_allocation_cubemap_face srcFace);
#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
/**
* Extract a single element from an allocation.
*/
extern const void * __attribute__((overloadable))
rsGetElementAt(rs_allocation a, uint32_t x);
/**
* \overload
*/
extern const void * __attribute__((overloadable))
rsGetElementAt(rs_allocation a, uint32_t x, uint32_t y);
/**
* \overload
*/
extern const void * __attribute__((overloadable))
rsGetElementAt(rs_allocation a, uint32_t x, uint32_t y, uint32_t z);
#if (defined(RS_VERSION) && (RS_VERSION >= 18))
#define GET_ELEMENT_AT(T) \
extern T __attribute__((overloadable)) \
rsGetElementAt_##T(rs_allocation a, uint32_t x); \
extern T __attribute__((overloadable)) \
rsGetElementAt_##T(rs_allocation a, uint32_t x, uint32_t y); \
extern T __attribute__((overloadable)) \
rsGetElementAt_##T(rs_allocation a, uint32_t x, uint32_t y, uint32_t z);
#else
#define GET_ELEMENT_AT(T) \
static inline T __attribute__((overloadable)) \
rsGetElementAt_##T(rs_allocation a, uint32_t x) { \
return ((T *)rsGetElementAt(a, x))[0]; \
} \
static inline T __attribute__((overloadable)) \
rsGetElementAt_##T(rs_allocation a, uint32_t x, uint32_t y) { \
return ((T *)rsGetElementAt(a, x, y))[0]; \
} \
static inline T __attribute__((overloadable)) \
rsGetElementAt_##T(rs_allocation a, uint32_t x, uint32_t y, uint32_t z) { \
return ((T *)rsGetElementAt(a, x, y, z))[0]; \
}
#endif
GET_ELEMENT_AT(char)
GET_ELEMENT_AT(char2)
GET_ELEMENT_AT(char3)
GET_ELEMENT_AT(char4)
GET_ELEMENT_AT(uchar)
GET_ELEMENT_AT(uchar2)
GET_ELEMENT_AT(uchar3)
GET_ELEMENT_AT(uchar4)
GET_ELEMENT_AT(short)
GET_ELEMENT_AT(short2)
GET_ELEMENT_AT(short3)
GET_ELEMENT_AT(short4)
GET_ELEMENT_AT(ushort)
GET_ELEMENT_AT(ushort2)
GET_ELEMENT_AT(ushort3)
GET_ELEMENT_AT(ushort4)
GET_ELEMENT_AT(int)
GET_ELEMENT_AT(int2)
GET_ELEMENT_AT(int3)
GET_ELEMENT_AT(int4)
GET_ELEMENT_AT(uint)
GET_ELEMENT_AT(uint2)
GET_ELEMENT_AT(uint3)
GET_ELEMENT_AT(uint4)
GET_ELEMENT_AT(long)
GET_ELEMENT_AT(long2)
GET_ELEMENT_AT(long3)
GET_ELEMENT_AT(long4)
GET_ELEMENT_AT(ulong)
GET_ELEMENT_AT(ulong2)
GET_ELEMENT_AT(ulong3)
GET_ELEMENT_AT(ulong4)
GET_ELEMENT_AT(float)
GET_ELEMENT_AT(float2)
GET_ELEMENT_AT(float3)
GET_ELEMENT_AT(float4)
GET_ELEMENT_AT(double)
GET_ELEMENT_AT(double2)
GET_ELEMENT_AT(double3)
GET_ELEMENT_AT(double4)
#undef GET_ELEMENT_AT
// Jelly Bean
#if (defined(RS_VERSION) && (RS_VERSION >= 16))
/**
* Send the contents of the Allocation to the queue.
* @param a allocation to work on
*/
extern const void __attribute__((overloadable))
rsAllocationIoSend(rs_allocation a);
/**
* Receive a new set of contents from the queue.
* @param a allocation to work on
*/
extern const void __attribute__((overloadable))
rsAllocationIoReceive(rs_allocation a);
/**
* Get the element object describing the allocation's layout
* @param a allocation to get data from
* @return element describing allocation layout
*/
extern rs_element __attribute__((overloadable))
rsAllocationGetElement(rs_allocation a);
/**
* Fetch allocation in a way described by the sampler
* @param a 1D allocation to sample from
* @param s sampler state
* @param location to sample from
*/
extern const float4 __attribute__((overloadable))
rsSample(rs_allocation a, rs_sampler s, float location);
/**
* Fetch allocation in a way described by the sampler
* @param a 1D allocation to sample from
* @param s sampler state
* @param location to sample from
* @param lod mip level to sample from, for fractional values
* mip levels will be interpolated if
* RS_SAMPLER_LINEAR_MIP_LINEAR is used
*/
extern const float4 __attribute__((overloadable))
rsSample(rs_allocation a, rs_sampler s, float location, float lod);
/**
* Fetch allocation in a way described by the sampler
* @param a 2D allocation to sample from
* @param s sampler state
* @param location to sample from
*/
extern const float4 __attribute__((overloadable))
rsSample(rs_allocation a, rs_sampler s, float2 location);
/**
* Fetch allocation in a way described by the sampler
* @param a 2D allocation to sample from
* @param s sampler state
* @param location to sample from
* @param lod mip level to sample from, for fractional values
* mip levels will be interpolated if
* RS_SAMPLER_LINEAR_MIP_LINEAR is used
*/
extern const float4 __attribute__((overloadable))
rsSample(rs_allocation a, rs_sampler s, float2 location, float lod);
#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
#if (defined(RS_VERSION) && (RS_VERSION >= 18))
/**
* Set single element of an allocation.
*/
extern void __attribute__((overloadable))
rsSetElementAt(rs_allocation a, void* ptr, uint32_t x);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetElementAt(rs_allocation a, void* ptr, uint32_t x, uint32_t y);
#define SET_ELEMENT_AT(T) \
extern void __attribute__((overloadable)) \
rsSetElementAt_##T(rs_allocation a, T val, uint32_t x); \
extern void __attribute__((overloadable)) \
rsSetElementAt_##T(rs_allocation a, T val, uint32_t x, uint32_t y); \
extern void __attribute__((overloadable)) \
rsSetElementAt_##T(rs_allocation a, T val, uint32_t x, uint32_t y, uint32_t z);
SET_ELEMENT_AT(char)
SET_ELEMENT_AT(char2)
SET_ELEMENT_AT(char3)
SET_ELEMENT_AT(char4)
SET_ELEMENT_AT(uchar)
SET_ELEMENT_AT(uchar2)
SET_ELEMENT_AT(uchar3)
SET_ELEMENT_AT(uchar4)
SET_ELEMENT_AT(short)
SET_ELEMENT_AT(short2)
SET_ELEMENT_AT(short3)
SET_ELEMENT_AT(short4)
SET_ELEMENT_AT(ushort)
SET_ELEMENT_AT(ushort2)
SET_ELEMENT_AT(ushort3)
SET_ELEMENT_AT(ushort4)
SET_ELEMENT_AT(int)
SET_ELEMENT_AT(int2)
SET_ELEMENT_AT(int3)
SET_ELEMENT_AT(int4)
SET_ELEMENT_AT(uint)
SET_ELEMENT_AT(uint2)
SET_ELEMENT_AT(uint3)
SET_ELEMENT_AT(uint4)
SET_ELEMENT_AT(long)
SET_ELEMENT_AT(long2)
SET_ELEMENT_AT(long3)
SET_ELEMENT_AT(long4)
SET_ELEMENT_AT(ulong)
SET_ELEMENT_AT(ulong2)
SET_ELEMENT_AT(ulong3)
SET_ELEMENT_AT(ulong4)
SET_ELEMENT_AT(float)
SET_ELEMENT_AT(float2)
SET_ELEMENT_AT(float3)
SET_ELEMENT_AT(float4)
SET_ELEMENT_AT(double)
SET_ELEMENT_AT(double2)
SET_ELEMENT_AT(double3)
SET_ELEMENT_AT(double4)
#undef SET_ELEMENT_AT
/**
* Extract a single element from an allocation.
*/
extern const uchar __attribute__((overloadable))
rsGetElementAtYuv_uchar_Y(rs_allocation a, uint32_t x, uint32_t y);
/**
* Extract a single element from an allocation.
*
* Coordinates are in the dimensions of the Y plane
*/
extern const uchar __attribute__((overloadable))
rsGetElementAtYuv_uchar_U(rs_allocation a, uint32_t x, uint32_t y);
/**
* Extract a single element from an allocation.
*
* Coordinates are in the dimensions of the Y plane
*/
extern const uchar __attribute__((overloadable))
rsGetElementAtYuv_uchar_V(rs_allocation a, uint32_t x, uint32_t y);
#endif // (defined(RS_VERSION) && (RS_VERSION >= 18))
#endif

View File

@ -0,0 +1,250 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_atomic.rsh
* \brief Atomic routines
*
*
*/
#ifndef __RS_ATOMIC_RSH__
#define __RS_ATOMIC_RSH__
#if (defined(RS_VERSION) && (RS_VERSION >= 14))
/**
* Atomic add one to the value at addr.
* Equal to rsAtomicAdd(addr, 1)
*
* @param addr Address of value to increment
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicInc(volatile int32_t* addr);
/**
* Atomic add one to the value at addr.
* Equal to rsAtomicAdd(addr, 1)
*
* @param addr Address of value to increment
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicInc(volatile uint32_t* addr);
/**
* Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
*
* @param addr Address of value to decrement
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicDec(volatile int32_t* addr);
/**
* Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
*
* @param addr Address of value to decrement
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicDec(volatile uint32_t* addr);
/**
* Atomic add a value to the value at addr. addr[0] += value
*
* @param addr Address of value to modify
* @param value Amount to add to the value at addr
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicAdd(volatile int32_t* addr, int32_t value);
/**
* Atomic add a value to the value at addr. addr[0] += value
*
* @param addr Address of value to modify
* @param value Amount to add to the value at addr
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicAdd(volatile uint32_t* addr, uint32_t value);
/**
* Atomic Subtract a value from the value at addr. addr[0] -= value
*
* @param addr Address of value to modify
* @param value Amount to subtract from the value at addr
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicSub(volatile int32_t* addr, int32_t value);
/**
* Atomic Subtract a value from the value at addr. addr[0] -= value
*
* @param addr Address of value to modify
* @param value Amount to subtract from the value at addr
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicSub(volatile uint32_t* addr, uint32_t value);
/**
* Atomic Bitwise and a value from the value at addr. addr[0] &= value
*
* @param addr Address of value to modify
* @param value Amount to and with the value at addr
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicAnd(volatile int32_t* addr, int32_t value);
/**
* Atomic Bitwise and a value from the value at addr. addr[0] &= value
*
* @param addr Address of value to modify
* @param value Amount to and with the value at addr
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicAnd(volatile uint32_t* addr, uint32_t value);
/**
* Atomic Bitwise or a value from the value at addr. addr[0] |= value
*
* @param addr Address of value to modify
* @param value Amount to or with the value at addr
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicOr(volatile int32_t* addr, int32_t value);
/**
* Atomic Bitwise or a value from the value at addr. addr[0] |= value
*
* @param addr Address of value to modify
* @param value Amount to or with the value at addr
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicOr(volatile uint32_t* addr, uint32_t value);
/**
* Atomic Bitwise xor a value from the value at addr. addr[0] ^= value
*
* @param addr Address of value to modify
* @param value Amount to xor with the value at addr
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicXor(volatile uint32_t* addr, uint32_t value);
/**
* Atomic Bitwise xor a value from the value at addr. addr[0] ^= value
*
* @param addr Address of value to modify
* @param value Amount to xor with the value at addr
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicXor(volatile int32_t* addr, int32_t value);
/**
* Atomic Set the value at addr to the min of addr and value
* addr[0] = rsMin(addr[0], value)
*
* @param addr Address of value to modify
* @param value comparison value
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicMin(volatile uint32_t* addr, uint32_t value);
/**
* Atomic Set the value at addr to the min of addr and value
* addr[0] = rsMin(addr[0], value)
*
* @param addr Address of value to modify
* @param value comparison value
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicMin(volatile int32_t* addr, int32_t value);
/**
* Atomic Set the value at addr to the max of addr and value
* addr[0] = rsMax(addr[0], value)
*
* @param addr Address of value to modify
* @param value comparison value
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicMax(volatile uint32_t* addr, uint32_t value);
/**
* Atomic Set the value at addr to the max of addr and value
* addr[0] = rsMin(addr[0], value)
*
* @param addr Address of value to modify
* @param value comparison value
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicMax(volatile int32_t* addr, int32_t value);
/**
* Compare-and-set operation with a full memory barrier.
*
* If the value at addr matches compareValue then newValue is written.
*
* @param addr The address to compare and replace if the compare passes.
* @param compareValue The value to test addr[0] against.
* @param newValue The value to write if the test passes.
*
* @return old value
*/
extern int32_t __attribute__((overloadable))
rsAtomicCas(volatile int32_t* addr, int32_t compareValue, int32_t newValue);
/**
* Compare-and-set operation with a full memory barrier.
*
* If the value at addr matches compareValue then newValue is written.
*
* @param addr The address to compare and replace if the compare passes.
* @param compareValue The value to test addr[0] against.
* @param newValue The value to write if the test passes.
*
* @return old value
*/
extern uint32_t __attribute__((overloadable))
rsAtomicCas(volatile uint32_t* addr, uint32_t compareValue, uint32_t newValue);
#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
#endif

View File

@ -0,0 +1,189 @@
/*
* Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*! \mainpage notitle
*
* RenderScript is a high-performance runtime that provides
* compute operations at the native level. RenderScript code is compiled on devices
* at runtime to allow platform-independence as well.
* This reference documentation describes the RenderScript runtime APIs, which you
* can utilize to write RenderScript code in C99. The RenderScript compute header
* files are automatically included for you.
*
* To use RenderScript, you need to utilize the RenderScript runtime APIs documented here
* as well as the Android framework APIs for RenderScript.
* For documentation on the Android framework APIs, see the <a target="_parent" href=
* "http://developer.android.com/reference/android/renderscript/package-summary.html">
* android.renderscript</a> package reference.
* For more information on how to develop with RenderScript and how the runtime and
* Android framework APIs interact, see the <a target="_parent" href=
* "http://developer.android.com/guide/topics/renderscript/index.html">RenderScript
* developer guide</a> and the <a target="_parent" href=
* "http://developer.android.com/resources/samples/RenderScript/index.html">
* RenderScript samples</a>.
*/
/** @file rs_core.rsh
* \brief todo-jsams
*
* todo-jsams
*
*/
#ifndef __RS_CORE_RSH__
#define __RS_CORE_RSH__
#define _RS_RUNTIME extern
#include "rs_types.rsh"
#include "rs_allocation.rsh"
#include "rs_atomic.rsh"
#include "rs_cl.rsh"
#include "rs_debug.rsh"
#include "rs_element.rsh"
#include "rs_math.rsh"
#include "rs_matrix.rsh"
#include "rs_object.rsh"
#include "rs_quaternion.rsh"
#include "rs_sampler.rsh"
#include "rs_time.rsh"
/**
* Send a message back to the client. Will not block and returns true
* if the message was sendable and false if the fifo was full.
* A message ID is required. Data payload is optional.
*/
extern bool __attribute__((overloadable))
rsSendToClient(int cmdID);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsSendToClient(int cmdID, const void *data, uint len);
/**
* Send a message back to the client, blocking until the message is queued.
* A message ID is required. Data payload is optional.
*/
extern void __attribute__((overloadable))
rsSendToClientBlocking(int cmdID);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSendToClientBlocking(int cmdID, const void *data, uint len);
/**
* Launch order hint for rsForEach calls. This provides a hint to the system to
* determine in which order the root function of the target is called with each
* cell of the allocation.
*
* This is a hint and implementations may not obey the order.
*/
enum rs_for_each_strategy {
RS_FOR_EACH_STRATEGY_SERIAL = 0,
RS_FOR_EACH_STRATEGY_DONT_CARE = 1,
RS_FOR_EACH_STRATEGY_DST_LINEAR = 2,
RS_FOR_EACH_STRATEGY_TILE_SMALL= 3,
RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4,
RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
};
/**
* Structure to provide extra information to a rsForEach call. Primarly used to
* restrict the call to a subset of cells in the allocation.
*/
typedef struct rs_script_call {
enum rs_for_each_strategy strategy;
uint32_t xStart;
uint32_t xEnd;
uint32_t yStart;
uint32_t yEnd;
uint32_t zStart;
uint32_t zEnd;
uint32_t arrayStart;
uint32_t arrayEnd;
} rs_script_call_t;
/**
* Make a script to script call to launch work. One of the input or output is
* required to be a valid object. The input and output must be of the same
* dimensions.
* API 10-13
*
* @param script The target script to call
* @param input The allocation to source data from
* @param output the allocation to write date into
* @param usrData The user definied params to pass to the root script. May be
* NULL.
* @param sc Extra control infomation used to select a sub-region of the
* allocation to be processed or suggest a walking strategy. May be
* NULL.
*
* */
#if !defined(RS_VERSION) || (RS_VERSION < 14)
extern void __attribute__((overloadable))
rsForEach(rs_script script, rs_allocation input,
rs_allocation output, const void * usrData,
const rs_script_call_t *sc);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsForEach(rs_script script, rs_allocation input,
rs_allocation output, const void * usrData);
#else
/**
* Make a script to script call to launch work. One of the input or output is
* required to be a valid object. The input and output must be of the same
* dimensions.
* API 14+
*
* @param script The target script to call
* @param input The allocation to source data from
* @param output the allocation to write date into
* @param usrData The user definied params to pass to the root script. May be
* NULL.
* @param usrDataLen The size of the userData structure. This will be used to
* perform a shallow copy of the data if necessary.
* @param sc Extra control infomation used to select a sub-region of the
* allocation to be processed or suggest a walking strategy. May be
* NULL.
*
*/
extern void __attribute__((overloadable))
rsForEach(rs_script script, rs_allocation input, rs_allocation output,
const void * usrData, size_t usrDataLen, const rs_script_call_t *);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsForEach(rs_script script, rs_allocation input, rs_allocation output,
const void * usrData, size_t usrDataLen);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsForEach(rs_script script, rs_allocation input, rs_allocation output);
#endif
#undef _RS_RUNTIME
#endif

View File

@ -0,0 +1,267 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_debug.rsh
* \brief Utility debugging routines
*
* Routines intended to be used during application developement. These should
* not be used in shipping applications. All print a string and value pair to
* the standard log.
*
*/
#ifndef __RS_DEBUG_RSH__
#define __RS_DEBUG_RSH__
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, float);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, float, float);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, float, float, float);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, float, float, float, float);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, float2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, float3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, float4);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, double);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, const rs_matrix4x4 *);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, const rs_matrix3x3 *);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, const rs_matrix2x2 *);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, int);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, uint);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, long);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, unsigned long);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, long long);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, unsigned long long);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, const void *);
#if (defined(RS_VERSION) && (RS_VERSION >= 17))
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, char);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, char2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, char3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, char4);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, unsigned char);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, uchar2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, uchar3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, uchar4);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, short);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, short2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, short3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, short4);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, unsigned short);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, ushort2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, ushort3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, ushort4);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, int2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, int3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, int4);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, uint2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, uint3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, uint4);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, long2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, long3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, long4);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, ulong2);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, ulong3);
/**
* Debug function. Prints a string and value to the log.
*/
extern void __attribute__((overloadable))
rsDebug(const char *, ulong4);
#endif // (defined(RS_VERSION) && (RS_VERSION >= 17))
#define RS_DEBUG(a) rsDebug(#a, a)
#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
#endif

View File

@ -0,0 +1,143 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_element.rsh
* \brief Element routines
*
*
*/
#ifndef __RS_ELEMENT_RSH__
#define __RS_ELEMENT_RSH__
// New API's
#if (defined(RS_VERSION) && (RS_VERSION >= 16))
/**
* Elements could be simple, such as an int or a float, or a
* structure with multiple sub elements, such as a collection of
* floats, float2, float4. This function returns zero for simple
* elements or the number of sub-elements otherwise.
*
* @param e element to get data from
* @return number of sub-elements in this element
*/
extern uint32_t __attribute__((overloadable))
rsElementGetSubElementCount(rs_element e);
/**
* For complex elements, this function will return the
* sub-element at index
*
* @param e element to get data from
* @param index index of the sub-element to return
* @return sub-element in this element at given index
*/
extern rs_element __attribute__((overloadable))
rsElementGetSubElement(rs_element, uint32_t index);
/**
* For complex elements, this function will return the length of
* sub-element name at index
*
* @param e element to get data from
* @param index index of the sub-element to return
* @return length of the sub-element name including the null
* terminator (size of buffer needed to write the name)
*/
extern uint32_t __attribute__((overloadable))
rsElementGetSubElementNameLength(rs_element e, uint32_t index);
/**
* For complex elements, this function will return the
* sub-element name at index
*
* @param e element to get data from
* @param index index of the sub-element
* @param name array to store the name into
* @param nameLength length of the provided name array
* @return number of characters actually written, excluding the
* null terminator
*/
extern uint32_t __attribute__((overloadable))
rsElementGetSubElementName(rs_element e, uint32_t index, char *name, uint32_t nameLength);
/**
* For complex elements, some sub-elements could be statically
* sized arrays. This function will return the array size for
* sub-element at index
*
* @param e element to get data from
* @param index index of the sub-element
* @return array size of sub-element in this element at given
* index
*/
extern uint32_t __attribute__((overloadable))
rsElementGetSubElementArraySize(rs_element e, uint32_t index);
/**
* This function specifies the location of a sub-element within
* the element
*
* @param e element to get data from
* @param index index of the sub-element
* @return offset in bytes of sub-element in this element at
* given index
*/
extern uint32_t __attribute__((overloadable))
rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index);
/**
* Returns the size of element in bytes
*
* @param e element to get data from
* @return total size of the element in bytes
*/
extern uint32_t __attribute__((overloadable))
rsElementGetBytesSize(rs_element e);
/**
* Returns the element's data type
*
* @param e element to get data from
* @return element's data type
*/
extern rs_data_type __attribute__((overloadable))
rsElementGetDataType(rs_element e);
/**
* Returns the element's data kind
*
* @param e element to get data from
* @return element's data size
*/
extern rs_data_kind __attribute__((overloadable))
rsElementGetDataKind(rs_element e);
/**
* Returns the element's vector size
*
* @param e element to get data from
* @return length of the element vector (for float2, float3,
* etc.)
*/
extern uint32_t __attribute__((overloadable))
rsElementGetVectorSize(rs_element e);
#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
#endif // __RS_ELEMENT_RSH__

View File

@ -0,0 +1,421 @@
/*
* Copyright (C) 2011-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_graphics.rsh
* \brief RenderScript graphics API
*
* A set of graphics functions used by RenderScript.
*
*/
#ifndef __RS_GRAPHICS_RSH__
#define __RS_GRAPHICS_RSH__
#include "rs_mesh.rsh"
#include "rs_program.rsh"
#if (defined(RS_VERSION) && (RS_VERSION >= 14))
/**
* Set the color target used for all subsequent rendering calls
* @param colorTarget
* @param slot
*/
extern void __attribute__((overloadable))
rsgBindColorTarget(rs_allocation colorTarget, uint slot);
/**
* Clear the previously set color target
* @param slot
*/
extern void __attribute__((overloadable))
rsgClearColorTarget(uint slot);
/**
* Set the depth target used for all subsequent rendering calls
* @param depthTarget
*/
extern void __attribute__((overloadable))
rsgBindDepthTarget(rs_allocation depthTarget);
/**
* Clear the previously set depth target
*/
extern void __attribute__((overloadable))
rsgClearDepthTarget(void);
/**
* Clear all color and depth targets and resume rendering into
* the framebuffer
*/
extern void __attribute__((overloadable))
rsgClearAllRenderTargets(void);
/**
* Force RenderScript to finish all rendering commands
*/
extern uint __attribute__((overloadable))
rsgFinish(void);
#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
/**
* Bind a new ProgramFragment to the rendering context.
*
* @param pf
*/
extern void __attribute__((overloadable))
rsgBindProgramFragment(rs_program_fragment pf);
/**
* Bind a new ProgramStore to the rendering context.
*
* @param ps
*/
extern void __attribute__((overloadable))
rsgBindProgramStore(rs_program_store ps);
/**
* Bind a new ProgramVertex to the rendering context.
*
* @param pv
*/
extern void __attribute__((overloadable))
rsgBindProgramVertex(rs_program_vertex pv);
/**
* Bind a new ProgramRaster to the rendering context.
*
* @param pr
*/
extern void __attribute__((overloadable))
rsgBindProgramRaster(rs_program_raster pr);
/**
* Bind a new Sampler object to a ProgramFragment. The sampler will
* operate on the texture bound at the matching slot.
*
* @param slot
*/
extern void __attribute__((overloadable))
rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
/**
* Bind a new Allocation object to a ProgramFragment. The
* Allocation must be a valid texture for the Program. The sampling
* of the texture will be controled by the Sampler bound at the
* matching slot.
*
* @param slot
*/
extern void __attribute__((overloadable))
rsgBindTexture(rs_program_fragment, uint slot, rs_allocation);
/**
* Load the projection matrix for a currently bound fixed function
* vertex program. Calling this function with a custom vertex shader
* would result in an error.
* @param proj projection matrix
*/
extern void __attribute__((overloadable))
rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *proj);
/**
* Load the model matrix for a currently bound fixed function
* vertex program. Calling this function with a custom vertex shader
* would result in an error.
* @param model model matrix
*/
extern void __attribute__((overloadable))
rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *model);
/**
* Load the texture matrix for a currently bound fixed function
* vertex program. Calling this function with a custom vertex shader
* would result in an error.
* @param tex texture matrix
*/
extern void __attribute__((overloadable))
rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *tex);
/**
* Get the projection matrix for a currently bound fixed function
* vertex program. Calling this function with a custom vertex shader
* would result in an error.
* @param proj matrix to store the current projection matrix into
*/
extern void __attribute__((overloadable))
rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *proj);
/**
* Set the constant color for a fixed function emulation program.
*
* @param pf
* @param r
* @param g
* @param b
* @param a
*/
extern void __attribute__((overloadable))
rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a);
/**
* Bind a new Allocation object to a ProgramFragment. The
* Allocation must be a valid constant input for the Program.
*
* @param ps program object
* @param slot index of the constant buffer on the program
* @param c constants to bind
*/
extern void __attribute__((overloadable))
rsgBindConstant(rs_program_fragment ps, uint slot, rs_allocation c);
/**
* Bind a new Allocation object to a ProgramVertex. The
* Allocation must be a valid constant input for the Program.
*
* @param pv program object
* @param slot index of the constant buffer on the program
* @param c constants to bind
*/
extern void __attribute__((overloadable))
rsgBindConstant(rs_program_vertex pv, uint slot, rs_allocation c);
/**
* Get the width of the current rendering surface.
*
* @return uint
*/
extern uint __attribute__((overloadable))
rsgGetWidth(void);
/**
* Get the height of the current rendering surface.
*
* @return uint
*/
extern uint __attribute__((overloadable))
rsgGetHeight(void);
/**
* Sync the contents of an allocation from its SCRIPT memory space to its HW
* memory spaces.
*
* @param alloc
*/
extern void __attribute__((overloadable))
rsgAllocationSyncAll(rs_allocation alloc);
#if (defined(RS_VERSION) && (RS_VERSION >= 14))
/**
* Sync the contents of an allocation from memory space
* specified by source.
*
* @param alloc
* @param source
*/
extern void __attribute__((overloadable))
rsgAllocationSyncAll(rs_allocation alloc,
rs_allocation_usage_type source);
#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
/**
* Low performance utility function for drawing a simple rectangle. Not
* intended for drawing large quantities of geometry.
*
* @param x1
* @param y1
* @param x2
* @param y2
* @param z
*/
extern void __attribute__((overloadable))
rsgDrawRect(float x1, float y1, float x2, float y2, float z);
/**
* Low performance utility function for drawing a simple quad. Not intended for
* drawing large quantities of geometry.
*
* @param x1
* @param y1
* @param z1
* @param x2
* @param y2
* @param z2
* @param x3
* @param y3
* @param z3
* @param x4
* @param y4
* @param z4
*/
extern void __attribute__((overloadable))
rsgDrawQuad(float x1, float y1, float z1,
float x2, float y2, float z2,
float x3, float y3, float z3,
float x4, float y4, float z4);
/**
* Low performance utility function for drawing a textured quad. Not intended
* for drawing large quantities of geometry.
*
* @param x1
* @param y1
* @param z1
* @param u1
* @param v1
* @param x2
* @param y2
* @param z2
* @param u2
* @param v2
* @param x3
* @param y3
* @param z3
* @param u3
* @param v3
* @param x4
* @param y4
* @param z4
* @param u4
* @param v4
*/
extern void __attribute__((overloadable))
rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
float x2, float y2, float z2, float u2, float v2,
float x3, float y3, float z3, float u3, float v3,
float x4, float y4, float z4, float u4, float v4);
/**
* Low performance function for drawing rectangles in screenspace. This
* function uses the default passthough ProgramVertex. Any bound ProgramVertex
* is ignored. This function has considerable overhead and should not be used
* for drawing in shipping applications.
*
* @param x
* @param y
* @param z
* @param w
* @param h
*/
extern void __attribute__((overloadable))
rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h);
extern void __attribute__((overloadable))
rsgDrawPath(rs_path p);
/**
* Draw a mesh using the current context state. The whole mesh is
* rendered.
*
* @param ism
*/
extern void __attribute__((overloadable))
rsgDrawMesh(rs_mesh ism);
/**
* Draw part of a mesh using the current context state.
* @param ism mesh object to render
* @param primitiveIndex for meshes that contain multiple primitive groups
* this parameter specifies the index of the group to draw.
*/
extern void __attribute__((overloadable))
rsgDrawMesh(rs_mesh ism, uint primitiveIndex);
/**
* Draw specified index range of part of a mesh using the current context state.
* @param ism mesh object to render
* @param primitiveIndex for meshes that contain multiple primitive groups
* this parameter specifies the index of the group to draw.
* @param start starting index in the range
* @param len number of indices to draw
*/
extern void __attribute__((overloadable))
rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len);
/**
* Clears the rendering surface to the specified color.
*
* @param r
* @param g
* @param b
* @param a
*/
extern void __attribute__((overloadable))
rsgClearColor(float r, float g, float b, float a);
/**
* Clears the depth suface to the specified value.
*/
extern void __attribute__((overloadable))
rsgClearDepth(float value);
/**
* Draws text given a string and location
*/
extern void __attribute__((overloadable))
rsgDrawText(const char *, int x, int y);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsgDrawText(rs_allocation, int x, int y);
/**
* Binds the font object to be used for all subsequent font rendering calls
* @param font object to bind
*/
extern void __attribute__((overloadable))
rsgBindFont(rs_font font);
/**
* Sets the font color for all subsequent rendering calls
* @param r red component
* @param g green component
* @param b blue component
* @param a alpha component
*/
extern void __attribute__((overloadable))
rsgFontColor(float r, float g, float b, float a);
/**
* Returns the bounding box of the text relative to (0, 0)
* Any of left, right, top, bottom could be NULL
*/
extern void __attribute__((overloadable))
rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom);
/**
* Computes an axis aligned bounding box of a mesh object
*/
extern void __attribute__((overloadable))
rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ,
float *maxX, float *maxY, float *maxZ);
/**
* \overload
*/
__inline__ static void __attribute__((overloadable, always_inline))
rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) {
float x1, y1, z1, x2, y2, z2;
rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2);
bBoxMin->x = x1;
bBoxMin->y = y1;
bBoxMin->z = z1;
bBoxMax->x = x2;
bBoxMax->y = y2;
bBoxMax->z = z2;
}
#endif

View File

@ -0,0 +1,251 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_math.rsh
* \brief todo-jsams
*
* todo-jsams
*
*/
#ifndef __RS_MATH_RSH__
#define __RS_MATH_RSH__
/**
* Return a random value between 0 (or min_value) and max_malue.
*/
extern int __attribute__((overloadable))
rsRand(int max_value);
/**
* \overload
*/
extern int __attribute__((overloadable))
rsRand(int min_value, int max_value);
/**
* \overload
*/
extern float __attribute__((overloadable))
rsRand(float max_value);
/**
* \overload
*/
extern float __attribute__((overloadable))
rsRand(float min_value, float max_value);
/**
* Returns the fractional part of a float
*/
extern float __attribute__((const, overloadable))
rsFrac(float);
/////////////////////////////////////////////////////
// int ops
/////////////////////////////////////////////////////
/**
* Clamp the value amount between low and high.
*
* @param amount The value to clamp
* @param low
* @param high
*/
_RS_RUNTIME uint __attribute__((const, overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
/**
* \overload
*/
_RS_RUNTIME int __attribute__((const, overloadable, always_inline)) rsClamp(int amount, int low, int high);
/**
* \overload
*/
_RS_RUNTIME ushort __attribute__((const, overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
/**
* \overload
*/
_RS_RUNTIME short __attribute__((const, overloadable, always_inline)) rsClamp(short amount, short low, short high);
/**
* \overload
*/
_RS_RUNTIME uchar __attribute__((const, overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
/**
* \overload
*/
_RS_RUNTIME char __attribute__((const, overloadable, always_inline)) rsClamp(char amount, char low, char high);
/**
* Computes 6 frustum planes from the view projection matrix
* @param viewProj matrix to extract planes from
* @param left plane
* @param right plane
* @param top plane
* @param bottom plane
* @param near plane
* @param far plane
*/
__inline__ static void __attribute__((overloadable, always_inline))
rsExtractFrustumPlanes(const rs_matrix4x4 *viewProj,
float4 *left, float4 *right,
float4 *top, float4 *bottom,
float4 *near, float4 *far) {
// x y z w = a b c d in the plane equation
left->x = viewProj->m[3] + viewProj->m[0];
left->y = viewProj->m[7] + viewProj->m[4];
left->z = viewProj->m[11] + viewProj->m[8];
left->w = viewProj->m[15] + viewProj->m[12];
right->x = viewProj->m[3] - viewProj->m[0];
right->y = viewProj->m[7] - viewProj->m[4];
right->z = viewProj->m[11] - viewProj->m[8];
right->w = viewProj->m[15] - viewProj->m[12];
top->x = viewProj->m[3] - viewProj->m[1];
top->y = viewProj->m[7] - viewProj->m[5];
top->z = viewProj->m[11] - viewProj->m[9];
top->w = viewProj->m[15] - viewProj->m[13];
bottom->x = viewProj->m[3] + viewProj->m[1];
bottom->y = viewProj->m[7] + viewProj->m[5];
bottom->z = viewProj->m[11] + viewProj->m[9];
bottom->w = viewProj->m[15] + viewProj->m[13];
near->x = viewProj->m[3] + viewProj->m[2];
near->y = viewProj->m[7] + viewProj->m[6];
near->z = viewProj->m[11] + viewProj->m[10];
near->w = viewProj->m[15] + viewProj->m[14];
far->x = viewProj->m[3] - viewProj->m[2];
far->y = viewProj->m[7] - viewProj->m[6];
far->z = viewProj->m[11] - viewProj->m[10];
far->w = viewProj->m[15] - viewProj->m[14];
float len = length(left->xyz);
*left /= len;
len = length(right->xyz);
*right /= len;
len = length(top->xyz);
*top /= len;
len = length(bottom->xyz);
*bottom /= len;
len = length(near->xyz);
*near /= len;
len = length(far->xyz);
*far /= len;
}
/**
* Checks if a sphere is withing the 6 frustum planes
* @param sphere float4 representing the sphere
* @param left plane
* @param right plane
* @param top plane
* @param bottom plane
* @param near plane
* @param far plane
*/
__inline__ static bool __attribute__((overloadable, always_inline))
rsIsSphereInFrustum(float4 *sphere,
float4 *left, float4 *right,
float4 *top, float4 *bottom,
float4 *near, float4 *far) {
float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(right->xyz, sphere->xyz) + right->w;
if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(top->xyz, sphere->xyz) + top->w;
if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(near->xyz, sphere->xyz) + near->w;
if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(far->xyz, sphere->xyz) + far->w;
if (distToCenter < -sphere->w) {
return false;
}
return true;
}
/**
* Pack floating point (0-1) RGB values into a uchar4. The alpha component is
* set to 255 (1.0).
*
* @param r
* @param g
* @param b
*
* @return uchar4
*/
_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsPackColorTo8888(float r, float g, float b);
/**
* Pack floating point (0-1) RGBA values into a uchar4.
*
* @param r
* @param g
* @param b
* @param a
*
* @return uchar4
*/
_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
/**
* Pack floating point (0-1) RGB values into a uchar4. The alpha component is
* set to 255 (1.0).
*
* @param color
*
* @return uchar4
*/
_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsPackColorTo8888(float3 color);
/**
* Pack floating point (0-1) RGBA values into a uchar4.
*
* @param color
*
* @return uchar4
*/
_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsPackColorTo8888(float4 color);
/**
* Unpack a uchar4 color to float4. The resulting float range will be (0-1).
*
* @param c
*
* @return float4
*/
_RS_RUNTIME float4 __attribute__((const)) rsUnpackColor8888(uchar4 c);
_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
_RS_RUNTIME float4 __attribute__((const, overloadable)) rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
#endif

View File

@ -0,0 +1,378 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_matrix.rsh
* \brief Matrix routines
*
*
*/
#ifndef __RS_MATRIX_RSH__
#define __RS_MATRIX_RSH__
/**
* Set one element of a matrix.
*
* @param m The matrix to be set
* @param row
* @param col
* @param v
*
* @return void
*/
_RS_RUNTIME void __attribute__((overloadable))
rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
/**
* \overload
*/
_RS_RUNTIME void __attribute__((overloadable))
rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
/**
* \overload
*/
_RS_RUNTIME void __attribute__((overloadable))
rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
/**
* Get one element of a matrix.
*
* @param m The matrix to read from
* @param row
* @param col
*
* @return float
*/
_RS_RUNTIME float __attribute__((overloadable))
rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
/**
* \overload
*/
_RS_RUNTIME float __attribute__((overloadable))
rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
/**
* \overload
*/
_RS_RUNTIME float __attribute__((overloadable))
rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
/**
* Set the elements of a matrix to the identity matrix.
*
* @param m
*/
extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix2x2 *m);
/**
* Set the elements of a matrix from an array of floats.
*
* @param m
*/
extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const float *v);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const float *v);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const float *v);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v);
/**
* Set the elements of a matrix from another matrix.
*
* @param m
*/
extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v);
/**
* Load a rotation matrix.
*
* @param m
* @param rot
* @param x
* @param y
* @param z
*/
extern void __attribute__((overloadable))
rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
/**
* Load a scale matrix.
*
* @param m
* @param x
* @param y
* @param z
*/
extern void __attribute__((overloadable))
rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
/**
* Load a translation matrix.
*
* @param m
* @param x
* @param y
* @param z
*/
extern void __attribute__((overloadable))
rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
/**
* Multiply two matrix (lhs, rhs) and place the result in m.
*
* @param m
* @param lhs
* @param rhs
*/
extern void __attribute__((overloadable))
rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
/**
* Multiply the matrix m by rhs and place the result back into m.
*
* @param m (lhs)
* @param rhs
*/
extern void __attribute__((overloadable))
rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
/**
* Multiple matrix m with a rotation matrix
*
* @param m
* @param rot
* @param x
* @param y
* @param z
*/
extern void __attribute__((overloadable))
rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
/**
* Multiple matrix m with a scale matrix
*
* @param m
* @param x
* @param y
* @param z
*/
extern void __attribute__((overloadable))
rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
/**
* Multiple matrix m with a translation matrix
*
* @param m
* @param x
* @param y
* @param z
*/
extern void __attribute__((overloadable))
rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
/**
* Load an Ortho projection matrix constructed from the 6 planes
*
* @param m
* @param left
* @param right
* @param bottom
* @param top
* @param near
* @param far
*/
extern void __attribute__((overloadable))
rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
/**
* Load an Frustum projection matrix constructed from the 6 planes
*
* @param m
* @param left
* @param right
* @param bottom
* @param top
* @param near
* @param far
*/
extern void __attribute__((overloadable))
rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
/**
* Load an perspective projection matrix constructed from the 6 planes
*
* @param m
* @param fovy Field of view, in degrees along the Y axis.
* @param aspect Ratio of x / y.
* @param near
* @param far
*/
extern void __attribute__((overloadable))
rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
#if !defined(RS_VERSION) || (RS_VERSION < 14)
/**
* Multiply a vector by a matrix and return the result vector.
* API version 10-13
*/
_RS_RUNTIME float4 __attribute__((overloadable))
rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
/**
* \overload
*/
_RS_RUNTIME float4 __attribute__((overloadable))
rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
/**
* \overload
*/
_RS_RUNTIME float4 __attribute__((overloadable))
rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
/**
* \overload
*/
_RS_RUNTIME float3 __attribute__((overloadable))
rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
/**
* \overload
*/
_RS_RUNTIME float3 __attribute__((overloadable))
rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
/**
* \overload
*/
_RS_RUNTIME float2 __attribute__((overloadable))
rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
#else
/**
* Multiply a vector by a matrix and return the result vector.
* API version 14+
*/
_RS_RUNTIME float4 __attribute__((overloadable))
rsMatrixMultiply(const rs_matrix4x4 *m, float4 in);
/**
* \overload
*/
_RS_RUNTIME float4 __attribute__((overloadable))
rsMatrixMultiply(const rs_matrix4x4 *m, float3 in);
/**
* \overload
*/
_RS_RUNTIME float4 __attribute__((overloadable))
rsMatrixMultiply(const rs_matrix4x4 *m, float2 in);
/**
* \overload
*/
_RS_RUNTIME float3 __attribute__((overloadable))
rsMatrixMultiply(const rs_matrix3x3 *m, float3 in);
/**
* \overload
*/
_RS_RUNTIME float3 __attribute__((overloadable))
rsMatrixMultiply(const rs_matrix3x3 *m, float2 in);
/**
* \overload
*/
_RS_RUNTIME float2 __attribute__((overloadable))
rsMatrixMultiply(const rs_matrix2x2 *m, float2 in);
#endif
/**
* Returns true if the matrix was successfully inversed
*
* @param m
*/
extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
/**
* Returns true if the matrix was successfully inversed and transposed.
*
* @param m
*/
extern bool __attribute__((overloadable)) rsMatrixInverseTranspose(rs_matrix4x4 *m);
/**
* Transpose the matrix m.
*
* @param m
*/
extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix4x4 *m);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix3x3 *m);
/**
* \overload
*/
extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
#endif

View File

@ -0,0 +1,88 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_mesh.rsh
* \brief Mesh routines
*
*
*/
#ifndef __RS_MESH_RSH__
#define __RS_MESH_RSH__
// New API's
#if (defined(RS_VERSION) && (RS_VERSION >= 16))
/**
* Returns the number of allocations in the mesh that contain
* vertex data
*
* @param m mesh to get data from
* @return number of allocations in the mesh that contain vertex
* data
*/
extern uint32_t __attribute__((overloadable))
rsgMeshGetVertexAllocationCount(rs_mesh m);
/**
* Meshes could have multiple index sets, this function returns
* the number.
*
* @param m mesh to get data from
* @return number of primitive groups in the mesh. This would
* include simple primitives as well as allocations
* containing index data
*/
extern uint32_t __attribute__((overloadable))
rsgMeshGetPrimitiveCount(rs_mesh m);
/**
* Returns an allocation that is part of the mesh and contains
* vertex data, e.g. positions, normals, texcoords
*
* @param m mesh to get data from
* @param index index of the vertex allocation
* @return allocation containing vertex data
*/
extern rs_allocation __attribute__((overloadable))
rsgMeshGetVertexAllocation(rs_mesh m, uint32_t index);
/**
* Returns an allocation containing index data or a null
* allocation if only the primitive is specified
*
* @param m mesh to get data from
* @param index index of the index allocation
* @return allocation containing index data
*/
extern rs_allocation __attribute__((overloadable))
rsgMeshGetIndexAllocation(rs_mesh m, uint32_t index);
/**
* Returns the primitive describing how a part of the mesh is
* rendered
*
* @param m mesh to get data from
* @param index index of the primitive
* @return primitive describing how the mesh is rendered
*/
extern rs_primitive __attribute__((overloadable))
rsgMeshGetPrimitive(rs_mesh m, uint32_t index);
#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
#endif // __RS_MESH_RSH__

View File

@ -0,0 +1,220 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_object.rsh
* \brief Object routines
*
*
*/
#ifndef __RS_OBJECT_RSH__
#define __RS_OBJECT_RSH__
/**
* Copy reference to the specified object.
*
* @param dst
* @param src
*/
extern void __attribute__((overloadable))
rsSetObject(rs_element *dst, rs_element src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_type *dst, rs_type src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_allocation *dst, rs_allocation src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_sampler *dst, rs_sampler src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_script *dst, rs_script src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_path *dst, rs_path src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_mesh *dst, rs_mesh src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_program_fragment *dst, rs_program_fragment src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_program_vertex *dst, rs_program_vertex src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_program_raster *dst, rs_program_raster src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_program_store *dst, rs_program_store src);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsSetObject(rs_font *dst, rs_font src);
/**
* Sets the object to NULL.
*
* @return bool
*/
extern void __attribute__((overloadable))
rsClearObject(rs_element *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_type *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_allocation *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_sampler *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_script *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_path *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_mesh *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_program_fragment *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_program_vertex *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_program_raster *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_program_store *dst);
/**
* \overload
*/
extern void __attribute__((overloadable))
rsClearObject(rs_font *dst);
/**
* Tests if the object is valid. Returns true if the object is valid, false if
* it is NULL.
*
* @return bool
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_element);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_type);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_allocation);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_sampler);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_script);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_path);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_mesh);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_program_fragment);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_program_vertex);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_program_raster);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_program_store);
/**
* \overload
*/
extern bool __attribute__((overloadable))
rsIsObject(rs_font);
#endif

View File

@ -0,0 +1,118 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_program.rsh
* \brief Program object routines
*
*
*/
#ifndef __RS_PROGRAM_RSH__
#define __RS_PROGRAM_RSH__
#if (defined(RS_VERSION) && (RS_VERSION >= 16))
/**
* Get program store depth function
*
* @param ps program store to query
*/
extern rs_depth_func __attribute__((overloadable))
rsgProgramStoreGetDepthFunc(rs_program_store ps);
/**
* Get program store depth mask
*
* @param ps program store to query
*/
extern bool __attribute__((overloadable))
rsgProgramStoreIsDepthMaskEnabled(rs_program_store ps);
/**
* Get program store red component color mask
*
* @param ps program store to query
*/
extern bool __attribute__((overloadable))
rsgProgramStoreIsColorMaskRedEnabled(rs_program_store ps);
/**
* Get program store green component color mask
*
* @param ps program store to query
*/
extern bool __attribute__((overloadable))
rsgProgramStoreIsColorMaskGreenEnabled(rs_program_store ps);
/**
* Get program store blur component color mask
*
* @param ps program store to query
*/
extern bool __attribute__((overloadable))
rsgProgramStoreIsColorMaskBlueEnabled(rs_program_store ps);
/**
* Get program store alpha component color mask
*
* @param ps program store to query
*/
extern bool __attribute__((overloadable))
rsgProgramStoreIsColorMaskAlphaEnabled(rs_program_store ps);
/**
* Get program store blend source function
*
* @param ps program store to query
*/
extern rs_blend_src_func __attribute__((overloadable))
rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
/**
* Get program store blend destination function
*
* @param ps program store to query
*/
extern rs_blend_dst_func __attribute__((overloadable))
rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
/**
* Get program store dither state
*
* @param ps program store to query
*/
extern bool __attribute__((overloadable))
rsgProgramStoreIsDitherEnabled(rs_program_store ps);
/**
* Get program raster point sprite state
*
* @param pr program raster to query
*/
extern bool __attribute__((overloadable))
rsgProgramRasterIsPointSpriteEnabled(rs_program_raster pr);
/**
* Get program raster cull mode
*
* @param pr program raster to query
*/
extern rs_cull_mode __attribute__((overloadable))
rsgProgramRasterGetCullMode(rs_program_raster pr);
#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
#endif // __RS_PROGRAM_RSH__

View File

@ -0,0 +1,253 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_quaternion.rsh
* \brief Quaternion routines
*
*
*/
#ifndef __RS_QUATERNION_RSH__
#define __RS_QUATERNION_RSH__
/**
* Set the quaternion components
* @param w component
* @param x component
* @param y component
* @param z component
*/
static void __attribute__((overloadable))
rsQuaternionSet(rs_quaternion *q, float w, float x, float y, float z) {
q->w = w;
q->x = x;
q->y = y;
q->z = z;
}
/**
* Set the quaternion from another quaternion
* @param q destination quaternion
* @param rhs source quaternion
*/
static void __attribute__((overloadable))
rsQuaternionSet(rs_quaternion *q, const rs_quaternion *rhs) {
q->w = rhs->w;
q->x = rhs->x;
q->y = rhs->y;
q->z = rhs->z;
}
/**
* Multiply quaternion by a scalar
* @param q quaternion to multiply
* @param s scalar
*/
static void __attribute__((overloadable))
rsQuaternionMultiply(rs_quaternion *q, float s) {
q->w *= s;
q->x *= s;
q->y *= s;
q->z *= s;
}
/**
* Add two quaternions
* @param q destination quaternion to add to
* @param rsh right hand side quaternion to add
*/
static void
rsQuaternionAdd(rs_quaternion *q, const rs_quaternion *rhs) {
q->w *= rhs->w;
q->x *= rhs->x;
q->y *= rhs->y;
q->z *= rhs->z;
}
/**
* Loads a quaternion that represents a rotation about an arbitrary unit vector
* @param q quaternion to set
* @param rot angle to rotate by
* @param x component of a vector
* @param y component of a vector
* @param x component of a vector
*/
static void
rsQuaternionLoadRotateUnit(rs_quaternion *q, float rot, float x, float y, float z) {
rot *= (float)(M_PI / 180.0f) * 0.5f;
float c = cos(rot);
float s = sin(rot);
q->w = c;
q->x = x * s;
q->y = y * s;
q->z = z * s;
}
/**
* Loads a quaternion that represents a rotation about an arbitrary vector
* (doesn't have to be unit)
* @param q quaternion to set
* @param rot angle to rotate by
* @param x component of a vector
* @param y component of a vector
* @param x component of a vector
*/
static void
rsQuaternionLoadRotate(rs_quaternion *q, float rot, float x, float y, float z) {
const float len = x*x + y*y + z*z;
if (len != 1) {
const float recipLen = 1.f / sqrt(len);
x *= recipLen;
y *= recipLen;
z *= recipLen;
}
rsQuaternionLoadRotateUnit(q, rot, x, y, z);
}
/**
* Conjugates the quaternion
* @param q quaternion to conjugate
*/
static void
rsQuaternionConjugate(rs_quaternion *q) {
q->x = -q->x;
q->y = -q->y;
q->z = -q->z;
}
/**
* Dot product of two quaternions
* @param q0 first quaternion
* @param q1 second quaternion
* @return dot product between q0 and q1
*/
static float
rsQuaternionDot(const rs_quaternion *q0, const rs_quaternion *q1) {
return q0->w*q1->w + q0->x*q1->x + q0->y*q1->y + q0->z*q1->z;
}
/**
* Normalizes the quaternion
* @param q quaternion to normalize
*/
static void
rsQuaternionNormalize(rs_quaternion *q) {
const float len = rsQuaternionDot(q, q);
if (len != 1) {
const float recipLen = 1.f / sqrt(len);
rsQuaternionMultiply(q, recipLen);
}
}
/**
* Multiply quaternion by another quaternion
* @param q destination quaternion
* @param rhs right hand side quaternion to multiply by
*/
static void __attribute__((overloadable))
rsQuaternionMultiply(rs_quaternion *q, const rs_quaternion *rhs) {
rs_quaternion qtmp;
rsQuaternionSet(&qtmp, q);
q->w = qtmp.w*rhs->w - qtmp.x*rhs->x - qtmp.y*rhs->y - qtmp.z*rhs->z;
q->x = qtmp.w*rhs->x + qtmp.x*rhs->w + qtmp.y*rhs->z - qtmp.z*rhs->y;
q->y = qtmp.w*rhs->y + qtmp.y*rhs->w + qtmp.z*rhs->x - qtmp.x*rhs->z;
q->z = qtmp.w*rhs->z + qtmp.z*rhs->w + qtmp.x*rhs->y - qtmp.y*rhs->x;
rsQuaternionNormalize(q);
}
/**
* Performs spherical linear interpolation between two quaternions
* @param q result quaternion from interpolation
* @param q0 first param
* @param q1 second param
* @param t how much to interpolate by
*/
static void
rsQuaternionSlerp(rs_quaternion *q, const rs_quaternion *q0, const rs_quaternion *q1, float t) {
if (t <= 0.0f) {
rsQuaternionSet(q, q0);
return;
}
if (t >= 1.0f) {
rsQuaternionSet(q, q1);
return;
}
rs_quaternion tempq0, tempq1;
rsQuaternionSet(&tempq0, q0);
rsQuaternionSet(&tempq1, q1);
float angle = rsQuaternionDot(q0, q1);
if (angle < 0) {
rsQuaternionMultiply(&tempq0, -1.0f);
angle *= -1.0f;
}
float scale, invScale;
if (angle + 1.0f > 0.05f) {
if (1.0f - angle >= 0.05f) {
float theta = acos(angle);
float invSinTheta = 1.0f / sin(theta);
scale = sin(theta * (1.0f - t)) * invSinTheta;
invScale = sin(theta * t) * invSinTheta;
} else {
scale = 1.0f - t;
invScale = t;
}
} else {
rsQuaternionSet(&tempq1, tempq0.z, -tempq0.y, tempq0.x, -tempq0.w);
scale = sin(M_PI * (0.5f - t));
invScale = sin(M_PI * t);
}
rsQuaternionSet(q, tempq0.w*scale + tempq1.w*invScale, tempq0.x*scale + tempq1.x*invScale,
tempq0.y*scale + tempq1.y*invScale, tempq0.z*scale + tempq1.z*invScale);
}
/**
* Computes rotation matrix from the normalized quaternion
* @param m resulting matrix
* @param p normalized quaternion
*/
static void rsQuaternionGetMatrixUnit(rs_matrix4x4 *m, const rs_quaternion *q) {
float xx = q->x * q->x;
float xy = q->x * q->y;
float xz = q->x * q->z;
float xw = q->x * q->w;
float yy = q->y * q->y;
float yz = q->y * q->z;
float yw = q->y * q->w;
float zz = q->z * q->z;
float zw = q->z * q->w;
m->m[0] = 1.0f - 2.0f * ( yy + zz );
m->m[4] = 2.0f * ( xy - zw );
m->m[8] = 2.0f * ( xz + yw );
m->m[1] = 2.0f * ( xy + zw );
m->m[5] = 1.0f - 2.0f * ( xx + zz );
m->m[9] = 2.0f * ( yz - xw );
m->m[2] = 2.0f * ( xz - yw );
m->m[6] = 2.0f * ( yz + xw );
m->m[10] = 1.0f - 2.0f * ( xx + yy );
m->m[3] = m->m[7] = m->m[11] = m->m[12] = m->m[13] = m->m[14] = 0.0f;
m->m[15] = 1.0f;
}
#endif

View File

@ -0,0 +1,77 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_sampler.rsh
* \brief Sampler routines
*
*
*/
#ifndef __RS_SAMPLER_RSH__
#define __RS_SAMPLER_RSH__
// New API's
#if (defined(RS_VERSION) && (RS_VERSION >= 16))
/**
* Get sampler minification value
*
* @param s sampler to query
* @return minification value
*/
extern rs_sampler_value __attribute__((overloadable))
rsSamplerGetMinification(rs_sampler s);
/**
* Get sampler magnification value
*
* @param s sampler to query
* @return magnification value
*/
extern rs_sampler_value __attribute__((overloadable))
rsSamplerGetMagnification(rs_sampler s);
/**
* Get sampler wrap S value
*
* @param s sampler to query
* @return wrap S value
*/
extern rs_sampler_value __attribute__((overloadable))
rsSamplerGetWrapS(rs_sampler s);
/**
* Get sampler wrap T value
*
* @param s sampler to query
* @return wrap T value
*/
extern rs_sampler_value __attribute__((overloadable))
rsSamplerGetWrapT(rs_sampler s);
/**
Get sampler anisotropy
*
* @param s sampler to query
* @return anisotropy
*/
extern float __attribute__((overloadable))
rsSamplerGetAnisotropy(rs_sampler s);
#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
#endif // __RS_SAMPLER_RSH__

View File

@ -0,0 +1,111 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_time.rsh
* \brief RenderScript time routines
*
* This file contains RenderScript functions relating to time and date
* manipulation.
*/
#ifndef __RS_TIME_RSH__
#define __RS_TIME_RSH__
/**
* Calendar time interpreted as seconds elapsed since the Epoch (00:00:00 on
* January 1, 1970, Coordinated Universal Time (UTC)).
*/
typedef int rs_time_t;
/**
* Data structure for broken-down time components.
*
* tm_sec - Seconds after the minute. This ranges from 0 to 59, but possibly
* up to 60 for leap seconds.
* tm_min - Minutes after the hour. This ranges from 0 to 59.
* tm_hour - Hours past midnight. This ranges from 0 to 23.
* tm_mday - Day of the month. This ranges from 1 to 31.
* tm_mon - Months since January. This ranges from 0 to 11.
* tm_year - Years since 1900.
* tm_wday - Days since Sunday. This ranges from 0 to 6.
* tm_yday - Days since January 1. This ranges from 0 to 365.
* tm_isdst - Flag to indicate whether daylight saving time is in effect. The
* value is positive if it is in effect, zero if it is not, and
* negative if the information is not available.
*/
typedef struct {
int tm_sec; ///< seconds
int tm_min; ///< minutes
int tm_hour; ///< hours
int tm_mday; ///< day of the month
int tm_mon; ///< month
int tm_year; ///< year
int tm_wday; ///< day of the week
int tm_yday; ///< day of the year
int tm_isdst; ///< daylight savings time
} rs_tm;
/**
* Returns the number of seconds since the Epoch (00:00:00 UTC, January 1,
* 1970). If @p timer is non-NULL, the result is also stored in the memory
* pointed to by this variable. If an error occurs, a value of -1 is returned.
*
* @param timer Location to also store the returned calendar time.
*
* @return Seconds since the Epoch.
*/
extern rs_time_t __attribute__((overloadable))
rsTime(rs_time_t *timer);
/**
* Converts the time specified by @p timer into broken-down time and stores it
* in @p local. This function also returns a pointer to @p local. If @p local
* is NULL, this function does nothing and returns NULL.
*
* @param local Broken-down time.
* @param timer Input time as calendar time.
*
* @return Pointer to broken-down time (same as input @p local).
*/
extern rs_tm * __attribute__((overloadable))
rsLocaltime(rs_tm *local, const rs_time_t *timer);
/**
* Returns the current system clock (uptime) in milliseconds.
*
* @return Uptime in milliseconds.
*/
extern int64_t __attribute__((overloadable))
rsUptimeMillis(void);
/**
* Returns the current system clock (uptime) in nanoseconds.
*
* @return Uptime in nanoseconds.
*/
extern int64_t __attribute__((overloadable))
rsUptimeNanos(void);
/**
* Returns the time in seconds since this function was last called in this
* script.
*
* @return Time in seconds.
*/
extern float __attribute__((overloadable))
rsGetDt(void);
#endif

View File

@ -0,0 +1,628 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file rs_types.rsh
*
* Define the standard RenderScript types
*
* Integers
* 8 bit: char, int8_t
* 16 bit: short, int16_t
* 32 bit: int, in32_t
* 64 bit: long, long long, int64_t
*
* Unsigned Integers
* 8 bit: uchar, uint8_t
* 16 bit: ushort, uint16_t
* 32 bit: uint, uint32_t
* 64 bit: ulong, uint64_t
*
* Floating point
* 32 bit: float
* 64 bit: double
*
* Vectors of length 2, 3, and 4 are supported for all the types above.
*
*/
#ifndef __RS_TYPES_RSH__
#define __RS_TYPES_RSH__
/* Constants */
#define M_E 2.718281828459045235360287471352662498f /* e */
#define M_LOG2E 1.442695040888963407359924681001892137f /* log_2 e */
#define M_LOG10E 0.434294481903251827651128918916605082f /* log_10 e */
#define M_LN2 0.693147180559945309417232121458176568f /* log_e 2 */
#define M_LN10 2.302585092994045684017991454684364208f /* log_e 10 */
#define M_PI 3.141592653589793238462643383279502884f /* pi */
#define M_PI_2 1.570796326794896619231321691639751442f /* pi/2 */
#define M_PI_4 0.785398163397448309615660845819875721f /* pi/4 */
#define M_1_PI 0.318309886183790671537767526745028724f /* 1/pi */
#define M_2_PIl 0.636619772367581343075535053490057448f /* 2/pi */
#define M_2_SQRTPI 1.128379167095512573896158903121545172f /* 2/sqrt(pi) */
#define M_SQRT2 1.414213562373095048801688724209698079f /* sqrt(2) */
#define M_SQRT1_2 0.707106781186547524400844362104849039f /* 1/sqrt(2) */
#include "stdbool.h"
/**
* 8 bit integer type
*/
typedef char int8_t;
/**
* 16 bit integer type
*/
typedef short int16_t;
/**
* 32 bit integer type
*/
typedef int int32_t;
/**
* 64 bit integer type
*/
typedef long long int64_t;
/**
* 8 bit unsigned integer type
*/
typedef unsigned char uint8_t;
/**
* 16 bit unsigned integer type
*/
typedef unsigned short uint16_t;
/**
* 32 bit unsigned integer type
*/
typedef unsigned int uint32_t;
/**
* 64 bit unsigned integer type
*/
typedef unsigned long long uint64_t;
/**
* 8 bit unsigned integer type
*/
typedef uint8_t uchar;
/**
* 16 bit unsigned integer type
*/
typedef uint16_t ushort;
/**
* 32 bit unsigned integer type
*/
typedef uint32_t uint;
/**
* Typedef for unsigned long (use for 64-bit unsigned integers)
*/
typedef uint64_t ulong;
/**
* Typedef for unsigned int
*/
typedef uint32_t size_t;
/**
* Typedef for int (use for 32-bit integers)
*/
typedef int32_t ssize_t;
/**
* \brief Opaque handle to a RenderScript element.
*
* See: android.renderscript.Element
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_element;
/**
* \brief Opaque handle to a RenderScript type.
*
* See: android.renderscript.Type
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_type;
/**
* \brief Opaque handle to a RenderScript allocation.
*
* See: android.renderscript.Allocation
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_allocation;
/**
* \brief Opaque handle to a RenderScript sampler object.
*
* See: android.renderscript.Sampler
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_sampler;
/**
* \brief Opaque handle to a RenderScript script object.
*
* See: android.renderscript.ScriptC
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_script;
/**
* \brief Opaque handle to a RenderScript mesh object.
*
* See: android.renderscript.Mesh
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_mesh;
/**
* \brief Opaque handle to a RenderScript Path object.
*
* See: android.renderscript.Path
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_path;
/**
* \brief Opaque handle to a RenderScript ProgramFragment object.
*
* See: android.renderscript.ProgramFragment
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_fragment;
/**
* \brief Opaque handle to a RenderScript ProgramVertex object.
*
* See: android.renderscript.ProgramVertex
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_vertex;
/**
* \brief Opaque handle to a RenderScript ProgramRaster object.
*
* See: android.renderscript.ProgramRaster
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_raster;
/**
* \brief Opaque handle to a RenderScript ProgramStore object.
*
* See: android.renderscript.ProgramStore
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_store;
/**
* \brief Opaque handle to a RenderScript font object.
*
* See: android.renderscript.Font
*/
typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_font;
/**
* Vector version of the basic float type.
* Provides two float fields packed into a single 64 bit field with 64 bit
* alignment.
*/
typedef float float2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic float type. Provides three float fields packed
* into a single 128 bit field with 128 bit alignment.
*/
typedef float float3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic float type.
* Provides four float fields packed into a single 128 bit field with 128 bit
* alignment.
*/
typedef float float4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic double type. Provides two double fields packed
* into a single 128 bit field with 128 bit alignment.
*/
typedef double double2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic double type. Provides three double fields packed
* into a single 256 bit field with 256 bit alignment.
*/
typedef double double3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic double type. Provides four double fields packed
* into a single 256 bit field with 256 bit alignment.
*/
typedef double double4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic uchar type. Provides two uchar fields packed
* into a single 16 bit field with 16 bit alignment.
*/
typedef uchar uchar2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic uchar type. Provides three uchar fields packed
* into a single 32 bit field with 32 bit alignment.
*/
typedef uchar uchar3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic uchar type. Provides four uchar fields packed
* into a single 32 bit field with 32 bit alignment.
*/
typedef uchar uchar4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic ushort type. Provides two ushort fields packed
* into a single 32 bit field with 32 bit alignment.
*/
typedef ushort ushort2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic ushort type. Provides three ushort fields packed
* into a single 64 bit field with 64 bit alignment.
*/
typedef ushort ushort3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic ushort type. Provides four ushort fields packed
* into a single 64 bit field with 64 bit alignment.
*/
typedef ushort ushort4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic uint type. Provides two uint fields packed into a
* single 64 bit field with 64 bit alignment.
*/
typedef uint uint2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic uint type. Provides three uint fields packed into
* a single 128 bit field with 128 bit alignment.
*/
typedef uint uint3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic uint type. Provides four uint fields packed into
* a single 128 bit field with 128 bit alignment.
*/
typedef uint uint4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic ulong type. Provides two ulong fields packed into
* a single 128 bit field with 128 bit alignment.
*/
typedef ulong ulong2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic ulong type. Provides three ulong fields packed
* into a single 256 bit field with 256 bit alignment.
*/
typedef ulong ulong3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic ulong type. Provides four ulong fields packed
* into a single 256 bit field with 256 bit alignment.
*/
typedef ulong ulong4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic char type. Provides two char fields packed into a
* single 16 bit field with 16 bit alignment.
*/
typedef char char2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic char type. Provides three char fields packed into
* a single 32 bit field with 32 bit alignment.
*/
typedef char char3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic char type. Provides four char fields packed into
* a single 32 bit field with 32 bit alignment.
*/
typedef char char4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic short type. Provides two short fields packed into
* a single 32 bit field with 32 bit alignment.
*/
typedef short short2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic short type. Provides three short fields packed
* into a single 64 bit field with 64 bit alignment.
*/
typedef short short3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic short type. Provides four short fields packed
* into a single 64 bit field with 64 bit alignment.
*/
typedef short short4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic int type. Provides two int fields packed into a
* single 64 bit field with 64 bit alignment.
*/
typedef int int2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic int type. Provides three int fields packed into a
* single 128 bit field with 128 bit alignment.
*/
typedef int int3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic int type. Provides two four fields packed into a
* single 128 bit field with 128 bit alignment.
*/
typedef int int4 __attribute__((ext_vector_type(4)));
/**
* Vector version of the basic long type. Provides two long fields packed into a
* single 128 bit field with 128 bit alignment.
*/
typedef long long2 __attribute__((ext_vector_type(2)));
/**
* Vector version of the basic long type. Provides three long fields packed into
* a single 256 bit field with 256 bit alignment.
*/
typedef long long3 __attribute__((ext_vector_type(3)));
/**
* Vector version of the basic long type. Provides four long fields packed into
* a single 256 bit field with 256 bit alignment.
*/
typedef long long4 __attribute__((ext_vector_type(4)));
/**
* \brief 4x4 float matrix
*
* Native holder for RS matrix. Elements are stored in the array at the
* location [row*4 + col]
*/
typedef struct {
float m[16];
} rs_matrix4x4;
/**
* \brief 3x3 float matrix
*
* Native holder for RS matrix. Elements are stored in the array at the
* location [row*3 + col]
*/
typedef struct {
float m[9];
} rs_matrix3x3;
/**
* \brief 2x2 float matrix
*
* Native holder for RS matrix. Elements are stored in the array at the
* location [row*2 + col]
*/
typedef struct {
float m[4];
} rs_matrix2x2;
/**
* quaternion type for use with the quaternion functions
*/
typedef float4 rs_quaternion;
#define RS_PACKED __attribute__((packed, aligned(4)))
#define NULL ((void *)0)
#if (defined(RS_VERSION) && (RS_VERSION >= 14))
/**
* \brief Enum for selecting cube map faces
*/
typedef enum {
RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
} rs_allocation_cubemap_face;
/**
* \brief Bitfield to specify the usage types for an allocation.
*
* These values are ORed together to specify which usages or memory spaces are
* relevant to an allocation or an operation on an allocation.
*/
typedef enum {
RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010
} rs_allocation_usage_type;
#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
// New API's
#if (defined(RS_VERSION) && (RS_VERSION >= 16))
/**
* Describes the way mesh vertex data is interpreted when rendering
*
**/
typedef enum {
/**
* Vertex data will be rendered as a series of points
*/
RS_PRIMITIVE_POINT = 0,
/**
* Vertex pairs will be rendered as lines
*/
RS_PRIMITIVE_LINE = 1,
/**
* Vertex data will be rendered as a connected line strip
*/
RS_PRIMITIVE_LINE_STRIP = 2,
/**
* Vertices will be rendered as individual triangles
*/
RS_PRIMITIVE_TRIANGLE = 3,
/**
* Vertices will be rendered as a connected triangle strip
* defined by the first three vertices with each additional
* triangle defined by a new vertex
*/
RS_PRIMITIVE_TRIANGLE_STRIP = 4,
/**
* Vertices will be rendered as a sequence of triangles that all
* share first vertex as the origin
*/
RS_PRIMITIVE_TRIANGLE_FAN = 5,
/**
* Invalid primitive
*/
RS_PRIMITIVE_INVALID = 100,
} rs_primitive;
/**
* \brief Enumeration for possible element data types
*
* DataType represents the basic type information for a basic element. The
* naming convention follows. For numeric types it is FLOAT,
* SIGNED, or UNSIGNED followed by the _BITS where BITS is the
* size of the data. BOOLEAN is a true / false (1,0)
* represented in an 8 bit container. The UNSIGNED variants
* with multiple bit definitions are for packed graphical data
* formats and represent vectors with per vector member sizes
* which are treated as a single unit for packing and alignment
* purposes.
*
* MATRIX the three matrix types contain FLOAT_32 elements and are treated
* as 32 bits for alignment purposes.
*
* RS_* objects. 32 bit opaque handles.
*/
typedef enum {
RS_TYPE_NONE = 0,
RS_TYPE_FLOAT_32 = 2,
RS_TYPE_FLOAT_64 = 3,
RS_TYPE_SIGNED_8 = 4,
RS_TYPE_SIGNED_16 = 5,
RS_TYPE_SIGNED_32 = 6,
RS_TYPE_SIGNED_64 = 7,
RS_TYPE_UNSIGNED_8 = 8,
RS_TYPE_UNSIGNED_16 = 9,
RS_TYPE_UNSIGNED_32 = 10,
RS_TYPE_UNSIGNED_64 = 11,
RS_TYPE_BOOLEAN = 12,
RS_TYPE_UNSIGNED_5_6_5 = 13,
RS_TYPE_UNSIGNED_5_5_5_1 = 14,
RS_TYPE_UNSIGNED_4_4_4_4 = 15,
RS_TYPE_MATRIX_4X4 = 16,
RS_TYPE_MATRIX_3X3 = 17,
RS_TYPE_MATRIX_2X2 = 18,
RS_TYPE_ELEMENT = 1000,
RS_TYPE_TYPE = 1001,
RS_TYPE_ALLOCATION = 1002,
RS_TYPE_SAMPLER = 1003,
RS_TYPE_SCRIPT = 1004,
RS_TYPE_MESH = 1005,
RS_TYPE_PROGRAM_FRAGMENT = 1006,
RS_TYPE_PROGRAM_VERTEX = 1007,
RS_TYPE_PROGRAM_RASTER = 1008,
RS_TYPE_PROGRAM_STORE = 1009,
RS_TYPE_FONT = 1010,
RS_TYPE_INVALID = 10000,
} rs_data_type;
/**
* \brief Enumeration for possible element data kind
*
* The special interpretation of the data if required. This is primarly
* useful for graphical data. USER indicates no special interpretation is
* expected. PIXEL is used in conjunction with the standard data types for
* representing texture formats.
*/
typedef enum {
RS_KIND_USER = 0,
RS_KIND_PIXEL_L = 7,
RS_KIND_PIXEL_A = 8,
RS_KIND_PIXEL_LA = 9,
RS_KIND_PIXEL_RGB = 10,
RS_KIND_PIXEL_RGBA = 11,
RS_KIND_PIXEL_DEPTH = 12,
RS_KIND_PIXEL_YUV = 13,
RS_KIND_INVALID = 100,
} rs_data_kind;
typedef enum {
/**
* Always drawn
*/
RS_DEPTH_FUNC_ALWAYS = 0,
/**
* Drawn if the incoming depth value is less than that in the
* depth buffer
*/
RS_DEPTH_FUNC_LESS = 1,
/**
* Drawn if the incoming depth value is less or equal to that in
* the depth buffer
*/
RS_DEPTH_FUNC_LEQUAL = 2,
/**
* Drawn if the incoming depth value is greater than that in the
* depth buffer
*/
RS_DEPTH_FUNC_GREATER = 3,
/**
* Drawn if the incoming depth value is greater or equal to that
* in the depth buffer
*/
RS_DEPTH_FUNC_GEQUAL = 4,
/**
* Drawn if the incoming depth value is equal to that in the
* depth buffer
*/
RS_DEPTH_FUNC_EQUAL = 5,
/**
* Drawn if the incoming depth value is not equal to that in the
* depth buffer
*/
RS_DEPTH_FUNC_NOTEQUAL = 6,
/**
* Invalid depth function
*/
RS_DEPTH_FUNC_INVALID = 100,
} rs_depth_func;
typedef enum {
RS_BLEND_SRC_ZERO = 0,
RS_BLEND_SRC_ONE = 1,
RS_BLEND_SRC_DST_COLOR = 2,
RS_BLEND_SRC_ONE_MINUS_DST_COLOR = 3,
RS_BLEND_SRC_SRC_ALPHA = 4,
RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA = 5,
RS_BLEND_SRC_DST_ALPHA = 6,
RS_BLEND_SRC_ONE_MINUS_DST_ALPHA = 7,
RS_BLEND_SRC_SRC_ALPHA_SATURATE = 8,
RS_BLEND_SRC_INVALID = 100,
} rs_blend_src_func;
typedef enum {
RS_BLEND_DST_ZERO = 0,
RS_BLEND_DST_ONE = 1,
RS_BLEND_DST_SRC_COLOR = 2,
RS_BLEND_DST_ONE_MINUS_SRC_COLOR = 3,
RS_BLEND_DST_SRC_ALPHA = 4,
RS_BLEND_DST_ONE_MINUS_SRC_ALPHA = 5,
RS_BLEND_DST_DST_ALPHA = 6,
RS_BLEND_DST_ONE_MINUS_DST_ALPHA = 7,
RS_BLEND_DST_INVALID = 100,
} rs_blend_dst_func;
typedef enum {
RS_CULL_BACK = 0,
RS_CULL_FRONT = 1,
RS_CULL_NONE = 2,
RS_CULL_INVALID = 100,
} rs_cull_mode;
typedef enum {
RS_SAMPLER_NEAREST = 0,
RS_SAMPLER_LINEAR = 1,
RS_SAMPLER_LINEAR_MIP_LINEAR = 2,
RS_SAMPLER_WRAP = 3,
RS_SAMPLER_CLAMP = 4,
RS_SAMPLER_LINEAR_MIP_NEAREST = 5,
RS_SAMPLER_MIRRORED_REPEAT = 6,
RS_SAMPLER_INVALID = 100,
} rs_sampler_value;
#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
#endif // __RS_TYPES_RSH__