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