rs_math.rsh revision 22fa371bf64b8aae786acfe5d711af21afb13a93
122fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams#include "rs_cl.rsh"
2717e34a50d2de026b5b66b4ccad06b7bc8b62b9eJason Sams
3be36bf3a76481737a7fa606a04144ceef80eb4f2Jason Sams
422fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams// Allocations
5ce92d4baf7a5bce097228fdd4498601764cd4014Jason Samsextern rs_allocation rsGetAllocation(const void *);
622fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uint32_t rsAllocationGetDimX(rs_allocation);
722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uint32_t rsAllocationGetDimY(rs_allocation);
822fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uint32_t rsAllocationGetDimZ(rs_allocation);
922fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uint32_t rsAllocationGetDimLOD(rs_allocation);
1022fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uint32_t rsAllocationGetDimFaces(rs_allocation);
1122fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
1222fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
1322fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
1422fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams// Color conversion
1522fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
1622fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
1722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3);
1822fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4);
1922fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float4 rsUnpackColor8888(uchar4);
2022fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
2122fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uchar4 __attribute__((overloadable)) rsPackColorTo565(float r, float g, float b);
2222fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern uchar4 __attribute__((overloadable)) rsPackColorTo565(float3);
2322fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float4 rsUnpackColor565(uchar4);
2422fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
2522fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
2622fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams// Debugging
2722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void __attribute__((overloadable))rsDebug(const char *, float);
2822fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void __attribute__((overloadable))rsDebug(const char *, float2);
2922fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void __attribute__((overloadable))rsDebug(const char *, float3);
3022fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void __attribute__((overloadable))rsDebug(const char *, float4);
3122fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void __attribute__((overloadable))rsDebug(const char *, int);
3222fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void __attribute__((overloadable))rsDebug(const char *, const void *);
3322fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams#define RS_DEBUG(a) rsDebug(#a, a)
3422fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
3522fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
3622fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams// RS Math
3722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int __attribute__((overloadable)) rsRand(int);
3822fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int __attribute__((overloadable)) rsRand(int, int);
3922fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float __attribute__((overloadable)) rsRand(float);
4022fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float __attribute__((overloadable)) rsRand(float, float);
4122fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
4222fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float __attribute__((overloadable)) rsFrac(float);
4322fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
4422fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams// time
4522fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int32_t rsSecond();
4622fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int32_t rsMinute();
4722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int32_t rsHour();
4822fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int32_t rsDay();
4922fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int32_t rsMonth();
5022fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int32_t rsYear();
5122fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int64_t rsUptimeMillis();
5222fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int64_t rsStartTimeMillis();
5322fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int64_t rsElapsedTimeMillis();
5422fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
5522fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern int rsSendToClient(void *data, int cmdID, int len, int waitForSpace);
5622fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
5722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixLoadIdentity(rs_matrix4x4 *mat);
5822fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixLoadFloat(rs_matrix4x4 *mat, const float *f);
5922fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixLoadMat(rs_matrix4x4 *mat, const rs_matrix4x4 *newmat);
6022fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixLoadRotate(rs_matrix4x4 *mat, float rot, float x, float y, float z);
6122fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixLoadScale(rs_matrix4x4*mat, float x, float y, float z);
6222fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixLoadTranslate(rs_matrix4x4 *mat, float x, float y, float z);
6322fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixLoadMultiply(rs_matrix4x4 *mat, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
6422fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixMultiply(rs_matrix4x4 *mat, const rs_matrix4x4 *rhs);
6522fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixRotate(rs_matrix4x4 *mat, float rot, float x, float y, float z);
6622fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixScale(rs_matrix4x4 *mat, float x, float y, float z);
6722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern void rsMatrixTranslate(rs_matrix4x4 *mat, float x, float y, float z);
6822fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
6922fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
7022fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams///////////////////////////////////////////////////////////////////
7122fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams// non update funcs
7222fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
7322fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float turbulencef2(float x, float y, float octaves);
7422fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float turbulencef3(float x, float y, float z, float octaves);
7522fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
7622fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams/*
7722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float3 float3Norm(float3);
7822fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float float3Length(float3);
7922fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float3 float3Add(float3 lhs, float3 rhs);
8022fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float3 float3Sub(float3 lhs, float3 rhs);
8122fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float3 float3Cross(float3 lhs, float3 rhs);
8222fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float float3Dot(float3 lhs, float3 rhs);
8322fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float3 float3Scale(float3 v, float scale);
8422fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
8522fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float4 float4Add(float4 lhs, float4 rhs);
8622fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float4 float4Sub(float4 lhs, float4 rhs);
8722fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float4 float4Cross(float4 lhs, float4 rhs);
8822fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float float4Dot(float4 lhs, float4 rhs);
8922fa371bf64b8aae786acfe5d711af21afb13a93Jason Samsextern float4 float4Scale(float4 v, float scale);
9022fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams*/
9122fa371bf64b8aae786acfe5d711af21afb13a93Jason Sams
92717e34a50d2de026b5b66b4ccad06b7bc8b62b9eJason Sams
93