blob: cdff49c5ec2409cc6688a4abb14f70d9eced319a [file] [log] [blame]
Jason Samsd19f10d2009-05-22 14:03:28 -07001/*
Stephen Hines4cbe25a2012-01-18 18:46:27 -08002 * Copyright (C) 2009-2012 The Android Open Source Project
Jason Samsd19f10d2009-05-22 14:03:28 -07003 *
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 */
Jason Samsd19f10d2009-05-22 14:03:28 -070016
Alex Sakhartchoukd0f5bd12011-01-31 14:53:24 -080017#include "rsContext.h"
Alex Sakhartchoukbedc0232012-03-09 10:47:27 -080018#include "rsAllocation.h"
19#include "rsAdapter.h"
Jason Sams7e8aae72011-05-26 16:33:01 -070020#include "rs_hal.h"
21
Jason Sams163766c2012-02-15 12:04:24 -080022#include "system/window.h"
Jason Samsfe1d5ff2012-03-23 11:47:26 -070023#include "gui/SurfaceTexture.h"
Alex Sakhartchouk26ae3902010-10-11 12:35:15 -070024
Jason Samsd19f10d2009-05-22 14:03:28 -070025using namespace android;
26using namespace android::renderscript;
27
Alex Sakhartchouk08571962010-12-15 09:59:58 -080028Allocation::Allocation(Context *rsc, const Type *type, uint32_t usages,
Jason Sams857d0c72011-11-23 15:02:15 -080029 RsAllocationMipmapControl mc, void * ptr)
Alex Sakhartchouk08571962010-12-15 09:59:58 -080030 : ObjectBase(rsc) {
Jason Sams8a64743f2010-03-01 15:31:04 -080031
Jason Sams7e8aae72011-05-26 16:33:01 -070032 memset(&mHal, 0, sizeof(mHal));
33 mHal.state.mipmapControl = RS_ALLOCATION_MIPMAP_NONE;
Jason Samse4a06c52011-03-16 16:29:28 -070034 mHal.state.usageFlags = usages;
35 mHal.state.mipmapControl = mc;
Jason Sams857d0c72011-11-23 15:02:15 -080036 mHal.state.usrPtr = ptr;
Jason Sams5476b452010-12-08 16:14:36 -080037
Alex Sakhartchouk5ef2f532011-10-18 10:54:29 -070038 setType(type);
Jason Samse4a06c52011-03-16 16:29:28 -070039 updateCache();
40}
Jason Sams8a64743f2010-03-01 15:31:04 -080041
Jason Sams7e8aae72011-05-26 16:33:01 -070042Allocation * Allocation::createAllocation(Context *rsc, const Type *type, uint32_t usages,
Jason Sams857d0c72011-11-23 15:02:15 -080043 RsAllocationMipmapControl mc, void * ptr) {
44 Allocation *a = new Allocation(rsc, type, usages, mc, ptr);
Jason Sams7e8aae72011-05-26 16:33:01 -070045
46 if (!rsc->mHal.funcs.allocation.init(rsc, a, type->getElement()->getHasReferences())) {
47 rsc->setError(RS_ERROR_FATAL_DRIVER, "Allocation::Allocation, alloc failure");
48 delete a;
49 return NULL;
50 }
Jason Sams163766c2012-02-15 12:04:24 -080051
Jason Sams7e8aae72011-05-26 16:33:01 -070052 return a;
53}
54
Jason Samse4a06c52011-03-16 16:29:28 -070055void Allocation::updateCache() {
Alex Sakhartchouk5ef2f532011-10-18 10:54:29 -070056 const Type *type = mHal.state.type;
Jason Samse4a06c52011-03-16 16:29:28 -070057 mHal.state.dimensionX = type->getDimX();
58 mHal.state.dimensionY = type->getDimY();
59 mHal.state.dimensionZ = type->getDimZ();
60 mHal.state.hasFaces = type->getDimFaces();
61 mHal.state.hasMipmaps = type->getDimLOD();
62 mHal.state.elementSizeBytes = type->getElementSizeBytes();
63 mHal.state.hasReferences = mHal.state.type->getElement()->getHasReferences();
Jason Samsd19f10d2009-05-22 14:03:28 -070064}
65
Alex Sakhartchouked9f2102010-11-09 17:00:54 -080066Allocation::~Allocation() {
Jason Sams777ec262011-08-18 18:01:33 -070067 freeChildrenUnlocked();
Jason Samsfe1d5ff2012-03-23 11:47:26 -070068 setSurfaceTexture(mRSC, NULL);
Jason Sams7e8aae72011-05-26 16:33:01 -070069 mRSC->mHal.funcs.allocation.destroy(mRSC, this);
Jason Samsd19f10d2009-05-22 14:03:28 -070070}
71
Jason Sams5476b452010-12-08 16:14:36 -080072void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) {
Jason Sams7e8aae72011-05-26 16:33:01 -070073 rsc->mHal.funcs.allocation.syncAll(rsc, this, src);
Jason Sams3b7d39b2009-12-14 12:57:40 -080074}
75
Alex Sakhartchouked9f2102010-11-09 17:00:54 -080076void Allocation::read(void *data) {
Jason Sams7e8aae72011-05-26 16:33:01 -070077 memcpy(data, getPtr(), mHal.state.type->getSizeBytes());
Jason Sams40a29e82009-08-10 14:55:26 -070078}
79
Jason Sams49a05d72010-12-29 14:31:29 -080080void Allocation::data(Context *rsc, uint32_t xoff, uint32_t lod,
Stephen Hines4cbe25a2012-01-18 18:46:27 -080081 uint32_t count, const void *data, size_t sizeBytes) {
82 const size_t eSize = mHal.state.type->getElementSizeBytes();
Jason Sams07ae4062009-08-27 20:23:34 -070083
Jason Sams7e8aae72011-05-26 16:33:01 -070084 if ((count * eSize) != sizeBytes) {
Stephen Hines4cbe25a2012-01-18 18:46:27 -080085 ALOGE("Allocation::subData called with mismatched size expected %zu, got %zu",
Jason Sams7e8aae72011-05-26 16:33:01 -070086 (count * eSize), sizeBytes);
Jason Samse4a06c52011-03-16 16:29:28 -070087 mHal.state.type->dumpLOGV("type info");
Jason Sams07ae4062009-08-27 20:23:34 -070088 return;
89 }
Jason Samsb28ca96f2010-08-09 18:13:33 -070090
Jason Sams7e8aae72011-05-26 16:33:01 -070091 rsc->mHal.funcs.allocation.data1D(rsc, this, xoff, lod, count, data, sizeBytes);
92 sendDirty(rsc);
Jason Samsd19f10d2009-05-22 14:03:28 -070093}
94
Jason Sams49a05d72010-12-29 14:31:29 -080095void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
Stephen Hines4cbe25a2012-01-18 18:46:27 -080096 uint32_t w, uint32_t h, const void *data, size_t sizeBytes) {
97 const size_t eSize = mHal.state.elementSizeBytes;
98 const size_t lineSize = eSize * w;
Jason Samsd19f10d2009-05-22 14:03:28 -070099
Steve Block3762c312012-01-06 19:20:56 +0000100 //ALOGE("data2d %p, %i %i %i %i %i %i %p %i", this, xoff, yoff, lod, face, w, h, data, sizeBytes);
Jason Sams07ae4062009-08-27 20:23:34 -0700101
Jason Samsf7086092011-01-12 13:28:37 -0800102 if ((lineSize * h) != sizeBytes) {
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800103 ALOGE("Allocation size mismatch, expected %zu, got %zu", (lineSize * h), sizeBytes);
Jason Sams07ae4062009-08-27 20:23:34 -0700104 rsAssert(!"Allocation::subData called with mismatched size");
105 return;
106 }
107
Jason Sams7e8aae72011-05-26 16:33:01 -0700108 rsc->mHal.funcs.allocation.data2D(rsc, this, xoff, yoff, lod, face, w, h, data, sizeBytes);
109 sendDirty(rsc);
Jason Samsd19f10d2009-05-22 14:03:28 -0700110}
111
Jason Samsfb9f82c2011-01-12 14:53:25 -0800112void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff,
113 uint32_t lod, RsAllocationCubemapFace face,
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800114 uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes) {
Jason Samsd19f10d2009-05-22 14:03:28 -0700115}
116
Jason Sams49a05d72010-12-29 14:31:29 -0800117void Allocation::elementData(Context *rsc, uint32_t x, const void *data,
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800118 uint32_t cIdx, size_t sizeBytes) {
119 size_t eSize = mHal.state.elementSizeBytes;
Jason Sams49bdaf02010-08-31 13:50:42 -0700120
Jason Samse4a06c52011-03-16 16:29:28 -0700121 if (cIdx >= mHal.state.type->getElement()->getFieldCount()) {
Steve Block3762c312012-01-06 19:20:56 +0000122 ALOGE("Error Allocation::subElementData component %i out of range.", cIdx);
Jason Sams49bdaf02010-08-31 13:50:42 -0700123 rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range.");
124 return;
125 }
126
Jason Samse4a06c52011-03-16 16:29:28 -0700127 if (x >= mHal.state.dimensionX) {
Steve Block3762c312012-01-06 19:20:56 +0000128 ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
Jason Sams49bdaf02010-08-31 13:50:42 -0700129 rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
130 return;
131 }
132
Jason Samse4a06c52011-03-16 16:29:28 -0700133 const Element * e = mHal.state.type->getElement()->getField(cIdx);
Alex Sakhartchoukbf3c3f22012-02-02 09:47:26 -0800134 uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx);
135 if (sizeBytes != e->getSizeBytes() * elemArraySize) {
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800136 ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes());
Jason Sams49bdaf02010-08-31 13:50:42 -0700137 rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
138 return;
139 }
140
Jason Sams7e8aae72011-05-26 16:33:01 -0700141 rsc->mHal.funcs.allocation.elementData1D(rsc, this, x, data, cIdx, sizeBytes);
142 sendDirty(rsc);
Jason Sams49bdaf02010-08-31 13:50:42 -0700143}
144
Jason Sams49a05d72010-12-29 14:31:29 -0800145void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y,
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800146 const void *data, uint32_t cIdx, size_t sizeBytes) {
147 size_t eSize = mHal.state.elementSizeBytes;
Jason Sams49bdaf02010-08-31 13:50:42 -0700148
Jason Samse4a06c52011-03-16 16:29:28 -0700149 if (x >= mHal.state.dimensionX) {
Steve Block3762c312012-01-06 19:20:56 +0000150 ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
Jason Sams49bdaf02010-08-31 13:50:42 -0700151 rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
152 return;
153 }
154
Jason Samse4a06c52011-03-16 16:29:28 -0700155 if (y >= mHal.state.dimensionY) {
Steve Block3762c312012-01-06 19:20:56 +0000156 ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
Jason Sams49bdaf02010-08-31 13:50:42 -0700157 rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
158 return;
159 }
160
Jason Samse4a06c52011-03-16 16:29:28 -0700161 if (cIdx >= mHal.state.type->getElement()->getFieldCount()) {
Steve Block3762c312012-01-06 19:20:56 +0000162 ALOGE("Error Allocation::subElementData component %i out of range.", cIdx);
Jason Sams49bdaf02010-08-31 13:50:42 -0700163 rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range.");
164 return;
165 }
166
Jason Samse4a06c52011-03-16 16:29:28 -0700167 const Element * e = mHal.state.type->getElement()->getField(cIdx);
Alex Sakhartchoukbf3c3f22012-02-02 09:47:26 -0800168 uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx);
169 if (sizeBytes != e->getSizeBytes() * elemArraySize) {
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800170 ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes());
Jason Sams49bdaf02010-08-31 13:50:42 -0700171 rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
172 return;
173 }
174
Jason Sams7e8aae72011-05-26 16:33:01 -0700175 rsc->mHal.funcs.allocation.elementData2D(rsc, this, x, y, data, cIdx, sizeBytes);
176 sendDirty(rsc);
Jason Sams49bdaf02010-08-31 13:50:42 -0700177}
178
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800179void Allocation::addProgramToDirty(const Program *p) {
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700180 mToDirtyList.push(p);
Jason Sams83f1c632009-10-26 15:19:28 -0700181}
Jason Samsd19f10d2009-05-22 14:03:28 -0700182
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800183void Allocation::removeProgramToDirty(const Program *p) {
Jason Sams83f1c632009-10-26 15:19:28 -0700184 for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
185 if (mToDirtyList[ct] == p) {
186 mToDirtyList.removeAt(ct);
187 return;
188 }
189 }
190 rsAssert(0);
191}
192
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800193void Allocation::dumpLOGV(const char *prefix) const {
Jason Sams715333b2009-11-17 17:26:46 -0800194 ObjectBase::dumpLOGV(prefix);
195
196 String8 s(prefix);
197 s.append(" type ");
Alex Sakhartchouk5ef2f532011-10-18 10:54:29 -0700198 if (mHal.state.type) {
Jason Samse4a06c52011-03-16 16:29:28 -0700199 mHal.state.type->dumpLOGV(s.string());
Jason Sams715333b2009-11-17 17:26:46 -0800200 }
201
Steve Block71f2cf12011-10-20 11:56:00 +0100202 ALOGV("%s allocation ptr=%p mUsageFlags=0x04%x, mMipmapControl=0x%04x",
Jason Sams7e8aae72011-05-26 16:33:01 -0700203 prefix, getPtr(), mHal.state.usageFlags, mHal.state.mipmapControl);
Jason Sams715333b2009-11-17 17:26:46 -0800204}
Jason Samsd19f10d2009-05-22 14:03:28 -0700205
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800206uint32_t Allocation::getPackedSize() const {
207 uint32_t numItems = mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes();
208 return numItems * mHal.state.type->getElement()->getSizeBytesUnpadded();
209}
210
211void Allocation::writePackedData(const Type *type,
212 uint8_t *dst, const uint8_t *src, bool dstPadded) {
213 const Element *elem = type->getElement();
214 uint32_t unpaddedBytes = elem->getSizeBytesUnpadded();
215 uint32_t paddedBytes = elem->getSizeBytes();
216 uint32_t numItems = type->getSizeBytes() / paddedBytes;
217
218 uint32_t srcInc = !dstPadded ? paddedBytes : unpaddedBytes;
219 uint32_t dstInc = dstPadded ? paddedBytes : unpaddedBytes;
220
221 // no sub-elements
222 uint32_t fieldCount = elem->getFieldCount();
223 if (fieldCount == 0) {
224 for (uint32_t i = 0; i < numItems; i ++) {
225 memcpy(dst, src, unpaddedBytes);
226 src += srcInc;
227 dst += dstInc;
228 }
229 return;
230 }
231
232 // Cache offsets
233 uint32_t *offsetsPadded = new uint32_t[fieldCount];
234 uint32_t *offsetsUnpadded = new uint32_t[fieldCount];
235 uint32_t *sizeUnpadded = new uint32_t[fieldCount];
236
237 for (uint32_t i = 0; i < fieldCount; i++) {
238 offsetsPadded[i] = elem->getFieldOffsetBytes(i);
239 offsetsUnpadded[i] = elem->getFieldOffsetBytesUnpadded(i);
240 sizeUnpadded[i] = elem->getField(i)->getSizeBytesUnpadded();
241 }
242
243 uint32_t *srcOffsets = !dstPadded ? offsetsPadded : offsetsUnpadded;
244 uint32_t *dstOffsets = dstPadded ? offsetsPadded : offsetsUnpadded;
245
246 // complex elements, need to copy subelem after subelem
247 for (uint32_t i = 0; i < numItems; i ++) {
248 for (uint32_t fI = 0; fI < fieldCount; fI++) {
249 memcpy(dst + dstOffsets[fI], src + srcOffsets[fI], sizeUnpadded[fI]);
250 }
251 src += srcInc;
252 dst += dstInc;
253 }
254
255 delete[] offsetsPadded;
256 delete[] offsetsUnpadded;
257 delete[] sizeUnpadded;
258}
259
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800260void Allocation::unpackVec3Allocation(const void *data, size_t dataSize) {
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800261 const uint8_t *src = (const uint8_t*)data;
262 uint8_t *dst = (uint8_t*)getPtr();
263
264 writePackedData(getType(), dst, src, true);
265}
266
267void Allocation::packVec3Allocation(OStream *stream) const {
268 uint32_t paddedBytes = getType()->getElement()->getSizeBytes();
269 uint32_t unpaddedBytes = getType()->getElement()->getSizeBytesUnpadded();
270 uint32_t numItems = mHal.state.type->getSizeBytes() / paddedBytes;
271
272 const uint8_t *src = (const uint8_t*)getPtr();
273 uint8_t *dst = new uint8_t[numItems * unpaddedBytes];
274
275 writePackedData(getType(), dst, src, false);
276 stream->addByteArray(dst, getPackedSize());
277
278 delete[] dst;
279}
280
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800281void Allocation::serialize(OStream *stream) const {
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700282 // Need to identify ourselves
283 stream->addU32((uint32_t)getClassId());
284
285 String8 name(getName());
286 stream->addString(&name);
287
288 // First thing we need to serialize is the type object since it will be needed
289 // to initialize the class
Jason Samse4a06c52011-03-16 16:29:28 -0700290 mHal.state.type->serialize(stream);
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700291
Jason Samse4a06c52011-03-16 16:29:28 -0700292 uint32_t dataSize = mHal.state.type->getSizeBytes();
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800293 // 3 element vectors are padded to 4 in memory, but padding isn't serialized
294 uint32_t packedSize = getPackedSize();
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700295 // Write how much data we are storing
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800296 stream->addU32(packedSize);
297 if (dataSize == packedSize) {
298 // Now write the data
299 stream->addByteArray(getPtr(), dataSize);
300 } else {
301 // Now write the data
302 packVec3Allocation(stream);
303 }
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700304}
305
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800306Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) {
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700307 // First make sure we are reading the correct object
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -0700308 RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800309 if (classID != RS_A3D_CLASS_ID_ALLOCATION) {
Steve Block3762c312012-01-06 19:20:56 +0000310 ALOGE("allocation loading skipped due to invalid class id\n");
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700311 return NULL;
312 }
313
314 String8 name;
315 stream->loadString(&name);
316
317 Type *type = Type::createFromStream(rsc, stream);
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800318 if (!type) {
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700319 return NULL;
320 }
321 type->compute();
322
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800323 Allocation *alloc = Allocation::createAllocation(rsc, type, RS_ALLOCATION_USAGE_SCRIPT);
324 type->decUserRef();
325
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700326 // Number of bytes we wrote out for this allocation
327 uint32_t dataSize = stream->loadU32();
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800328 // 3 element vectors are padded to 4 in memory, but padding isn't serialized
329 uint32_t packedSize = alloc->getPackedSize();
330 if (dataSize != type->getSizeBytes() &&
331 dataSize != packedSize) {
Steve Block3762c312012-01-06 19:20:56 +0000332 ALOGE("failed to read allocation because numbytes written is not the same loaded type wants\n");
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800333 ObjectBase::checkDelete(alloc);
Jason Samsb38d5342010-10-21 14:06:55 -0700334 ObjectBase::checkDelete(type);
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700335 return NULL;
336 }
337
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700338 alloc->setName(name.string(), name.size());
339
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800340 if (dataSize == type->getSizeBytes()) {
341 uint32_t count = dataSize / type->getElementSizeBytes();
342 // Read in all of our allocation data
343 alloc->data(rsc, 0, 0, count, stream->getPtr() + stream->getPos(), dataSize);
344 } else {
345 alloc->unpackVec3Allocation(stream->getPtr() + stream->getPos(), dataSize);
346 }
Alex Sakhartchouk2ce0e3f2010-08-11 10:30:44 -0700347 stream->reset(stream->getPos() + dataSize);
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -0700348
349 return alloc;
350}
351
Jason Sams7e8aae72011-05-26 16:33:01 -0700352void Allocation::sendDirty(const Context *rsc) const {
Jason Sams83f1c632009-10-26 15:19:28 -0700353 for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
354 mToDirtyList[ct]->forceDirty();
355 }
Jason Sams7e8aae72011-05-26 16:33:01 -0700356 mRSC->mHal.funcs.allocation.markDirty(rsc, this);
Jason Sams83f1c632009-10-26 15:19:28 -0700357}
Jason Samsd19f10d2009-05-22 14:03:28 -0700358
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800359void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const {
Jason Samsb28ca96f2010-08-09 18:13:33 -0700360 const uint8_t *p = static_cast<const uint8_t *>(ptr);
Jason Samse4a06c52011-03-16 16:29:28 -0700361 const Element *e = mHal.state.type->getElement();
Jason Samsb28ca96f2010-08-09 18:13:33 -0700362 uint32_t stride = e->getSizeBytes();
363
Jason Sams5edc6082010-10-05 13:32:49 -0700364 p += stride * startOff;
Jason Samsb28ca96f2010-08-09 18:13:33 -0700365 while (ct > 0) {
366 e->incRefs(p);
367 ct --;
368 p += stride;
369 }
370}
371
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800372void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const {
Alex Sakhartchouk065fa8d2011-08-12 11:30:30 -0700373 if (!mHal.state.hasReferences || !getIsScript()) {
374 return;
375 }
Jason Samsb28ca96f2010-08-09 18:13:33 -0700376 const uint8_t *p = static_cast<const uint8_t *>(ptr);
Jason Samse4a06c52011-03-16 16:29:28 -0700377 const Element *e = mHal.state.type->getElement();
Jason Samsb28ca96f2010-08-09 18:13:33 -0700378 uint32_t stride = e->getSizeBytes();
379
Jason Sams5edc6082010-10-05 13:32:49 -0700380 p += stride * startOff;
Jason Samsb28ca96f2010-08-09 18:13:33 -0700381 while (ct > 0) {
382 e->decRefs(p);
383 ct --;
384 p += stride;
385 }
386}
387
Jason Sams777ec262011-08-18 18:01:33 -0700388void Allocation::freeChildrenUnlocked () {
389 decRefs(getPtr(), mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes(), 0);
390}
391
392bool Allocation::freeChildren() {
393 if (mHal.state.hasReferences) {
394 incSysRef();
395 freeChildrenUnlocked();
396 return decSysRef();
397 }
398 return false;
399}
400
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800401void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len) {
Jason Sams5edc6082010-10-05 13:32:49 -0700402}
403
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800404void Allocation::resize1D(Context *rsc, uint32_t dimX) {
Jason Samse4a06c52011-03-16 16:29:28 -0700405 uint32_t oldDimX = mHal.state.dimensionX;
Jason Sams5edc6082010-10-05 13:32:49 -0700406 if (dimX == oldDimX) {
407 return;
408 }
409
Alex Sakhartchouk117abdb2011-08-16 13:09:46 -0700410 ObjectBaseRef<Type> t = mHal.state.type->cloneAndResize1D(rsc, dimX);
Jason Sams5edc6082010-10-05 13:32:49 -0700411 if (dimX < oldDimX) {
Jason Sams7e8aae72011-05-26 16:33:01 -0700412 decRefs(getPtr(), oldDimX - dimX, dimX);
Jason Sams5edc6082010-10-05 13:32:49 -0700413 }
Alex Sakhartchouk117abdb2011-08-16 13:09:46 -0700414 rsc->mHal.funcs.allocation.resize(rsc, this, t.get(), mHal.state.hasReferences);
Alex Sakhartchouk5ef2f532011-10-18 10:54:29 -0700415 setType(t.get());
Jason Samse4a06c52011-03-16 16:29:28 -0700416 updateCache();
Jason Sams5edc6082010-10-05 13:32:49 -0700417}
418
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800419void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY) {
Steve Block3762c312012-01-06 19:20:56 +0000420 ALOGE("not implemented");
Jason Sams5edc6082010-10-05 13:32:49 -0700421}
422
Jason Sams615e7ce2012-01-13 14:01:20 -0800423int32_t Allocation::getSurfaceTextureID(const Context *rsc) {
424 int32_t id = rsc->mHal.funcs.allocation.initSurfaceTexture(rsc, this);
425 mHal.state.surfaceTextureID = id;
426 return id;
427}
428
Jason Samsfe1d5ff2012-03-23 11:47:26 -0700429void Allocation::setSurfaceTexture(const Context *rsc, SurfaceTexture *st) {
430 if(st != mHal.state.surfaceTexture) {
431 if(mHal.state.surfaceTexture != NULL) {
432 mHal.state.surfaceTexture->decStrong(NULL);
433 }
434 mHal.state.surfaceTexture = st;
435 if(mHal.state.surfaceTexture != NULL) {
436 mHal.state.surfaceTexture->incStrong(NULL);
437 }
438 }
439}
440
Jason Sams163766c2012-02-15 12:04:24 -0800441void Allocation::setSurface(const Context *rsc, RsNativeWindow sur) {
442 ANativeWindow *nw = (ANativeWindow *)sur;
443 ANativeWindow *old = mHal.state.wndSurface;
444 if (nw) {
445 nw->incStrong(NULL);
446 }
447 rsc->mHal.funcs.allocation.setSurfaceTexture(rsc, this, nw);
448 mHal.state.wndSurface = nw;
449 if (old) {
450 old->decStrong(NULL);
451 }
452}
453
454void Allocation::ioSend(const Context *rsc) {
455 rsc->mHal.funcs.allocation.ioSend(rsc, this);
456}
457
458void Allocation::ioReceive(const Context *rsc) {
459 rsc->mHal.funcs.allocation.ioReceive(rsc, this);
460}
461
462
Jason Samsd19f10d2009-05-22 14:03:28 -0700463/////////////////
Jason Samse2ae85f2009-06-03 16:04:54 -0700464//
Stephen Hines60f9a622011-03-01 17:34:59 -0800465
Jason Samsd19f10d2009-05-22 14:03:28 -0700466namespace android {
467namespace renderscript {
468
Jason Samsc5765372011-04-28 18:26:48 -0700469static void AllocationGenerateScriptMips(RsContext con, RsAllocation va);
470
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800471static void mip565(const Adapter2D &out, const Adapter2D &in) {
Jason Samsd19f10d2009-05-22 14:03:28 -0700472 uint32_t w = out.getDimX();
473 uint32_t h = out.getDimY();
474
Jason Sams6f5c61c2009-07-28 17:20:11 -0700475 for (uint32_t y=0; y < h; y++) {
Jason Samsd19f10d2009-05-22 14:03:28 -0700476 uint16_t *oPtr = static_cast<uint16_t *>(out.getElement(0, y));
477 const uint16_t *i1 = static_cast<uint16_t *>(in.getElement(0, y*2));
478 const uint16_t *i2 = static_cast<uint16_t *>(in.getElement(0, y*2+1));
479
Jason Sams6f5c61c2009-07-28 17:20:11 -0700480 for (uint32_t x=0; x < w; x++) {
Jason Samse2ae85f2009-06-03 16:04:54 -0700481 *oPtr = rsBoxFilter565(i1[0], i1[1], i2[0], i2[1]);
482 oPtr ++;
483 i1 += 2;
484 i2 += 2;
485 }
486 }
487}
488
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800489static void mip8888(const Adapter2D &out, const Adapter2D &in) {
Jason Samse2ae85f2009-06-03 16:04:54 -0700490 uint32_t w = out.getDimX();
491 uint32_t h = out.getDimY();
492
Jason Sams6f5c61c2009-07-28 17:20:11 -0700493 for (uint32_t y=0; y < h; y++) {
Jason Samse2ae85f2009-06-03 16:04:54 -0700494 uint32_t *oPtr = static_cast<uint32_t *>(out.getElement(0, y));
495 const uint32_t *i1 = static_cast<uint32_t *>(in.getElement(0, y*2));
496 const uint32_t *i2 = static_cast<uint32_t *>(in.getElement(0, y*2+1));
497
Jason Sams6f5c61c2009-07-28 17:20:11 -0700498 for (uint32_t x=0; x < w; x++) {
Jason Samse2ae85f2009-06-03 16:04:54 -0700499 *oPtr = rsBoxFilter8888(i1[0], i1[1], i2[0], i2[1]);
Jason Samsd19f10d2009-05-22 14:03:28 -0700500 oPtr ++;
501 i1 += 2;
502 i2 += 2;
503 }
504 }
Jason Samsd19f10d2009-05-22 14:03:28 -0700505}
506
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800507static void mip8(const Adapter2D &out, const Adapter2D &in) {
Jason Samse20e3b42010-01-19 17:53:54 -0800508 uint32_t w = out.getDimX();
509 uint32_t h = out.getDimY();
510
511 for (uint32_t y=0; y < h; y++) {
512 uint8_t *oPtr = static_cast<uint8_t *>(out.getElement(0, y));
513 const uint8_t *i1 = static_cast<uint8_t *>(in.getElement(0, y*2));
514 const uint8_t *i2 = static_cast<uint8_t *>(in.getElement(0, y*2+1));
515
516 for (uint32_t x=0; x < w; x++) {
517 *oPtr = (uint8_t)(((uint32_t)i1[0] + i1[1] + i2[0] + i2[1]) * 0.25f);
518 oPtr ++;
519 i1 += 2;
520 i2 += 2;
521 }
522 }
523}
524
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800525static void mip(const Adapter2D &out, const Adapter2D &in) {
526 switch (out.getBaseType()->getElement()->getSizeBits()) {
Jason Sams6f5c61c2009-07-28 17:20:11 -0700527 case 32:
528 mip8888(out, in);
529 break;
530 case 16:
531 mip565(out, in);
532 break;
Jason Samse20e3b42010-01-19 17:53:54 -0800533 case 8:
534 mip8(out, in);
535 break;
Jason Sams6f5c61c2009-07-28 17:20:11 -0700536 }
Jason Sams6f5c61c2009-07-28 17:20:11 -0700537}
Jason Samsd19f10d2009-05-22 14:03:28 -0700538
Jason Sams5476b452010-12-08 16:14:36 -0800539void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType src) {
540 Allocation *a = static_cast<Allocation *>(va);
Jason Sams7e8aae72011-05-26 16:33:01 -0700541 a->sendDirty(rsc);
Jason Sams5476b452010-12-08 16:14:36 -0800542 a->syncAll(rsc, src);
543}
544
Jason Samsf7086092011-01-12 13:28:37 -0800545void rsi_AllocationGenerateMipmaps(Context *rsc, RsAllocation va) {
Alex Sakhartchouk26ae3902010-10-11 12:35:15 -0700546 Allocation *texAlloc = static_cast<Allocation *>(va);
Jason Samsc5765372011-04-28 18:26:48 -0700547 AllocationGenerateScriptMips(rsc, texAlloc);
Jason Sams4ef66502010-12-10 16:03:15 -0800548}
549
550void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) {
551 Allocation *texAlloc = static_cast<Allocation *>(va);
552 const Type * t = texAlloc->getType();
553
554 size_t s = t->getDimX() * t->getDimY() * t->getElementSizeBytes();
555 if (s != dataLen) {
556 rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size");
557 return;
558 }
559
560 memcpy(data, texAlloc->getPtr(), s);
Alex Sakhartchouk26ae3902010-10-11 12:35:15 -0700561}
562
Jason Sams49a05d72010-12-29 14:31:29 -0800563void rsi_Allocation1DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t lod,
Alex Sakhartchouk17a8a192011-06-03 10:18:01 -0700564 uint32_t count, const void *data, size_t sizeBytes) {
Jason Samsd19f10d2009-05-22 14:03:28 -0700565 Allocation *a = static_cast<Allocation *>(va);
Jason Sams49a05d72010-12-29 14:31:29 -0800566 a->data(rsc, xoff, lod, count, data, sizeBytes);
Jason Samsd19f10d2009-05-22 14:03:28 -0700567}
568
Jason Sams49a05d72010-12-29 14:31:29 -0800569void rsi_Allocation2DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, uint32_t lod, RsAllocationCubemapFace face,
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800570 const void *data, size_t sizeBytes, size_t eoff) {
Jason Samsd19f10d2009-05-22 14:03:28 -0700571 Allocation *a = static_cast<Allocation *>(va);
Jason Sams49a05d72010-12-29 14:31:29 -0800572 a->elementData(rsc, x, y, data, eoff, sizeBytes);
Jason Sams49bdaf02010-08-31 13:50:42 -0700573}
574
Jason Sams49a05d72010-12-29 14:31:29 -0800575void rsi_Allocation1DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t lod,
Stephen Hines4cbe25a2012-01-18 18:46:27 -0800576 const void *data, size_t sizeBytes, size_t eoff) {
Jason Sams49bdaf02010-08-31 13:50:42 -0700577 Allocation *a = static_cast<Allocation *>(va);
Jason Sams49a05d72010-12-29 14:31:29 -0800578 a->elementData(rsc, x, data, eoff, sizeBytes);
Jason Sams49bdaf02010-08-31 13:50:42 -0700579}
580
Jason Sams49a05d72010-12-29 14:31:29 -0800581void rsi_Allocation2DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
Alex Sakhartchouk17a8a192011-06-03 10:18:01 -0700582 uint32_t w, uint32_t h, const void *data, size_t sizeBytes) {
Jason Sams49bdaf02010-08-31 13:50:42 -0700583 Allocation *a = static_cast<Allocation *>(va);
Jason Sams49a05d72010-12-29 14:31:29 -0800584 a->data(rsc, xoff, yoff, lod, face, w, h, data, sizeBytes);
Jason Samsd19f10d2009-05-22 14:03:28 -0700585}
586
Alex Sakhartchouke7c4a752011-04-06 10:57:51 -0700587void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data, size_t data_length) {
Jason Sams40a29e82009-08-10 14:55:26 -0700588 Allocation *a = static_cast<Allocation *>(va);
589 a->read(data);
590}
591
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800592void rsi_AllocationResize1D(Context *rsc, RsAllocation va, uint32_t dimX) {
Jason Sams5edc6082010-10-05 13:32:49 -0700593 Allocation *a = static_cast<Allocation *>(va);
594 a->resize1D(rsc, dimX);
595}
596
Alex Sakhartchouked9f2102010-11-09 17:00:54 -0800597void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32_t dimY) {
Jason Sams5edc6082010-10-05 13:32:49 -0700598 Allocation *a = static_cast<Allocation *>(va);
599 a->resize2D(rsc, dimX, dimY);
600}
601
Jason Samsc5765372011-04-28 18:26:48 -0700602static void AllocationGenerateScriptMips(RsContext con, RsAllocation va) {
Alex Sakhartchoukdcc23192011-01-11 14:47:44 -0800603 Context *rsc = static_cast<Context *>(con);
604 Allocation *texAlloc = static_cast<Allocation *>(va);
605 uint32_t numFaces = texAlloc->getType()->getDimFaces() ? 6 : 1;
606 for (uint32_t face = 0; face < numFaces; face ++) {
607 Adapter2D adapt(rsc, texAlloc);
608 Adapter2D adapt2(rsc, texAlloc);
609 adapt.setFace(face);
610 adapt2.setFace(face);
611 for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
612 adapt.setLOD(lod);
613 adapt2.setLOD(lod + 1);
614 mip(adapt2, adapt);
615 }
616 }
617}
618
Jason Samsc5765372011-04-28 18:26:48 -0700619RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype,
620 RsAllocationMipmapControl mips,
Jason Sams857d0c72011-11-23 15:02:15 -0800621 uint32_t usages, uint32_t ptr) {
622 Allocation * alloc = Allocation::createAllocation(rsc, static_cast<Type *>(vtype), usages, mips, (void *)ptr);
Jason Sams7e8aae72011-05-26 16:33:01 -0700623 if (!alloc) {
624 return NULL;
625 }
Jason Sams31a7e422010-10-26 13:09:17 -0700626 alloc->incUserRef();
627 return alloc;
628}
629
Jason Samsc5765372011-04-28 18:26:48 -0700630RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, RsType vtype,
631 RsAllocationMipmapControl mips,
632 const void *data, size_t data_length, uint32_t usages) {
Jason Sams5476b452010-12-08 16:14:36 -0800633 Type *t = static_cast<Type *>(vtype);
Jason Sams31a7e422010-10-26 13:09:17 -0700634
Jason Sams857d0c72011-11-23 15:02:15 -0800635 RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages, 0);
Jason Sams31a7e422010-10-26 13:09:17 -0700636 Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
637 if (texAlloc == NULL) {
Steve Block3762c312012-01-06 19:20:56 +0000638 ALOGE("Memory allocation failure");
Jason Sams31a7e422010-10-26 13:09:17 -0700639 return NULL;
640 }
641
Jason Sams5476b452010-12-08 16:14:36 -0800642 memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes());
Jason Samsd4b23b52010-12-13 15:32:35 -0800643 if (mips == RS_ALLOCATION_MIPMAP_FULL) {
Jason Samsc5765372011-04-28 18:26:48 -0700644 AllocationGenerateScriptMips(rsc, texAlloc);
Jason Sams31a7e422010-10-26 13:09:17 -0700645 }
646
Jason Sams7e8aae72011-05-26 16:33:01 -0700647 texAlloc->sendDirty(rsc);
Jason Sams31a7e422010-10-26 13:09:17 -0700648 return texAlloc;
649}
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800650
Jason Samsc5765372011-04-28 18:26:48 -0700651RsAllocation rsi_AllocationCubeCreateFromBitmap(Context *rsc, RsType vtype,
652 RsAllocationMipmapControl mips,
653 const void *data, size_t data_length, uint32_t usages) {
Jason Sams5476b452010-12-08 16:14:36 -0800654 Type *t = static_cast<Type *>(vtype);
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800655
656 // Cubemap allocation's faces should be Width by Width each.
657 // Source data should have 6 * Width by Width pixels
658 // Error checking is done in the java layer
Jason Sams857d0c72011-11-23 15:02:15 -0800659 RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages, 0);
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800660 Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
661 if (texAlloc == NULL) {
Steve Block3762c312012-01-06 19:20:56 +0000662 ALOGE("Memory allocation failure");
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800663 return NULL;
664 }
665
Alex Sakhartchoukfe852e22011-01-10 15:57:57 -0800666 uint32_t faceSize = t->getDimX();
667 uint32_t strideBytes = faceSize * 6 * t->getElementSizeBytes();
668 uint32_t copySize = faceSize * t->getElementSizeBytes();
669
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800670 uint8_t *sourcePtr = (uint8_t*)data;
Jason Sams5476b452010-12-08 16:14:36 -0800671 for (uint32_t face = 0; face < 6; face ++) {
672 Adapter2D faceAdapter(rsc, texAlloc);
673 faceAdapter.setFace(face);
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800674
Alex Sakhartchoukfe852e22011-01-10 15:57:57 -0800675 for (uint32_t dI = 0; dI < faceSize; dI ++) {
676 memcpy(faceAdapter.getElement(0, dI), sourcePtr + strideBytes * dI, copySize);
677 }
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800678
Jason Sams5476b452010-12-08 16:14:36 -0800679 // Move the data pointer to the next cube face
Alex Sakhartchoukfe852e22011-01-10 15:57:57 -0800680 sourcePtr += copySize;
Alex Sakhartchoukdcc23192011-01-11 14:47:44 -0800681 }
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800682
Alex Sakhartchoukdcc23192011-01-11 14:47:44 -0800683 if (mips == RS_ALLOCATION_MIPMAP_FULL) {
Jason Samsc5765372011-04-28 18:26:48 -0700684 AllocationGenerateScriptMips(rsc, texAlloc);
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800685 }
686
Jason Sams7e8aae72011-05-26 16:33:01 -0700687 texAlloc->sendDirty(rsc);
Alex Sakhartchouk67f2e442010-11-18 15:22:43 -0800688 return texAlloc;
689}
Alex Sakhartchouka3b59602011-01-28 09:31:47 -0800690
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700691void rsi_AllocationCopy2DRange(Context *rsc,
692 RsAllocation dstAlloc,
693 uint32_t dstXoff, uint32_t dstYoff,
694 uint32_t dstMip, uint32_t dstFace,
695 uint32_t width, uint32_t height,
696 RsAllocation srcAlloc,
697 uint32_t srcXoff, uint32_t srcYoff,
698 uint32_t srcMip, uint32_t srcFace) {
699 Allocation *dst = static_cast<Allocation *>(dstAlloc);
700 Allocation *src= static_cast<Allocation *>(srcAlloc);
701 rsc->mHal.funcs.allocation.allocData2D(rsc, dst, dstXoff, dstYoff, dstMip,
702 (RsAllocationCubemapFace)dstFace,
703 width, height,
704 src, srcXoff, srcYoff,srcMip,
705 (RsAllocationCubemapFace)srcFace);
706}
707
Jason Sams615e7ce2012-01-13 14:01:20 -0800708int32_t rsi_AllocationGetSurfaceTextureID(Context *rsc, RsAllocation valloc) {
709 Allocation *alloc = static_cast<Allocation *>(valloc);
710 return alloc->getSurfaceTextureID(rsc);
711}
712
Jason Samsfe1d5ff2012-03-23 11:47:26 -0700713void rsi_AllocationGetSurfaceTextureID2(Context *rsc, RsAllocation valloc, void *vst, size_t len) {
714 Allocation *alloc = static_cast<Allocation *>(valloc);
715 alloc->setSurfaceTexture(rsc, static_cast<SurfaceTexture *>(vst));
716}
717
Jason Sams163766c2012-02-15 12:04:24 -0800718void rsi_AllocationSetSurface(Context *rsc, RsAllocation valloc, RsNativeWindow sur) {
719 Allocation *alloc = static_cast<Allocation *>(valloc);
720 alloc->setSurface(rsc, sur);
721}
722
723void rsi_AllocationIoSend(Context *rsc, RsAllocation valloc) {
724 Allocation *alloc = static_cast<Allocation *>(valloc);
725 alloc->ioSend(rsc);
726}
727
728void rsi_AllocationIoReceive(Context *rsc, RsAllocation valloc) {
729 Allocation *alloc = static_cast<Allocation *>(valloc);
730 alloc->ioReceive(rsc);
731}
732
Jason Samsc5765372011-04-28 18:26:48 -0700733}
734}
735
736const void * rsaAllocationGetType(RsContext con, RsAllocation va) {
737 Allocation *a = static_cast<Allocation *>(va);
738 a->getType()->incUserRef();
739
740 return a->getType();
741}