blob: 584317e0476c50b71e7039e87f0f80667390b9b1 [file] [log] [blame]
Jason Samsc4cdf452010-07-07 11:55:51 -07001#ifndef __RS_MATH_RSH__
2#define __RS_MATH_RSH__
3
Jason Sams09aeb8a2011-01-28 15:49:07 -08004/**
5 * Copy reference to the specified object.
6 *
7 * @param dst
8 * @param src
9 */
Jason Samsc0936852010-08-16 12:41:48 -070010extern void __attribute__((overloadable))
11 rsSetObject(rs_element *dst, rs_element src);
12extern void __attribute__((overloadable))
13 rsSetObject(rs_type *dst, rs_type src);
14extern void __attribute__((overloadable))
15 rsSetObject(rs_allocation *dst, rs_allocation src);
16extern void __attribute__((overloadable))
17 rsSetObject(rs_sampler *dst, rs_sampler src);
18extern void __attribute__((overloadable))
19 rsSetObject(rs_script *dst, rs_script src);
20extern void __attribute__((overloadable))
21 rsSetObject(rs_mesh *dst, rs_mesh src);
22extern void __attribute__((overloadable))
23 rsSetObject(rs_program_fragment *dst, rs_program_fragment src);
24extern void __attribute__((overloadable))
25 rsSetObject(rs_program_vertex *dst, rs_program_vertex src);
26extern void __attribute__((overloadable))
27 rsSetObject(rs_program_raster *dst, rs_program_raster src);
28extern void __attribute__((overloadable))
29 rsSetObject(rs_program_store *dst, rs_program_store src);
30extern void __attribute__((overloadable))
31 rsSetObject(rs_font *dst, rs_font src);
32
Jason Sams09aeb8a2011-01-28 15:49:07 -080033/**
34 * Sets the object to NULL.
35 *
36 * @return bool
37 */
Jason Samsc0936852010-08-16 12:41:48 -070038extern void __attribute__((overloadable))
39 rsClearObject(rs_element *dst);
40extern void __attribute__((overloadable))
41 rsClearObject(rs_type *dst);
42extern void __attribute__((overloadable))
43 rsClearObject(rs_allocation *dst);
44extern void __attribute__((overloadable))
45 rsClearObject(rs_sampler *dst);
46extern void __attribute__((overloadable))
47 rsClearObject(rs_script *dst);
48extern void __attribute__((overloadable))
49 rsClearObject(rs_mesh *dst);
50extern void __attribute__((overloadable))
51 rsClearObject(rs_program_fragment *dst);
52extern void __attribute__((overloadable))
53 rsClearObject(rs_program_vertex *dst);
54extern void __attribute__((overloadable))
55 rsClearObject(rs_program_raster *dst);
56extern void __attribute__((overloadable))
57 rsClearObject(rs_program_store *dst);
58extern void __attribute__((overloadable))
59 rsClearObject(rs_font *dst);
60
Jason Sams09aeb8a2011-01-28 15:49:07 -080061/**
62 * Tests if the object is valid. Returns true if the object is valid, false if
63 * it is NULL.
64 *
65 * @return bool
66 */
Jason Samsc0936852010-08-16 12:41:48 -070067extern bool __attribute__((overloadable))
68 rsIsObject(rs_element);
69extern bool __attribute__((overloadable))
70 rsIsObject(rs_type);
71extern bool __attribute__((overloadable))
72 rsIsObject(rs_allocation);
73extern bool __attribute__((overloadable))
74 rsIsObject(rs_sampler);
75extern bool __attribute__((overloadable))
76 rsIsObject(rs_script);
77extern bool __attribute__((overloadable))
78 rsIsObject(rs_mesh);
79extern bool __attribute__((overloadable))
80 rsIsObject(rs_program_fragment);
81extern bool __attribute__((overloadable))
82 rsIsObject(rs_program_vertex);
83extern bool __attribute__((overloadable))
84 rsIsObject(rs_program_raster);
85extern bool __attribute__((overloadable))
86 rsIsObject(rs_program_store);
87extern bool __attribute__((overloadable))
88 rsIsObject(rs_font);
89
90
Jason Sams09aeb8a2011-01-28 15:49:07 -080091/**
92 * Returns the Allocation for a given pointer. The pointer should point within
93 * a valid allocation. The results are undefined if the pointer is not from a
94 * valid allocation.
95 */
Jason Samsef5867a2010-07-28 11:17:53 -070096extern rs_allocation __attribute__((overloadable))
97 rsGetAllocation(const void *);
Jason Sams73495472010-07-29 17:31:14 -070098
Jason Sams09aeb8a2011-01-28 15:49:07 -080099/**
Jason Sams09aeb8a2011-01-28 15:49:07 -0800100 * Query the dimension of an allocation.
101 *
102 * @return uint32_t The X dimension of the allocation.
103 */
Jason Samsef5867a2010-07-28 11:17:53 -0700104extern uint32_t __attribute__((overloadable))
105 rsAllocationGetDimX(rs_allocation);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800106
107/**
108 * Query the dimension of an allocation.
109 *
110 * @return uint32_t The Y dimension of the allocation.
111 */
Jason Samsef5867a2010-07-28 11:17:53 -0700112extern uint32_t __attribute__((overloadable))
113 rsAllocationGetDimY(rs_allocation);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800114
115/**
116 * Query the dimension of an allocation.
117 *
118 * @return uint32_t The Z dimension of the allocation.
119 */
Jason Samsef5867a2010-07-28 11:17:53 -0700120extern uint32_t __attribute__((overloadable))
121 rsAllocationGetDimZ(rs_allocation);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800122
123/**
124 * Query an allocation for the presence of more than one LOD.
125 *
126 * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
127 */
Jason Samsef5867a2010-07-28 11:17:53 -0700128extern uint32_t __attribute__((overloadable))
129 rsAllocationGetDimLOD(rs_allocation);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800130
131/**
132 * Query an allocation for the presence of more than one face.
133 *
134 * @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
135 */
Jason Samsef5867a2010-07-28 11:17:53 -0700136extern uint32_t __attribute__((overloadable))
137 rsAllocationGetDimFaces(rs_allocation);
Jason Sams22fa3712010-05-19 17:22:57 -0700138
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700139/**
140 * Copy part of an allocation from another allocation.
141 *
142 * @param dstAlloc Allocation to copy data into.
143 * @param dstOff The offset of the first element to be copied in
144 * the destination allocation.
145 * @param dstMip Mip level in the destination allocation.
146 * @param count The number of elements to be copied.
147 * @param srcAlloc The source data allocation.
148 * @param srcOff The offset of the first element in data to be
149 * copied in the source allocation.
150 * @param srcMip Mip level in the source allocation.
151 */
152extern void __attribute__((overloadable))
153 rsAllocationCopy1DRange(rs_allocation dstAlloc,
154 uint32_t dstOff, uint32_t dstMip,
155 uint32_t count,
156 rs_allocation srcAlloc,
157 uint32_t srcOff, uint32_t srcMip);
158
159/**
160 * Copy a rectangular region into the allocation from another
161 * allocation.
162 *
163 * @param dstAlloc allocation to copy data into.
164 * @param dstXoff X offset of the region to update in the
165 * destination allocation.
166 * @param dstYoff Y offset of the region to update in the
167 * destination allocation.
168 * @param dstMip Mip level in the destination allocation.
169 * @param dstFace Cubemap face of the destination allocation,
170 * ignored for allocations that aren't cubemaps.
171 * @param width Width of the incoming region to update.
172 * @param height Height of the incoming region to update.
173 * @param srcAlloc The source data allocation.
174 * @param srcXoff X offset in data of the source allocation.
175 * @param srcYoff Y offset in data of the source allocation.
176 * @param srcMip Mip level in the source allocation.
177 * @param srcFace Cubemap face of the source allocation,
178 * ignored for allocations that aren't cubemaps.
179 */
180extern void __attribute__((overloadable))
181 rsAllocationCopy2DRange(rs_allocation dstAlloc,
182 uint32_t dstXoff, uint32_t dstYoff,
183 uint32_t dstMip,
184 rs_allocation_cubemap_face dstFace,
185 uint32_t width, uint32_t height,
186 rs_allocation srcAlloc,
187 uint32_t srcXoff, uint32_t srcYoff,
188 uint32_t srcMip,
189 rs_allocation_cubemap_face srcFace);
190
Jason Sams73495472010-07-29 17:31:14 -0700191// Extract a single element from an allocation.
Jason Sams7bf29dd2010-07-19 15:38:19 -0700192extern const void * __attribute__((overloadable))
193 rsGetElementAt(rs_allocation, uint32_t x);
194extern const void * __attribute__((overloadable))
195 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
196extern const void * __attribute__((overloadable))
197 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
Jason Sams22fa3712010-05-19 17:22:57 -0700198
Jason Sams73495472010-07-29 17:31:14 -0700199// Return a random value between 0 (or min_value) and max_malue.
200extern int __attribute__((overloadable))
201 rsRand(int max_value);
202extern int __attribute__((overloadable))
203 rsRand(int min_value, int max_value);
204extern float __attribute__((overloadable))
205 rsRand(float max_value);
206extern float __attribute__((overloadable))
207 rsRand(float min_value, float max_value);
Jason Sams22fa3712010-05-19 17:22:57 -0700208
Jason Sams73495472010-07-29 17:31:14 -0700209// return the fractional part of a float
210// min(v - ((int)floor(v)), 0x1.fffffep-1f);
211extern float __attribute__((overloadable))
212 rsFrac(float);
Jason Sams22fa3712010-05-19 17:22:57 -0700213
Jason Sams73495472010-07-29 17:31:14 -0700214// Send a message back to the client. Will not block and returns true
215// if the message was sendable and false if the fifo was full.
216// A message ID is required. Data payload is optional.
217extern bool __attribute__((overloadable))
218 rsSendToClient(int cmdID);
219extern bool __attribute__((overloadable))
220 rsSendToClient(int cmdID, const void *data, uint len);
221
222// Send a message back to the client, blocking until the message is queued.
223// A message ID is required. Data payload is optional.
224extern void __attribute__((overloadable))
225 rsSendToClientBlocking(int cmdID);
226extern void __attribute__((overloadable))
227 rsSendToClientBlocking(int cmdID, const void *data, uint len);
Jason Sams22fa3712010-05-19 17:22:57 -0700228
Jason Samsdd663fa2010-08-11 13:26:28 -0700229
Jason Samsc61346b2010-05-28 18:23:22 -0700230// Script to Script
Jason Samsdd663fa2010-08-11 13:26:28 -0700231enum rs_for_each_strategy {
232 RS_FOR_EACH_STRATEGY_SERIAL,
233 RS_FOR_EACH_STRATEGY_DONT_CARE,
234 RS_FOR_EACH_STRATEGY_DST_LINEAR,
235 RS_FOR_EACH_STRATEGY_TILE_SMALL,
236 RS_FOR_EACH_STRATEGY_TILE_MEDIUM,
237 RS_FOR_EACH_STRATEGY_TILE_LARGE
238};
239
Jason Samsace3e012010-07-15 17:11:13 -0700240typedef struct rs_script_call {
Jason Samsdd663fa2010-08-11 13:26:28 -0700241 enum rs_for_each_strategy strategy;
Jason Sams479e2922010-07-09 15:34:32 -0700242 uint32_t xStart;
243 uint32_t xEnd;
244 uint32_t yStart;
245 uint32_t yEnd;
246 uint32_t zStart;
247 uint32_t zEnd;
248 uint32_t arrayStart;
249 uint32_t arrayEnd;
Jason Samsace3e012010-07-15 17:11:13 -0700250} rs_script_call_t;
Jason Sams479e2922010-07-09 15:34:32 -0700251
Jason Sams73495472010-07-29 17:31:14 -0700252extern void __attribute__((overloadable))
253 rsForEach(rs_script script, rs_allocation input,
254 rs_allocation output, const void * usrData);
Jason Samsace3e012010-07-15 17:11:13 -0700255
Jason Sams73495472010-07-29 17:31:14 -0700256extern void __attribute__((overloadable))
257 rsForEach(rs_script script, rs_allocation input,
258 rs_allocation output, const void * usrData,
259 const rs_script_call_t *);
Jason Samsc61346b2010-05-28 18:23:22 -0700260
Jason Samsc4cdf452010-07-07 11:55:51 -0700261#endif