• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 // IndexDataManager.h: Defines the IndexDataManager, a class that
16 // runs the Buffer translation process for index buffers.
17 
18 #ifndef LIBGL_INDEXDATAMANAGER_H_
19 #define LIBGL_INDEXDATAMANAGER_H_
20 
21 #include "Context.h"
22 
23 #define _GDI32_
24 #include <windows.h>
25 #include <GL/GL.h>
26 #include <GL/glext.h>
27 
28 namespace gl
29 {
30 
31 struct TranslatedIndexData
32 {
33 	unsigned int minIndex;
34 	unsigned int maxIndex;
35 	unsigned int indexOffset;
36 
37 	sw::Resource *indexBuffer;
38 };
39 
40 class StreamingIndexBuffer
41 {
42 public:
43 	StreamingIndexBuffer(unsigned int initialSize);
44 	virtual ~StreamingIndexBuffer();
45 
46 	void *map(unsigned int requiredSpace, unsigned int *offset);
47 	void unmap();
48 	void reserveSpace(unsigned int requiredSpace, GLenum type);
49 
50 	sw::Resource *getResource() const;
51 
52 private:
53 	sw::Resource *mIndexBuffer;
54 	unsigned int mBufferSize;
55 	unsigned int mWritePosition;
56 };
57 
58 class IndexDataManager
59 {
60 public:
61 	IndexDataManager();
62 	virtual ~IndexDataManager();
63 
64 	GLenum prepareIndexData(GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices, TranslatedIndexData *translated);
65 
66 	static std::size_t typeSize(GLenum type);
67 
68 private:
69 	StreamingIndexBuffer *mStreamingBuffer;
70 };
71 
72 }
73 
74 #endif   // LIBGL_INDEXDATAMANAGER_H_
75