Geoff Lang | f23eb28 | 2013-07-22 10:52:19 -0400 | [diff] [blame] | 1 | // |
| 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 Madill | 3078d0f | 2014-02-04 16:04:06 -0500 | [diff] [blame] | 14 | #include <map> |
Geoff Lang | f23eb28 | 2013-07-22 10:52:19 -0400 | [diff] [blame] | 15 | |
| 16 | namespace rx |
| 17 | { |
| 18 | |
| 19 | class IndexRangeCache |
| 20 | { |
| 21 | public: |
Geoff Lang | b23fc09 | 2013-08-06 10:43:14 -0400 | [diff] [blame] | 22 | void addRange(GLenum type, unsigned int offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx, |
Geoff Lang | f23eb28 | 2013-07-22 10:52:19 -0400 | [diff] [blame] | 23 | unsigned int streamOffset); |
Geoff Lang | b23fc09 | 2013-08-06 10:43:14 -0400 | [diff] [blame] | 24 | bool findRange(GLenum type, unsigned int offset, GLsizei count, unsigned int *outMinIndex, |
Geoff Lang | f23eb28 | 2013-07-22 10:52:19 -0400 | [diff] [blame] | 25 | 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 Lang | b23fc09 | 2013-08-06 10:43:14 -0400 | [diff] [blame] | 34 | unsigned int offset; |
Geoff Lang | f23eb28 | 2013-07-22 10:52:19 -0400 | [diff] [blame] | 35 | 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 |