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