2 // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 // VertexDataManager.h: Defines the VertexDataManager, a class that
8 // runs the Buffer translation process.
10 #ifndef LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
11 #define LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
13 #include "libGLESv2/Constants.h"
14 #include "libGLESv2/VertexAttribute.h"
15 #include "common/angleutils.h"
19 struct VertexAttribute;
21 struct VertexAttribCurrentValueData;
27 class StreamingVertexBufferInterface;
31 struct TranslatedAttribute
33 TranslatedAttribute() : active(false), attribute(NULL), currentValueType(GL_NONE),
34 offset(0), stride(0), vertexBuffer(NULL), storage(NULL),
35 serial(0), divisor(0) {};
38 const gl::VertexAttribute *attribute;
39 GLenum currentValueType;
41 unsigned int stride; // 0 means not to advance the read pointer at all
43 VertexBuffer *vertexBuffer;
49 class VertexDataManager
52 VertexDataManager(rx::Renderer *renderer);
53 virtual ~VertexDataManager();
55 gl::Error prepareVertexData(const gl::VertexAttribute attribs[], const gl::VertexAttribCurrentValueData currentValues[],
56 gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *outAttribs, GLsizei instances);
59 DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
61 gl::Error reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
62 const gl::VertexAttribCurrentValueData ¤tValue,
64 GLsizei instances) const;
66 void invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
67 const gl::VertexAttribCurrentValueData ¤tValue) const;
69 gl::Error storeAttribute(const gl::VertexAttribute &attrib,
70 const gl::VertexAttribCurrentValueData ¤tValue,
71 TranslatedAttribute *translated,
76 gl::Error storeCurrentValue(const gl::VertexAttribute &attrib,
77 const gl::VertexAttribCurrentValueData ¤tValue,
78 TranslatedAttribute *translated,
79 gl::VertexAttribCurrentValueData *cachedValue,
81 StreamingVertexBufferInterface *buffer);
83 rx::Renderer *const mRenderer;
85 StreamingVertexBufferInterface *mStreamingBuffer;
87 gl::VertexAttribCurrentValueData mCurrentValue[gl::MAX_VERTEX_ATTRIBS];
89 StreamingVertexBufferInterface *mCurrentValueBuffer[gl::MAX_VERTEX_ATTRIBS];
90 std::size_t mCurrentValueOffsets[gl::MAX_VERTEX_ATTRIBS];
95 #endif // LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_