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