blob: d7e83d69c6dbd2c61a3a3eca5b50ec0d8df6e342 [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// 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 LIBGLES_CM_INDEXDATAMANAGER_H_
19#define LIBGLES_CM_INDEXDATAMANAGER_H_
20
21#include "Context.h"
22
23#include <GLES/gl.h>
24
25namespace es1
26{
27
28struct TranslatedIndexData
29{
30 unsigned int minIndex;
31 unsigned int maxIndex;
32 unsigned int indexOffset;
33
34 sw::Resource *indexBuffer;
35};
36
37class StreamingIndexBuffer
38{
39public:
40 StreamingIndexBuffer(unsigned int initialSize);
41 virtual ~StreamingIndexBuffer();
42
43 void *map(unsigned int requiredSpace, unsigned int *offset);
44 void unmap();
45 void reserveSpace(unsigned int requiredSpace, GLenum type);
46
47 sw::Resource *getResource() const;
48
49private:
50 sw::Resource *mIndexBuffer;
51 unsigned int mBufferSize;
52 unsigned int mWritePosition;
53};
54
55class IndexDataManager
56{
57public:
58 IndexDataManager();
59 virtual ~IndexDataManager();
60
61 GLenum prepareIndexData(GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices, TranslatedIndexData *translated);
62
63 static std::size_t typeSize(GLenum type);
64
65private:
66 StreamingIndexBuffer *mStreamingBuffer;
67};
68
69}
70
71#endif // LIBGLES_CM_INDEXDATAMANAGER_H_