OSDN Git Service

Implement a Radiance prototype.
[android-x86/external-swiftshader.git] / src / Radiance / libRAD / IndexDataManager.h
1 // SwiftShader Software Renderer\r
2 //\r
3 // Copyright(c) 2005-2012 TransGaming Inc.\r
4 //\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
10 //\r
11 \r
12 // IndexDataManager.h: Defines the IndexDataManager, a class that\r
13 // runs the Buffer translation process for index buffers.\r
14 \r
15 #ifndef LIBGLESV2_INDEXDATAMANAGER_H_\r
16 #define LIBGLESV2_INDEXDATAMANAGER_H_\r
17 \r
18 #include "Context.h"\r
19 \r
20 #define GL_APICALL\r
21 #include <GLES2/gl2.h>\r
22 \r
23 namespace es2\r
24 {\r
25 \r
26 struct TranslatedIndexData\r
27 {\r
28     unsigned int minIndex;\r
29     unsigned int maxIndex;\r
30     unsigned int indexOffset;\r
31 \r
32     sw::Resource *indexBuffer;\r
33 };\r
34 \r
35 class StreamingIndexBuffer\r
36 {\r
37   public:\r
38     StreamingIndexBuffer(unsigned int initialSize);\r
39     virtual ~StreamingIndexBuffer();\r
40 \r
41     void *map(unsigned int requiredSpace, unsigned int *offset);\r
42         void unmap();\r
43     void reserveSpace(unsigned int requiredSpace, GLenum type);\r
44 \r
45         sw::Resource *getResource() const;\r
46 \r
47   private:\r
48     sw::Resource *mIndexBuffer;\r
49     unsigned int mBufferSize;\r
50     unsigned int mWritePosition;\r
51 };\r
52 \r
53 class IndexDataManager\r
54 {\r
55   public:\r
56     IndexDataManager();\r
57     virtual ~IndexDataManager();\r
58 \r
59     GLenum prepareIndexData(GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices, TranslatedIndexData *translated);\r
60 \r
61         static std::size_t typeSize(GLenum type);\r
62 \r
63   private:\r
64     StreamingIndexBuffer *mStreamingBuffer;\r
65 };\r
66 \r
67 }\r
68 \r
69 #endif   // LIBGLESV2_INDEXDATAMANAGER_H_\r