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