1 // SwiftShader Software Renderer
\r
3 // Copyright(c) 2005-2012 TransGaming Inc.
\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,
\r
6 // transcribed, stored in a retrieval system, translated into any human or computer
\r
7 // language by any means, or disclosed to third parties without the explicit written
\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
\r
9 // or implied, including but not limited to any patent rights, are granted to you.
\r
12 // VertexDataManager.h: Defines the VertexDataManager, a class that
\r
13 // runs the Buffer translation process.
\r
15 #ifndef LIBGLESV2_VERTEXDATAMANAGER_H_
\r
16 #define LIBGLESV2_VERTEXDATAMANAGER_H_
\r
18 #include "Context.h"
\r
19 #include "Device.hpp"
\r
22 #include <GLES2/gl2.h>
\r
27 struct TranslatedAttribute
\r
29 sw::StreamType type;
\r
33 unsigned int offset;
\r
34 unsigned int stride; // 0 means not to advance the read pointer at all
\r
36 sw::Resource *vertexBuffer;
\r
42 VertexBuffer(unsigned int size);
\r
43 virtual ~VertexBuffer();
\r
47 sw::Resource *getResource() const;
\r
50 sw::Resource *mVertexBuffer;
\r
53 class ConstantVertexBuffer : public VertexBuffer
\r
56 ConstantVertexBuffer(float x, float y, float z, float w);
\r
57 ~ConstantVertexBuffer();
\r
60 class StreamingVertexBuffer : public VertexBuffer
\r
63 StreamingVertexBuffer(unsigned int size);
\r
64 ~StreamingVertexBuffer();
\r
66 void *map(const VertexAttribute &attribute, unsigned int requiredSpace, unsigned int *streamOffset);
\r
67 void reserveRequiredSpace();
\r
68 void addRequiredSpace(unsigned int requiredSpace);
\r
71 unsigned int mBufferSize;
\r
72 unsigned int mWritePosition;
\r
73 unsigned int mRequiredSpace;
\r
76 class VertexDataManager
\r
79 VertexDataManager(Context *context);
\r
80 virtual ~VertexDataManager();
\r
82 void dirtyCurrentValue(int index) { mDirtyCurrentValue[index] = true; }
\r
84 GLenum prepareVertexData(GLint start, GLsizei count, TranslatedAttribute *outAttribs);
\r
87 unsigned int writeAttributeData(StreamingVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute);
\r
89 Context *const mContext;
\r
91 StreamingVertexBuffer *mStreamingBuffer;
\r
93 bool mDirtyCurrentValue[MAX_VERTEX_ATTRIBS];
\r
94 ConstantVertexBuffer *mCurrentValueBuffer[MAX_VERTEX_ATTRIBS];
\r
99 #endif // LIBGLESV2_VERTEXDATAMANAGER_H_
\r