shannon.woods@transgaming.com | bdf2d80 | 2013-02-28 23:16:20 +0000 | [diff] [blame] | 1 | #include "precompiled.h" |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2 | // |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3 | // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 4 | // Use of this source code is governed by a BSD-style license that can be |
| 5 | // found in the LICENSE file. |
| 6 | // |
| 7 | |
daniel@transgaming.com | 8fd34bd | 2011-02-18 02:52:14 +0000 | [diff] [blame] | 8 | // VertexDataManager.h: Defines the VertexDataManager, a class that |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 9 | // runs the Buffer translation process. |
| 10 | |
daniel@transgaming.com | 50aadb0 | 2012-11-28 21:06:11 +0000 | [diff] [blame] | 11 | #include "libGLESv2/renderer/VertexDataManager.h" |
shannon.woods@transgaming.com | d2811d6 | 2013-02-28 23:11:19 +0000 | [diff] [blame] | 12 | #include "libGLESv2/renderer/BufferStorage.h" |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 13 | |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 14 | #include "libGLESv2/Buffer.h" |
apatrick@chromium.org | ea09f9b | 2012-06-08 00:45:32 +0000 | [diff] [blame] | 15 | #include "libGLESv2/ProgramBinary.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 16 | #include "libGLESv2/Context.h" |
shannon.woods@transgaming.com | d2811d6 | 2013-02-28 23:11:19 +0000 | [diff] [blame] | 17 | #include "libGLESv2/renderer/VertexBuffer.h" |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 18 | |
| 19 | namespace |
| 20 | { |
| 21 | enum { INITIAL_STREAM_BUFFER_SIZE = 1024*1024 }; |
jbauman@chromium.org | 83b61bc | 2011-09-02 18:59:24 +0000 | [diff] [blame] | 22 | // This has to be at least 4k or else it fails on ATI cards. |
| 23 | enum { CONSTANT_VERTEX_BUFFER_SIZE = 4096 }; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 24 | } |
| 25 | |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 26 | namespace rx |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 27 | { |
| 28 | |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 29 | static int elementsInBuffer(const gl::VertexAttribute &attribute, int size) |
jbauman@chromium.org | 059fc15 | 2011-11-18 19:26:17 +0000 | [diff] [blame] | 30 | { |
| 31 | int stride = attribute.stride(); |
| 32 | return (size - attribute.mOffset % stride + (stride - attribute.typeSize())) / stride; |
| 33 | } |
| 34 | |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 35 | VertexDataManager::VertexDataManager(Renderer *renderer) : mRenderer(renderer) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 36 | { |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 37 | for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 38 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame^] | 39 | mCurrentValue[i].FloatValues[0] = std::numeric_limits<float>::quiet_NaN(); |
| 40 | mCurrentValue[i].FloatValues[1] = std::numeric_limits<float>::quiet_NaN(); |
| 41 | mCurrentValue[i].FloatValues[2] = std::numeric_limits<float>::quiet_NaN(); |
| 42 | mCurrentValue[i].FloatValues[3] = std::numeric_limits<float>::quiet_NaN(); |
| 43 | mCurrentValue[i].Type = GL_FLOAT; |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 44 | mCurrentValueBuffer[i] = NULL; |
jbauman@chromium.org | 83b61bc | 2011-09-02 18:59:24 +0000 | [diff] [blame] | 45 | mCurrentValueOffsets[i] = 0; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 46 | } |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 47 | |
daniel@transgaming.com | e4e4506 | 2012-12-20 20:56:53 +0000 | [diff] [blame] | 48 | mStreamingBuffer = new StreamingVertexBufferInterface(renderer, INITIAL_STREAM_BUFFER_SIZE); |
daniel@transgaming.com | 72b9e18 | 2011-04-13 14:58:33 +0000 | [diff] [blame] | 49 | |
| 50 | if (!mStreamingBuffer) |
| 51 | { |
| 52 | ERR("Failed to allocate the streaming vertex buffer."); |
| 53 | } |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | VertexDataManager::~VertexDataManager() |
| 57 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 58 | delete mStreamingBuffer; |
| 59 | |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 60 | for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 61 | { |
| 62 | delete mCurrentValueBuffer[i]; |
| 63 | } |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 64 | } |
| 65 | |
shannon.woods@transgaming.com | 709fee9 | 2013-02-28 23:10:37 +0000 | [diff] [blame] | 66 | static bool directStoragePossible(VertexBufferInterface* vb, const gl::VertexAttribute& attrib) |
| 67 | { |
| 68 | gl::Buffer *buffer = attrib.mBoundBuffer.get(); |
| 69 | BufferStorage *storage = buffer ? buffer->getStorage() : NULL; |
| 70 | |
shannon.woods@transgaming.com | 047dc62 | 2013-02-28 23:18:08 +0000 | [diff] [blame] | 71 | const bool isAligned = (attrib.stride() % 4 == 0) && (attrib.mOffset % 4 == 0); |
| 72 | |
| 73 | return storage && storage->supportsDirectBinding() && !vb->getVertexBuffer()->requiresConversion(attrib) && isAligned; |
shannon.woods@transgaming.com | 709fee9 | 2013-02-28 23:10:37 +0000 | [diff] [blame] | 74 | } |
| 75 | |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 76 | GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *translated, GLsizei instances) |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 77 | { |
daniel@transgaming.com | 72b9e18 | 2011-04-13 14:58:33 +0000 | [diff] [blame] | 78 | if (!mStreamingBuffer) |
| 79 | { |
| 80 | return GL_OUT_OF_MEMORY; |
| 81 | } |
| 82 | |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 83 | for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 84 | { |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 85 | translated[attributeIndex].active = (programBinary->getSemanticIndex(attributeIndex) != -1); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 86 | } |
| 87 | |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 88 | // Invalidate static buffers that don't contain matching attributes |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 89 | for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 90 | { |
daniel@transgaming.com | 72b9e18 | 2011-04-13 14:58:33 +0000 | [diff] [blame] | 91 | if (translated[i].active && attribs[i].mArrayEnabled) |
daniel@transgaming.com | c828b14 | 2010-05-12 03:42:04 +0000 | [diff] [blame] | 92 | { |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 93 | gl::Buffer *buffer = attribs[i].mBoundBuffer.get(); |
daniel@transgaming.com | e4e4506 | 2012-12-20 20:56:53 +0000 | [diff] [blame] | 94 | StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL; |
daniel@transgaming.com | c828b14 | 2010-05-12 03:42:04 +0000 | [diff] [blame] | 95 | |
shannon.woods@transgaming.com | a9a509e | 2013-02-28 23:10:44 +0000 | [diff] [blame] | 96 | if (staticBuffer && staticBuffer->getBufferSize() > 0 && staticBuffer->lookupAttribute(attribs[i]) == -1 && |
| 97 | !directStoragePossible(staticBuffer, attribs[i])) |
| 98 | { |
| 99 | buffer->invalidateStaticData(); |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // Reserve the required space in the buffers |
| 105 | for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) |
| 106 | { |
| 107 | if (translated[i].active && attribs[i].mArrayEnabled) |
| 108 | { |
| 109 | gl::Buffer *buffer = attribs[i].mBoundBuffer.get(); |
| 110 | StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL; |
| 111 | VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer); |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 112 | |
shannon.woods@transgaming.com | 709fee9 | 2013-02-28 23:10:37 +0000 | [diff] [blame] | 113 | if (!directStoragePossible(vertexBuffer, attribs[i])) |
apatrick@chromium.org | f99fbb7 | 2010-11-16 01:57:05 +0000 | [diff] [blame] | 114 | { |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 115 | if (staticBuffer) |
daniel@transgaming.com | 5ee2ad0 | 2011-01-08 05:46:20 +0000 | [diff] [blame] | 116 | { |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 117 | if (staticBuffer->getBufferSize() == 0) |
| 118 | { |
shannon.woods@transgaming.com | 709fee9 | 2013-02-28 23:10:37 +0000 | [diff] [blame] | 119 | int totalCount = elementsInBuffer(attribs[i], buffer->size()); |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 120 | staticBuffer->reserveVertexSpace(attribs[i], totalCount, 0); |
| 121 | } |
daniel@transgaming.com | 5ee2ad0 | 2011-01-08 05:46:20 +0000 | [diff] [blame] | 122 | } |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 123 | else |
daniel@transgaming.com | 838bcea | 2010-05-20 19:17:42 +0000 | [diff] [blame] | 124 | { |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 125 | mStreamingBuffer->reserveVertexSpace(attribs[i], count, instances); |
daniel@transgaming.com | 50aadb0 | 2012-11-28 21:06:11 +0000 | [diff] [blame] | 126 | } |
daniel@transgaming.com | 72b9e18 | 2011-04-13 14:58:33 +0000 | [diff] [blame] | 127 | } |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
| 131 | // Perform the vertex data translations |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 132 | for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 133 | { |
| 134 | if (translated[i].active) |
| 135 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 136 | if (attribs[i].mArrayEnabled) |
| 137 | { |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 138 | gl::Buffer *buffer = attribs[i].mBoundBuffer.get(); |
daniel@transgaming.com | 78624ca | 2011-04-22 04:17:57 +0000 | [diff] [blame] | 139 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 140 | if (!buffer && attribs[i].mPointer == NULL) |
| 141 | { |
| 142 | // This is an application error that would normally result in a crash, but we catch it and return an error |
| 143 | ERR("An enabled vertex array has no buffer and no pointer."); |
daniel@transgaming.com | 838bcea | 2010-05-20 19:17:42 +0000 | [diff] [blame] | 144 | return GL_INVALID_OPERATION; |
| 145 | } |
| 146 | |
daniel@transgaming.com | e4e4506 | 2012-12-20 20:56:53 +0000 | [diff] [blame] | 147 | StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL; |
| 148 | VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 149 | |
shannon.woods@transgaming.com | 7665541 | 2013-02-28 23:08:09 +0000 | [diff] [blame] | 150 | BufferStorage *storage = buffer ? buffer->getStorage() : NULL; |
shannon.woods@transgaming.com | 709fee9 | 2013-02-28 23:10:37 +0000 | [diff] [blame] | 151 | bool directStorage = directStoragePossible(vertexBuffer, attribs[i]); |
shannon.woods@transgaming.com | 7665541 | 2013-02-28 23:08:09 +0000 | [diff] [blame] | 152 | |
daniel@transgaming.com | 58f76fe | 2011-06-21 14:21:07 +0000 | [diff] [blame] | 153 | std::size_t streamOffset = -1; |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 154 | unsigned int outputElementSize = 0; |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 155 | |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 156 | if (directStorage) |
| 157 | { |
| 158 | outputElementSize = attribs[i].stride(); |
| 159 | streamOffset = attribs[i].mOffset + outputElementSize * start; |
| 160 | storage->markBufferUsage(); |
| 161 | } |
| 162 | else if (staticBuffer) |
daniel@transgaming.com | 838bcea | 2010-05-20 19:17:42 +0000 | [diff] [blame] | 163 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 164 | streamOffset = staticBuffer->lookupAttribute(attribs[i]); |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 165 | outputElementSize = staticBuffer->getVertexBuffer()->getSpaceRequired(attribs[i], 1, 0); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 166 | |
| 167 | if (streamOffset == -1) |
| 168 | { |
| 169 | // Convert the entire buffer |
shannon.woods@transgaming.com | 7665541 | 2013-02-28 23:08:09 +0000 | [diff] [blame] | 170 | int totalCount = elementsInBuffer(attribs[i], storage->getSize()); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 171 | int startIndex = attribs[i].mOffset / attribs[i].stride(); |
| 172 | |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 173 | streamOffset = staticBuffer->storeVertexAttributes(attribs[i], -startIndex, totalCount, 0); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | if (streamOffset != -1) |
| 177 | { |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 178 | streamOffset += (attribs[i].mOffset / attribs[i].stride()) * outputElementSize; |
daniel@transgaming.com | c41a6fe | 2012-01-27 15:39:04 +0000 | [diff] [blame] | 179 | |
| 180 | if (instances == 0 || attribs[i].mDivisor == 0) |
| 181 | { |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 182 | streamOffset += start * outputElementSize; |
daniel@transgaming.com | c41a6fe | 2012-01-27 15:39:04 +0000 | [diff] [blame] | 183 | } |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | else |
| 187 | { |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 188 | outputElementSize = mStreamingBuffer->getVertexBuffer()->getSpaceRequired(attribs[i], 1, 0); |
| 189 | streamOffset = mStreamingBuffer->storeVertexAttributes(attribs[i], start, count, instances); |
daniel@transgaming.com | 838bcea | 2010-05-20 19:17:42 +0000 | [diff] [blame] | 190 | } |
| 191 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 192 | if (streamOffset == -1) |
| 193 | { |
| 194 | return GL_OUT_OF_MEMORY; |
| 195 | } |
| 196 | |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 197 | translated[i].storage = directStorage ? storage : NULL; |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 198 | translated[i].vertexBuffer = vertexBuffer->getVertexBuffer(); |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 199 | translated[i].serial = directStorage ? storage->getSerial() : vertexBuffer->getSerial(); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 200 | translated[i].divisor = attribs[i].mDivisor; |
| 201 | |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 202 | translated[i].attribute = &attribs[i]; |
| 203 | translated[i].stride = outputElementSize; |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 204 | translated[i].offset = streamOffset; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 205 | } |
daniel@transgaming.com | 9a0606c | 2010-05-12 03:42:00 +0000 | [diff] [blame] | 206 | else |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 207 | { |
jbauman@chromium.org | 83b61bc | 2011-09-02 18:59:24 +0000 | [diff] [blame] | 208 | if (!mCurrentValueBuffer[i]) |
| 209 | { |
daniel@transgaming.com | e4e4506 | 2012-12-20 20:56:53 +0000 | [diff] [blame] | 210 | mCurrentValueBuffer[i] = new StreamingVertexBufferInterface(mRenderer, CONSTANT_VERTEX_BUFFER_SIZE); |
jbauman@chromium.org | 83b61bc | 2011-09-02 18:59:24 +0000 | [diff] [blame] | 211 | } |
| 212 | |
daniel@transgaming.com | e4e4506 | 2012-12-20 20:56:53 +0000 | [diff] [blame] | 213 | StreamingVertexBufferInterface *buffer = mCurrentValueBuffer[i]; |
jbauman@chromium.org | 83b61bc | 2011-09-02 18:59:24 +0000 | [diff] [blame] | 214 | |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame^] | 215 | if (memcmp(&mCurrentValue[i], &attribs[i].mCurrentValue, sizeof(gl::VertexAttribute::CurrentValueData)) != 0) |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 216 | { |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 217 | unsigned int requiredSpace = sizeof(float) * 4; |
| 218 | buffer->reserveRawDataSpace(requiredSpace); |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame^] | 219 | int streamOffset = buffer->storeRawData(attribs[i].mCurrentValue.FloatValues, requiredSpace); |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 220 | if (streamOffset == -1) |
jbauman@chromium.org | 83b61bc | 2011-09-02 18:59:24 +0000 | [diff] [blame] | 221 | { |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 222 | return GL_OUT_OF_MEMORY; |
jbauman@chromium.org | 83b61bc | 2011-09-02 18:59:24 +0000 | [diff] [blame] | 223 | } |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 224 | |
| 225 | mCurrentValueOffsets[i] = streamOffset; |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 226 | } |
| 227 | |
shannon.woods@transgaming.com | db1899c | 2013-02-28 23:08:33 +0000 | [diff] [blame] | 228 | translated[i].storage = NULL; |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 229 | translated[i].vertexBuffer = mCurrentValueBuffer[i]->getVertexBuffer(); |
jbauman@chromium.org | d8f3faa | 2011-09-02 01:10:47 +0000 | [diff] [blame] | 230 | translated[i].serial = mCurrentValueBuffer[i]->getSerial(); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 231 | translated[i].divisor = 0; |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 232 | |
daniel@transgaming.com | 4150d36 | 2012-12-20 21:07:43 +0000 | [diff] [blame] | 233 | translated[i].attribute = &attribs[i]; |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 234 | translated[i].stride = 0; |
jbauman@chromium.org | 83b61bc | 2011-09-02 18:59:24 +0000 | [diff] [blame] | 235 | translated[i].offset = mCurrentValueOffsets[i]; |
daniel@transgaming.com | 9a0606c | 2010-05-12 03:42:00 +0000 | [diff] [blame] | 236 | } |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 237 | } |
| 238 | } |
apatrick@chromium.org | f99fbb7 | 2010-11-16 01:57:05 +0000 | [diff] [blame] | 239 | |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 240 | for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) |
daniel@transgaming.com | 78624ca | 2011-04-22 04:17:57 +0000 | [diff] [blame] | 241 | { |
| 242 | if (translated[i].active && attribs[i].mArrayEnabled) |
| 243 | { |
daniel@transgaming.com | 3124048 | 2012-11-28 21:06:41 +0000 | [diff] [blame] | 244 | gl::Buffer *buffer = attribs[i].mBoundBuffer.get(); |
daniel@transgaming.com | 78624ca | 2011-04-22 04:17:57 +0000 | [diff] [blame] | 245 | |
| 246 | if (buffer) |
| 247 | { |
| 248 | buffer->promoteStaticUsage(count * attribs[i].typeSize()); |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
apatrick@chromium.org | f99fbb7 | 2010-11-16 01:57:05 +0000 | [diff] [blame] | 253 | return GL_NO_ERROR; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 254 | } |
| 255 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 256 | } |