blob: ac0cbfef3dacb261c0ea120f3226bce0089dc6cf [file] [log] [blame]
daniel@transgaming.comf8b58a02010-03-26 04:08:45 +00001//
2// Copyright (c) 2002-2010 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// geometry/IndexDataManager.h: Defines the IndexDataManager, a class that
8// runs the Buffer translation process for index buffers.
9
10#ifndef LIBGLESV2_GEOMETRY_INDEXDATAMANAGER_H_
11#define LIBGLESV2_GEOMETRY_INDEXDATAMANAGER_H_
12
13#include <bitset>
14#include <cstddef>
15
16#define GL_APICALL
17#include <GLES2/gl2.h>
18
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000019#include "libGLESv2/Context.h"
daniel@transgaming.comf8b58a02010-03-26 04:08:45 +000020
21namespace gl
22{
23
24class Buffer;
25class BufferBackEnd;
26class TranslatedIndexBuffer;
27struct FormatConverter;
28
29struct TranslatedIndexData
30{
31 GLuint minIndex;
32 GLuint maxIndex;
33 GLuint count;
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +000034 GLuint indexSize;
daniel@transgaming.comf8b58a02010-03-26 04:08:45 +000035
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +000036 const void *indices;
daniel@transgaming.comf8b58a02010-03-26 04:08:45 +000037
38 TranslatedIndexBuffer *buffer;
39 GLsizei offset;
40};
41
42class IndexDataManager
43{
44 public:
45 IndexDataManager(Context *context, BufferBackEnd *backend);
46 ~IndexDataManager();
47
daniel@transgaming.com41d8dd82010-05-12 03:45:03 +000048 GLenum preRenderValidate(GLenum mode, GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices, TranslatedIndexData *translated);
daniel@transgaming.comf8b58a02010-03-26 04:08:45 +000049
50 private:
daniel@transgaming.com41d8dd82010-05-12 03:45:03 +000051 std::size_t IndexDataManager::typeSize(GLenum type) const;
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +000052 std::size_t IndexDataManager::indexSize(GLenum type) const;
53 std::size_t spaceRequired(GLenum type, GLsizei count) const;
54 TranslatedIndexBuffer *prepareIndexBuffer(GLenum type, std::size_t requiredSpace);
daniel@transgaming.comf8b58a02010-03-26 04:08:45 +000055
56 Context *mContext;
57 BufferBackEnd *mBackend;
58
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +000059 bool mIntIndicesSupported;
60
61 TranslatedIndexBuffer *mStreamBufferShort;
62 TranslatedIndexBuffer *mStreamBufferInt;
daniel@transgaming.comf8b58a02010-03-26 04:08:45 +000063};
64
65}
66
67#endif // LIBGLESV2_GEOMETRY_INDEXDATAMANAGER_H_