rs_math.rsh revision 1e5168d113ccdcf9fe1b817dcbf2f7f476d36c74
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 32extern void __attribute__((overloadable)) 33 rsSetObject(rs_element *dst, rs_element src); 34extern void __attribute__((overloadable)) 35 rsSetObject(rs_type *dst, rs_type src); 36extern void __attribute__((overloadable)) 37 rsSetObject(rs_allocation *dst, rs_allocation src); 38extern void __attribute__((overloadable)) 39 rsSetObject(rs_sampler *dst, rs_sampler src); 40extern void __attribute__((overloadable)) 41 rsSetObject(rs_script *dst, rs_script src); 42extern void __attribute__((overloadable)) 43 rsSetObject(rs_mesh *dst, rs_mesh src); 44extern void __attribute__((overloadable)) 45 rsSetObject(rs_program_fragment *dst, rs_program_fragment src); 46extern void __attribute__((overloadable)) 47 rsSetObject(rs_program_vertex *dst, rs_program_vertex src); 48extern void __attribute__((overloadable)) 49 rsSetObject(rs_program_raster *dst, rs_program_raster src); 50extern void __attribute__((overloadable)) 51 rsSetObject(rs_program_store *dst, rs_program_store src); 52extern void __attribute__((overloadable)) 53 rsSetObject(rs_font *dst, rs_font src); 54 55extern void __attribute__((overloadable)) 56 rsClearObject(rs_element *dst); 57extern void __attribute__((overloadable)) 58 rsClearObject(rs_type *dst); 59extern void __attribute__((overloadable)) 60 rsClearObject(rs_allocation *dst); 61extern void __attribute__((overloadable)) 62 rsClearObject(rs_sampler *dst); 63extern void __attribute__((overloadable)) 64 rsClearObject(rs_script *dst); 65extern void __attribute__((overloadable)) 66 rsClearObject(rs_mesh *dst); 67extern void __attribute__((overloadable)) 68 rsClearObject(rs_program_fragment *dst); 69extern void __attribute__((overloadable)) 70 rsClearObject(rs_program_vertex *dst); 71extern void __attribute__((overloadable)) 72 rsClearObject(rs_program_raster *dst); 73extern void __attribute__((overloadable)) 74 rsClearObject(rs_program_store *dst); 75extern void __attribute__((overloadable)) 76 rsClearObject(rs_font *dst); 77 78extern bool __attribute__((overloadable)) 79 rsIsObject(rs_element); 80extern bool __attribute__((overloadable)) 81 rsIsObject(rs_type); 82extern bool __attribute__((overloadable)) 83 rsIsObject(rs_allocation); 84extern bool __attribute__((overloadable)) 85 rsIsObject(rs_sampler); 86extern bool __attribute__((overloadable)) 87 rsIsObject(rs_script); 88extern bool __attribute__((overloadable)) 89 rsIsObject(rs_mesh); 90extern bool __attribute__((overloadable)) 91 rsIsObject(rs_program_fragment); 92extern bool __attribute__((overloadable)) 93 rsIsObject(rs_program_vertex); 94extern bool __attribute__((overloadable)) 95 rsIsObject(rs_program_raster); 96extern bool __attribute__((overloadable)) 97 rsIsObject(rs_program_store); 98extern bool __attribute__((overloadable)) 99 rsIsObject(rs_font); 100 101 102 103// Allocations 104 105// Return the rs_allocation associated with a bound data 106// pointer. 107extern rs_allocation __attribute__((overloadable)) 108 rsGetAllocation(const void *); 109 110// Mark the allocation dirty and notify those using it 111extern void __attribute__((overloadable)) 112 rsAllocationMarkDirty(rs_allocation); 113 114// Return the dimensions associated with an allocation. 115extern uint32_t __attribute__((overloadable)) 116 rsAllocationGetDimX(rs_allocation); 117extern uint32_t __attribute__((overloadable)) 118 rsAllocationGetDimY(rs_allocation); 119extern uint32_t __attribute__((overloadable)) 120 rsAllocationGetDimZ(rs_allocation); 121extern uint32_t __attribute__((overloadable)) 122 rsAllocationGetDimLOD(rs_allocation); 123extern uint32_t __attribute__((overloadable)) 124 rsAllocationGetDimFaces(rs_allocation); 125 126// Extract a single element from an allocation. 127extern const void * __attribute__((overloadable)) 128 rsGetElementAt(rs_allocation, uint32_t x); 129extern const void * __attribute__((overloadable)) 130 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y); 131extern const void * __attribute__((overloadable)) 132 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z); 133 134// Return a random value between 0 (or min_value) and max_malue. 135extern int __attribute__((overloadable)) 136 rsRand(int max_value); 137extern int __attribute__((overloadable)) 138 rsRand(int min_value, int max_value); 139extern float __attribute__((overloadable)) 140 rsRand(float max_value); 141extern float __attribute__((overloadable)) 142 rsRand(float min_value, float max_value); 143 144// return the fractional part of a float 145// min(v - ((int)floor(v)), 0x1.fffffep-1f); 146extern float __attribute__((overloadable)) 147 rsFrac(float); 148 149// time 150extern int32_t __attribute__((overloadable)) 151 rsSecond(void); 152extern int32_t __attribute__((overloadable)) 153 rsMinute(void); 154extern int32_t __attribute__((overloadable)) 155 rsHour(void); 156extern int32_t __attribute__((overloadable)) 157 rsDay(void); 158extern int32_t __attribute__((overloadable)) 159 rsMonth(void); 160extern int32_t __attribute__((overloadable)) 161 rsYear(void); 162 163// Return the current system clock in milliseconds 164extern int64_t __attribute__((overloadable)) 165 rsUptimeMillis(void); 166 167// Return the current system clock in nanoseconds 168extern int64_t __attribute__((overloadable)) 169 rsUptimeNanos(void); 170 171// Return the time in seconds since function was last called in this script. 172extern float __attribute__((overloadable)) 173 rsGetDt(void); 174 175// Send a message back to the client. Will not block and returns true 176// if the message was sendable and false if the fifo was full. 177// A message ID is required. Data payload is optional. 178extern bool __attribute__((overloadable)) 179 rsSendToClient(int cmdID); 180extern bool __attribute__((overloadable)) 181 rsSendToClient(int cmdID, const void *data, uint len); 182 183// Send a message back to the client, blocking until the message is queued. 184// A message ID is required. Data payload is optional. 185extern void __attribute__((overloadable)) 186 rsSendToClientBlocking(int cmdID); 187extern void __attribute__((overloadable)) 188 rsSendToClientBlocking(int cmdID, const void *data, uint len); 189 190 191// Script to Script 192enum rs_for_each_strategy { 193 RS_FOR_EACH_STRATEGY_SERIAL, 194 RS_FOR_EACH_STRATEGY_DONT_CARE, 195 RS_FOR_EACH_STRATEGY_DST_LINEAR, 196 RS_FOR_EACH_STRATEGY_TILE_SMALL, 197 RS_FOR_EACH_STRATEGY_TILE_MEDIUM, 198 RS_FOR_EACH_STRATEGY_TILE_LARGE 199}; 200 201typedef struct rs_script_call { 202 enum rs_for_each_strategy strategy; 203 uint32_t xStart; 204 uint32_t xEnd; 205 uint32_t yStart; 206 uint32_t yEnd; 207 uint32_t zStart; 208 uint32_t zEnd; 209 uint32_t arrayStart; 210 uint32_t arrayEnd; 211} rs_script_call_t; 212 213extern void __attribute__((overloadable)) 214 rsForEach(rs_script script, rs_allocation input, 215 rs_allocation output, const void * usrData); 216 217extern void __attribute__((overloadable)) 218 rsForEach(rs_script script, rs_allocation input, 219 rs_allocation output, const void * usrData, 220 const rs_script_call_t *); 221 222#endif 223