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"
21 struct VertexAttribute;
22 struct VertexAttribCurrentValueData;
28 class StreamingVertexBufferInterface;
32 struct TranslatedAttribute
34 TranslatedAttribute() : active(false), attribute(NULL), currentValueType(GL_NONE),
35 offset(0), stride(0), vertexBuffer(NULL), storage(NULL),
36 serial(0), divisor(0) {};
39 const gl::VertexAttribute *attribute;
40 GLenum currentValueType;
42 unsigned int stride; // 0 means not to advance the read pointer at all
44 VertexBuffer *vertexBuffer;
50 class VertexDataManager
53 VertexDataManager(rx::Renderer *renderer);
54 virtual ~VertexDataManager();
56 gl::Error prepareVertexData(const gl::State &state, GLint start, GLsizei count,
57 TranslatedAttribute *outAttribs, GLsizei instances);
60 DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
62 gl::Error reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
63 const gl::VertexAttribCurrentValueData ¤tValue,
65 GLsizei instances) const;
67 void invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
68 const gl::VertexAttribCurrentValueData ¤tValue) const;
70 gl::Error storeAttribute(const gl::VertexAttribute &attrib,
71 const gl::VertexAttribCurrentValueData ¤tValue,
72 TranslatedAttribute *translated,
77 gl::Error storeCurrentValue(const gl::VertexAttribute &attrib,
78 const gl::VertexAttribCurrentValueData ¤tValue,
79 TranslatedAttribute *translated,
80 gl::VertexAttribCurrentValueData *cachedValue,
82 StreamingVertexBufferInterface *buffer);
84 rx::Renderer *const mRenderer;
86 StreamingVertexBufferInterface *mStreamingBuffer;
88 gl::VertexAttribCurrentValueData mCurrentValue[gl::MAX_VERTEX_ATTRIBS];
90 StreamingVertexBufferInterface *mCurrentValueBuffer[gl::MAX_VERTEX_ATTRIBS];
91 std::size_t mCurrentValueOffsets[gl::MAX_VERTEX_ATTRIBS];
96 #endif // LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_