Jason Sams | c4cdf45 | 2010-07-07 11:55:51 -0700 | [diff] [blame] | 1 | #ifndef __RS_MATH_RSH__ |
| 2 | #define __RS_MATH_RSH__ |
| 3 | |
Jason Sams | 7dce6bc | 2010-08-06 16:22:50 -0700 | [diff] [blame^] | 4 | // Debugging, print to the LOG a description string and a value. |
| 5 | extern void __attribute__((overloadable)) |
| 6 | rsDebug(const char *, float); |
| 7 | extern void __attribute__((overloadable)) |
| 8 | rsDebug(const char *, float, float); |
| 9 | extern void __attribute__((overloadable)) |
| 10 | rsDebug(const char *, float, float, float); |
| 11 | extern void __attribute__((overloadable)) |
| 12 | rsDebug(const char *, float, float, float, float); |
| 13 | extern void __attribute__((overloadable)) |
| 14 | rsDebug(const char *, const rs_matrix4x4 *); |
| 15 | extern void __attribute__((overloadable)) |
| 16 | rsDebug(const char *, const rs_matrix3x3 *); |
| 17 | extern void __attribute__((overloadable)) |
| 18 | rsDebug(const char *, const rs_matrix2x2 *); |
| 19 | extern void __attribute__((overloadable)) |
| 20 | rsDebug(const char *, int); |
| 21 | extern void __attribute__((overloadable)) |
| 22 | rsDebug(const char *, uint); |
| 23 | extern void __attribute__((overloadable)) |
| 24 | rsDebug(const char *, const void *); |
| 25 | #define RS_DEBUG(a) rsDebug(#a, a) |
| 26 | #define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__) |
| 27 | |
| 28 | |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 29 | #include "rs_cl.rsh" |
Jason Sams | 275b1e9 | 2010-05-28 18:08:16 -0700 | [diff] [blame] | 30 | #include "rs_core.rsh" |
| 31 | |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 32 | // Allocations |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 33 | |
| 34 | // Return the rs_allocation associated with a bound data |
| 35 | // pointer. |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 36 | extern rs_allocation __attribute__((overloadable)) |
| 37 | rsGetAllocation(const void *); |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 38 | |
| 39 | // Return the dimensions associated with an allocation. |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 40 | extern uint32_t __attribute__((overloadable)) |
| 41 | rsAllocationGetDimX(rs_allocation); |
| 42 | extern uint32_t __attribute__((overloadable)) |
| 43 | rsAllocationGetDimY(rs_allocation); |
| 44 | extern uint32_t __attribute__((overloadable)) |
| 45 | rsAllocationGetDimZ(rs_allocation); |
| 46 | extern uint32_t __attribute__((overloadable)) |
| 47 | rsAllocationGetDimLOD(rs_allocation); |
| 48 | extern uint32_t __attribute__((overloadable)) |
| 49 | rsAllocationGetDimFaces(rs_allocation); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 50 | |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 51 | // Extract a single element from an allocation. |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 52 | extern const void * __attribute__((overloadable)) |
| 53 | rsGetElementAt(rs_allocation, uint32_t x); |
| 54 | extern const void * __attribute__((overloadable)) |
| 55 | rsGetElementAt(rs_allocation, uint32_t x, uint32_t y); |
| 56 | extern const void * __attribute__((overloadable)) |
| 57 | rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 58 | |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 59 | // Return a random value between 0 (or min_value) and max_malue. |
| 60 | extern int __attribute__((overloadable)) |
| 61 | rsRand(int max_value); |
| 62 | extern int __attribute__((overloadable)) |
| 63 | rsRand(int min_value, int max_value); |
| 64 | extern float __attribute__((overloadable)) |
| 65 | rsRand(float max_value); |
| 66 | extern float __attribute__((overloadable)) |
| 67 | rsRand(float min_value, float max_value); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 68 | |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 69 | // return the fractional part of a float |
| 70 | // min(v - ((int)floor(v)), 0x1.fffffep-1f); |
| 71 | extern float __attribute__((overloadable)) |
| 72 | rsFrac(float); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 73 | |
| 74 | // time |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 75 | extern int32_t __attribute__((overloadable)) |
| 76 | rsSecond(void); |
| 77 | extern int32_t __attribute__((overloadable)) |
| 78 | rsMinute(void); |
| 79 | extern int32_t __attribute__((overloadable)) |
| 80 | rsHour(void); |
| 81 | extern int32_t __attribute__((overloadable)) |
| 82 | rsDay(void); |
| 83 | extern int32_t __attribute__((overloadable)) |
| 84 | rsMonth(void); |
| 85 | extern int32_t __attribute__((overloadable)) |
| 86 | rsYear(void); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 87 | |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 88 | // Return the current system clock in milliseconds |
| 89 | extern int64_t __attribute__((overloadable)) |
| 90 | rsUptimeMillis(void); |
| 91 | |
| 92 | // Return the current system clock in nanoseconds |
| 93 | extern int64_t __attribute__((overloadable)) |
| 94 | rsUptimeNanos(void); |
| 95 | |
| 96 | // Return the time in seconds since function was last called in this script. |
| 97 | extern float __attribute__((overloadable)) |
| 98 | rsGetDt(void); |
| 99 | |
| 100 | // Send a message back to the client. Will not block and returns true |
| 101 | // if the message was sendable and false if the fifo was full. |
| 102 | // A message ID is required. Data payload is optional. |
| 103 | extern bool __attribute__((overloadable)) |
| 104 | rsSendToClient(int cmdID); |
| 105 | extern bool __attribute__((overloadable)) |
| 106 | rsSendToClient(int cmdID, const void *data, uint len); |
| 107 | |
| 108 | // Send a message back to the client, blocking until the message is queued. |
| 109 | // A message ID is required. Data payload is optional. |
| 110 | extern void __attribute__((overloadable)) |
| 111 | rsSendToClientBlocking(int cmdID); |
| 112 | extern void __attribute__((overloadable)) |
| 113 | rsSendToClientBlocking(int cmdID, const void *data, uint len); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 114 | |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 115 | // Script to Script |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 116 | typedef struct rs_script_call { |
Jason Sams | 479e292 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 117 | uint32_t xStart; |
| 118 | uint32_t xEnd; |
| 119 | uint32_t yStart; |
| 120 | uint32_t yEnd; |
| 121 | uint32_t zStart; |
| 122 | uint32_t zEnd; |
| 123 | uint32_t arrayStart; |
| 124 | uint32_t arrayEnd; |
| 125 | |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 126 | } rs_script_call_t; |
Jason Sams | 479e292 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 127 | |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 128 | extern void __attribute__((overloadable)) |
| 129 | rsForEach(rs_script script, rs_allocation input, |
| 130 | rs_allocation output, const void * usrData); |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 131 | |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 132 | extern void __attribute__((overloadable)) |
| 133 | rsForEach(rs_script script, rs_allocation input, |
| 134 | rs_allocation output, const void * usrData, |
| 135 | const rs_script_call_t *); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 136 | |
Jason Sams | c4cdf45 | 2010-07-07 11:55:51 -0700 | [diff] [blame] | 137 | #endif |