blob: d0848ce7c7d46523374ef06552bfc1a1aac9f499 [file] [log] [blame]
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00001//
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00002// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00003// 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.com8fd34bd2011-02-18 02:52:14 +00007// VertexDataManager.h: Defines the VertexDataManager, a class that
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00008// runs the Buffer translation process.
9
Geoff Lang2b5420c2014-11-19 14:20:15 -050010#include "libANGLE/renderer/d3d/VertexDataManager.h"
11#include "libANGLE/renderer/d3d/BufferD3D.h"
12#include "libANGLE/renderer/d3d/VertexBuffer.h"
13#include "libANGLE/renderer/Renderer.h"
14#include "libANGLE/Buffer.h"
Geoff Lang7dd2e102014-11-10 15:19:26 -050015#include "libANGLE/Program.h"
Geoff Lang2b5420c2014-11-19 14:20:15 -050016#include "libANGLE/VertexAttribute.h"
17#include "libANGLE/State.h"
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +000018
19namespace
20{
21 enum { INITIAL_STREAM_BUFFER_SIZE = 1024*1024 };
jbauman@chromium.org83b61bc2011-09-02 18:59:24 +000022 // This has to be at least 4k or else it fails on ATI cards.
23 enum { CONSTANT_VERTEX_BUFFER_SIZE = 4096 };
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +000024}
25
daniel@transgaming.com31240482012-11-28 21:06:41 +000026namespace rx
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +000027{
28
Brandon Jones5bf98292014-06-06 17:19:38 -070029static int ElementsInBuffer(const gl::VertexAttribute &attrib, unsigned int size)
jbauman@chromium.org059fc152011-11-18 19:26:17 +000030{
Geoff Langa36ead42013-08-02 11:54:08 -040031 // Size cannot be larger than a GLsizei
32 if (size > static_cast<unsigned int>(std::numeric_limits<int>::max()))
33 {
34 size = static_cast<unsigned int>(std::numeric_limits<int>::max());
35 }
36
Brandon Jones5bf98292014-06-06 17:19:38 -070037 GLsizei stride = ComputeVertexAttributeStride(attrib);
38 return (size - attrib.offset % stride + (stride - ComputeVertexAttributeTypeSize(attrib))) / stride;
jbauman@chromium.org059fc152011-11-18 19:26:17 +000039}
40
Brandon Jones5bf98292014-06-06 17:19:38 -070041static int StreamingBufferElementCount(const gl::VertexAttribute &attrib, int vertexDrawCount, int instanceDrawCount)
Jamie Madill9b4f3842013-08-26 15:29:30 -040042{
43 // For instanced rendering, we draw "instanceDrawCount" sets of "vertexDrawCount" vertices.
44 //
45 // A vertex attribute with a positive divisor loads one instanced vertex for every set of
46 // non-instanced vertices, and the instanced vertex index advances once every "mDivisor" instances.
Brandon Jones5bf98292014-06-06 17:19:38 -070047 if (instanceDrawCount > 0 && attrib.divisor > 0)
Jamie Madill9b4f3842013-08-26 15:29:30 -040048 {
Gregoire Payen de La Garanderie2c7ea052015-01-07 12:47:35 +000049 // When instanceDrawCount is not a multiple attrib.divisor, the division must round up.
50 // For instance, with 5 non-instanced vertices and a divisor equal to 3, we need 2 instanced vertices.
51 return (instanceDrawCount + attrib.divisor - 1) / attrib.divisor;
Jamie Madill9b4f3842013-08-26 15:29:30 -040052 }
53
54 return vertexDrawCount;
55}
56
Jamie Madill93e13fb2014-11-06 15:27:25 -050057VertexDataManager::VertexDataManager(RendererD3D *renderer) : mRenderer(renderer)
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +000058{
daniel@transgaming.com31240482012-11-28 21:06:41 +000059 for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +000060 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +000061 mCurrentValue[i].FloatValues[0] = std::numeric_limits<float>::quiet_NaN();
62 mCurrentValue[i].FloatValues[1] = std::numeric_limits<float>::quiet_NaN();
63 mCurrentValue[i].FloatValues[2] = std::numeric_limits<float>::quiet_NaN();
64 mCurrentValue[i].FloatValues[3] = std::numeric_limits<float>::quiet_NaN();
65 mCurrentValue[i].Type = GL_FLOAT;
daniel@transgaming.com83921382011-01-08 05:46:00 +000066 mCurrentValueBuffer[i] = NULL;
jbauman@chromium.org83b61bc2011-09-02 18:59:24 +000067 mCurrentValueOffsets[i] = 0;
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +000068 }
daniel@transgaming.com83921382011-01-08 05:46:00 +000069
daniel@transgaming.come4e45062012-12-20 20:56:53 +000070 mStreamingBuffer = new StreamingVertexBufferInterface(renderer, INITIAL_STREAM_BUFFER_SIZE);
daniel@transgaming.com72b9e182011-04-13 14:58:33 +000071
72 if (!mStreamingBuffer)
73 {
74 ERR("Failed to allocate the streaming vertex buffer.");
75 }
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +000076}
77
78VertexDataManager::~VertexDataManager()
79{
daniel@transgaming.com83921382011-01-08 05:46:00 +000080 delete mStreamingBuffer;
81
daniel@transgaming.com31240482012-11-28 21:06:41 +000082 for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
daniel@transgaming.com83921382011-01-08 05:46:00 +000083 {
84 delete mCurrentValueBuffer[i];
85 }
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +000086}
87
Austin Kinrossbe0facc2015-01-07 16:22:29 -080088void VertexDataManager::hintUnmapAllResources(const gl::State &state)
89{
90 mStreamingBuffer->getVertexBuffer()->hintUnmapResource();
91
92 for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
93 {
94 const gl::VertexAttribute &attrib = state.getVertexAttribState(i);
95 if (attrib.enabled)
96 {
97 gl::Buffer *buffer = attrib.buffer.get();
98 BufferD3D *storage = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
99 StaticVertexBufferInterface *staticBuffer = storage ? storage->getStaticVertexBuffer() : NULL;
100
101 if (staticBuffer)
102 {
103 staticBuffer->getVertexBuffer()->hintUnmapResource();
104 }
105 }
106 }
107
108 for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
109 {
110 if (mCurrentValueBuffer[i] != NULL)
111 {
112 mCurrentValueBuffer[i]->getVertexBuffer()->hintUnmapResource();
113 }
114 }
115}
116
Shannon Woods1a965482014-09-22 18:00:32 -0400117gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint start, GLsizei count,
118 TranslatedAttribute *translated, GLsizei instances)
daniel@transgaming.com83921382011-01-08 05:46:00 +0000119{
daniel@transgaming.com72b9e182011-04-13 14:58:33 +0000120 if (!mStreamingBuffer)
121 {
Geoff Langf7100b92014-09-08 16:17:08 -0400122 return gl::Error(GL_OUT_OF_MEMORY, "Internal streaming vertex buffer is unexpectedly NULL.");
daniel@transgaming.com72b9e182011-04-13 14:58:33 +0000123 }
124
Jamie Madill6d113802014-08-25 15:47:52 -0400125 // Invalidate static buffers that don't contain matching attributes
daniel@transgaming.com31240482012-11-28 21:06:41 +0000126 for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000127 {
Geoff Lang7dd2e102014-11-10 15:19:26 -0500128 translated[attributeIndex].active = (state.getProgram()->getSemanticIndex(attributeIndex) != -1);
Shannon Woods1a965482014-09-22 18:00:32 -0400129 const gl::VertexAttribute &curAttrib = state.getVertexAttribState(attributeIndex);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000130
Shannon Woods1a965482014-09-22 18:00:32 -0400131 if (translated[attributeIndex].active && curAttrib.enabled)
daniel@transgaming.comc828b142010-05-12 03:42:04 +0000132 {
Shannon Woods1a965482014-09-22 18:00:32 -0400133 invalidateMatchingStaticData(curAttrib, state.getVertexAttribCurrentValue(attributeIndex));
shannon.woods@transgaming.coma9a509e2013-02-28 23:10:44 +0000134 }
135 }
136
137 // Reserve the required space in the buffers
138 for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
139 {
Shannon Woods1a965482014-09-22 18:00:32 -0400140 const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
141 if (translated[i].active && curAttrib.enabled)
shannon.woods@transgaming.coma9a509e2013-02-28 23:10:44 +0000142 {
Shannon Woods1a965482014-09-22 18:00:32 -0400143 gl::Error error = reserveSpaceForAttrib(curAttrib, state.getVertexAttribCurrentValue(i), count, instances);
Geoff Langf7100b92014-09-08 16:17:08 -0400144 if (error.isError())
apatrick@chromium.orgf99fbb72010-11-16 01:57:05 +0000145 {
Geoff Langf7100b92014-09-08 16:17:08 -0400146 return error;
daniel@transgaming.com72b9e182011-04-13 14:58:33 +0000147 }
daniel@transgaming.com83921382011-01-08 05:46:00 +0000148 }
149 }
150
151 // Perform the vertex data translations
daniel@transgaming.com31240482012-11-28 21:06:41 +0000152 for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
daniel@transgaming.com83921382011-01-08 05:46:00 +0000153 {
Shannon Woods1a965482014-09-22 18:00:32 -0400154 const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
daniel@transgaming.com83921382011-01-08 05:46:00 +0000155 if (translated[i].active)
156 {
Shannon Woods1a965482014-09-22 18:00:32 -0400157 if (curAttrib.enabled)
daniel@transgaming.com83921382011-01-08 05:46:00 +0000158 {
Shannon Woods1a965482014-09-22 18:00:32 -0400159 gl::Error error = storeAttribute(curAttrib, state.getVertexAttribCurrentValue(i),
160 &translated[i], start, count, instances);
161
Geoff Langf7100b92014-09-08 16:17:08 -0400162 if (error.isError())
163 {
Austin Kinrossbe0facc2015-01-07 16:22:29 -0800164 hintUnmapAllResources(state);
Geoff Langf7100b92014-09-08 16:17:08 -0400165 return error;
166 }
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000167 }
daniel@transgaming.com9a0606c2010-05-12 03:42:00 +0000168 else
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000169 {
jbauman@chromium.org83b61bc2011-09-02 18:59:24 +0000170 if (!mCurrentValueBuffer[i])
171 {
daniel@transgaming.come4e45062012-12-20 20:56:53 +0000172 mCurrentValueBuffer[i] = new StreamingVertexBufferInterface(mRenderer, CONSTANT_VERTEX_BUFFER_SIZE);
jbauman@chromium.org83b61bc2011-09-02 18:59:24 +0000173 }
174
Shannon Woods1a965482014-09-22 18:00:32 -0400175 gl::Error error = storeCurrentValue(curAttrib, state.getVertexAttribCurrentValue(i), &translated[i],
Geoff Langf7100b92014-09-08 16:17:08 -0400176 &mCurrentValue[i], &mCurrentValueOffsets[i],
177 mCurrentValueBuffer[i]);
178 if (error.isError())
179 {
Austin Kinrossbe0facc2015-01-07 16:22:29 -0800180 hintUnmapAllResources(state);
Geoff Langf7100b92014-09-08 16:17:08 -0400181 return error;
182 }
daniel@transgaming.com9a0606c2010-05-12 03:42:00 +0000183 }
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000184 }
185 }
apatrick@chromium.orgf99fbb72010-11-16 01:57:05 +0000186
Austin Kinrossbe0facc2015-01-07 16:22:29 -0800187 // Hint to unmap all the resources
188 hintUnmapAllResources(state);
189
daniel@transgaming.com31240482012-11-28 21:06:41 +0000190 for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
daniel@transgaming.com78624ca2011-04-22 04:17:57 +0000191 {
Shannon Woods1a965482014-09-22 18:00:32 -0400192 const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
193 if (translated[i].active && curAttrib.enabled)
daniel@transgaming.com78624ca2011-04-22 04:17:57 +0000194 {
Shannon Woods1a965482014-09-22 18:00:32 -0400195 gl::Buffer *buffer = curAttrib.buffer.get();
daniel@transgaming.com78624ca2011-04-22 04:17:57 +0000196
197 if (buffer)
198 {
Brandon Jonesd38f9262014-06-18 16:26:45 -0700199 BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation());
Shannon Woods1a965482014-09-22 18:00:32 -0400200 bufferImpl->promoteStaticUsage(count * ComputeVertexAttributeTypeSize(curAttrib));
daniel@transgaming.com78624ca2011-04-22 04:17:57 +0000201 }
202 }
203 }
204
Geoff Langf7100b92014-09-08 16:17:08 -0400205 return gl::Error(GL_NO_ERROR);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000206}
207
Jamie Madill6d113802014-08-25 15:47:52 -0400208void VertexDataManager::invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
209 const gl::VertexAttribCurrentValueData &currentValue) const
210{
211 gl::Buffer *buffer = attrib.buffer.get();
212
213 if (buffer)
214 {
215 BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation());
216 StaticVertexBufferInterface *staticBuffer = bufferImpl->getStaticVertexBuffer();
217
218 if (staticBuffer &&
219 staticBuffer->getBufferSize() > 0 &&
220 !staticBuffer->lookupAttribute(attrib, NULL) &&
221 !staticBuffer->directStoragePossible(attrib, currentValue))
222 {
223 bufferImpl->invalidateStaticData();
224 }
225 }
226}
227
Geoff Langf7100b92014-09-08 16:17:08 -0400228gl::Error VertexDataManager::reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
229 const gl::VertexAttribCurrentValueData &currentValue,
230 GLsizei count,
231 GLsizei instances) const
Jamie Madill6d113802014-08-25 15:47:52 -0400232{
233 gl::Buffer *buffer = attrib.buffer.get();
234 BufferD3D *bufferImpl = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
235 StaticVertexBufferInterface *staticBuffer = bufferImpl ? bufferImpl->getStaticVertexBuffer() : NULL;
236 VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
237
238 if (!vertexBuffer->directStoragePossible(attrib, currentValue))
239 {
240 if (staticBuffer)
241 {
242 if (staticBuffer->getBufferSize() == 0)
243 {
244 int totalCount = ElementsInBuffer(attrib, bufferImpl->getSize());
Geoff Langf7100b92014-09-08 16:17:08 -0400245 gl::Error error = staticBuffer->reserveVertexSpace(attrib, totalCount, 0);
246 if (error.isError())
Jamie Madill6d113802014-08-25 15:47:52 -0400247 {
Geoff Langf7100b92014-09-08 16:17:08 -0400248 return error;
Jamie Madill6d113802014-08-25 15:47:52 -0400249 }
250 }
251 }
252 else
253 {
254 int totalCount = StreamingBufferElementCount(attrib, count, instances);
255 ASSERT(!bufferImpl || ElementsInBuffer(attrib, bufferImpl->getSize()) >= totalCount);
256
Geoff Langf7100b92014-09-08 16:17:08 -0400257 gl::Error error = mStreamingBuffer->reserveVertexSpace(attrib, totalCount, instances);
258 if (error.isError())
Jamie Madill6d113802014-08-25 15:47:52 -0400259 {
Geoff Langf7100b92014-09-08 16:17:08 -0400260 return error;
Jamie Madill6d113802014-08-25 15:47:52 -0400261 }
262 }
263 }
264
Geoff Langf7100b92014-09-08 16:17:08 -0400265 return gl::Error(GL_NO_ERROR);
Jamie Madill6d113802014-08-25 15:47:52 -0400266}
267
Geoff Langf7100b92014-09-08 16:17:08 -0400268gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribute &attrib,
269 const gl::VertexAttribCurrentValueData &currentValue,
270 TranslatedAttribute *translated,
271 GLint start,
272 GLsizei count,
273 GLsizei instances)
Jamie Madillf41522b2014-08-18 16:39:49 -0400274{
275 gl::Buffer *buffer = attrib.buffer.get();
Jamie Madill2b976812014-08-25 15:47:49 -0400276 ASSERT(buffer || attrib.pointer);
Jamie Madillf41522b2014-08-18 16:39:49 -0400277
278 BufferD3D *storage = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
279 StaticVertexBufferInterface *staticBuffer = storage ? storage->getStaticVertexBuffer() : NULL;
280 VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
281 bool directStorage = vertexBuffer->directStoragePossible(attrib, currentValue);
282
283 unsigned int streamOffset = 0;
284 unsigned int outputElementSize = 0;
285
Jamie Madilld4b55a02015-01-09 14:21:49 -0500286 // Instanced vertices do not apply the 'start' offset
287 GLint firstVertexIndex = (instances > 0 && attrib.divisor > 0 ? 0 : start);
288
Jamie Madillf41522b2014-08-18 16:39:49 -0400289 if (directStorage)
290 {
291 outputElementSize = ComputeVertexAttributeStride(attrib);
Jamie Madilld4b55a02015-01-09 14:21:49 -0500292 streamOffset = attrib.offset + outputElementSize * firstVertexIndex;
Jamie Madillf41522b2014-08-18 16:39:49 -0400293 }
294 else if (staticBuffer)
295 {
Geoff Langf7100b92014-09-08 16:17:08 -0400296 gl::Error error = staticBuffer->getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize);
297 if (error.isError())
Jamie Madillf41522b2014-08-18 16:39:49 -0400298 {
Geoff Langf7100b92014-09-08 16:17:08 -0400299 return error;
Jamie Madillf41522b2014-08-18 16:39:49 -0400300 }
301
302 if (!staticBuffer->lookupAttribute(attrib, &streamOffset))
303 {
304 // Convert the entire buffer
305 int totalCount = ElementsInBuffer(attrib, storage->getSize());
306 int startIndex = attrib.offset / ComputeVertexAttributeStride(attrib);
307
Geoff Langf7100b92014-09-08 16:17:08 -0400308 gl::Error error = staticBuffer->storeVertexAttributes(attrib, currentValue, -startIndex, totalCount,
309 0, &streamOffset);
310 if (error.isError())
Jamie Madillf41522b2014-08-18 16:39:49 -0400311 {
Geoff Langf7100b92014-09-08 16:17:08 -0400312 return error;
Jamie Madillf41522b2014-08-18 16:39:49 -0400313 }
314 }
315
316 unsigned int firstElementOffset = (attrib.offset / ComputeVertexAttributeStride(attrib)) * outputElementSize;
Jamie Madilld4b55a02015-01-09 14:21:49 -0500317 unsigned int startOffset = (instances == 0 || attrib.divisor == 0) ? firstVertexIndex * outputElementSize : 0;
Jamie Madillf41522b2014-08-18 16:39:49 -0400318 if (streamOffset + firstElementOffset + startOffset < streamOffset)
319 {
Geoff Langf7100b92014-09-08 16:17:08 -0400320 return gl::Error(GL_OUT_OF_MEMORY);
Jamie Madillf41522b2014-08-18 16:39:49 -0400321 }
322
323 streamOffset += firstElementOffset + startOffset;
324 }
325 else
326 {
327 int totalCount = StreamingBufferElementCount(attrib, count, instances);
Geoff Langf7100b92014-09-08 16:17:08 -0400328 gl::Error error = mStreamingBuffer->getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize);
329 if (error.isError())
Jamie Madillf41522b2014-08-18 16:39:49 -0400330 {
Geoff Langf7100b92014-09-08 16:17:08 -0400331 return error;
332 }
333
Jamie Madilld4b55a02015-01-09 14:21:49 -0500334 error = mStreamingBuffer->storeVertexAttributes(attrib, currentValue, firstVertexIndex,
335 totalCount, instances, &streamOffset);
Geoff Langf7100b92014-09-08 16:17:08 -0400336 if (error.isError())
337 {
338 return error;
Jamie Madillf41522b2014-08-18 16:39:49 -0400339 }
340 }
341
342 translated->storage = directStorage ? storage : NULL;
343 translated->vertexBuffer = vertexBuffer->getVertexBuffer();
344 translated->serial = directStorage ? storage->getSerial() : vertexBuffer->getSerial();
345 translated->divisor = attrib.divisor;
346
347 translated->attribute = &attrib;
348 translated->currentValueType = currentValue.Type;
349 translated->stride = outputElementSize;
350 translated->offset = streamOffset;
351
Geoff Langf7100b92014-09-08 16:17:08 -0400352 return gl::Error(GL_NO_ERROR);
Jamie Madillf41522b2014-08-18 16:39:49 -0400353}
354
Geoff Langf7100b92014-09-08 16:17:08 -0400355gl::Error VertexDataManager::storeCurrentValue(const gl::VertexAttribute &attrib,
356 const gl::VertexAttribCurrentValueData &currentValue,
357 TranslatedAttribute *translated,
358 gl::VertexAttribCurrentValueData *cachedValue,
359 size_t *cachedOffset,
360 StreamingVertexBufferInterface *buffer)
Jamie Madillf41522b2014-08-18 16:39:49 -0400361{
362 if (*cachedValue != currentValue)
363 {
Geoff Langf7100b92014-09-08 16:17:08 -0400364 gl::Error error = buffer->reserveVertexSpace(attrib, 1, 0);
365 if (error.isError())
Jamie Madillf41522b2014-08-18 16:39:49 -0400366 {
Geoff Langf7100b92014-09-08 16:17:08 -0400367 return error;
Jamie Madillf41522b2014-08-18 16:39:49 -0400368 }
369
370 unsigned int streamOffset;
Geoff Langf7100b92014-09-08 16:17:08 -0400371 error = buffer->storeVertexAttributes(attrib, currentValue, 0, 1, 0, &streamOffset);
372 if (error.isError())
Jamie Madillf41522b2014-08-18 16:39:49 -0400373 {
Geoff Langf7100b92014-09-08 16:17:08 -0400374 return error;
Jamie Madillf41522b2014-08-18 16:39:49 -0400375 }
376
377 *cachedValue = currentValue;
378 *cachedOffset = streamOffset;
379 }
380
381 translated->storage = NULL;
382 translated->vertexBuffer = buffer->getVertexBuffer();
383 translated->serial = buffer->getSerial();
384 translated->divisor = 0;
385
386 translated->attribute = &attrib;
387 translated->currentValueType = currentValue.Type;
388 translated->stride = 0;
389 translated->offset = *cachedOffset;
390
Geoff Langf7100b92014-09-08 16:17:08 -0400391 return gl::Error(GL_NO_ERROR);
Jamie Madillf41522b2014-08-18 16:39:49 -0400392}
393
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000394}