1 // 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. 5 // 6 7 // VertexDataManager.h: Defines the VertexDataManager, a class that 8 // runs the Buffer translation process. 9 10 #ifndef LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_ 11 #define LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_ 12 13 #include "libGLESv2/Constants.h" 14 #include "libGLESv2/VertexAttribute.h" 15 #include "common/angleutils.h" 16 17 namespace gl 18 { 19 struct VertexAttribute; 20 class ProgramBinary; 21 struct VertexAttribCurrentValueData; 22 } 23 24 namespace rx 25 { 26 class BufferD3D; 27 class StreamingVertexBufferInterface; 28 class VertexBuffer; 29 class Renderer; 30 31 struct TranslatedAttribute 32 { 33 TranslatedAttribute() : active(false), attribute(NULL), currentValueType(GL_NONE), 34 offset(0), stride(0), vertexBuffer(NULL), storage(NULL), 35 serial(0), divisor(0) {}; 36 bool active; 37 38 const gl::VertexAttribute *attribute; 39 GLenum currentValueType; 40 unsigned int offset; 41 unsigned int stride; // 0 means not to advance the read pointer at all 42 43 VertexBuffer *vertexBuffer; 44 BufferD3D *storage; 45 unsigned int serial; 46 unsigned int divisor; 47 }; 48 49 class VertexDataManager 50 { 51 public: 52 VertexDataManager(rx::Renderer *renderer); 53 virtual ~VertexDataManager(); 54 55 gl::Error prepareVertexData(const gl::VertexAttribute attribs[], const gl::VertexAttribCurrentValueData currentValues[], 56 gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *outAttribs, GLsizei instances); 57 58 private: 59 DISALLOW_COPY_AND_ASSIGN(VertexDataManager); 60 61 gl::Error reserveSpaceForAttrib(const gl::VertexAttribute &attrib, 62 const gl::VertexAttribCurrentValueData ¤tValue, 63 GLsizei count, 64 GLsizei instances) const; 65 66 void invalidateMatchingStaticData(const gl::VertexAttribute &attrib, 67 const gl::VertexAttribCurrentValueData ¤tValue) const; 68 69 gl::Error storeAttribute(const gl::VertexAttribute &attrib, 70 const gl::VertexAttribCurrentValueData ¤tValue, 71 TranslatedAttribute *translated, 72 GLint start, 73 GLsizei count, 74 GLsizei instances); 75 76 gl::Error storeCurrentValue(const gl::VertexAttribute &attrib, 77 const gl::VertexAttribCurrentValueData ¤tValue, 78 TranslatedAttribute *translated, 79 gl::VertexAttribCurrentValueData *cachedValue, 80 size_t *cachedOffset, 81 StreamingVertexBufferInterface *buffer); 82 83 rx::Renderer *const mRenderer; 84 85 StreamingVertexBufferInterface *mStreamingBuffer; 86 87 gl::VertexAttribCurrentValueData mCurrentValue[gl::MAX_VERTEX_ATTRIBS]; 88 89 StreamingVertexBufferInterface *mCurrentValueBuffer[gl::MAX_VERTEX_ATTRIBS]; 90 std::size_t mCurrentValueOffsets[gl::MAX_VERTEX_ATTRIBS]; 91 }; 92 93 } 94 95 #endif // LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_ 96