blob: b0840a09abe7b34c91cb6fbdfa3f0b0c5ea3db53 [file] [log] [blame]
Jason Sams044e2ee2011-08-08 16:52:30 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/** @file rs_allocation.rsh
18 * \brief Allocation routines
19 *
20 *
21 */
22
23#ifndef __RS_ALLOCATION_RSH__
24#define __RS_ALLOCATION_RSH__
25
26/**
27 * Returns the Allocation for a given pointer. The pointer should point within
28 * a valid allocation. The results are undefined if the pointer is not from a
29 * valid allocation.
30 */
31extern rs_allocation __attribute__((overloadable))
32 rsGetAllocation(const void *);
33
34/**
35 * Query the dimension of an allocation.
36 *
37 * @return uint32_t The X dimension of the allocation.
38 */
39extern uint32_t __attribute__((overloadable))
40 rsAllocationGetDimX(rs_allocation);
41
42/**
43 * Query the dimension of an allocation.
44 *
45 * @return uint32_t The Y dimension of the allocation.
46 */
47extern uint32_t __attribute__((overloadable))
48 rsAllocationGetDimY(rs_allocation);
49
50/**
51 * Query the dimension of an allocation.
52 *
53 * @return uint32_t The Z dimension of the allocation.
54 */
55extern uint32_t __attribute__((overloadable))
56 rsAllocationGetDimZ(rs_allocation);
57
58/**
59 * Query an allocation for the presence of more than one LOD.
60 *
61 * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
62 */
63extern uint32_t __attribute__((overloadable))
64 rsAllocationGetDimLOD(rs_allocation);
65
66/**
67 * Query an allocation for the presence of more than one face.
68 *
69 * @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
70 */
71extern uint32_t __attribute__((overloadable))
72 rsAllocationGetDimFaces(rs_allocation);
73
Alex Sakhartchouk43253872011-09-28 15:23:18 -070074#if (defined(RS_VERSION) && (RS_VERSION >= 14))
75
Jason Sams044e2ee2011-08-08 16:52:30 -070076/**
77 * Copy part of an allocation from another allocation.
78 *
79 * @param dstAlloc Allocation to copy data into.
80 * @param dstOff The offset of the first element to be copied in
81 * the destination allocation.
82 * @param dstMip Mip level in the destination allocation.
83 * @param count The number of elements to be copied.
84 * @param srcAlloc The source data allocation.
85 * @param srcOff The offset of the first element in data to be
86 * copied in the source allocation.
87 * @param srcMip Mip level in the source allocation.
88 */
89extern void __attribute__((overloadable))
90 rsAllocationCopy1DRange(rs_allocation dstAlloc,
91 uint32_t dstOff, uint32_t dstMip,
92 uint32_t count,
93 rs_allocation srcAlloc,
94 uint32_t srcOff, uint32_t srcMip);
95
96/**
97 * Copy a rectangular region into the allocation from another
98 * allocation.
99 *
100 * @param dstAlloc allocation to copy data into.
101 * @param dstXoff X offset of the region to update in the
102 * destination allocation.
103 * @param dstYoff Y offset of the region to update in the
104 * destination allocation.
105 * @param dstMip Mip level in the destination allocation.
106 * @param dstFace Cubemap face of the destination allocation,
107 * ignored for allocations that aren't cubemaps.
108 * @param width Width of the incoming region to update.
109 * @param height Height of the incoming region to update.
110 * @param srcAlloc The source data allocation.
111 * @param srcXoff X offset in data of the source allocation.
112 * @param srcYoff Y offset in data of the source allocation.
113 * @param srcMip Mip level in the source allocation.
114 * @param srcFace Cubemap face of the source allocation,
115 * ignored for allocations that aren't cubemaps.
116 */
117extern void __attribute__((overloadable))
118 rsAllocationCopy2DRange(rs_allocation dstAlloc,
119 uint32_t dstXoff, uint32_t dstYoff,
120 uint32_t dstMip,
121 rs_allocation_cubemap_face dstFace,
122 uint32_t width, uint32_t height,
123 rs_allocation srcAlloc,
124 uint32_t srcXoff, uint32_t srcYoff,
125 uint32_t srcMip,
126 rs_allocation_cubemap_face srcFace);
127
Alex Sakhartchouk43253872011-09-28 15:23:18 -0700128#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
Jason Sams044e2ee2011-08-08 16:52:30 -0700129
130/**
131 * Extract a single element from an allocation.
132 */
133extern const void * __attribute__((overloadable))
134 rsGetElementAt(rs_allocation, uint32_t x);
135/**
136 * \overload
137 */
138extern const void * __attribute__((overloadable))
139 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
140/**
141 * \overload
142 */
143extern const void * __attribute__((overloadable))
144 rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
145
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -0700146#if (defined(RS_VERSION) && (RS_VERSION >= 16))
147
Alex Sakhartchouk8d0f59e2011-12-16 14:15:07 -0800148/**
149 * @param a allocation to get data from
150 * @return element describing allocation layout
151 */
Alex Sakhartchoukb0fa3a62011-12-16 09:44:26 -0800152extern rs_element __attribute__((overloadable))
Alex Sakhartchouk8d0f59e2011-12-16 14:15:07 -0800153 rsAllocationGetElement(rs_allocation a);
Alex Sakhartchouk253325d2011-12-15 09:56:10 -0800154
Alex Sakhartchouk8d0f59e2011-12-16 14:15:07 -0800155/**
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800156 * Fetch allocation in a way described by the sampler
157 * @param a 1D allocation to sample from
158 * @param s sampler state
159 * @param location to sample from
160 */
161extern const float4 __attribute__((overloadable))
162 rsSample(rs_allocation a, rs_sampler s, float location);
163/**
164 * Fetch allocation in a way described by the sampler
165 * @param a 1D allocation to sample from
166 * @param s sampler state
167 * @param location to sample from
168 * @param lod mip level to sample from, for fractional values
169 * mip levels will be interpolated if
170 * RS_SAMPLER_LINEAR_MIP_LINEAR is used
171 */
172extern const float4 __attribute__((overloadable))
173 rsSample(rs_allocation a, rs_sampler s, float location, float lod);
174
175/**
176 * Fetch allocation in a way described by the sampler
177 * @param a 2D allocation to sample from
178 * @param s sampler state
179 * @param location to sample from
180 */
181extern const float4 __attribute__((overloadable))
182 rsSample(rs_allocation a, rs_sampler s, float2 location);
183
184/**
185 * Fetch allocation in a way described by the sampler
186 * @param a 2D allocation to sample from
187 * @param s sampler state
188 * @param location to sample from
189 * @param lod mip level to sample from, for fractional values
190 * mip levels will be interpolated if
191 * RS_SAMPLER_LINEAR_MIP_LINEAR is used
192 */
193extern const float4 __attribute__((overloadable))
194 rsSample(rs_allocation a, rs_sampler s, float2 location, float lod);
195
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -0700196#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
Alex Sakhartchouk09db9072012-02-29 16:43:24 -0800197
Jason Sams044e2ee2011-08-08 16:52:30 -0700198#endif
199