1/* 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 74#if (defined(RS_VERSION) && (RS_VERSION >= 14)) 75 76/** 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 128#endif //defined(RS_VERSION) && (RS_VERSION >= 14) 129 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 146// New API's 147#if (defined(RS_VERSION) && (RS_VERSION >= 16)) 148 149/** 150 * Send the contents of the Allocation to the queue. 151 * @param a allocation to work on 152 */ 153extern const void __attribute__((overloadable)) 154 rsAllocationIoSend(rs_allocation a); 155 156/** 157 * Receive a new set of contents from the queue. 158 * @param a allocation to work on 159 */ 160extern const void __attribute__((overloadable)) 161 rsAllocationIoReceive(rs_allocation a); 162 163 164/** 165 * Get the element object describing the allocation's layout 166 * @param a allocation to get data from 167 * @return element describing allocation layout 168 */ 169extern rs_element __attribute__((overloadable)) 170 rsAllocationGetElement(rs_allocation a); 171 172/** 173 * Fetch allocation in a way described by the sampler 174 * @param a 1D allocation to sample from 175 * @param s sampler state 176 * @param location to sample from 177 */ 178extern const float4 __attribute__((overloadable)) 179 rsSample(rs_allocation a, rs_sampler s, float location); 180/** 181 * Fetch allocation in a way described by the sampler 182 * @param a 1D allocation to sample from 183 * @param s sampler state 184 * @param location to sample from 185 * @param lod mip level to sample from, for fractional values 186 * mip levels will be interpolated if 187 * RS_SAMPLER_LINEAR_MIP_LINEAR is used 188 */ 189extern const float4 __attribute__((overloadable)) 190 rsSample(rs_allocation a, rs_sampler s, float location, float lod); 191 192/** 193 * Fetch allocation in a way described by the sampler 194 * @param a 2D allocation to sample from 195 * @param s sampler state 196 * @param location to sample from 197 */ 198extern const float4 __attribute__((overloadable)) 199 rsSample(rs_allocation a, rs_sampler s, float2 location); 200 201/** 202 * Fetch allocation in a way described by the sampler 203 * @param a 2D allocation to sample from 204 * @param s sampler state 205 * @param location to sample from 206 * @param lod mip level to sample from, for fractional values 207 * mip levels will be interpolated if 208 * RS_SAMPLER_LINEAR_MIP_LINEAR is used 209 */ 210extern const float4 __attribute__((overloadable)) 211 rsSample(rs_allocation a, rs_sampler s, float2 location, float lod); 212 213#endif // (defined(RS_VERSION) && (RS_VERSION >= 16)) 214 215#endif 216 217