Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | */ |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 16 | #ifndef ANDROID_RS_BUILD_FOR_HOST |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 17 | #include "rsContext.h" |
| 18 | |
Jason Sams | 4b962e5 | 2009-06-22 17:15:15 -0700 | [diff] [blame] | 19 | #include <GLES/gl.h> |
Jason Sams | c2908e6 | 2010-02-23 17:44:28 -0800 | [diff] [blame] | 20 | #include <GLES2/gl2.h> |
Jason Sams | 4b962e5 | 2009-06-22 17:15:15 -0700 | [diff] [blame] | 21 | #include <GLES/glext.h> |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 22 | #else |
| 23 | #include "rsContextHostStub.h" |
| 24 | |
| 25 | #include <OpenGL/gl.h> |
| 26 | #include <OpenGl/glext.h> |
| 27 | #endif |
Jason Sams | 4b962e5 | 2009-06-22 17:15:15 -0700 | [diff] [blame] | 28 | |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 29 | #include "utils/StopWatch.h" |
| 30 | |
Alex Sakhartchouk | dcc2319 | 2011-01-11 14:47:44 -0800 | [diff] [blame] | 31 | static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va); |
| 32 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 33 | using namespace android; |
| 34 | using namespace android::renderscript; |
| 35 | |
Alex Sakhartchouk | 0857196 | 2010-12-15 09:59:58 -0800 | [diff] [blame] | 36 | Allocation::Allocation(Context *rsc, const Type *type, uint32_t usages, |
| 37 | RsAllocationMipmapControl mc) |
| 38 | : ObjectBase(rsc) { |
Jason Sams | 8a64743f | 2010-03-01 15:31:04 -0800 | [diff] [blame] | 39 | init(rsc, type); |
| 40 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 41 | mUsageFlags = usages; |
Alex Sakhartchouk | 0857196 | 2010-12-15 09:59:58 -0800 | [diff] [blame] | 42 | mMipmapControl = mc; |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 43 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 44 | allocScriptMemory(); |
Jason Sams | ee73498 | 2010-08-12 12:44:02 -0700 | [diff] [blame] | 45 | if (mType->getElement()->getHasReferences()) { |
| 46 | memset(mPtr, 0, mType->getSizeBytes()); |
| 47 | } |
Jason Sams | 8a64743f | 2010-03-01 15:31:04 -0800 | [diff] [blame] | 48 | if (!mPtr) { |
| 49 | LOGE("Allocation::Allocation, alloc failure"); |
| 50 | } |
| 51 | } |
| 52 | |
Jason Sams | 8a64743f | 2010-03-01 15:31:04 -0800 | [diff] [blame] | 53 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 54 | void Allocation::init(Context *rsc, const Type *type) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 55 | mPtr = NULL; |
| 56 | |
| 57 | mCpuWrite = false; |
| 58 | mCpuRead = false; |
| 59 | mGpuWrite = false; |
| 60 | mGpuRead = false; |
| 61 | |
| 62 | mReadWriteRatio = 0; |
| 63 | mUpdateSize = 0; |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 64 | mUsageFlags = 0; |
| 65 | mMipmapControl = RS_ALLOCATION_MIPMAP_NONE; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 66 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 67 | mTextureID = 0; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 68 | mBufferID = 0; |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 69 | mUploadDefered = false; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 70 | |
Jason Sams | 8a64743f | 2010-03-01 15:31:04 -0800 | [diff] [blame] | 71 | mUserBitmapCallback = NULL; |
| 72 | mUserBitmapCallbackData = NULL; |
| 73 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 74 | mType.set(type); |
Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 75 | rsAssert(type); |
Jason Sams | 8a64743f | 2010-03-01 15:31:04 -0800 | [diff] [blame] | 76 | |
| 77 | mPtr = NULL; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 80 | Allocation::~Allocation() { |
Jason Sams | 8a64743f | 2010-03-01 15:31:04 -0800 | [diff] [blame] | 81 | if (mUserBitmapCallback != NULL) { |
| 82 | mUserBitmapCallback(mUserBitmapCallbackData); |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 83 | mPtr = NULL; |
Jason Sams | 8a64743f | 2010-03-01 15:31:04 -0800 | [diff] [blame] | 84 | } |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 85 | freeScriptMemory(); |
Jason Sams | 9d5e03d | 2009-11-03 11:25:42 -0800 | [diff] [blame] | 86 | |
| 87 | if (mBufferID) { |
| 88 | // Causes a SW crash.... |
| 89 | //LOGV(" mBufferID %i", mBufferID); |
| 90 | //glDeleteBuffers(1, &mBufferID); |
| 91 | //mBufferID = 0; |
| 92 | } |
| 93 | if (mTextureID) { |
| 94 | glDeleteTextures(1, &mTextureID); |
| 95 | mTextureID = 0; |
| 96 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 99 | void Allocation::setCpuWritable(bool) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 102 | void Allocation::setGpuWritable(bool) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 105 | void Allocation::setCpuReadable(bool) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 108 | void Allocation::setGpuReadable(bool) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 111 | bool Allocation::fixAllocation() { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 112 | return false; |
| 113 | } |
| 114 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 115 | void Allocation::deferedUploadToTexture(const Context *rsc) { |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 116 | mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 117 | mUploadDefered = true; |
| 118 | } |
| 119 | |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 120 | uint32_t Allocation::getGLTarget() const { |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 121 | if (getIsTexture()) { |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 122 | if (mType->getDimFaces()) { |
| 123 | return GL_TEXTURE_CUBE_MAP; |
| 124 | } else { |
| 125 | return GL_TEXTURE_2D; |
| 126 | } |
| 127 | } |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 128 | if (getIsBufferObject()) { |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 129 | return GL_ARRAY_BUFFER; |
| 130 | } |
| 131 | return 0; |
| 132 | } |
| 133 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 134 | void Allocation::allocScriptMemory() { |
| 135 | rsAssert(!mPtr); |
| 136 | mPtr = malloc(mType->getSizeBytes()); |
| 137 | } |
| 138 | |
| 139 | void Allocation::freeScriptMemory() { |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 140 | if (mPtr) { |
| 141 | free(mPtr); |
| 142 | mPtr = NULL; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 147 | void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) { |
| 148 | rsAssert(src == RS_ALLOCATION_USAGE_SCRIPT); |
| 149 | |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 150 | if (getIsTexture()) { |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 151 | uploadToTexture(rsc); |
| 152 | } |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 153 | if (getIsBufferObject()) { |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 154 | uploadToBufferObject(rsc); |
| 155 | } |
| 156 | |
| 157 | mUploadDefered = false; |
| 158 | } |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 159 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 160 | void Allocation::uploadToTexture(const Context *rsc) { |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 161 | |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 162 | mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 163 | GLenum type = mType->getElement()->getComponent().getGLType(); |
| 164 | GLenum format = mType->getElement()->getComponent().getGLFormat(); |
Jason Sams | e2ae85f | 2009-06-03 16:04:54 -0700 | [diff] [blame] | 165 | |
| 166 | if (!type || !format) { |
| 167 | return; |
| 168 | } |
| 169 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 170 | if (!mPtr) { |
| 171 | return; |
| 172 | } |
| 173 | |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 174 | bool isFirstUpload = false; |
| 175 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 176 | if (!mTextureID) { |
| 177 | glGenTextures(1, &mTextureID); |
Jason Sams | 9dab667 | 2009-11-24 12:26:35 -0800 | [diff] [blame] | 178 | |
| 179 | if (!mTextureID) { |
| 180 | // This should not happen, however, its likely the cause of the |
| 181 | // white sqare bug. |
| 182 | // Force a crash to 1: restart the app, 2: make sure we get a bugreport. |
| 183 | LOGE("Upload to texture failed to gen mTextureID"); |
| 184 | rsc->dumpDebug(); |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 185 | mUploadDefered = true; |
| 186 | return; |
Jason Sams | 9dab667 | 2009-11-24 12:26:35 -0800 | [diff] [blame] | 187 | } |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 188 | isFirstUpload = true; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 189 | } |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 190 | |
| 191 | GLenum target = (GLenum)getGLTarget(); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 192 | if (target == GL_TEXTURE_2D) { |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 193 | upload2DTexture(isFirstUpload, mPtr); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 194 | } else if (target == GL_TEXTURE_CUBE_MAP) { |
| 195 | uploadCubeTexture(isFirstUpload); |
| 196 | } |
| 197 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 198 | if (!(mUsageFlags & RS_ALLOCATION_USAGE_SCRIPT)) { |
| 199 | freeScriptMemory(); |
| 200 | } |
| 201 | |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 202 | rsc->checkError("Allocation::uploadToTexture"); |
| 203 | } |
| 204 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 205 | void Allocation::upload2DTexture(bool isFirstUpload, const void *ptr) { |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 206 | GLenum type = mType->getElement()->getComponent().getGLType(); |
| 207 | GLenum format = mType->getElement()->getComponent().getGLFormat(); |
| 208 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 209 | GLenum target = (GLenum)getGLTarget(); |
| 210 | glBindTexture(target, mTextureID); |
| 211 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 212 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 213 | for (uint32_t lod = 0; lod < mType->getLODCount(); lod++) { |
| 214 | const uint8_t *p = (const uint8_t *)ptr; |
| 215 | p += mType->getLODOffset(lod); |
| 216 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 217 | if (isFirstUpload) { |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 218 | glTexImage2D(GL_TEXTURE_2D, lod, format, |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 219 | mType->getLODDimX(lod), mType->getLODDimY(lod), |
| 220 | 0, format, type, p); |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 221 | } else { |
| 222 | glTexSubImage2D(GL_TEXTURE_2D, lod, 0, 0, |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 223 | mType->getLODDimX(lod), mType->getLODDimY(lod), |
| 224 | format, type, p); |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 225 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 226 | } |
Jason Sams | 6d8eb26 | 2010-12-15 01:41:00 -0800 | [diff] [blame] | 227 | |
| 228 | if (mMipmapControl == RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE) { |
| 229 | #ifndef ANDROID_RS_BUILD_FOR_HOST |
| 230 | glGenerateMipmap(target); |
| 231 | #endif //ANDROID_RS_BUILD_FOR_HOST |
| 232 | } |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 233 | } |
Jason Sams | c2908e6 | 2010-02-23 17:44:28 -0800 | [diff] [blame] | 234 | |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 235 | void Allocation::uploadCubeTexture(bool isFirstUpload) { |
| 236 | GLenum type = mType->getElement()->getComponent().getGLType(); |
| 237 | GLenum format = mType->getElement()->getComponent().getGLFormat(); |
| 238 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 239 | GLenum target = (GLenum)getGLTarget(); |
| 240 | glBindTexture(target, mTextureID); |
| 241 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 242 | |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 243 | GLenum faceOrder[] = { |
| 244 | GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
| 245 | GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
| 246 | GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
| 247 | GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, |
| 248 | GL_TEXTURE_CUBE_MAP_POSITIVE_Z, |
| 249 | GL_TEXTURE_CUBE_MAP_NEGATIVE_Z |
| 250 | }; |
| 251 | |
| 252 | Adapter2D adapt(getContext(), this); |
| 253 | for (uint32_t face = 0; face < 6; face ++) { |
| 254 | adapt.setFace(face); |
| 255 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 256 | for (uint32_t lod = 0; lod < mType->getLODCount(); lod++) { |
| 257 | adapt.setLOD(lod); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 258 | |
| 259 | uint16_t * ptr = static_cast<uint16_t *>(adapt.getElement(0,0)); |
| 260 | |
| 261 | if (isFirstUpload) { |
| 262 | glTexImage2D(faceOrder[face], lod, format, |
| 263 | adapt.getDimX(), adapt.getDimY(), |
| 264 | 0, format, type, ptr); |
| 265 | } else { |
| 266 | glTexSubImage2D(faceOrder[face], lod, 0, 0, |
| 267 | adapt.getDimX(), adapt.getDimY(), |
| 268 | format, type, ptr); |
| 269 | } |
| 270 | } |
| 271 | } |
Jason Sams | 6d8eb26 | 2010-12-15 01:41:00 -0800 | [diff] [blame] | 272 | |
| 273 | if (mMipmapControl == RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE) { |
| 274 | #ifndef ANDROID_RS_BUILD_FOR_HOST |
| 275 | glGenerateMipmap(target); |
| 276 | #endif //ANDROID_RS_BUILD_FOR_HOST |
| 277 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 280 | void Allocation::deferedUploadToBufferObject(const Context *rsc) { |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 281 | mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_VERTEX; |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 282 | mUploadDefered = true; |
| 283 | } |
| 284 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 285 | void Allocation::uploadToBufferObject(const Context *rsc) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 286 | rsAssert(!mType->getDimY()); |
| 287 | rsAssert(!mType->getDimZ()); |
| 288 | |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 289 | mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_VERTEX; |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 290 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 291 | if (!mBufferID) { |
| 292 | glGenBuffers(1, &mBufferID); |
| 293 | } |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 294 | if (!mBufferID) { |
| 295 | LOGE("Upload to buffer object failed"); |
| 296 | mUploadDefered = true; |
| 297 | return; |
| 298 | } |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 299 | GLenum target = (GLenum)getGLTarget(); |
| 300 | glBindBuffer(target, mBufferID); |
| 301 | glBufferData(target, mType->getSizeBytes(), getPtr(), GL_DYNAMIC_DRAW); |
| 302 | glBindBuffer(target, 0); |
Jason Sams | f468700 | 2010-03-10 17:30:41 -0800 | [diff] [blame] | 303 | rsc->checkError("Allocation::uploadToBufferObject"); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 306 | void Allocation::uploadCheck(Context *rsc) { |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 307 | if (mUploadDefered) { |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 308 | syncAll(rsc, RS_ALLOCATION_USAGE_SCRIPT); |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 312 | void Allocation::read(void *data) { |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 313 | memcpy(data, mPtr, mType->getSizeBytes()); |
| 314 | } |
| 315 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 316 | void Allocation::data(Context *rsc, uint32_t xoff, uint32_t lod, |
| 317 | uint32_t count, const void *data, uint32_t sizeBytes) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 318 | uint32_t eSize = mType->getElementSizeBytes(); |
| 319 | uint8_t * ptr = static_cast<uint8_t *>(mPtr); |
| 320 | ptr += eSize * xoff; |
Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 321 | uint32_t size = count * eSize; |
| 322 | |
| 323 | if (size != sizeBytes) { |
| 324 | LOGE("Allocation::subData called with mismatched size expected %i, got %i", size, sizeBytes); |
Jason Sams | 3c0dfba | 2009-09-27 17:50:38 -0700 | [diff] [blame] | 325 | mType->dumpLOGV("type info"); |
Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 326 | return; |
| 327 | } |
Jason Sams | b28ca96f | 2010-08-09 18:13:33 -0700 | [diff] [blame] | 328 | |
| 329 | if (mType->getElement()->getHasReferences()) { |
| 330 | incRefs(data, count); |
| 331 | decRefs(ptr, count); |
| 332 | } |
| 333 | |
Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 334 | memcpy(ptr, data, size); |
Jason Sams | 83f1c63 | 2009-10-26 15:19:28 -0700 | [diff] [blame] | 335 | sendDirty(); |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 336 | mUploadDefered = true; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 337 | } |
| 338 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 339 | void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 340 | uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 341 | uint32_t eSize = mType->getElementSizeBytes(); |
| 342 | uint32_t lineSize = eSize * w; |
| 343 | uint32_t destW = mType->getDimX(); |
| 344 | |
| 345 | const uint8_t *src = static_cast<const uint8_t *>(data); |
| 346 | uint8_t *dst = static_cast<uint8_t *>(mPtr); |
| 347 | dst += eSize * (xoff + yoff * destW); |
Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 348 | |
| 349 | if ((lineSize * eSize * h) != sizeBytes) { |
| 350 | rsAssert(!"Allocation::subData called with mismatched size"); |
| 351 | return; |
| 352 | } |
| 353 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 354 | for (uint32_t line=yoff; line < (yoff+h); line++) { |
Jason Sams | b28ca96f | 2010-08-09 18:13:33 -0700 | [diff] [blame] | 355 | if (mType->getElement()->getHasReferences()) { |
| 356 | incRefs(src, w); |
| 357 | decRefs(dst, w); |
| 358 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 359 | memcpy(dst, src, lineSize); |
| 360 | src += lineSize; |
| 361 | dst += destW * eSize; |
| 362 | } |
Jason Sams | 83f1c63 | 2009-10-26 15:19:28 -0700 | [diff] [blame] | 363 | sendDirty(); |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 364 | mUploadDefered = true; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 367 | void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, RsAllocationCubemapFace face, |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 368 | uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 369 | } |
| 370 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 371 | void Allocation::elementData(Context *rsc, uint32_t x, const void *data, |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 372 | uint32_t cIdx, uint32_t sizeBytes) { |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 373 | uint32_t eSize = mType->getElementSizeBytes(); |
| 374 | uint8_t * ptr = static_cast<uint8_t *>(mPtr); |
| 375 | ptr += eSize * x; |
| 376 | |
| 377 | if (cIdx >= mType->getElement()->getFieldCount()) { |
| 378 | LOGE("Error Allocation::subElementData component %i out of range.", cIdx); |
| 379 | rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range."); |
| 380 | return; |
| 381 | } |
| 382 | |
| 383 | if (x >= mType->getDimX()) { |
| 384 | LOGE("Error Allocation::subElementData X offset %i out of range.", x); |
| 385 | rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range."); |
| 386 | return; |
| 387 | } |
| 388 | |
| 389 | const Element * e = mType->getElement()->getField(cIdx); |
| 390 | ptr += mType->getElement()->getFieldOffsetBytes(cIdx); |
| 391 | |
| 392 | if (sizeBytes != e->getSizeBytes()) { |
| 393 | LOGE("Error Allocation::subElementData data size %i does not match field size %i.", sizeBytes, e->getSizeBytes()); |
| 394 | rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size."); |
| 395 | return; |
| 396 | } |
| 397 | |
| 398 | if (e->getHasReferences()) { |
| 399 | e->incRefs(data); |
| 400 | e->decRefs(ptr); |
| 401 | } |
| 402 | |
| 403 | memcpy(ptr, data, sizeBytes); |
| 404 | sendDirty(); |
| 405 | mUploadDefered = true; |
| 406 | } |
| 407 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 408 | void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 409 | const void *data, uint32_t cIdx, uint32_t sizeBytes) { |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 410 | uint32_t eSize = mType->getElementSizeBytes(); |
| 411 | uint8_t * ptr = static_cast<uint8_t *>(mPtr); |
| 412 | ptr += eSize * (x + y * mType->getDimX()); |
| 413 | |
| 414 | if (x >= mType->getDimX()) { |
| 415 | LOGE("Error Allocation::subElementData X offset %i out of range.", x); |
| 416 | rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range."); |
| 417 | return; |
| 418 | } |
| 419 | |
| 420 | if (y >= mType->getDimY()) { |
| 421 | LOGE("Error Allocation::subElementData X offset %i out of range.", x); |
| 422 | rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range."); |
| 423 | return; |
| 424 | } |
| 425 | |
| 426 | if (cIdx >= mType->getElement()->getFieldCount()) { |
| 427 | LOGE("Error Allocation::subElementData component %i out of range.", cIdx); |
| 428 | rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range."); |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | const Element * e = mType->getElement()->getField(cIdx); |
| 433 | ptr += mType->getElement()->getFieldOffsetBytes(cIdx); |
| 434 | |
| 435 | if (sizeBytes != e->getSizeBytes()) { |
| 436 | LOGE("Error Allocation::subElementData data size %i does not match field size %i.", sizeBytes, e->getSizeBytes()); |
| 437 | rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size."); |
| 438 | return; |
| 439 | } |
| 440 | |
| 441 | if (e->getHasReferences()) { |
| 442 | e->incRefs(data); |
| 443 | e->decRefs(ptr); |
| 444 | } |
| 445 | |
| 446 | memcpy(ptr, data, sizeBytes); |
| 447 | sendDirty(); |
| 448 | mUploadDefered = true; |
| 449 | } |
| 450 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 451 | void Allocation::addProgramToDirty(const Program *p) { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 452 | mToDirtyList.push(p); |
Jason Sams | 83f1c63 | 2009-10-26 15:19:28 -0700 | [diff] [blame] | 453 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 454 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 455 | void Allocation::removeProgramToDirty(const Program *p) { |
Jason Sams | 83f1c63 | 2009-10-26 15:19:28 -0700 | [diff] [blame] | 456 | for (size_t ct=0; ct < mToDirtyList.size(); ct++) { |
| 457 | if (mToDirtyList[ct] == p) { |
| 458 | mToDirtyList.removeAt(ct); |
| 459 | return; |
| 460 | } |
| 461 | } |
| 462 | rsAssert(0); |
| 463 | } |
| 464 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 465 | void Allocation::dumpLOGV(const char *prefix) const { |
Jason Sams | 715333b | 2009-11-17 17:26:46 -0800 | [diff] [blame] | 466 | ObjectBase::dumpLOGV(prefix); |
| 467 | |
| 468 | String8 s(prefix); |
| 469 | s.append(" type "); |
| 470 | if (mType.get()) { |
| 471 | mType->dumpLOGV(s.string()); |
| 472 | } |
| 473 | |
| 474 | LOGV("%s allocation ptr=%p mCpuWrite=%i, mCpuRead=%i, mGpuWrite=%i, mGpuRead=%i", |
| 475 | prefix, mPtr, mCpuWrite, mCpuRead, mGpuWrite, mGpuRead); |
| 476 | |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 477 | LOGV("%s allocation mUsageFlags=0x04%x, mMipmapControl=0x%04x, mTextureID=%i, mBufferID=%i", |
| 478 | prefix, mUsageFlags, mMipmapControl, mTextureID, mBufferID); |
Jason Sams | 715333b | 2009-11-17 17:26:46 -0800 | [diff] [blame] | 479 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 480 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 481 | void Allocation::serialize(OStream *stream) const { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 482 | // Need to identify ourselves |
| 483 | stream->addU32((uint32_t)getClassId()); |
| 484 | |
| 485 | String8 name(getName()); |
| 486 | stream->addString(&name); |
| 487 | |
| 488 | // First thing we need to serialize is the type object since it will be needed |
| 489 | // to initialize the class |
| 490 | mType->serialize(stream); |
| 491 | |
| 492 | uint32_t dataSize = mType->getSizeBytes(); |
| 493 | // Write how much data we are storing |
| 494 | stream->addU32(dataSize); |
| 495 | // Now write the data |
| 496 | stream->addByteArray(mPtr, dataSize); |
| 497 | } |
| 498 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 499 | Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 500 | // First make sure we are reading the correct object |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 501 | RsA3DClassID classID = (RsA3DClassID)stream->loadU32(); |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 502 | if (classID != RS_A3D_CLASS_ID_ALLOCATION) { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 503 | LOGE("allocation loading skipped due to invalid class id\n"); |
| 504 | return NULL; |
| 505 | } |
| 506 | |
| 507 | String8 name; |
| 508 | stream->loadString(&name); |
| 509 | |
| 510 | Type *type = Type::createFromStream(rsc, stream); |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 511 | if (!type) { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 512 | return NULL; |
| 513 | } |
| 514 | type->compute(); |
| 515 | |
| 516 | // Number of bytes we wrote out for this allocation |
| 517 | uint32_t dataSize = stream->loadU32(); |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 518 | if (dataSize != type->getSizeBytes()) { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 519 | LOGE("failed to read allocation because numbytes written is not the same loaded type wants\n"); |
Jason Sams | b38d534 | 2010-10-21 14:06:55 -0700 | [diff] [blame] | 520 | ObjectBase::checkDelete(type); |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 521 | return NULL; |
| 522 | } |
| 523 | |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 524 | Allocation *alloc = new Allocation(rsc, type, RS_ALLOCATION_USAGE_SCRIPT); |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 525 | alloc->setName(name.string(), name.size()); |
| 526 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 527 | uint32_t count = dataSize / type->getElementSizeBytes(); |
| 528 | |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 529 | // Read in all of our allocation data |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 530 | alloc->data(rsc, 0, 0, count, stream->getPtr() + stream->getPos(), dataSize); |
Alex Sakhartchouk | 2ce0e3f | 2010-08-11 10:30:44 -0700 | [diff] [blame] | 531 | stream->reset(stream->getPos() + dataSize); |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 532 | |
| 533 | return alloc; |
| 534 | } |
| 535 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 536 | void Allocation::sendDirty() const { |
Jason Sams | 83f1c63 | 2009-10-26 15:19:28 -0700 | [diff] [blame] | 537 | for (size_t ct=0; ct < mToDirtyList.size(); ct++) { |
| 538 | mToDirtyList[ct]->forceDirty(); |
| 539 | } |
| 540 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 541 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 542 | void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const { |
Jason Sams | b28ca96f | 2010-08-09 18:13:33 -0700 | [diff] [blame] | 543 | const uint8_t *p = static_cast<const uint8_t *>(ptr); |
| 544 | const Element *e = mType->getElement(); |
| 545 | uint32_t stride = e->getSizeBytes(); |
| 546 | |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 547 | p += stride * startOff; |
Jason Sams | b28ca96f | 2010-08-09 18:13:33 -0700 | [diff] [blame] | 548 | while (ct > 0) { |
| 549 | e->incRefs(p); |
| 550 | ct --; |
| 551 | p += stride; |
| 552 | } |
| 553 | } |
| 554 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 555 | void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const { |
Jason Sams | b28ca96f | 2010-08-09 18:13:33 -0700 | [diff] [blame] | 556 | const uint8_t *p = static_cast<const uint8_t *>(ptr); |
| 557 | const Element *e = mType->getElement(); |
| 558 | uint32_t stride = e->getSizeBytes(); |
| 559 | |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 560 | p += stride * startOff; |
Jason Sams | b28ca96f | 2010-08-09 18:13:33 -0700 | [diff] [blame] | 561 | while (ct > 0) { |
| 562 | e->decRefs(p); |
| 563 | ct --; |
| 564 | p += stride; |
| 565 | } |
| 566 | } |
| 567 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 568 | void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len) { |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 571 | void Allocation::resize1D(Context *rsc, uint32_t dimX) { |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 572 | Type *t = mType->cloneAndResize1D(rsc, dimX); |
| 573 | |
| 574 | uint32_t oldDimX = mType->getDimX(); |
| 575 | if (dimX == oldDimX) { |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | if (dimX < oldDimX) { |
| 580 | decRefs(mPtr, oldDimX - dimX, dimX); |
| 581 | } |
| 582 | mPtr = realloc(mPtr, t->getSizeBytes()); |
| 583 | |
| 584 | if (dimX > oldDimX) { |
| 585 | const Element *e = mType->getElement(); |
| 586 | uint32_t stride = e->getSizeBytes(); |
| 587 | memset(((uint8_t *)mPtr) + stride * oldDimX, 0, stride * (dimX - oldDimX)); |
| 588 | } |
| 589 | mType.set(t); |
| 590 | } |
| 591 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 592 | void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY) { |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 593 | LOGE("not implemented"); |
| 594 | } |
| 595 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 596 | ///////////////// |
Jason Sams | e2ae85f | 2009-06-03 16:04:54 -0700 | [diff] [blame] | 597 | // |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 598 | |
| 599 | |
| 600 | namespace android { |
| 601 | namespace renderscript { |
| 602 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 603 | void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, bool genmip, uint32_t baseMipLevel) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 604 | Allocation *alloc = static_cast<Allocation *>(va); |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 605 | alloc->deferedUploadToTexture(rsc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 606 | } |
| 607 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 608 | void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 609 | Allocation *alloc = static_cast<Allocation *>(va); |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 610 | alloc->deferedUploadToBufferObject(rsc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 611 | } |
| 612 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 613 | static void mip565(const Adapter2D &out, const Adapter2D &in) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 614 | uint32_t w = out.getDimX(); |
| 615 | uint32_t h = out.getDimY(); |
| 616 | |
Jason Sams | 6f5c61c | 2009-07-28 17:20:11 -0700 | [diff] [blame] | 617 | for (uint32_t y=0; y < h; y++) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 618 | uint16_t *oPtr = static_cast<uint16_t *>(out.getElement(0, y)); |
| 619 | const uint16_t *i1 = static_cast<uint16_t *>(in.getElement(0, y*2)); |
| 620 | const uint16_t *i2 = static_cast<uint16_t *>(in.getElement(0, y*2+1)); |
| 621 | |
Jason Sams | 6f5c61c | 2009-07-28 17:20:11 -0700 | [diff] [blame] | 622 | for (uint32_t x=0; x < w; x++) { |
Jason Sams | e2ae85f | 2009-06-03 16:04:54 -0700 | [diff] [blame] | 623 | *oPtr = rsBoxFilter565(i1[0], i1[1], i2[0], i2[1]); |
| 624 | oPtr ++; |
| 625 | i1 += 2; |
| 626 | i2 += 2; |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 631 | static void mip8888(const Adapter2D &out, const Adapter2D &in) { |
Jason Sams | e2ae85f | 2009-06-03 16:04:54 -0700 | [diff] [blame] | 632 | uint32_t w = out.getDimX(); |
| 633 | uint32_t h = out.getDimY(); |
| 634 | |
Jason Sams | 6f5c61c | 2009-07-28 17:20:11 -0700 | [diff] [blame] | 635 | for (uint32_t y=0; y < h; y++) { |
Jason Sams | e2ae85f | 2009-06-03 16:04:54 -0700 | [diff] [blame] | 636 | uint32_t *oPtr = static_cast<uint32_t *>(out.getElement(0, y)); |
| 637 | const uint32_t *i1 = static_cast<uint32_t *>(in.getElement(0, y*2)); |
| 638 | const uint32_t *i2 = static_cast<uint32_t *>(in.getElement(0, y*2+1)); |
| 639 | |
Jason Sams | 6f5c61c | 2009-07-28 17:20:11 -0700 | [diff] [blame] | 640 | for (uint32_t x=0; x < w; x++) { |
Jason Sams | e2ae85f | 2009-06-03 16:04:54 -0700 | [diff] [blame] | 641 | *oPtr = rsBoxFilter8888(i1[0], i1[1], i2[0], i2[1]); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 642 | oPtr ++; |
| 643 | i1 += 2; |
| 644 | i2 += 2; |
| 645 | } |
| 646 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 647 | } |
| 648 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 649 | static void mip8(const Adapter2D &out, const Adapter2D &in) { |
Jason Sams | e20e3b4 | 2010-01-19 17:53:54 -0800 | [diff] [blame] | 650 | uint32_t w = out.getDimX(); |
| 651 | uint32_t h = out.getDimY(); |
| 652 | |
| 653 | for (uint32_t y=0; y < h; y++) { |
| 654 | uint8_t *oPtr = static_cast<uint8_t *>(out.getElement(0, y)); |
| 655 | const uint8_t *i1 = static_cast<uint8_t *>(in.getElement(0, y*2)); |
| 656 | const uint8_t *i2 = static_cast<uint8_t *>(in.getElement(0, y*2+1)); |
| 657 | |
| 658 | for (uint32_t x=0; x < w; x++) { |
| 659 | *oPtr = (uint8_t)(((uint32_t)i1[0] + i1[1] + i2[0] + i2[1]) * 0.25f); |
| 660 | oPtr ++; |
| 661 | i1 += 2; |
| 662 | i2 += 2; |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 667 | static void mip(const Adapter2D &out, const Adapter2D &in) { |
| 668 | switch (out.getBaseType()->getElement()->getSizeBits()) { |
Jason Sams | 6f5c61c | 2009-07-28 17:20:11 -0700 | [diff] [blame] | 669 | case 32: |
| 670 | mip8888(out, in); |
| 671 | break; |
| 672 | case 16: |
| 673 | mip565(out, in); |
| 674 | break; |
Jason Sams | e20e3b4 | 2010-01-19 17:53:54 -0800 | [diff] [blame] | 675 | case 8: |
| 676 | mip8(out, in); |
| 677 | break; |
Jason Sams | 6f5c61c | 2009-07-28 17:20:11 -0700 | [diff] [blame] | 678 | } |
Jason Sams | 6f5c61c | 2009-07-28 17:20:11 -0700 | [diff] [blame] | 679 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 680 | |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 681 | #ifndef ANDROID_RS_BUILD_FOR_HOST |
| 682 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 683 | void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType src) { |
| 684 | Allocation *a = static_cast<Allocation *>(va); |
| 685 | a->syncAll(rsc, src); |
| 686 | } |
| 687 | |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 688 | void rsi_AllocationCopyFromBitmap(Context *rsc, RsAllocation va, const void *data, size_t dataLen) { |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 689 | Allocation *texAlloc = static_cast<Allocation *>(va); |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 690 | const Type * t = texAlloc->getType(); |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 691 | |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 692 | uint32_t w = t->getDimX(); |
| 693 | uint32_t h = t->getDimY(); |
| 694 | bool genMips = t->getDimLOD(); |
| 695 | size_t s = w * h * t->getElementSizeBytes(); |
| 696 | if (s != dataLen) { |
| 697 | rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size"); |
| 698 | return; |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 699 | } |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 700 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 701 | if (texAlloc->getIsScript()) { |
| 702 | memcpy(texAlloc->getPtr(), data, s); |
| 703 | if (genMips) { |
Alex Sakhartchouk | dcc2319 | 2011-01-11 14:47:44 -0800 | [diff] [blame] | 704 | rsaAllocationGenerateScriptMips(rsc, texAlloc); |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 705 | } |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 706 | } else { |
| 707 | texAlloc->upload2DTexture(false, data); |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 708 | } |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 709 | |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) { |
| 713 | Allocation *texAlloc = static_cast<Allocation *>(va); |
| 714 | const Type * t = texAlloc->getType(); |
| 715 | |
| 716 | size_t s = t->getDimX() * t->getDimY() * t->getElementSizeBytes(); |
| 717 | if (s != dataLen) { |
| 718 | rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size"); |
| 719 | return; |
| 720 | } |
| 721 | |
| 722 | memcpy(data, texAlloc->getPtr(), s); |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 723 | } |
| 724 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 725 | void rsi_Allocation1DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t lod, |
| 726 | uint32_t count, const void *data, uint32_t sizeBytes) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 727 | Allocation *a = static_cast<Allocation *>(va); |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 728 | a->data(rsc, xoff, lod, count, data, sizeBytes); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 729 | } |
| 730 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 731 | void rsi_Allocation2DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, uint32_t lod, RsAllocationCubemapFace face, |
| 732 | const void *data, uint32_t eoff, uint32_t sizeBytes) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 733 | Allocation *a = static_cast<Allocation *>(va); |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 734 | a->elementData(rsc, x, y, data, eoff, sizeBytes); |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 735 | } |
| 736 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 737 | void rsi_Allocation1DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t lod, |
| 738 | const void *data, uint32_t eoff, uint32_t sizeBytes) { |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 739 | Allocation *a = static_cast<Allocation *>(va); |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 740 | a->elementData(rsc, x, data, eoff, sizeBytes); |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 741 | } |
| 742 | |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 743 | void rsi_Allocation2DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, |
| 744 | uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) { |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 745 | Allocation *a = static_cast<Allocation *>(va); |
Jason Sams | 49a05d7 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 746 | a->data(rsc, xoff, yoff, lod, face, w, h, data, sizeBytes); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 747 | } |
| 748 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 749 | void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data) { |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 750 | Allocation *a = static_cast<Allocation *>(va); |
| 751 | a->read(data); |
| 752 | } |
| 753 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 754 | void rsi_AllocationResize1D(Context *rsc, RsAllocation va, uint32_t dimX) { |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 755 | Allocation *a = static_cast<Allocation *>(va); |
| 756 | a->resize1D(rsc, dimX); |
| 757 | } |
| 758 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 759 | void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32_t dimY) { |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 760 | Allocation *a = static_cast<Allocation *>(va); |
| 761 | a->resize2D(rsc, dimX, dimY); |
| 762 | } |
| 763 | |
Alex Sakhartchouk | 581cc64 | 2010-10-27 14:10:07 -0700 | [diff] [blame] | 764 | #endif //ANDROID_RS_BUILD_FOR_HOST |
| 765 | |
| 766 | } |
| 767 | } |
| 768 | |
Alex Sakhartchouk | dcc2319 | 2011-01-11 14:47:44 -0800 | [diff] [blame] | 769 | static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va) { |
| 770 | Context *rsc = static_cast<Context *>(con); |
| 771 | Allocation *texAlloc = static_cast<Allocation *>(va); |
| 772 | uint32_t numFaces = texAlloc->getType()->getDimFaces() ? 6 : 1; |
| 773 | for (uint32_t face = 0; face < numFaces; face ++) { |
| 774 | Adapter2D adapt(rsc, texAlloc); |
| 775 | Adapter2D adapt2(rsc, texAlloc); |
| 776 | adapt.setFace(face); |
| 777 | adapt2.setFace(face); |
| 778 | for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { |
| 779 | adapt.setLOD(lod); |
| 780 | adapt2.setLOD(lod + 1); |
| 781 | mip(adapt2, adapt); |
| 782 | } |
| 783 | } |
| 784 | } |
| 785 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 786 | const void * rsaAllocationGetType(RsContext con, RsAllocation va) { |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 787 | Allocation *a = static_cast<Allocation *>(va); |
| 788 | a->getType()->incUserRef(); |
| 789 | |
| 790 | return a->getType(); |
| 791 | } |
| 792 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 793 | RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype, |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 794 | RsAllocationMipmapControl mips, |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 795 | uint32_t usages) { |
Jason Sams | 31a7e42 | 2010-10-26 13:09:17 -0700 | [diff] [blame] | 796 | Context *rsc = static_cast<Context *>(con); |
Alex Sakhartchouk | 0857196 | 2010-12-15 09:59:58 -0800 | [diff] [blame] | 797 | Allocation * alloc = new Allocation(rsc, static_cast<Type *>(vtype), usages, mips); |
Jason Sams | 31a7e42 | 2010-10-26 13:09:17 -0700 | [diff] [blame] | 798 | alloc->incUserRef(); |
| 799 | return alloc; |
| 800 | } |
| 801 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 802 | |
| 803 | RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 804 | RsAllocationMipmapControl mips, |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 805 | const void *data, uint32_t usages) { |
Jason Sams | 31a7e42 | 2010-10-26 13:09:17 -0700 | [diff] [blame] | 806 | Context *rsc = static_cast<Context *>(con); |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 807 | Type *t = static_cast<Type *>(vtype); |
Jason Sams | 31a7e42 | 2010-10-26 13:09:17 -0700 | [diff] [blame] | 808 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 809 | RsAllocation vTexAlloc = rsaAllocationCreateTyped(rsc, vtype, mips, usages); |
Jason Sams | 31a7e42 | 2010-10-26 13:09:17 -0700 | [diff] [blame] | 810 | Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc); |
| 811 | if (texAlloc == NULL) { |
| 812 | LOGE("Memory allocation failure"); |
| 813 | return NULL; |
| 814 | } |
| 815 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 816 | memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes()); |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 817 | if (mips == RS_ALLOCATION_MIPMAP_FULL) { |
Alex Sakhartchouk | dcc2319 | 2011-01-11 14:47:44 -0800 | [diff] [blame] | 818 | rsaAllocationGenerateScriptMips(rsc, texAlloc); |
Jason Sams | 31a7e42 | 2010-10-26 13:09:17 -0700 | [diff] [blame] | 819 | } |
| 820 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 821 | texAlloc->deferedUploadToTexture(rsc); |
Jason Sams | 31a7e42 | 2010-10-26 13:09:17 -0700 | [diff] [blame] | 822 | return texAlloc; |
| 823 | } |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 824 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 825 | RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, |
Jason Sams | d4b23b5 | 2010-12-13 15:32:35 -0800 | [diff] [blame] | 826 | RsAllocationMipmapControl mips, |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 827 | const void *data, uint32_t usages) { |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 828 | Context *rsc = static_cast<Context *>(con); |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 829 | Type *t = static_cast<Type *>(vtype); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 830 | |
| 831 | // Cubemap allocation's faces should be Width by Width each. |
| 832 | // Source data should have 6 * Width by Width pixels |
| 833 | // Error checking is done in the java layer |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 834 | RsAllocation vTexAlloc = rsaAllocationCreateTyped(rsc, t, mips, usages); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 835 | Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc); |
| 836 | if (texAlloc == NULL) { |
| 837 | LOGE("Memory allocation failure"); |
| 838 | return NULL; |
| 839 | } |
| 840 | |
Alex Sakhartchouk | fe852e2 | 2011-01-10 15:57:57 -0800 | [diff] [blame] | 841 | uint32_t faceSize = t->getDimX(); |
| 842 | uint32_t strideBytes = faceSize * 6 * t->getElementSizeBytes(); |
| 843 | uint32_t copySize = faceSize * t->getElementSizeBytes(); |
| 844 | |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 845 | uint8_t *sourcePtr = (uint8_t*)data; |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 846 | for (uint32_t face = 0; face < 6; face ++) { |
| 847 | Adapter2D faceAdapter(rsc, texAlloc); |
| 848 | faceAdapter.setFace(face); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 849 | |
Alex Sakhartchouk | fe852e2 | 2011-01-10 15:57:57 -0800 | [diff] [blame] | 850 | for (uint32_t dI = 0; dI < faceSize; dI ++) { |
| 851 | memcpy(faceAdapter.getElement(0, dI), sourcePtr + strideBytes * dI, copySize); |
| 852 | } |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 853 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 854 | // Move the data pointer to the next cube face |
Alex Sakhartchouk | fe852e2 | 2011-01-10 15:57:57 -0800 | [diff] [blame] | 855 | sourcePtr += copySize; |
Alex Sakhartchouk | dcc2319 | 2011-01-11 14:47:44 -0800 | [diff] [blame] | 856 | } |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 857 | |
Alex Sakhartchouk | dcc2319 | 2011-01-11 14:47:44 -0800 | [diff] [blame] | 858 | if (mips == RS_ALLOCATION_MIPMAP_FULL) { |
| 859 | rsaAllocationGenerateScriptMips(rsc, texAlloc); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 860 | } |
| 861 | |
Jason Sams | 5e0035a | 2010-12-13 17:11:21 -0800 | [diff] [blame] | 862 | texAlloc->deferedUploadToTexture(rsc); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 863 | return texAlloc; |
| 864 | } |