rs_math.rsh revision 7dce6bc09126187534ab0297c66b30149643b162
1#ifndef __RS_MATH_RSH__
2#define __RS_MATH_RSH__
3
4// Debugging, print to the LOG a description string and a value.
5extern void __attribute__((overloadable))
6    rsDebug(const char *, float);
7extern void __attribute__((overloadable))
8    rsDebug(const char *, float, float);
9extern void __attribute__((overloadable))
10    rsDebug(const char *, float, float, float);
11extern void __attribute__((overloadable))
12    rsDebug(const char *, float, float, float, float);
13extern void __attribute__((overloadable))
14    rsDebug(const char *, const rs_matrix4x4 *);
15extern void __attribute__((overloadable))
16    rsDebug(const char *, const rs_matrix3x3 *);
17extern void __attribute__((overloadable))
18    rsDebug(const char *, const rs_matrix2x2 *);
19extern void __attribute__((overloadable))
20    rsDebug(const char *, int);
21extern void __attribute__((overloadable))
22    rsDebug(const char *, uint);
23extern 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
29#include "rs_cl.rsh"
30#include "rs_core.rsh"
31
32// Allocations
33
34// Return the rs_allocation associated with a bound data
35// pointer.
36extern rs_allocation __attribute__((overloadable))
37    rsGetAllocation(const void *);
38
39// Return the dimensions associated with an allocation.
40extern uint32_t __attribute__((overloadable))
41    rsAllocationGetDimX(rs_allocation);
42extern uint32_t __attribute__((overloadable))
43    rsAllocationGetDimY(rs_allocation);
44extern uint32_t __attribute__((overloadable))
45    rsAllocationGetDimZ(rs_allocation);
46extern uint32_t __attribute__((overloadable))
47    rsAllocationGetDimLOD(rs_allocation);
48extern uint32_t __attribute__((overloadable))
49    rsAllocationGetDimFaces(rs_allocation);
50
51// Extract a single element from an allocation.
52extern const void * __attribute__((overloadable))
53    rsGetElementAt(rs_allocation, uint32_t x);
54extern const void * __attribute__((overloadable))
55    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
56extern const void * __attribute__((overloadable))
57    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
58
59// Return a random value between 0 (or min_value) and max_malue.
60extern int __attribute__((overloadable))
61    rsRand(int max_value);
62extern int __attribute__((overloadable))
63    rsRand(int min_value, int max_value);
64extern float __attribute__((overloadable))
65    rsRand(float max_value);
66extern float __attribute__((overloadable))
67    rsRand(float min_value, float max_value);
68
69// return the fractional part of a float
70// min(v - ((int)floor(v)), 0x1.fffffep-1f);
71extern float __attribute__((overloadable))
72    rsFrac(float);
73
74// time
75extern int32_t __attribute__((overloadable))
76    rsSecond(void);
77extern int32_t __attribute__((overloadable))
78    rsMinute(void);
79extern int32_t __attribute__((overloadable))
80    rsHour(void);
81extern int32_t __attribute__((overloadable))
82    rsDay(void);
83extern int32_t __attribute__((overloadable))
84    rsMonth(void);
85extern int32_t __attribute__((overloadable))
86    rsYear(void);
87
88// Return the current system clock in milliseconds
89extern int64_t __attribute__((overloadable))
90    rsUptimeMillis(void);
91
92// Return the current system clock in nanoseconds
93extern int64_t __attribute__((overloadable))
94    rsUptimeNanos(void);
95
96// Return the time in seconds since function was last called in this script.
97extern 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.
103extern bool __attribute__((overloadable))
104    rsSendToClient(int cmdID);
105extern 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.
110extern void __attribute__((overloadable))
111    rsSendToClientBlocking(int cmdID);
112extern void __attribute__((overloadable))
113    rsSendToClientBlocking(int cmdID, const void *data, uint len);
114
115// Script to Script
116typedef struct rs_script_call {
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
126} rs_script_call_t;
127
128extern void __attribute__((overloadable))
129    rsForEach(rs_script script, rs_allocation input,
130              rs_allocation output, const void * usrData);
131
132extern void __attribute__((overloadable))
133    rsForEach(rs_script script, rs_allocation input,
134              rs_allocation output, const void * usrData,
135              const rs_script_call_t *);
136
137#endif
138