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