blob: 4318e2b7a431af011a699b6a06048464316840d8 [file] [log] [blame]
Geoff Langf23eb282013-07-22 10:52:19 -04001//
2// Copyright (c) 2013 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// IndexRangeCache.h: Defines the rx::IndexRangeCache class which stores information about
8// ranges of indices.
9
10#ifndef LIBGLESV2_RENDERER_INDEXRANGECACHE_H_
11#define LIBGLESV2_RENDERER_INDEXRANGECACHE_H_
12
13#include "common/angleutils.h"
Jamie Madill3078d0f2014-02-04 16:04:06 -050014#include <map>
Geoff Langf23eb282013-07-22 10:52:19 -040015
16namespace rx
17{
18
19class IndexRangeCache
20{
21 public:
Geoff Langb23fc092013-08-06 10:43:14 -040022 void addRange(GLenum type, unsigned int offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx,
Geoff Langf23eb282013-07-22 10:52:19 -040023 unsigned int streamOffset);
Geoff Langb23fc092013-08-06 10:43:14 -040024 bool findRange(GLenum type, unsigned int offset, GLsizei count, unsigned int *outMinIndex,
Geoff Langf23eb282013-07-22 10:52:19 -040025 unsigned int *outMaxIndex, unsigned int *outStreamOffset) const;
26
27 void invalidateRange(unsigned int offset, unsigned int size);
28 void clear();
29
30 private:
31 struct IndexRange
32 {
33 GLenum type;
Geoff Langb23fc092013-08-06 10:43:14 -040034 unsigned int offset;
Geoff Langf23eb282013-07-22 10:52:19 -040035 GLsizei count;
36
37 IndexRange();
38 IndexRange(GLenum type, intptr_t offset, GLsizei count);
39
40 bool operator<(const IndexRange& rhs) const;
41 };
42
43 struct IndexBounds
44 {
45 unsigned int minIndex;
46 unsigned int maxIndex;
47 unsigned int streamOffset;
48
49 IndexBounds();
50 IndexBounds(unsigned int minIdx, unsigned int maxIdx, unsigned int offset);
51 };
52
53 typedef std::map<IndexRange, IndexBounds> IndexRangeMap;
54 IndexRangeMap mIndexRangeCache;
55};
56
57}
58
59#endif LIBGLESV2_RENDERER_INDEXRANGECACHE_H